0

I wrote a tool that creates a table whith errors and fills an error field. Then I published it on the server as a geoprocessing service. But when I run it causes an error

enter image description here

But when I comment arcpy.CalculateField_management(temp_table_error, "Error_text", "'Раскорчевка должна быть заполнена'", "PYTHON_9.3") it works great. I don't understand what should I do.

arcpy.env.workspace = "C:\inetpub.........\GosKontrol_temp.gdb"
arcpy.env.overwriteOutput = True
arcpy.CreateTable_management(arcpy.env.workspace, "Excel_Error_"+str(varOrgname))
temp_table_error=arcpy.env.workspace+"\\Excel_Error_"+str(varOrgname)
arcpy.AddField_management(temp_table_error, "ObjectID_vovl", "LONG", 9)
arcpy.AddField_management(temp_table_error, "Error_text", "TEXT", 255)
UchGoskontr_temp="C:\inetpub\......\GosKontrol_temp.gdb\UchGoskontr_temp"
##########################################################################
expr1=""""Kod_vz"=1 AND "Korch_vz" IS NULL AND "Orgname" = """ + str(varOrgname)

arcpy.MakeTableView_management (UchGoskontr_temp, "stateslyr1", expr1)

#
fieldmappings = arcpy.FieldMappings()
fieldmappings.addTable(temp_table_error)
try:
    fieldmap = fieldmappings.getFieldMap(fieldmappings.findFieldMapIndex("ObjectID_vovl"))
    fieldmap.addInputField("stateslyr1", "OBJECTID")
    fieldmappings.replaceFieldMap(fieldmappings.findFieldMapIndex("ObjectID_vovl"), fieldmap)
except:
    pass

arcpy.Append_management("stateslyr1",temp_table_error,"NO_TEST",fieldmappings)

arcpy.CalculateField_management(temp_table_error, "Error_text", "'Раскорчевка должна быть заполнена'", "PYTHON_9.3")

arcpy.Delete_management("stateslyr1")

  • Could you write out the error into the question (instead of a picture). Translated to English would be helpful too. – KHibma Jun 22 at 13:35
  • @KHibma, there is no description. Just "Failed". – Lora Jun 22 at 14:01
0

I completely changed my code,made an output to Excel without an additional table and without a field calculator, using SearchCursor. Service worked successfully.


workbook = xlsxwriter.Workbook('C:/inetpub/wwwroot/.....Otchet_error_'+str(varOrgname)+'.xlsx')
worksheet1 = workbook.add_worksheet("Errors")

expr1=""""Kod_vz"=1 AND "Korch_vz" IS NULL AND "Orgname" = """ + str(varOrgname)
  
x=0
y=0
with arcpy.da.SearchCursor(worklayer,"OBJECTID",expr1)as cursor:
    for row in cursor:
        worksheet1.write_number(x,y, row[0] )
        worksheet1.write(x,y+1, u'Раскорчевка должна быть заполнена')
        x+=1

workbook.close()

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.