Select to view content in your preferred language

Analyze script tool in Pro doesn't work

236
1
02-10-2023 08:43 AM
DHighness
New Contributor III

I'm having a horrible time trying to publish script tools in ArcGIS Pro to ArcGIS Server. Currently I have a script tool that does pretty much nothing. It runs through cleanly in Pro but when I try to share it as a Web Tool I can never get past the Analyze which appears to be required. It would be great if that could be circumvented in some way because it seems to be the biggest computer Karen ever invented. Please let me worry if my script is going to function or not!

Anyway, my script tool hangs at Analyze. The script does nothing! I've been publishing script tools to Server from Desktop for a decade!

To make matters worse, when I get these script tools to Analyze, I publish the simple one and then go in to the services folder and replace the script tool with the real python script. The real script will never ever analyze!

Thanks

import arcpy, os, time, traceback, sys

def main():
    try:
        #get the oids parameter
        state_abbrv = arcpy.GetParameterAsText(0)
        cnty_name = arcpy.GetParameterAsText(1)
        uscong_dist = arcpy.GetParameterAsText(2)
        program = arcpy.GetParameterAsText(3)

        scr_ws = arcpy.env.scratchWorkspace
        arcpy.env.overwriteOutput = True
        arcpy.env.parallelProcessingFactor = "25%"

        # map documents
        inFldr = r"\\drive\share\folder"

        # PDF files
        nowDt = time.localtime(time.time())
        sdt = time.strftime("_%Y%m%d_%H%M%S", nowDt)
        outFilePdf = os.path.join(scr_ws,"Summary_Rpt" + sdt + ".pdf")

        pdfDoc = arcpy.mp.PDFDocumentCreate(outFilePdf)
        pg = os.path.join(inFldr,"publish.pdf")
        pdfDoc.appendPages(pg)
        pdfDoc.saveAndClose()
        del pdfDoc
        arcpy.AddMessage("PDF completed")

        #Set the output parameter
        arcpy.SetParameter(4, outFilePdf)
        arcpy.SetParameter(5, outFilePdf)
        
        return

    except arcpy.ExecuteError:
        # Get the tool error messages
        #
        msgs = arcpy.GetMessages(2)

        # Return tool error messages for use with a script tool
        #
        arcpy.AddError(msgs)
        return

    except:
        # Get the traceback object
        #
        tb = sys.exc_info()[2]
        tbinfo = traceback.format_tb(tb)[0]

        # Concatenate information together concerning the error into a message string
        #
        pymsg = "PYTHON ERRORS:\nTraceback info:\n" + tbinfo + "\nError Info:\n" + str(sys.exc_info()[1])
        msgs = "arcpy ERRORS:\n" + arcpy.GetMessages(2) + "\n"

        # Return python error messages for use in script tool or Python Window
        #
        arcpy.AddError(pymsg)
        arcpy.AddError(msgs)
        return

#Main part of the script
if __name__ == '__main__':
    main()
    arcpy.AddMessage("Export completed")

 

0 Kudos
1 Reply
DHighness
New Contributor III

This thing finally did Analyze and I got it published but this is ridiculous! I need a way to circumvent the Analyze. I'm still going to have to go on Server to the "arcgisinput" folder and replace the published script with the real one.

0 Kudos