From 3b9d19b5244c8a88ca0b385c2ca91c0d91bfcb5a Mon Sep 17 00:00:00 2001 From: Frederic Massart Date: Tue, 4 Dec 2012 10:54:18 +0800 Subject: [PATCH] Can expand user directories from config file --- config-dist.json | 4 ++-- lib/backup.py | 2 +- lib/moodle.py | 2 +- lib/workplace.py | 6 +++--- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/config-dist.json b/config-dist.json index b4b3738..4efacc5 100644 --- a/config-dist.json +++ b/config-dist.json @@ -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 diff --git a/lib/backup.py b/lib/backup.py index c07b456..5473be2 100644 --- a/lib/backup.py +++ b/lib/backup.py @@ -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""" diff --git a/lib/moodle.py b/lib/moodle.py index 61d9042..500639b 100644 --- a/lib/moodle.py +++ b/lib/moodle.py @@ -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__), '..')) diff --git a/lib/workplace.py b/lib/workplace.py index c9bdc39..6cc113d 100644 --- a/lib/workplace.py +++ b/lib/workplace.py @@ -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 -- 2.11.0