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.

For me, this entailed inserting the try function above code line 13 and then catching the exception after approximately 8 lines


My full process for working through the creation of the Try-Except loop can be seen below

  1. Python 3.11.10 (main, Sep 20 2024, 18:44:55) [MSC v.1938 64 bit (AMD64)] on win32

  2. Type "help", "copyright", "credits" or "license()" for more information.


  3. ========= RESTART: S:/GISProgramming/Module3/Results/Mod3_Script3_JM.py ========

  4. Running Part A...

  5. Traceback (most recent call last):

  6.   File "S:/GISProgramming/Module3/Results/Mod3_Script3_JM.py", line 13, in <module>

  7.     project = arcpy.mp.ArcGISProject()

  8. TypeError: ArcGISProject.__init__() missing 1 required positional argument: 'aprx_path'


  9. ========= RESTART: S:/GISProgramming/Module3/Results/Mod3_Script3_JM.py ========

  10. Running Part A...

  11. Traceback (most recent call last):

  12.   File "S:/GISProgramming/Module3/Results/Mod3_Script3_JM.py", line 14, in <module>

  13.     project = arcpy.mp.ArcGISProject()

  14. TypeError: ArcGISProject.__init__() missing 1 required positional argument: 'aprx_path'


  15. During handling of the above exception, another exception occurred:


  16. Traceback (most recent call last):

  17.   File "S:/GISProgramming/Module3/Results/Mod3_Script3_JM.py", line 26, in <module>

  18.     Print ("Part A Unsuccesful")

  19. NameError: name 'Print' is not defined. Did you mean: 'print'?


  20. ========= RESTART: S:/GISProgramming/Module3/Results/Mod3_Script3_JM.py ========

  21. Running Part A...

  22. ArcGISProject.__init__() missing 1 required positional argument: 'aprx_path'

  23. Traceback (most recent call last):

  24.   File "S:/GISProgramming/Module3/Results/Mod3_Script3_JM.py", line 17, in <module>

  25.     lyrlist = project.listMaps()

  26. NameError: name 'project' is not defined. Did you mean: 'property'?


  27. ========= RESTART: S:/GISProgramming/Module3/Results/Mod3_Script3_JM.py ========

  28. Running Part A...

  29. ArcGISProject.__init__() missing 1 required positional argument: 'aprx_path'

  30. Traceback (most recent call last):

  31.   File "S:/GISProgramming/Module3/Results/Mod3_Script3_JM.py", line 18, in <module>

  32.     for lyr in lyrlist:

  33. NameError: name 'lyrlist' is not defined


  34. ========= RESTART: S:/GISProgramming/Module3/Results/Mod3_Script3_JM.py ========

  35. Running Part A...

  36. ArcGISProject.__init__() missing 1 required positional argument: 'aprx_path'

  37. Traceback (most recent call last):

  38.   File "S:/GISProgramming/Module3/Results/Mod3_Script3_JM.py", line 23, in <module>

  39.     project.save()

  40. NameError: name 'project' is not defined. Did you mean: 'property'?


  41. ========= RESTART: S:/GISProgramming/Module3/Results/Mod3_Script3_JM.py ========

  42. Running Part A...

  43. ArcGISProject.__init__() missing 1 required positional argument: 'aprx_path'

  44. Part A successfully completed.


  45. Running Part B...

  46. Name: parks

  47. Data source: S:\GISProgramming\Module3\Data\parks

  48. Spatial Reference: NAD_1983_StatePlane_Texas_Central_FIPS_4203_Feet [Code: 2277]


  49. Name: bike_routes

  50. Data source: S:\GISProgramming\Module3\Data\bike_routes

  51. Spatial Reference: NAD_1983_StatePlane_Texas_Central_FIPS_4203_Feet [Code: 2277]


  52. Name: facilities

  53. Data source: S:\GISProgramming\Module3\Data\facilities

  54. Spatial Reference: NAD_1983_StatePlane_Texas_Central_FIPS_4203_Feet [Code: 2277]


  55. Name: county

  56. Data source: S:\GISProgramming\Module3\Data\county

  57. Spatial Reference: NAD_1983_StatePlane_Texas_Central_FIPS_4203_Feet [Code: 2277]


  58. Part B successfuly completed.


  59. ========= RESTART: S:/GISProgramming/Module3/Results/Mod3_Script3_JM.py ========

  60. Running Part A...

  61. Part A Failed


  62. Running Part B...

  63. Name: parks

  64. Data source: S:\GISProgramming\Module3\Data\parks

  65. Spatial Reference: NAD_1983_StatePlane_Texas_Central_FIPS_4203_Feet [Code: 2277]


  66. Name: bike_routes

  67. Data source: S:\GISProgramming\Module3\Data\bike_routes

  68. Spatial Reference: NAD_1983_StatePlane_Texas_Central_FIPS_4203_Feet [Code: 2277]


  69. Name: facilities

  70. Data source: S:\GISProgramming\Module3\Data\facilities

  71. Spatial Reference: NAD_1983_StatePlane_Texas_Central_FIPS_4203_Feet [Code: 2277]


  72. Name: county

  73. Data source: S:\GISProgramming\Module3\Data\county

  74. Spatial Reference: NAD_1983_StatePlane_Texas_Central_FIPS_4203_Feet [Code: 2277]


  75. Part B successfuly completed.


  76. ========= RESTART: S:/GISProgramming/Module3/Results/Mod3_Script3_JM.py ========

  77. Running Part A...

  78. Part A Failed - Error {e}


  79. Running Part B...

  80. Name: parks

  81. Data source: S:\GISProgramming\Module3\Data\parks

  82. Spatial Reference: NAD_1983_StatePlane_Texas_Central_FIPS_4203_Feet [Code: 2277]


  83. Name: bike_routes

  84. Data source: S:\GISProgramming\Module3\Data\bike_routes

  85. Spatial Reference: NAD_1983_StatePlane_Texas_Central_FIPS_4203_Feet [Code: 2277]


  86. Name: facilities

  87. Data source: S:\GISProgramming\Module3\Data\facilities

  88. Spatial Reference: NAD_1983_StatePlane_Texas_Central_FIPS_4203_Feet [Code: 2277]


  89. Name: county

  90. Data source: S:\GISProgramming\Module3\Data\county

  91. Spatial Reference: NAD_1983_StatePlane_Texas_Central_FIPS_4203_Feet [Code: 2277]


  92. Part B successfuly completed.


  93. ========= RESTART: S:/GISProgramming/Module3/Results/Mod3_Script3_JM.py ========

  94. Running Part A...

  95. Part A Failed - Error ArcGISProject.__init__() missing 1 required positional argument: 'aprx_path'


  96. Running Part B...

  97. Name: parks

  98. Data source: S:\GISProgramming\Module3\Data\parks

  99. Spatial Reference: NAD_1983_StatePlane_Texas_Central_FIPS_4203_Feet [Code: 2277]


  100. Name: bike_routes

  101. Data source: S:\GISProgramming\Module3\Data\bike_routes

  102. Spatial Reference: NAD_1983_StatePlane_Texas_Central_FIPS_4203_Feet [Code: 2277]


  103. Name: facilities

  104. Data source: S:\GISProgramming\Module3\Data\facilities

  105. Spatial Reference: NAD_1983_StatePlane_Texas_Central_FIPS_4203_Feet [Code: 2277]


  106. Name: county

  107. Data source: S:\GISProgramming\Module3\Data\county

  108. Spatial Reference: NAD_1983_StatePlane_Texas_Central_FIPS_4203_Feet [Code: 2277]


  109. Part B successfuly completed.


Comments

Popular posts from this blog

GIS 5007 - About Me!

GIS 5100 Module 5 Damage Assessment

GIS 5100 M4