GIS 5103 Lab 3 - DeBugging
For this week's lab we were asked to de-bug 3 separate instances of python scripts. For the first script we were asked to work through the code to debug it, the majority of the errors within this code chunk were simple punctuation and capitalization errors
The second script was much the same, though errors were more complicated and included issues like an incorrect file path.
For the third script, we were asked not to fix the code, but in fact to insert a Try-Except process to allow the code to run without fixing the error.
My full process for working through the creation of the Try-Except loop can be seen below
Python 3.11.10 (main, Sep 20 2024, 18:44:55) [MSC v.1938 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
========= RESTART: S:/GISProgramming/Module3/Results/Mod3_Script3_JM.py ========
Running Part A...
Traceback (most recent call last):
File "S:/GISProgramming/Module3/Results/Mod3_Script3_JM.py", line 13, in <module>
project = arcpy.mp.ArcGISProject()
TypeError: ArcGISProject.__init__() missing 1 required positional argument: 'aprx_path'
========= RESTART: S:/GISProgramming/Module3/Results/Mod3_Script3_JM.py ========
Running Part A...
Traceback (most recent call last):
File "S:/GISProgramming/Module3/Results/Mod3_Script3_JM.py", line 14, in <module>
project = arcpy.mp.ArcGISProject()
TypeError: ArcGISProject.__init__() missing 1 required positional argument: 'aprx_path'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "S:/GISProgramming/Module3/Results/Mod3_Script3_JM.py", line 26, in <module>
Print ("Part A Unsuccesful")
NameError: name 'Print' is not defined. Did you mean: 'print'?
========= RESTART: S:/GISProgramming/Module3/Results/Mod3_Script3_JM.py ========
Running Part A...
ArcGISProject.__init__() missing 1 required positional argument: 'aprx_path'
Traceback (most recent call last):
File "S:/GISProgramming/Module3/Results/Mod3_Script3_JM.py", line 17, in <module>
lyrlist = project.listMaps()
NameError: name 'project' is not defined. Did you mean: 'property'?
========= RESTART: S:/GISProgramming/Module3/Results/Mod3_Script3_JM.py ========
Running Part A...
ArcGISProject.__init__() missing 1 required positional argument: 'aprx_path'
Traceback (most recent call last):
File "S:/GISProgramming/Module3/Results/Mod3_Script3_JM.py", line 18, in <module>
for lyr in lyrlist:
NameError: name 'lyrlist' is not defined
========= RESTART: S:/GISProgramming/Module3/Results/Mod3_Script3_JM.py ========
Running Part A...
ArcGISProject.__init__() missing 1 required positional argument: 'aprx_path'
Traceback (most recent call last):
File "S:/GISProgramming/Module3/Results/Mod3_Script3_JM.py", line 23, in <module>
project.save()
NameError: name 'project' is not defined. Did you mean: 'property'?
========= RESTART: S:/GISProgramming/Module3/Results/Mod3_Script3_JM.py ========
Running Part A...
ArcGISProject.__init__() missing 1 required positional argument: 'aprx_path'
Part A successfully completed.
Running Part B...
Name: parks
Data source: S:\GISProgramming\Module3\Data\parks
Spatial Reference: NAD_1983_StatePlane_Texas_Central_FIPS_4203_Feet [Code: 2277]
Name: bike_routes
Data source: S:\GISProgramming\Module3\Data\bike_routes
Spatial Reference: NAD_1983_StatePlane_Texas_Central_FIPS_4203_Feet [Code: 2277]
Name: facilities
Data source: S:\GISProgramming\Module3\Data\facilities
Spatial Reference: NAD_1983_StatePlane_Texas_Central_FIPS_4203_Feet [Code: 2277]
Name: county
Data source: S:\GISProgramming\Module3\Data\county
Spatial Reference: NAD_1983_StatePlane_Texas_Central_FIPS_4203_Feet [Code: 2277]
Part B successfuly completed.
========= RESTART: S:/GISProgramming/Module3/Results/Mod3_Script3_JM.py ========
Running Part A...
Part A Failed
Running Part B...
Name: parks
Data source: S:\GISProgramming\Module3\Data\parks
Spatial Reference: NAD_1983_StatePlane_Texas_Central_FIPS_4203_Feet [Code: 2277]
Name: bike_routes
Data source: S:\GISProgramming\Module3\Data\bike_routes
Spatial Reference: NAD_1983_StatePlane_Texas_Central_FIPS_4203_Feet [Code: 2277]
Name: facilities
Data source: S:\GISProgramming\Module3\Data\facilities
Spatial Reference: NAD_1983_StatePlane_Texas_Central_FIPS_4203_Feet [Code: 2277]
Name: county
Data source: S:\GISProgramming\Module3\Data\county
Spatial Reference: NAD_1983_StatePlane_Texas_Central_FIPS_4203_Feet [Code: 2277]
Part B successfuly completed.
========= RESTART: S:/GISProgramming/Module3/Results/Mod3_Script3_JM.py ========
Running Part A...
Part A Failed - Error {e}
Running Part B...
Name: parks
Data source: S:\GISProgramming\Module3\Data\parks
Spatial Reference: NAD_1983_StatePlane_Texas_Central_FIPS_4203_Feet [Code: 2277]
Name: bike_routes
Data source: S:\GISProgramming\Module3\Data\bike_routes
Spatial Reference: NAD_1983_StatePlane_Texas_Central_FIPS_4203_Feet [Code: 2277]
Name: facilities
Data source: S:\GISProgramming\Module3\Data\facilities
Spatial Reference: NAD_1983_StatePlane_Texas_Central_FIPS_4203_Feet [Code: 2277]
Name: county
Data source: S:\GISProgramming\Module3\Data\county
Spatial Reference: NAD_1983_StatePlane_Texas_Central_FIPS_4203_Feet [Code: 2277]
Part B successfuly completed.
========= RESTART: S:/GISProgramming/Module3/Results/Mod3_Script3_JM.py ========
Running Part A...
Part A Failed - Error ArcGISProject.__init__() missing 1 required positional argument: 'aprx_path'
Running Part B...
Name: parks
Data source: S:\GISProgramming\Module3\Data\parks
Spatial Reference: NAD_1983_StatePlane_Texas_Central_FIPS_4203_Feet [Code: 2277]
Name: bike_routes
Data source: S:\GISProgramming\Module3\Data\bike_routes
Spatial Reference: NAD_1983_StatePlane_Texas_Central_FIPS_4203_Feet [Code: 2277]
Name: facilities
Data source: S:\GISProgramming\Module3\Data\facilities
Spatial Reference: NAD_1983_StatePlane_Texas_Central_FIPS_4203_Feet [Code: 2277]
Name: county
Data source: S:\GISProgramming\Module3\Data\county
Spatial Reference: NAD_1983_StatePlane_Texas_Central_FIPS_4203_Feet [Code: 2277]
Part B successfuly completed.
Comments
Post a Comment