Changeset View
Changeset View
Standalone View
Standalone View
swh/core/db/tests/db_testing.py
Show All 36 Lines | cmd = [ | ||||
"-v", | "-v", | ||||
"ON_ERROR_STOP=1", | "ON_ERROR_STOP=1", | ||||
"--command=%s" % query, | "--command=%s" % query, | ||||
dbname_or_service, | dbname_or_service, | ||||
] | ] | ||||
try: | try: | ||||
r = subprocess.run( | r = subprocess.run( | ||||
cmd, check=True, stdout=subprocess.PIPE, universal_newlines=True | cmd, | ||||
check=True, | |||||
stdout=subprocess.PIPE, | |||||
stderr=subprocess.PIPE, | |||||
universal_newlines=True, | |||||
) | ) | ||||
result = int(r.stdout.strip()) | result = int(r.stdout.strip()) | ||||
except Exception: # db not initialized | except Exception: # db not initialized | ||||
result = None | result = None | ||||
return result | return result | ||||
def pg_restore(dbname, dumpfile, dumptype="pg_dump"): | def pg_restore(dbname, dumpfile, dumptype="pg_dump"): | ||||
▲ Show 20 Lines • Show All 287 Lines • Show Last 20 Lines |