mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Fix unicode handling in the external process tools and show the complete command in the process viewer. Fixes #2963. Fixes #3157.
This commit is contained in:
parent
876ce1799a
commit
802269910c
@ -78,10 +78,20 @@ class BatchProcess(object):
|
|||||||
_("Could not find a process with the specified ID.")
|
_("Could not find a process with the specified ID.")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
try:
|
||||||
|
tmp_desc = loads(p.desc.encode('latin-1')) if \
|
||||||
|
IS_PY2 and hasattr(p.desc, 'encode') else loads(p.desc)
|
||||||
|
except UnicodeDecodeError:
|
||||||
|
tmp_desc = loads(p.desc.encode('utf-8')) if \
|
||||||
|
IS_PY2 and hasattr(p.desc, 'encode') else loads(p.desc)
|
||||||
|
except Exception as e:
|
||||||
|
tmp_desc = loads(p.desc.encode('utf-8', 'ignore')) if \
|
||||||
|
IS_PY2 and hasattr(p.desc, 'encode') else loads(p.desc)
|
||||||
|
|
||||||
# ID
|
# ID
|
||||||
self.id = _id
|
self.id = _id
|
||||||
# Description
|
# Description
|
||||||
self.desc = loads(p.desc)
|
self.desc = tmp_desc
|
||||||
# Status Acknowledged time
|
# Status Acknowledged time
|
||||||
self.atime = p.acknowledge
|
self.atime = p.acknowledge
|
||||||
# Command
|
# Command
|
||||||
@ -171,6 +181,16 @@ class BatchProcess(object):
|
|||||||
csv_writer.writerow(_args)
|
csv_writer.writerow(_args)
|
||||||
|
|
||||||
args_val = args_csv_io.getvalue().strip(str('\r\n'))
|
args_val = args_csv_io.getvalue().strip(str('\r\n'))
|
||||||
|
tmp_desc = dumps(self.desc)
|
||||||
|
try:
|
||||||
|
tmp_desc =tmp_desc.decode('utf-8') if\
|
||||||
|
IS_PY2 and hasattr(tmp_desc, 'decode') else tmp_desc
|
||||||
|
except UnicodeDecodeError:
|
||||||
|
tmp_desc = tmp_desc.decode('latin-1') if \
|
||||||
|
IS_PY2 and hasattr(tmp_desc, 'decode') else tmp_desc
|
||||||
|
except Exception:
|
||||||
|
tmp_desc = tmp_desc.decode('utf-8', 'ignore') if \
|
||||||
|
IS_PY2 and hasattr(tmp_desc, 'decode') else tmp_desc
|
||||||
|
|
||||||
j = Process(
|
j = Process(
|
||||||
pid=int(id),
|
pid=int(id),
|
||||||
@ -178,7 +198,7 @@ class BatchProcess(object):
|
|||||||
arguments=args_val.decode('utf-8', 'replace')
|
arguments=args_val.decode('utf-8', 'replace')
|
||||||
if IS_PY2 and hasattr(args_val, 'decode') else args_val,
|
if IS_PY2 and hasattr(args_val, 'decode') else args_val,
|
||||||
logdir=log_dir,
|
logdir=log_dir,
|
||||||
desc=dumps(self.desc),
|
desc=tmp_desc,
|
||||||
user_id=current_user.id
|
user_id=current_user.id
|
||||||
)
|
)
|
||||||
db.session.add(j)
|
db.session.add(j)
|
||||||
@ -534,7 +554,17 @@ class BatchProcess(object):
|
|||||||
etime = parser.parse(p.end_time or get_current_time())
|
etime = parser.parse(p.end_time or get_current_time())
|
||||||
|
|
||||||
execution_time = (etime - stime).total_seconds()
|
execution_time = (etime - stime).total_seconds()
|
||||||
desc = loads(p.desc)
|
desc = ""
|
||||||
|
try:
|
||||||
|
desc = loads(p.desc.encode('latin-1')) if \
|
||||||
|
IS_PY2 and hasattr(p.desc, 'encode') else loads(p.desc)
|
||||||
|
except UnicodeDecodeError:
|
||||||
|
desc = loads(p.desc.encode('utf-8')) if \
|
||||||
|
IS_PY2 and hasattr(p.desc, 'encode') else loads(p.desc)
|
||||||
|
except Exception:
|
||||||
|
desc = loads(p.desc.encode('utf-8', 'ignore')) if \
|
||||||
|
IS_PY2 and hasattr(p.desc, 'encode') else loads(p.desc)
|
||||||
|
|
||||||
details = desc
|
details = desc
|
||||||
|
|
||||||
if isinstance(desc, IProcessDesc):
|
if isinstance(desc, IProcessDesc):
|
||||||
|
@ -248,7 +248,7 @@ define('misc.bgprocess', [
|
|||||||
if (!self.notifier) {
|
if (!self.notifier) {
|
||||||
var header = $('<div></div>', {
|
var header = $('<div></div>', {
|
||||||
class: 'h5 pg-bg-notify-header',
|
class: 'h5 pg-bg-notify-header',
|
||||||
}).append($('<span></span>').text(self.desc)),
|
}).append($('<span></span>').text(_.unescape(self.desc))),
|
||||||
content = $('<div class="pg-bg-bgprocess row"></div>').append(
|
content = $('<div class="pg-bg-bgprocess row"></div>').append(
|
||||||
header
|
header
|
||||||
).append(
|
).append(
|
||||||
@ -366,7 +366,7 @@ define('misc.bgprocess', [
|
|||||||
self.logs[0].scrollTop = self.logs[0].scrollHeight;
|
self.logs[0].scrollTop = self.logs[0].scrollHeight;
|
||||||
});
|
});
|
||||||
// set bgprocess detailed description
|
// set bgprocess detailed description
|
||||||
$header.find('.bg-detailed-desc').html(self.detailed_desc);
|
$header.find('.bg-detailed-desc').html(_.unescape(self.detailed_desc));
|
||||||
}
|
}
|
||||||
|
|
||||||
// set bgprocess start time
|
// set bgprocess start time
|
||||||
@ -562,4 +562,4 @@ define('misc.bgprocess', [
|
|||||||
});
|
});
|
||||||
|
|
||||||
return pgBrowser.BackgroundProcessObsorver;
|
return pgBrowser.BackgroundProcessObsorver;
|
||||||
});
|
});
|
||||||
|
@ -97,11 +97,9 @@ class BackupMessage(IProcessDesc):
|
|||||||
|
|
||||||
def cmdArg(x):
|
def cmdArg(x):
|
||||||
if x:
|
if x:
|
||||||
# x = html.safe_str(x)
|
|
||||||
x = x.replace('\\', '\\\\')
|
x = x.replace('\\', '\\\\')
|
||||||
x = x.replace('"', '\\"')
|
x = x.replace('"', '\\"')
|
||||||
x = x.replace('""', '\\"')
|
x = x.replace('""', '\\"')
|
||||||
|
|
||||||
return ' "' + x + '"'
|
return ' "' + x + '"'
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
@ -111,6 +109,7 @@ class BackupMessage(IProcessDesc):
|
|||||||
else:
|
else:
|
||||||
self.cmd += cmdArg(arg)
|
self.cmd += cmdArg(arg)
|
||||||
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def message(self):
|
def message(self):
|
||||||
# Fetch the server details like hostname, port, roles etc
|
# Fetch the server details like hostname, port, roles etc
|
||||||
@ -189,7 +188,7 @@ class BackupMessage(IProcessDesc):
|
|||||||
res += '</div><div class="h5">'
|
res += '</div><div class="h5">'
|
||||||
res += _("Running command:")
|
res += _("Running command:")
|
||||||
res += '</b><br><span class="pg-bg-cmd enable-selection">'
|
res += '</b><br><span class="pg-bg-cmd enable-selection">'
|
||||||
res += html.safe_str(self.cmd)
|
res += html.safe_str(cmd + self.cmd)
|
||||||
res += '</span></div>'
|
res += '</span></div>'
|
||||||
|
|
||||||
return res
|
return res
|
||||||
|
Loading…
Reference in New Issue
Block a user