Minor refactoring
This commit is contained in:
10
artemis.py
10
artemis.py
@@ -606,7 +606,7 @@ class Artemis(QMainWindow, Ui_MainWindow):
|
||||
query += self.gfd_line_edit.text()
|
||||
try:
|
||||
webbrowser.open(Constants.GFD_SITE + query.lower())
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
@pyqtSlot(QListWidgetItem)
|
||||
@@ -713,12 +713,12 @@ class Artemis(QMainWindow, Ui_MainWindow):
|
||||
try:
|
||||
with open(db_path, "rb") as file_db:
|
||||
db = file_db.read()
|
||||
except:
|
||||
except Exception:
|
||||
self.download_db()
|
||||
else:
|
||||
try:
|
||||
is_checksum_ok = checksum_ok(db, ChecksumWhat.DB)
|
||||
except:
|
||||
except Exception:
|
||||
pop_up(self, title = Messages.NO_CONNECTION,
|
||||
text = Messages.NO_CONNECTION_MSG).show()
|
||||
else:
|
||||
@@ -741,7 +741,7 @@ class Artemis(QMainWindow, Ui_MainWindow):
|
||||
try:
|
||||
with open(db_path, "rb") as file_db:
|
||||
db = file_db.read()
|
||||
except:
|
||||
except Exception:
|
||||
answer = pop_up(self, title = Messages.NO_DB,
|
||||
text = Messages.NO_DB_AVAIL,
|
||||
informative_text = Messages.DOWNLOAD_NOW_QUESTION,
|
||||
@@ -751,7 +751,7 @@ class Artemis(QMainWindow, Ui_MainWindow):
|
||||
else:
|
||||
try:
|
||||
is_checksum_ok = checksum_ok(db, ChecksumWhat.DB)
|
||||
except:
|
||||
except Exception:
|
||||
pop_up(self, title = Messages.NO_CONNECTION,
|
||||
text = Messages.NO_CONNECTION_MSG).show()
|
||||
else:
|
||||
|
||||
48
constants.py
48
constants.py
@@ -131,30 +131,30 @@ class Constants(object):
|
||||
REMOVE = "Remove"
|
||||
UNKNOWN = "N/A"
|
||||
MODULATIONS = ("8VSB",
|
||||
"AFSK",
|
||||
"AM",
|
||||
"BFSK",
|
||||
"C4FM",
|
||||
"CDMA",
|
||||
"COFDM",
|
||||
"CW",
|
||||
"FFSK",
|
||||
"FM",
|
||||
"FMCW",
|
||||
"FMOP",
|
||||
"FSK",
|
||||
"GFSK",
|
||||
"GMSK",
|
||||
"IFK",
|
||||
"MFSK",
|
||||
"MSK",
|
||||
"OFDM",
|
||||
"OOK",
|
||||
"PAM",
|
||||
"PPM",
|
||||
"PSK",
|
||||
"QAM",
|
||||
"TDMA",)
|
||||
"AFSK",
|
||||
"AM",
|
||||
"BFSK",
|
||||
"C4FM",
|
||||
"CDMA",
|
||||
"COFDM",
|
||||
"CW",
|
||||
"FFSK",
|
||||
"FM",
|
||||
"FMCW",
|
||||
"FMOP",
|
||||
"FSK",
|
||||
"GFSK",
|
||||
"GMSK",
|
||||
"IFK",
|
||||
"MFSK",
|
||||
"MSK",
|
||||
"OFDM",
|
||||
"OOK",
|
||||
"PAM",
|
||||
"PPM",
|
||||
"PSK",
|
||||
"QAM",
|
||||
"TDMA",)
|
||||
LOCATIONS = (UNKNOWN,
|
||||
"Australia",
|
||||
"Canada",
|
||||
|
||||
16
themes.py
16
themes.py
@@ -38,13 +38,13 @@ class Theme(object):
|
||||
ThemeConstants.DEFAULT,
|
||||
ThemeConstants.ICONS_FOLDER)
|
||||
|
||||
self.__forecast_labels = SwitchableLabelsIterable(*list(chain(self.__parent.switchable_r_labels,
|
||||
self.__parent.switchable_s_labels,
|
||||
self.__parent.switchable_g_now_labels,
|
||||
self.__parent.switchable_g_today_labels,
|
||||
self.__parent.k_storm_labels,
|
||||
self.__parent.a_storm_labels,
|
||||
[self.__parent.expected_noise_lbl])))
|
||||
self.__forecast_labels = SwitchableLabelsIterable(*list(chain(self.__parent.switchable_r_labels,
|
||||
self.__parent.switchable_s_labels,
|
||||
self.__parent.switchable_g_now_labels,
|
||||
self.__parent.switchable_g_today_labels,
|
||||
self.__parent.k_storm_labels,
|
||||
self.__parent.a_storm_labels,
|
||||
[self.__parent.expected_noise_lbl])))
|
||||
|
||||
self.__forecast_labels.set("switch_on_colors", ThemeConstants.DEFAULT_ON_COLORS)
|
||||
self.__forecast_labels.set("switch_off_colors", ThemeConstants.DEFAULT_OFF_COLORS)
|
||||
@@ -209,7 +209,7 @@ class Theme(object):
|
||||
with open(os.path.join(ThemeConstants.FOLDER,
|
||||
ThemeConstants.CURRENT), "w") as current_theme:
|
||||
current_theme.write(self.__theme_path)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def initialize(self):
|
||||
|
||||
36
threads.py
36
threads.py
@@ -1,6 +1,5 @@
|
||||
from enum import Enum, auto
|
||||
from io import BytesIO
|
||||
from os import mkdir
|
||||
import os.path
|
||||
from shutil import rmtree
|
||||
import urllib3
|
||||
@@ -42,7 +41,7 @@ class DownloadThread(QThread):
|
||||
return
|
||||
try:
|
||||
is_checksum_ok = checksum_ok(db.data, ChecksumWhat.FOLDER)
|
||||
except:
|
||||
except Exception:
|
||||
self.__status = ThreadStatus.NO_CONNECTION_ERR
|
||||
return
|
||||
else:
|
||||
@@ -54,7 +53,7 @@ class DownloadThread(QThread):
|
||||
try:
|
||||
with ZipFile(BytesIO(db.data)) as zipped:
|
||||
zipped.extractall()
|
||||
except:
|
||||
except Exception:
|
||||
self.__status = ThreadStatus.UNKNOWN_ERR
|
||||
else:
|
||||
self.__status = ThreadStatus.OK
|
||||
@@ -75,22 +74,23 @@ class UpadteSpaceWeatherThread(QThread):
|
||||
self.wait()
|
||||
|
||||
def run(self):
|
||||
get_request_data = lambda link: urllib3.PoolManager().request('GET', link).data
|
||||
try:
|
||||
self.__space_weather_data.xray = str(urllib3.PoolManager().request('GET', Constants.FORECAST_XRAY).data, 'utf-8')
|
||||
self.__space_weather_data.prot_el = str(urllib3.PoolManager().request('GET', Constants.FORECAST_PROT).data, 'utf-8')
|
||||
self.__space_weather_data.ak_index = str(urllib3.PoolManager().request('GET', Constants.FORECAST_AK_IND).data, 'utf-8')
|
||||
self.__space_weather_data.sgas = str(urllib3.PoolManager().request('GET', Constants.FORECAST_SGAS).data, 'utf-8')
|
||||
self.__space_weather_data.geo_storm = str(urllib3.PoolManager().request('GET', Constants.FORECAST_G).data, 'utf-8')
|
||||
self.__space_weather_data.images[0].loadFromData(urllib3.PoolManager().request('GET', Constants.FORECAST_IMG_0).data)
|
||||
self.__space_weather_data.images[1].loadFromData(urllib3.PoolManager().request('GET', Constants.FORECAST_IMG_1).data)
|
||||
self.__space_weather_data.images[2].loadFromData(urllib3.PoolManager().request('GET', Constants.FORECAST_IMG_2).data)
|
||||
self.__space_weather_data.images[3].loadFromData(urllib3.PoolManager().request('GET', Constants.FORECAST_IMG_3).data)
|
||||
self.__space_weather_data.images[4].loadFromData(urllib3.PoolManager().request('GET', Constants.FORECAST_IMG_4).data)
|
||||
self.__space_weather_data.images[5].loadFromData(urllib3.PoolManager().request('GET', Constants.FORECAST_IMG_5).data)
|
||||
self.__space_weather_data.images[6].loadFromData(urllib3.PoolManager().request('GET', Constants.FORECAST_IMG_6).data)
|
||||
self.__space_weather_data.images[7].loadFromData(urllib3.PoolManager().request('GET', Constants.FORECAST_IMG_7).data)
|
||||
self.__space_weather_data.images[8].loadFromData(urllib3.PoolManager().request('GET', Constants.FORECAST_IMG_8).data)
|
||||
except:
|
||||
self.__space_weather_data.xray = str(get_request_data(Constants.FORECAST_XRAY), 'utf-8')
|
||||
self.__space_weather_data.prot_el = str(get_request_data(Constants.FORECAST_PROT), 'utf-8')
|
||||
self.__space_weather_data.ak_index = str(get_request_data(Constants.FORECAST_AK_IND), 'utf-8')
|
||||
self.__space_weather_data.sgas = str(get_request_data(Constants.FORECAST_SGAS), 'utf-8')
|
||||
self.__space_weather_data.geo_storm = str(get_request_data(Constants.FORECAST_G), 'utf-8')
|
||||
self.__space_weather_data.images[0].loadFromData(get_request_data(Constants.FORECAST_IMG_0))
|
||||
self.__space_weather_data.images[1].loadFromData(get_request_data(Constants.FORECAST_IMG_1))
|
||||
self.__space_weather_data.images[2].loadFromData(get_request_data(Constants.FORECAST_IMG_2))
|
||||
self.__space_weather_data.images[3].loadFromData(get_request_data(Constants.FORECAST_IMG_3))
|
||||
self.__space_weather_data.images[4].loadFromData(get_request_data(Constants.FORECAST_IMG_4))
|
||||
self.__space_weather_data.images[5].loadFromData(get_request_data(Constants.FORECAST_IMG_5))
|
||||
self.__space_weather_data.images[6].loadFromData(get_request_data(Constants.FORECAST_IMG_6))
|
||||
self.__space_weather_data.images[7].loadFromData(get_request_data(Constants.FORECAST_IMG_7))
|
||||
self.__space_weather_data.images[8].loadFromData(get_request_data(Constants.FORECAST_IMG_8))
|
||||
except Exception:
|
||||
self.__status = ThreadStatus.UNKNOWN_ERR
|
||||
else:
|
||||
self.__status = ThreadStatus.OK
|
||||
|
||||
@@ -50,7 +50,7 @@ def checksum_ok(data, what):
|
||||
try:
|
||||
reference = read_csv(Database.LINK_REF,
|
||||
delimiter = Database.DELIMITER).iat[-1, n]
|
||||
except:
|
||||
except Exception:
|
||||
raise
|
||||
return code.hexdigest() == reference
|
||||
|
||||
|
||||
Reference in New Issue
Block a user