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 3167
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: lllomh |
last post by:
Define the method first
this.state = {
buttonBackgroundColor: 'green',
isBlinking: false, // A new status is added to identify whether the button is blinking or not
}
autoStart=()=>{
|
by: giovanniandrean |
last post by:
The energy model is structured as follows and uses excel sheets to give input data:
1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
|
by: NeoPa |
last post by:
Hello everyone.
I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report).
I know it can be done by selecting :...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
|
by: Teri B |
last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course.
0ne-to-many. One course many roles.
Then I created a report based on the Course form and...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM)
Please note that the UK and Europe revert to winter time on...
|
by: nia12 |
last post by:
Hi there,
I am very new to Access so apologies if any of this is obvious/not clear.
I am creating a data collection tool for health care employees to complete. It consists of a number of...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
|
by: isladogs |
last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, Mike...
| |