r124 - in /debtorrent/trunk: DebTorrent/ConfigDir.py DebTorrent/download_bt1.py btdownloadheadless.py btlaunchmany.py

camrdale-guest at users.alioth.debian.org camrdale-guest at users.alioth.debian.org
Sat Jun 23 22:22:06 UTC 2007


Author: camrdale-guest
Date: Sat Jun 23 22:22:06 2007
New Revision: 124

URL: http://svn.debian.org/wsvn/debtorrent/?sc=1&rev=124
Log:
Add a config option to specify the directory to store config and cache files in.

Modified:
    debtorrent/trunk/DebTorrent/ConfigDir.py
    debtorrent/trunk/DebTorrent/download_bt1.py
    debtorrent/trunk/btdownloadheadless.py
    debtorrent/trunk/btlaunchmany.py

Modified: debtorrent/trunk/DebTorrent/ConfigDir.py
URL: http://svn.debian.org/wsvn/debtorrent/debtorrent/trunk/DebTorrent/ConfigDir.py?rev=124&op=diff
==============================================================================
--- debtorrent/trunk/DebTorrent/ConfigDir.py (original)
+++ debtorrent/trunk/DebTorrent/ConfigDir.py Sat Jun 23 22:22:06 2007
@@ -137,12 +137,15 @@
 
     ###### INITIALIZATION TASKS ######
 
-    def __init__(self, config_type = None):
+    def __init__(self, config_type = None, dir_root = ''):
         """Initialize the instance, create directories and file names.
         
         @type config_type: C{string}
         @param config_type: the extension to include in the saved files' names
             (optional, default is to use no extension)
+        @type dir_root: C{string}
+        @param dir_root: the root directory to save config files in
+            (optional, default is to use L{DIRNAME} in the user's home directory)
         
         """
         
@@ -152,31 +155,32 @@
         else:
             config_ext = ''
 
-        def check_sysvars(x):
-            """Check a system variable to see if it expands to something.
-            
-            @type x: C{string}
-            @param x: the system variable to check
-            @rtype: C{string}
-            @return: the expanded variable, or None if it doesn't expand
-            
-            """
-            
-            y = os.path.expandvars(x)
-            if y != x and os.path.isdir(y):
-                return y
-            return None
-
-        for d in ['${APPDATA}', '${HOME}', '${HOMEPATH}', '${USERPROFILE}']:
-            dir_root = check_sysvars(d)
-            if dir_root:
-                break
-        else:
-            dir_root = os.path.expanduser('~')
-            if not os.path.isdir(dir_root):
-                dir_root = os.path.abspath(os.path.dirname(sys.argv[0]))
-
-        dir_root = os.path.join(dir_root,DIRNAME)
+        if not dir_root:
+            def check_sysvars(x):
+                """Check a system variable to see if it expands to something.
+                
+                @type x: C{string}
+                @param x: the system variable to check
+                @rtype: C{string}
+                @return: the expanded variable, or None if it doesn't expand
+                
+                """
+                
+                y = os.path.expandvars(x)
+                if y != x and os.path.isdir(y):
+                    return y
+                return None
+    
+            for d in ['${APPDATA}', '${HOME}', '${HOMEPATH}', '${USERPROFILE}']:
+                dir_root = check_sysvars(d)
+                if dir_root:
+                    break
+            else:
+                dir_root = os.path.expanduser('~')
+                if not os.path.isdir(dir_root):
+                    dir_root = os.path.abspath(os.path.dirname(sys.argv[0]))
+    
+            dir_root = os.path.join(dir_root,DIRNAME)
         self.dir_root = dir_root
 
         if not os.path.isdir(self.dir_root):

Modified: debtorrent/trunk/DebTorrent/download_bt1.py
URL: http://svn.debian.org/wsvn/debtorrent/debtorrent/trunk/DebTorrent/download_bt1.py?rev=124&op=diff
==============================================================================
--- debtorrent/trunk/DebTorrent/download_bt1.py (original)
+++ debtorrent/trunk/DebTorrent/download_bt1.py Sat Jun 23 22:22:06 2007
@@ -212,6 +212,8 @@
     ('logfile', '', 'file to write the tracker logs, use - for stdout (default)'),
     ('allow_get', 0, 'use with allowed_dir; adds a /file?hash={hash} url that allows users to download the torrent file'),
     ('default_tracker', 'http://dttracker.debian.net:6969/announce', 'the default tracker address to use for new torrents'),
+    ('config_dir', '', 'the directory to use to get/store configuration and cache files, if not ' + 
+             'specified then a .DebTorrent directory in the user\'s home directory will be used')
     ]
 
 argslistheader = 'Arguments are:\n\n'
@@ -725,7 +727,7 @@
         if appdataobj:
             self.appdataobj = appdataobj
         elif self.selector_enabled:
-            self.appdataobj = ConfigDir()
+            self.appdataobj = ConfigDir(dir_root = config['config_dir'])
             self.appdataobj.deleteOldCacheData( config['expire_cache_data'],
                                                 [self.infohash] )
 

Modified: debtorrent/trunk/btdownloadheadless.py
URL: http://svn.debian.org/wsvn/debtorrent/debtorrent/trunk/btdownloadheadless.py?rev=124&op=diff
==============================================================================
--- debtorrent/trunk/btdownloadheadless.py (original)
+++ debtorrent/trunk/btdownloadheadless.py Sat Jun 23 22:22:06 2007
@@ -252,7 +252,10 @@
     
     h = HeadlessDisplayer()
     while 1:
-        configdir = ConfigDir('downloadheadless')
+        try:
+            configdir = ConfigDir('downloadheadless', params[params.index('--config_dir')+1])
+        except:
+            configdir = ConfigDir('downloadheadless')
         defaultsToIgnore = ['responsefile', 'url', 'priority']
         configdir.setDefaults(defaults,defaultsToIgnore)
         configdefaults = configdir.loadConfig()

Modified: debtorrent/trunk/btlaunchmany.py
URL: http://svn.debian.org/wsvn/debtorrent/debtorrent/trunk/btlaunchmany.py?rev=124&op=diff
==============================================================================
--- debtorrent/trunk/btlaunchmany.py (original)
+++ debtorrent/trunk/btlaunchmany.py Sat Jun 23 22:22:06 2007
@@ -146,7 +146,10 @@
           "2 = separate and run all architectures but all, " + "3 = separate and run both"),
     ] )
     try:
-        configdir = ConfigDir('launchmany')
+        try:
+            configdir = ConfigDir('launchmany', params[params.index('--config_dir')+1])
+        except:
+            configdir = ConfigDir('launchmany')
         defaultsToIgnore = ['responsefile', 'url', 'priority']
         configdir.setDefaults(defaults,defaultsToIgnore)
         configdefaults = configdir.loadConfig()




More information about the Debtorrent-commits mailing list