Traceback (most recent call last): File "C:\GIS\Python Scripts\AddressPoints\Point_2_Ca.py", line 125, in <module> edit.stopOperation() SystemError: error return without exception set
import arcpy
from arcpy import env
import time
import datetime
import pythonaddins
import os
fc = "TonyTwoWay.DBO.TT"
workspace = r"Database Servers\DSD15_SQLEXPRESS.gds\TonyTwoWay (VERSION:dbo.DEFAULT)"
arcpy.env.overwriteOutput = True
arcpy.env.qualifiedFieldNames = False
# Start an edit session. Must provide the worksapce.
edit = arcpy.da.Editor(workspace)
# Edit session is started without an undo/redo stack for versioned data
# (for second argument, use False for unversioned data)
edit.startEditing(True)
# Start an edit operation
edit.startOperation()
input = arcpy.GetParameterAsText(0)
rows = arcpy.SearchCursor(input)
for row in rows:
geom = row.Shape
X = geom.centroid.X
Y = geom.centroid.Y
del rows, row
row_values = (X, Y, (X, Y))
cursor = arcpy.da.InsertCursor(fc, ["X_Coord", "Y_Coord", "SHAPE@XY"])
cursor.insertRow(row_values)
del cursor
####Select by location on parcels with created point
Parcellyr = "Taxparcels"
arcpy.MakeFeatureLayer_management(Parcellyr, "in_memory\Parcel layer")
entries = int(arcpy.GetCount_management(fc).getOutput(0))
for i in xrange(entries):
arcpy.MakeFeatureLayer_management(fc, "in_memory\point layer", "\"OBJECTID\"={}".format(str(i) + ""))
arcpy.SelectLayerByLocation_management("in_memory\Parcel layer", "INTERSECT", "in_memory\point layer", "", "NEW_SELECTION")
#if arcpy.Exists(pt_lyr): arcpy.Delete_management(pt_lyr)
arcpy.CopyFeatures_management("in_memory\Parcel layer", "in_memory\Sel_Par")
table = "Vector.DBO.PARCELADMIN"
try:
arcpy.AddJoin_management("in_memory\Sel_Par", "ACCOUNT", table, "Acct", "KEEP_COMMON")
except BaseException as e:
pass
arcpy.CopyFeatures_management("in_memory\Sel_Par","in_memory\ParLYR")
arcpy.MakeFeatureLayer_management("in_memory\ParLYR", "in_memory\Par")
#### populates fields
add_fields = ["ACCOUNT","SiteNum","OwnerName","SiteAddres","SiteNumSfx","SiteStreet","Predir","StreetType","Postdir", "SubName", "SiteCity", "SiteZip", "SubName"]
# fix args
if not isinstance(add_fields, list):
# from script tool
add_fields = add_fields.split(';')
# do not need this scratch file
fcOutput = r'C:\Temp\Default.gdb\temp_join' #'temp_join' when using workspace = r"C:\Temp\default.gdb"
arcpy.SpatialJoin_analysis("in_memory\Par", "in_memory\point layer", fcOutput, 'JOIN_ONE_TO_MANY', 'KEEP_COMMON')
# grab oid field from points
oid_t = arcpy.Describe(fc).OIDFieldName
Field4 = "SubNum" #Field from spaital Join
Field4a = "SiteSubNum"
#Field5 = "City" #Field from spaital Join
#Field5a = "BusinsName"
# init rowW and rowR
curR = arcpy.SearchCursor(fcOutput)
join_dict = dict([(r.JOIN_FID,[r.getValue(f) for f in add_fields]) for r in curR])
del curR
Fields = ["SubNum","City",]
rows = arcpy.da.SearchCursor(fcOutput, Fields)
for row in rows:
Num1 = rows[0]
#Num2 = rows[1]
# Now update the new target
curW = arcpy.UpdateCursor(fc)
for row in curW:
t_oid = row.getValue(oid_t)
if t_oid in join_dict:
for f in add_fields:
row.setValue(f, join_dict[t_oid][add_fields.index(f)])
row.setValue('GIS_STEW', "Canyon Co")
row.setValue('IssuedBy', "TA")
row.setValue('Status', "Active")
row.setValue('StartDate', datetime.datetime.now().strftime('%m/%d/%Y'))
row.setValue('SiteState', "ID")
row.setValue('SiteCounty', "Canyon")
row.setValue('StreetName', row.SiteStreet + " " + row.StreetType)
row.setValue('Verified', "Yes,TA")
row.setValue(Field4a, Num1)
#row.setValue(Field5a, Num2)
#else:
#row.StreetName = curR.SiteStreet
curW.updateRow(row)
del row, curW, rows
#arcpy.SelectLayerByAttribute_management(Parcellyr, "CLEAR_SELECTION")
arcpy.Delete_management("in_memory\Parcel layer")
arcpy.Delete_management("in_memory\point layer")
arcpy.Delete_management("in_memory\Sel_Par")
arcpy.Delete_management("in_memory\ParLYR")
arcpy.Delete_management("in_memory\Par")
#arcpy.Delete_management(r'in_memory\temp_join')
# Stop the edit operation.
edit.stopOperation()
# Stop the edit session and save the changes
edit.stopEditing(True)
With versioned SDE data in an Oracle database I use:
edit.startEditing(False, True)
with unversioned SDE data in an Oracle database I use
edit.startEditing(False, False)
these settings work for me
edit.stopOperation() SystemError: error return without exception set
edit.stopOperation() SystemError: error return without exception set
Is the user already in an edit session in Arcmap before your script starts editing? If so then I would check with tech support and look into
[BUG-000089820: The Editor class from ArcPy returns an error message when the 'stopEditing()' command is executed when an existing edit session is open on the same workspace. "RuntimeError: Start edit session."]
I had a situation where the user is already in an edit session so I didn't think I had to start editing in python script but the tech support person had me start editing. However when I went to stopEditing it failed with the error you received and they pointed out the bug. In my case I just removed the stopediting from my script and it seems to be functioning.
The error"RuntimeError: workspace already in transaction mode" happens when i have my data as versioned and set the line to edit.startEditing(True,False).
I have unversioned the data and change the edit.startEditing(True) line to edit.startEditing(True,False). I get the same error.edit.stopOperation() SystemError: error return without exception set
i have registered as versioned and changed the line back to edit.startEditing(True) now i get this error,edit.stopOperation() SystemError: error return without exception set
So no matter which way i change the code i get the same error. Anyone have any other ideas what's going on and how can i fix this?
I have not, i am still messing around with it.
I'm also experiencing the same problem. Did anyone ever get an answer to this?
I had the same issue:
My problem and solution: I forgot edit.startOperation()!
Workspace already in transaction mode: my problem and solution:
Check to make sure the field that need to be updated, surely exist. Add an If to check the filed, then
the problem is gone,
lang