From 0857d8c7cab2038a764fd5ef8777e19b78837144 Mon Sep 17 00:00:00 2001 From: clinton-hall Date: Wed, 9 Apr 2014 13:42:58 +0930 Subject: [PATCH] fix extractor path for windows --- nzbtomedia/extractor/extractor.py | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/nzbtomedia/extractor/extractor.py b/nzbtomedia/extractor/extractor.py index 6de9cf24..4c89e2dd 100644 --- a/nzbtomedia/extractor/extractor.py +++ b/nzbtomedia/extractor/extractor.py @@ -1,8 +1,9 @@ +import os import sys import logging from subprocess import call, Popen -from nzbtomedia.nzbToMediaConfig import * +from nzbtomedia.nzbToMediaConfig import config from nzbtomedia.nzbToMediaUtil import create_destination @@ -10,6 +11,7 @@ Logger = logging.getLogger() # which() and os_platform() breaks when running in Transmission (has to do with os.environ) + def os_platform(): # Author Credit: Matthew Scouten @ http://stackoverflow.com/a/7260315 true_platform = os.environ['PROCESSOR_ARCHITECTURE'] @@ -20,22 +22,6 @@ def os_platform(): #true_platform not assigned to if this does not exist return true_platform -def which(program): - # Author Credit: Jay @ http://stackoverflow.com/a/377028 - def is_exe(fpath): - return os.path.isfile(fpath) and os.access(fpath, os.X_OK) - - fpath, fname = os.path.split(program) - if fpath: - if is_exe(program): - return program - else: - for path in os.environ["PATH"].split(os.pathsep): - exe_file = os.path.join(path, program) - if is_exe(exe_file): - return exe_file - - return None def extract(filePath, outputDestination): # Using Windows @@ -45,11 +31,11 @@ def extract(filePath, outputDestination): else: platform = 'x86' if not os.path.dirname(sys.argv[0]): - chplocation = os.path.normpath(os.path.join(os.getcwd(), 'extractor/bin/chp.exe')) - sevenzipLocation = os.path.normpath(os.path.join(os.getcwd(), 'extractor/bin/' + platform + '/7z.exe')) + chplocation = os.path.normpath(os.path.join(os.getcwd(), 'nzbtomedia/extractor/bin/chp.exe')) + sevenzipLocation = os.path.normpath(os.path.join(os.getcwd(), 'nzbtomedia/extractor/bin/' + platform + '/7z.exe')) else: - chplocation = os.path.normpath(os.path.join(os.path.dirname(sys.argv[0]), 'extractor/bin/chp.exe')) - sevenzipLocation = os.path.normpath(os.path.join(os.path.dirname(sys.argv[0]), 'extractor/bin/' + platform + '/7z.exe')) + chplocation = os.path.normpath(os.path.join(os.path.dirname(sys.argv[0]), 'nzbtomedia/extractor/bin/chp.exe')) + sevenzipLocation = os.path.normpath(os.path.join(os.path.dirname(sys.argv[0]), 'nzbtomedia/extractor/bin/' + platform + '/7z.exe')) if not os.path.exists(sevenzipLocation): Logger.error("EXTRACTOR: Could not find 7-zip, Exiting") return False