Compare commits

...

2 Commits

6 changed files with 52 additions and 16 deletions

2
.gitignore vendored
View File

@ -2,6 +2,8 @@
*.py[oc] *.py[oc]
*.swp *.swp
_buildid.py
build/ build/
dist/ dist/

View File

@ -17,7 +17,7 @@
</sizepolicy> </sizepolicy>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Luftdaten.info Flashing Tool</string> <string>Luftdaten.info Flashing Tool (v{version})</string>
</property> </property>
<property name="windowIcon"> <property name="windowIcon">
<iconset> <iconset>
@ -279,6 +279,19 @@
<property name="spacing"> <property name="spacing">
<number>12</number> <number>12</number>
</property> </property>
<item row="1" column="1">
<widget class="QLabel" name="buildLabel">
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>&lt;b&gt;Luftdaten.info Flashing Tool&lt;/b&gt;&lt;br/&gt;Build {build_id}</string>
</property>
</widget>
</item>
<item row="1" column="0"> <item row="1" column="0">
<widget class="QLabel" name="label_6"> <widget class="QLabel" name="label_6">
<property name="maximumSize"> <property name="maximumSize">
@ -298,19 +311,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1">
<widget class="QLabel" name="label_7">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Luftdaten.info Flashing Tool</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2"> <item row="2" column="0" colspan="2">
<widget class="QLabel" name="label_8"> <widget class="QLabel" name="label_8">
<property name="text"> <property name="text">

View File

@ -11,6 +11,7 @@ import logging
import requests import requests
from esptool import ESPLoader from esptool import ESPLoader
import luftdatentool
from luftdatentool.qtvariant import QtGui, QtCore, QtWidgets from luftdatentool.qtvariant import QtGui, QtCore, QtWidgets
from luftdatentool.utils import QuickThread from luftdatentool.utils import QuickThread
from luftdatentool.workers import PortDetectThread, FirmwareListThread, \ from luftdatentool.workers import PortDetectThread, FirmwareListThread, \
@ -87,6 +88,21 @@ class MainWindow(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
def on_work_error(self, message): def on_work_error(self, message):
self.statusbar.showMessage(message) self.statusbar.showMessage(message)
@property
def version(self):
return luftdatentool.__version__
@property
def build_id(self):
try:
from luftdatentool._buildid import commit, builddate
except ImportError:
import datetime
commit = 'devel'
builddate = datetime.datetime.now().strftime('%Y%m%d')
return '{}-{}/{}'.format(self.version, commit, builddate)
def i18n_init(self, locale): def i18n_init(self, locale):
"""Initializes i18n to specified QLocale""" """Initializes i18n to specified QLocale"""
@ -97,6 +113,13 @@ class MainWindow(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
self.app.installTranslator(self.translator) self.app.installTranslator(self.translator)
self.retranslateUi(self) self.retranslateUi(self)
def retranslateUi(self, win):
super(MainWindow, self).retranslateUi(win)
win.setWindowTitle(win.windowTitle().format(
version=self.version))
win.buildLabel.setText(win.buildLabel.text().format(
build_id=self.build_id))
def populate_versions(self, files): def populate_versions(self, files):
"""Loads available firmware versions into versionbox widget""" """Loads available firmware versions into versionbox widget"""

View File

@ -2,6 +2,16 @@
block_cipher = None block_cipher = None
import subprocess
import datetime
commit = subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD']).strip().decode('utf-8')
builddate = datetime.datetime.now().strftime('%Y%m%d')
with open('luftdatentool/_buildid.py', 'w') as fd:
fd.write('''# This file is autogenerated in luftdaten-tool.spec file
commit = "{commit}"
builddate = "{builddate}"'''.format(commit=commit, builddate=builddate))
a = Analysis(['luftdaten-tool.py'], a = Analysis(['luftdaten-tool.py'],
pathex=['.'], pathex=['.'],

View File

@ -0,0 +1 @@
__version__ = '0.2'

View File

@ -17,11 +17,11 @@ class PortDetectThread(QuickThread):
def target(self): def target(self):
"""Checks list of available ports and emits signal when necessary""" """Checks list of available ports and emits signal when necessary"""
ports = [] ports = None
while True: while True:
new_ports = serial.tools.list_ports.comports() new_ports = serial.tools.list_ports.comports()
if [p.name for p in ports] != [p.name for p in new_ports]: if ports is None or [p.name for p in ports] != [p.name for p in new_ports]:
self.portsUpdate.emit(new_ports) self.portsUpdate.emit(new_ports)
time.sleep(self.interval) time.sleep(self.interval)