21
21
# ...
22
22
]
23
23
24
+ # Whether to print an error if connection failed (no Transmission running?)
25
+ err_on_connect = False
26
+
24
27
# Where to cache downloaded lists
25
28
cache_file = '/tmp/trackers_cache.txt'
26
29
@@ -169,14 +172,22 @@ def readLocalLists():
169
172
lg ("No trackers loaded, nothing to do" )
170
173
exit (1 )
171
174
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
+
173
184
torrents = tc .get_torrents ()
174
185
175
186
dbg ('{} torrents total' .format (len (torrents )))
176
187
177
188
for t in torrents :
178
189
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 ))
180
191
continue
181
192
182
193
ttrk = set (())
@@ -186,7 +197,7 @@ def readLocalLists():
186
197
diff = trackers - ttrk
187
198
188
199
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 )))
190
201
tc .change_torrent (t .id , trackerAdd = list (diff ))
191
202
else :
192
- if debug : print ('{}: update not needed' .format (t .name ))
203
+ dbg ('{}: update not needed' .format (t .name ))
0 commit comments