mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-22 06:13:19 -07:00
remove indented section
This commit is contained in:
parent
78d6840702
commit
6b1eb7d1cd
1 changed files with 49 additions and 49 deletions
|
@ -148,60 +148,60 @@ elif packed == 1: ## unpack
|
||||||
print "ERROR: Unknown OS, exiting"
|
print "ERROR: Unknown OS, exiting"
|
||||||
|
|
||||||
files = [ f for f in os.listdir(Directory) if os.path.isfile(os.path.join(Directory,f)) ]
|
files = [ f for f in os.listdir(Directory) if os.path.isfile(os.path.join(Directory,f)) ]
|
||||||
for f in files:
|
for f in files:
|
||||||
ext = os.path.splitext(f)
|
ext = os.path.splitext(f)
|
||||||
fp = os.path.join(Directory, os.path.normpath(f))
|
fp = os.path.join(Directory, os.path.normpath(f))
|
||||||
if ext[1] in (".gz", ".bz2", ".lzma"):
|
if ext[1] in (".gz", ".bz2", ".lzma"):
|
||||||
## Check if this is a tar
|
## Check if this is a tar
|
||||||
if os.path.splitext(ext[0])[1] == ".tar":
|
if os.path.splitext(ext[0])[1] == ".tar":
|
||||||
cmd = EXTRACT_COMMANDS[".tar" + ext[1]]
|
cmd = EXTRACT_COMMANDS[".tar" + ext[1]]
|
||||||
|
else:
|
||||||
|
if ext[1] in EXTRACT_COMMANDS:
|
||||||
|
cmd = EXTRACT_COMMANDS[ext[1]]
|
||||||
else:
|
else:
|
||||||
if ext[1] in EXTRACT_COMMANDS:
|
print("ERROR: Unknown file type: %s", ext[1])
|
||||||
cmd = EXTRACT_COMMANDS[ext[1]]
|
continue
|
||||||
else:
|
|
||||||
print("ERROR: Unknown file type: %s", ext[1])
|
|
||||||
continue
|
|
||||||
|
|
||||||
## Create destination folder
|
## Create destination folder
|
||||||
if not os.path.exists(destination):
|
if not os.path.exists(destination):
|
||||||
|
try:
|
||||||
|
os.makedirs(destination)
|
||||||
|
except Exception, e:
|
||||||
|
print("ERROR: Not possible to create destination folder: %s", e)
|
||||||
|
return
|
||||||
|
|
||||||
|
print("INFO: Extracting to %s", destination)
|
||||||
|
|
||||||
|
|
||||||
|
## Running..
|
||||||
|
print("INFO: 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:
|
try:
|
||||||
os.makedirs(destination)
|
run = "\"" + cmd[0] + "\" " + cmd[1] + " \"" + fp + "\"" #windows needs quotes around directories.
|
||||||
except Exception, e:
|
res = call(run)
|
||||||
print("ERROR: Not possible to create destination folder: %s", e)
|
if res == 0:
|
||||||
return
|
status = 0
|
||||||
|
print ("INFO: Extraction was successful for %s to %s", fp, destination)
|
||||||
print("INFO: Extracting to %s", destination)
|
else:
|
||||||
|
print("ERROR: Extraction failed for %s. 7zip result was %s", fp, res)
|
||||||
|
except:
|
||||||
## Running..
|
print ("ERROR: Extraction failed for %s. Could not call command %s %s", fp, run)
|
||||||
print("INFO: Extracting %s %s %s %s", cmd[0], cmd[1], fp, destination)
|
else:
|
||||||
pwd = os.getcwd() # Get our Present Working Directory
|
try:
|
||||||
os.chdir(destination) #not all unpack commands accept full paths, so just extract into this directory.
|
if cmd[1] == "": #if calling unzip, we dont want to pass the ""
|
||||||
if os.name == 'nt': #Windows needs quotes around directory structure
|
res = call([cmd[0], fp])
|
||||||
try:
|
else:
|
||||||
run = "\"" + cmd[0] + "\" " + cmd[1] + " \"" + fp + "\"" #windows needs quotes around directories.
|
res = call([cmd[0], cmd[1], fp])
|
||||||
res = call(run)
|
if res == 0:
|
||||||
if res == 0:
|
status = 0
|
||||||
status = 0
|
print ("INFO: Extraction was successful for %s to %s", fp, destination)
|
||||||
print ("INFO: Extraction was successful for %s to %s", fp, destination)
|
else:
|
||||||
else:
|
print("ERROR: Extraction failed for %s. 7zip result was %s", fp, res)
|
||||||
print("ERROR: Extraction failed for %s. 7zip result was %s", fp, res)
|
except:
|
||||||
except:
|
print ("ERROR: Extraction failed for %s. Could not call command %s %s %s %s", fp, cmd[0], cmd[1], fp)
|
||||||
print ("ERROR: Extraction failed for %s. Could not call command %s %s", fp, run)
|
os.chdir(pwd) # Go back to our Original Working Directory
|
||||||
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:
|
|
||||||
status = 0
|
|
||||||
print ("INFO: Extraction was successful for %s to %s", fp, destination)
|
|
||||||
else:
|
|
||||||
print("ERROR: Extraction failed for %s. 7zip result was %s", fp, res)
|
|
||||||
except:
|
|
||||||
print ("ERROR: 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
|
|
||||||
|
|
||||||
for dirpath, dirnames, filenames in os.walk(destination): #flatten out the directory to make postprocessing easier.
|
for dirpath, dirnames, filenames in os.walk(destination): #flatten out the directory to make postprocessing easier.
|
||||||
if dirpath == destination:
|
if dirpath == destination:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue