2121 # ...
2222]
2323
24+ # Whether to print an error if connection failed (no Transmission running?)
25+ err_on_connect = False
26+
2427# Where to cache downloaded lists
2528cache_file = '/tmp/trackers_cache.txt'
2629
@@ -169,14 +172,22 @@ def readLocalLists():
169172 lg ("No trackers loaded, nothing to do" )
170173 exit (1 )
171174
172- tc = transmissionrpc .Client (host , port = port , user = user , password = pw )
175+ try :
176+ tc = transmissionrpc .Client (host , port = port , user = user , password = pw )
177+ except :
178+ if not err_on_connect :
179+ exit ()
180+
181+ print ("Unable to connect to Transmission: " , sys .exc_info ()[0 ])
182+ raise
183+
173184torrents = tc .get_torrents ()
174185
175186dbg ('{} torrents total' .format (len (torrents )))
176187
177188for t in torrents :
178189 if status_filter and not t .status in status_filter :
179- if debug : print ('{}: skipping due to status filter' .format (t .name ))
190+ dbg ('{}: skipping due to status filter' .format (t .name ))
180191 continue
181192
182193 ttrk = set (())
@@ -186,7 +197,7 @@ def readLocalLists():
186197 diff = trackers - ttrk
187198
188199 if diff :
189- if not silent : print ('{}: Adding {} trackers (before: {})' .format (t .name , len (diff ), len (ttrk )))
200+ lg ('{}: Adding {} trackers (before: {})' .format (t .name , len (diff ), len (ttrk )))
190201 tc .change_torrent (t .id , trackerAdd = list (diff ))
191202 else :
192- if debug : print ('{}: update not needed' .format (t .name ))
203+ dbg ('{}: update not needed' .format (t .name ))
0 commit comments