mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-27 13:19:24 +01:00
Unix: Fix FD leaks and Windows compatibility
This commit is contained in:
parent
a3c79d61f8
commit
bc4cfb96dd
@ -210,10 +210,11 @@ class Unix(callbacks.Plugin):
|
|||||||
args.append('-a')
|
args.append('-a')
|
||||||
args.extend(self.registryValue('fortune.files'))
|
args.extend(self.registryValue('fortune.files'))
|
||||||
try:
|
try:
|
||||||
inst = subprocess.Popen(args, close_fds=True,
|
with open(os.devnull) as null:
|
||||||
|
inst = subprocess.Popen(args,
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.PIPE,
|
stderr=subprocess.PIPE,
|
||||||
stdin=open(os.devnull))
|
stdin=null)
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
irc.error(_('It seems the configured fortune command was '
|
irc.error(_('It seems the configured fortune command was '
|
||||||
'not available.'), Raise=True)
|
'not available.'), Raise=True)
|
||||||
@ -241,10 +242,11 @@ class Unix(callbacks.Plugin):
|
|||||||
if wtfCmd:
|
if wtfCmd:
|
||||||
something = something.rstrip('?')
|
something = something.rstrip('?')
|
||||||
try:
|
try:
|
||||||
inst = subprocess.Popen([wtfCmd, something], close_fds=True,
|
with open(os.devnull, 'r+') as null:
|
||||||
|
inst = subprocess.Popen([wtfCmd, something],
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=open(os.devnull),
|
stderr=null,
|
||||||
stdin=open(os.devnull))
|
stdin=null)
|
||||||
except OSError:
|
except OSError:
|
||||||
irc.error(_('It seems the configured wtf command was not '
|
irc.error(_('It seems the configured wtf command was not '
|
||||||
'available.'), Raise=True)
|
'available.'), Raise=True)
|
||||||
@ -291,9 +293,11 @@ class Unix(callbacks.Plugin):
|
|||||||
args.append('5')
|
args.append('5')
|
||||||
args.append(host)
|
args.append(host)
|
||||||
try:
|
try:
|
||||||
inst = subprocess.Popen(args, stdout=subprocess.PIPE,
|
with open(os.devnull) as null:
|
||||||
|
inst = subprocess.Popen(args,
|
||||||
|
stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.PIPE,
|
stderr=subprocess.PIPE,
|
||||||
stdin=open(os.devnull))
|
stdin=null)
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
irc.error('It seems the configured ping command was '
|
irc.error('It seems the configured ping command was '
|
||||||
'not available (%s).' % e, Raise=True)
|
'not available (%s).' % e, Raise=True)
|
||||||
@ -323,10 +327,11 @@ class Unix(callbacks.Plugin):
|
|||||||
if uptimeCmd:
|
if uptimeCmd:
|
||||||
args = [uptimeCmd]
|
args = [uptimeCmd]
|
||||||
try:
|
try:
|
||||||
inst = subprocess.Popen(args, close_fds=True,
|
with open(os.devnull) as null:
|
||||||
|
inst = subprocess.Popen(args,
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.PIPE,
|
stderr=subprocess.PIPE,
|
||||||
stdin=open(os.devnull))
|
stdin=null)
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
irc.error('It seems the configured uptime command was '
|
irc.error('It seems the configured uptime command was '
|
||||||
'not available.', Raise=True)
|
'not available.', Raise=True)
|
||||||
@ -351,10 +356,11 @@ class Unix(callbacks.Plugin):
|
|||||||
if unameCmd:
|
if unameCmd:
|
||||||
args = [unameCmd, '-a']
|
args = [unameCmd, '-a']
|
||||||
try:
|
try:
|
||||||
inst = subprocess.Popen(args, close_fds=True,
|
with open(os.devnull) as null:
|
||||||
|
inst = subprocess.Popen(args,
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.PIPE,
|
stderr=subprocess.PIPE,
|
||||||
stdin=open(os.devnull))
|
stdin=null)
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
irc.error('It seems the configured uptime command was '
|
irc.error('It seems the configured uptime command was '
|
||||||
'not available.', Raise=True)
|
'not available.', Raise=True)
|
||||||
@ -381,9 +387,10 @@ class Unix(callbacks.Plugin):
|
|||||||
"""
|
"""
|
||||||
args = shlex.split(text)
|
args = shlex.split(text)
|
||||||
try:
|
try:
|
||||||
|
with open(os.devnull) as null:
|
||||||
inst = subprocess.Popen(args, stdout=subprocess.PIPE,
|
inst = subprocess.Popen(args, stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.PIPE,
|
stderr=subprocess.PIPE,
|
||||||
stdin=open(os.devnull))
|
stdin=null)
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
irc.error('It seems the requested command was '
|
irc.error('It seems the requested command was '
|
||||||
'not available (%s).' % e, Raise=True)
|
'not available (%s).' % e, Raise=True)
|
||||||
|
Loading…
Reference in New Issue
Block a user