Solved! Go to Solution.
# Import arcpy module import arcpy # Log file logfile = "C:\\arcgis\\scripts\\log\\speedreturn2.log" f = open(logfile, 'w') arcpy.ImportToolbox(r"C:\arcgis\Tools\GPS_speed.tbx", "TBX") try: arcpy.Speed_TBX() f.close() except: f.write(arcpy.GetMessages(2)) f.close()
The only thing I can think of is that the task is running under a different user that doesn't have access to your Y: drive. Check the properties of your scheduled task. In Windows 7, the task scheduler has a "When running a task, use the following user account" option. Is it the same account that you are logged into when you run from DOS?
net use Y: /d /Y net use Y: \\adminfs\gis IF EXIST "Y:\Data\Current\ROADBUFFERLL.shp" echo "Y:\Data\Current\ROADBUFFERLL.shp exist" >>C:\arcgis\scripts\log\speedreturn.log C:\Python27\ArcGIS10.1\python.exe C:\arcgis\Tools\SpeedReturn.py
So, I figured out that your line:
net use Y: \\adminfs\gis
Is mapping the Y: drive to \\adminfs\gis
As best I can figure out, the first line:
net use Y: /d /Y
is actually shorthand for:
net use Y: /delete /YES
which removes the existing connection to the Y: drive (/delete) then instructs DOS to remember any subsequent mapping you make. Is this correct?
>>> import arcpy >>> # mapped network drive test >>> shp = r'G:\Data\Shapefiles\Census_CedarCo\Block_Groups.shp' >>> if arcpy.Exists(shp): print 'yes' yes >>> # UNC path test >>> shp = r'\\ccgis\Cedar_CO_GIS\Data\Shapefiles\Census_CedarCo\Block_Groups.shp' >>> if arcpy.Exists(shp): print 'yes' yes
I totally agree that UNC paths would be better. My takeaway from this, for debugging purposes, is:
[INDENT]If you have data access problems, look for suspicious drive letters like Y: instead of the typical C: D: and E: . It usually implies that a network drive has been mapped and the mapping no longer exists, or cannot be found by the scheduled task. You can either change the script or model being run to use a UNC path instead of a drive letter, or, as an alternative when modifying the model or script is difficult, use the NET USE stuff...[/INDENT]