fix for logging and windows

This commit is contained in:
Clinton Hall 2013-02-27 22:32:56 -08:00
parent 1a5e697148
commit 5fc55fb0da

View file

@ -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
return True