forked from ScoDoc/installmgr
last_stable_version returns json
This commit is contained in:
parent
12c875f76a
commit
e288b4c80d
@ -1,6 +1,6 @@
|
||||
import json, datetime, fcntl, glob, os, re, socket, subprocess, time
|
||||
|
||||
from flask import request, abort
|
||||
from flask import jsonify, request, abort
|
||||
from flask import Blueprint
|
||||
from app import email
|
||||
|
||||
@ -25,7 +25,7 @@ DEBIAN_PACKAGES_EXP="/srv/packages/pool/main/s/scodoc9/scodoc9_*.deb"
|
||||
@bp.route("/scodoc-installmgr/last_stable_version")
|
||||
def last_stable_version():
|
||||
"""version du dernier paquet ScoDoc 9 publié.
|
||||
=> chaine, "9.1.82"
|
||||
=> json
|
||||
"""
|
||||
# LAST_RELEASE_TAG=$(curl "$GITEA_RELEASE_URL" | jq ".[].tag_name" | tr -d -c "0-9.\n" | sort --version-sort | tail -1)
|
||||
debs = glob.glob(DEBIAN_PACKAGES_EXP)
|
||||
@ -33,13 +33,21 @@ def last_stable_version():
|
||||
for filename in debs:
|
||||
m = re.match(r".*scodoc9_9\.([0-9]{1,2})\.([0-9]{1,3})-1_amd64.deb", filename)
|
||||
if m:
|
||||
version_tuples.append( (9, int(m.group(1)), int(m.group(2))) )
|
||||
version_tuples.append( (9, int(m.group(1)), int(m.group(2)), filename) )
|
||||
|
||||
if len(version_tuples) == 0:
|
||||
return "?.?.?"
|
||||
version_tuples.sort()
|
||||
last_package_version = version_tuples[-1]
|
||||
return ".".join([str(x) for x in last_package_version])
|
||||
last_package_version = version_tuples[-1][:-1]
|
||||
last_package_filename = version_tuples[-1][-1]
|
||||
package_mtime = os.path.getmtime(last_package_filename)
|
||||
package_version_string = ".".join([str(x) for x in last_package_version])
|
||||
return jsonify( {
|
||||
"publication_time": package_mtime, # float, time
|
||||
"version" : package_version_string,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
|
||||
@bp.route("/scodoc-installmgr/upload-dump", methods=["POST"])
|
||||
|
Loading…
Reference in New Issue
Block a user