PEP8: Fix formatting

* Remove redundant backslash between brackets
* Fix multiple statements on one line
* Fix missing/excess whitespace
* Fix comments not starting with a single # and a space
This commit is contained in:
labrys 2016-06-06 03:25:06 -04:00 committed by Labrys
parent 58d439f3eb
commit c2bf14f775
8 changed files with 501 additions and 483 deletions

View file

@ -9,6 +9,7 @@ from core import logger, nzbToMediaDB
from core.nzbToMediaUtil import convert_to_ascii, CharReplace, plex_update
from core.nzbToMediaUserScript import external_script
def processTorrent(inputDirectory, inputName, inputCategory, inputHash, inputID, clientAgent):
status = 1 # 1 = failed | 0 = success
root = 0
@ -51,10 +52,12 @@ def processTorrent(inputDirectory, inputName, inputCategory, inputHash, inputID,
usercat = inputCategory
try:
inputName = inputName.encode(core.SYS_ENCODING)
except: pass
except:
pass
try:
inputDirectory = inputDirectory.encode(core.SYS_ENCODING)
except: pass
except:
pass
logger.debug("Determined Directory: {0} | Name: {1} | Category: {2}".format(inputDirectory, inputName, inputCategory))
@ -122,7 +125,8 @@ def processTorrent(inputDirectory, inputName, inputCategory, inputHash, inputID,
core.os.path.join(core.OUTPUTDIRECTORY, inputCategory))
try:
outputDestination = outputDestination.encode(core.SYS_ENCODING)
except: pass
except:
pass
if outputDestination in inputDirectory:
outputDestination = inputDirectory
@ -162,12 +166,13 @@ def processTorrent(inputDirectory, inputName, inputCategory, inputHash, inputID,
"Setting outputDestination to {0} to preserve folder structure".format(os.path.dirname(targetFile)))
try:
targetFile = targetFile.encode(core.SYS_ENCODING)
except: pass
except:
pass
if root == 1:
if not foundFile:
logger.debug("Looking for {0} in: {1}".format(inputName, inputFile))
if (core.sanitizeName(inputName) in core.sanitizeName(inputFile)) or (
core.sanitizeName(fileName) in core.sanitizeName(inputName)):
if any([core.sanitizeName(inputName) in core.sanitizeName(inputFile),
core.sanitizeName(fileName) in core.sanitizeName(inputName)]):
foundFile = True
logger.debug("Found file {0} that matches Torrent Name {1}".format(fullFileName, inputName))
else:
@ -339,11 +344,13 @@ def main(args):
try:
dirName = dirName.encode(core.SYS_ENCODING)
except: pass
except:
pass
inputName = os.path.basename(dirName)
try:
inputName = inputName.encode(core.SYS_ENCODING)
except: pass
except:
pass
results = processTorrent(dirName, inputName, subsection, inputHash, inputID,
clientAgent)

View file

@ -1,8 +1,8 @@
#!/usr/bin/env python2
# coding=utf-8
#
##############################################################################
### NZBGET POST-PROCESSING SCRIPT ###
# ##############################################################################
# ### NZBGET POST-PROCESSING SCRIPT ###
# Post-Process to CouchPotato, SickBeard, NzbDrone, Mylar, Gamez, HeadPhones.
#
@ -10,10 +10,10 @@
#
# NOTE: This script requires Python to be installed on your system.
##############################################################################
### OPTIONS ###
# ##############################################################################
# ### OPTIONS ###
## General
# ## General
# Auto Update nzbToMedia (0, 1).
#
@ -30,7 +30,7 @@
# Enable/Disable a safety check to ensure we don't process all downloads in the default_downloadDirectory by mistake.
# safe_mode=1
## CouchPotato
# ## CouchPotato
# CouchPotato script category.
#
@ -83,7 +83,7 @@
# Enable to replace local path with the path as per the mountPoints below.
# cpsremote_path=0
## Network
# ## Network
# Network Mount Points (Needed for remote path above)
#
@ -91,14 +91,14 @@
# e.g. mountPoints=/volume1/Public/,E:\|/volume2/share/,\\NAS\
# mountPoints=
## Extensions
# ## Extensions
# Media Extensions
#
# This is a list of media extensions that are used to verify that the download does contain valid media.
# mediaExtensions=.mkv,.avi,.divx,.xvid,.mov,.wmv,.mp4,.mpg,.mpeg,.vob,.iso,.ts
## Posix
# ## Posix
# Niceness for external tasks Extractor and Transcoder.
#
@ -115,7 +115,7 @@
# Set the ionice scheduling class data. This defines the class data, if the class accepts an argument. For real time and best-effort, 0-7 is valid data.
# ionice_classdata=4
## Transcoder
# ## Transcoder
# getSubs (0, 1).
#
@ -225,7 +225,7 @@
# outputAudioOtherBitrate=128k
# outputSubtitleCodec=
## WakeOnLan
# ## WakeOnLan
# use WOL (0, 1).
#
@ -241,8 +241,9 @@
# wolhost=192.168.1.37
# wolport=80
### NZBGET POST-PROCESSING SCRIPT ###
##############################################################################
# ### NZBGET POST-PROCESSING SCRIPT ###
# ##############################################################################
import sys
import nzbToMedia

View file

@ -1,8 +1,8 @@
#!/usr/bin/env python2
# coding=utf-8
#
##############################################################################
### NZBGET POST-PROCESSING SCRIPT ###
# ##############################################################################
# ### NZBGET POST-PROCESSING SCRIPT ###
# Post-Process to CouchPotato, SickBeard, NzbDrone, Mylar, Gamez, HeadPhones.
#
@ -10,11 +10,11 @@
#
# NOTE: This script requires Python to be installed on your system.
##############################################################################
# ##############################################################################
#
### OPTIONS ###
# ### OPTIONS ###
## General
# ## General
# Auto Update nzbToMedia (0, 1).
#
@ -26,7 +26,7 @@
# Enable/Disable a safety check to ensure we don't process all downloads in the default_downloadDirectory by mistake.
# safe_mode=1
## Gamez
# ## Gamez
# Gamez script category.
#
@ -64,7 +64,7 @@
# set this to where your Gamez completed downloads are.
# gzwatch_dir=
## Posix
# ## Posix
# Niceness for external tasks Extractor and Transcoder.
#
@ -81,7 +81,7 @@
# Set the ionice scheduling class data. This defines the class data, if the class accepts an argument. For real time and best-effort, 0-7 is valid data.
# ionice_classdata=4
## WakeOnLan
# ## WakeOnLan
# use WOL (0, 1).
#
@ -97,8 +97,9 @@
# wolhost=192.168.1.37
# wolport=80
### NZBGET POST-PROCESSING SCRIPT ###
##############################################################################
# ### NZBGET POST-PROCESSING SCRIPT ###
# ##############################################################################
import sys
import nzbToMedia

View file

@ -1,8 +1,8 @@
#!/usr/bin/env python2
# coding=utf-8
#
##############################################################################
### NZBGET POST-PROCESSING SCRIPT ###
# ##############################################################################
# ### NZBGET POST-PROCESSING SCRIPT ###
# Post-Process to HeadPhones.
#
@ -10,10 +10,10 @@
#
# NOTE: This script requires Python to be installed on your system.
##############################################################################
### OPTIONS
# ##############################################################################
# ### OPTIONS
## General
# ## General
# Auto Update nzbToMedia (0, 1).
#
@ -25,7 +25,7 @@
# Enable/Disable a safety check to ensure we don't process all downloads in the default_downloadDirectory by mistake.
# safe_mode=1
## HeadPhones
# ## HeadPhones
# HeadPhones script category.
#
@ -68,7 +68,7 @@
# Enable to replace local path with the path as per the mountPoints below.
# hpremote_path=0
## Posix
# ## Posix
# Niceness for external tasks Extractor and Transcoder.
#
@ -85,7 +85,7 @@
# Set the ionice scheduling class data. This defines the class data, if the class accepts an argument. For real time and best-effort, 0-7 is valid data.
# ionice_classdata=4
## Network
# ## Network
# Network Mount Points (Needed for remote path above)
#
@ -93,7 +93,7 @@
# e.g. mountPoints=/volume1/Public/,E:\|/volume2/share/,\\NAS\
# mountPoints=
## WakeOnLan
# ## WakeOnLan
# use WOL (0, 1).
#
@ -109,8 +109,9 @@
# wolhost=192.168.1.37
# wolport=80
### NZBGET POST-PROCESSING SCRIPT ###
##############################################################################
# ### NZBGET POST-PROCESSING SCRIPT ###
# ##############################################################################
import sys
import nzbToMedia

View file

@ -1,8 +1,8 @@
#!/usr/bin/env python2
# coding=utf-8
#
##############################################################################
### NZBGET POST-PROCESSING SCRIPT ###
# ##############################################################################
# ### NZBGET POST-PROCESSING SCRIPT ###
# Post-Process to CouchPotato, SickBeard, NzbDrone, Mylar, Gamez, HeadPhones.
#
@ -10,10 +10,10 @@
#
# NOTE: This script requires Python to be installed on your system.
##############################################################################
### OPTIONS ###
# ##############################################################################
# ### OPTIONS ###
## General
# ## General
# Auto Update nzbToMedia (0, 1).
#
@ -30,7 +30,7 @@
# Enable/Disable a safety check to ensure we don't process all downloads in the default_downloadDirectory by mistake.
# safe_mode=1
## CouchPotato
# ## CouchPotato
# CouchPotato script category.
#
@ -78,7 +78,7 @@
# Enable to replace local path with the path as per the mountPoints below.
# cpsremote_path=0
## SickBeard
# ## SickBeard
# SickBeard script category.
#
@ -134,7 +134,7 @@
# Enable to replace local path with the path as per the mountPoints below.
# sbremote_path=0
## NzbDrone
# ## NzbDrone
# NzbDrone script category.
#
@ -177,7 +177,7 @@
# Enable to replace local path with the path as per the mountPoints below.
# ndremote_path=0
## HeadPhones
# ## HeadPhones
# HeadPhones script category.
#
@ -210,7 +210,7 @@
# Enable to replace local path with the path as per the mountPoints below.
# hpremote_path=0
## Mylar
# ## Mylar
# Mylar script category.
#
@ -251,7 +251,7 @@
# Enable to replace local path with the path as per the mountPoints below.
# myremote_path=0
## Gamez
# ## Gamez
# Gamez script category.
#
@ -289,7 +289,7 @@
# Enable to replace local path with the path as per the mountPoints below.
# gzremote_path=0
## Network
# ## Network
# Network Mount Points (Needed for remote path above)
#
@ -297,14 +297,14 @@
# e.g. mountPoints=/volume1/Public/,E:\|/volume2/share/,\\NAS\
# mountPoints=
## Extensions
# ## Extensions
# Media Extensions
#
# This is a list of media extensions that are used to verify that the download does contain valid media.
# mediaExtensions=.mkv,.avi,.divx,.xvid,.mov,.wmv,.mp4,.mpg,.mpeg,.vob,.iso,.ts
## Posix
# ## Posix
# Niceness for external tasks Extractor and Transcoder.
#
@ -321,7 +321,7 @@
# Set the ionice scheduling class data. This defines the class data, if the class accepts an argument. For real time and best-effort, 0-7 is valid data.
# ionice_classdata=4
## Transcoder
# ## Transcoder
# getSubs (0, 1).
#
@ -431,7 +431,7 @@
# outputAudioOtherBitrate=128k
# outputSubtitleCodec=
## WakeOnLan
# ## WakeOnLan
# use WOL (0, 1).
#
@ -447,7 +447,7 @@
# wolhost=192.168.1.37
# wolport=80
## UserScript
# ## UserScript
# User Script category.
#
@ -496,8 +496,9 @@
# Delay in seconds after processing.
# usdelay=120
### NZBGET POST-PROCESSING SCRIPT ###
##############################################################################
# ### NZBGET POST-PROCESSING SCRIPT ###
# ##############################################################################
import os
import sys
import datetime
@ -510,6 +511,8 @@ from core.autoProcess.autoProcessTV import autoProcessTV
from core.nzbToMediaUtil import getDirs, extractFiles, cleanDir, update_downloadInfoStatus, get_downloadInfo, CharReplace, convert_to_ascii, get_nzoid, plex_update
from core.nzbToMediaUserScript import external_script
from core import logger, nzbToMediaDB
from six import text_type
# post-processing
def process(inputDirectory, inputName=None, status=0, clientAgent='manual', download_id=None, inputCategory=None, failureLink=None):
@ -769,17 +772,19 @@ def main(args, section=None):
try:
dirName = dirName.encode(core.SYS_ENCODING)
except: pass
except:
pass
inputName = os.path.basename(dirName)
try:
inputName = inputName.encode(core.SYS_ENCODING)
except: pass
except:
pass
results = process(dirName, inputName, 0, clientAgent=clientAgent,
download_id=download_id, inputCategory=subsection)
if results[0] != 0:
logger.error("A problem was reported when trying to perform a manual run for {0}:{1}.".format(
section, subsection))
logger.error("A problem was reported when trying to perform a manual run for {0}:{1}.".format
(section, subsection))
result = results
if result[0] == 0:

View file

@ -1,8 +1,8 @@
#!/usr/bin/env python2
# coding=utf-8
#
##############################################################################
### NZBGET POST-PROCESSING SCRIPT ###
# ##############################################################################
# ### NZBGET POST-PROCESSING SCRIPT ###
# Post-Process to Mylar.
#
@ -10,11 +10,11 @@
#
# NOTE: This script requires Python to be installed on your system.
##############################################################################
# ##############################################################################
#
### OPTIONS
# ### OPTIONS
## General
# ## General
# Auto Update nzbToMedia (0, 1).
#
@ -26,7 +26,7 @@
# Enable/Disable a safety check to ensure we don't process all downloads in the default_downloadDirectory by mistake.
# safe_mode=1
## Mylar
# ## Mylar
# Mylar script category.
#
@ -72,7 +72,7 @@
# Enable to replace local path with the path as per the mountPoints below.
# myremote_path=0
## Posix
# ## Posix
# Niceness for external tasks Extractor and Transcoder.
#
@ -89,7 +89,7 @@
# Set the ionice scheduling class data. This defines the class data, if the class accepts an argument. For real time and best-effort, 0-7 is valid data.
# ionice_classdata=4
## Network
# ## Network
# Network Mount Points (Needed for remote path above)
#
@ -97,7 +97,7 @@
# e.g. mountPoints=/volume1/Public/,E:\|/volume2/share/,\\NAS\
# mountPoints=
## WakeOnLan
# ## WakeOnLan
# use WOL (0, 1).
#
@ -113,8 +113,9 @@
# wolhost=192.168.1.37
# wolport=80
### NZBGET POST-PROCESSING SCRIPT ###
##############################################################################
# ### NZBGET POST-PROCESSING SCRIPT ###
# ##############################################################################
import sys
import nzbToMedia

View file

@ -1,8 +1,8 @@
#!/usr/bin/env python2
# coding=utf-8
#
##############################################################################
### NZBGET POST-PROCESSING SCRIPT ###
# ##############################################################################
# ### NZBGET POST-PROCESSING SCRIPT ###
# Post-Process to NzbDrone.
#
@ -10,10 +10,10 @@
#
# NOTE: This script requires Python to be installed on your system.
##############################################################################
### OPTIONS ###
# ##############################################################################
# ### OPTIONS ###
## General
# ## General
# Auto Update nzbToMedia (0, 1).
#
@ -30,7 +30,7 @@
# Enable/Disable a safety check to ensure we don't process all downloads in the default_downloadDirectory by mistake.
# safe_mode=1
## NzbDrone
# ## NzbDrone
# NzbDrone script category.
#
@ -73,7 +73,7 @@
# Enable to replace local path with the path as per the mountPoints below.
# ndremote_path=0
## Network
# ## Network
# Network Mount Points (Needed for remote path above)
#
@ -81,14 +81,14 @@
# e.g. mountPoints=/volume1/Public/,E:\|/volume2/share/,\\NAS\
# mountPoints=
## Extensions
# ## Extensions
# Media Extensions
#
# This is a list of media extensions that are used to verify that the download does contain valid media.
# mediaExtensions=.mkv,.avi,.divx,.xvid,.mov,.wmv,.mp4,.mpg,.mpeg,.vob,.iso,.ts
## Posix
# ## Posix
# Niceness for external tasks Extractor and Transcoder.
#
@ -105,7 +105,7 @@
# Set the ionice scheduling class data. This defines the class data, if the class accepts an argument. For real time and best-effort, 0-7 is valid data.
# ionice_classdata=4
## Transcoder
# ## Transcoder
# getSubs (0, 1).
#
@ -212,7 +212,7 @@
# outputAudioOtherBitrate = 128k
# outputSubtitleCodec =
## WakeOnLan
# ## WakeOnLan
# use WOL (0, 1).
#
@ -228,8 +228,9 @@
# wolhost=192.168.1.37
# wolport=80
### NZBGET POST-PROCESSING SCRIPT ###
##############################################################################
# ### NZBGET POST-PROCESSING SCRIPT ###
# ##############################################################################
import sys
import nzbToMedia

View file

@ -1,8 +1,8 @@
#!/usr/bin/env python2
# coding=utf-8
#
##############################################################################
### NZBGET POST-PROCESSING SCRIPT ###
# ##############################################################################
# ### NZBGET POST-PROCESSING SCRIPT ###
# Post-Process to SickBeard.
#
@ -10,10 +10,10 @@
#
# NOTE: This script requires Python to be installed on your system.
##############################################################################
### OPTIONS ###
# ##############################################################################
# ### OPTIONS ###
## General
# ## General
# Auto Update nzbToMedia (0, 1).
#
@ -30,7 +30,7 @@
# Enable/Disable a safety check to ensure we don't process all downloads in the default_downloadDirectory by mistake.
# safe_mode=1
## SickBeard
# ## SickBeard
# SickBeard script category.
#
@ -86,7 +86,7 @@
# Enable to replace local path with the path as per the mountPoints below.
# sbremote_path=0
## Network
# ## Network
# Network Mount Points (Needed for remote path above)
#
@ -94,14 +94,14 @@
# e.g. mountPoints=/volume1/Public/,E:\|/volume2/share/,\\NAS\
# mountPoints=
## Extensions
# ## Extensions
# Media Extensions
#
# This is a list of media extensions that are used to verify that the download does contain valid media.
# mediaExtensions=.mkv,.avi,.divx,.xvid,.mov,.wmv,.mp4,.mpg,.mpeg,.vob,.iso,.ts
## Posix
# ## Posix
# Niceness for external tasks Extractor and Transcoder.
#
@ -118,7 +118,7 @@
# Set the ionice scheduling class data. This defines the class data, if the class accepts an argument. For real time and best-effort, 0-7 is valid data.
# ionice_classdata=4
## Transcoder
# ## Transcoder
# getSubs (0, 1).
#
@ -228,7 +228,7 @@
# outputAudioOtherBitrate=128k
# outputSubtitleCodec=
## WakeOnLan
# ## WakeOnLan
# use WOL (0, 1).
#
@ -244,8 +244,9 @@
# wolhost=192.168.1.37
# wolport=80
### NZBGET POST-PROCESSING SCRIPT ###
##############################################################################
# ### NZBGET POST-PROCESSING SCRIPT ###
# ##############################################################################
import sys
import nzbToMedia