Code tidy.

This commit is contained in:
Dave Page
2016-06-21 14:21:06 +01:00
parent 3026b470e9
commit 7d0fe669ca
114 changed files with 3891 additions and 3680 deletions

View File

@@ -23,13 +23,12 @@ MODULE_NAME = 'bgprocess'
class BGProcessModule(PgAdminModule):
def get_own_javascripts(self):
return [{
'name': 'pgadmin.browser.bgprocess',
'path': url_for('bgprocess.static', filename='js/bgprocess'),
'when': None
}]
}]
def get_own_stylesheets(self):
"""
@@ -38,7 +37,7 @@ class BGProcessModule(PgAdminModule):
"""
stylesheets = [
url_for('bgprocess.static', filename='css/bgprocess.css')
]
]
return stylesheets
def get_own_messages(self):
@@ -59,6 +58,7 @@ class BGProcessModule(PgAdminModule):
'failed_with_exit_code': _("Failed (exit code: %%s).")
}
# Initialise the module
blueprint = BGProcessModule(
MODULE_NAME, __name__, url_prefix='/misc/bgprocess'

View File

@@ -41,17 +41,18 @@ import csv
import pytz
import codecs
# SQLite3 needs all string as UTF-8
# We need to make string for Python2/3 compatible
if sys.version_info < (3,):
from cStringIO import StringIO
def u(x):
return x
else:
from io import StringIO
def u(x):
if hasattr(x, 'decode'):
return x.decode()
@@ -299,7 +300,7 @@ def execute(configs):
shell=(os.name == 'nt'), close_fds=(os.name != 'nt')
)
try:
del(os.environ['PGPASSWORD'])
del (os.environ['PGPASSWORD'])
except:
pass
@@ -367,17 +368,17 @@ if __name__ == '__main__':
# Read command line arguments
parser = argparse.ArgumentParser(
description='Process executor for pgAdmin 4'
)
)
parser.add_argument(
'-p', '--process_id', help='Process ID', required=True
)
)
parser.add_argument(
'-d', '--db_file', help='Configuration Database', required=True
)
)
parser.add_argument(
'-o', '--output_directory',
help='Location where the logs will be created', required=True
)
)
args = parser.parse_args()
# Fetch bakcground process details from SQLite3 database file

View File

@@ -58,7 +58,6 @@ class IProcessDesc(object):
class BatchProcess(object):
def __init__(self, **kwargs):
self.id = self.desc = self.cmd = self.args = self.log_dir = \
@@ -105,7 +104,7 @@ class BatchProcess(object):
ctime = get_current_time(format='%y%m%d%H%M%S%f')
log_dir = os.path.join(
config.SESSION_DB_PATH, 'process_logs'
)
)
def random_number(size):
import random
@@ -184,7 +183,7 @@ class BatchProcess(object):
p = None
cmd = [
(sys.executable if not app.PGADMIN_RUNTIME else
'pythonw.exe' if os.name == 'nt' else 'python'),
'pythonw.exe' if os.name == 'nt' else 'python'),
executor,
'-p', self.id,
'-o', self.log_dir,
@@ -282,7 +281,7 @@ class BatchProcess(object):
execution_time = (etime - stime).total_seconds()
if process_output and self.ecode is not None and (
len(stdout) + len(stderr) < 3073
len(stdout) + len(stderr) < 3073
):
out, out_completed = read_log(
self.stdout, stdout, out, ctime, False