some random thoughts:
1. do not do
2. All this
3. this
1. do not do
if verbose == True:
. verbose is already True or False, so just do if verbose:
2. All this
if action == 'restart': run_command('systemctl restart ' + service, systemctl_verbose) if verbose == True: print('[V] Restarting service: ' + service) if action == 'start': run_command('systemctl start ' + service, systemctl_verbose) if verbose == True: print('[V] Starting service: ' + service) if action == 'stop': run_command('systemctl stop ' + service, systemctl_verbose) if verbose == True: print('[V] Stopping service: ' + service) if action == 'reload': run_command('systemctl reload ' + service, systemctl_verbose) if verbose == True: print('[V] Reloading service: ' + service)could be just
run_command('systemctl {} {}'.format(action, service), systemctl_verbose) if verbose: print('[V] {} service: {}'.format(action.capitalize(), service))
3. this
with open(path) as infile: with open(path + '.new', 'w') as outfile:can be on one line, to reduce indentation levels
with open(path) as infile, open(path + '.new', 'w') as outfile:
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs