command line fixes
This commit is contained in:
parent
a6cd53b97c
commit
d0230b4893
5 changed files with 37 additions and 22 deletions
|
@ -25,7 +25,8 @@ jobs:
|
|||
- pip install -e .[test]
|
||||
script:
|
||||
- HOME=/tmp coverage run -p --source=lbrynet -m twisted.trial --reactor=asyncio tests.unit.core tests.unit.cryptstream tests.unit.database tests.unit.dht tests.unit.lbryfilemanager tests.unit.lbrynet_daemon tests.unit.schema tests.unit.wallet tests.unit.components tests.unit.test_conf
|
||||
#- HOME=/tmp coverage run -p --source=lbrynet -m twisted.trial --reactor=asyncio tests.unit.analytics tests.unit.test_cli
|
||||
- HOME=/tmp coverage run -p --source=lbrynet -m twisted.trial --reactor=asyncio tests.unit.test_cli
|
||||
#- HOME=/tmp coverage run -p --source=lbrynet -m twisted.trial --reactor=asyncio tests.unit.analytics
|
||||
after_success:
|
||||
- coverage combine
|
||||
- bash <(curl -s https://codecov.io/bash)
|
||||
|
|
|
@ -21,7 +21,7 @@ log.addHandler(logging.NullHandler())
|
|||
|
||||
|
||||
def display(data):
|
||||
print(json.dumps(data["result"], indent=2))
|
||||
print(json.dumps(data, indent=2))
|
||||
|
||||
|
||||
async def execute_command(conf, method, params):
|
||||
|
@ -153,7 +153,7 @@ def main(argv=None):
|
|||
parser = get_argument_parser()
|
||||
args = parser.parse_args(argv)
|
||||
|
||||
conf = Config()
|
||||
conf = Config.create_from_arguments(args)
|
||||
|
||||
if args.cli_version:
|
||||
print(f"{lbrynet_name} {lbrynet_version}")
|
||||
|
@ -184,16 +184,26 @@ def main(argv=None):
|
|||
|
||||
elif args.command is not None:
|
||||
|
||||
if args.subcommand is None:
|
||||
args.group_doc.print_help()
|
||||
|
||||
else:
|
||||
if args.subcommand is not None:
|
||||
method = f'{args.command}_{args.subcommand}'
|
||||
fn = Daemon.callable_methods[method]
|
||||
parsed = docopt(fn.__doc__, [method]+argv[2:])
|
||||
params = set_kwargs(parsed)
|
||||
loop = asyncio.get_event_loop()
|
||||
loop.run_until_complete(execute_command(conf, method, params))
|
||||
command_before_args = args.subcommand
|
||||
elif args.command in ('status', 'publish', 'version'):
|
||||
method = command_before_args = args.command
|
||||
else:
|
||||
args.group_doc.print_help()
|
||||
return 0
|
||||
|
||||
command_index = 0
|
||||
for i in range(len(argv)):
|
||||
if argv[i] == command_before_args:
|
||||
command_index = i
|
||||
break
|
||||
|
||||
fn = Daemon.callable_methods[method]
|
||||
parsed = docopt(fn.__doc__, argv[command_index+1:])
|
||||
params = set_kwargs(parsed)
|
||||
loop = asyncio.get_event_loop()
|
||||
loop.run_until_complete(execute_command(conf, method, params))
|
||||
|
||||
else:
|
||||
parser.print_help()
|
||||
|
|
|
@ -520,7 +520,7 @@ class Daemon(metaclass=JSONRPCServerType):
|
|||
await self.handler.shutdown(60.0)
|
||||
await self.app.cleanup()
|
||||
if self.analytics_manager:
|
||||
self.analytics_manager.shutdown()
|
||||
self.analytics_manager.stop()
|
||||
try:
|
||||
self._component_setup_task.cancel()
|
||||
except (AttributeError, asyncio.CancelledError):
|
||||
|
|
|
@ -40,6 +40,10 @@ class Manager:
|
|||
self.session_id = session_id
|
||||
self.task: asyncio.Task = None
|
||||
|
||||
@property
|
||||
def is_started(self):
|
||||
return self.task is not None
|
||||
|
||||
def start(self):
|
||||
if self._enabled and self.task is None:
|
||||
self.task = asyncio.create_task(self.run())
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
import contextlib
|
||||
from io import StringIO
|
||||
from unittest import skip
|
||||
from torba.testcase import AsyncioTestCase
|
||||
|
||||
from lbrynet import conf
|
||||
from lbrynet.conf import Config
|
||||
from lbrynet.extras import cli
|
||||
from lbrynet.extras.daemon.Components import DATABASE_COMPONENT, BLOB_COMPONENT, HEADERS_COMPONENT, WALLET_COMPONENT, \
|
||||
DHT_COMPONENT, HASH_ANNOUNCER_COMPONENT, FILE_MANAGER_COMPONENT, \
|
||||
|
@ -37,13 +36,14 @@ class CLIIntegrationTest(AsyncioTestCase):
|
|||
PEER_PROTOCOL_SERVER_COMPONENT, REFLECTOR_COMPONENT, UPNP_COMPONENT, EXCHANGE_RATE_MANAGER_COMPONENT,
|
||||
RATE_LIMITER_COMPONENT, PAYMENT_RATE_COMPONENT
|
||||
]
|
||||
conf.initialize_settings(load_conf_file=False)
|
||||
conf.settings['api_port'] = 5299
|
||||
conf.settings['components_to_skip'] = skip
|
||||
conf.settings.initialize_post_conf_load()
|
||||
conf = Config()
|
||||
conf.data_dir = '/tmp'
|
||||
conf.share_usage_data = False
|
||||
conf.api_port = 5299
|
||||
conf.components_to_skip = skip
|
||||
Daemon.component_attributes = {}
|
||||
self.daemon = Daemon(analytics_manager=FakeAnalytics())
|
||||
await self.daemon.start_listening()
|
||||
self.daemon = Daemon(conf)
|
||||
await self.daemon.start()
|
||||
|
||||
async def asyncTearDown(self):
|
||||
await self.daemon.shutdown()
|
||||
|
@ -51,6 +51,6 @@ class CLIIntegrationTest(AsyncioTestCase):
|
|||
def test_cli_status_command_with_auth(self):
|
||||
actual_output = StringIO()
|
||||
with contextlib.redirect_stdout(actual_output):
|
||||
cli.main(["status"])
|
||||
cli.main(["--api-port", "5299", "status"])
|
||||
actual_output = actual_output.getvalue()
|
||||
self.assertIn("connection_status", actual_output)
|
||||
|
|
Loading…
Add table
Reference in a new issue