Formatted with black

This commit is contained in:
2020-06-21 20:29:53 +01:00
parent 079dff8d9f
commit 24045034c8
12 changed files with 913 additions and 568 deletions

View File

@@ -7,34 +7,36 @@ from jellyfin_accounts.web_api import resp
import os
if first_run:
def tempJF(server):
return Jellyfin(server,
config['jellyfin']['client'],
config['jellyfin']['version'],
config['jellyfin']['device'] + '_temp',
config['jellyfin']['device_id'] + '_temp')
return Jellyfin(
server,
config["jellyfin"]["client"],
config["jellyfin"]["version"],
config["jellyfin"]["device"] + "_temp",
config["jellyfin"]["device_id"] + "_temp",
)
@app.errorhandler(404)
def page_not_found(e):
return render_template('404.html'), 404
return render_template("404.html"), 404
@app.route('/', methods=['GET', 'POST'])
@app.route("/", methods=["GET", "POST"])
def setup():
return render_template('setup.html')
return render_template("setup.html")
@app.route('/<path:path>')
@app.route("/<path:path>")
def static_proxy(path):
if 'html' not in path:
if "html" not in path:
return app.send_static_file(path)
else:
return render_template('404.html'), 404
return render_template("404.html"), 404
@app.route('/modifyConfig', methods=['POST'])
@app.route("/modifyConfig", methods=["POST"])
def modifyConfig():
log.info('Config modification requested')
log.info("Config modification requested")
data = request.get_json()
temp_config = RawConfigParser(comment_prefixes='/',
allow_no_value=True)
temp_config = RawConfigParser(comment_prefixes="/", allow_no_value=True)
temp_config.read(config_path)
for section in data:
if section in temp_config:
@@ -42,24 +44,23 @@ if first_run:
if item in temp_config[section]:
temp_config[section][item] = data[section][item]
data[section][item] = True
log.debug(f'{section}/{item} modified')
log.debug(f"{section}/{item} modified")
else:
data[section][item] = False
log.debug(f'{section}/{item} does not exist in config')
with open(config_path, 'w') as config_file:
log.debug(f"{section}/{item} does not exist in config")
with open(config_path, "w") as config_file:
temp_config.write(config_file)
log.debug('Config written')
log.debug("Config written")
# ugly exit, sorry
os._exit(1)
return resp()
@app.route('/testJF', methods=['GET', 'POST'])
@app.route("/testJF", methods=["GET", "POST"])
def testJF():
data = request.get_json()
tempjf = tempJF(data['jfHost'])
tempjf = tempJF(data["jfHost"])
try:
tempjf.authenticate(data['jfUser'],
data['jfPassword'])
tempjf.authenticate(data["jfUser"], data["jfPassword"])
tempjf.getUsers(public=False)
return resp()
except: