diff --git a/maloja/__init__.py b/maloja/__init__.py index e87142e..9d41815 100644 --- a/maloja/__init__.py +++ b/maloja/__init__.py @@ -7,14 +7,14 @@ author = { "email":"maloja@krateng.dev", "github": "krateng" } -version = 2,3,0 +version = 2,3,1 versionstr = ".".join(str(n) for n in version) requires = [ "bottle>=0.12.16", "waitress>=1.3", - "doreah>=1.5.2", + "doreah>=1.5.3", "nimrodel>=0.6.3", "setproctitle>=1.1.10", "wand>=0.5.4", diff --git a/maloja/controller.py b/maloja/controller.py index 8c120df..e45b2be 100755 --- a/maloja/controller.py +++ b/maloja/controller.py @@ -10,7 +10,7 @@ import stat import pathlib import pkg_resources from doreah.control import mainfunction -from doreah.io import col +from doreah.io import col, ask, prompt from .globalconf import datadir from .backup import backup @@ -37,6 +37,8 @@ def setup(): "SPOTIFY_API_ID":"Spotify Client ID", "SPOTIFY_API_SECRET":"Spotify Client Secret" } + + SKIP = settings.get_settings("SKIP_SETUP") print("Various external services can be used to display images. If not enough of them are set up, only local images will be used.") for k in apikeys: @@ -45,8 +47,7 @@ def setup(): print("\t" + "Currently not using a " + apikeys[k] + " for image display.") elif key == "ASK": print("\t" + "Please enter your " + apikeys[k] + ". If you do not want to use one at this moment, simply leave this empty and press Enter.") - key = input() - if key == "": key = None + key = prompt("",types=(str,),default=None,skip=SKIP) settings.update_settings(datadir("settings/settings.ini"),{k:key},create_new=True) else: print("\t" + apikeys[k] + " found.") @@ -56,9 +57,8 @@ def setup(): if os.path.exists(datadir("clients/authenticated_machines.tsv")): pass else: - print("Do you want to set up a key to enable scrobbling? Your scrobble extension needs that key so that only you can scrobble tracks to your database. [Y/n]") - answer = input() - if answer.lower() in ["y","yes","yea","1","positive","true",""]: + answer = ask("Do you want to set up a key to enable scrobbling? Your scrobble extension needs that key so that only you can scrobble tracks to your database.",default=True,skip=SKIP) + if answer: import random key = "" for i in range(64): @@ -66,20 +66,17 @@ def setup(): print("Your API Key: " + col["yellow"](key)) with open(datadir("clients/authenticated_machines.tsv"),"w") as keyfile: keyfile.write(key + "\t" + "Default Generated Key") - elif answer.lower() in ["n","no","nay","0","negative","false"]: + else: pass if settings.get_settings("NAME") is None: - print("Please enter your name. This will be displayed e.g. when comparing your charts to another user. Leave this empty if you would not like to specify a name right now.") - name = input() - if name == "": name = "Generic Maloja User" + name = prompt("Please enter your name. This will be displayed e.g. when comparing your charts to another user. Leave this empty if you would not like to specify a name right now.",default="Generic Maloja User",skip=SKIP) settings.update_settings(datadir("settings/settings.ini"),{"NAME":name},create_new=True) if settings.get_settings("SEND_STATS") is None: - print("I would like to know how many people use Maloja. Would it be okay to send a daily ping to my server (this contains no data that isn't accessible via your web interface already)? [Y/n]") - answer = input() - if answer.lower() in ["y","yes","yea","1","positive","true",""]: + answer = ask("I would like to know how many people use Maloja. Would it be okay to send a daily ping to my server (this contains no data that isn't accessible via your web interface already)?",default=True,skip=SKIP) + if answer: settings.update_settings(datadir("settings/settings.ini"),{"SEND_STATS":True,"PUBLIC_URL":None},create_new=True) else: settings.update_settings(datadir("settings/settings.ini"),{"SEND_STATS":False},create_new=True) diff --git a/maloja/data_files/settings/default.ini b/maloja/data_files/settings/default.ini index 65bd298..1784fc1 100644 --- a/maloja/data_files/settings/default.ini +++ b/maloja/data_files/settings/default.ini @@ -64,3 +64,4 @@ USE_PYHP = no #not recommended at the moment FEDERATION = yes #does nothing yet UPDATE_AFTER_CRASH = no #update when server is automatically restarted DAILY_RESTART = 2 # hour of day. no / none means no daily restarts +SKIP_SETUP = no