Select to view content in your preferred language

Python script running over Windows Server 2008 R2 and FV application connection

6806
9
02-11-2014 12:58 PM
GustavoOrozco
Emerging Contributor
To all Python and Flex Viewers Developers:

I'm a new Python user. I have a Python script that runs perfectly on Windows 7. However, whenever I try to run it over Windows Server 2008 R2, it doesn't work (maybe UNC paths?). The script should run automatically every day at 4:00 am. The script is already configure in the "Task Scheduler" for Windows Server 2008 R2 but when it finishes my information (feature class in a file geodatabase) is NOT updated.
Also, I want the script to stop and restart the service that is on the same server and the updates to be reflected whenever a user opens de FV application.
Any help will be very appreciated. Again, I'm pretty new in Python.
Thank you,
Tags (2)
0 Kudos
9 Replies
NeoGeo
by
Frequent Contributor
It would be best to just run it in IDLE on the server so you can see the error message and let us know what it is instead of trying to test it from task scheduler. 

I would say the next biggest problem one typically runs into is usually licensing.  Often the workstation (Windows 7) usually has ArcGIS Desktop on it and often the server does not have ArcGIS Desktop because it is a waste of a desktop license to put it on a server, and as a result, when you try to import an ESRI library (like arcgisscripting and arcpy) on the server, it fails because there is no license.
0 Kudos
GustavoOrozco
Emerging Contributor
It would be best to just run it in IDLE on the server so you can see the error message and let us know what it is instead of trying to test it from task scheduler. 

I would say the next biggest problem one typically runs into is usually licensing.  Often the workstation (Windows 7) usually has ArcGIS Desktop on it and often the server does not have ArcGIS Desktop because it is a waste of a desktop license to put it on a server, and as a result, when you try to import an ESRI library (like arcgisscripting and arcpy) on the server, it fails because there is no license.


Thanks JN, I'll do it and I will post my answers
0 Kudos
MichaelVolz
Esteemed Contributor
Gustavo:

On the Windows 2008 Server, do you have the Scheduled Task configured with the following settings:

1.)Run whether user is logged in or not
2.)Run with highest privileges

Are you running the python script directly from the Task Scheduler or are you calling the python script from a bat file?

Can you provide a screenshot of the Edit Action Properties for the scheduled task?

What version of ArcMap are you using?
0 Kudos
GustavoOrozco
Emerging Contributor
Gustavo:

On the Windows 2008 Server, do you have the Scheduled Task configured with the following settings:

1.)Run whether user is logged in or not
2.)Run with highest privileges

Are you running the python script directly from the Task Scheduler or are you calling the python script from a bat file?

Can you provide a screenshot of the Edit Action Properties for the scheduled task?

What version of ArcMap are you using?


Hi Michael,

Yes to number 1 and number 2. Also, I'm running the script directly from the Task Scheduler as a .py.

I'm running it over an dedicated ArcGIS 10.0 Server

I really appreciate your help Michael!
0 Kudos
MichaelVolz
Esteemed Contributor
Can you provide the screenshot that I asked for in a previous post?  I would like to see exactly how you are calling the python script directly.

Do you have ArcGIS Server software installed on this machine as well?
0 Kudos
GustavoOrozco
Emerging Contributor
Can you provide the screenshot that I asked for in a previous post?  I would like to see exactly how you are calling the python script directly.

Do you have ArcGIS Server software installed on this machine as well?


Hi Michael,

Thank you for your help, I discovered the issue. Eventhough we have ArcGIS license in the server, it is concurrent and it is not always available.
So, you are right, when the script runs it cannot find any license to access the ArcGIS libraries.
Thank you again.
0 Kudos
MichaelVolz
Esteemed Contributor
Can you set your script to run at night when no one else would be using a license to ensure that it will run without the license availability error?
0 Kudos
ChrisSnyder
Honored Contributor
You could also set up a loop at the beginning of your script to check if a license is available maybe every 10 seconds or so... Maybe after a duration of a few hours it would then give up trying... Something like this (very untested) code:


import time, sys, arcpy
licFlag = False
time1 = time.clock()
time2 = time.clock()
while licFlag == False or ((time2 - time1) / 3600) < 2):
    time2 = time.clock()
    if arcpy.CheckProduct('ArcInfo') == 'Available':
       licFlag = True
    else:
       time.sleep(10)
if licFlag == False:
   sys.exit(1) #give up
0 Kudos
NeoGeo
by
Frequent Contributor
It might be useful to know that you can turn your script into a geoprocessing service you can call, in which case it is guaranteed to use ArcGIS Server's license. 

Also, I think with the old arcgisscripting in 9.3, you were just screwed on the license issue, but with ArcPy there are actually two different installs of ArcPy, one for the server and one for the Desktop. You might be able to make it execute from the server one.  Here is the information Kevin H. from ESRI gave me:

1)For scripts being run on a scheduled basis, what determines which is used? Is it just the first one listed in sys.path?
>> on a default install, Python doesn't get put into the PATH. What happens is the last Python (32 or 64 bit) that gets installed is the one file associations are set to. So if you double click a script in Explorer, whatever the last Python (Arc* product) installed is what it'll run under.

2) Can standalone scripts on the ArcGIS server use the server installation, or do they have to use the Desktop installation?
>> yes. You can control what Python you execute against. See this blog topic. It's on 64bit Background, but the same applies for 64bit Server. http://blogs.esri.com/esri/arcgis/20...it-processing/

3)Do geoprocessing services always use the server installation no matter what? (I assume yes)
>> yes.

4)I notice that my 10.1 server by default installed server10.1.pth in the c:\python27\ArcGISx6410.1\Lib\site-packages whereas the desktop10.1.pth is in c:\python27\ArcGIS10.1\Lib\site-packages. Is this really best practice or should I have both use the 32 bit version?
>> You need both. You have and need a 32bit and 64bit version of Python. If you modify those files bad things may happen. "Dont cross the bits!"
0 Kudos