-
Notifications
You must be signed in to change notification settings - Fork 1
/
CREATE_GDB_ENFORCED.PY
545 lines (521 loc) · 27.9 KB
/
CREATE_GDB_ENFORCED.PY
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
#CREATES A FGDB IN A ORGANIZATION STANDARD LOCATION USING AN ORGANIZATION STANDARD SCHEMA
import os
import errno
import arcpy
import sys
import traceback
#Get user input
gdb_name = arcpy.GetParameterAsText(0)
fc_name = arcpy.GetParameterAsText(1)
fc_type = arcpy.GetParameterAsText(2)
has_m = arcpy.GetParameterAsText(3)
has_z = arcpy.GetParameterAsText(4)
spat_ref = arcpy.GetParameterAsText(5)
unit_code = arcpy.GetParameterAsText(6)
unit_name = arcpy.GetParameterAsText(7)
reg_code = arcpy.GetParameterAsText(8)
time_format = arcpy.GetParameterAsText(9)
#Get the current project directory
curr = arcpy.mp.ArcGISProject("CURRENT").filePath
folder = "/".join(curr.split("\\")[:-1])
#Get the current working data directory within the project
#This is where GRSM policy requires the GDB to be
#Edit this to meet your needs, but the "Create Folders in Pro Project" MUST create this directory first!
#So that means if this needs to be different, the python for "Create Folders in Pro Project" must also be edited!
############
#EDIT ME AFTER EDITING NEW_FC.py!!!!!!!!!!!
os.chdir(folder+"/data/working")
############
path = os.getcwd()
#Create the GDB
#path +"\\"+ gdb_name+".gdb = path +"\\"+ gdb_name+".gdb"
if arcpy.Exists(path +"\\"+ gdb_name+".gdb"):
arcpy.AddWarning (path +"\\"+ gdb_name+".gdb already exists!")
else:
arcpy.CreateFileGDB_management(path, gdb_name)
arcpy.AddMessage ("Sasquatch created the file geodatabae in "+path+"\\"+gdb_name)
arcpy.SetParameterAsText(10, gdb_name)
#Create the NPS Standard Domains
#Create DOM_PUBLICDISPLAY_NPS2016 domain
try:
PUBLICDISPLAYDict = {"No Public Map Display":"No Public Map Display", "Public Map Display": "Public Map Display"}
domains = arcpy.da.ListDomains(path +"\\"+ gdb_name+".gdb")
domain_names = [domain.name for domain in domains]
if 'DOM_PUBLICDISPLAY_NPS2016' in domain_names :
arcpy.AddWarning("DOM_PUBLICDISPLAY_NPS2016 already exists")
for domain in domains:
if domain.name == 'DOM_PUBLICDISPLAY_NPS2016':
values = [cv for cv in domain.codedValues]
if not set(set(["No Public Map Display", "Public Map Display"])).issubset(values):
arcpy.AddWarning("DOM_PUBLICDISPLAY_NPS2016 is missing a coded value pair.")
for code in DATAACCESSDict:
arcpy.AddCodedValueToDomain_management(path+"\\"+gdb_name+".gdb", "DOM_PUBLICDISPLAY_NPS2016", code, DATAACCESSDict[code])
arcpy.AddWarning("But Sasquatch took care of it.")
else:
#arcpy.SetParameterAsText(10, gdb_name)
arcpy.CreateDomain_management(path+"\\"+gdb_name+".gdb", "DOM_PUBLICDISPLAY_NPS2016", "Public Map Display Yes/No", "TEXT", "CODED")
arcpy.AddMessage ("Sasquatch created the DOM_PUBLICDISPLAY_NPS2016 domain")
for code in PUBLICDISPLAYDict:
arcpy.AddCodedValueToDomain_management(path+"\\"+gdb_name+".gdb", "DOM_PUBLICDISPLAY_NPS2016", code, PUBLICDISPLAYDict[code])
arcpy.AddMessage ("Sasquatch added coded domain values to the DOM_PUBLICDISPLAY_NPS2016 domain")
except arcpy.ExecuteError:
msgs = arcpy.GetMessages(2)
arcpy.AddError(msgs)
except:
tb = sys.exc_info()[2]
tbinfo = traceback.format_tb(tb)[0]
pymsg = "PYTHON ERRORS:\nTraceback info:\n" + tbinfo + "\nError Info:\n" + str(sys.exc_info()[1])
msgs = "ArcPy ERRORS:\n" + arcpy.GetMessages(2) + "\n"
arcpy.AddError(pymsg)
arcpy.AddError(msgs)
#Create DOM_DATAACCESS_NPS2016 domain
try:
DATAACCESSDict = {"Internal NPS Only":"Internal NPS Only", "Secure Access Only": "Secure Access Only", "Unrestricted": "Unrestricted"}
domains = arcpy.da.ListDomains(path +"\\"+ gdb_name+".gdb")
domain_names = [domain.name for domain in domains]
if 'DOM_DATAACCESS_NPS2016' in domain_names :
arcpy.AddWarning("DOM_DATAACCESS_NPS2016 already exists")
for domain in domains:
if domain.name == 'DOM_DATAACCESS_NPS2016':
values = [cv for cv in domain.codedValues]
if not set(set(["Internal NPS Only", "Secure Access Only", "Unrestricted"])).issubset(values):
arcpy.AddWarning("DOM_DATAACCESS_NPS2016 is missing a coded value pair.")
for code in DATAACCESSDict:
arcpy.AddCodedValueToDomain_management(path+"\\"+gdb_name+".gdb", "DOM_DATAACCESS_NPS2016", code, DATAACCESSDict[code])
arcpy.AddWarning("But Sasquatch took care of it.")
else:
arcpy.CreateDomain_management(path+"\\"+gdb_name+".gdb", "DOM_DATAACCESS_NPS2016", "Restriction Level", "TEXT", "CODED")
arcpy.AddMessage ("Sasquatch created the DOM_DATAACCESS_NPS2016 domain")
for code in DATAACCESSDict:
arcpy.AddCodedValueToDomain_management(path+"\\"+gdb_name+".gdb", "DOM_DATAACCESS_NPS2016", code, DATAACCESSDict[code])
arcpy.AddMessage ("Sasquatch added coded domain values to the DOM_DATAACCESS_NPS2016 domain")
except arcpy.ExecuteError:
msgs = arcpy.GetMessages(2)
arcpy.AddError(msgs)
except:
tb = sys.exc_info()[2]
tbinfo = traceback.format_tb(tb)[0]
pymsg = "PYTHON ERRORS:\nTraceback info:\n" + tbinfo + "\nError Info:\n" + str(sys.exc_info()[1])
msgs = "ArcPy ERRORS:\n" + arcpy.GetMessages(2) + "\n"
arcpy.AddError(pymsg)
arcpy.AddError(msgs)
#Create DOM_XYACCURACY_NPS2016 domain
try:
XYACCURACYDict = {"Unknown":"Unknown", "<5cm": "<5cm", ">=5cm and <50cm": ">=5cm and <50cm" , ">=50cm and < 1m": ">=50cm and < 1m", ">=1m and <5m": ">=1m and <5m" , ">=5m and <14m": ">=5m and <14m" , ">=14m": ">=14m" , "Scaled": "Scaled"}
domains = arcpy.da.ListDomains(path +"\\"+ gdb_name+".gdb")
domain_names = [domain.name for domain in domains]
if 'DOM_XYACCURACY_NPS2016' in domain_names :
arcpy.AddWarning("DOM_XYACCURACY_NPS2016 already exists")
for domain in domains:
if domain.name == 'DOM_XYACCURACY_NPS2016':
values = [cv for cv in domain.codedValues]
if not set(set(["Unknown", "<5cm", ">=5cm and <50cm", ">=50cm and < 1m", ">=1m and <5m", ">=5m and <14m", ">=14m","Scaled"])).issubset(values):
arcpy.AddWarning("DOM_XYACCURACY_NPS2016 is missing a coded value pair.")
for code in XYACCURACYDict:
arcpy.AddCodedValueToDomain_management(path+"\\"+gdb_name+".gdb", "DOM_XYACCURACY_NPS2016", code, XYACCURACYDict[code])
arcpy.AddWarning("But Sasquatch took care of it.")
else:
arcpy.CreateDomain_management(path+"\\"+gdb_name+".gdb", "DOM_XYACCURACY_NPS2016", "Data of unknown origin, spatial accuracy,unknown scale or resolution where a minimum mapping unit or scale of reference cannot be statistically determined (Qualitative accuracy assessment).", "TEXT", "CODED")
arcpy.AddMessage ("Sasquatch created the DOM_XYACCURACY_NPS2016 domain")
for code in XYACCURACYDict:
arcpy.AddCodedValueToDomain_management(path+"\\"+gdb_name+".gdb", "DOM_XYACCURACY_NPS2016", code, XYACCURACYDict[code])
arcpy.AddMessage ("Sasquatch added coded domain values to the DOM_XYACCURACY_NPS2016 domain")
except arcpy.ExecuteError:
msgs = arcpy.GetMessages(2)
arcpy.AddError(msgs)
except:
tb = sys.exc_info()[2]
tbinfo = traceback.format_tb(tb)[0]
pymsg = "PYTHON ERRORS:\nTraceback info:\n" + tbinfo + "\nError Info:\n" + str(sys.exc_info()[1])
msgs = "ArcPy ERRORS:\n" + arcpy.GetMessages(2) + "\n"
arcpy.AddError(pymsg)
arcpy.AddError(msgs)
#Create DOM_REGIONCODE_NPS2016 domain
try:
REGIONCODEDict = {"AKR":"AKR", "IMR": "IMR", "MWR": "MWR" , "NCR": "NCR", "NER": "NER" , "PWR": "PWR" , "SER": "SER" , "WASO": "WASO"}
domains = arcpy.da.ListDomains(path +"\\"+ gdb_name+".gdb")
domain_names = [domain.name for domain in domains]
if 'DOM_REGIONCODE_NPS2016' in domain_names:
arcpy.AddWarning("DOM_REGIONCODE_NPS2016 already exists")
for domain in domains:
if domain.name == 'DOM_REGIONCODE_NPS2016':
values = [cv for cv in domain.codedValues]
if not set(set(["AKR", "IMR", "MWR", "NCR", "NER", "PWR", "SER","WASO"])).issubset(values):
arcpy.AddWarning("DOM_REGIONCODE_NPS2016 is missing a coded value pair.")
for code in REGIONCODEDict:
arcpy.AddCodedValueToDomain_management(path+"\\"+gdb_name+".gdb", "DOM_REGIONCODE_NPS2016", code, REGIONCODEDict[code])
arcpy.AddWarning("But Sasquatch took care of it.")
else:
arcpy.CreateDomain_management(path+"\\"+gdb_name+".gdb", "DOM_REGIONCODE_NPS2016", "Region Code", "TEXT", "CODED")
arcpy.AddMessage ("Sasquatch created the DOM_REGIONCODE_NPS2016 domain")
for code in REGIONCODEDict:
arcpy.AddCodedValueToDomain_management(path+"\\"+gdb_name+".gdb", "DOM_REGIONCODE_NPS2016", code, REGIONCODEDict[code])
arcpy.AddMessage ("Sasquatch added coded domain values to the DOM_REGIONCODE_NPS2016 domain")
except arcpy.ExecuteError:
msgs = arcpy.GetMessages(2)
arcpy.AddError(msgs)
except:
tb = sys.exc_info()[2]
tbinfo = traceback.format_tb(tb)[0]
pymsg = "PYTHON ERRORS:\nTraceback info:\n" + tbinfo + "\nError Info:\n" + str(sys.exc_info()[1])
msgs = "ArcPy ERRORS:\n" + arcpy.GetMessages(2) + "\n"
arcpy.AddError(pymsg)
arcpy.AddError(msgs)
#Create the Feature Class
in_Table = path+"\\"+gdb_name+".gdb\\"+fc_name
if arcpy.Exists(in_Table):
arcpy.AddWarning (in_Table+" Exists already")
else:
arcpy.CreateFeatureclass_management(path+"\\"+gdb_name+".gdb", fc_name, fc_type, "", has_m, has_z, spat_ref)
arcpy.AddMessage ("Sasquatch created"+in_Table)
#Create required PUBLICDISPLAY Field
try:
in_Field = "PUBLICDISPLAY"
default = "No Public Map Display"
if len(arcpy.ListFields(in_Table,in_Field))>0:
arcpy.AddWarning (in_Field+" exits already")
else:
arcpy.AddField_management(path+"\\"+gdb_name+".gdb\\"+fc_name, in_Field, "TEXT", "", "", 50, in_Field, "NON_NULLABLE", "REQUIRED", "DOM_PUBLICDISPLAY_NPS2016")
arcpy.AddMessage ("Sasquatch created the "+in_Field+" field and the attribute domain is DOM_PUBLICDISPLAY_NPS2016")
arcpy.AssignDefaultToField_management(path+"\\"+gdb_name+".gdb\\"+fc_name, in_Field, default)
arcpy.AddMessage ("Saquatch assigned "+default+" as the default value for "+ in_Field)
except arcpy.ExecuteError:
msgs = arcpy.GetMessages(2)
arcpy.AddError(msgs)
except:
tb = sys.exc_info()[2]
tbinfo = traceback.format_tb(tb)[0]
pymsg = "PYTHON ERRORS:\nTraceback info:\n" + tbinfo + "\nError Info:\n" + str(sys.exc_info()[1])
msgs = "ArcPy ERRORS:\n" + arcpy.GetMessages(2) + "\n"
arcpy.AddError(pymsg)
arcpy.AddError(msgs)
#Create required DATAACCESS Field
try:
in_Field = "DATAACCESS"
default = "Internal NPS Only"
if len(arcpy.ListFields(in_Table,in_Field))>0:
arcpy.AddWarning(in_Field+" exits already")
else:
arcpy.AddField_management(path+"\\"+gdb_name+".gdb\\"+fc_name, in_Field, "TEXT", "", "", 50, in_Field, "NON_NULLABLE", "REQUIRED", "DOM_DATAACCESS_NPS2016")
arcpy.AddMessage ("Sasquatch created the "+in_Field+" field and the attribute domain is DOM_DATAACCESS_NPS2016")
arcpy.AssignDefaultToField_management(path+"\\"+gdb_name+".gdb\\"+fc_name, in_Field, default)
arcpy.AddMessage ("Saquatch assigned "+default+" as the default value for "+ in_Field)
except arcpy.ExecuteError:
msgs = arcpy.GetMessages(2)
arcpy.AddError(msgs)
except:
tb = sys.exc_info()[2]
tbinfo = traceback.format_tb(tb)[0]
pymsg = "PYTHON ERRORS:\nTraceback info:\n" + tbinfo + "\nError Info:\n" + str(sys.exc_info()[1])
msgs = "ArcPy ERRORS:\n" + arcpy.GetMessages(2) + "\n"
arcpy.AddError(pymsg)
arcpy.AddError(msgs)
#Create required UNITCODE Field
try:
in_Field = "UNITCODE"
if len(arcpy.ListFields(in_Table,in_Field))>0:
arcpy.AddWarning (in_Field+" exits already")
else:
arcpy.AddField_management(path+"\\"+gdb_name+".gdb\\"+fc_name, in_Field, "TEXT", "", "", 10, in_Field, "NON_NULLABLE", "REQUIRED")
arcpy.AddMessage ("Sasquatch created the "+in_Field+" field")
arcpy.AssignDefaultToField_management(path+"\\"+gdb_name+".gdb\\"+fc_name, in_Field, unit_code)
arcpy.AddMessage ("Saquatch assigned "+unit_code+" as the default value for "+ in_Field)
except arcpy.ExecuteError:
msgs = arcpy.GetMessages(2)
arcpy.AddError(msgs)
except:
tb = sys.exc_info()[2]
tbinfo = traceback.format_tb(tb)[0]
pymsg = "PYTHON ERRORS:\nTraceback info:\n" + tbinfo + "\nError Info:\n" + str(sys.exc_info()[1])
msgs = "ArcPy ERRORS:\n" + arcpy.GetMessages(2) + "\n"
arcpy.AddError(pymsg)
arcpy.AddError(msgs)
#Create required UNITNAME Field
try:
in_Field = "UNITNAME"
if len(arcpy.ListFields(in_Table,in_Field))>0:
arcpy.AddWarning (in_Field+" exits already")
else:
arcpy.AddField_management(path+"\\"+gdb_name+".gdb\\"+fc_name, in_Field, "TEXT", "", "", 254, in_Field, "NON_NULLABLE", "REQUIRED")
arcpy.AddMessage ("Sasquatch created the "+in_Field+" field")
arcpy.AssignDefaultToField_management(path+"\\"+gdb_name+".gdb\\"+fc_name, in_Field, unit_name)
arcpy.AddMessage ("Saquatch assigned "+unit_name+" as the default value for "+ in_Field)
except arcpy.ExecuteError:
msgs = arcpy.GetMessages(2)
arcpy.AddError(msgs)
except:
tb = sys.exc_info()[2]
tbinfo = traceback.format_tb(tb)[0]
pymsg = "PYTHON ERRORS:\nTraceback info:\n" + tbinfo + "\nError Info:\n" + str(sys.exc_info()[1])
msgs = "ArcPy ERRORS:\n" + arcpy.GetMessages(2) + "\n"
arcpy.AddError(pymsg)
arcpy.AddError(msgs)
#Create required GROUPCODE Field
try:
in_Field = "GROUPCODE"
if len(arcpy.ListFields(in_Table,in_Field))>0:
arcpy.AddWarning (in_Field+" exits already")
else:
arcpy.AddField_management(path+"\\"+gdb_name+".gdb\\"+fc_name, in_Field, "TEXT", "", "", 10, in_Field, "NULLABLE", "NON_REQUIRED")
arcpy.AddMessage ("Sasquatch created the "+in_Field+" field")
except arcpy.ExecuteError:
msgs = arcpy.GetMessages(2)
arcpy.AddError(msgs)
except:
tb = sys.exc_info()[2]
tbinfo = traceback.format_tb(tb)[0]
pymsg = "PYTHON ERRORS:\nTraceback info:\n" + tbinfo + "\nError Info:\n" + str(sys.exc_info()[1])
msgs = "ArcPy ERRORS:\n" + arcpy.GetMessages(2) + "\n"
arcpy.AddError(pymsg)
arcpy.AddError(msgs)
#Create required GROUPNAME Field
try:
in_Field = "GROUPNAME"
if len(arcpy.ListFields(in_Table,in_Field))>0:
arcpy.AddWarning (in_Field+" exits already")
else:
arcpy.AddField_management(path+"\\"+gdb_name+".gdb\\"+fc_name, in_Field, "TEXT", "", "", 254, in_Field, "NULLABLE", "NON_REQUIRED")
arcpy.AddMessage ("Sasquatch created the "+in_Field+" field")
except arcpy.ExecuteError:
msgs = arcpy.GetMessages(2)
arcpy.AddError(msgs)
except:
tb = sys.exc_info()[2]
tbinfo = traceback.format_tb(tb)[0]
pymsg = "PYTHON ERRORS:\nTraceback info:\n" + tbinfo + "\nError Info:\n" + str(sys.exc_info()[1])
msgs = "ArcPy ERRORS:\n" + arcpy.GetMessages(2) + "\n"
arcpy.AddError(pymsg)
arcpy.AddError(msgs)
#Create required REGIONCODE Field
try:
in_Field = "REGIONCODE"
if len(arcpy.ListFields(in_Table,in_Field))>0:
arcpy.AddWarning (in_Field+" exits already")
else:
arcpy.AddField_management(path+"\\"+gdb_name+".gdb\\"+fc_name, in_Field, "TEXT", "", "", 4, in_Field, "NON_NULLABLE", "REQUIRED", "DOM_REGIONCODE_NPS2016")
arcpy.AddMessage ("Sasquatch created the "+in_Field+" field and the attribute domain is DOM_REGIONCODE_NPS2016")
arcpy.AssignDefaultToField_management(path+"\\"+gdb_name+".gdb\\"+fc_name, in_Field, reg_code)
arcpy.AddMessage ("Saquatch assigned "+reg_code+" as the default value for "+ in_Field)
except arcpy.ExecuteError:
msgs = arcpy.GetMessages(2)
arcpy.AddError(msgs)
except:
tb = sys.exc_info()[2]
tbinfo = traceback.format_tb(tb)[0]
pymsg = "PYTHON ERRORS:\nTraceback info:\n" + tbinfo + "\nError Info:\n" + str(sys.exc_info()[1])
msgs = "ArcPy ERRORS:\n" + arcpy.GetMessages(2) + "\n"
arcpy.AddError(pymsg)
arcpy.AddError(msgs)
#Create required CREATEDATE Field
try:
in_Field = "CREATEDATE"
if len(arcpy.ListFields(in_Table,in_Field))>0:
arcpy.AddWarning (in_Field+" exits already")
else:
arcpy.AddField_management(path+"\\"+gdb_name+".gdb\\"+fc_name, in_Field, "DATE", "", "", "", in_Field, "NON_NULLABLE", "REQUIRED")
arcpy.AddMessage ("Sasquatch created the "+in_Field+" field")
except arcpy.ExecuteError:
msgs = arcpy.GetMessages(2)
arcpy.AddError(msgs)
except:
tb = sys.exc_info()[2]
tbinfo = traceback.format_tb(tb)[0]
pymsg = "PYTHON ERRORS:\nTraceback info:\n" + tbinfo + "\nError Info:\n" + str(sys.exc_info()[1])
msgs = "ArcPy ERRORS:\n" + arcpy.GetMessages(2) + "\n"
arcpy.AddError(pymsg)
arcpy.AddError(msgs)
#Create required CREATEUSER Field
try:
in_Field = "CREATEUSER"
if len(arcpy.ListFields(in_Table,in_Field))>0:
arcpy.AddWarning (in_Field+" exits already")
else:
arcpy.AddField_management(path+"\\"+gdb_name+".gdb\\"+fc_name, in_Field, "TEXT", "", "", 50, in_Field, "NON_NULLABLE", "REQUIRED")
arcpy.AddMessage ("Sasquatch created the "+in_Field+" field")
except arcpy.ExecuteError:
msgs = arcpy.GetMessages(2)
arcpy.AddError(msgs)
except:
tb = sys.exc_info()[2]
tbinfo = traceback.format_tb(tb)[0]
pymsg = "PYTHON ERRORS:\nTraceback info:\n" + tbinfo + "\nError Info:\n" + str(sys.exc_info()[1])
msgs = "ArcPy ERRORS:\n" + arcpy.GetMessages(2) + "\n"
arcpy.AddError(pymsg)
arcpy.AddError(msgs)
#Create required EDITDATE Field
try:
in_Field = "EDITDATE"
if len(arcpy.ListFields(in_Table,in_Field))>0:
arcpy.AddWarning (in_Field+" exits already")
else:
arcpy.AddField_management(path+"\\"+gdb_name+".gdb\\"+fc_name, in_Field, "DATE", "", "", "", in_Field, "NON_NULLABLE", "REQUIRED")
arcpy.AddMessage ("Sasquatch created the "+in_Field+" field")
except arcpy.ExecuteError:
msgs = arcpy.GetMessages(2)
arcpy.AddError(msgs)
except:
tb = sys.exc_info()[2]
tbinfo = traceback.format_tb(tb)[0]
pymsg = "PYTHON ERRORS:\nTraceback info:\n" + tbinfo + "\nError Info:\n" + str(sys.exc_info()[1])
msgs = "ArcPy ERRORS:\n" + arcpy.GetMessages(2) + "\n"
arcpy.AddError(pymsg)
arcpy.AddError(msgs)
#Create required EDITUSER Field
try:
in_Field = "EDITUSER"
if len(arcpy.ListFields(in_Table,in_Field))>0:
arcpy.AddWarning (in_Field+" exits already")
else:
arcpy.AddField_management(path+"\\"+gdb_name+".gdb\\"+fc_name, in_Field, "TEXT", "", "", 50, in_Field, "NON_NULLABLE", "REQUIRED")
arcpy.AddMessage ("Sasquatch created the "+in_Field+" field")
except arcpy.ExecuteError:
msgs = arcpy.GetMessages(2)
arcpy.AddError(msgs)
except:
tb = sys.exc_info()[2]
tbinfo = traceback.format_tb(tb)[0]
pymsg = "PYTHON ERRORS:\nTraceback info:\n" + tbinfo + "\nError Info:\n" + str(sys.exc_info()[1])
msgs = "ArcPy ERRORS:\n" + arcpy.GetMessages(2) + "\n"
arcpy.AddError(pymsg)
arcpy.AddError(msgs)
#Create required MAPMETHOD Field
try:
in_Field = "MAPMETHOD"
if len(arcpy.ListFields(in_Table,in_Field))>0:
arcpy.AddWarning (in_Field+" exits already")
else:
arcpy.AddField_management(path+"\\"+gdb_name+".gdb\\"+fc_name, in_Field, "TEXT", "", "", 254, in_Field, "NON_NULLABLE", "REQUIRED")
arcpy.AddMessage ("Sasquatch created the "+in_Field+" field")
except arcpy.ExecuteError:
msgs = arcpy.GetMessages(2)
arcpy.AddError(msgs)
except:
tb = sys.exc_info()[2]
tbinfo = traceback.format_tb(tb)[0]
pymsg = "PYTHON ERRORS:\nTraceback info:\n" + tbinfo + "\nError Info:\n" + str(sys.exc_info()[1])
msgs = "ArcPy ERRORS:\n" + arcpy.GetMessages(2) + "\n"
arcpy.AddError(pymsg)
arcpy.AddError(msgs)
#Create required MAPSOURCE Field
try:
in_Field = "MAPSOURCE"
if len(arcpy.ListFields(in_Table,in_Field))>0:
arcpy.AddWarning (in_Field+" exits already")
else:
arcpy.AddField_management(path+"\\"+gdb_name+".gdb\\"+fc_name, in_Field, "TEXT", "", "", 254, in_Field, "NON_NULLABLE", "REQUIRED")
arcpy.AddMessage ("Sasquatch created the "+in_Field+" field")
except arcpy.ExecuteError:
msgs = arcpy.GetMessages(2)
arcpy.AddError(msgs)
except:
tb = sys.exc_info()[2]
tbinfo = traceback.format_tb(tb)[0]
pymsg = "PYTHON ERRORS:\nTraceback info:\n" + tbinfo + "\nError Info:\n" + str(sys.exc_info()[1])
msgs = "ArcPy ERRORS:\n" + arcpy.GetMessages(2) + "\n"
arcpy.AddError(pymsg)
arcpy.AddError(msgs)
#Create required SOURCEDATE Field
try:
in_Field = "SOURCEDATE"
if len(arcpy.ListFields(in_Table,in_Field))>0:
arcpy.AddWarning (in_Field+" exits already")
else:
arcpy.AddField_management(path+"\\"+gdb_name+".gdb\\"+fc_name, in_Field, "DATE", "", "", "", in_Field, "NULLABLE", "NON_REQUIRED")
arcpy.AddMessage ("Sasquatch created the "+in_Field+" field")
except arcpy.ExecuteError:
msgs = arcpy.GetMessages(2)
arcpy.AddError(msgs)
except:
tb = sys.exc_info()[2]
tbinfo = traceback.format_tb(tb)[0]
pymsg = "PYTHON ERRORS:\nTraceback info:\n" + tbinfo + "\nError Info:\n" + str(sys.exc_info()[1])
msgs = "ArcPy ERRORS:\n" + arcpy.GetMessages(2) + "\n"
arcpy.AddError(pymsg)
arcpy.AddError(msgs)
#Create required XYACCURACY Field
try:
in_Field = "XYACCURACY"
if len(arcpy.ListFields(in_Table,in_Field))>0:
arcpy.AddWarning (in_Field+" exits already")
else:
arcpy.AddField_management(path+"\\"+gdb_name+".gdb\\"+fc_name, in_Field, "TEXT", "", "", 50, in_Field, "NON_NULLABLE", "REQUIRED", "DOM_XYACCURACY_NPS2016")
arcpy.AddMessage ("Sasquatch created the "+in_Field+" field and the attribute domain is DOM_XYACCURACY_NPS2016")
arcpy.AssignDefaultToField_management(path+"\\"+gdb_name+".gdb\\"+fc_name, in_Field, "Unknown")
arcpy.AddMessage ("Saquatch assigned Unknown as the default value for "+ in_Field)
except arcpy.ExecuteError:
msgs = arcpy.GetMessages(2)
arcpy.AddError(msgs)
except:
tb = sys.exc_info()[2]
tbinfo = traceback.format_tb(tb)[0]
pymsg = "PYTHON ERRORS:\nTraceback info:\n" + tbinfo + "\nError Info:\n" + str(sys.exc_info()[1])
msgs = "ArcPy ERRORS:\n" + arcpy.GetMessages(2) + "\n"
arcpy.AddError(pymsg)
arcpy.AddError(msgs)
#Create required GEOMETRYID Field
try:
in_Field = "GEOMETRYID"
if len(arcpy.ListFields(in_Table,in_Field))>0:
arcpy.AddWarning (in_Field+" exits already")
else:
arcpy.AddField_management(path+"\\"+gdb_name+".gdb\\"+fc_name, in_Field, "GUID", "", "", "", in_Field, "NULLABLE", "NON_REQUIRED")
arcpy.AddMessage ("Sasquatch created the "+in_Field+" field")
except arcpy.ExecuteError:
msgs = arcpy.GetMessages(2)
arcpy.AddError(msgs)
except:
tb = sys.exc_info()[2]
tbinfo = traceback.format_tb(tb)[0]
pymsg = "PYTHON ERRORS:\nTraceback info:\n" + tbinfo + "\nError Info:\n" + str(sys.exc_info()[1])
msgs = "ArcPy ERRORS:\n" + arcpy.GetMessages(2) + "\n"
arcpy.AddError(pymsg)
arcpy.AddError(msgs)
#Create required NOTES Field
try:
in_Field = "NOTES"
if len(arcpy.ListFields(in_Table,in_Field))>0:
arcpy.AddWarning (in_Field+" exits already")
else:
arcpy.AddField_management(path+"\\"+gdb_name+".gdb\\"+fc_name, in_Field, "TEXT", "", "", 254, in_Field, "NULLABLE", "NON_REQUIRED")
arcpy.AddMessage ("Sasquatch created the "+in_Field+" field")
except arcpy.ExecuteError:
msgs = arcpy.GetMessages(2)
arcpy.AddError(msgs)
except:
tb = sys.exc_info()[2]
tbinfo = traceback.format_tb(tb)[0]
pymsg = "PYTHON ERRORS:\nTraceback info:\n" + tbinfo + "\nError Info:\n" + str(sys.exc_info()[1])
msgs = "ArcPy ERRORS:\n" + arcpy.GetMessages(2) + "\n"
arcpy.AddError(pymsg)
arcpy.AddError(msgs)
#Create the required GlobalID Field
try:
if len(arcpy.ListFields(in_Table,"GlobalID"))>0:
arcpy.AddWarning ("GlobalID exits already")
else:
arcpy.AddGlobalIDs_management(in_Table)
arcpy.AddMessage ("Sasquatch created the GlobalID field")
except arcpy.ExecuteError:
msgs = arcpy.GetMessages(2)
arcpy.AddError(msgs)
except:
tb = sys.exc_info()[2]
tbinfo = traceback.format_tb(tb)[0]
pymsg = "PYTHON ERRORS:\nTraceback info:\n" + tbinfo + "\nError Info:\n" + str(sys.exc_info()[1])
msgs = "ArcPy ERRORS:\n" + arcpy.GetMessages(2) + "\n"
arcpy.AddError(pymsg)
arcpy.AddError(msgs)
#Enable editor tracking
try:
arcpy.EnableEditorTracking_management(path+"\\"+gdb_name+".gdb\\"+fc_name, "CREATEUSER","CREATEDATE", "EDITUSER", "EDITDATE", "NO_ADD_FIELDS", time_format)
arcpy.AddMessage ("Sasquatch enabled editor tracking on "+fc_name)
except arcpy.ExecuteError:
msgs = arcpy.GetMessages(2)
arcpy.AddError(msgs)
except:
tb = sys.exc_info()[2]
tbinfo = traceback.format_tb(tb)[0]
pymsg = "PYTHON ERRORS:\nTraceback info:\n" + tbinfo + "\nError Info:\n" + str(sys.exc_info()[1])
msgs = "ArcPy ERRORS:\n" + arcpy.GetMessages(2) + "\n"
arcpy.AddError(pymsg)
arcpy.AddError(msgs)