mirror of
https://github.com/LBRYFoundation/lbry-sdk.git
synced 2025-08-23 17:27:25 +00:00
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]
|
- pip install -e .[test]
|
||||||
script:
|
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.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:
|
after_success:
|
||||||
- coverage combine
|
- coverage combine
|
||||||
- bash <(curl -s https://codecov.io/bash)
|
- bash <(curl -s https://codecov.io/bash)
|
||||||
|
|
|
@ -21,7 +21,7 @@ log.addHandler(logging.NullHandler())
|
||||||
|
|
||||||
|
|
||||||
def display(data):
|
def display(data):
|
||||||
print(json.dumps(data["result"], indent=2))
|
print(json.dumps(data, indent=2))
|
||||||
|
|
||||||
|
|
||||||
async def execute_command(conf, method, params):
|
async def execute_command(conf, method, params):
|
||||||
|
@ -153,7 +153,7 @@ def main(argv=None):
|
||||||
parser = get_argument_parser()
|
parser = get_argument_parser()
|
||||||
args = parser.parse_args(argv)
|
args = parser.parse_args(argv)
|
||||||
|
|
||||||
conf = Config()
|
conf = Config.create_from_arguments(args)
|
||||||
|
|
||||||
if args.cli_version:
|
if args.cli_version:
|
||||||
print(f"{lbrynet_name} {lbrynet_version}")
|
print(f"{lbrynet_name} {lbrynet_version}")
|
||||||
|
@ -184,13 +184,23 @@ def main(argv=None):
|
||||||
|
|
||||||
elif args.command is not None:
|
elif args.command is not None:
|
||||||
|
|
||||||
if args.subcommand is None:
|
if args.subcommand is not None:
|
||||||
args.group_doc.print_help()
|
|
||||||
|
|
||||||
else:
|
|
||||||
method = f'{args.command}_{args.subcommand}'
|
method = f'{args.command}_{args.subcommand}'
|
||||||
|
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]
|
fn = Daemon.callable_methods[method]
|
||||||
parsed = docopt(fn.__doc__, [method]+argv[2:])
|
parsed = docopt(fn.__doc__, argv[command_index+1:])
|
||||||
params = set_kwargs(parsed)
|
params = set_kwargs(parsed)
|
||||||
loop = asyncio.get_event_loop()
|
loop = asyncio.get_event_loop()
|
||||||
loop.run_until_complete(execute_command(conf, method, params))
|
loop.run_until_complete(execute_command(conf, method, params))
|
||||||
|
|
|
@ -520,7 +520,7 @@ class Daemon(metaclass=JSONRPCServerType):
|
||||||
await self.handler.shutdown(60.0)
|
await self.handler.shutdown(60.0)
|
||||||
await self.app.cleanup()
|
await self.app.cleanup()
|
||||||
if self.analytics_manager:
|
if self.analytics_manager:
|
||||||
self.analytics_manager.shutdown()
|
self.analytics_manager.stop()
|
||||||
try:
|
try:
|
||||||
self._component_setup_task.cancel()
|
self._component_setup_task.cancel()
|
||||||
except (AttributeError, asyncio.CancelledError):
|
except (AttributeError, asyncio.CancelledError):
|
||||||
|
|
|
@ -40,6 +40,10 @@ class Manager:
|
||||||
self.session_id = session_id
|
self.session_id = session_id
|
||||||
self.task: asyncio.Task = None
|
self.task: asyncio.Task = None
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_started(self):
|
||||||
|
return self.task is not None
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
if self._enabled and self.task is None:
|
if self._enabled and self.task is None:
|
||||||
self.task = asyncio.create_task(self.run())
|
self.task = asyncio.create_task(self.run())
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
import contextlib
|
import contextlib
|
||||||
from io import StringIO
|
from io import StringIO
|
||||||
from unittest import skip
|
|
||||||
from torba.testcase import AsyncioTestCase
|
from torba.testcase import AsyncioTestCase
|
||||||
|
|
||||||
from lbrynet import conf
|
from lbrynet.conf import Config
|
||||||
from lbrynet.extras import cli
|
from lbrynet.extras import cli
|
||||||
from lbrynet.extras.daemon.Components import DATABASE_COMPONENT, BLOB_COMPONENT, HEADERS_COMPONENT, WALLET_COMPONENT, \
|
from lbrynet.extras.daemon.Components import DATABASE_COMPONENT, BLOB_COMPONENT, HEADERS_COMPONENT, WALLET_COMPONENT, \
|
||||||
DHT_COMPONENT, HASH_ANNOUNCER_COMPONENT, FILE_MANAGER_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,
|
PEER_PROTOCOL_SERVER_COMPONENT, REFLECTOR_COMPONENT, UPNP_COMPONENT, EXCHANGE_RATE_MANAGER_COMPONENT,
|
||||||
RATE_LIMITER_COMPONENT, PAYMENT_RATE_COMPONENT
|
RATE_LIMITER_COMPONENT, PAYMENT_RATE_COMPONENT
|
||||||
]
|
]
|
||||||
conf.initialize_settings(load_conf_file=False)
|
conf = Config()
|
||||||
conf.settings['api_port'] = 5299
|
conf.data_dir = '/tmp'
|
||||||
conf.settings['components_to_skip'] = skip
|
conf.share_usage_data = False
|
||||||
conf.settings.initialize_post_conf_load()
|
conf.api_port = 5299
|
||||||
|
conf.components_to_skip = skip
|
||||||
Daemon.component_attributes = {}
|
Daemon.component_attributes = {}
|
||||||
self.daemon = Daemon(analytics_manager=FakeAnalytics())
|
self.daemon = Daemon(conf)
|
||||||
await self.daemon.start_listening()
|
await self.daemon.start()
|
||||||
|
|
||||||
async def asyncTearDown(self):
|
async def asyncTearDown(self):
|
||||||
await self.daemon.shutdown()
|
await self.daemon.shutdown()
|
||||||
|
@ -51,6 +51,6 @@ class CLIIntegrationTest(AsyncioTestCase):
|
||||||
def test_cli_status_command_with_auth(self):
|
def test_cli_status_command_with_auth(self):
|
||||||
actual_output = StringIO()
|
actual_output = StringIO()
|
||||||
with contextlib.redirect_stdout(actual_output):
|
with contextlib.redirect_stdout(actual_output):
|
||||||
cli.main(["status"])
|
cli.main(["--api-port", "5299", "status"])
|
||||||
actual_output = actual_output.getvalue()
|
actual_output = actual_output.getvalue()
|
||||||
self.assertIn("connection_status", actual_output)
|
self.assertIn("connection_status", actual_output)
|
||||||
|
|
Loading…
Add table
Reference in a new issue