mirror of
https://gitlab.com/RemixDev/deemix-gui-pyweb.git
synced 2024-12-29 10:56:06 +00:00
Added version to spec file
This commit is contained in:
parent
dc3c7640e5
commit
431cd7c7f9
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -34,3 +34,4 @@ deemix
|
||||||
webview
|
webview
|
||||||
config
|
config
|
||||||
commit.txt
|
commit.txt
|
||||||
|
version.txt
|
||||||
|
|
|
@ -1,5 +1,13 @@
|
||||||
# -*- mode: python ; coding: utf-8 -*-
|
# -*- mode: python ; coding: utf-8 -*-
|
||||||
import sys
|
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
|
block_cipher = None
|
||||||
|
|
||||||
|
@ -7,7 +15,7 @@ sys.modules['FixTk'] = None
|
||||||
|
|
||||||
a = Analysis(['deemix-pyweb.py'],
|
a = Analysis(['deemix-pyweb.py'],
|
||||||
binaries=[],
|
binaries=[],
|
||||||
datas=[('webui/public', 'webui'), ('icon.ico', '.')],
|
datas=[('webui/public', 'webui'), ('icon.ico', '.'), ('version.txt', '.')],
|
||||||
hiddenimports=['engineio.async_drivers.threading', 'pkg_resources.py2_warn'],
|
hiddenimports=['engineio.async_drivers.threading', 'pkg_resources.py2_warn'],
|
||||||
hookspath=[],
|
hookspath=[],
|
||||||
runtime_hooks=[],
|
runtime_hooks=[],
|
||||||
|
|
38
server.py
38
server.py
|
@ -4,8 +4,10 @@ import sys
|
||||||
import subprocess
|
import subprocess
|
||||||
from os import path
|
from os import path
|
||||||
import json
|
import json
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
from urllib.request import urlopen
|
from urllib.request import urlopen
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
from flask import Flask, render_template, request, session, redirect, copy_current_request_context
|
from flask import Flask, render_template, request, session, redirect, copy_current_request_context
|
||||||
from flask_socketio import SocketIO, emit
|
from flask_socketio import SocketIO, emit
|
||||||
|
@ -80,20 +82,38 @@ logging.getLogger('engineio').setLevel(logging.ERROR)
|
||||||
#server.logger.disabled = True
|
#server.logger.disabled = True
|
||||||
|
|
||||||
firstConnection = True
|
firstConnection = True
|
||||||
appDir = path.dirname(path.realpath(__file__))
|
|
||||||
|
|
||||||
currentCommit = None
|
currentVersion = None
|
||||||
latestCommit = None
|
latestVersion = None
|
||||||
updateAvailable = False
|
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():
|
def check_for_updates():
|
||||||
global currentCommit, latestCommit, updateAvailable
|
global currentVersion, latestVersion, updateAvailable
|
||||||
if path.isfile(path.join(appDir, 'commit.txt')):
|
commitFile = resource_path('version.txt')
|
||||||
|
if path.isfile(commitFile):
|
||||||
print("Checking for updates...")
|
print("Checking for updates...")
|
||||||
with open(path.join(appDir, 'commit.txt'), 'r') as f:
|
with open(commitFile, 'r') as f:
|
||||||
currentCommit = f.read().strip()
|
currentVersion = f.read().strip()
|
||||||
latestCommit = requests.get("https://deemix.app/pyweb/latest").text.strip()
|
try:
|
||||||
updateAvailable = currentCommit != latestCommit
|
latestVersion = requests.get("https://deemix.app/pyweb/latest").text.strip()
|
||||||
|
except:
|
||||||
|
latestVersion = None
|
||||||
|
if currentVersion and latestVersion:
|
||||||
|
updateAvailable = compare_versions(currentVersion, latestVersion)
|
||||||
if updateAvailable:
|
if updateAvailable:
|
||||||
print("Update available! Commit: "+latestCommit)
|
print("Update available! Commit: "+latestCommit)
|
||||||
else:
|
else:
|
||||||
|
|
10
server.spec
10
server.spec
|
@ -1,5 +1,13 @@
|
||||||
# -*- mode: python ; coding: utf-8 -*-
|
# -*- mode: python ; coding: utf-8 -*-
|
||||||
import sys
|
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
|
block_cipher = None
|
||||||
|
|
||||||
|
@ -7,7 +15,7 @@ sys.modules['FixTk'] = None
|
||||||
|
|
||||||
a = Analysis(['server.py'],
|
a = Analysis(['server.py'],
|
||||||
binaries=[],
|
binaries=[],
|
||||||
datas=[('webui/public', 'webui'), ('icon.ico', '.')],
|
datas=[('webui/public', 'webui'), ('icon.ico', '.'), ('version.txt', '.')],
|
||||||
hiddenimports=['engineio.async_drivers.threading', 'pkg_resources.py2_warn'],
|
hiddenimports=['engineio.async_drivers.threading', 'pkg_resources.py2_warn'],
|
||||||
hookspath=[],
|
hookspath=[],
|
||||||
runtime_hooks=[],
|
runtime_hooks=[],
|
||||||
|
|
Loading…
Reference in a new issue