# Batch and Schedule a Geoprocessing Script # Created by: Nathan Jennings # www.jenningsplanet.com # Created on: 05.24.2011 # Update on: 10.24.2011 # Copyright: 2011 ''' !!!! Change the output and log file paths as needed where the Chapter 11 folders exist.!!! Save these changes. Test the script to make sure it executes properly. ''' import arcpy, sys, os, traceback, datetime CURDATE = datetime.date.today() try: # workspace for input data # e.g c:\\pythonprimer\\chapter11\\data arcpy.env.workspace = arcpy.GetParameterAsText(0) # name of input shapefile feature class to be clipped # i.e. city_facilities.shp infile = arcpy.GetParameterAsText(1) # name of clip shapefile feature class to use as the clip file # i.e. central_city_commplan.shp clipfile = arcpy.GetParameterAsText(2) # output folder name for output # e.g. c:\\pythonprimer\\chapter11\\mydata output_ws = arcpy.GetParameterAsText(3) # name of the output feature class # NOTE: the output path is hard coded to the following path # the user will need to change this location outfile = output_ws + os.sep + arcpy.GetParameterAsText(4) # location of log file for tracking messages logfile = output_ws + '\\log' + str(CURDATE) + '.txt' if arcpy.Exists(logfile): arcpy.Delete_management(logfile) # Open the log file for writing log = open(logfile, 'a') print '\nRunning Clip Routine...' print >> log, 'Running Clip Routine...' print 'Input workspace is: ' + arcpy.env.workspace print >> log, 'Input workspace is: ' + arcpy.env.workspace print 'Input file is: ' + infile print >> log, 'Input file is: ' + infile print 'Clip file is: ' + clipfile print >> log, 'Clip file is: ' + clipfile print 'Output workspace is: ' + output_ws print >> log, 'Output workspace is: ' + output_ws print 'Output file is: ' + outfile print >> log, 'Output file is: ' + outfile if arcpy.Exists(outfile): arcpy.Delete_management(outfile) arcpy.Clip_analysis(infile, clipfile, outfile) print 'Completed Clip' print >> log, 'Completed Clip' log.close() except: print arcpy.GetMessages(2) tb = sys.exc_info()[2] tbinfo = traceback.format_tb(tb)[0] pymsg = "PYTHON ERRORS:\nTraceback Info:\n" + tbinfo + "\nError Info:\n " + str(sys.exc_type) + ": " + str(sys.exc_value) + "\n" msgs = "arcpy ERRORS:\n" + arcpy.GetMessages(2) + "\n" arcpy.AddError(msgs) arcpy.AddError(pymsg) print msgs print pymsg arcpy.AddMessage(arcpy.GetMessages(1)) print arcpy.GetMessages(1)
Solved! Go to Solution.
It seems I have two versions of Idle. I think I installed the 2.7.3 by downloading and installing it by myself. I am not sure about the other version though.
C:\>python Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>>import arcpy
import sys for p in sys.path: print p
It seems I have two versions of Idle. I think I installed the 2.7.3 by downloading and installing it by myself. I am not sure about the other version though.