Ejemplo n.º 1
0
def add_data_store_item(data_store_name=None, data_path=None):
    """add_data_store_item(data_store_name=None,data_path=None
        Checks if data store is already registered, if not registers it
    """
    if data_path not in [
            i[2] for i in arcpy.ListDataStoreItems(CONNECTIONFILE, 'FOLDER')
    ]:
        print 'This path is not a registered data store:', data_path
        dsStatus = arcpy.AddDataStoreItem(CONNECTIONFILE, "FOLDER",
                                          data_store_name, data_path,
                                          data_path)
        print "Data store addition status : " + str(dsStatus)
        validity = arcpy.ValidateDataStoreItem(CONNECTIONFILE, "FOLDER",
                                               data_store_name)
        print("The data store item '{}' is {}".format(data_store_name,
                                                      validity))
        return True
    else:
        print 'This path is already a registered data store:', data_path
        return False
Ejemplo n.º 2
0
    #arcpy.env.workspace = "D:/ArcSerTest/Server/Usa/USA.gdb"

    # create layers which will be available as input
    #arcpy.MakeFeatureLayer_management('USA.gdb/Cities', 'pt')

    # run the extract data task and assign it to the 'result' variable
    # only the cityhall layer was used as input, but the airport and firestation layers will be used in the service creation

    print "Try buffering..."
    #result = arcpy.Buffer_analysis(inp, res, "10 kilometers");
    result = arcpy.Buffer_analysis(inp, res, dis)
    #arcpy.ExtractDataTask_server("Counties", aoi, "File Geodatabase - GDB - .gdb", "ESRI GRID - GRID", os.path.join(arcpy.env.scratchFolder, "output.zip"))

    # make sure the folder is registered with the server, if not, add it to the datastore
    if arcpy.env.workspace not in [
            i[2] for i in arcpy.ListDataStoreItems(connPath, 'FOLDER')
    ]:
        # both the client and server paths are the same
        dsStatus = arcpy.AddDataStoreItem(connPath, "FOLDER", "CityData",
                                          arcpy.env.workspace,
                                          arcpy.env.workspace)
        print "Data store : " + str(dsStatus)

    # create service definition draft
    print "Creating sddraft file..."
    arcpy.CreateGPSDDraft(result,
                          sddraft,
                          serviceName,
                          server_type="ARCGIS_SERVER",
                          connection_file_path=connPath,
                          copy_data_to_server=False,
Ejemplo n.º 3
0
sdePath = outFolderPath + '\\' + outName
if os.path.exists(sdePath):
    os.remove(sdePath)

print(sdePath)
arcpy.CreateDatabaseConnection_management(
    out_folder_path=outFolderPath,
    out_name=outName,
    database_platform="ORACLE",
    instance="192.168.220.131/test",
    account_authentication="DATABASE_AUTH",
    username=sdeUserName,
    password=sdePw,
    save_user_pass="******",
    database="#",
    schema="#",
    version_type='POINT_IN_TIME',
    version="#",
    date="#")

agsPath = outFolderPath + '\AGSConnection116.ags'
arcpy.AddDataStoreItem(connection_file=agsPath,
                       datastore_type="DATABASE",
                       connection_name="myDBConnectOracleSpatial",
                       server_path=sdePath)

for i in arcpy.ListDataStoreItems(agsPath, "DATABASE"):
    validity = arcpy.ValidateDataStoreItem(agsPath, "DATABASE", i[0])
    print("The data item '{}' is {}".format(i[0], validity))
Ejemplo n.º 4
0
import arcpy

conn = sys.argv[1]
name = sys.argv[2]
sde_file = sys.argv[3]

# check whether the SDE to register is already register => if yes, delete the former registered SDE
for item in arcpy.ListDataStoreItems(conn, "DATABASE"):
    current_name = item[0]
    if current_name == name:
        arcpy.RemoveDataStoreItem(conn, "DATABASE", name)

arcpy.AddDataStoreItem(conn, "DATABASE", name, sde_file)
Ejemplo n.º 5
0
                if arcpy.Exists(ags_con4):
                    ags_con = ags_con4
                    arcpy.AddMessage("      SUCCESS: " + ags_con)

                else:
                    arcpy.AddMessage("      ERROR: " + agsconn +
                                     " not found on this system.")
                    boo_good = False
                    int_bad += 1

    if boo_good:
        arcpy.AddMessage("   Counting folder data stores...")

        try:
            stores = arcpy.ListDataStoreItems(ags_con, "FOLDER")
        except arcpy.ExecuteError:
            print(arcpy.GetMessages(2))

        arcpy.AddMessage("      SUCCESS: Found " + str(len(stores)) +
                         " data stores.")
        ags_good_conn.append(ags_con)

#------------------------------------------------------------------------------
# Step 30
# Test the ArcSDE Database Connections
#------------------------------------------------------------------------------
sde_good_conn = []
for sdeconn in arcsde_database_connections:
    arcpy.AddMessage(" ")
    arcpy.AddMessage("Testing " + sdeconn + ":")
Ejemplo n.º 6
0
    else:
        print "Server connection already established."
except arcpy.ExecuteError:
    e = sys.exc_info()[1]
    print(e.args[0])
    print arcpy.GetMessages() + "\n\n"
    sys.exit("Failed establishing server connection")

# If Image Service does not exist create Service drafts to publih the service
# Otherwise add new raster to existing Image Service

# When Image Service does not exist yet create a service definition draft and publish the Service
if not os.path.exists(workspace_gdb+"\\"+collection_id+ "Service.sd"):
    try:
        print "Try Creating SD draft"
        if data_store_path not in [i[2] for i in arcpy.ListDataStoreItems(con, 'FOLDER')]:
            # Register folder with ArcGIS Server site --> both the server path(out_folder_path 1.) and client path (out_folder_path 2.) are the same
            dsStatus = arcpy.AddDataStoreItem(con, "FOLDER", "Workspace for " + collection_id + 'Service', data_store_path, data_store_path)
            print "Data store : " + str(dsStatus)
        Sddraft = os.path.join(workspace_gdb, collection_id+"Service"+".sddraft")  # Name = Name der Bilddateien/ Ordner bzw. des sddraft
        # vorletzter Parameter der createImageSdd Draft Funktion muss nachher mit den Metadaten besetzt werden, als description des Services
        arcpy.CreateImageSDDraft(os.path.join(workspace_gdb, collection_id+'.gdb\\Master_'+collection_id), Sddraft, collection_id+"Service", 'ARCGIS_SERVER', None, False, 'WaCoDiS',
                                 str(json_metadata['productType']),
                                 str(json_metadata['productType'])+",image service, WaCoDiS")
    except arcpy.ExecuteError:
        e = sys.exc_info()[1]
        print(e.args[0])
        print arcpy.GetMessages() + "\n\n"
        sys.exit("Failed in creating SD draft")

    # Analyze the service definition draft
Ejemplo n.º 7
0
###############################################################################
tempMap = wrkspc + mxd
tempMap = tempMap.replace(".mxd", "_temp.mxd")
print "  Temp MXD = " + tempMap
os.remove(tempMap) if os.path.exists(tempMap) else None
mapDoc.saveACopy(tempMap)
mapDoc = arcpy.mapping.MapDocument(tempMap)
print
print "  Connection = " + con

###############################################################################
#                                                                             #
# Do data store path swap on temporary MXD                                    #
#                                                                             #
###############################################################################
database_stores = arcpy.ListDataStoreItems(con, 'DATABASE')
folder_stores = arcpy.ListDataStoreItems(con, 'FOLDER')

boo = False
for item in folder_stores:
    key = None

    if item[0] == ds_expected:
        boo = True

    if item[0] in ds_equivalents:
        print
        print "  Found AGS Data Store " + item[0] + " mapped to "
        print "    " + item[2]

        for equiv in ds_equivalents[item[0]]:
Ejemplo n.º 8
0
import arcpy

conn = sys.argv[1]
name = sys.argv[2]
server_path = sys.argv[3]

# check whether an additional publisher path has been provided
if (len(sys.argv) > 4):
    publisher_path = sys.argv[4]
else:
    publisher_path = ""

# check whether the folder to register is already register => if yes, delete the former registered folders
for item in arcpy.ListDataStoreItems(conn, "FOLDER"):
    current_name = item[0]
    if current_name == name:
        arcpy.RemoveDataStoreItem(conn, "FOLDER", name)

if publisher_path == "":
    arcpy.AddDataStoreItem(conn, "FOLDER", name, server_path)
else:
    arcpy.AddDataStoreItem(conn, "FOLDER", name, server_path, publisher_path)