POST
|
#Post and Reconcile script: #My perpetual Error: "Work Space wrong type Error 000301" is frustrating and I need some help. Thank You import arcpy import time, datetime # Current Day Day = time.strftime("%m-%d-%Y", time.localtime()) # Current Time Time = time.strftime("%I:%M:%S %p", time.localtime()) editDB = "Database Connections\\Arden_Admin.sde" Post_Reconcile_Log1_txt = "\\\\Client\\R$\\Engineering and Planning\\GIS\\813 - Post_Reconcile Log\\Post_Reconcile_Log1.txt" # Set workspace workspace = editDB # Set the workspace environment arcpy.env.workspace = workspace arcpy.env.overwriteOutput = True # Start Time print 'Process Started at ' + str(Day) + " " + str(Time) # block new connections to the working and prod database. print "Blocking Connections..." arcpy.AcceptConnections(editDB, False) # disconnect all users from the working and prod database. print "Disconnecting Users..." arcpy.DisconnectUser(editDB, "ALL") #Get a list of all versions besides QAQC and DEFAULT to pass into the ReconcileVersions tool. ver1List = [ver1.name for ver1 in arcpy.da.ListVersions(editDB) if ver1.name != 'GSWC_SDE.Quality Control' and ver1.name != 'sde.DEFAULT'] print ver1List arcpy.ReconcileVersions_management(editDB, "ALL_VERSIONS", "GSWC_SDE_Quality Control", ver1List, "LOCK_ACQUIRED", "ABORT_CONFLICTS", "BY_OBJECT", "FAVOR_EDIT_VERSION", "POST", "KEEP_VERSION", Post_Reconcile_Log1_txt) # Extract QAQC version from the list of versions to pass to ReconcileVersions tool. ver2List = [ver2.name for ver2 in arcpy.da.ListVersions(editDB) if ver2.name == 'GSWC_SDE.Quality Control'] print ver2List arcpy.ReconcileVersions_management(editDB, "ALL_VERSIONS", "sde.DEFAULT", ver2List, "LOCK_ACQUIRED", "ABORT_CONFLICTS", "BY_OBJECT", "FAVOR_EDIT_VERSION", "POST", "KEEP_VERSION", Post_Reconcile_Log1_txt) #Allow the database to begin accepting connections again print "Set databases to allow connections..." arcpy.AcceptConnections(editDB, True) #My Error message is below: #Runtime error Traceback (most recent call last): File "<string>", line 41, in <module> File "d:\program files (x86)\arcgis\desktop10.3\arcpy\arcpy\management.py", line 16193, #in ReconcileVersions raise e ExecuteError: ERROR 000301: The workspace is of the wrong type Failed to execute (ReconcileVersions).
... View more
07-20-2017
08:39 AM
|
0
|
3
|
988
|
POST
|
Thanks Joe for your response, yes it is a very strange Error and frustrating-Any solutions?
... View more
07-19-2017
08:11 AM
|
0
|
0
|
1486
|
POST
|
This script is far from perfect, but I'm getting a very strange error message and I was hopeful someone could help me solve the issue. Thank You for your time: ERROR 000301: The workspace is of the wrong type import arcpy import sys import os import time, datetime #import pyodbc import traceback # \\\\Constant Vars\\\\ # Database Connection editDB ="Database Connections/EdnaRoad_Admin.sde" # Current Day Day = time.strftime("%m-%d-%Y", time.localtime()) # Current Time Time = time.strftime("%I:%M:%S %p", time.localtime()) # \\\\pyodbc.connect vars\\\\ #sqlsvrname = 'gisavglis' #sqldbname = 'Arden' loggingTableName = "dbo.PYTHON_SCRIPT_LOGGING" # Set workspace workspace = editDB # Set the workspace environment arcpy.env.workspace = workspace arcpy.env.overwriteOutput = True def log_messages(scriptName,Status, ErrorCode): runDate = datetime.datetime.fromtimestamp(time.time()).strftime('%Y-%m-%d %H:%M:%S') egdb_conn = arcpy.ArcSDESQLExecute(workspace) sql = "INSERT INTO {4} (ScriptName,RunDate,Status,ErrorCode) VALUES ('{0}','{1}','{2}','{3}')".format(scriptName, runDate, Status, ErrorCode, loggingTableName) try: egdb_conn.startTransaction() print("Attempt to execute SQL Statement: {0}".format(sql)) egdb_return = egdb_conn.execute(sql) egdb_conn.commitTransaction() except Exception as err: print(err) egdb_return = False try: # Start Time print 'Process Started at ' + str(Day) + " " + str(Time) # block new connections to the working and prod database. print "Blocking Connections..." arcpy.AcceptConnections(editDB, False) # disconnect all users from the working and prod database. print "Disconnecting Users..." arcpy.DisconnectUser(editDB, "ALL") # Get a list of all versions besides QAQC and DEFAULT to pass into the ReconcileVersions tool. ver1List = [ver1.name for ver1 in arcpy.da.ListVersions(editDB) if ver1.name != 'DBO.Quality Control' and ver1.name != 'dbo.DEFAULT'] # Execute the ReconcileVersions tool with QAQC Target Version then delete all versions besides QAQC print "Reconcile/post versions to Quality Control...." arcpy.ReconcileVersions_management(editDB, "ALL_VERSIONS", "DBO.Quality Control", ver1List, "LOCK_ACQUIRED", "NO_ABORT", "BY_OBJECT", "FAVOR_EDIT_VERSION", "POST", "") # Extract QAQC version from the list of versions to pass to ReconcileVersions tool. ver2List = [ver2.name for ver2 in arcpy.da.ListVersions(editDB) if ver2.name == 'DBO.Quality Control'] # Execute the ReconcileVersions tool with DEFAULT Target Version and delete QAQC version print "Reconcile/post Quality Control to DEFAULT..." arcpy.ReconcileVersions_management(editDB, "ALL_VERSIONS", "dbo.DEFAULT", ver2List, "LOCK_ACQUIRED", "NO_ABORT", "BY_OBJECT", "FAVOR_EDIT_VERSION", "POST", "") print("==============================") print ("Unregister Tables Started") print("==============================") # **** wildcards for tables I don't want to include **** for tbs in [tb for tb in arcpy.ListTables() if '_log' not in tb and 'GenerateId' not in tb and 'PYTHON_SCRIPT' not in tb]: print tbs arcpy.UnregisterAsVersioned_management(tbs,"NO_KEEP_EDIT","COMPRESS_DEFAULT") # If you want to include all tables in the database use this instead: # for tbs in arcpy.ListTables(): # print tbs # arcpy.UnregisterAsVersioned_management(tbs,"NO_KEEP_EDIT","COMPRESS_DEFAULT") print("==============================") print ("Unregister Feature Classes is started") print("==============================") datasets = arcpy.ListDatasets("*", "Feature") for dataset in datasets: fcList = arcpy.ListFeatureClasses("*","",dataset) for fc in fcList: print fc arcpy.UnregisterAsVersioned_management(fc,"NO_KEEP_EDIT","COMPRESS_DEFAULT") # Run the compress tool. print "Compressing database..." arcpy.Compress_management(editDB) # \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ script initiation, Rec/Post process error handling \\\\\\\\\\\\\\\\\\\\\\\\\\\\\ except: print 'An error occured' failMsg = '\nSCRIPT FAILURE IN SCRIPT INITIATION OR RECONCILE-POST PROCESS, \n' failMsg += 'Most recent GP messages below.\n' failMsg += arcpy.GetMessages() +'\n' failMsg += '\nTraceback messages below.\n' failMsg += traceback.format_exc().splitlines()[-1] print failMsg #write error log info print 'Logging error to database....' # THIS SECTION FOR LOGGING ERRORS TO A DB TABLE log_messages('ReconcilePost_AssetIDs_QAQC','Failure', failMsg) sys.exit() # ////////////////////////////////////// REGISTER AS VERSIONED AND RE-CREATE VERSIONS ///////////////////////////////// try: print("==============================") print ("register tables is started") print("==============================") # **** wildcards for tables I don't want to version **** for tbs in [tb for tb in arcpy.ListTables() if '_log' not in tb and 'GenerateId' not in tb and 'PYTHON_SCRIPT' not in tb]: print tbs arcpy.RegisterAsVersioned_management(tbs, "NO_EDITS_TO_BASE") # If you want to include all tables in the database use this: # for tbs in arcpy.ListTables(): # print tbs # arcpy.RegisterAsVersioned_management(tbs, "NO_EDITS_TO_BASE") print("==============================") print ("register Feature Class is started") print("==============================") datasets = arcpy.ListDatasets("*", "Feature") for dataset in datasets: fcList = arcpy.ListFeatureClasses("*","",dataset) for fc in fcList: print fc arcpy.RegisterAsVersioned_management(fc, "NO_EDITS_TO_BASE") # create versions #print "Creating Versions..." #arcpy.CreateVersion_management(editDB, 'dbo.DEFAULT', 'QAQC', 'PRIVATE') #arcpy.CreateVersion_management(editDB, 'DBO.QAQC', 'MICHAEL', 'PUBLIC') #arcpy.CreateVersion_management(editDB, 'DBO.QAQC', 'KAREN', 'PUBLIC') #arcpy.CreateVersion_management(editDB, 'DBO.QAQC', 'COLLECTOR', 'PUBLIC') # /////////////////////////////////// ANALYZE DATASETS AND CALC STATISTICS ///////////////////////////////////// # NOTE: Rebuild indexes can accept a Python list of datasets. # Get a list of all the datasets the user has access to. # First, get all the stand alone tables, feature classes and rasters. dataList = arcpy.ListTables() + arcpy.ListFeatureClasses() + arcpy.ListRasters() # Next, for feature datasets get all of the datasets and featureclasses # from the list and add them to the master list. for dataset in arcpy.ListDatasets("*", "Feature"): arcpy.env.workspace = os.path.join(workspace, dataset) dataList += arcpy.ListFeatureClasses() + arcpy.ListDatasets() # reset the workspace arcpy.env.workspace = workspace # Concatenate all datasets into a list datasetList = [ds for ds in dataList] print "rebuilding indexes" # Execute rebuild indexes # Note: to use the "SYSTEM" option the workspace user must be an administrator. arcpy.RebuildIndexes_management(workspace, "SYSTEM", datasetList, "ALL") print('Rebuild Complete') print "analyzing datasets" arcpy.AnalyzeDatasets_management(workspace, "SYSTEM", datasetList, "ANALYZE_BASE", "ANALYZE_DELTA", "ANALYZE_ARCHIVE") print "analysis complete" #Allow the database to begin accepting connections again print "Set databases to allow connections..." arcpy.AcceptConnections(editDB, True) # \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ If Script Successful, log into database \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ print 'Data has been synched succesfully and logged in the tracking database' # conn = pyodbc.connect('Trusted_Connection=yes', driver='{SQL Server}', server="ggogisapp1.scwater.com", database= "Database Connections/Arden.Admin.sde, ALL") # cursor = conn.cursor() # # You will need to create a table in sql to log to and add fields that you want to log into and pass them as params to this cursor # cursor.execute("""INSERT INTO [dbo].[PYTHON_SCRIPT_TRACKER] (ScriptName,RunDate,Status,ErrorCode) VALUES ('ReconcilePost_AssetIDs_QAQC',GetDate(),'Success','All Steps Completed Without Error'); """) # conn.commit() # del cursor # conn.close() # print 'Script is finished' # /////////////////////////////////Register as Versioned Error handling area//////////////////////////////////////////// except: print 'An error occured' failMsg = '\nSCRIPT FAILURE IN VERSIONING PROCESS\n' failMsg += 'Most recent GP messages below.\n' failMsg += arcpy.GetMessages() +'\n' failMsg += '\nTraceback messages below.\n' failMsg += traceback.format_exc().splitlines()[-1] print failMsg #write error log info print 'Logging error to database....' # THIS SECTION FOR LOGGING ERRORS TO A DB TABLE log_messages('ReconcilePost_AssetIDs_QAQC','Failure', failMsg) conn = pyodbc.connect('Trusted_Connection=yes', driver='{SQL Server}', server=sqlsvrname, database=sqldbname) cursor = conn.cursor() #You will need to create a table in sql to log to and add fields that you want to log into and pass them as params to this cursor cursor.execute("""INSERT INTO [dbo].[PYTHON_SCRIPT_TRACKER] (ScriptName,RunDate,Status,ErrorCode) VALUES ('ReconcilePost_AssetIDs_QAQC',GetDate(),'Failure',(?)); """,failMsg) conn.commit() conn.close() sys.exit() print "Script has run its course and is now complete"
... View more
07-06-2017
01:15 PM
|
0
|
7
|
3205
|
POST
|
Hi Cort, I apologize for my late response but I'm just now getting around at looking at your code and I have a question. When running your script, I'm getting an error message that the pyodbc module does not exist. I'm also a little confused about how the sql file structure log works. Your thoughts please
... View more
06-27-2017
01:22 PM
|
0
|
1
|
618
|
POST
|
We are a very large Water Utility Company with over 40 Geodatabases and web map applications. All our Web applications have several user friendly widgets where information can be added or removed. To resolve some quality control issues, my office has also employed a very tight versioning setup where we the default geodatabase is locked. But the locked geodatabases no longer support the web application widgets. We are in a pickle and not sure how proceed. Please tell me yours thoughts on this issue and is there a workaround?
... View more
06-16-2017
10:48 AM
|
1
|
2
|
719
|
POST
|
Not sure where to begin on this one, so a little direction would help...... Thank You in advance I am looking for a geoprocessing tool to evaluate several fields and feature classes and determine whether or not the same number is a match in a table. The attachment is a good illustration of what needs to happen and any tools should report a match or no match or Null. Unfortunately all the fields are text. Thank You once again, Larry Adgate
... View more
06-13-2017
01:20 PM
|
0
|
1
|
642
|
POST
|
Hi Judson, your thread was very interesting because I am trying to do the same thing. Did you ever finalize your script and how is it working? If possible, can you forward a final copy to me Thanks, Larry Adgate
... View more
06-06-2017
02:19 PM
|
0
|
0
|
721
|
POST
|
Hi Clinton, Can you show me what a python dictionary would look like, a production set preferably , and is the data stored in a table?
... View more
06-06-2017
08:00 AM
|
0
|
2
|
813
|
POST
|
Thank You for your thoughts, at least now I have some ideas how to solve the problem. Larry
... View more
06-05-2017
02:03 PM
|
1
|
4
|
813
|
POST
|
I would really appreciate some help on this to help solve a long term problem in our office. We have 114 feature classes where one of the fields is void of information or is wrong. We also have a very large table with the corrected information and there is commonality between the Feature class and the table. As a solution but very time consuming , I can joint the feature class and the table and using the field calculator transfer the information. Provided is an attachment to Illustrate what needs to happen. Once again, thank You for your help on this, Larry
... View more
06-05-2017
09:11 AM
|
0
|
6
|
1146
|
POST
|
Thank You Cort, Are you going to ESRI Conference in San Diego? Larry Adgate
... View more
06-02-2017
02:00 PM
|
0
|
1
|
1159
|
Title | Kudos | Posted |
---|---|---|
1 | 02-19-2019 09:17 AM | |
2 | 11-27-2018 10:53 AM | |
1 | 06-16-2017 10:48 AM | |
1 | 06-06-2017 11:26 AM | |
1 | 06-05-2017 02:03 PM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|