Esempio n. 1
0
    def enable(self, authfile):

        try:
            arcpy.EnableEnterpriseGeodatabase_management(
                self.sdeconn, authfile)

        except:

            print "{0}".format(arcpy.GetMessages())
            print "using {0} and {1}".format(self.sdeconn, authfile)
            raise ValueError('Failure on enable enterprise gdb from ArcGIS')

        print "".format(arcpy.GetMessages())
    for i in range(arcpy.GetMessageCount()):
        if "000565" in arcpy.GetMessage(
                i):  #Check if database connection was successful
            arcpy.AddReturnMessage(i)
            arcpy.AddMessage("Exiting!!")
            sys.exit(3)
        else:
            arcpy.AddReturnMessage(i)

    # Process: Enable geodatabase egdb...
    try:
        print "Enabling Enterprise Geodatabase egdb..."
        print Connection_File_Name_full_path
        print license
        arcpy.EnableEnterpriseGeodatabase_management(
            input_database=Connection_File_Name_full_path,
            authorization_file=license)
        for i in range(arcpy.GetMessageCount()):
            arcpy.AddReturnMessage(i)
    except:
        for i in range(arcpy.GetMessageCount()):
            arcpy.AddReturnMessage(i)

    if os.path.exists(Connection_File_Name_full_path):
        os.remove(Connection_File_Name_full_path)

#Check if no value entered for option
except SystemExit as e:
    if e.code == 2:
        parser.usage = ""
        print "\n"
Esempio n. 3
0
def esrify():
    #enable ESRI Geodatabase on the converted spatial database
    arcpy.EnableEnterpriseGeodatabase_management(
        NewDB, "T:/Program Files/ESRI/License10.2/sysgen/keycodes")
	# Usage:  out_file_location, out_file_name, DBMS_TYPE, instance, database, account_authentication, username, password, save_username_password(must be true)
	arcpy.CreateDatabaseConnection_management(out_folder_path=temp, out_name=Connection_File_Name, database_platform=database_type, instance=instance, database=database, account_authentication=account_authentication, username=username, password=password, save_user_pass="******")
    for i in range(arcpy.GetMessageCount()):
		if "000565" in arcpy.GetMessage(i):   #Check if database connection was successful
			arcpy.AddReturnMessage(i)			
			arcpy.AddMessage("Exiting!!")
			sys.exit(3)            
		else:
			arcpy.AddReturnMessage(i)			
	
	# Process: Enable geodatabase egdb...
	try:
		print "Enabling Enterprise Geodatabase egdb..."
		print Connection_File_Name_full_path
		print license
		arcpy.EnableEnterpriseGeodatabase_management(Connection_File_Name_full_path, license)
		for i in range(arcpy.GetMessageCount()):
			arcpy.AddReturnMessage(i)		
	except:
		for i in range(arcpy.GetMessageCount()):
			arcpy.AddReturnMessage(i)
			
	if os.path.exists(Connection_File_Name_full_path):
		 os.remove(Connection_File_Name_full_path)
	
#Check if no value entered for option	
except SystemExit as e:
	if e.code == 2:
		parser.usage = ""
		print "\n"
		parser.print_help()