Browse Source

Whitelist classes in verbose (-v) option

3.2.x
Janus 7 years ago
committed by ThomasV
parent
commit
780b2d067c
  1. 2
      electrum/commands.py
  2. 1
      electrum/interface.py
  3. 1
      electrum/network.py
  4. 1
      electrum/plugin.py
  5. 16
      electrum/util.py
  6. 1
      electrum/wallet.py
  7. 4
      run_electrum

2
electrum/commands.py

@ -829,7 +829,7 @@ def add_network_options(parser):
def add_global_options(parser):
group = parser.add_argument_group('global options')
group.add_argument("-v", "--verbose", action="store_true", dest="verbose", default=False, help="Show debugging information")
group.add_argument("-v", "--verbosity", dest="verbosity", default='', help="Set verbosity filter")
group.add_argument("-D", "--dir", dest="electrum_path", help="electrum directory")
group.add_argument("-P", "--portable", action="store_true", dest="portable", default=False, help="Use local 'electrum_data' directory")
group.add_argument("-w", "--wallet", dest="wallet_path", help="wallet path")

1
electrum/interface.py

@ -59,6 +59,7 @@ def Connection(server, queue, config_path):
class TcpConnection(threading.Thread, util.PrintError):
verbosity_filter = 'i'
def __init__(self, server, queue, config_path):
threading.Thread.__init__(self)

1
electrum/network.py

@ -170,6 +170,7 @@ class Network(util.DaemonThread):
get_parameters(), get_server_height(), get_status_value(),
is_connected(), set_parameters(), stop()
"""
verbosity_filter = 'n'
def __init__(self, config=None):
if config is None:

1
electrum/plugin.py

@ -43,6 +43,7 @@ hooks = {}
class Plugins(DaemonThread):
verbosity_filter = 'p'
@profiler
def __init__(self, config, is_local, gui_name):

16
electrum/util.py

@ -164,12 +164,14 @@ class MyEncoder(json.JSONEncoder):
class PrintError(object):
'''A handy base class'''
verbosity_filter = ''
def diagnostic_name(self):
return self.__class__.__name__
def print_error(self, *msg):
# only prints with --verbose flag
print_error("[%s]" % self.diagnostic_name(), *msg)
if self.verbosity_filter in verbosity:
print_stderr("[%s]" % self.diagnostic_name(), *msg)
def print_stderr(self, *msg):
print_stderr("[%s]" % self.diagnostic_name(), *msg)
@ -213,6 +215,7 @@ class DebugMem(ThreadJob):
class DaemonThread(threading.Thread, PrintError):
""" daemon thread that terminates cleanly """
verbosity_filter = 'd'
def __init__(self):
threading.Thread.__init__(self)
@ -263,15 +266,14 @@ class DaemonThread(threading.Thread, PrintError):
self.print_error("stopped")
# TODO: disable
is_verbose = True
verbosity = ''
def set_verbosity(b):
global is_verbose
is_verbose = b
global verbosity
verbosity = b
def print_error(*args):
if not is_verbose: return
if not verbosity: return
print_stderr(*args)
def print_stderr(*args):

1
electrum/wallet.py

@ -165,6 +165,7 @@ class Abstract_Wallet(AddressSynchronizer):
max_change_outputs = 3
gap_limit_for_change = 6
verbosity_filter = 'w'
def __init__(self, storage):
AddressSynchronizer.__init__(self, storage)

4
run_electrum

@ -355,7 +355,7 @@ if __name__ == '__main__':
# config is an object passed to the various constructors (wallet, interface, gui)
if is_android:
config_options = {
'verbose': True,
'verbosity': '',
'cmd': 'gui',
'gui': 'kivy',
}
@ -376,7 +376,7 @@ if __name__ == '__main__':
config_options['electrum_path'] = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'electrum_data')
# kivy sometimes freezes when we write to sys.stderr
set_verbosity(config_options.get('verbose') and config_options.get('gui')!='kivy')
set_verbosity(config_options.get('verbosity') if config_options.get('gui') != 'kivy' else '')
# check uri
uri = config_options.get('url')

Loading…
Cancel
Save