From 563d4f53886d16ffd7a85304bc2910b31f3fb101 Mon Sep 17 00:00:00 2001
From: Chris Pomeroy <chris.pomeroy@hotmail.com>
Date: Fri, 23 Mar 2018 01:09:49 +0000
Subject: [PATCH] Added retry for the Checkkey function

---
 aaxConvert.py |   20 +++++++++++++-------
 1 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/aaxConvert.py b/aaxConvert.py
index ae9567d..9752304 100755
--- a/aaxConvert.py
+++ b/aaxConvert.py
@@ -7,6 +7,7 @@
 import json
 import requests
 from querysubsonic import findalbumbyname
+from time import sleep
 
 
 # arguments
@@ -138,12 +139,17 @@
 def getcorrectkey(aaxfile):
     hex = filechecksum(aaxfile)
     payload = hex
-    r = requests.post('http://x86-docker01:8080/function/checkkey', payload, verify=False)
-    if r.status_code == 200:
-        key = r.text
-    else: 
-        print('Checkkey function is down please wait')
-    return key
+    recovery = 3
+    while recovery != 0:
+      r = requests.post('http://x86-docker01:8080/function/checkkey', payload, verify=False, timeout=None)
+      if r.status_code == 200:
+          key = r.text
+          recovery = 0
+      else: 
+          print('Checkkey function is down please wait')
+          recovery = recovery - 1
+          sleep(5)
+      return key
 
 for rfile in glob.glob(args.filename):
     if rfile.find("aax") != -1 and os.path.isfile(rfile):
@@ -155,7 +161,7 @@
             title = getmetadatatags('title')
             act_byte = getcorrectkey(rfile)
             ddir = "%s/%s/%s" % (path, artist, title)
-            single_file_path = "%s/%s.mp3" % (ddir, title)
+            single_file_path = "/processing/%s.mp3" % (title)
             if not os.path.exists(ddir):
                 os.makedirs(ddir)
             print(ddir)

--
Gitblit v1.10.0