From 45d95a0a1b82531f330775e2ba21f9b94b415731 Mon Sep 17 00:00:00 2001 From: sailoog Date: Tue, 19 Mar 2024 12:18:12 +0100 Subject: [PATCH] new SK connections management --- debian/control | 2 +- openplotterMaiana/maianaPostInstall.py | 9 ------ openplotterMaiana/openplotterMaiana.py | 35 ---------------------- openplotterMaiana/openplotterMaianaRead.py | 4 ++- openplotterMaiana/startup.py | 4 +-- 5 files changed, 6 insertions(+), 48 deletions(-) diff --git a/debian/control b/debian/control index 2c3ed63..c764f48 100644 --- a/debian/control +++ b/debian/control @@ -10,6 +10,6 @@ X-Python3-Version: >= 3.2 Package: openplotter-maiana Architecture: all Multi-Arch: foreign -Depends: ${misc:Depends}, ${python3:Depends}, openplotter-settings, openplotter-signalk-installer, python3-serial, python3-websocket +Depends: ${misc:Depends}, ${python3:Depends}, openplotter-settings, openplotter-signalk-installer, python3-serial Description: OpenPlotter integration of the MAIANA open source AIS transponder OpenPlotter integration of the MAIANA open source AIS transponder diff --git a/openplotterMaiana/maianaPostInstall.py b/openplotterMaiana/maianaPostInstall.py index 0a9130c..423412d 100755 --- a/openplotterMaiana/maianaPostInstall.py +++ b/openplotterMaiana/maianaPostInstall.py @@ -56,15 +56,6 @@ def main(): print(_('DONE')) except Exception as e: print(_('FAILED: ')+str(e)) - print(_('Checking access to Signal K server...')) - try: - from openplotterSignalkInstaller import connections - skConnections = connections.Connections('MAIANA') - result = skConnections.checkConnection() - if result[1]: print(result[1]) - else: print(_('DONE')) - except Exception as e: print(_('FAILED: ')+str(e)) - print(_('Setting version...')) try: conf2.set('APPS', 'maiana', version) diff --git a/openplotterMaiana/openplotterMaiana.py b/openplotterMaiana/openplotterMaiana.py index 5acf2aa..1ad69fc 100644 --- a/openplotterMaiana/openplotterMaiana.py +++ b/openplotterMaiana/openplotterMaiana.py @@ -20,7 +20,6 @@ import wx.richtext as rt from openplotterSettings import conf from openplotterSettings import language from openplotterSettings import platform -from openplotterSignalkInstaller import connections from .version import version class MyFrame(wx.Frame): @@ -53,11 +52,6 @@ class MyFrame(wx.Frame): toolSettings = self.toolbar1.AddTool(102, _('Settings'), wx.Bitmap(self.currentdir+"/data/settings.png")) self.Bind(wx.EVT_TOOL, self.OnToolSettings, toolSettings) self.toolbar1.AddSeparator() - aproveSK = self.toolbar1.AddTool(105, _('Approve'), wx.Bitmap(self.currentdir+"/data/sk.png")) - self.Bind(wx.EVT_TOOL, self.onAproveSK, aproveSK) - connectionSK = self.toolbar1.AddTool(106, _('Reconnect'), wx.Bitmap(self.currentdir+"/data/sk.png")) - self.Bind(wx.EVT_TOOL, self.onConnectionSK, connectionSK) - self.toolbar1.AddSeparator() self.connInit = _('MAIANA Signal K connection') self.SKconn = wx.ComboBox(self.toolbar1, 103, self.connInit, choices=[], size=(250,-1), style=wx.CB_DROPDOWN) toolSKconn = self.toolbar1.AddControl(self.SKconn) @@ -122,16 +116,6 @@ class MyFrame(wx.Frame): subprocess.call(['pkill', '-f', 'openplotter-settings']) subprocess.Popen('openplotter-settings') - def onAproveSK(self,e): - if self.platform.skPort: - url = self.platform.http+'localhost:'+self.platform.skPort+'/admin/#/security/access/requests' - webbrowser.open(url, new=2) - - def onConnectionSK(self,e): - self.conf.set('MAIANA', 'href', '') - self.conf.set('MAIANA', 'token', '') - self.onRead() - def onShowSK(self, event): if self.platform.skPort: url = self.platform.http+'localhost:'+self.platform.skPort+'/admin/#/serverConfiguration/connections/-' @@ -155,7 +139,6 @@ class MyFrame(wx.Frame): self.logger.Clear() self.logger2.Clear() self.device = self.conf.get('MAIANA', 'device') - self.toolbar1.EnableTool(105,False) self.toolbar2.EnableTool(202,False) self.toolbar3.EnableTool(302,False) self.toolbar3.EnableTool(303,False) @@ -166,24 +149,6 @@ class MyFrame(wx.Frame): selected = '' self.tx = False - skConnections = connections.Connections('MAIANA') - result = skConnections.checkConnection() - if result[0] == 'pending': - self.toolbar1.EnableTool(105,True) - self.ShowStatusBarYELLOW(result[1]+_(' Press "Approve" and then "Refresh".')) - return - elif result[0] == 'error': - self.ShowStatusBarRED(result[1]+_(' Try "Reconnect".')) - return - elif result[0] == 'repeat': - self.ShowStatusBarYELLOW(result[1]+_(' Press "Refresh".')) - return - elif result[0] == 'permissions': - self.ShowStatusBarYELLOW(result[1]) - return - elif result[0] == 'approved': - self.ShowStatusBarGREEN(result[1]) - try: setting_file = self.platform.skDir+'/settings.json' with open(setting_file) as data_file: diff --git a/openplotterMaiana/openplotterMaianaRead.py b/openplotterMaiana/openplotterMaianaRead.py index 47a6000..edafb66 100644 --- a/openplotterMaiana/openplotterMaianaRead.py +++ b/openplotterMaiana/openplotterMaianaRead.py @@ -20,6 +20,7 @@ from openplotterSettings import conf from openplotterSettings import platform from openplotterSettings import language from websocket import create_connection +from openplotterSignalkInstaller import connections def main(): platform2 = platform.Platform() @@ -28,7 +29,8 @@ def main(): currentLanguage = conf2.get('GENERAL', 'lang') package = 'openplotter-maiana' language.Language(currentdir, package, currentLanguage) - token = conf2.get('MAIANA', 'token') + skConnections = connections.Connections('MAIANA') + token = skConnections.token device = conf2.get('MAIANA', 'device') if conf2.get('GENERAL', 'debug') == 'yes': debug = True else: debug = False diff --git a/openplotterMaiana/startup.py b/openplotterMaiana/startup.py index 1bfbfbc..38418ff 100644 --- a/openplotterMaiana/startup.py +++ b/openplotterMaiana/startup.py @@ -149,10 +149,10 @@ class Check(): #access skConnections = connections.Connections('MAIANA') result = skConnections.checkConnection() - if result[0] == 'pending' or result[0] == 'error' or result[0] == 'repeat' or result[0] == 'permissions': + if result[0] =='error': if not red: red = result[1] else: red+= '\n '+result[1] - if result[0] == 'approved' or result[0] == 'validated': + if result[0] =='validated': msg = _('Access to Signal K server validated') if not black: black = msg else: black+= ' | '+msg