mirror of
https://github.com/krateng/maloja.git
synced 2025-06-06 18:33:19 +03:00
Add output for EOFError, fix GH-273
This commit is contained in:
parent
6bb81ce589
commit
63b8a49993
@ -37,46 +37,52 @@ def setup():
|
|||||||
copy_initial_local_files()
|
copy_initial_local_files()
|
||||||
SKIP = malojaconfig["SKIP_SETUP"]
|
SKIP = malojaconfig["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.")
|
try:
|
||||||
for k in ext_apikeys:
|
|
||||||
keyname = malojaconfig.get_setting_info(k)['name']
|
|
||||||
key = malojaconfig[k]
|
|
||||||
if key is False:
|
|
||||||
print(f"\tCurrently not using a {col['red'](keyname)} for image display.")
|
|
||||||
elif key is None or key == "ASK":
|
|
||||||
promptmsg = f"\tPlease enter your {col['gold'](keyname)}. If you do not want to use one at this moment, simply leave this empty and press Enter."
|
|
||||||
key = prompt(promptmsg,types=(str,),default=False,skip=SKIP)
|
|
||||||
malojaconfig[k] = key
|
|
||||||
else:
|
|
||||||
print(f"\t{col['lawngreen'](keyname)} found.")
|
|
||||||
|
|
||||||
|
print("Various external services can be used to display images. If not enough of them are set up, only local images will be used.")
|
||||||
# OWN API KEY
|
for k in ext_apikeys:
|
||||||
from .apis import apikeystore
|
keyname = malojaconfig.get_setting_info(k)['name']
|
||||||
if len(apikeystore) == 0:
|
key = malojaconfig[k]
|
||||||
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 key is False:
|
||||||
if answer:
|
print(f"\tCurrently not using a {col['red'](keyname)} for image display.")
|
||||||
key = apikeystore.generate_key('default')
|
elif key is None or key == "ASK":
|
||||||
print("Your API Key: " + col["yellow"](key))
|
promptmsg = f"\tPlease enter your {col['gold'](keyname)}. If you do not want to use one at this moment, simply leave this empty and press Enter."
|
||||||
|
key = prompt(promptmsg,types=(str,),default=False,skip=SKIP)
|
||||||
# PASSWORD
|
malojaconfig[k] = key
|
||||||
forcepassword = malojaconfig["FORCE_PASSWORD"]
|
|
||||||
# this is mainly meant for docker, supply password via environment variable
|
|
||||||
|
|
||||||
if forcepassword is not None:
|
|
||||||
# user has specified to force the pw, nothing else matters
|
|
||||||
auth.defaultuser.setpw(forcepassword)
|
|
||||||
print("Password has been set.")
|
|
||||||
elif auth.defaultuser.checkpw("admin"):
|
|
||||||
# if the actual pw is admin, it means we've never set this up properly (eg first start after update)
|
|
||||||
while True:
|
|
||||||
newpw = prompt("Please set a password for web backend access. Leave this empty to generate a random password.",skip=SKIP,secret=True)
|
|
||||||
if newpw is None:
|
|
||||||
newpw = randomstring(32)
|
|
||||||
print("Generated password:",col["yellow"](newpw))
|
|
||||||
break
|
|
||||||
else:
|
else:
|
||||||
newpw_repeat = prompt("Please type again to confirm.",skip=SKIP,secret=True)
|
print(f"\t{col['lawngreen'](keyname)} found.")
|
||||||
if newpw != newpw_repeat: print("Passwords do not match!")
|
|
||||||
else: break
|
|
||||||
auth.defaultuser.setpw(newpw)
|
# OWN API KEY
|
||||||
|
from .apis import apikeystore
|
||||||
|
if len(apikeystore) == 0:
|
||||||
|
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:
|
||||||
|
key = apikeystore.generate_key('default')
|
||||||
|
print("Your API Key: " + col["yellow"](key))
|
||||||
|
|
||||||
|
# PASSWORD
|
||||||
|
forcepassword = malojaconfig["FORCE_PASSWORD"]
|
||||||
|
# this is mainly meant for docker, supply password via environment variable
|
||||||
|
|
||||||
|
if forcepassword is not None:
|
||||||
|
# user has specified to force the pw, nothing else matters
|
||||||
|
auth.defaultuser.setpw(forcepassword)
|
||||||
|
print("Password has been set.")
|
||||||
|
elif auth.defaultuser.checkpw("admin"):
|
||||||
|
# if the actual pw is admin, it means we've never set this up properly (eg first start after update)
|
||||||
|
while True:
|
||||||
|
newpw = prompt("Please set a password for web backend access. Leave this empty to generate a random password.",skip=SKIP,secret=True)
|
||||||
|
if newpw is None:
|
||||||
|
newpw = randomstring(32)
|
||||||
|
print("Generated password:",col["yellow"](newpw))
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
newpw_repeat = prompt("Please type again to confirm.",skip=SKIP,secret=True)
|
||||||
|
if newpw != newpw_repeat: print("Passwords do not match!")
|
||||||
|
else: break
|
||||||
|
auth.defaultuser.setpw(newpw)
|
||||||
|
|
||||||
|
except EOFError:
|
||||||
|
print("No user input possible. If you are running inside a container, set the environment variable",col['yellow']("MALOJA_SKIP_SETUP=yes"))
|
||||||
|
raise SystemExit
|
||||||
|
Loading…
x
Reference in New Issue
Block a user