cleaning up user init

master
Vincent Zeng 2017-12-31 12:52:23 -05:00
parent b5845ede8d
commit 22c03ccc75
1 changed files with 26 additions and 79 deletions

View File

@ -54,9 +54,6 @@ __author__ = "endorphant <endorphant@tilde.town)"
p = inflect.engine() p = inflect.engine()
## user globals
SETTINGS = { }
## ui globals ## ui globals
BANNER = util.attach_rainbow() + config.BANNER + util.attach_reset() BANNER = util.attach_rainbow() + config.BANNER + util.attach_reset()
SPACER = "\n" SPACER = "\n"
@ -67,7 +64,6 @@ EJECT = "eject button fired! going home now."
RAINBOW = False RAINBOW = False
## ref ## ref
EDITORS = ["nano", "vim", "vi", "emacs", "pico", "ed", "micro"] EDITORS = ["nano", "vim", "vi", "emacs", "pico", "ed", "micro"]
SUBJECTS = ["help request", "bug report", "feature suggestion", "general comment"] SUBJECTS = ["help request", "bug report", "feature suggestion", "general comment"]
DEFAULT_SETTINGS = { DEFAULT_SETTINGS = {
@ -77,6 +73,15 @@ DEFAULT_SETTINGS = {
"publishing": False "publishing": False
} }
## user globals
SETTINGS = {
"editor": "nano",
"publish dir": None,
"gopher": False,
"publishing": False
}
## ttbp specific utilities ## ttbp specific utilities
def menu_handler(options, prompt, pagify=10, rainbow=False, top=""): def menu_handler(options, prompt, pagify=10, rainbow=False, top=""):
@ -224,14 +229,7 @@ def check_init():
## ttbp env validation ## ttbp env validation
if not valid_setup(): if not valid_setup():
setup_repair() setup_repair()
elif not updated():
## version checker
'''
mismatch = build_mismatch()
if mismatch is not False:
switch_build(mismatch)
'''
if not updated():
update_version() update_version()
else: else:
raw_input("press <enter> to explore your feels.\n\n") raw_input("press <enter> to explore your feels.\n\n")
@ -254,12 +252,17 @@ def init():
raw_input(""" raw_input("""
i don't recognize you, stranger. let's make friends. i don't recognize you, stranger. let's make friends.
press <enter> to begin, or <ctrl-c> to get out of here. press <enter> to begin, or <ctrl-c> to get out of here.""")
""")
except KeyboardInterrupt: except KeyboardInterrupt:
print("\n\nthanks for checking in! i'll always be here.\n\n") print("\n\nthanks for checking in! i'll always be here.\n\n")
quit() quit()
print("\nokay! gimme a second to get you set up!")
time.sleep(1)
print("...")
time.sleep(1)
## record user in source list ## record user in source list
users = open(config.USERFILE, 'a') users = open(config.USERFILE, 'a')
users.write(config.USER+"\n") users.write(config.USER+"\n")
@ -268,6 +271,7 @@ press <enter> to begin, or <ctrl-c> to get out of here.
#subprocess.call(['chmod', 'a+w', config.USERFILE]) #subprocess.call(['chmod', 'a+w', config.USERFILE])
## make .ttbp directory structure ## make .ttbp directory structure
print("\ngenerating feels at {path}...".format(path=config.PATH).rstrip())
subprocess.call(["mkdir", config.PATH]) subprocess.call(["mkdir", config.PATH])
subprocess.call(["mkdir", config.USER_CONFIG]) subprocess.call(["mkdir", config.USER_CONFIG])
subprocess.call(["mkdir", config.USER_DATA]) subprocess.call(["mkdir", config.USER_DATA])
@ -289,10 +293,13 @@ press <enter> to begin, or <ctrl-c> to get out of here.
f.write(config.DEFAULT_STYLE) f.write(config.DEFAULT_STYLE)
## run user-interactive setup and load core engine ## run user-interactive setup and load core engine
time.sleep(1)
print("done setting up feels!")
print("\nthese are the default settings. you can change any of them now, or change them later at any time!!")
setup() setup()
core.load(SETTINGS) core.load(SETTINGS)
#raw_input("\nyou're all good to go, "+chatter.say("friend")+"! hit <enter> to continue.\n\n") raw_input("\nyou're all good to go, "+chatter.say("friend")+"! hit <enter> to continue.\n\n")
return "" return ""
def gen_header(): def gen_header():
@ -369,7 +376,7 @@ def setup_repair():
global SETTINGS global SETTINGS
print("\nyour ttbp configuration doesn't look right. let's make you a fresh copy.\n\n") print("\nyour ttbp configuration doesn't look right. let me try to fix it....\n\n")
settings_map = { settings_map = {
"editor": select_editor, "editor": select_editor,
@ -386,30 +393,10 @@ def setup_repair():
update_publishing() update_publishing()
core.reload_ttbprc(SETTINGS) core.reload_ttbprc(SETTINGS)
save_settings() save_settings()
'''
if SETTINGS.get("editor", None) is None:
SETTINGS.update({"editor": "not set"})
SETTINGS.update({"editor": select_editor()})
if SETTINGS.get("publishing", None) is None: print("...")
SETTINGS.update({"publishing": "not set"}) time.sleep(1)
SETTINGS.update({"publishing": select_publishing()}) raw_input("\nyou're all good to go, "+chatter.say("friend")+"! hit <enter> to continue.\n\n")
'''
'''
SETTINGS = {
"editor": "none",
"publish dir": False,
"publishing": False,
"gopher": False,
}
try:
setup()
except KeyboardInterrupt:
print("\n\nsorry, trying again.\n\n")
setup()
'''
def setup(): def setup():
''' '''
@ -1090,46 +1077,6 @@ def update_gopher():
##### PATCHING UTILITIES ##### PATCHING UTILITIES
"""
def build_mismatch():
'''
checks to see if user's last run build is the same as this session
'''
versionFile = os.path.join(config.PATH, "version")
if not os.path.exists(versionFile):
return False
ver = open(versionFile, "r").read().rstrip()
if ver[-1] == __version__[-1]:
return False
return ver
def switch_build(ver):
'''
switches user between beta and stable builds
'''
if __version__[-1] == 'b':
build = "beta"
ver += "b"
else:
build = "stable"
ver = ver[0:-1]
# write user versionfile
'''
print("\nswitching you over to the "+build+" version...\n")
time.sleep(1)
print("...")
'''
versionFile = os.path.join(config.PATH, "version")
open(versionFile, "w").write(ver)
time.sleep(1)
#print("\nall good!\n")
"""
def updated(): def updated():
''' '''
checks to see if current user is up to the same version as system checks to see if current user is up to the same version as system