Added back a simple_command() where path changes and stuff had to be done. For now.. this surely must work by doing os.chdir() or something
This commit is contained in:
parent
f11d93e255
commit
2d4ae27454
|
|
@ -170,31 +170,30 @@ class sys_command():
|
||||||
|
|
||||||
yield output
|
yield output
|
||||||
|
|
||||||
x = os.waitpid(self.pid, 0)
|
exit_code = os.waitpid(self.pid, 0)[1]
|
||||||
print('Exited with:', x)
|
if exit_code != 0:
|
||||||
|
print('[E] Command "{}" exited with status code:'.format(self.cmd[0]), exit_code)
|
||||||
|
|
||||||
# def sys_command(cmd, echo=False, opts=None, *args, **kwargs):
|
def simple_command(cmd, opts=None, *args, **kwargs):
|
||||||
# if not opts: opts = {}
|
if not opts: opts = {}
|
||||||
# if echo or 'debug' in opts:
|
if echo or 'debug' in opts:
|
||||||
# print('[!] {}'.format(cmd))
|
print('[!] {}'.format(cmd))
|
||||||
# handle = Popen(cmd, shell='True', stdout=PIPE, stderr=STDOUT, stdin=PIPE, **kwargs)
|
handle = Popen(cmd, shell='True', stdout=PIPE, stderr=STDOUT, stdin=PIPE, **kwargs)
|
||||||
# output = b''
|
output = b''
|
||||||
# while handle.poll() is None:
|
while handle.poll() is None:
|
||||||
# data = handle.stdout.read()
|
data = handle.stdout.read()
|
||||||
# if b'or press Control-D' in data:
|
if len(data):
|
||||||
# handle.stdin.write(b'')
|
if echo or 'debug' in opts:
|
||||||
# if len(data):
|
print(data.decode('UTF-8'), end='')
|
||||||
# if echo or 'debug' in opts:
|
# print(data.decode('UTF-8'), end='')
|
||||||
# print(data.decode('UTF-8'), end='')
|
output += data
|
||||||
# # print(data.decode('UTF-8'), end='')
|
data = handle.stdout.read()
|
||||||
# output += data
|
if echo or 'debug' in opts:
|
||||||
# data = handle.stdout.read()
|
print(data.decode('UTF-8'), end='')
|
||||||
# if echo or 'debug' in opts:
|
output += data
|
||||||
# print(data.decode('UTF-8'), end='')
|
handle.stdin.close()
|
||||||
# output += data
|
handle.stdout.close()
|
||||||
# handle.stdin.close()
|
return output
|
||||||
# handle.stdout.close()
|
|
||||||
# return output
|
|
||||||
|
|
||||||
def update_git():
|
def update_git():
|
||||||
default_gw = get_default_gateway_linux()
|
default_gw = get_default_gateway_linux()
|
||||||
|
|
@ -204,7 +203,7 @@ def update_git():
|
||||||
os.remove('/root/archinstall/archinstall.py')
|
os.remove('/root/archinstall/archinstall.py')
|
||||||
os.remove('/root/archinstall/README.md')
|
os.remove('/root/archinstall/README.md')
|
||||||
|
|
||||||
output = b''.join(sys_command('(cd /root/archinstall; git reset --hard origin/$(git branch | grep "*" | cut -d\' \' -f 2))').exec()) # git reset --hard origin/<branch_name> / git fetch --all
|
simple_command('(cd /root/archinstall; git reset --hard origin/$(git branch | grep "*" | cut -d\' \' -f 2))') # git reset --hard origin/<branch_name> / git fetch --all
|
||||||
print(output)
|
print(output)
|
||||||
|
|
||||||
if b'error:' in output:
|
if b'error:' in output:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue