Improvise the pgsql driver to keep the utility names used for different

operation like backup, restore, etc within it.

Also:
* improvised the color combination of the background process logger.
* Removed an unnecessary print statement from the
  get_storage_directory(..) function, also return None if STORAGE_DIR
  is set to None.
This commit is contained in:
Ashesh Vashi
2016-05-14 00:48:11 +05:30
parent 5348f6e96a
commit b22d73ec46
4 changed files with 41 additions and 11 deletions

View File

@@ -335,6 +335,7 @@ WHERE
for st in kwargs['server_types']:
if st.instanceOf(mgr.ver):
mgr.server_type = st.stype
mgr.server_cls = st
break
mgr.update_session()
@@ -1017,6 +1018,7 @@ class ServerManager(object):
self.ver = None
self.sversion = None
self.server_type = None
self.server_cls = None
self.password = None
self.sid = server.id
@@ -1188,6 +1190,7 @@ WHERE db.oid = {0}""".format(did))
self.ver = None
self.sversion = None
self.server_type = None
self.server_cls = None
self.password = None
self.update_session()
@@ -1203,6 +1206,7 @@ WHERE db.oid = {0}""".format(did))
self.ver = None
self.sversion = None
self.server_type = None
self.server_cls = None
self.password = None
self.update_session()
@@ -1221,6 +1225,18 @@ WHERE db.oid = {0}""".format(did))
managers[self.sid] = updated_mgr
session['__pgsql_server_managers'] = managers
def utility(self, operation):
"""
utility(operation)
Returns: name of the utility which used for the operation
"""
if self.server_cls is not None:
return self.server_cls.utility(operation, self.sversion)
return None
class Driver(BaseDriver):
"""

View File

@@ -28,12 +28,15 @@ def get_storage_directory():
), 'storage'
)
)
if storage_dir is None:
return None
username = current_user.email.split('@')[0]
if len(username) == 0 or username[0].isdigit():
username = 'pga_user_' + username
storage_dir = os.path.join(storage_dir, username)
print(storage_dir)
if not os.path.exists(storage_dir):
os.makedirs(storage_dir, int('700', 8))
@@ -55,7 +58,7 @@ def init_app(app):
)
)
if not os.path.isdir(storage_dir):
if storage_dir and not os.path.isdir(storage_dir):
if os.path.exists(storage_dir):
raise Exception(
'The value specified for as the storage directory is not a directory!'