SaultDon

Errno: 10054 when batch exporting mxd to pdf using arcpy.mapping - ArcGIS 10 SP2

Discussion created by SaultDon on Jul 20, 2011
Latest reply on Aug 22, 2011 by SaultDon
I wrote a small python script that exports all mxd's in a folder to PDF's, but I get the following error in PyScripter and I don't know why...:
[ATTACH]7866[/ATTACH]

The python interpreter has whole bunch of red in it:
Found 5 mxds for PDF exporting...
Directory: C:\Users\is0009\Desktop\temp

Exporting Rural_OCP_map_1_17x11.mxd to:
C:\Users\is0009\Desktop\temp\Rural_OCP_map_1_17x11.pdf
Traceback (most recent call last):
  File "<string>", line 70, in execInThread
  File "C:\Program Files (x86)\PyScripter\Lib\rpyc-python2x.zip\rpyc\core\netref.py", line 123, in __call__
  File "C:\Program Files (x86)\PyScripter\Lib\rpyc-python2x.zip\rpyc\core\netref.py", line 45, in syncreq
  File "C:\Program Files (x86)\PyScripter\Lib\rpyc-python2x.zip\rpyc\core\protocol.py", line 343, in sync_request
  File "C:\Program Files (x86)\PyScripter\Lib\rpyc-python2x.zip\rpyc\core\protocol.py", line 305, in serve
  File "C:\Program Files (x86)\PyScripter\Lib\rpyc-python2x.zip\rpyc\core\protocol.py", line 265, in _recv
  File "C:\Program Files (x86)\PyScripter\Lib\rpyc-python2x.zip\rpyc\core\channel.py", line 36, in recv
  File "C:\Program Files (x86)\PyScripter\Lib\rpyc-python2x.zip\rpyc\core\stream.py", line 105, in read
EOFError: [Errno 10054] An existing connection was forcibly closed by the remote host


Below is my script that I am trying:
The script is placed in a folder with a bunch of mxds.

#Import python modules
import os, sys, string, glob, arcpy
from arcpy import mapping

#Set local variables
mxdLst = glob.glob('*.mxd')
mxdCnt = len(mxdLst)
####
#Place script in same folder as MXDs to get 'current working directory'
####
baseF = os.getcwd()

#Print how many mxd's found
print '\n' + 'Found ' + str(mxdCnt) + ' mxds for PDF exporting...'
print 'Directory: ' + str(baseF) + '\n'

#Loop to process each mxd into a PDF
for mxds in mxdLst:
    PDFr = mxds.replace('mxd', 'pdf') #Replace 'mxd' extension with 'pdf'
    print 'Exporting ' + str(mxds) + ' to:' + '\n' + str(baseF) + '\\' + str(PDFr) #Print current mxd exporting and output pdf name...
    inMxd = arcpy.mapping.MapDocument(mxds) #Make current mxd in loop the mapdocument
    arcpy.mapping.ExportToPDF(inMxd, PDFr) #Export mapdocument to pdf
    print 'Done exporting: ' + str(PDFr)
del mxds

Attachments

Outcomes