Added version to spec file

This commit is contained in:
RemixDev 2020-09-08 19:55:36 +02:00
parent dc3c7640e5
commit 431cd7c7f9
4 changed files with 48 additions and 11 deletions

1
.gitignore vendored
View file

@ -34,3 +34,4 @@ deemix
webview
config
commit.txt
version.txt

View file

@ -1,5 +1,13 @@
# -*- mode: python ; coding: utf-8 -*-
import sys
from datetime import date
import subprocess
today = date.today().strftime("%Y.%m.%d")
commit = str(subprocess.check_output(['git', 'rev-parse', 'HEAD'])[:10])
version = f"{today}-{commit}"
with open('version.txt', 'w') as f:
f.write(version)
block_cipher = None
@ -7,7 +15,7 @@ sys.modules['FixTk'] = None
a = Analysis(['deemix-pyweb.py'],
binaries=[],
datas=[('webui/public', 'webui'), ('icon.ico', '.')],
datas=[('webui/public', 'webui'), ('icon.ico', '.'), ('version.txt', '.')],
hiddenimports=['engineio.async_drivers.threading', 'pkg_resources.py2_warn'],
hookspath=[],
runtime_hooks=[],

View file

@ -4,8 +4,10 @@ import sys
import subprocess
from os import path
import json
import requests
from urllib.request import urlopen
from datetime import datetime
from flask import Flask, render_template, request, session, redirect, copy_current_request_context
from flask_socketio import SocketIO, emit
@ -80,20 +82,38 @@ logging.getLogger('engineio').setLevel(logging.ERROR)
#server.logger.disabled = True
firstConnection = True
appDir = path.dirname(path.realpath(__file__))
currentCommit = None
latestCommit = None
currentVersion = None
latestVersion = None
updateAvailable = False
def compare_versions(currentVersion, latestVersion):
(currentDate, currentCommit) = tuple(currentVersion.split('-'))
(latestDate, latestCommit) = tuple(latestVersion.split('-'))
currentDate = currentDate.split('.')
latestDate = latestDate.split('.')
current = datetime(int(currentDate[0]), int(currentDate[1]), int(currentDate[2]))
latest = datetime(int(latestDate[0]), int(latestDate[1]), int(latestDate[2]))
if latest > current:
return True
elif latest == current:
return latestCommit != currentCommit
else:
return False
def check_for_updates():
global currentCommit, latestCommit, updateAvailable
if path.isfile(path.join(appDir, 'commit.txt')):
global currentVersion, latestVersion, updateAvailable
commitFile = resource_path('version.txt')
if path.isfile(commitFile):
print("Checking for updates...")
with open(path.join(appDir, 'commit.txt'), 'r') as f:
currentCommit = f.read().strip()
latestCommit = requests.get("https://deemix.app/pyweb/latest").text.strip()
updateAvailable = currentCommit != latestCommit
with open(commitFile, 'r') as f:
currentVersion = f.read().strip()
try:
latestVersion = requests.get("https://deemix.app/pyweb/latest").text.strip()
except:
latestVersion = None
if currentVersion and latestVersion:
updateAvailable = compare_versions(currentVersion, latestVersion)
if updateAvailable:
print("Update available! Commit: "+latestCommit)
else:

View file

@ -1,5 +1,13 @@
# -*- mode: python ; coding: utf-8 -*-
import sys
from datetime import date
import subprocess
today = date.today().strftime("%Y.%m.%d")
commit = subprocess.check_output(['git', 'rev-parse', 'HEAD'])[:10].decode("utf-8")
version = f"{today}-{commit}"
with open('version.txt', 'w') as f:
f.write(version)
block_cipher = None
@ -7,7 +15,7 @@ sys.modules['FixTk'] = None
a = Analysis(['server.py'],
binaries=[],
datas=[('webui/public', 'webui'), ('icon.ico', '.')],
datas=[('webui/public', 'webui'), ('icon.ico', '.'), ('version.txt', '.')],
hiddenimports=['engineio.async_drivers.threading', 'pkg_resources.py2_warn'],
hookspath=[],
runtime_hooks=[],