1
0
Fork 0

Merge pull request #1118 from mmtj/logging-cleanup

Logging cleanup
This commit is contained in:
Amjith Ramanujam 2019-10-29 10:05:56 -07:00 committed by GitHub
commit 0f969aba0c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 32 additions and 33 deletions

View File

@ -100,6 +100,7 @@ Contributors:
* Pablo A. Bianchi (pabloab)
* Sebastian Janko (sebojanko)
* Pedro Ferrari (petobens)
* Martin Matejek (mmtj)
Creator:
--------

View File

@ -43,7 +43,7 @@ def pgcli_line_magic(line):
conn._pgcli = pgcli
# For convenience, print the connection alias
print ("Connected: {}".format(conn.name))
print("Connected: {}".format(conn.name))
try:
pgcli.run_cli()

View File

@ -132,14 +132,13 @@ class PGCli(object):
if configured_pager:
self.logger.info(
'Default pager found in config file: "{}"'.format(configured_pager)
'Default pager found in config file: "%s"', configured_pager
)
os.environ["PAGER"] = configured_pager
elif os_environ_pager:
self.logger.info(
'Default pager found in PAGER environment variable: "{}"'.format(
os_environ_pager
)
'Default pager found in PAGER environment variable: "%s"',
os_environ_pager,
)
os.environ["PAGER"] = os_environ_pager
else:
@ -672,7 +671,7 @@ class PGCli(object):
if self.pgspecial.timing_enabled:
# Only add humanized time display if > 1 second
if query.total_time > 1:
print (
print(
"Time: %0.03fs (%s), executed in: %0.03fs (%s)"
% (
query.total_time,
@ -682,7 +681,7 @@ class PGCli(object):
)
)
else:
print ("Time: %0.03fs" % query.total_time)
print("Time: %0.03fs" % query.total_time)
# Check if we need to update completions, in order of most
# to least drastic changes
@ -711,10 +710,10 @@ class PGCli(object):
self.prompt_app = self._build_cli(history)
if not self.less_chatty:
print ("Server: PostgreSQL", self.pgexecute.server_version)
print ("Version:", __version__)
print ("Chat: https://gitter.im/dbcli/pgcli")
print ("Home: http://pgcli.com")
print("Server: PostgreSQL", self.pgexecute.server_version)
print("Version:", __version__)
print("Chat: https://gitter.im/dbcli/pgcli")
print("Home: http://pgcli.com")
try:
while True:
@ -758,7 +757,7 @@ class PGCli(object):
except (PgCliQuitError, EOFError):
if not self.less_chatty:
print ("Goodbye!")
print("Goodbye!")
def _build_cli(self, history):
key_bindings = pgcli_bindings(self)
@ -1200,7 +1199,7 @@ def cli(
warn,
):
if version:
print ("Version:", __version__)
print("Version:", __version__)
sys.exit(0)
config_dir = os.path.dirname(config_location())
@ -1212,12 +1211,11 @@ def cli(
if os.path.exists(os.path.expanduser("~/.pgclirc")):
if not os.path.exists(config_full_path):
shutil.move(os.path.expanduser("~/.pgclirc"), config_full_path)
print ("Config file (~/.pgclirc) moved to new location", config_full_path)
print("Config file (~/.pgclirc) moved to new location", config_full_path)
else:
print ("Config file is now located at", config_full_path)
print (
"Please move the existing config file ~/.pgclirc to",
config_full_path,
print("Config file is now located at", config_full_path)
print(
"Please move the existing config file ~/.pgclirc to", config_full_path,
)
if list_dsn:
try:

View File

@ -36,11 +36,11 @@ def run_step(*args):
global DRY_RUN
cmd = args
print (" ".join(cmd))
print(" ".join(cmd))
if skip_step():
print ("--- Skipping...")
print("--- Skipping...")
elif DRY_RUN:
print ("--- Pretending to run...")
print("--- Pretending to run...")
else:
subprocess.check_output(cmd)
@ -99,7 +99,7 @@ if __name__ == "__main__":
checklist(checks)
ver = version("pgcli/__init__.py")
print ("Releasing Version:", ver)
print("Releasing Version:", ver)
parser = OptionParser()
parser.add_option(

View File

@ -48,7 +48,7 @@ def create_cn(hostname, password, username, dbname, port):
host=hostname, user=username, database=dbname, password=password, port=port
)
print ("Created connection: {0}.".format(cn.dsn))
print("Created connection: {0}.".format(cn.dsn))
return cn
@ -79,4 +79,4 @@ def close_cn(cn=None):
"""
if cn:
cn.close()
print ("Closed connection: {0}.".format(cn.dsn))
print("Closed connection: {0}.".format(cn.dsn))

View File

@ -29,8 +29,8 @@ def before_all(context):
)
fixture_dir = os.path.join(context.package_root, "tests/features/fixture_data")
print ("package root:", context.package_root)
print ("fixture dir:", fixture_dir)
print("package root:", context.package_root)
print("fixture dir:", fixture_dir)
os.environ["COVERAGE_PROCESS_START"] = os.path.join(
context.package_root, ".coveragerc"
@ -123,14 +123,14 @@ def before_all(context):
def show_env_changes(env_old, env_new):
"""Print out all test-specific env values."""
print ("--- os.environ changed values: ---")
print("--- os.environ changed values: ---")
all_keys = set(list(env_old.keys()) + list(env_new.keys()))
for k in sorted(all_keys):
old_value = env_old.get(k, "")
new_value = env_new.get(k, "")
if new_value and old_value != new_value:
print ('{}="{}"'.format(k, new_value))
print ("-" * 20)
print('{}="{}"'.format(k, new_value))
print("-" * 20)
def after_all(context):
@ -181,7 +181,7 @@ def after_scenario(context, scenario):
try:
context.cli.expect_exact(pexpect.EOF, timeout=15)
except pexpect.TIMEOUT:
print ("--- after_scenario {}: kill cli".format(scenario.name))
print("--- after_scenario {}: kill cli".format(scenario.name))
context.cli.kill(signal.SIGKILL)
if hasattr(context, "tmpfile_sql_help") and context.tmpfile_sql_help:
context.tmpfile_sql_help.close()

View File

@ -22,7 +22,7 @@ def read_fixture_files():
"""Read all files inside fixture_data directory."""
current_dir = os.path.dirname(__file__)
fixture_dir = os.path.join(current_dir, "fixture_data/")
print ("reading fixture data: {}".format(fixture_dir))
print("reading fixture data: {}".format(fixture_dir))
fixture_dict = {}
for filename in os.listdir(fixture_dir):
if filename not in [".", ".."]:

View File

@ -3,13 +3,13 @@ import sys
def wrappager(boundary):
print (boundary)
print(boundary)
while 1:
buf = sys.stdin.read(2048)
if not buf:
break
sys.stdout.write(buf)
print (boundary)
print(boundary)
if __name__ == "__main__":