AnsweredAssumed Answered

Script are changed by ESRI with g_ESRI_variable_1, g_ESRI_variable_2

Question asked by simo on Aug 10, 2018
Latest reply on Aug 13, 2018 by simo

It's a surprise to me that ArcGIS Pro changes the python code in my script tool when I pack the project and upload the ppkx to ArcGIS Online.


Here is the first a few lines of code for one script tool in the unpacked ppkx, please pay attention to the codes between "Esri start of added imports" and "Esri end of added variables"


# Esri start of added imports
import sys, os, arcpy
# Esri end of added imports

# Esri start of added variables
g_ESRI_variable_1 = "EventID = '{}'"
g_ESRI_variable_2 = os.path.join(arcpy.env.scriptWorkspace,'..\\..\\..\\Users\\simoxu
\\RDA Tools for ArcGIS Pro\\p20\\current_checkout_attachments')
# Esri end of added variables

# Name:        rda_checkout
# Purpose:     checkout the assessment for a specific event and map it
# Author:      simoxu
# Created:     27/07/2018
from arcpy import da
import os,sys
import shutil


In one place in my original code, I have the following line:

checkout_image_path= os.path.join(homefolder,"current_checkout_attachments")


But it was replaced with the following code, which is causing fatal error for the tool itself.

checkout_image_path= os.path.join(homefolder,g_ESRI_variable_2)



It's quite strange that ArcGIS Pro packaging tool will change my code without informing me ---  I only found out this when I shared the project package with others and then was told the tools could not run properly.


Is it only me? Any advice?

I am using ArcGIS Pro 2.2.1, by the way.