Script are changed by ESRI with g_ESRI_variable_1, g_ESRI_variable_2

3718
12
08-10-2018 12:09 AM
simoxu
by MVP Regular Contributor
MVP Regular Contributor

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
\\AppData\\Local\\Esri\\ArcGISPro\\Staging\\SharingProcesses\\0038
\\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.

Thanks.

12 Replies
simoxu
by MVP Regular Contributor
MVP Regular Contributor

Yes, I removed the history completely. I seriously think this is a bug in the Package Project tool.

It makes sense to analyze the code when you publish the geoprocessing tool as a service and make sure all the folders used in the code are accessible by the server, But as a project package, this process is not needed and the folders are relative to the project folder, which will be created when you unpack the project in ArcGIS Pro.

DanPatterson_Retired
MVP Emeritus

I agree... it is that user folder with your name that still bugs me... don't know why it appears, unless your data were in it or it belongs to history

simoxu
by MVP Regular Contributor
MVP Regular Contributor

A bug related to this topic has been confirmed by ESRI.

#BUG-000116650 Python script within the default toolbox in a project is appended with an invalid directory path after sharing the project as a project package.