Strange string truncation in ArcToolbox

307
2
10-10-2011 05:21 AM
pierocavalieri
New Contributor
Hi all,

I have a simple Python script, which should check if a text file exists, and if not, create it:

filename = "%s\\%s.sql" % (sqlDir,viewName)
gp.AddMessage("Sql file: " + filename)
if not os.path.exists(filename):
  ecc.

Running the script from an IDE (I use PyScripter) it works fine (the debugger also displays correctly the filename)
Running it from the ArcToolbox, the directory part of the file path is removed, i.e. gp.AddMessage("Sql file: " + filename) prints only "\\viewName", so the line

if not os.path.exists(filename):

Can anyone explain me why this weired behaviour ?
Tags (2)
0 Kudos
2 Replies
DanPatterson_Retired
MVP Emeritus
did you try this for your replace?
filename.replace("\\", "/")
0 Kudos
pierocavalieri
New Contributor
Sorry, it was my mystake. When using:

gp.GetParameterAsText(pos_dir) 

pos_dir was not correct (but was correct in PyScripter...)

Thanks
Piero
0 Kudos