mirror of
https://github.com/codex-storage/deluge.git
synced 2025-02-22 16:18:15 +00:00
use os.path.join()
This commit is contained in:
parent
d889759b5d
commit
4c97301478
@ -30,9 +30,9 @@ CONFIG_DIR = xdg.BaseDirectory.save_config_path('deluge')
|
||||
|
||||
# the necessary substitutions are made at installation time
|
||||
INSTALL_PREFIX = '@datadir@'
|
||||
GLADE_DIR = INSTALL_PREFIX + '/share/deluge/glade'
|
||||
PIXMAP_DIR = INSTALL_PREFIX + '/share/deluge/pixmaps'
|
||||
PLUGIN_DIR = INSTALL_PREFIX + '/share/deluge/plugins'
|
||||
GLADE_DIR = os.path.join(INSTALL_PREFIX, 'share', 'deluge', 'glade')
|
||||
PIXMAP_DIR = os.path.join(INSTALL_PREFIX, 'share', 'deluge', 'pixmaps')
|
||||
PLUGIN_DIR = os.path.join(INSTALL_PREFIX, 'share', 'deluge', 'plugins')
|
||||
|
||||
def estimate_eta(state):
|
||||
try:
|
||||
@ -93,10 +93,10 @@ def ftime(seconds):
|
||||
|
||||
|
||||
def get_glade_file(fname):
|
||||
return GLADE_DIR + "/" + fname
|
||||
return os.path.join(GLADE_DIR, fname)
|
||||
|
||||
def get_pixmap(fname):
|
||||
return PIXMAP_DIR + "/" + fname
|
||||
return os.path.join(PIXMAP_DIR, fname)
|
||||
|
||||
def open_url_in_browser(dialog, link):
|
||||
try:
|
||||
|
@ -37,7 +37,7 @@
|
||||
# 3. supp_torrent_state - supplementary torrent data, from Deluge
|
||||
|
||||
import deluge_core
|
||||
import os, shutil, statvfs
|
||||
import os, os.path, shutil, statvfs
|
||||
import pickle
|
||||
import time
|
||||
import gettext
|
||||
@ -170,7 +170,7 @@ class Manager:
|
||||
|
||||
# Ensure directories exist
|
||||
if not TORRENTS_SUBDIR in os.listdir(self.base_dir):
|
||||
os.mkdir(self.base_dir + "/" + TORRENTS_SUBDIR)
|
||||
os.mkdir(os.path.join(self.base_dir, TORRENTS_SUBDIR))
|
||||
|
||||
# Pre-initialize the core's data structures
|
||||
deluge_core.pre_init(DelugeError,
|
||||
@ -210,7 +210,7 @@ class Manager:
|
||||
self.prefs = DEFAULT_PREFS
|
||||
if not blank_slate:
|
||||
try:
|
||||
pkl_file = open(self.base_dir + "/" + PREFS_FILENAME, 'rb')
|
||||
pkl_file = open(os.path.join(self.base_dir, PREFS_FILENAME), 'rb')
|
||||
self.prefs = pickle.load(pkl_file)
|
||||
pkl_file.close()
|
||||
except IOError:
|
||||
@ -222,14 +222,14 @@ class Manager:
|
||||
# Apply DHT, if needed. Note that this is before any torrents are added
|
||||
if self.get_pref('use_DHT'):
|
||||
if not blank_slate:
|
||||
deluge_core.start_DHT(self.base_dir + "/" + DHT_FILENAME)
|
||||
deluge_core.start_DHT(os.path.join(self.base_dir, DHT_FILENAME))
|
||||
else:
|
||||
deluge_core.start_DHT("")
|
||||
|
||||
# Unpickle the state, or create a new one
|
||||
if not blank_slate:
|
||||
try:
|
||||
pkl_file = open(self.base_dir + "/" + STATE_FILENAME, 'rb')
|
||||
pkl_file = open(os.path.join(self.base_dir, STATE_FILENAME), 'rb')
|
||||
self.state = pickle.load(pkl_file)
|
||||
pkl_file.close()
|
||||
|
||||
@ -252,13 +252,13 @@ class Manager:
|
||||
|
||||
# Pickle the prefs
|
||||
print "Pickling prefs..."
|
||||
output = open(self.base_dir + "/" + PREFS_FILENAME, 'wb')
|
||||
output = open(os.path.join(self.base_dir, PREFS_FILENAME), 'wb')
|
||||
pickle.dump(self.prefs, output)
|
||||
output.close()
|
||||
|
||||
# Pickle the state
|
||||
print "Pickling state..."
|
||||
output = open(self.base_dir + "/" + STATE_FILENAME, 'wb')
|
||||
output = open(os.path.join(self.base_dir, STATE_FILENAME), 'wb')
|
||||
pickle.dump(self.state, output)
|
||||
output.close()
|
||||
|
||||
@ -269,7 +269,7 @@ class Manager:
|
||||
# Stop DHT, if needed
|
||||
if self.get_pref('use_DHT'):
|
||||
print "Stopping DHT..."
|
||||
deluge_core.stop_DHT(self.base_dir + "/" + DHT_FILENAME)
|
||||
deluge_core.stop_DHT(os.path.join(self.base_dir, DHT_FILENAME))
|
||||
|
||||
# Shutdown torrent core
|
||||
print "Quitting the core..."
|
||||
@ -328,17 +328,17 @@ class Manager:
|
||||
for filedata in temp_fileinfo:
|
||||
filename = filedata['path']
|
||||
try:
|
||||
os.remove(temp.save_dir + "/" + filename)
|
||||
os.remove(os.path.join(temp.save_dir, filename))
|
||||
except OSError:
|
||||
pass # No file just means it wasn't downloaded, we can continue
|
||||
|
||||
# A function to try and reload a torrent from a previous session. This is
|
||||
# used in the event that Deluge crashes and a blank state is loaded.
|
||||
def add_old_torrent(self, filename, save_dir, compact):
|
||||
if not filename in os.listdir(self.base_dir + "/" + TORRENTS_SUBDIR):
|
||||
if not filename in os.listdir(os.path.join(self.base_dir, TORRENTS_SUBDIR)):
|
||||
raise InvalidTorrentError(_("File was not found") + ": " + filename)
|
||||
|
||||
full_new_name = self.base_dir + "/" + TORRENTS_SUBDIR + "/" + filename
|
||||
full_new_name = os.path.join(self.base_dir, TORRENTS_SUBDIR, filename)
|
||||
|
||||
# Create torrent object
|
||||
new_torrent = torrent_info(full_new_name, save_dir, compact)
|
||||
@ -353,7 +353,7 @@ class Manager:
|
||||
|
||||
# Load all NEW torrents in a directory. The GUI can call this every minute or so,
|
||||
# if one wants a directory to be 'watched' (personally, I think it should only be
|
||||
# done on user command).
|
||||
# done on user command).os.path.join(
|
||||
def autoload_directory(self, directory, save_dir, compact):
|
||||
for filename in os.listdir(directory):
|
||||
if filename[-len(".torrent"):].lower() == ".torrent":
|
||||
@ -614,7 +614,7 @@ class Manager:
|
||||
# if filename_short in os.listdir(self.base_dir + "/" + TORRENTS_SUBDIR):
|
||||
# raise DuplicateTorrentError("Duplicate Torrent, it appears: " + filename_short)
|
||||
|
||||
full_new_name = self.base_dir + "/" + TORRENTS_SUBDIR + "/" + filename_short
|
||||
full_new_name = os.path.join(self.base_dir, TORRENTS_SUBDIR, filename_short)
|
||||
|
||||
shutil.copy(filename, full_new_name)
|
||||
|
||||
|
@ -44,7 +44,7 @@ class DelugeGTK:
|
||||
self.ipc_manager = ipc_manager.Manager(self)
|
||||
self.torrent_file_queue = []
|
||||
#Load up a config file:
|
||||
self.conf_file = dcommon.CONFIG_DIR + '/deluge.conf'
|
||||
self.conf_file = os.path.join(dcommon.CONFIG_DIR, 'deluge.conf')
|
||||
if os.path.isdir(self.conf_file):
|
||||
print 'Weird, the file I was trying to write to, %s, is an existing directory'%(self.conf_file)
|
||||
sys.exit(0)
|
||||
@ -68,8 +68,8 @@ class DelugeGTK:
|
||||
#else: self.something_screwed_up = False
|
||||
self.plugins = delugeplugins.PluginManager(self.manager, self)
|
||||
self.plugins.add_plugin_dir(dcommon.PLUGIN_DIR)
|
||||
if os.path.isdir(dcommon.CONFIG_DIR + '/plugins'):
|
||||
self.plugins.add_plugin_dir(dcommon.CONFIG_DIR + '/plugins')
|
||||
if os.path.isdir(os.path.join(dcommon.CONFIG_DIR , 'plugins')):
|
||||
self.plugins.add_plugin_dir(os.path.join(dcommon.CONFIG_DIR, 'plugins'))
|
||||
self.plugins.scan_for_plugins()
|
||||
self.config = pref.Preferences()
|
||||
self.config.load_from_file(self.conf_file)
|
||||
@ -673,7 +673,7 @@ class DelugeGTK:
|
||||
restore_torrents = dgtk.show_popup_question(self.window,
|
||||
_("Would you like to attempt to reload the previous session's downloads?"))
|
||||
if restore_torrents:
|
||||
torrent_subdir = self.manager.base_dir + "/" + deluge.TORRENTS_SUBDIR
|
||||
torrent_subdir = os.path.join(self.manager.base_dir, deluge.TORRENTS_SUBDIR)
|
||||
for torrent in os.listdir(torrent_subdir):
|
||||
if torrent.endswith('.torrent'):
|
||||
self.interactive_add_torrent(torrent)
|
||||
|
@ -38,9 +38,9 @@ class PluginManager:
|
||||
for folder in self.plugin_dirs:
|
||||
plugin_folders = os.listdir(folder)
|
||||
for plugin in plugin_folders:
|
||||
if os.path.isfile(folder + "/" + plugin + "/plugin.py"):
|
||||
self.path = folder + "/" + plugin
|
||||
execfile(folder + "/" + plugin + "/plugin.py")
|
||||
if os.path.isfile(os.path.join(folder, plugin, "plugin.py")):
|
||||
self.path = os.path.join(folder, plugin)
|
||||
execfile(os.path.join(folder, plugin, "plugin.py"))
|
||||
|
||||
def get_available_plugins(self):
|
||||
return self.available_plugins.keys()
|
||||
|
Loading…
x
Reference in New Issue
Block a user