Add flask update server

pull/2/head
Daniel Richman 2012-09-04 17:29:50 +01:00
rodzic dcf3804ec3
commit 6e372c5978
5 zmienionych plików z 50 dodań i 0 usunięć

2
update_server/.gitignore vendored 100644
Wyświetl plik

@ -0,0 +1,2 @@
__main__.pyc
__init__.pyc

Wyświetl plik

Wyświetl plik

@ -0,0 +1,39 @@
# Copyright 2012 Daniel Richman
# DL-Fldigi update check server
import os.path
import json
import yaml
from flask import Flask, abort, request
app_dir = os.path.dirname(__file__)
config_file = os.path.join(app_dir, "config.yml")
config = {}
app = Flask(__name__)
def load_config():
global config
mtime = os.stat(config_file).st_mtime
if mtime != config.get("_mtime", None):
with open(config_file) as f:
config = yaml.load(f)
config["_mtime"] = mtime
@app.route("/")
def check():
load_config()
# KeyError becomes 400 Bad Request; good.
platform = request.args["platform"]
commit = request.args["commit"]
expect = config["expect"][platform]
if expect == commit:
return ""
else:
return config["update_text"]
if __name__ == "__main__":
app.run(debug=True)

Wyświetl plik

@ -0,0 +1,7 @@
update_text: |
There is a new version of dl-fldigi available!
Go to http://ukhas.org.uk/projects:dl-fldigi to upgrade.
expect:
win32: "dcf3804ec3c006ab99867e053ec6996fb17ec50e"
linux: "dcf3804ec3c006ab99867e053ec6996fb17ec50e"
macosx: "dcf3804ec3c006ab99867e053ec6996fb17ec50e"

Wyświetl plik

@ -0,0 +1,2 @@
Flask==0.9
PyYAML==3.10