Browse Source

exception printing was broken on normal python

Thomas Buck 11 months ago
parent
commit
d82f47d27b
3 changed files with 31 additions and 7 deletions
  1. 5
    1
      mapper.py
  2. 5
    1
      net.py
  3. 21
    5
      util.py

+ 5
- 1
mapper.py View File

122
                     print("After sync: "  + str(time.localtime()))
122
                     print("After sync: "  + str(time.localtime()))
123
                 except Exception as e:
123
                 except Exception as e:
124
                     print()
124
                     print()
125
-                    sys.print_exception(e)
125
+                    if hasattr(sys, "print_exception"):
126
+                        sys.print_exception(e)
127
+                    else:
128
+                        print(e)
126
                     print()
129
                     print()
130
+
127
                     return
131
                     return
128
 
132
 
129
         # (year, month, day, hour, minute, second, ?, ?)
133
         # (year, month, day, hour, minute, second, ?, ?)

+ 5
- 1
net.py View File

58
                 self.response = (r.status_code < 400)
58
                 self.response = (r.status_code < 400)
59
             except Exception as e:
59
             except Exception as e:
60
                 print()
60
                 print()
61
-                sys.print_exception(e)
61
+                if hasattr(sys, "print_exception"):
62
+                    sys.print_exception(e)
63
+                else:
64
+                    print(e)
62
                 print()
65
                 print()
66
+
63
                 self.response = False
67
                 self.response = False
64
 
68
 
65
     def finished(self):
69
     def finished(self):

+ 21
- 5
util.py View File

48
         targetPlatform = "pi"
48
         targetPlatform = "pi"
49
     except Exception as e:
49
     except Exception as e:
50
         print()
50
         print()
51
-        sys.print_exception(e)
51
+        if hasattr(sys, "print_exception"):
52
+            sys.print_exception(e)
53
+        else:
54
+            print(e)
52
         print()
55
         print()
53
 
56
 
54
         try:
57
         try:
66
             targetPlatform = "pico"
69
             targetPlatform = "pico"
67
         except Exception as e:
70
         except Exception as e:
68
             print()
71
             print()
69
-            sys.print_exception(e)
72
+            if hasattr(sys, "print_exception"):
73
+                sys.print_exception(e)
74
+            else:
75
+                print(e)
70
             print()
76
             print()
71
 
77
 
72
             # If this fails fall back to the SDL/pygame GUI
78
             # If this fails fall back to the SDL/pygame GUI
92
         from pico import PicoMatrix
98
         from pico import PicoMatrix
93
     except Exception as e:
99
     except Exception as e:
94
         print()
100
         print()
95
-        sys.print_exception(e)
101
+        if hasattr(sys, "print_exception"):
102
+            sys.print_exception(e)
103
+        else:
104
+            print(e)
96
         print()
105
         print()
106
+
97
         wifiConnected = True
107
         wifiConnected = True
98
         return True
108
         return True
99
 
109
 
167
         return requests.get
177
         return requests.get
168
     except Exception as e:
178
     except Exception as e:
169
         print()
179
         print()
170
-        sys.print_exception(e)
180
+        if hasattr(sys, "print_exception"):
181
+            sys.print_exception(e)
182
+        else:
183
+            print(e)
171
         print()
184
         print()
172
 
185
 
173
         # if it fails try the Pi Pico MicroPython implementation
186
         # if it fails try the Pi Pico MicroPython implementation
189
         return DrawText
202
         return DrawText
190
     except Exception as e:
203
     except Exception as e:
191
         print()
204
         print()
192
-        sys.print_exception(e)
205
+        if hasattr(sys, "print_exception"):
206
+            sys.print_exception(e)
207
+        else:
208
+            print(e)
193
         print()
209
         print()
194
 
210
 
195
         # fall back to the Pico Interstate75 implementation
211
         # fall back to the Pico Interstate75 implementation

Loading…
Cancel
Save