From 957f2506655f3ecb0e866e2b0f17f18f265ff85c Mon Sep 17 00:00:00 2001 From: Arinerron Date: Fri, 29 Mar 2019 17:21:02 -0700 Subject: [PATCH] Change print to logger functions and provide context --- onionr/onionr.py | 2 +- onionr/onionrcommands/__init__.py | 2 +- onionr/onionrcommands/onionrstatistics.py | 6 +++--- onionr/static-data/default-plugins/cliui/main.py | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/onionr/onionr.py b/onionr/onionr.py index 532c87d5..a5993eeb 100755 --- a/onionr/onionr.py +++ b/onionr/onionr.py @@ -123,7 +123,7 @@ class Onionr: config.set('client.client.port', randomPort, savefile=True) if type(config.get('client.public.port')) is type(None): randomPort = netcontroller.getOpenPort() - print(randomPort) + logger.debug('Random port chosen: %s' % randomPort) config.set('client.public.port', randomPort, savefile=True) if type(config.get('client.participate')) is type(None): config.set('client.participate', True, savefile=True) diff --git a/onionr/onionrcommands/__init__.py b/onionr/onionrcommands/__init__.py index bf10f4ed..bd456a5c 100644 --- a/onionr/onionrcommands/__init__.py +++ b/onionr/onionrcommands/__init__.py @@ -46,7 +46,7 @@ def open_home(o_inst): logger.error('Onionr seems to not be running (could not get api host)') else: url = 'http://%s/#%s' % (url, o_inst.onionrCore.config.get('client.webpassword')) - print('If Onionr does not open automatically, use this URL:', url) + logger.info('If Onionr does not open automatically, use this URL:\n\n%s' % url) webbrowser.open_new_tab(url) def get_commands(onionr_inst): diff --git a/onionr/onionrcommands/onionrstatistics.py b/onionr/onionrcommands/onionrstatistics.py index 04264655..fd478b66 100644 --- a/onionr/onionrcommands/onionrstatistics.py +++ b/onionr/onionrcommands/onionrstatistics.py @@ -104,7 +104,7 @@ def show_peers(o_inst): if not type(peers) is None: if peers not in ('', 'failure', None): if peers != False: - print(peers) + logger.info('Peers: %s' % peers) else: - print('Daemon probably not running. Unable to list connected peers.') - break \ No newline at end of file + logger.warn('Daemon probably not running. Unable to list connected peers.') + break diff --git a/onionr/static-data/default-plugins/cliui/main.py b/onionr/static-data/default-plugins/cliui/main.py index e1398a13..2653c755 100755 --- a/onionr/static-data/default-plugins/cliui/main.py +++ b/onionr/static-data/default-plugins/cliui/main.py @@ -82,12 +82,12 @@ class OnionrCLIUI: if self.flow_enabled: self.subCommand("flow") else: - print('Plugin not enabled') + logger.warn('flow plugin is not enabled') elif choice in ("2", "mail"): if self.mail_enabled: self.subCommand("mail") else: - print('Plugin not enabled') + logger.warn('mail plugin not enabled') elif choice in ("3", "file sharing", "file"): filename = input("Enter full path to file: ").strip() self.subCommand("addfile", filename)