mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-23 17:47:31 +00:00
do not declare pointless static methods
This commit is contained in:
parent
56c7d4139e
commit
1c83c3e060
2 changed files with 41 additions and 54 deletions
43
electrum
43
electrum
|
@ -313,18 +313,53 @@ if __name__ == '__main__':
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
if cmdname == 'gui':
|
if cmdname == 'gui':
|
||||||
result = Daemon.gui_command(config, config_options, plugins)
|
lockfile = Daemon.lockfile(config)
|
||||||
|
fd = Daemon.get_fd_or_server(lockfile)
|
||||||
|
if isinstance(fd, int):
|
||||||
|
daemon = Daemon.create_daemon(config, fd)
|
||||||
|
daemon.init_gui(config, plugins)
|
||||||
|
sys.exit(0)
|
||||||
|
server = fd
|
||||||
|
result = server.gui(config_options)
|
||||||
|
|
||||||
elif cmdname == 'daemon':
|
elif cmdname == 'daemon':
|
||||||
result = Daemon.daemon_command(config, config_options)
|
lockfile = Daemon.lockfile(config)
|
||||||
|
fd = Daemon.get_fd_or_server(lockfile)
|
||||||
|
if isinstance(fd, int):
|
||||||
|
subcommand = config.get('subcommand')
|
||||||
|
assert subcommand in ['start', 'stop', 'status']
|
||||||
|
if subcommand != 'start':
|
||||||
|
print_msg("Daemon not running")
|
||||||
|
os.close(fd)
|
||||||
|
Daemon.remove_lockfile(lockfile)
|
||||||
|
sys.exit(1)
|
||||||
|
pid = os.fork()
|
||||||
|
if pid:
|
||||||
|
print_stderr("starting daemon (PID %d)" % pid)
|
||||||
|
sys.exit(0)
|
||||||
|
daemon = Daemon.create_daemon(config, fd)
|
||||||
|
if config.get('websocket_server'):
|
||||||
|
from electrum import websockets
|
||||||
|
websockets.WebSocketServer(config, daemon.network).start()
|
||||||
|
if config.get('requests_dir'):
|
||||||
|
util.check_www_dir(config.get('requests_dir'))
|
||||||
|
daemon.join()
|
||||||
|
sys.exit(0)
|
||||||
|
else:
|
||||||
|
server = fd
|
||||||
|
result = server.daemon(config_options)
|
||||||
else:
|
else:
|
||||||
# command line
|
# command line
|
||||||
init_cmdline(config_options)
|
init_cmdline(config_options)
|
||||||
run_offline, result = Daemon.cmdline_command(config, config_options)
|
server = Daemon.get_server(Daemon.lockfile(config))
|
||||||
if run_offline:
|
if server is not None:
|
||||||
|
result = server.run_cmdline(config_options)
|
||||||
|
else:
|
||||||
cmd = known_commands[cmdname]
|
cmd = known_commands[cmdname]
|
||||||
if cmd.requires_network:
|
if cmd.requires_network:
|
||||||
print_msg("Daemon not running; try 'electrum daemon start'")
|
print_msg("Daemon not running; try 'electrum daemon start'")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
else:
|
||||||
result = run_offline_command(config, config_options)
|
result = run_offline_command(config, config_options)
|
||||||
|
|
||||||
# print result
|
# print result
|
||||||
|
|
|
@ -25,7 +25,7 @@ import jsonrpclib
|
||||||
from jsonrpclib.SimpleJSONRPCServer import SimpleJSONRPCServer, SimpleJSONRPCRequestHandler
|
from jsonrpclib.SimpleJSONRPCServer import SimpleJSONRPCServer, SimpleJSONRPCRequestHandler
|
||||||
|
|
||||||
from network import Network
|
from network import Network
|
||||||
from util import check_www_dir, json_decode, DaemonThread
|
from util import json_decode, DaemonThread
|
||||||
from util import print_msg, print_error, print_stderr
|
from util import print_msg, print_error, print_stderr
|
||||||
from wallet import WalletStorage, Wallet
|
from wallet import WalletStorage, Wallet
|
||||||
from wizard import WizardBase
|
from wizard import WizardBase
|
||||||
|
@ -234,51 +234,3 @@ class Daemon(DaemonThread):
|
||||||
daemon = Daemon(config, server)
|
daemon = Daemon(config, server)
|
||||||
daemon.start()
|
daemon.start()
|
||||||
return daemon
|
return daemon
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def gui_command(config, config_options, plugins):
|
|
||||||
lockfile = Daemon.lockfile(config)
|
|
||||||
fd = Daemon.get_fd_or_server(lockfile)
|
|
||||||
if isinstance(fd, int):
|
|
||||||
daemon = Daemon.create_daemon(config, fd)
|
|
||||||
daemon.init_gui(config, plugins)
|
|
||||||
sys.exit(0)
|
|
||||||
server = fd
|
|
||||||
return server.gui(config_options)
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def cmdline_command(config, config_options):
|
|
||||||
server = Daemon.get_server(Daemon.lockfile(config))
|
|
||||||
if server is not None:
|
|
||||||
return False, server.run_cmdline(config_options)
|
|
||||||
|
|
||||||
return True, None
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def daemon_command(config, config_options):
|
|
||||||
lockfile = Daemon.lockfile(config)
|
|
||||||
fd = Daemon.get_fd_or_server(lockfile)
|
|
||||||
if isinstance(fd, int):
|
|
||||||
subcommand = config.get('subcommand')
|
|
||||||
assert subcommand in ['start', 'stop', 'status']
|
|
||||||
if subcommand != 'start':
|
|
||||||
print_msg("Daemon not running")
|
|
||||||
os.close(fd)
|
|
||||||
Daemon.remove_lockfile(lockfile)
|
|
||||||
sys.exit(1)
|
|
||||||
pid = os.fork()
|
|
||||||
if pid:
|
|
||||||
print_stderr("starting daemon (PID %d)" % pid)
|
|
||||||
sys.exit(0)
|
|
||||||
daemon = Daemon.create_daemon(config, fd)
|
|
||||||
if config.get('websocket_server'):
|
|
||||||
from electrum import websockets
|
|
||||||
websockets.WebSocketServer(config, daemon.network).start()
|
|
||||||
if config.get('requests_dir'):
|
|
||||||
check_www_dir(config.get('requests_dir'))
|
|
||||||
daemon.join()
|
|
||||||
sys.exit(0)
|
|
||||||
|
|
||||||
server = fd
|
|
||||||
if server is not None:
|
|
||||||
return server.daemon(config_options)
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue