Can expand user directories from config file
authorFrederic Massart <fred@moodle.com>
Tue, 4 Dec 2012 02:54:18 +0000 (10:54 +0800)
committerFrederic Massart <fred@moodle.com>
Wed, 5 Dec 2012 06:15:09 +0000 (14:15 +0800)
config-dist.json
lib/backup.py
lib/moodle.py
lib/workplace.py

index b4b3738..4efacc5 100644 (file)
@@ -10,9 +10,9 @@
         // The web directory you are going to access Moodle from. A symlink will be created here.
         "www": "/var/www",
         // The directory where the instances will be stored
-        "storage": "/var/www/moodles",
+        "storage": "~/moodles",
         // A directory used by MDK to store different kind of things such as backups and cached repositories.
-        "moodle": "/home/fred/.moodle-sdk"
+        "moodle": "~/.moodle-sdk"
     },
 
     // List of remotes to work with
index c07b456..5473be2 100644 (file)
@@ -39,7 +39,7 @@ sqlfile = 'dump.sql'
 class BackupManager(object):
 
     def __init__(self):
-        self.path = os.path.join(C.get('dirs.moodle'), 'backup')
+        self.path = os.path.expanduser(os.path.join(C.get('dirs.moodle'), 'backup'))
 
     def create(self, M):
         """Creates a new backup of M"""
index 61d9042..500639b 100644 (file)
@@ -416,7 +416,7 @@ class Moodle(object):
     def runScript(self, scriptname, **kwargs):
         """Runs a script on the instance"""
         supported = ['php']
-        directories = ['~/.moodle-sdk', '/etc/moodle-sdk']
+        directories = ['~/.moodle-sdk']
         if C.get('dirs.moodle') != None:
             directories.insert(0, C.get('dirs.moodle'))
         directories.append(os.path.join(os.path.dirname(__file__), '..'))
index c9bdc39..6cc113d 100644 (file)
@@ -46,9 +46,9 @@ class Workplace(object):
             raise Exception('Directory %s not found' % path)
 
         # Directory paths
-        self.path = os.path.abspath(os.path.realpath(path))
-        self.cache = os.path.abspath(os.path.realpath(C.get('dirs.moodle')))
-        self.www = os.path.abspath(os.path.realpath(C.get('dirs.www')))
+        self.path = os.path.abspath(os.path.realpath(os.path.expanduser(path)))
+        self.cache = os.path.abspath(os.path.realpath(os.path.expanduser(C.get('dirs.moodle'))))
+        self.www = os.path.abspath(os.path.realpath(os.path.expanduser(C.get('dirs.www'))))
 
         # Directory names
         self.wwwDir = wwwDir