[elbe-devel] [PATCH 03/40] pylint: test/updated: use optparse defaults
Torben Hohn
torben.hohn at linutronix.de
Thu Sep 20 11:04:48 CEST 2018
On Fri, Sep 14, 2018 at 01:56:15PM +0200, Manuel Traut wrote:
> instead of strange code that does the same.
> this should fix some pylint warnings:
>
> Signed-off-by: Manuel Traut <manut at linutronix.de>
Reviewed-by: Torben Hohn <torben.hohn at linutronix.de>
> ---
> test/updated.py | 45 ++++++++++++---------------------------------
> 1 file changed, 12 insertions(+), 33 deletions(-)
>
> diff --git a/test/updated.py b/test/updated.py
> index ca74bc46..3e7cf704 100755
> --- a/test/updated.py
> +++ b/test/updated.py
> @@ -55,20 +55,19 @@ def shutdown(monitor):
> oparser = OptionParser(usage="usage: %prog [options]")
>
> oparser.add_option("--debug", dest="debug", action="store_true",
> - default=False,
> - help="run in debug mode")
> + default=False, help="run in debug mode")
>
> -oparser.add_option("--target", dest="target",
> - help="ip or hostname of target")
> +oparser.add_option("--target", dest="target", default="localhost",
> + help="ip or hostname of target", type="string")
>
> -oparser.add_option("--port", dest="port",
> - help="port of updated on target")
> +oparser.add_option("--port", dest="port", default="8080",
> + help="port of updated on target", type="string")
>
> -oparser.add_option("--listen", dest="host",
> - help="interface ip")
> +oparser.add_option("--listen", dest="host", default="localhost",
> + help="interface ip", type="string")
>
> -oparser.add_option("--monitorport", dest="monitorport",
> - help="port used for update monitor")
> +oparser.add_option("--monitorport", dest="monitorport", default="8087",
> + help="port used for update monitor", type="string")
>
> (opt, args) = oparser.parse_args(sys.argv)
>
> @@ -77,40 +76,20 @@ if opt.debug:
> logging.basicConfig(level=logging.INFO)
> logging.getLogger('suds.client').setLevel(logging.DEBUG)
>
> -if not opt.target:
> - target = "localhost"
> -else:
> - target = opt.target
> -
> -if not opt.port:
> - port = "8088"
> -else:
> - port = str(opt.port)
> -
> -if not opt.monitorport:
> - monitorport = "8087"
> -else:
> - monitorport = opt.monitorport
> -
> -if not opt.host:
> - host = "localhost"
> -else:
> - host = opt.host
> -
> -wsdl = "http://" + target + ":" + port + "/?wsdl"
> +wsdl = "http://" + opt.target + ":" + opt.port + "/?wsdl"
> try:
> control = Client(wsdl)
> except BaseException:
> print(wsdl, "not reachable")
> sys.exit(1)
>
> -monitor = MonitorThread(monitorport)
> +monitor = MonitorThread(opt.monitorport)
> monitor.start()
>
> time.sleep(1) # hack to ensure that monitor server was started
>
> try:
> - monitor_wsdl = "http://" + host + ":" + monitorport + "/?wsdl"
> + monitor_wsdl = "http://" + opt.host + ":" + opt.monitorport + "/?wsdl"
> control.service.register_monitor(monitor_wsdl)
> except BaseException:
> print("monitor couldn't be registered (port already in use?)")
> --
> 2.19.0.rc2
>
--
Torben Hohn
Linutronix GmbH | Bahnhofstrasse 3 | D-88690 Uhldingen-Mühlhofen
Phone: +49 7556 25 999 18; Fax.: +49 7556 25 999 99
Hinweise zum Datenschutz finden Sie hier (Informations on data privacy
can be found here): https://linutronix.de/kontakt/Datenschutz.php
Linutronix GmbH | Firmensitz (Registered Office): Uhldingen-Mühlhofen |
Registergericht (Registration Court): Amtsgericht Freiburg i.Br., HRB700
806 | Geschäftsführer (Managing Directors): Heinz Egger, Thomas Gleixner
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://lists.linutronix.de/pipermail/elbe-devel/attachments/20180920/de7e020c/attachment.sig>
More information about the elbe-devel
mailing list