Python Forum
Not able to figure out what is wrong with argparse
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Not able to figure out what is wrong with argparse
#31
(Mar-16-2022, 04:22 PM)deanhystad Wrote: f" string formatting is new in Python 3.6. You need to do this:
print('Printing all arguments', ' '.join('"{}"'.format(a) if ' ' in a else a for a in sys.argv[1:]))

Worked like a charm Heart and all the parameters looks very good. If i introduce --os it starts failing. If I remove - it goes forward and creates ticket. Look at --os it does have double quotes around it coming from the tool. even for --eventtime. That was the reason --eventtime never had the problem

Quote:Printing all arguments --IPAddress 00.00.00.00 --operatormw GSC_W_RUN --operatoros GSC_W_RUN --division Tech --environment PROD --eventtime "2022-03-16 17:33:53 +0100" --host wwwwwww754 --host_appname TEC-W --notificationtype RECOVERY --operator operator_os --os "Windows Server 2016 Standard" --priority OK --service SN-WIN-osservices

Another example
Quote:Printing all arguments --IPAddress 99.99.99.99 --operatormw RES_INFRA_NL --operatoros MOBILITY_LINUX --division TEC --environment PROD --eventtime "2022-03-16 17:57:38 +0100" --host fishfishfish --host_appname APPData --notificationtype PROBLEM --os "Red Hat Enterprise Linux 6" --operator operator_mw --priority CRITICAL --service SN-LIN-disk-non_slash


Not sure why I can't parse --os - any suggestion
Reply


Messages In This Thread
RE: Not able to figure out what is wrong with argparse - by radioactive9 - Mar-16-2022, 04:59 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Bug argparse io issue pyDream 8 778 Apr-02-2024, 12:42 PM
Last Post: pyDream
  Am I wrong or is Udemy wrong? String Slicing! Mavoz 3 2,648 Nov-05-2022, 11:33 AM
Last Post: Mavoz
  argparse --help in one line. Denial 1 2,029 Sep-20-2020, 03:38 PM
Last Post: deanhystad
  Argparse error when inputting values tqader 2 2,918 Sep-11-2020, 07:42 PM
Last Post: buran
  Why this pycharm warning for argparse formatter_class value? pjfarley3 2 2,162 Sep-09-2020, 05:23 AM
Last Post: pjfarley3
  Can argparse support undocumented options? pjfarley3 3 2,276 Aug-14-2020, 06:13 AM
Last Post: pjfarley3
  In ArgParse, can two compatible formatter_class values be used? pjfarley3 2 2,644 Jul-31-2020, 02:01 PM
Last Post: pjfarley3
  python gives wrong string length and wrong character thienson30 2 3,055 Oct-15-2019, 08:54 PM
Last Post: Gribouillis
  Why am I getting KeyError 'file' when using argparse? Mike Ru 1 3,115 Jun-09-2019, 04:48 PM
Last Post: metulburr
  How can I get some arguments using argparse? Mike Ru 0 1,907 Jun-05-2019, 12:57 PM
Last Post: Mike Ru

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020