From 2b4147f03fbe9c9e8f18f85883665bde06dfd37d Mon Sep 17 00:00:00 2001 From: e-sailing Date: Wed, 25 Mar 2020 21:57:16 +0100 Subject: [PATCH 1/5] mistake in systemd --- openplotterKplex/add_kplex.py | 8 ++++---- openplotterKplex/kplexPostInstall.py | 2 +- openplotterKplex/openplotterKplex.py | 15 +++++++++------ 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/openplotterKplex/add_kplex.py b/openplotterKplex/add_kplex.py index a2448a2..06f2d4c 100644 --- a/openplotterKplex/add_kplex.py +++ b/openplotterKplex/add_kplex.py @@ -586,7 +586,7 @@ def ok_conn(self, event): if str(self.kplex_device_select.GetValue()) != 'none': port_address = str(self.kplex_device_select.GetValue()) else: - self.ShowMessage(_('You must select a Port.')) + self.ShowMessage(_('You must select a port.')) return bauds_port = str(self.kplex_baud_select.GetValue()) for index, sublist in enumerate(self.extkplex): @@ -600,16 +600,16 @@ def ok_conn(self, event): if self.kplex_address.GetValue(): port_address = self.kplex_address.GetValue() else: - self.ShowMessage(_('You must enter an Address.')) + self.ShowMessage(_('You must enter an address.')) return if self.kplex_netport.GetValue(): bauds_port = self.kplex_netport.GetValue() else: - self.ShowMessage(_('You must enter a Port.')) + self.ShowMessage(_('You must enter a port.')) return if bauds_port >= '10111' and bauds_port <= '10113' and type_conn == 'TCP': - self.ShowMessage(_('Cancelled. Port 10111-10113 are reserved.')) + self.ShowMessage(_('Cancelled. Ports 10111-10113 are reserved.')) return new_address_port = str(type_conn) + str(port_address) + str(bauds_port) diff --git a/openplotterKplex/kplexPostInstall.py b/openplotterKplex/kplexPostInstall.py index b8aa4e0..af70233 100644 --- a/openplotterKplex/kplexPostInstall.py +++ b/openplotterKplex/kplexPostInstall.py @@ -36,7 +36,7 @@ def main(): '[Service]\n'+ 'Type=forking\n'+ 'PIDFILE=/var/run/kplex.pid\n'+ - 'ExecStart=/usr/bin/kplex -p /var/run/kplex.pid -o mode=background\n'+ + 'ExecStart=/usr/bin/kplex -f ' + conf2.home + '/.kplex.conf -p /var/run/kplex.pid -o mode=background\n'+ 'KillMode=process\n'+ '[Install]\n'+ 'WantedBy=multi-user.target\n' diff --git a/openplotterKplex/openplotterKplex.py b/openplotterKplex/openplotterKplex.py index 3ac0b00..cec182b 100644 --- a/openplotterKplex/openplotterKplex.py +++ b/openplotterKplex/openplotterKplex.py @@ -44,6 +44,7 @@ def __init__(self): self.currentdir = os.path.dirname(os.path.abspath(__file__)) self.currentLanguage = self.conf.get('GENERAL', 'lang') self.language = language.Language(self.currentdir,'openplotter-kplex',self.currentLanguage) + self.diagnostic = False self.selected = -1 @@ -141,8 +142,12 @@ def OnRestart(self, event=0): #self.ShowStatusBarRED(_('Closing Kplex')) print(_('Closing Kplex')) self.notebook.Update() + if self.diagnostic: + subprocess.call(['pkill', '-f', 'diagnostic-NMEA.py']) + subprocess.call(['pkill', '-f', 'kplex']) + time.sleep(1) + self.diagnostic = False command = self.platform.admin+' python3 ' + self.currentdir + '/service.py restart' - #subprocess.Popen([self.platform.admin, 'python3', self.currentdir+'/service.py', 'restart'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True, shell=True)) popen = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True, shell=True) time.sleep(5) command = self.platform.admin+' python3 ' + self.currentdir + '/service.py status' @@ -155,11 +160,6 @@ def OnRestart(self, event=0): if 'active (running)' in line: print(_('Kplex running')) - #subprocess.Popen([self.platform.admin, 'python3', self.currentdir+'/service.py', 'restart'],stdout=sys.stdout, stderr=sys.stderr, universal_newlines=True, shell=True) - #subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True, shell=True) - #popen = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True, shell=True) - - #self.ShowStatusBarGREEN(_('Kplex restarted')) if err: print(_("Error: Can't restart Kplex")) else: @@ -416,6 +416,7 @@ def OnApply(self, event): file = open(self.home + '/.kplex.conf', 'w') file.write(data) file.close() + time.sleep(1) self.OnRestart() self.read_kplex_conf() @@ -457,6 +458,8 @@ def OnShowButton(self, event): file.close() self.stop_kplex() + self.diagnostic = True + time.sleep(0.2) subprocess.Popen(['kplex', '-f', self.home + '/.debugkplex.conf']) time.sleep(0.5) From fb67cc760eb66c02c1f03decb4f5accec1e8f648 Mon Sep 17 00:00:00 2001 From: e-sailing Date: Fri, 27 Mar 2020 21:07:26 +0100 Subject: [PATCH 2/5] integrated systemd --- openplotterKplex/openplotterKplex.py | 100 ++++++++++++++++++++++++++- 1 file changed, 97 insertions(+), 3 deletions(-) diff --git a/openplotterKplex/openplotterKplex.py b/openplotterKplex/openplotterKplex.py index cec182b..0db26f9 100644 --- a/openplotterKplex/openplotterKplex.py +++ b/openplotterKplex/openplotterKplex.py @@ -35,6 +35,11 @@ def __init__(self, parent, height): CheckListCtrlMixin.__init__(self) ListCtrlAutoWidthMixin.__init__(self) +class CheckListCtrl(wx.ListCtrl, CheckListCtrlMixin, ListCtrlAutoWidthMixin): + def __init__(self, parent, height): + wx.ListCtrl.__init__(self, parent, -1, style=wx.LC_REPORT | wx.SUNKEN_BORDER, size=(650, height)) + CheckListCtrlMixin.__init__(self) + ListCtrlAutoWidthMixin.__init__(self) class KplexFrame(wx.Frame): def __init__(self): @@ -82,22 +87,26 @@ def __init__(self): self.notebook = wx.Notebook(self) self.notebook.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, self.onTabChange) self.p_kplex = wx.Panel(self.notebook) + self.systemd = wx.Panel(self.notebook) self.output = wx.Panel(self.notebook) self.notebook.AddPage(self.p_kplex, _('Devices')) + self.notebook.AddPage(self.systemd, _('Process status')) self.notebook.AddPage(self.output, '') self.il = wx.ImageList(24, 24) img0 = self.il.Add(wx.Bitmap(self.currentdir+"/data/kplex.png", wx.BITMAP_TYPE_PNG)) img1 = self.il.Add(wx.Bitmap(self.currentdir+"/data/output.png", wx.BITMAP_TYPE_PNG)) self.notebook.AssignImageList(self.il) self.notebook.SetPageImage(0, img0) - self.notebook.SetPageImage(1, img1) - + self.notebook.SetPageImage(1, img0) + self.notebook.SetPageImage(2, img1) + vbox = wx.BoxSizer(wx.VERTICAL) vbox.Add(self.toolbar1, 0, wx.EXPAND) vbox.Add(self.notebook, 1, wx.EXPAND) self.SetSizer(vbox) self.pageKplex() + self.pageSystemd() self.pageOutput() self.read_kplex_conf() @@ -126,6 +135,16 @@ def onTabChange(self, event): try: self.SetStatusText('') except: pass + + tab = self.notebook.GetSelection() + if tab == 0: + self.toolbar1.EnableTool(105,True) + self.toolbar1.EnableTool(106,True) + self.toolbar1.EnableTool(107,True) + else: + self.toolbar1.EnableTool(105,False) + self.toolbar1.EnableTool(106,False) + self.toolbar1.EnableTool(107,False) def OnToolHelp(self, event): url = "/usr/share/openplotter-doc/kplex/kplex_app.html" @@ -136,7 +155,7 @@ def OnToolSettings(self, event=0): subprocess.Popen('openplotter-settings') def OnRestart(self, event=0): - self.notebook.ChangeSelection(1) + self.notebook.ChangeSelection(2) self.logger.Clear() err = False #self.ShowStatusBarRED(_('Closing Kplex')) @@ -491,6 +510,81 @@ def ShowMessage(self, w_msg): def write(self, string): wx.CallAfter(self.logger.WriteText, string) +################################################################################ + + def pageSystemd(self): + self.started = False + self.process = ['openplotter-kplex'] + self.aStatusList = [_('inactive'),_('active')] + self.bStatusList = [_('dead'),_('running')] + + self.listSystemd = CheckListCtrl(self.systemd, 152) + self.listSystemd.InsertColumn(0, _('Autostart'), width=90) + self.listSystemd.InsertColumn(1, _('Process'), width=150) + self.listSystemd.InsertColumn(2, _('Status'), width=150) + self.listSystemd.InsertColumn(3, ' ', width=150) + + self.listSystemd.OnCheckItem = self.OnCheckItem + + self.toolbar3 = wx.ToolBar(self.systemd, style=wx.TB_TEXT | wx.TB_VERTICAL) + self.start = self.toolbar3.AddTool(301, _('Start'), wx.Bitmap(self.currentdir+"/data/start.png")) + self.Bind(wx.EVT_TOOL, self.onStart, self.start) + self.stop = self.toolbar3.AddTool(302, _('Stop'), wx.Bitmap(self.currentdir+"/data/stop.png")) + self.Bind(wx.EVT_TOOL, self.onStop, self.stop) + self.restart = self.toolbar3.AddTool(303, _('Restart'), wx.Bitmap(self.currentdir+"/data/restart.png")) + self.Bind(wx.EVT_TOOL, self.onRestart, self.restart) + + sizer = wx.BoxSizer(wx.HORIZONTAL) + sizer.Add(self.listSystemd, 1, wx.EXPAND, 0) + sizer.Add(self.toolbar3, 0) + + self.systemd.SetSizer(sizer) + + self.set_listSystemd() + self.started = True + + def set_listSystemd(self): + self.listSystemd.DeleteAllItems() + index = 1 + for i in self.process: + if i: + index = self.listSystemd.InsertItem(sys.maxsize, '') + self.statusUpdate(i,index) + + def statusUpdate(self, process, index): + command = 'systemctl show ' + process + ' --no-page' + output = subprocess.check_output(command.split(),universal_newlines=True) + if 'UnitFileState=enabled' in output: self.listSystemd.CheckItem(index) + self.listSystemd.SetItem(index, 1, process) + self.listSystemd.SetItem(index, 2, self.aStatusList[('ActiveState=active' in output)*1]) + self.listSystemd.SetItem(index, 3, self.bStatusList[('SubState=running' in output)*1]) + + def onStart(self,e): + index = self.listSystemd.GetFirstSelected() + if index == -1: return + subprocess.call((self.platform.admin + ' systemctl start ' + self.process[index]).split()) + self.set_listSystemd() + + def onStop(self,e): + index = self.listSystemd.GetFirstSelected() + if index == -1: return + subprocess.call((self.platform.admin + ' systemctl stop ' + self.process[index]).split()) + self.set_listSystemd() + + def onRestart(self,e): + index = self.listSystemd.GetFirstSelected() + if index == -1: return + subprocess.call((self.platform.admin + ' systemctl restart ' + self.process[index]).split()) + self.set_listSystemd() + + def OnCheckItem(self, index, flag): + if not self.started: return + if flag: + subprocess.call((self.platform.admin + ' systemctl enable ' + self.process[index]).split()) + else: + subprocess.call((self.platform.admin + ' systemctl disable ' + self.process[index]).split()) + #self.set_listSystemd() + ################################################################################ def pageOutput(self): From f47bed72aee970f712de953dd11a2a7ee2ebf96a Mon Sep 17 00:00:00 2001 From: e-sailing Date: Fri, 27 Mar 2020 21:46:14 +0100 Subject: [PATCH 3/5] added icons --- openplotterKplex/data/restart.png | Bin 0 -> 1736 bytes openplotterKplex/data/start.png | Bin 0 -> 1006 bytes openplotterKplex/data/stop.png | Bin 0 -> 827 bytes openplotterKplex/openplotterKplex.py | 8 +------- 4 files changed, 1 insertion(+), 7 deletions(-) create mode 100644 openplotterKplex/data/restart.png create mode 100644 openplotterKplex/data/start.png create mode 100644 openplotterKplex/data/stop.png diff --git a/openplotterKplex/data/restart.png b/openplotterKplex/data/restart.png new file mode 100644 index 0000000000000000000000000000000000000000..d2e4a71d3fa9468610faabe7f5a3a13b321d76cb GIT binary patch literal 1736 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE3?yBabR7dyEa{HEjtmSN`?>!lvI6;x#X;^) z4C~IxyacIC_6YK2V5m}KU}$JzVE6?TYIwoGP-?)y@G60U!D5bE1WtSD_3RwB#-`{7; zd@Sy)GFtO(LuIO;e_GAvS6{X5e;r_ny;rMi&~S4ybI!-#i*>Y?e5vCpociA6PgZ8& z_uEx!NeT%}bEC_fn&&6)c6N1fOYHeMQOZN?`9d#!-bD}OT5n9-vu?I1U)#&o#(FWA zuV#GO))^MkzUAR#RR^Weilx;m!VcYuK*upAdAqwzn#S^80m$Jj@Q5sCV6f%`Va7At z7B&MF9QJf^46!(!oZ!IN<8!8mX9okfwzM_7y0|&NzP$YeZ3T^%MPU&xAwD&aTsS*B zg^#K(T{2T5CFSXiiBF!2il}#KYOY?fYGrmtmhY8mmo8qtoZjRuEg|J=Vq})s_<_ae zY>(QkXa&s;TQ+UmxYc>vg?o-mtf8mu8>60ojExRj8Hv}?0DsT{ z0V6}k=}in1M0q-erxt2<%#h$y;hj9GaEXza>IU=Rpvwgk36u0X&G{M*PDpIsvsgKnHIod)n^K1#hk&6x42bwD{aQ5rxbPcQ3zwbs_x5ePc%d z9}!WDI2jneWW-DD`mhdE7O9rFMwFx^mZVxG7o`Fz1|tJQOI-saT_eK~LqjW5b1MTg zZ39Cq1A|LF$L&!xU0q(r8M`3_KtB$5)}%-qzH%7Rn|u&eY7^3v@$h54bG;~N50#b9V^YG7_+W(G{t zA@<2YCBjJN1ZP$ORT$|RdOJC#OY&R?O6MX;hX#2vq-Ex$0)s$LzqBAHKQX0P-_%Us z)ZZmMAgEB^(8AD2-^9q!*u=zKH?gQFzg!oj225n;rRx@@rWK_YX8>uiFpyo6SX820 hT$z^~Z)j+0Vq~lbbb8IZuy~-w44$rjF6*2UngE9N(XIdh literal 0 HcmV?d00001 diff --git a/openplotterKplex/data/start.png b/openplotterKplex/data/start.png new file mode 100644 index 0000000000000000000000000000000000000000..c8dfa346986ed1484267e09f8e26f5f165bdc974 GIT binary patch literal 1006 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE3?yBabR7dyEa{HEjtmSN`?>!lvI6;x#X;^) z4C~IxyacIC_6YK2V5m}KU}$JzVE6?TYIwoGP-?)y@G60U!D&Blv5tFWaYuhK!G!r2nPx z{hrHlCcegCwX387Yd6OGI(r$-OHq)@5L8za@RtJ4BzcsA>Ze1J0V|k;)>19SydA8 zZvx))+iv~!&m+R=pSsldM~8EEr`fZM25w|#{|9t}YKdz^NlIc#s#S7PDv)9@GB7mP zH89dOFby#>v@*7^GBDIOFtjo-*y;T?1w}({eoAIqC2kET#6oWXHMoInD9%qSDNig) zW$?^ROi%SqOwUZtRxr~u*R#;IQ~+9OrfXoPYiOnr2*epBB?VUc`sL;2dYK^AKnzr^ zmtU0rY`@7ipotP76GJjebCayBT=J7kb5rw5tgHfnN{bl`m;c|bkERA}r1-tF&>&BS zw9K4TU=Zl(mlovYC#DqZCnpx=4R-Du`o3@(#)V$Vsf!El4aaPSs7$&nqd)&(TfK*G()c$}f+%FfcK-&;vT$Y+C4lptTI1u6{1- HoD!M%$@_bs=g+&4h)0@T z`&|Ig932QHQQdZJbKpC)d~Fk@Q3=EX0QawN|0z20yTM3Cg0S+k^RrD#1IZY`+(CfK zRe&G(tMUoJq5-~40tib0ZTju?;iK5-OPoxFQUBwq)oL5hW+|N9Z6@O*uur*s>0;dZ zwSQ60rqy$Ur#9bvu-Py*6bbE_-^kk$P5QtY1NFIG4bzU+DjtqSLxB|kLYi!M_Ec^x z+;X;zzkS2B-g6yrw8VEf&-S<)*P0H0=oszqb}j{CbhW+weODz7p7jWiJ6PS>b*T65 zJQ{VI;c+t~nzA4jWfWj(#!t{JL31gV5j=i@^Y+q=K-0;kn@9c_C}rF|1mklLW93X!7bvP!Dv_#9VkiTG6f+gt4huUj$t3aN(>{@ zR_F7ZIjv^QoQ-r|aJ)mLqYjCw1=%d?GHl(7(r1+8)v@?rKCu*1z<7C|hxOBb@2bQ; zL1b^8&xksQYbLqAp Date: Fri, 29 May 2020 21:00:22 +0200 Subject: [PATCH 4/5] fix + changed to new process theme --- debian/changelog | 8 ++ openplotterKplex/data/process.png | Bin 0 -> 1041 bytes openplotterKplex/data/restart.png | Bin 1736 -> 1186 bytes openplotterKplex/data/start.png | Bin 1006 -> 1036 bytes openplotterKplex/data/stop.png | Bin 827 -> 970 bytes openplotterKplex/openplotterKplex.py | 148 ++++++++++++++++++++------- openplotterKplex/version.py | 6 +- 7 files changed, 120 insertions(+), 42 deletions(-) create mode 100644 openplotterKplex/data/process.png diff --git a/debian/changelog b/debian/changelog index c637b76..041fe3b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +openplotter-kplex (2.0.1-beta) bionic; urgency=medium + + * Beta release + * add process tab + * fix start kplex + + -- e-sailing Fri, 29 May 2020 18:59:22 +0100 + openplotter-kplex (2.0.0-dev) bionic; urgency=medium * Development release diff --git a/openplotterKplex/data/process.png b/openplotterKplex/data/process.png new file mode 100644 index 0000000000000000000000000000000000000000..54db51b338d703ca3ff285acbabee1c5dd6d6a14 GIT binary patch literal 1041 zcmV+s1n&EZP)GHjoN!?2F$G zts6vr5GjJbNUfC?rP@kS8U*_wLaiWmiLF9Ged&`ADs7cYsz{-&U=7r2YD=Rg#$=_t z>)w0!-kI?st_`}^rjVY;b7p>L&dm9rA!7`#r^&|g^^Y)Fv-0jwM;8+uj}EQX(Csp= z*AH=~Q2Tal{6sTojFD`3&+6Nj9bO3Rn=|K!H0d2g6gPc+jmDs~ZC^^q8>Xl{IndvG zaQ+6stN^f}1b|t=hWD&qdF4RSwAiGzX_xleBd;wC0t}Y?=UGtY^UdyiS6gches%x= zxK&UwDwe*pJ-&m}XQJqtc2+NnKPd`2}C8Pg2r(vO8=2=r{Cp z^(fw*wk#!D~?Pm(O3H8Nb8k1rme$a440X`lqI0G0t@+i z7-JZOfPgOT005r7rUZ@DQV}lvHVI~i*Oo)tcCe%^<=Ikr0A?(MHjRE#?h+RpXmTz!!?ED=B z(|3D+?>|$sSn>%OB0lgez`u`Q`LuePRX(XsWLG;zC(!`g1n6l!P2 z#vf}24b6R-3xxsny(Ycm^w{{erl(J-L1_!0!qIit_0vxj+G5#XN<4PF#NKQW00000 LNkvXXu0mjfs^Z`6 literal 0 HcmV?d00001 diff --git a/openplotterKplex/data/restart.png b/openplotterKplex/data/restart.png index d2e4a71d3fa9468610faabe7f5a3a13b321d76cb..8a994339f552a20a16844d805ca9af5746fb11bf 100644 GIT binary patch literal 1186 zcmV;T1YP@yP)Ey`fq)9(QGwE@Wjb_b+V8vf zxcFMW=?nC~xyd=_{?0w;-rOVHMEdilDLAbIo&=c&Iw|tVWzdTtd(mKztk`*JG=_`_ zKK#l=0=EUx7XUAg?hjWj4R^q9toN3z`uO546KKPxHK3mZm6$R}-wl;hAz1}}Dhdh< z(AxpICdgd?7Xai?Hpq${-;J6;e|qUPgbx8jW)_TF6hlW-n1_yIko_yFM&xyQ=#%Zk z67-*ZH+Y7crI49*bMR1Q&p^vzz&ez*1CaIPn!(@p4kdil9~12;ceHz>0n#to`K5KIP)%m^gqS(7~f<1`r$nfLO9m~-93Zt z^^MRM!p28o>iF1hi*WucaDm0@G#_OR;E|p&9R5QieA$3@X3;PlXpCkvG@J@ByW# zMwc$~gby+kfaJJ1Am0nS4xv7n9h;&0Hik-;+y}E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$5)}%-qzH%7Rn|u&eY7^3v@$h54bG;~N50#b9V^YG7_+W(G{t zA@<2YCBjJN1ZP$ORT$|RdOJC#OY&R?O6MX;hX#2vq-Ex$0)s$LzqBAHKQX0P-_%Us z)ZZmMAgEB^(8AD2-^9q!*u=zKH?gQFzg!oj225n;rRx@@rWK_YX8>uiFpyo6SX820 hT$z^~Z)j+0Vq~lbbb8IZuy~-w44$rjF6*2UngE9N(XIdh diff --git a/openplotterKplex/data/start.png b/openplotterKplex/data/start.png index c8dfa346986ed1484267e09f8e26f5f165bdc974..eed37866fbf215d0fc4ba85ccca25d72221ed311 100644 GIT binary patch literal 1036 zcmV+n1oQieP)qU@*^bauid)SRqPpG@z z++Sr-u6z)TrgJ?cdmDq7#@rt;JqlQdu(i^O0+6pCU5-(|0&zMwK=OvmgP%7!1=Aw{ z^Jsgc+VIYl2EgbSfH=wC{|^U9USH`vfz!_esPa`DM|*~z?bUlO0&fq)>TbAmb#oJ2 zfbm1%e2bM88et1yNUW-Tpv3@=jlmnA!%H8)*-T>t6NN+%fI-u*5qBRDUd3kd+ax@5 z01h7qYwPP0WtLL+Yf#q#5bbDg0N@93coYWSgFnyK)j zonV$Em3*XFM2aP7)#w*@!Mc_8i?9VKW2@q`rmX?3lXu$eQpi zYKiS6KjTP!4}KQ%GawCqq$;*RAqD%s68?j}uY(2Dggk#c+g@>=o(^CSl zrEu6FP)Nf+$DuF{=8BJ0-_Ro!X7$J%-ntK)eHs&0v~|Ii>mbrzZq}7m8kB>=Ihg%1 ztlH*;*2G@5dFa`Td9{cBXZ>q2!9i^9X0!)h8|aqsIT1h#V12MTa2C9_Qz&nHWm}pW zoHzP%+wD02NnEfAu}Q?XgjvQ1Gly>d3S(YTn?L@p9^*e1H)=wlmGUqE0000!lvI6;x#X;^) z4C~IxyacIC_6YK2V5m}KU}$JzVE6?TYIwoGP-?)y@G60U!D&Blv5tFWaYuhK!G!r2nPx z{hrHlCcegCwX387Yd6OGI(r$-OHq)@5L8za@RtJ4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4h)0@T z`&|Ig932QHQQdZJbKpC)d~Fk@Q3=EX0QawN|0z20yTM3Cg0S+k^RrD#1IZY`+(CfK zRe&G(tMUoJq5-~40tib0ZTju?;iK5-OPoxFQUBwq)oL5hW+|N9Z6@O*uur*s>0;dZ zwSQ60rqy$Ur#9bvu-Py*6bbE_-^kk$P5QtY1NFIG4bzU+DjtqSLxB|kLYi!M_Ec^x z+;X;zzkS2B-g6yrw8VEf&-S<)*P0H0=oszqb}j{CbhW+weODz7p7jWiJ6PS>b*T65 zJQ{VI;c+t~nzA4jWfWj(#!t{JL31gV5j=i@^Y+q=K-0;kn@9c_C}rF|1mklLW93X!7bvP!Dv_#9VkiTG6f+gt4huUj$t3aN(>{@ zR_F7ZIjv^QoQ-r|aJ)mLqYjCw1=%d?GHl(7(r1+8)v@?rKCu*1z<7C|hxOBb@2bQ; zL1b^8&xksQYbLqAp= 0 + if not valid: return + self.toolbar3.EnableTool(301,True) + self.toolbar3.EnableTool(302,True) + self.toolbar3.EnableTool(303,True) + + def onListSystemdDeselected(self, event=0): + self.toolbar3.EnableTool(301,False) + self.toolbar3.EnableTool(302,False) + self.toolbar3.EnableTool(303,False) + + def OnRefreshButton(self, event=0): self.listSystemd.DeleteAllItems() - index = 1 - for i in self.process: - if i: - index = self.listSystemd.InsertItem(sys.maxsize, '') - self.statusUpdate(i,index) + self.started = False + self.set_listSystemd() + self.started = True + + def set_listSystemd(self): + apps = list(reversed(self.appsDict)) + for i in apps: + if i['service']: + for ii in i['service']: + index = self.listSystemd.InsertItem(sys.maxsize, '') + self.listSystemd.SetItem(index, 1, i['name']) + self.listSystemd.SetItem(index, 2, ii) + command = 'systemctl show '+ii+' --no-page' + output = subprocess.check_output(command.split(),universal_newlines=True) + if 'UnitFileState=enabled' in output: self.listSystemd.CheckItem(index) + self.statusUpdate() + + def statusUpdate(self): + listCount = range(self.listSystemd.GetItemCount()) + for i in listCount: + service = self.listSystemd.GetItemText(i, 2) + command = 'systemctl show '+service+' --no-page' + output = subprocess.check_output(command.split(),universal_newlines=True) + if 'ActiveState=active' in output: self.listSystemd.SetItem(i, 3, _('active')) + else: self.listSystemd.SetItem(i, 3, _('inactive')) + if 'SubState=running' in output: + self.listSystemd.SetItem(i, 4, _('running')) + self.listSystemd.SetItemBackgroundColour(i,(0,255,0)) + else: + self.listSystemd.SetItem(i, 4, _('dead')) + self.listSystemd.SetItemBackgroundColour(i,(-1,-1,-1)) - def statusUpdate(self, process, index): - command = 'systemctl show ' + process + ' --no-page' - output = subprocess.check_output(command.split(),universal_newlines=True) - if 'UnitFileState=enabled' in output: self.listSystemd.CheckItem(index) - self.listSystemd.SetItem(index, 1, process) - self.listSystemd.SetItem(index, 2, self.aStatusList[('ActiveState=active' in output)*1]) - self.listSystemd.SetItem(index, 3, self.bStatusList[('SubState=running' in output)*1]) def onStart(self,e): index = self.listSystemd.GetFirstSelected() if index == -1: return - subprocess.call((self.platform.admin + ' systemctl start ' + self.process[index]).split()) - self.set_listSystemd() + self.ShowStatusBarYELLOW(_('Starting process...')) + subprocess.call((self.platform.admin + ' systemctl start ' + self.listSystemd.GetItemText(index, 2)).split()) + time.sleep(1) + self.OnRefreshButton() + self.ShowStatusBarGREEN(_('Done')) def onStop(self,e): index = self.listSystemd.GetFirstSelected() if index == -1: return - subprocess.call((self.platform.admin + ' systemctl stop ' + self.process[index]).split()) - self.set_listSystemd() + self.ShowStatusBarYELLOW(_('Stopping process...')) + subprocess.call((self.platform.admin + ' systemctl stop ' + self.listSystemd.GetItemText(index, 2)).split()) + time.sleep(1) + self.OnRefreshButton() + self.ShowStatusBarGREEN(_('Done')) def onRestart(self,e): index = self.listSystemd.GetFirstSelected() if index == -1: return - subprocess.call((self.platform.admin + ' systemctl restart ' + self.process[index]).split()) - self.set_listSystemd() + self.ShowStatusBarYELLOW(_('Restarting process...')) + subprocess.call((self.platform.admin + ' systemctl restart ' + self.listSystemd.GetItemText(index, 2)).split()) + time.sleep(1) + self.OnRefreshButton() + self.ShowStatusBarGREEN(_('Done')) def OnCheckItem(self, index, flag): if not self.started: return + self.ShowStatusBarYELLOW(_('Enabling/Disabling process...')) if flag: - subprocess.call((self.platform.admin + ' systemctl enable ' + self.process[index]).split()) + subprocess.call((self.platform.admin + ' systemctl enable ' + self.listSystemd.GetItemText(index, 2)).split()) else: - subprocess.call((self.platform.admin + ' systemctl disable ' + self.process[index]).split()) - #self.set_listSystemd() + subprocess.call((self.platform.admin + ' systemctl disable ' + self.listSystemd.GetItemText(index, 2)).split()) + self.OnRefreshButton() + self.ShowStatusBarGREEN(_('Done')) ################################################################################ diff --git a/openplotterKplex/version.py b/openplotterKplex/version.py index a07b0e9..f2b9f05 100644 --- a/openplotterKplex/version.py +++ b/openplotterKplex/version.py @@ -1,3 +1,3 @@ -version = '2.0.0' -codeName = 'Open Arms' -state = 'dev' +version = '2.0.1' +codeName = 'Open Arms' +state = 'beta' From 21790baf3f90a845788bd582a029932e0223bcf5 Mon Sep 17 00:00:00 2001 From: e-sailing Date: Fri, 29 May 2020 21:34:20 +0200 Subject: [PATCH 5/5] fix --- openplotterKplex/openplotterKplex.py | 41 ++++------------------------ 1 file changed, 6 insertions(+), 35 deletions(-) diff --git a/openplotterKplex/openplotterKplex.py b/openplotterKplex/openplotterKplex.py index dd0d215..ee73d93 100644 --- a/openplotterKplex/openplotterKplex.py +++ b/openplotterKplex/openplotterKplex.py @@ -70,8 +70,6 @@ def __init__(self): opSerial = self.toolbar1.AddTool(104, _('OP Serial'), wx.Bitmap(self.currentdir+"/data/usb.png")) self.Bind(wx.EVT_TOOL, self.OnOpSerial, opSerial) #self.toolbar1.AddSeparator() - restart = self.toolbar1.AddTool(105, _('restart'), wx.Bitmap(self.currentdir+"/data/kplex.png")) - self.Bind(wx.EVT_TOOL, self.OnRestart, restart) advanced = self.toolbar1.AddTool(106, _('manual settings'), wx.Bitmap(self.currentdir+"/data/kplex.png")) self.Bind(wx.EVT_TOOL, self.OnAdvanced, advanced) self.toolbar1.AddSeparator() @@ -162,38 +160,6 @@ def OnToolSettings(self, event=0): subprocess.call(['pkill', '-f', 'openplotter-settings']) subprocess.Popen('openplotter-settings') - def OnRestart(self, event=0): - self.notebook.ChangeSelection(2) - self.logger.Clear() - err = False - #self.ShowStatusBarRED(_('Closing Kplex')) - print(_('Closing Kplex')) - self.notebook.Update() - if self.diagnostic: - subprocess.call(['pkill', '-f', 'diagnostic-NMEA.py']) - subprocess.call(['pkill', '-f', 'kplex']) - time.sleep(1) - self.diagnostic = False - command = self.platform.admin+' python3 ' + self.currentdir + '/service.py restart' - popen = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True, shell=True) - time.sleep(5) - command = self.platform.admin+' python3 ' + self.currentdir + '/service.py status' - popen = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True, shell=True) - for line in popen.stdout: - if 'openplotter kplex' in line: - print(line[:-1]) - err = True - self.logger.ShowPosition(self.logger.GetLastPosition()) - if 'active (running)' in line: - print(_('Kplex running')) - - if err: - print(_("Error: Can't restart Kplex")) - else: - print(_('Kplex restarted')) - - self.read_kplex_conf() - def OnSkConnections(self,e): if self.platform.skPort: url = self.platform.http+'localhost:'+self.platform.skPort+'/admin/#/serverConfiguration/connections/-' @@ -255,7 +221,8 @@ def pageKplex(self): self.onDeselected() def stop_kplex(self): - subprocess.Popen([self.platform.admin, 'python3', self.currentdir+'/service.py', 'stop']) + subprocess.Popen([self.platform.admin, 'pkill', '-f', 'diagnostic-NMEA.py']) + subprocess.Popen([self.platform.admin, 'pkill', '-f', 'debugkplex']) def OnEditButton(self, e): idx = self.selected @@ -616,6 +583,8 @@ def onStart(self,e): index = self.listSystemd.GetFirstSelected() if index == -1: return self.ShowStatusBarYELLOW(_('Starting process...')) + subprocess.Popen([self.platform.admin, 'pkill', '-f', 'diagnostic-NMEA.py']) + subprocess.Popen([self.platform.admin, 'pkill', '-f', 'debugkplex']) subprocess.call((self.platform.admin + ' systemctl start ' + self.listSystemd.GetItemText(index, 2)).split()) time.sleep(1) self.OnRefreshButton() @@ -634,6 +603,8 @@ def onRestart(self,e): index = self.listSystemd.GetFirstSelected() if index == -1: return self.ShowStatusBarYELLOW(_('Restarting process...')) + subprocess.Popen([self.platform.admin, 'pkill', '-f', 'diagnostic-NMEA.py']) + subprocess.Popen([self.platform.admin, 'pkill', '-f', 'debugkplex']) subprocess.call((self.platform.admin + ' systemctl restart ' + self.listSystemd.GetItemText(index, 2)).split()) time.sleep(1) self.OnRefreshButton()