Commit 6c346a8c authored by echel0n's avatar echel0n
Browse files

Misc code improvements for Plex notifier

Refactored database backups to use pickle default protocol to stay compatible with Python 3.5.x
Refactored to use pickle default protocol to stay compatible with Python 3.5.x
parent ec0d14e0
......@@ -290,9 +290,9 @@ class SRDatabase(object):
def backup(self, filename):
metadata = self.get_metadata()
data = {t: dumps(self.session().query(metadata.tables[t]).all()) for t in metadata.tables}
data = {t: dumps(self.session().query(metadata.tables[t]).all(), protocol=pickle.DEFAULT_PROTOCOL) for t in metadata.tables}
with open(filename, 'wb') as fh:
pickle.dump(data, fh)
pickle.dump(data, fh, protocol=pickle.DEFAULT_PROTOCOL)
def restore(self, filename):
session = self.session()
......@@ -64,7 +64,7 @@ def get_ED2K(filePath, forceHash=False, cacheLocation=os.path.normpath(sys.path[
if len(get_ED2K.ED2KCache) != 0:
with open(cacheLocation, 'wb') as f:
pickle.dump(get_ED2K.ED2KCache, f, pickle.HIGHEST_PROTOCOL)
pickle.dump(get_ED2K.ED2KCache, f, pickle.DEFAULT_PROTOCOL)
logger.error("Error occurred while writing back to disk")
......@@ -82,13 +82,13 @@ class PLEXNotifier(Notifiers):
else:'PLEX: Contacting via url: ' + url)
result = WebSession().get(url, headers=headers).text
except Exception as e:
resp = WebSession().get(url, headers=headers)
if not resp or not resp.text:'PLEX: Warning: Couldn\'t contact Plex at {}: {}'.format(url, e))
return False'PLEX: HTTP response: ' + result.replace('\n', ''))'PLEX: HTTP response: ' + resp.text.replace('\n', ''))
return 'OK'
def _notify_pmc(self, message, title='SiCKRAGE', host=None, username=None, password=None, force=False):
......@@ -234,13 +234,14 @@ class PLEXNotifier(Notifiers):
hosts_try = (hosts_all.copy(), hosts_match.copy())[bool(hosts_match)]
host_list = []
for section_key, cur_host in hosts_try.items():
url = 'http://%s/library/sections/%s/refresh' % (cur_host, section_key)
WebSession().get(url, headers=self.headers)
except Exception as e:'PLEX: Error updating library section for Plex Media Server: {}'.format(e))
url = 'http://%s/library/sections/%s/refresh' % (cur_host, section_key)
resp = WebSession().get(url, headers=self.headers)
if not resp or not resp.ok:'PLEX: Error updating library section for Plex Media Server')
if hosts_match:'PLEX: Updating hosts where TV section paths match the downloaded show: ' + ', '.join(set(host_list)))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment