From 5fc55fb0daaae68fa93ce953a3ac28b50c6176d9 Mon Sep 17 00:00:00 2001 From: Clinton Hall Date: Wed, 27 Feb 2013 22:32:56 -0800 Subject: [PATCH] fix for logging and windows --- extractor/extractor.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/extractor/extractor.py b/extractor/extractor.py index 187cade1..9325f79d 100644 --- a/extractor/extractor.py +++ b/extractor/extractor.py @@ -1,8 +1,9 @@ import os import sys import logging +from subprocess import call -Logger = logging.getLogger(__name__) +Logger = logging.getLogger() # which() and os_platform() breaks when running in Transmission (has to do with os.environ) @@ -40,8 +41,10 @@ def extract(dirpath, file, outputDestination): platform = 'x64' else: platform = 'x86' - - sevenzipLocation = os.path.normpath(os.path.join(os.path.dirname(sys.argv[0]), 'extractor/bin/' + platform + '/7z.exe')) + if not os.path.dirname(sys.argv[0]): + sevenzipLocation = os.path.normpath(os.path.join(os.getcwd(), 'extractor/bin/' + platform + '/7z.exe')) + else: + sevenzipLocation = os.path.normpath(os.path.join(os.path.dirname(sys.argv[0]), 'extractor/bin/' + platform + '/7z.exe')) if not os.path.exists(sevenzipLocation): Logger.error("EXTRACTOR: Couldnt find 7-zip, Exiting") sys.exit(-1) @@ -113,7 +116,7 @@ def extract(dirpath, file, outputDestination): else: Logger.info("EXTRACTOR: Extraction failed for %s. 7zip result was %s", filePath, res) except: - Logger.error("EXTRACTOR: Extraction failed for %s. Could not call command %s %s", filePath, run) + Logger.error("EXTRACTOR: Extraction failed for %s. Could not call command %s", filePath, run) else: try: if cmd[1] == "": # If calling unzip, we dont want to pass the "" @@ -127,4 +130,4 @@ def extract(dirpath, file, outputDestination): except: Logger.error("EXTRACTOR: Extraction failed for %s. Could not call command %s %s %s %s", filePath, cmd[0], cmd[1], filePath) os.chdir(pwd) # Go back to our Original Working Directory - return True \ No newline at end of file + return True