kopia lustrzana https://github.com/jamescoxon/dl-fldigi
Add flask update server
rodzic
dcf3804ec3
commit
6e372c5978
|
@ -0,0 +1,2 @@
|
|||
__main__.pyc
|
||||
__init__.pyc
|
|
@ -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)
|
|
@ -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"
|
|
@ -0,0 +1,2 @@
|
|||
Flask==0.9
|
||||
PyYAML==3.10
|
Ładowanie…
Reference in New Issue