-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
configure-scripts: Fixes PEP8 errors
- Loading branch information
Showing
2 changed files
with
43 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,14 +9,15 @@ import os | |
import subprocess | ||
import sys | ||
|
||
## vars ######################################################################## | ||
# vars ################################################################### | ||
configfile = '/etc/xdg/weston/weston.ini' | ||
|
||
|
||
## functions ################################################################### | ||
# functions ############################################################## | ||
def pretty_print(line, prefix=""): | ||
print(prefix + line.decode('utf-8')) | ||
|
||
|
||
def call(command, interrupt=False, pp=pretty_print): | ||
print("\033[0;32m>>> %s\033[0m" % command) | ||
proc = subprocess.Popen(command.split(), stdout=subprocess.PIPE) | ||
|
@@ -29,6 +30,7 @@ def call(command, interrupt=False, pp=pretty_print): | |
print("!!! Failure") | ||
sys.exit(1) | ||
|
||
|
||
def set_option(config, section, option, defaults={}): | ||
if not config.has_section(section): | ||
config[section] = {} | ||
|
@@ -37,30 +39,37 @@ def set_option(config, section, option, defaults={}): | |
value = config.get(section, option, fallback=None) | ||
if not value: | ||
status = "default" | ||
value = defaults.get(section, {}).get(option,"") | ||
new_value = input("\033[1;33m>>> \033[0;37m[%s][%s] (%s: '%s'):\033[0m " % (section, option, status, value)) | ||
value = defaults.get(section, {}).get(option, "") | ||
new_value = input( | ||
"\033[1;33m>>> \033[0;37m[%s][%s] (%s: '%s'):\033[0m " % | ||
(section, option, status, value)) | ||
config[section][option] = new_value if new_value else value | ||
|
||
|
||
## command line options parser ################################################# | ||
# command line options parser ############################################ | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument("-c", "--configfile", dest="configfile", default=configfile, | ||
help=" (default: %s)" % configfile) | ||
parser.add_argument( | ||
"-c", | ||
"--configfile", | ||
dest="configfile", | ||
default=configfile, | ||
help=" (default: %s)" % | ||
configfile) | ||
|
||
args = parser.parse_args() | ||
configfile = args.configfile | ||
|
||
|
||
## main #################################################################### | ||
# main ##################################################################### | ||
if __name__ == "__main__": | ||
if os.geteuid() != 0: | ||
print("\033[0;31mYou need root permissions to run this command.\033") | ||
sys.exit(2) | ||
|
||
config = configparser.ConfigParser() | ||
config.read(configfile) | ||
config.get("core","idle-time", fallback=None) | ||
config.get("core","", fallback=None) | ||
config.get("core", "idle-time", fallback=None) | ||
config.get("core", "", fallback=None) | ||
|
||
defaults = {} | ||
defaults['core'] = {} | ||
|
@@ -92,4 +101,3 @@ if __name__ == "__main__": | |
|
||
call("diff -u %s.prev %s" % (configfile, configfile)) | ||
call("systemctl restart [email protected]") | ||
|