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.
pull/3/head
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

@ -7,13 +7,11 @@
#
##########################################################################
import six
from abc import ABCMeta, abstractmethod, abstractproperty
from flask import render_template
from flask.ext.babel import gettext
class ServerType:
class ServerType(object):
"""
Server Type
@ -72,5 +70,17 @@ class ServerType:
reverse=True
)
@classmethod
def utility(cls, operation, sverion):
if operation == 'backup':
return 'pg_dump'
if operation == 'backup_server':
return 'pg_dumpall'
if operation == 'restore':
return 'pg_restore'
return None
# Default Server Type
ServerType('pg', gettext("PostgreSQL"), -1)

View File

@ -85,24 +85,24 @@
.pg-panel-content div.bg-process-watcher.col-xs-12 {
height: 100%;
padding: 0px;
padding: 0px 0px 0px 0px;
WebkitTransition: all 1s;
transition: all 1s;
background-color: rgb(255, 239, 217);
}
ol.pg-bg-process-logs {
padding: 15px 15px 15px 60px;
padding: 5px 10px 5px 60px;
height: 100%;
overflow: auto;
width: 100%;
background: #000;
background: rgb(255, 239, 217);
}
.pg-bg-res-out, .pg-bg-res-err {
background-color: #000;
background-color: rgb(255, 239, 217);
padding-left: 10px;
white-space: pre-wrap;
font-size: 12px;
}
.pg-bg-res-out {
@ -117,6 +117,7 @@ ol.pg-bg-process-logs {
padding: 10px 15px;
min-height: 70px;
color: #000;
background-color: whitesmoke;
}
.pg-panel-content .bg-process-stats p{
@ -131,7 +132,7 @@ ol.pg-bg-process-logs {
padding: 10px 15px;
position: absolute;
bottom: 0;
background-color: white;
background-color: whitesmoke;
}
.pg-panel-content .bg-process-footer p {

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!'