Python Forum
Search Results
Post Author Forum Replies Views Posted [asc]
    Thread: Not able to figure out what is wrong with argparse
Post: RE: Not able to figure out what is wrong with argp...

(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.ar...
radioactive9 General Coding Help 31 8,623 Mar-16-2022, 04:59 PM
    Thread: Not able to figure out what is wrong with argparse
Post: RE: Not able to figure out what is wrong with argp...

(Mar-16-2022, 04:14 PM)Gribouillis Wrote: radioactive9 Wrote:So now the most important thing is how to dump the arguments as the above code is introducing commas which seems to be not correctI alrea...
radioactive9 General Coding Help 31 8,623 Mar-16-2022, 04:18 PM
    Thread: Not able to figure out what is wrong with argparse
Post: RE: Not able to figure out what is wrong with argp...

(Mar-16-2022, 03:46 PM)Gribouillis Wrote: radioactive9 Wrote:I figured out a way to pass '--os', ' "Windows Server 2016 Standard" ' - but it continues to failDon't pass Output:'--os', ' "Windows Ser...
radioactive9 General Coding Help 31 8,623 Mar-16-2022, 04:01 PM
    Thread: Not able to figure out what is wrong with argparse
Post: RE: Not able to figure out what is wrong with argp...

(Mar-16-2022, 02:34 PM)radioactive9 Wrote: Further to my testing '--eventtime', '2022-03-16 16:15:16 +0100' actually pursing without any issue. But --os fails :( Even though --eventtime has space bu...
radioactive9 General Coding Help 31 8,623 Mar-16-2022, 03:27 PM
    Thread: Not able to figure out what is wrong with argparse
Post: RE: Not able to figure out what is wrong with argp...

I was so frustrated I even tried to use docopt - but it is too complex and I left the idea **huh** Then taking your line of thought I removed all the parameters which was being passed from the Tool ...
radioactive9 General Coding Help 31 8,623 Mar-16-2022, 02:34 PM
    Thread: Not able to figure out what is wrong with argparse
Post: RE: Not able to figure out what is wrong with argp...

Honestly you are right The arguments should not be so odd. Something is really off. I just changed the script to a simple shell script #!/bin/bash echo "$@" >> /tmp/icinga_argument.txt ech...
radioactive9 General Coding Help 31 8,623 Mar-16-2022, 08:39 AM
    Thread: Not able to figure out what is wrong with argparse
Post: RE: Not able to figure out what is wrong with argp...

(Mar-15-2022, 06:09 PM)Gribouillis Wrote: What is this run command that you are using, also why are there commas on the command line ? It looks like you copied and pasted some part of a Python list ...
radioactive9 General Coding Help 31 8,623 Mar-15-2022, 06:19 PM
    Thread: Not able to figure out what is wrong with argparse
Post: RE: Not able to figure out what is wrong with argp...

(Mar-15-2022, 05:23 PM)Gribouillis Wrote: It looks like --Environment is misspelled, the parser knows --environment Corrected thanks. Same error still. If the argument doesn't exist or argument val...
radioactive9 General Coding Help 31 8,623 Mar-15-2022, 05:49 PM
    Thread: Not able to figure out what is wrong with argparse
Post: RE: Not able to figure out what is wrong with argp...

(Mar-15-2022, 04:30 PM)Gribouillis Wrote: If you had tried the code I wrote above, you would have a log message indicating the error that the parser met. Hello Mate Sorry I am really lost. Don't tak...
radioactive9 General Coding Help 31 8,623 Mar-15-2022, 05:03 PM
    Thread: Not able to figure out what is wrong with argparse
Post: RE: Not able to figure out what is wrong with argp...

Hi Thanks. The call of the script is coming from a tool which is enforcing the below format as agument. Look at the comma separations between keys and values and quotes. I do not have a way to change...
radioactive9 General Coding Help 31 8,623 Mar-15-2022, 04:00 PM
    Thread: Not able to figure out what is wrong with argparse
Post: RE: Not able to figure out what is wrong with argp...

(Mar-15-2022, 02:20 PM)radioactive9 Wrote: Thank You I took your Code and tried to parse my arguments the way the tool is sending and it failed. Because it is not in a expected format import argpa...
radioactive9 General Coding Help 31 8,623 Mar-15-2022, 03:29 PM
    Thread: Not able to figure out what is wrong with argparse
Post: RE: Not able to figure out what is wrong with argp...

(Mar-15-2022, 02:57 PM)Gribouillis Wrote: Try this hack to log the error parser = argparse.ArgumentParser() ... _error = parser.error def error(message): logging.debug('argparse parser error %...
radioactive9 General Coding Help 31 8,623 Mar-15-2022, 03:08 PM
    Thread: Not able to figure out what is wrong with argparse
Post: RE: Not able to figure out what is wrong with argp...

Thank You I took your Code and tried to parse my arguments the way the tool is sending and it failed. Because it is not in a expected format import argparse def get_args(): parser = argparse...
radioactive9 General Coding Help 31 8,623 Mar-15-2022, 02:20 PM
    Thread: Not able to figure out what is wrong with argparse
Post: RE: Not able to figure out what is wrong with argp...

(Mar-15-2022, 12:39 PM)Gribouillis Wrote: This code is incomplete, I was unable to reproduce the error. In the code line 36 doesn't get executed. It doesn't throw any error as well. That is my probl...
radioactive9 General Coding Help 31 8,623 Mar-15-2022, 01:39 PM
    Thread: Not able to figure out what is wrong with argparse
Post: Not able to figure out what is wrong with argparse

Hello I am facing a very unique issue. I have written the following code which will be called by a Tool and pass certain arguments. I was using argpass thinking it will be easy. But I am not able to ...
radioactive9 General Coding Help 31 8,623 Mar-15-2022, 11:47 AM
    Thread: Simple List manipulation - bowled
Post: RE: Simple List manipulation - bowled

Got you. Thanks Do you think we can improve the code little better. I do not want list comprehension as it is confusing :) appPath = 'D:\\Backup\\Drive_D\\W0rk\\Script\\Python\\HTMLTOCSV_Python\\Try\\...
radioactive9 Web Scraping & Web Development 5 4,278 Aug-11-2017, 03:28 AM
    Thread: Simple List manipulation - bowled
Post: RE: Simple List manipulation - bowled

Well we need to keep in mind priority of colors. If a technology : color is having both yellow and red we need to drop technology:yellow and keep technology:red Ok here is the full scenario. I have ...
radioactive9 Web Scraping & Web Development 5 4,278 Aug-11-2017, 02:47 AM
    Thread: Simple List manipulation - bowled
Post: Simple List manipulation - bowled

Hello I have a simple list like below. Now I need to convert that list into unique technology list. For e.g in VMWare_Technology we have both yellow and red. Only red and yellow possible. Red has mo...
radioactive9 Web Scraping & Web Development 5 4,278 Aug-11-2017, 01:54 AM
    Thread: IndentationError: unexpected indent (Python)
Post: RE: IndentationError: unexpected indent (Python)

Hello Indentation error is because you have mixed space with tab. Or You have given logical wrong indents Also you did not post the actual code for us to see the indents that you have used. Looking...
radioactive9 General Coding Help 8 17,314 Aug-11-2017, 01:43 AM
    Thread: Why do I get this error when I try to access MSAccess database from python?
Post: RE: Why do I get this error when I try to access M...

Hello I had some trouble with MS Access DB in the past. Careful with 32 Bit or 64 Bit connstr = ( r'DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};' r'DBQ=C:\mypath\myaccessdb.accdb;' ...
radioactive9 General Coding Help 2 7,222 Aug-10-2017, 08:48 AM

User Panel Messages

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