Fixes bug in forecast thread (close app while downloading). Also makes some style adjustments
This commit is contained in:
@@ -2,6 +2,7 @@ from PyQt5.QtGui import QPixmap
|
||||
from PyQt5.QtCore import pyqtSlot, pyqtSignal, QObject
|
||||
from threads import UpadteSpaceWeatherThread, ThreadStatus
|
||||
|
||||
|
||||
class SpaceWeatherData(QObject):
|
||||
update_complete = pyqtSignal(bool)
|
||||
|
||||
@@ -12,15 +13,17 @@ class SpaceWeatherData(QObject):
|
||||
self.ak_index = ''
|
||||
self.sgas = ''
|
||||
self.geo_storm = ''
|
||||
self.images = [QPixmap(),
|
||||
QPixmap(),
|
||||
QPixmap(),
|
||||
QPixmap(),
|
||||
QPixmap(),
|
||||
QPixmap(),
|
||||
QPixmap(),
|
||||
QPixmap(),
|
||||
QPixmap()]
|
||||
self.images = [
|
||||
QPixmap(),
|
||||
QPixmap(),
|
||||
QPixmap(),
|
||||
QPixmap(),
|
||||
QPixmap(),
|
||||
QPixmap(),
|
||||
QPixmap(),
|
||||
QPixmap(),
|
||||
QPixmap()
|
||||
]
|
||||
self.__update_thread = UpadteSpaceWeatherThread(self)
|
||||
self.__update_thread.finished.connect(self.__parse_and_emit_signal)
|
||||
|
||||
@@ -33,7 +36,7 @@ class SpaceWeatherData(QObject):
|
||||
self.__update_thread.start()
|
||||
|
||||
def __parse_data(self):
|
||||
double_split = lambda string : [i.split() for i in string.splitlines()]
|
||||
double_split = lambda string: [i.split() for i in string.splitlines()]
|
||||
self.xray = double_split(self.xray)
|
||||
self.prot_el = double_split(self.prot_el)
|
||||
self.ak_index = double_split(self.ak_index)
|
||||
@@ -46,21 +49,26 @@ class SpaceWeatherData(QObject):
|
||||
self.ak_index = ''
|
||||
self.sgas = ''
|
||||
self.geo_storm = ''
|
||||
self.images = [QPixmap(),
|
||||
QPixmap(),
|
||||
QPixmap(),
|
||||
QPixmap(),
|
||||
QPixmap(),
|
||||
QPixmap(),
|
||||
QPixmap(),
|
||||
QPixmap(),
|
||||
QPixmap()]
|
||||
self.images = [
|
||||
QPixmap(),
|
||||
QPixmap(),
|
||||
QPixmap(),
|
||||
QPixmap(),
|
||||
QPixmap(),
|
||||
QPixmap(),
|
||||
QPixmap(),
|
||||
QPixmap(),
|
||||
QPixmap()
|
||||
]
|
||||
|
||||
@pyqtSlot()
|
||||
def __parse_and_emit_signal(self):
|
||||
if self.__update_thread.status is not ThreadStatus.OK:
|
||||
status_ok = False
|
||||
else:
|
||||
status_ok = False
|
||||
if self.__update_thread.status is ThreadStatus.OK:
|
||||
status_ok = True
|
||||
self.__parse_data()
|
||||
self.update_complete.emit(status_ok)
|
||||
|
||||
def shutdown_thread(self):
|
||||
self.__update_thread.terminate()
|
||||
self.__update_thread.wait()
|
||||
|
||||
Reference in New Issue
Block a user