From 01c7540989f4b824740a715c34b0adb3fb82d9cc Mon Sep 17 00:00:00 2001 From: bohung Date: Wed, 31 Aug 2022 19:57:10 +0800 Subject: [PATCH] Fix bug. --- configure_netplan.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/configure_netplan.py b/configure_netplan.py index ddbee9b..45d2441 100644 --- a/configure_netplan.py +++ b/configure_netplan.py @@ -150,12 +150,17 @@ def main(): yaml.dump(netplan_config_yaml, f) netplan_get_status = os.system('sudo netplan get') if netplan_get_status == 0: - os.system('sudo netplan try --timeout 10 && echo "Finish configuring netplan!" && exit 0') - f.write(org_file_contents) - print("Recover changed!") + if os.system('sudo netplan try --timeout 10') == 0: + print("Finish configuring netplan!") + sys.exit(0) else: print("Something went wrong!") f.write(org_file_contents) print("Recover changed!") + sys.exit(1) + with open(netplan_config_file, 'w+') as f: + print(org_file_contents) + f.write(org_file_contents) + print("Recover changed!") if __name__ == '__main__': main() \ No newline at end of file