浏览代码

add fallback urls to all include_url calls. improve http timeout handling.

Thomas B 2 个月前
父节点
当前提交
b2959c258f

+ 12
- 3
input/projects/3d-printing/i3-am8.md 查看文件

264
 
264
 
265
 <pre id="printercfg" class="sh_desktop">
265
 <pre id="printercfg" class="sh_desktop">
266
 <!--%
266
 <!--%
267
-include_url("https://git.xythobuz.de/thomas/3d-print-designs/raw/branch/master/configs/i3-AM8/printer.cfg")
267
+include_url(
268
+    "https://git.xythobuz.de/thomas/3d-print-designs/raw/branch/master/configs/i3-AM8/printer.cfg",
269
+    "https://codeberg.org/xythobuz/3d-print-designs/raw/branch/master/configs/i3-AM8/printer.cfg"
270
+)
268
 %-->
271
 %-->
269
 </pre>
272
 </pre>
270
 
273
 
273
 
276
 
274
 <pre id="moonrakerconf" class="sh_desktop">
277
 <pre id="moonrakerconf" class="sh_desktop">
275
 <!--%
278
 <!--%
276
-include_url("https://git.xythobuz.de/thomas/3d-print-designs/raw/branch/master/configs/i3-AM8/moonraker.conf")
279
+include_url(
280
+    "https://git.xythobuz.de/thomas/3d-print-designs/raw/branch/master/configs/i3-AM8/moonraker.conf",
281
+    "https://codeberg.org/xythobuz/3d-print-designs/raw/branch/master/configs/i3-AM8/moonraker.conf"
282
+)
277
 %-->
283
 %-->
278
 </pre>
284
 </pre>
279
 
285
 
282
 
288
 
283
 <pre id="prusabundle" class="sh_desktop">
289
 <pre id="prusabundle" class="sh_desktop">
284
 <!--%
290
 <!--%
285
-include_url("https://git.xythobuz.de/thomas/3d-print-designs/raw/branch/master/configs/i3-AM8/PrusaSlicer_config_bundle.ini")
291
+include_url(
292
+    "https://git.xythobuz.de/thomas/3d-print-designs/raw/branch/master/configs/i3-AM8/PrusaSlicer_config_bundle.ini",
293
+    "https://codeberg.org/xythobuz/3d-print-designs/raw/branch/master/configs/i3-AM8/PrusaSlicer_config_bundle.ini"
294
+)
286
 %-->
295
 %-->
287
 </pre>
296
 </pre>
288
 
297
 

+ 4
- 1
input/projects/3d-printing/sparkmaker_repair.md 查看文件

144
 
144
 
145
 <pre class="sh_python">
145
 <pre class="sh_python">
146
 <!--%
146
 <!--%
147
-include_url("https://git.xythobuz.de/thomas/gcode-tools/raw/branch/master/tools/convert_sparkmaker.py")
147
+include_url(
148
+    "https://git.xythobuz.de/thomas/gcode-tools/raw/branch/master/tools/convert_sparkmaker.py",
149
+    "https://codeberg.org/xythobuz/gcode-tools/raw/branch/master/tools/convert_sparkmaker.py"
150
+)
148
 %-->
151
 %-->
149
 </pre>
152
 </pre>
150
 
153
 

+ 20
- 5
input/projects/laser-engraver.md 查看文件

275
 
275
 
276
 <pre class="sh_python">
276
 <pre class="sh_python">
277
 <!--%
277
 <!--%
278
-include_url("https://git.xythobuz.de/thomas/gcode-tools/raw/branch/master/tools/convert_lasergrbl.py")
278
+include_url(
279
+    "https://git.xythobuz.de/thomas/gcode-tools/raw/branch/master/tools/convert_lasergrbl.py",
280
+    "https://codeberg.org/xythobuz/gcode-tools/raw/branch/master/tools/convert_lasergrbl.py"
281
+)
279
 %-->
282
 %-->
280
 </pre>
283
 </pre>
281
 
284
 
338
 
341
 
339
 <pre class="sh_python">
342
 <pre class="sh_python">
340
 <!--%
343
 <!--%
341
-include_url("https://git.xythobuz.de/thomas/gcode-tools/raw/branch/master/tools/outline_gcode.py")
344
+include_url(
345
+    "https://git.xythobuz.de/thomas/gcode-tools/raw/branch/master/tools/outline_gcode.py",
346
+    "https://codeberg.org/xythobuz/gcode-tools/raw/branch/master/tools/outline_gcode.py"
347
+)
342
 %-->
348
 %-->
343
 </pre>
349
 </pre>
344
 
350
 
349
 
355
 
350
 <pre class="sh_python">
356
 <pre class="sh_python">
351
 <!--%
357
 <!--%
352
-include_url("https://git.xythobuz.de/thomas/gcode-tools/raw/branch/master/generators/grid_gcode.py")
358
+include_url(
359
+    "https://git.xythobuz.de/thomas/gcode-tools/raw/branch/master/generators/grid_gcode.py",
360
+    "https://codeberg.org/xythobuz/gcode-tools/raw/branch/master/generators/grid_gcode.py"
361
+)
353
 %-->
362
 %-->
354
 </pre>
363
 </pre>
355
 
364
 
375
 
384
 
376
 <pre class="sh_python">
385
 <pre class="sh_python">
377
 <!--%
386
 <!--%
378
-include_url("https://git.xythobuz.de/thomas/gcode-tools/raw/branch/master/tools/send_gcode.py")
387
+include_url(
388
+    "https://git.xythobuz.de/thomas/gcode-tools/raw/branch/master/tools/send_gcode.py",
389
+    "https://codeberg.org/xythobuz/gcode-tools/raw/branch/master/tools/send_gcode.py"
390
+)
379
 %-->
391
 %-->
380
 </pre>
392
 </pre>
381
 
393
 
390
 
402
 
391
 <pre class="sh_python">
403
 <pre class="sh_python">
392
 <!--%
404
 <!--%
393
-include_url("https://git.xythobuz.de/thomas/gcode-tools/raw/branch/master/generators/cut_test_gcode.py")
405
+include_url(
406
+    "https://git.xythobuz.de/thomas/gcode-tools/raw/branch/master/generators/cut_test_gcode.py",
407
+    "https://codeberg.org/xythobuz/gcode-tools/raw/branch/master/generators/cut_test_gcode.py"
408
+)
394
 %-->
409
 %-->
395
 </pre>
410
 </pre>
396
 
411
 

+ 9
- 2
input/projects/osci_music_player.md 查看文件

2
 description: Properly playing sound files for visualization on an oscilloscope
2
 description: Properly playing sound files for visualization on an oscilloscope
3
 parent: projects
3
 parent: projects
4
 git: https://git.xythobuz.de/thomas/osci-music-player
4
 git: https://git.xythobuz.de/thomas/osci-music-player
5
+github: https://github.com/xythobuz/osci-music-player
5
 date: 2024-02-11
6
 date: 2024-02-11
6
 update: 2024-03-08
7
 update: 2024-03-08
7
 comments: true
8
 comments: true
257
 
258
 
258
 <pre id="oscipipy" class="sh_python">
259
 <pre id="oscipipy" class="sh_python">
259
 <!--%
260
 <!--%
260
-include_url("https://git.xythobuz.de/thomas/osci-music-player/raw/branch/master/osci-pi.py")
261
+include_url(
262
+    "https://git.xythobuz.de/thomas/osci-music-player/raw/branch/master/osci-pi.py",
263
+    "https://raw.githubusercontent.com/xythobuz/osci-music-player/refs/heads/master/osci-pi.py"
264
+)
261
 %-->
265
 %-->
262
 </pre>
266
 </pre>
263
 
267
 
267
 
271
 
268
 <pre id="osciservice" class="sh_desktop">
272
 <pre id="osciservice" class="sh_desktop">
269
 <!--%
273
 <!--%
270
-include_url("https://git.xythobuz.de/thomas/osci-music-player/raw/branch/master/osci.service")
274
+include_url(
275
+    "https://git.xythobuz.de/thomas/osci-music-player/raw/branch/master/osci.service",
276
+    "https://raw.githubusercontent.com/xythobuz/osci-music-player/refs/heads/master/osci.service"
277
+)
271
 %-->
278
 %-->
272
 </pre>
279
 </pre>
273
 
280
 

+ 7
- 6
macros.py 查看文件

509
     sys.stderr.write("warning: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n")
509
     sys.stderr.write("warning: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n")
510
     sys.stderr.write("\n")
510
     sys.stderr.write("\n")
511
 
511
 
512
-def http_request(url):
512
+def http_request(url, timeout = 5):
513
     if PY3:
513
     if PY3:
514
-        response = urllib.request.urlopen(url, timeout = 5)
514
+        response = urllib.request.urlopen(url, timeout = timeout)
515
     else:
515
     else:
516
         response = urllib.urlopen(url)
516
         response = urllib.urlopen(url)
517
 
517
 
521
     data = response.read().decode("utf-8")
521
     data = response.read().decode("utf-8")
522
     return data
522
     return data
523
 
523
 
524
-def include_url(url, fallback = None):
524
+def include_url(url, fallback = None, timeout = 2):
525
     sys.stderr.write('sub    : fetching page "%s"\n' % url)
525
     sys.stderr.write('sub    : fetching page "%s"\n' % url)
526
 
526
 
527
     if fallback == None:
527
     if fallback == None:
528
         print_cnsl_error("include_url() without fallback option", url)
528
         print_cnsl_error("include_url() without fallback option", url)
529
+        timeout = timeout * 3
529
 
530
 
530
     try:
531
     try:
531
-        data = http_request(url)
532
+        data = http_request(url, timeout)
532
     except Exception as e:
533
     except Exception as e:
533
         if fallback != None:
534
         if fallback != None:
534
-            sys.stderr.write('sub    : fetching fallback page "%s"\n' % url)
535
+            sys.stderr.write('sub    : fetching fallback page "%s"\n' % fallback)
535
             try:
536
             try:
536
-                data = http_request(fallback)
537
+                data = http_request(fallback, timeout * 3)
537
             except Exception as e:
538
             except Exception as e:
538
                 print_cnsl_error(str(e), fallback)
539
                 print_cnsl_error(str(e), fallback)
539
                 return
540
                 return

正在加载...
取消
保存