diff --git a/webnotes/model/doctype.py b/webnotes/model/doctype.py index 52bfefa58b..c5e0d172ad 100644 --- a/webnotes/model/doctype.py +++ b/webnotes/model/doctype.py @@ -18,7 +18,7 @@ import webnotes import webnotes.model import webnotes.model.doc import webnotes.model.doclist -from webnotes.utils import cint +from webnotes.utils import cint, get_base_path doctype_cache = webnotes.local('doctype_doctype_cache') docfield_types = webnotes.local('doctype_docfield_types') @@ -281,7 +281,7 @@ def add_embedded_js(doc): doc.fields['__js'] = ((doc.fields.get('__js') or '') + '\n' + custom).encode("utf-8") def _sub(match): - fpath = os.path.join(os.path.dirname(conf.__file__), \ + fpath = os.path.join(get_base_path(), \ re.search('["\'][^"\']*["\']', match.group(0)).group(0)[1:-1]) if os.path.exists(fpath): with open(fpath, 'r') as f: diff --git a/webnotes/model/sync.py b/webnotes/model/sync.py index 82f284c02c..7392696263 100644 --- a/webnotes/model/sync.py +++ b/webnotes/model/sync.py @@ -10,6 +10,7 @@ import webnotes import os import conf from webnotes.modules.import_file import import_file +from webntoes.utils import get_base_path def sync_all(force=0): sync_for("lib", force) @@ -17,7 +18,7 @@ def sync_all(force=0): webnotes.clear_cache() def sync_for(folder, force=0, sync_everything = False): - return walk_and_sync(os.path.join(os.path.dirname(os.path.abspath(conf.__file__)), + return walk_and_sync(os.path.join(get_base_path(), folder), force, sync_everything) def walk_and_sync(start_path, force=0, sync_everything = False): @@ -46,4 +47,4 @@ def walk_and_sync(start_path, force=0, sync_everything = False): webnotes.conn.commit() - return modules \ No newline at end of file + return modules diff --git a/webnotes/modules/__init__.py b/webnotes/modules/__init__.py index 800482a8fe..b0d97a9408 100644 --- a/webnotes/modules/__init__.py +++ b/webnotes/modules/__init__.py @@ -26,7 +26,7 @@ def get_module_path(module): """Returns path of the given module""" m = scrub(module) - app_path = os.path.dirname(conf.__file__) + app_path = webnotes.utils.get_base_path() if m in ('core', 'website'): return os.path.join(app_path, 'lib', m) @@ -50,4 +50,4 @@ def export_doc(doctype, name, module=None): write_document_file(webnotes.model.doc.get(doctype, name), module) def get_doctype_module(doctype): - return webnotes.conn.get_value('DocType', doctype, 'module') \ No newline at end of file + return webnotes.conn.get_value('DocType', doctype, 'module') diff --git a/webnotes/utils/backups.py b/webnotes/utils/backups.py index f58130cf27..07421d4b6e 100644 --- a/webnotes/utils/backups.py +++ b/webnotes/utils/backups.py @@ -17,7 +17,7 @@ from datetime import datetime #Global constants verbose = 0 -import conf +from webnotes import conf #------------------------------------------------------------------------------- class BackupGenerator: """ @@ -70,8 +70,7 @@ class BackupGenerator: self.backup_path_db = this_file_path def zip_files(self): - # TODO use get_storage_base_path - files_path = os.path.join(os.path.dirname(os.path.abspath(conf.__file__)), 'public', 'files') + files_path = webnotes.utils.get_storage_path(conf.files_path) cmd_string = """tar -cf %s %s""" % (self.backup_path_files, files_path) err, out = webnotes.utils.execute_in_shell(cmd_string) @@ -186,10 +185,8 @@ def get_backup_path(): global backup_path if not backup_path: import os - from webnotes import conf # TODO Use get_storage_base_path - backup_path = os.path.join(os.path.dirname(os.path.abspath(conf.__file__)), - 'public', 'backups') + backup_path = webnotes.utils.get_storage_path(conf.backup_path) return backup_path #-------------------------------------------------------------------------------