[elbe-devel] [PATCH 2/5] test/updated: use optparse defaults

Torben Hohn torben.hohn at linutronix.de
Tue Aug 28 11:11:14 CEST 2018


looks okish, see 2 comments inline


On Fri, Aug 24, 2018 at 04:00:34PM +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>
> ---
>  test/updated.py | 44 ++++++++++++--------------------------------
>  1 file changed, 12 insertions(+), 32 deletions(-)
> 
> diff --git a/test/updated.py b/test/updated.py
> index df49a3fe..e03a0e87 100755
> --- a/test/updated.py
> +++ b/test/updated.py
> @@ -55,20 +55,20 @@ def shutdown(monitor):
>  oparser = OptionParser(usage="usage: %prog [options]")
>  
>  oparser.add_option("--debug", dest="debug", action="store_true",
> -                   default=False,
> +                   default=False, type="string",

this is not a string ^^^^^^^^^

>                     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")

string or int ?
maybe string is ok.

>  
>  (opt, args) = oparser.parse_args(sys.argv)
>  
> @@ -77,40 +77,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.18.0
> 
> 
> _______________________________________________
> elbe-devel mailing list
> elbe-devel at linutronix.de
> https://lists.linutronix.de/mailman/listinfo/elbe-devel

-- 
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/20180828/3bd94d87/attachment.sig>


More information about the elbe-devel mailing list