Hi,
I'm passing what I think is a string parameter to another Python
program (spawn.py) - see the code snip below. But only the counter
part gets printed to a log file via spawn.py. Yet the echo print to
the output window shows the whole string with the fc part. Better
explained below I hope, there's the calling .py and the spawn
script .py:
....snip...
while fc:
counter = counter + 1
fc_cntr = str(counter) + ' : ' + fc
print fc_cntr + '\n' # Print to Pythonwin interactive window -
eg. "1 : New York" - all is printed OK
arglist = []
arglist.append(pythonPath)
arglist.append(spawn_script)
arglist.append(fc_cntr) # This gets sent to the spawn_script but
only "1" gets printed
os.spawnv(os.P_WAIT, pythonPath, arglist)
fc = fcs.next()
....
--------------------------
## the spawn_script
import win32com.client, sys, os, time, re
in_featclass = sys.argv[1]
handle = open('C:\\log_file.txt', 'a')
handle.write(in_featclass + "\n") # ONLY the counter part gets printed
to the log file! Why?
--------------------------
Thanks, for help. 5 3290
On Sep 1, 9:54 am, goldtech <goldt...@worldpost.comwrote:
Hi,
I'm passing what I think is a string parameter to another Python
program (spawn.py) - see the code snip below. But only the counter
part gets printed to a log file via spawn.py. Yet the echo print to
the output window shows the whole string with the fc part. Better
explained below I hope, there's the calling .py and the spawn
script .py:
...snip...
while fc:
counter = counter + 1
fc_cntr = str(counter) + ' : ' + fc
print fc_cntr + '\n' # Print to Pythonwin interactive window -
eg. "1 : New York" - all is printed OK
arglist = []
arglist.append(pythonPath)
arglist.append(spawn_script)
arglist.append(fc_cntr) # This gets sent to the spawn_script but
only "1" gets printed
os.spawnv(os.P_WAIT, pythonPath, arglist)
fc = fcs.next()
...
--------------------------
## the spawn_script
import win32com.client, sys, os, time, re
in_featclass = sys.argv[1]
handle = open('C:\\log_file.txt', 'a')
handle.write(in_featclass + "\n") # ONLY the counter part gets printed
to the log file! Why?
--------------------------
Try handle.write(repr(sys.argv[1:]) + "\n")
and come back with your conclusions ... unless of course someone has
spoonfed you in the meantime.
Another clue: write yourself a little arg-dumper script and try
running it in a Command Prompt window.
8<---
import sys
for x, arg in enumerate(sys.argv):
print x, repr(arg)
8<---
HTH,
John
goldtech wrote:
Hi,
I'm passing what I think is a string parameter to another Python
program (spawn.py) - see the code snip below. But only the counter
part gets printed to a log file via spawn.py. Yet the echo print to
the output window shows the whole string with the fc part. Better
explained below I hope, there's the calling .py and the spawn
script .py:
...snip...
while fc:
counter = counter + 1
fc_cntr = str(counter) + ' : ' + fc
print fc_cntr + '\n' # Print to Pythonwin interactive window -
eg. "1 : New York" - all is printed OK
arglist = []
arglist.append(pythonPath)
arglist.append(spawn_script)
arglist.append(fc_cntr) # This gets sent to the spawn_script but
only "1" gets printed
os.spawnv(os.P_WAIT, pythonPath, arglist)
fc = fcs.next()
...
--------------------------
## the spawn_script
import win32com.client, sys, os, time, re
in_featclass = sys.argv[1]
Try
in_featclass = sys.argv[1:]
to collect all the arguments. At the moment I suspect some shell
argument processing is intervening, splitting your "N : something" into
multiple arguments.
handle = open('C:\\log_file.txt', 'a')
handle.write(in_featclass + "\n") # ONLY the counter part gets printed
to the log file! Why?
--------------------------
Thanks, for help.
regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
--------------- Asciimercial ------------------
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
----------- Thank You for Reading -------------
Steve Holden wrote:
[...]
>in_featclass = sys.argv[1]
Try
in_featclass = sys.argv[1:]
Sorry, that should have been
in_featclass = " ".join(sys.argv[1:])+"\n"
regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
--------------- Asciimercial ------------------
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
----------- Thank You for Reading -------------
Steve Holden wrote:
[...]
>in_featclass = sys.argv[1]
Try
in_featclass = sys.argv[1:]
Sorry, that should have been
in_featclass = " ".join(sys.argv[1:])+"\n"
regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
--------------- Asciimercial ------------------
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
----------- Thank You for Reading -------------
snip...
--------------------------
Try handle.write(repr(sys.argv[1:]) + "\n")
and come back with your conclusions ... unless of course someone has
spoonfed you in the meantime.
Another clue: write yourself a little arg-dumper script and try
running it in a Command Prompt window.
8<---
import sys
for x, arg in enumerate(sys.argv):
print x, repr(arg)
8<---
HTH,
John
It's a list.
....
['5', ':', 'Alaska.shp']
['6', ':', 'Arizona.shp']
['7', ':', 'Arkansas.shp']
['8', ':', 'California.shp']
['9', ':', 'Colorado.shp']
['10', ':', 'Connecticut.shp']
['11', ':', 'Delaware.shp']
['12', ':', 'District', 'of', 'Columbia.shp']
['13', ':', 'Florida.shp']
['14', ':', 'West', 'Virginia.shp']
['15', ':', 'Wisconsin.shp']
['16', ':', 'Wyoming.shp']
Thanks,
Lee G. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Belinda |
last post by:
Hello All
I have the following test.asp page which needs one parameter querystr
but my querystr is a very long string value. When I send a long value
the query string is getting truncated after...
|
by: whatduck |
last post by:
I'm having trouble passing a variable that contains spaces. If the
variable contains a space I get the following error:
"Application uses a value of the wrong type for the current operation."
...
|
by: Chris |
last post by:
I have two forms. From form one I have a listbox that when double
clicked I get the selected value (string) and store in a variable. I
parse the string to get the first 12 characters and store it...
|
by: Maxim |
last post by:
Hi!
A have a string variable (which is a reference type).
Now I define my Method like that:
void MakeFullName(string sNamePrivate)
{
sNamePrivate+="Gates"
}
|
by: Cole Shelton |
last post by:
Hi all,
I am trying to upload roughly 20-30k of binary data up to my webservice. At
first, I just took my byte array and encoded it as a base64 string and
passed it into my webservice. ...
|
by: Ranginald |
last post by:
Hi,
I'm having trouble passing a parameter from my default.aspx page to my
default2.aspx page.
I have values from a query in a list box and the goal is to pass the
"catID" from default.aspx...
|
by: R.Manikandan |
last post by:
Hi
In my code, one string variable is subjected to contain more amount of
characters. If it cross certain limit, the string content in the
varabile is automatically getting truncated and i am...
|
by: bill |
last post by:
Can someone please show me an example of passing a string value into an sql
statement in vb 2005? Something like this is what I'm after:
Dim sqlButton1 As String = "Select * from tblAssets where...
|
by: masso600 |
last post by:
char word;
in = fopen("test.txt", "r");
while(fscanf(in,"%s",&word)!=EOF)
{
/* Print all words */
/* printf("%s\n",&word); */
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM).
In this month's session, the creator of the excellent VBE...
|
by: MeoLessi9 |
last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: Aftab Ahmad |
last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below.
Dim IE As Object
Set IE =...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: marcoviolo |
last post by:
Dear all,
I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
| |