27
27
28
28
DEBUG = os .getenv ("DEBUG" ) is not None
29
29
30
-
31
30
def debug (msg ):
32
31
if DEBUG :
33
- print (msg )
34
-
32
+ print (msg , file = sys .stderr )
35
33
36
34
LANGUAGE_CODE = "C"
37
35
try :
@@ -257,7 +255,7 @@ def _update_local_json(self):
257
255
debug (f"Downloading from { r .request .url } " )
258
256
r .raise_for_status ()
259
257
except Exception as e :
260
- print (f"Could not refresh json data for { self .spice_type } : { e } " )
258
+ debug (f"Could not refresh json data for { self .spice_type } : { e } " )
261
259
return
262
260
263
261
with open (self .index_file , "w" , encoding = "utf-8" ) as f :
@@ -289,7 +287,7 @@ def _download_thumb(self, uuid, item):
289
287
params = {"time" : get_current_timestamp ()})
290
288
r .raise_for_status ()
291
289
except Exception as e :
292
- print (f"Could not get thumbnail for { uuid } : { e } " )
290
+ debug (f"Could not get thumbnail for { uuid } : { e } " )
293
291
return
294
292
295
293
with open (paths .thumb_local_path , "wb" , encoding = "utf-8" ) as f :
@@ -322,7 +320,7 @@ def _load_metadata(self):
322
320
self .meta_map [uuid ] = metadata
323
321
except Exception as detail :
324
322
debug (detail )
325
- print (f"Skipping { uuid } : there was a problem trying to read metadata.json" , file = sys . stderr )
323
+ debug (f"Skipping { uuid } : there was a problem trying to read metadata.json" )
326
324
except FileNotFoundError :
327
325
# debug("%s does not exist! Creating it now." % directory)
328
326
try :
@@ -365,7 +363,7 @@ def _generate_update_list(self):
365
363
update = SpiceUpdate (self .spice_type , uuid , self .index_cache [uuid ], self .meta_map [uuid ])
366
364
self .updates .append (update )
367
365
except Exception as e :
368
- debug (f"Error checking updates for { uuid } : { e } " , file = sys . stderr )
366
+ debug (f"Error checking updates for { uuid } : { e } " )
369
367
raise
370
368
371
369
return self .updates
@@ -384,7 +382,7 @@ def _install_by_uuid(self, uuid):
384
382
try :
385
383
item = self .index_cache [uuid ]
386
384
except KeyError :
387
- print (f"Can't install { uuid } - it doesn't seem to exist on the server" , file = sys . stderr )
385
+ debug (f"Can't install { uuid } - it doesn't seem to exist on the server" )
388
386
raise
389
387
390
388
paths = SpicePathSet (item , spice_type = self .spice_type )
@@ -396,7 +394,7 @@ def _install_by_uuid(self, uuid):
396
394
params = {"time" : get_current_timestamp ()})
397
395
r .raise_for_status ()
398
396
except Exception as e :
399
- debug (f"Could not download zip for { uuid } : { e } " , file = sys . stderr )
397
+ debug (f"Could not download zip for { uuid } : { e } " )
400
398
raise
401
399
402
400
try :
@@ -415,7 +413,7 @@ def _install_by_uuid(self, uuid):
415
413
416
414
self ._load_metadata ()
417
415
except Exception as e :
418
- debug (f"couldn't install: { e } " , file = sys . stderr )
416
+ debug (f"couldn't install: { e } " )
419
417
raise
420
418
421
419
def _install_from_folder (self , folder , base_folder , uuid , from_spices = False ):
0 commit comments