remove obsolete function

This commit is contained in:
Clinton Hall 2013-03-01 01:12:17 -08:00
commit 0db69fa50c

View file

@ -157,75 +157,6 @@ def copy_link(source, target, useLink, outputDestination):
return True return True
def unpack(dirpath, file, destination): ###Need to remove this when extractor is confirmed
# Using Windows
if os.name == 'nt':
Logger.info("EXTRACTOR: We are using Windows")
cmd_7zip = [extractionTool, 'x -y']
ext_7zip = [".rar", ".zip", ".tar.gz", "tgz", ".tar.bz2", ".tbz", ".tar.lzma", ".tlz", ".7z", ".xz"]
EXTRACT_COMMANDS = dict.fromkeys(ext_7zip, cmd_7zip)
# Using linux
elif os.name == 'posix':
Logger.info("EXTRACTOR: We are using *nix")
EXTRACT_COMMANDS = {".rar": ["unrar", "e"], ".zip": ["unzip", ""], ".tar.gz": ["tar", "xzf"], ".tgz": ["tar", "xzf"], ".tar.bz2": ["tar", "xjf"], ".tbz": ["tar", "xjf"], ".tar.lzma": ["tar", "--lzma xf"], ".tlz": ["tar", "--lzma xf"], ".txz": ["tar", "--xz xf"], ".7z": ["7zr", "x"], }
# Need to add a check for which commands that can be utilized in *nix systems..
else:
Logger.error("EXTRACTOR: Unknown OS, exiting")
ext = os.path.splitext(file)
fp = os.path.join(dirpath, file)
if ext[1] in (".gz", ".bz2", ".lzma"):
# Check if this is a tar
if os.path.splitext(ext[0])[1] == ".tar":
cmd = EXTRACT_COMMANDS[".tar" + ext[1]]
else:
if ext[1] in EXTRACT_COMMANDS:
cmd = EXTRACT_COMMANDS[ext[1]]
else:
Logger.debug("EXTRACTOR: Unknown file type: %s", ext[1])
return False
# Create destination folder
if not os.path.exists(destination):
try:
Logger.debug("EXTRACTOR: Creating destination folder: %s", destination)
os.makedirs(destination)
except Exception, e:
Logger.error("EXTRACTOR: Not possible to create destination folder: %s", e)
return False
Logger.info("Extracting %s to %s", fp, destination)
# Running
Logger.debug("Extracting %s %s %s %s", cmd[0], cmd[1], fp, destination)
pwd = os.getcwd() # Get our Present Working Directory
os.chdir(destination) # Not all unpack commands accept full paths, so just extract into this directory
if os.name == 'nt': # Windows needs quotes around directory structure
try:
run = "\"" + cmd[0] + "\" " + cmd[1] + " \"" + fp + "\"" # Windows needs quotes around directories
res = call(run)
if res == 0:
Logger.info("EXTRACTOR: Extraction was successful for %s to %s", fp, destination)
else:
Logger.info("EXTRACTOR: Extraction failed for %s. 7zip result was %s", fp, res)
except:
Logger.error("EXTRACTOR: Extraction failed for %s. Could not call command %s %s", fp, run)
else:
try:
if cmd[1] == "": # If calling unzip, we dont want to pass the ""
res = call([cmd[0], fp])
else:
res = call([cmd[0], cmd[1], fp])
if res == 0:
Logger.info("EXTRACTOR: Extraction was successful for %s to %s", fp, destination)
else:
Logger.error("EXTRACTOR: Extraction failed for %s. 7zip result was %s", fp, res)
except:
Logger.error("EXTRACTOR: Extraction failed for %s. Could not call command %s %s %s %s", fp, cmd[0], cmd[1], fp)
os.chdir(pwd) # Go back to our Original Working Directory
return True
def flatten(outputDestination): def flatten(outputDestination):
Logger.info("FLATTEN: Flattening directory: %s", outputDestination) Logger.info("FLATTEN: Flattening directory: %s", outputDestination)
for dirpath, dirnames, filenames in os.walk(outputDestination): # Flatten out the directory to make postprocessing easier for dirpath, dirnames, filenames in os.walk(outputDestination): # Flatten out the directory to make postprocessing easier
@ -293,7 +224,6 @@ movieCategory = config.get("CouchPotato", "category")
movieDestination = os.path.normpath(config.get("CouchPotato", "outputDirectory")) movieDestination = os.path.normpath(config.get("CouchPotato", "outputDirectory"))
# Torrent specific # Torrent specific
useLink = int(config.get("Torrent", "useLink")) useLink = int(config.get("Torrent", "useLink"))
extractionTool = os.path.normpath(config.get("Torrent", "extractionTool")) ### this can be removed when extractor verified.
uTorrentWEBui = config.get("Torrent", "uTorrentWEBui") uTorrentWEBui = config.get("Torrent", "uTorrentWEBui")
uTorrentUSR = config.get("Torrent", "uTorrentUSR") uTorrentUSR = config.get("Torrent", "uTorrentUSR")
uTorrentPWD = config.get("Torrent", "uTorrentPWD") uTorrentPWD = config.get("Torrent", "uTorrentPWD")