<s> import os , sys , traceback <EOL> import arcpy <EOL> from arcpy import da <EOL> dataset = arcpy . GetParameterAsText ( <NUM_LIT:0> ) <EOL> fieldName = arcpy . GetParameterAsText ( <NUM_LIT:1> ) <EOL> counter = <NUM_LIT:1> <EOL> try : <EOL> arcpy . AddMessage ( "<STR_LIT>" + str ( fieldName ) ) <EOL> arcpy . AddField_management ( dataset , fieldName , "<STR_LIT>" ) <EOL> fields = [ str ( fieldName ) ] <EOL> arcpy . AddMessage ( "<STR_LIT>" ) <EOL> rows = arcpy . da . UpdateCursor ( dataset , fields ) <EOL> for row in rows : <EOL> row [ <NUM_LIT:0> ] = counter <EOL> rows . updateRow ( row ) <EOL> counter += <NUM_LIT:1> <EOL> del rows <EOL> arcpy . SetParameter ( <NUM_LIT:0> , dataset ) <EOL> except arcpy . ExecuteError : <EOL> error = True <EOL> msgs = arcpy . GetMessages ( ) <EOL> arcpy . AddError ( msgs ) <EOL> print ( msgs ) <EOL> except : <EOL> error = True <EOL> tb = sys . exc_info ( ) [ <NUM_LIT:2> ] <EOL> tbinfo = traceback . format_tb ( tb ) [ <NUM_LIT:0> ] <EOL> pymsg = "<STR_LIT>" + tbinfo + "<STR_LIT>" + str ( sys . exc_info ( ) [ <NUM_LIT:1> ] ) <EOL> msgs = "<STR_LIT>" + arcpy . GetMessages ( ) + "<STR_LIT:\n>" <EOL> arcpy . AddError ( pymsg ) <EOL> arcpy . AddError ( msgs ) <EOL> print ( pymsg + "<STR_LIT:\n>" ) <EOL> print ( msgs ) </s>
