index : archinstall32 | |
Archlinux32 installer | gitolite user |
summaryrefslogtreecommitdiff |
author | Anton Hvornum <anton.feeds@gmail.com> | 2019-04-11 21:11:20 +0200 |
---|---|---|
committer | Anton Hvornum <anton.feeds@gmail.com> | 2019-04-11 21:11:20 +0200 |
commit | 2d4ae2745485890d333f5b08bb7e484b5abfce85 (patch) | |
tree | f8c7f17802ed117b8cc13103572876df60e3c379 | |
parent | f11d93e255a9e0a9b5d16a6385ed74bf8be35b06 (diff) |
-rw-r--r-- | archinstall.py | 51 |
diff --git a/archinstall.py b/archinstall.py index d48d50e7..413ce171 100644 --- a/archinstall.py +++ b/archinstall.py @@ -170,31 +170,30 @@ class sys_command(): yield output - x = os.waitpid(self.pid, 0) - print('Exited with:', x) - -# def sys_command(cmd, echo=False, opts=None, *args, **kwargs): -# if not opts: opts = {} -# if echo or 'debug' in opts: -# print('[!] {}'.format(cmd)) -# handle = Popen(cmd, shell='True', stdout=PIPE, stderr=STDOUT, stdin=PIPE, **kwargs) -# output = b'' -# while handle.poll() is None: -# data = handle.stdout.read() -# if b'or press Control-D' in data: -# handle.stdin.write(b'') -# if len(data): -# if echo or 'debug' in opts: -# print(data.decode('UTF-8'), end='') -# # print(data.decode('UTF-8'), end='') -# output += data -# data = handle.stdout.read() -# if echo or 'debug' in opts: -# print(data.decode('UTF-8'), end='') -# output += data -# handle.stdin.close() -# handle.stdout.close() -# return output + exit_code = os.waitpid(self.pid, 0)[1] + if exit_code != 0: + print('[E] Command "{}" exited with status code:'.format(self.cmd[0]), exit_code) + +def simple_command(cmd, opts=None, *args, **kwargs): + if not opts: opts = {} + if echo or 'debug' in opts: + print('[!] {}'.format(cmd)) + handle = Popen(cmd, shell='True', stdout=PIPE, stderr=STDOUT, stdin=PIPE, **kwargs) + output = b'' + while handle.poll() is None: + data = handle.stdout.read() + if len(data): + if echo or 'debug' in opts: + print(data.decode('UTF-8'), end='') + # print(data.decode('UTF-8'), end='') + output += data + data = handle.stdout.read() + if echo or 'debug' in opts: + print(data.decode('UTF-8'), end='') + output += data + handle.stdin.close() + handle.stdout.close() + return output def update_git(): default_gw = get_default_gateway_linux() @@ -204,7 +203,7 @@ def update_git(): os.remove('/root/archinstall/archinstall.py') 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) if b'error:' in output: |