Improve !fpull
This commit is contained in:
parent
360903c7ab
commit
8b76de1aea
@ -3273,25 +3273,46 @@ def player_stats_pm(cli, nick, rest):
|
||||
player_stats(cli, nick, nick, rest)
|
||||
|
||||
|
||||
@cmd("fpull", admin_only=True)
|
||||
@cmd('fpull', admin_only=True)
|
||||
def fpull(cli, nick, chan, rest):
|
||||
output = None
|
||||
try:
|
||||
output = subprocess.check_output(('git', 'pull'), stderr=subprocess.STDOUT)
|
||||
except subprocess.CalledProcessError as e:
|
||||
pm(cli, nick, '{0}: {1}'.format(type(e), e))
|
||||
#raise
|
||||
args = ['git', 'pull']
|
||||
|
||||
if output:
|
||||
for line in output.splitlines():
|
||||
if rest:
|
||||
args += rest.split(' ')
|
||||
|
||||
child = subprocess.Popen(args,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE)
|
||||
(out, err) = child.communicate()
|
||||
ret = child.returncode
|
||||
|
||||
for line in (out + err).splitlines():
|
||||
if chan == nick:
|
||||
cli.msg(nick, line.decode('utf-8'))
|
||||
else:
|
||||
pm(cli, nick, line.decode('utf-8'))
|
||||
else:
|
||||
pm(cli, nick, '(no output)')
|
||||
|
||||
@pmcmd("fpull", admin_only=True)
|
||||
if ret != 0:
|
||||
if ret < 0:
|
||||
cause = 'signal'
|
||||
else:
|
||||
cause = 'status'
|
||||
|
||||
if chan == nick:
|
||||
cli.msg(nick, 'Process {} exited with {} {}'.format(args,
|
||||
cause,
|
||||
abs(ret)))
|
||||
else:
|
||||
pm(cli, nick, 'Process {} exited with {} {}'.format(args,
|
||||
cause,
|
||||
abs(ret)))
|
||||
|
||||
|
||||
@pmcmd('fpull', admin_only=True)
|
||||
def fpull_pm(cli, nick, rest):
|
||||
fpull(cli, nick, nick, rest)
|
||||
|
||||
|
||||
@pmcmd("fsend", admin_only=True)
|
||||
def fsend(cli, nick, rest):
|
||||
print('{0} - {1} fsend - {2}'.format(time.strftime('%Y-%m-%dT%H:%M:%S%z'), nick, rest))
|
||||
|
Loading…
Reference in New Issue
Block a user