[Met_help] [rt.rap.ucar.edu #79331] History for Command Line Issue

John Halley Gotway via RT met_help at ucar.edu
Fri Feb 3 09:22:57 MST 2017


----------------------------------------------------------------
  Initial Request
----------------------------------------------------------------

Hi John, I have an syntax issue when I run regrid_data_plane using python.   If I type the following command at the prompt, it will run just fine:

/h/WXQC/met-5.1/bin/regrid_data_plane /h/data/global/WXQC/data/umm/1701150006 G003 /h/data/global/WXQC/data/met/nc_mdl/umm/1701150006 -field 'name="HGT"; level="P500";' -field 'name="TMP"; level="Z2";'

When I submit this as a Python list I get the following:

['/h/WXQC/met-5.1/bin/regrid_data_plane', '/h/data/global/WXQC/data/umm/1701150006', 'G003', '/h/data/global/WXQC/data/met/nc_mdl/umm/1701150006', '-field \'name="HGT"; level="P500";\'', '-v', '6']
ERROR  : 
ERROR  : CommandLine::next_option() -> unrecognized command-line switch "-field 'name="HGT"; level="P500";'"
ERROR  :

Note the list field that contains -field has some \ characters escaping the single quote.  However if I print out this field it looks correct:

-field 'name="HGT"; level="P500";'

I thought the \ character was just an artifact of the print put it seems to remain giving MET issues.  Is there a better way to pass a parameter with two types of quotes to MET?

thanks

Bob Craig





----------------------------------------------------------------
  Complete Ticket History
----------------------------------------------------------------

Subject: Command Line Issue
From: John Halley Gotway
Time: Thu Feb 02 17:28:04 2017

Bob,

Don't all these little details drive you crazy?  Unfortunately, I
don't see
an obvious problem jumping out at me in your script.  But you're
right,
it's definitely something to do with single quotes, double quotes, and
escape characters.

There are some folks here working on wrapping calls to MET with
Python, and
I suspect they've run into something similar.  MET is parsing that
whole
string as a single command line option... which obviously isn't
working.
You could try breaking it up, like you did for the -v 6 option:

['/h/WXQC/met-5.1/bin/regrid_data_plane',
'/h/data/global/WXQC/data/umm/1701150006',
'G003', '/h/data/global/WXQC/data/met/nc_mdl/umm/1701150006', '-
field',
'\'name="HGT"; level="P500";\'', '-v', '6']

If that doesn't work, I could ask one of the python people here for
help.

Thanks,
John



On Thu, Feb 2, 2017 at 1:00 PM, robert.craig.2 at us.af.mil via RT <
met_help at ucar.edu> wrote:

>
> Thu Feb 02 13:00:51 2017: Request 79331 was acted upon.
> Transaction: Ticket created by robert.craig.2 at us.af.mil
>        Queue: met_help
>      Subject: Command Line Issue
>        Owner: Nobody
>   Requestors: robert.craig.2 at us.af.mil
>       Status: new
>  Ticket <URL:
https://rt.rap.ucar.edu/rt/Ticket/Display.html?id=79331 >
>
>
> Hi John, I have an syntax issue when I run regrid_data_plane using
> python.   If I type the following command at the prompt, it will run
just
> fine:
>
> /h/WXQC/met-5.1/bin/regrid_data_plane
/h/data/global/WXQC/data/umm/1701150006
> G003 /h/data/global/WXQC/data/met/nc_mdl/umm/1701150006 -field
> 'name="HGT"; level="P500";' -field 'name="TMP"; level="Z2";'
>
> When I submit this as a Python list I get the following:
>
> ['/h/WXQC/met-5.1/bin/regrid_data_plane',
'/h/data/global/WXQC/data/umm/1701150006',
> 'G003', '/h/data/global/WXQC/data/met/nc_mdl/umm/1701150006', '-
field
> \'name="HGT"; level="P500";\'', '-v', '6']
> ERROR  :
> ERROR  : CommandLine::next_option() -> unrecognized command-line
switch
> "-field 'name="HGT"; level="P500";'"
> ERROR  :
>
> Note the list field that contains -field has some \ characters
escaping
> the single quote.  However if I print out this field it looks
correct:
>
> -field 'name="HGT"; level="P500";'
>
> I thought the \ character was just an artifact of the print put it
seems
> to remain giving MET issues.  Is there a better way to pass a
parameter
> with two types of quotes to MET?
>
> thanks
>
> Bob Craig
>
>
>
>
>

------------------------------------------------
Subject: RE: [rt.rap.ucar.edu #79331] Command Line Issue
From: robert.craig.2 at us.af.mil
Time: Fri Feb 03 07:17:50 2017

John,

That worked.  Splitting out the -field as a separate component of the
python list was the key.

Thanks again for the great support!

Bob



-----Original Message-----
From: John Halley Gotway via RT [mailto:met_help at ucar.edu]
Sent: Thursday, February 02, 2017 6:28 PM
To: CRAIG, ROBERT J GS-12 USAF ACC 16 WS/WXN
<robert.craig.2 at us.af.mil>
Cc: SITTEL, MATTHEW C CTR USAF AFMC AFLCMC/HBAW-OL
<matthew.sittel.ctr at us.af.mil>; MITANI, MICKEY W GS-12 USAF ACC 16
WS/WXET <mickey.mitani.1 at us.af.mil>
Subject: Re: [rt.rap.ucar.edu #79331] Command Line Issue

Bob,

Don't all these little details drive you crazy?  Unfortunately, I
don't see an obvious problem jumping out at me in your script.  But
you're right, it's definitely something to do with single quotes,
double quotes, and escape characters.

There are some folks here working on wrapping calls to MET with
Python, and I suspect they've run into something similar.  MET is
parsing that whole string as a single command line option... which
obviously isn't working.
You could try breaking it up, like you did for the -v 6 option:

['/h/WXQC/met-5.1/bin/regrid_data_plane',
'/h/data/global/WXQC/data/umm/1701150006',
'G003', '/h/data/global/WXQC/data/met/nc_mdl/umm/1701150006', '-
field', '\'name="HGT"; level="P500";\'', '-v', '6']

If that doesn't work, I could ask one of the python people here for
help.

Thanks,
John



On Thu, Feb 2, 2017 at 1:00 PM, robert.craig.2 at us.af.mil via RT <
met_help at ucar.edu> wrote:

>
> Thu Feb 02 13:00:51 2017: Request 79331 was acted upon.
> Transaction: Ticket created by robert.craig.2 at us.af.mil
>        Queue: met_help
>      Subject: Command Line Issue
>        Owner: Nobody
>   Requestors: robert.craig.2 at us.af.mil
>       Status: new
>  Ticket <URL:
https://rt.rap.ucar.edu/rt/Ticket/Display.html?id=79331
> >
>
>
> Hi John, I have an syntax issue when I run regrid_data_plane using
> python.   If I type the following command at the prompt, it will run
just
> fine:
>
> /h/WXQC/met-5.1/bin/regrid_data_plane
> /h/data/global/WXQC/data/umm/1701150006
> G003 /h/data/global/WXQC/data/met/nc_mdl/umm/1701150006 -field
> 'name="HGT"; level="P500";' -field 'name="TMP"; level="Z2";'
>
> When I submit this as a Python list I get the following:
>
> ['/h/WXQC/met-5.1/bin/regrid_data_plane',
> '/h/data/global/WXQC/data/umm/1701150006',
> 'G003', '/h/data/global/WXQC/data/met/nc_mdl/umm/1701150006', '-
field
> \'name="HGT"; level="P500";\'', '-v', '6'] ERROR  :
> ERROR  : CommandLine::next_option() -> unrecognized command-line
> switch "-field 'name="HGT"; level="P500";'"
> ERROR  :
>
> Note the list field that contains -field has some \ characters
> escaping the single quote.  However if I print out this field it
looks correct:
>
> -field 'name="HGT"; level="P500";'
>
> I thought the \ character was just an artifact of the print put it
> seems to remain giving MET issues.  Is there a better way to pass a
> parameter with two types of quotes to MET?
>
> thanks
>
> Bob Craig
>
>
>
>
>



------------------------------------------------


More information about the Met_help mailing list