mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-19 12:59:36 -07:00
Use context manager instead of assignment
This commit is contained in:
parent
e0c55c4f84
commit
ddf15247e3
1 changed files with 15 additions and 16 deletions
|
@ -530,28 +530,27 @@ def configure_plex():
|
||||||
def configure_niceness():
|
def configure_niceness():
|
||||||
global NICENESS
|
global NICENESS
|
||||||
|
|
||||||
devnull = open(os.devnull, 'w')
|
with open(os.devnull, 'w') as devnull:
|
||||||
try:
|
|
||||||
subprocess.Popen(['nice'], stdout=devnull, stderr=devnull).communicate()
|
|
||||||
NICENESS.extend(['nice', '-n{0}'.format(int(CFG['Posix']['niceness']))])
|
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
subprocess.Popen(['ionice'], stdout=devnull, stderr=devnull).communicate()
|
|
||||||
try:
|
try:
|
||||||
NICENESS.extend(['ionice', '-c{0}'.format(int(CFG['Posix']['ionice_class']))])
|
subprocess.Popen(['nice'], stdout=devnull, stderr=devnull).communicate()
|
||||||
|
NICENESS.extend(['nice', '-n{0}'.format(int(CFG['Posix']['niceness']))])
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
if 'ionice' in NICENESS:
|
subprocess.Popen(['ionice'], stdout=devnull, stderr=devnull).communicate()
|
||||||
NICENESS.extend(['-n{0}'.format(int(CFG['Posix']['ionice_classdata']))])
|
try:
|
||||||
else:
|
NICENESS.extend(['ionice', '-c{0}'.format(int(CFG['Posix']['ionice_class']))])
|
||||||
NICENESS.extend(['ionice', '-n{0}'.format(int(CFG['Posix']['ionice_classdata']))])
|
except Exception:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
if 'ionice' in NICENESS:
|
||||||
|
NICENESS.extend(['-n{0}'.format(int(CFG['Posix']['ionice_classdata']))])
|
||||||
|
else:
|
||||||
|
NICENESS.extend(['ionice', '-n{0}'.format(int(CFG['Posix']['ionice_classdata']))])
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
devnull.close()
|
|
||||||
|
|
||||||
|
|
||||||
def initialize(section=None):
|
def initialize(section=None):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue