From: Philipp Klaus Date: Mon, 14 Aug 2017 11:25:21 +0000 (+0200) Subject: opus20: use entry_points in setup.py, not scripts X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=f57124ef946223a63f86310d6f8fd30e5028b8ef;p=labtools.git opus20: use entry_points in setup.py, not scripts --- diff --git a/opus20/scripts/opus20_cli b/opus20/opus20/opus20_cli.py similarity index 95% rename from opus20/scripts/opus20_cli rename to opus20/opus20/opus20_cli.py index 2b36ab8..15c504a 100755 --- a/opus20/scripts/opus20_cli +++ b/opus20/opus20/opus20_cli.py @@ -19,7 +19,7 @@ def extended_int(string): def main(): - parser = argparse.ArgumentParser(description="CLI for the Lufft OPUS20") + parser = argparse.ArgumentParser(description="CLI for the Lufft OPUS20. Note that the subcommands provide their own --help!") parser.add_argument('host', help='hostname of the device') parser.add_argument('--port', '-p', type=int, help='TCP port of the OPUS20') parser.add_argument('--timeout', '-t', type=float, help='Timeout of the TCP connection in seconds') @@ -30,7 +30,7 @@ def main(): parser_get.add_argument('channel', type=extended_int, nargs='+', help='The selected channel(s)') parser_download = subparsers.add_parser('download', help='download the logs and store them locally') parser_download.add_argument('persistance_file', help='file to store the logs in') - parser_logging = subparsers.add_parser('logging', help='change or query global logging settings') + parser_logging = subparsers.add_parser('logging', help='change or query global logging settings (start, stop, clear)') subsubparsers = parser_logging.add_subparsers(help='Action to perform w/ respect to logging', dest='action') parser_logging_action_status = subsubparsers.add_parser('status', help='Query the current logging status of the device') parser_logging_action_start = subsubparsers.add_parser('start', help='Start logging altogether on the device') @@ -56,8 +56,10 @@ def main(): if args.timeout: kwargs['timeout'] = args.timeout o20 = Opus20(args.host, **kwargs) + logger.info(o20.get_logging_state()) if args.cmd == 'list': for channel in o20.available_channels: + logger.info(o20.get_channel_logging_state(channel)) print("Channel {:5d} (0x{:04X}): {name:22s} unit: {unit:6s} offset: {offset}".format(channel, channel, **OPUS20_CHANNEL_SPEC[channel])) if args.cmd == 'get': if len(args.channel) > 1: diff --git a/opus20/scripts/opus20_discovery b/opus20/opus20/opus20_discovery.py similarity index 100% rename from opus20/scripts/opus20_discovery rename to opus20/opus20/opus20_discovery.py diff --git a/opus20/scripts/opus20_fakeserver b/opus20/opus20/opus20_fakeserver.py similarity index 100% rename from opus20/scripts/opus20_fakeserver rename to opus20/opus20/opus20_fakeserver.py diff --git a/opus20/scripts/opus20_web b/opus20/opus20/opus20_web.py similarity index 100% rename from opus20/scripts/opus20_web rename to opus20/opus20/opus20_web.py diff --git a/opus20/setup.py b/opus20/setup.py index 6cf42c7..e63d2c2 100644 --- a/opus20/setup.py +++ b/opus20/setup.py @@ -17,12 +17,14 @@ setup(name='opus20', url = '', license = 'GPL', packages = ['opus20', 'opus20.webapp'], - scripts = [ - 'scripts/opus20_cli', - 'scripts/opus20_web', - 'scripts/opus20_discovery', - 'scripts/opus20_fakeserver', - ], + entry_points = { + 'console_scripts': [ + 'opus20_cli = opus20.opus20_cli:main', + 'opus20_web = opus20.opus20_web:main', + 'opus20_discovery = opus20.opus20_discovery:main', + 'opus20_fakeserver = opus20.opus20_fakeserver:main', + ], + }, include_package_data = True, zip_safe = True, platforms = 'any',