소스 검색

exception printing was broken on normal python

Thomas Buck 1 년 전
부모
커밋
d82f47d27b
3개의 변경된 파일31개의 추가작업 그리고 7개의 파일을 삭제
  1. 5
    1
      mapper.py
  2. 5
    1
      net.py
  3. 21
    5
      util.py

+ 5
- 1
mapper.py 파일 보기

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

+ 5
- 1
net.py 파일 보기

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

+ 21
- 5
util.py 파일 보기

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

Loading…
취소
저장