Beispiel #1
0
def createAGSConnFile(username, password):

    success = True
    printMsg = True

    try:
        print
        print "--Create ArcGIS Administrative connection file..."
        print
        
        # Set connection folder and file variables
        fileRoot = "ops-server-config"
        scriptPath = sys.argv[0]
        agsConnFolderPath = scriptPath[:(scriptPath.find(fileRoot) + len(fileRoot))]
        agsConnFile = "OpsServer_admin.ags"
        agsConnFilePath = agsConnFolderPath + os.sep + agsConnFile
        
        # Create ArcGIS Server connection file
        print "\tCreating admin connection file " + agsConnFilePath + "..."
        
        results = createAGSConnectionFile(agsConnFolderPath, agsConnFile, servername,
                            username, password, serverPort)
        success = checkResults(results, printMsg)
            
    except:
        success = 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:
        # Return success flag
        return success    
def createAGSConnFile(servername, username, password, serverport, useSSL):

    success = True
    printMsg = True
    agsConnFilePath = None

    try:

        # Set connection folder and file variables
        agsConnFolderPath = os.path.dirname(sys.argv[0])
        agsConnFile = "OpsServer_publish.ags"
        agsConnFilePath = os.path.join(agsConnFolderPath, agsConnFile)

        results = createAGSConnectionFile(agsConnFolderPath, agsConnFile,
                                          servername, username, password,
                                          serverport, useSSL,
                                          "PUBLISH_GIS_SERVICES")

        success = checkResults(results, printMsg)

        if not os.path.exists(agsConnFilePath):
            agsConnFilePath = None

    except:
        success = 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:
        # Return success flag
        return agsConnFilePath
def createAGSConnFile(servername, username, password, serverport, useSSL):

    success = True
    printMsg = True
    agsConnFilePath = None
    
    try:
        
        # Set connection folder and file variables
        agsConnFolderPath = os.path.dirname(sys.argv[0])
        agsConnFile = "OpsServer_publish.ags"
        agsConnFilePath = os.path.join(agsConnFolderPath, agsConnFile)
        
        results = createAGSConnectionFile(agsConnFolderPath, agsConnFile, servername,
                            username, password, serverport, useSSL, "PUBLISH_GIS_SERVICES")
        
        success = checkResults(results, printMsg)
        
        if not os.path.exists(agsConnFilePath):
            agsConnFilePath = None
            
    except:
        success = 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:
        # Return success flag
        return agsConnFilePath