mirror of
https://github.com/jlu5/SupyPlugins.git
synced 2025-04-26 13:01:07 -05:00
SysDNS: simplify encoding setup
This commit is contained in:
parent
c7c1153459
commit
9e3e49ee70
@ -71,18 +71,17 @@ class SysDNS(callbacks.Plugin):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
with open(os.devnull) as null:
|
with open(os.devnull) as null:
|
||||||
inst = subprocess.Popen(args,
|
inst = subprocess.Popen(args, encoding='utf-8', errors='replace',
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
|
||||||
stderr=subprocess.PIPE,
|
|
||||||
stdin=null)
|
stdin=null)
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
irc.error('It seems the configured \'host\' command was '
|
irc.error('It seems the configured \'host\' command was '
|
||||||
'not available (%s).' % e, Raise=True)
|
'not available (%s).' % e, Raise=True)
|
||||||
result = inst.communicate()
|
result = inst.communicate()
|
||||||
if result[1]: # stderr
|
if result[1]: # stderr
|
||||||
irc.error(' '.join(result[1].decode('utf8').split()))
|
irc.error(' '.join(result[1].split()))
|
||||||
if result[0]: # stdout
|
if result[0]: # stdout
|
||||||
response = result[0].decode('utf8').splitlines()
|
response = result[0].splitlines()
|
||||||
response = [l for l in response if l]
|
response = [l for l in response if l]
|
||||||
irc.replies(response)
|
irc.replies(response)
|
||||||
elif not result[1]:
|
elif not result[1]:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user