I have a python-based GTK application that loads several modules. It is run from the (linux) terminal like so:
./myscript.py --some-flag setting
I'm using this to give an option for the users to restart the script within the console. Hope it could be a help.
def close_restart(self,csvfile):
choice = input('Do you want to restart the program? Please select \'Y\' if you would like to restart.')
if choice == 'Y' or choice == 'y':
print('Restarting now...')
os.execl(sys.executable, sys.executable, *sys.argv)
else:
print('Thank you for using the tool!')
print('The program will close in 10s...')
time.sleep(10)
So the user can input an option 'Y/N' to restart the program or not.