From 74c6ed02a8dd57e85f6d4040c82e7c6651b90217 Mon Sep 17 00:00:00 2001 From: Kevin Midboe Date: Fri, 2 Jun 2017 08:52:54 +0200 Subject: [PATCH 1/6] Changed debug level and removed a unused exit --- classedStray.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/classedStray.py b/classedStray.py index 851095c..1e0b847 100755 --- a/classedStray.py +++ b/classedStray.py @@ -147,7 +147,7 @@ def getDirContent(dir=env.show_dir): # TODO Log to error file logging.info('Error: "' + dir + '" is not a directory.') # TODO Remove this exit(0) - exit(0) + # exit(0) # Hashes the contents of media folder to easily check for changes. def directoryChecksum(): @@ -205,7 +205,7 @@ def main(): if __name__ == '__main__': if (os.path.exists(env.logfile)): - logging.basicConfig(filename=env.logfile, level=logging.INFO) + logging.basicConfig(filename=env.logfile, level=logging.DEBUG) else: print('Logfile could not be found at ' + env.logfile + '. Verifiy presence or disable logging in config.') exit(0) From 7f14f647629f49c39fb8a82b991187f5428b13bb Mon Sep 17 00:00:00 2001 From: Kevin Midboe Date: Tue, 13 Jun 2017 05:11:50 +0200 Subject: [PATCH 2/6] Set gid and uid to static vars --- moveSeasoned.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/moveSeasoned.py b/moveSeasoned.py index caaca70..4f79b43 100755 --- a/moveSeasoned.py +++ b/moveSeasoned.py @@ -45,7 +45,7 @@ class episode(object): def fix_ownership(path): uid = int(os.environ.get('SUDO_UID')) gid = int(os.environ.get('SUDO_GID')) - os.chown(path, uid, gid) + os.chown(path, '1000', '1000') def moveStray(strayId): ep = episode(strayId) @@ -63,4 +63,4 @@ def moveStray(strayId): os.rmdir(ep.typeDir('parent')) if __name__ == '__main__': - moveStray(sys.argv[-1]) \ No newline at end of file + moveStray(sys.argv[-1]) From 90384e4ebc2c0379791a4f5d1881c392bf7b9a47 Mon Sep 17 00:00:00 2001 From: Kevin Midboe Date: Tue, 13 Jun 2017 05:17:40 +0200 Subject: [PATCH 3/6] Calls fix_ownership after creating new directory --- moveSeasoned.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/moveSeasoned.py b/moveSeasoned.py index 4f79b43..bbaf43b 100755 --- a/moveSeasoned.py +++ b/moveSeasoned.py @@ -37,6 +37,7 @@ class episode(object): url = '/'.join(self.queries[dType]) if create and not os.path.isdir(url): os.makedirs(url) + fix_ownership(url) if mergeItem: return '/'.join([url, str(mergeItem)]) return url @@ -45,7 +46,7 @@ class episode(object): def fix_ownership(path): uid = int(os.environ.get('SUDO_UID')) gid = int(os.environ.get('SUDO_GID')) - os.chown(path, '1000', '1000') + os.chown(path, '1000', '113') def moveStray(strayId): ep = episode(strayId) From 5a458566991cc060c778c47100936284c342eae5 Mon Sep 17 00:00:00 2001 From: KevinMidboe Date: Sun, 18 Jun 2017 21:47:15 -0600 Subject: [PATCH 4/6] Pulled variable for subtitles path out of open() and retunes subfile without analysis on typeError. --- classedStray.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/classedStray.py b/classedStray.py index 3b3fb8c..d3c846c 100755 --- a/classedStray.py +++ b/classedStray.py @@ -3,7 +3,7 @@ # @Author: KevinMidboe # @Date: 2017-04-05 18:40:11 # @Last Modified by: KevinMidboe -# @Last Modified time: 2017-06-01 19:02:04 +# @Last Modified time: 2017-06-18 21:45:42 import os.path, hashlib, time, glob, sqlite3, re, json, tweepy import logging from functools import reduce @@ -91,7 +91,11 @@ class strayEpisode(object): def analyseSubtitles(self, subFile): # TODO verify that it is a file - f = open(os.path.join([env.show_dir, self.parent, subFile]), 'r', encoding='ISO-8859-15') + try: + subtitlesPath = os.path.join([env.show_dir, self.parent, subFile]) + except TypeError: + return removeUploadSign(subFile) + f = open(subtitlesPath, 'r', encoding='ISO-8859-15') language = detect(f.read()) f.close() From 17b89748e133b39e0d7a345b090ecb9aeab7bd9a Mon Sep 17 00:00:00 2001 From: KevinMidboe Date: Sun, 18 Jun 2017 21:48:08 -0600 Subject: [PATCH 5/6] Added todo to analyseSubtitles function --- classedStray.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/classedStray.py b/classedStray.py index d3c846c..8c829d9 100755 --- a/classedStray.py +++ b/classedStray.py @@ -3,7 +3,7 @@ # @Author: KevinMidboe # @Date: 2017-04-05 18:40:11 # @Last Modified by: KevinMidboe -# @Last Modified time: 2017-06-18 21:45:42 +# @Last Modified time: 2017-06-18 21:47:48 import os.path, hashlib, time, glob, sqlite3, re, json, tweepy import logging from functools import reduce @@ -92,8 +92,9 @@ class strayEpisode(object): def analyseSubtitles(self, subFile): # TODO verify that it is a file try: - subtitlesPath = os.path.join([env.show_dir, self.parent, subFile]) + subtitlePath = os.path.join([env.show_dir, self.parent, subFile]) except TypeError: + # TODO don't get a list in subtitlePath return removeUploadSign(subFile) f = open(subtitlesPath, 'r', encoding='ISO-8859-15') language = detect(f.read()) From d5ea7a6bbb86fd6c520fa2a94d0c706d26c144ed Mon Sep 17 00:00:00 2001 From: KevinMidboe Date: Sun, 18 Jun 2017 21:49:58 -0600 Subject: [PATCH 6/6] Error with function call --- classedStray.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/classedStray.py b/classedStray.py index 8c829d9..dc92e00 100755 --- a/classedStray.py +++ b/classedStray.py @@ -3,7 +3,7 @@ # @Author: KevinMidboe # @Date: 2017-04-05 18:40:11 # @Last Modified by: KevinMidboe -# @Last Modified time: 2017-06-18 21:47:48 +# @Last Modified time: 2017-06-18 21:49:33 import os.path, hashlib, time, glob, sqlite3, re, json, tweepy import logging from functools import reduce @@ -95,7 +95,7 @@ class strayEpisode(object): subtitlePath = os.path.join([env.show_dir, self.parent, subFile]) except TypeError: # TODO don't get a list in subtitlePath - return removeUploadSign(subFile) + return self.removeUploadSign(subFile) f = open(subtitlesPath, 'r', encoding='ISO-8859-15') language = detect(f.read()) f.close()