def main(): # Before executing rest of script, lets check if 7-zip exe exists if not os.path.exists(sevenZipExePath): print 'ERROR: File path set by "sevenZipExePath" variable (' + \ sevenZipExePath + ') does not exist. Exiting script.' sys.exit(exitErrCode) # Check arguments results = check_args() if not results: sys.exit(exitErrCode) server, port, adminuser, password, doCopy, targetFolder, users = results if debug: print server, port, adminuser, password, doCopy, targetFolder, users # Determine where admins upload folder is located on server uploadsFolderInfo = getServerDirectory(server, port, adminuser, password, "UPLOADS") sdRootFolder = os.path.join(uploadsFolderInfo['physicalPath'], 'admin') print '\nNOTE: Uploads\admin folder is: ' + sdRootFolder + '\n' if not os.path.exists(sdRootFolder): print '\nERROR: the uploads\\admin folder ' + sdRootFolder + ' does not exist. Exiting script.' sys.exit(exitErrCode) # Get collection of .sd files sdFiles = get_sd_files(sdRootFolder) # Get collection of ArcGIS Service services on server agsServices = get_ags_services(server, port, adminuser, password) # Get the portal properties for each portal item referenced by the service # according to the services' json info portal = Portal('https://' + server + ':7443/arcgis', adminuser, password) props = getPortalPropsForServices(portal, agsServices) # Get list of item ids for all specified users userItemIDs = None if users: userItemIDs = getItemsIDs(portal, users) # Determine which sd files to copy sdFilesToCopy = filesToCopy(sdFiles, agsServices, userItemIDs) # Copy sd files if doCopy: copySDFiles(sdFilesToCopy, targetFolder, agsServices, props) # Print report report(sdFilesToCopy, agsServices) print '\nDone.'
def main(): totalSuccess = True # Before executing rest of script, lets check if 7-zip exe exists if not os.path.exists(sevenZipExePath): print 'ERROR: File path set by "sevenZipExePath" variable (' + \ sevenZipExePath + ') does not exist. Exiting script.' sys.exit(exitErrCode) # Check arguments results = check_args() if not results: sys.exit(exitErrCode) try: server, port, adminuser, password, doCopy, targetFolder, users = results if debug: print server, port, adminuser, password, doCopy, targetFolder, users # Determine where admins upload folder is located on server uploadsFolderInfo = getServerDirectory(server, port, adminuser, password, "UPLOADS") sdRootFolder = os.path.join(uploadsFolderInfo['physicalPath'], 'admin') print '\nNOTE: Uploads\admin folder is: ' + sdRootFolder + '\n' if not os.path.exists(sdRootFolder): print '\nERROR: the uploads\\admin folder ' + sdRootFolder + ' does not exist. Exiting script.' sys.exit(exitErrCode) # Get collection of .sd files sdFiles = get_sd_files(sdRootFolder) # Get collection of ArcGIS Service services on server agsServices = get_ags_services(server, port, adminuser, password) # Get the portal properties for each portal item referenced by the service # according to the services' json info portal = Portal('https://' + server + ':7443/arcgis', adminuser, password) props = getPortalPropsForServices(portal, agsServices) # Get list of item ids for all specified users userItemIDs = None if users: userItemIDs = getItemsIDs(portal, users) # Determine which sd files to copy sdFilesToCopy = filesToCopy(sdFiles, agsServices, userItemIDs) # Copy sd files if doCopy: copySDFiles(sdFilesToCopy, targetFolder, agsServices, props) # Print report report(sdFilesToCopy, agsServices) print '\nDone.' except: totalSuccess = False # 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]) # Print Python error messages for use in Python / Python Window print print "***** ERROR ENCOUNTERED *****" print pymsg + "\n" finally: if totalSuccess: sys.exit(0) else: sys.exit(1)
def main(): totalSuccess = True # Before executing rest of script, lets check if 7-zip exe exists if not os.path.exists(sevenZipExePath): print 'ERROR: File path set by "sevenZipExePath" variable (' + \ sevenZipExePath + ') does not exist. Exiting script.' sys.exit(exitErrCode) # Check arguments results = check_args() if not results: sys.exit(exitErrCode) try: server, port, adminuser, password, doCopy, targetFolder, users = results if debug: print server, port, adminuser, password, doCopy, targetFolder, users # Determine where admins upload folder is located on server uploadsFolderInfo = getServerDirectory(server, port, adminuser, password, "UPLOADS") sdRootFolder = os.path.join(uploadsFolderInfo['physicalPath'], 'admin') print '\nNOTE: Uploads\admin folder is: ' + sdRootFolder + '\n' if not os.path.exists(sdRootFolder): print '\nERROR: the uploads\\admin folder ' + sdRootFolder + ' does not exist. Exiting script.' sys.exit(exitErrCode) # Get collection of .sd files sdFiles = get_sd_files(sdRootFolder) # Get collection of ArcGIS Service services on server agsServices = get_ags_services(server, port, adminuser, password) # Get the portal properties for each portal item referenced by the service # according to the services' json info portal = Portal('https://' + server + ':7443/arcgis', adminuser, password) props = getPortalPropsForServices(portal, agsServices) # Get list of item ids for all specified users userItemIDs = None if users: userItemIDs = getItemsIDs(portal, users) # Determine which sd files to copy sdFilesToCopy = filesToCopy(sdFiles, agsServices, userItemIDs) # Copy sd files if doCopy: copySDFiles(sdFilesToCopy, targetFolder, agsServices, props) # Print report report(sdFilesToCopy, agsServices) print '\nDone.' except: totalSuccess = False # 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]) # Print Python error messages for use in Python / Python Window print print "***** ERROR ENCOUNTERED *****" print pymsg + "\n" finally: if totalSuccess: sys.exit(0) else: sys.exit(1)