forked from openplotter/openplotter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
openplotter
3540 lines (3138 loc) · 130 KB
/
openplotter
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/python
# This file is part of Openplotter.
# Copyright (C) 2015 by sailoog <https://github.com/sailoog/openplotter>
#
# Openplotter is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# any later version.
# Openplotter is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Openplotter. If not, see <http://www.gnu.org/licenses/>.
import ConfigParser, json, os, io, pyudev, re, requests, subprocess, sys, time, webbrowser, wx, wx.lib.scrolledpanel
from wx.lib.mixins.listctrl import CheckListCtrlMixin, ListCtrlAutoWidthMixin
try:
from classes.add_DS18B20 import addDS18B20
except:
print '1-Wire must be enabled in "Raspberry Pi Configuration->Interfaces->1-Wire"'
app = wx.App(False)
wx.Frame( None, title="OpenPlotter", size=(710, 460))
wx.MessageBox('1-Wire must be enabled in "Raspberry Pi Configuration->Interfaces->1-Wire"', 'Warning', wx.OK | wx.ICON_WARNING)
exit()
from classes.actions import Actions
from classes.add_MCP import addMCP
from classes.add_i2c import addI2c
from classes.edit_i2c import editI2c
from classes.add_USBinst import addUSBinst
from classes.add_action import addAction
from classes.add_gpio import addGPIO
from classes.add_kplex import addkplex
from classes.add_tool10 import addTool10
from classes.add_topic import addTopic
from classes.add_trigger import addTrigger
from classes.add_value_setting import addvaluesetting
from classes.add_deviation_setting import adddeviationsetting
from classes.check_vessel_self import checkVesselSelf
from classes.conf import Conf
from classes.language import Language
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=(565, height))
CheckListCtrlMixin.__init__(self)
ListCtrlAutoWidthMixin.__init__(self)
class CheckListCtrl2(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 MainFrame(wx.Frame):
def __init__(self):
self.conf = conf
self.home = conf.home
self.conf_folder = conf.conf_folder
self.currentpath = currentpath
wx.Frame.__init__(self, None, title="OpenPlotter", size=(710, 460))
if self.util_process_exist('startup.py'):
print "System not ready, try later."
sys.exit(0)
self.Bind(wx.EVT_CLOSE, self.when_closed)
self.SetFont(wx.Font(10, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL))
self.language = self.conf.get('GENERAL', 'lang')
self.vessel_self = checkVesselSelf(self.conf)
Language(self.conf)
self.p = wx.lib.scrolledpanel.ScrolledPanel(self, -1, style=wx.TAB_TRAVERSAL | wx.SUNKEN_BORDER)
self.p.SetAutoLayout(1)
self.p.SetupScrolling()
self.nb = wx.Notebook(self.p)
self.p_usb = wx.Panel(self.nb)
self.p_kplex = wx.Panel(self.nb)
self.p_n2k = wx.Panel(self.nb)
self.p_sk = wx.Panel(self.nb)
self.p_wifi = wx.Panel(self.nb)
self.p_compass = wx.Panel(self.nb)
self.p_action = wx.Panel(self.nb)
self.p_gpio = wx.Panel(self.nb)
self.p_i2c = wx.Panel(self.nb)
self.p_1w = wx.Panel(self.nb)
self.p_spi = wx.Panel(self.nb)
self.p_account = wx.Panel(self.nb)
self.p_mqtt = wx.Panel(self.nb)
self.p_sms = wx.Panel(self.nb)
self.p_startup = wx.Panel(self.nb)
self.nb.AddPage(self.p_usb, _('USB manager'))
self.nb.AddPage(self.p_kplex, 'NMEA 0183')
self.nb.AddPage(self.p_n2k, 'N2K')
self.nb.AddPage(self.p_sk, 'Signal K')
self.nb.AddPage(self.p_wifi, _('WiFi AP'))
self.nb.AddPage(self.p_compass, _('Compass'))
self.nb.AddPage(self.p_action, _('Actions'))
self.nb.AddPage(self.p_gpio, _('GPIO'))
self.nb.AddPage(self.p_i2c, _('I2C'))
self.nb.AddPage(self.p_1w, '1W')
self.nb.AddPage(self.p_spi, 'SPI')
self.nb.AddPage(self.p_mqtt, 'MQTT')
self.nb.AddPage(self.p_account, _('Accounts'))
self.nb.AddPage(self.p_sms, _('SMS'))
self.nb.AddPage(self.p_startup, _('Startup'))
sizer = wx.BoxSizer()
sizer.Add(self.nb, 1, wx.EXPAND)
self.p.SetSizer(sizer)
self.icon = wx.Icon(self.currentpath + '/openplotter.ico', wx.BITMAP_TYPE_ICO)
self.SetIcon(self.icon)
self.CreateStatusBar()
font_statusBar = self.GetStatusBar().GetFont()
font_statusBar.SetWeight(wx.BOLD)
self.GetStatusBar().SetFont(font_statusBar)
self.GetStatusBar().SetForegroundColour(wx.BLACK)
self.nb.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, self.Changingpage)
self.Centre()
########################### menu
self.menubar = wx.MenuBar()
self.settings = wx.Menu()
self.time_item1 = self.settings.Append(wx.ID_ANY, _('Set time zone'), _('Set time zone in the new window'))
self.Bind(wx.EVT_MENU, self.time_zone, self.time_item1)
self.time_item2 = self.settings.Append(wx.ID_ANY, _('Set time from NMEA'), _('Set system time from NMEA data'))
self.Bind(wx.EVT_MENU, self.time_gps, self.time_item2)
self.gpsd_item1 = self.settings.Append(wx.ID_ANY, _('Set GPSD'), _('Set GPSD in the new window'))
self.Bind(wx.EVT_MENU, self.reconfigure_gpsd, self.gpsd_item1)
self.settings.AppendSeparator()
self.sdr_ais_item1 = self.settings.Append(wx.ID_ANY, _('SDR receiver'),
_('Set an SDR receiver in the new window'))
self.Bind(wx.EVT_MENU, self.open_sdr_ais, self.sdr_ais_item1)
self.deviation_table = self.settings.Append(wx.ID_ANY, _('Deviation Table'),
_('Create a deviation table for your boat'))
self.Bind(wx.EVT_MENU, self.on_deviation_table, self.deviation_table)
self.calculate_item1 = self.settings.Append(wx.ID_ANY, _('Calculate'),
_('Calculate new data from current values'))
self.Bind(wx.EVT_MENU, self.open_calculate, self.calculate_item1)
self.nmea_0183_item1 = self.settings.Append(wx.ID_ANY, _('NMEA 0183 generator'),
_('Generate NMEA 0183 from current values'))
self.Bind(wx.EVT_MENU, self.open_nmea_0183, self.nmea_0183_item1)
self.nmea_2000_item1 = self.settings.Append(wx.ID_ANY, _('NMEA 2000 generator'),
_('Generate NMEA 2000 from current values'))
self.Bind(wx.EVT_MENU, self.open_nmea_2000, self.nmea_2000_item1)
self.settings.AppendSeparator()
self.tools_py = []
if self.conf.has_section('TOOLS'):
if self.conf.has_option('TOOLS', 'py'):
data = self.conf.get('TOOLS', 'py')
try:
temp_list = eval(data)
except:
temp_list = []
if type(temp_list) is list:
pass
else:
temp_list = []
for ii in temp_list:
self.tools_py.append(ii)
self.tool10_b = []
index = 0
for i in self.tools_py:
self.tool10_b.append(0)
self.tool10_b[index] = self.settings.Append(index, i[0], i[1])
self.Bind(wx.EVT_MENU, self.tool10, self.tool10_b[index])
index += 1
self.menubar.Append(self.settings, _('Tools'))
self.lang = wx.Menu()
self.lang_item8 = self.lang.Append(wx.ID_ANY, _('Basque'), _('Set Basque language'), kind=wx.ITEM_CHECK)
self.Bind(wx.EVT_MENU, self.lang_eu, self.lang_item8)
self.lang_item2 = self.lang.Append(wx.ID_ANY, _('Catalan'), _('Set Catalan language'), kind=wx.ITEM_CHECK)
self.Bind(wx.EVT_MENU, self.lang_ca, self.lang_item2)
self.lang_item5 = self.lang.Append(wx.ID_ANY, _('Dutch'), _('Set Dutch language'), kind=wx.ITEM_CHECK)
self.Bind(wx.EVT_MENU, self.lang_nl, self.lang_item5)
self.lang_item1 = self.lang.Append(wx.ID_ANY, _('English'), _('Set English language'), kind=wx.ITEM_CHECK)
self.Bind(wx.EVT_MENU, self.lang_en, self.lang_item1)
self.lang_item4 = self.lang.Append(wx.ID_ANY, _('French'), _('Set French language'), kind=wx.ITEM_CHECK)
self.Bind(wx.EVT_MENU, self.lang_fr, self.lang_item4)
self.lang_item9 = self.lang.Append(wx.ID_ANY, _('Galician'), _('Set Galician language'), kind=wx.ITEM_CHECK)
self.Bind(wx.EVT_MENU, self.lang_gl, self.lang_item9)
self.lang_item6 = self.lang.Append(wx.ID_ANY, _('German'), _('Set German language'), kind=wx.ITEM_CHECK)
self.Bind(wx.EVT_MENU, self.lang_de, self.lang_item6)
self.lang_item7 = self.lang.Append(wx.ID_ANY, _('Italiano'), _('Set Italian language'), kind=wx.ITEM_CHECK)
self.Bind(wx.EVT_MENU, self.lang_it, self.lang_item7)
self.lang_item3 = self.lang.Append(wx.ID_ANY, _('Spanish'), _('Set Spanish language'), kind=wx.ITEM_CHECK)
self.Bind(wx.EVT_MENU, self.lang_es, self.lang_item3)
self.menubar.Append(self.lang, _('Language'))
self.update = wx.Menu()
self.opencpn_item1 = self.update.Append(wx.ID_ANY, _('Update OpenCPN'), _('Update OpenCPN to latest stable release'))
self.Bind(wx.EVT_MENU, self.update_opencpn, self.opencpn_item1)
self.opencpn_item2 = self.update.Append(wx.ID_ANY, _('Update OpenCPN plugins'), _('Update OpenCPN plugins to latest stable releases'))
self.Bind(wx.EVT_MENU, self.update_opencpn_plugins, self.opencpn_item2)
self.update.AppendSeparator()
self.system_item2 = self.update.Append(wx.ID_ANY, _('Set default OpenPlotter desktop'), _('Run this after a major update'))
self.Bind(wx.EVT_MENU, self.default_desktop, self.system_item2)
self.update.AppendSeparator()
self.openplotter_item1 = self.update.Append(wx.ID_ANY, _('Update OpenPlotter'), _('Apply latest changes'))
self.Bind(wx.EVT_MENU, self.update_openplotter, self.openplotter_item1)
self.menubar.Append(self.update, _('Updates'))
self.helpm = wx.Menu()
self.helpm_item1 = self.helpm.Append(wx.ID_ANY, _('&About'), _('About OpenPlotter'))
self.Bind(wx.EVT_MENU, self.OnAboutBox, self.helpm_item1)
self.helpm_item2 = self.helpm.Append(wx.ID_ANY, _('OpenPlotter online documentation'),
_('OpenPlotter online documentation'))
self.Bind(wx.EVT_MENU, self.op_doc, self.helpm_item2)
self.helpm_item2 = self.helpm.Append(wx.ID_ANY, _('OpenPlotter offline documentation'),
_('OpenPlotter offline documentation'))
self.Bind(wx.EVT_MENU, self.op_doc_off, self.helpm_item2)
self.menubar.Append(self.helpm, _('&Help'))
self.SetMenuBar(self.menubar)
# ##########################menu
self.page_usb()
self.page_kplex()
self.page_n2k()
self.page_sk()
self.page_wifi()
self.page_compass()
self.page_action()
self.page_gpio()
self.page_i2c()
self.page_1w()
self.page_spi()
self.page_account()
self.page_mqtt()
self.page_sms()
self.page_startup()
self.manual_settings = ''
self.read_kplex_conf()
self.SerialCheck()
self.SerialWrongPort()
self.read_language()
self.read_account()
# self.read_sk()
self.read_sms()
self.read_startup()
self.read_wifi_conf()
self.read_triggers()
self.read_DS18B20()
self.read_USBinst()
self.read_gpio()
self.read_mqtt()
self.read_MCP()
self.read_i2c()
self.read_compass()
self.read_n2k()
self.read_triggers()
#self.when_closed(0x001)
########################################### general functions
def read_language(self):
if self.language == 'en': self.lang.Check(self.lang_item1.GetId(), True)
if self.language == 'ca': self.lang.Check(self.lang_item2.GetId(), True)
if self.language == 'es': self.lang.Check(self.lang_item3.GetId(), True)
if self.language == 'fr': self.lang.Check(self.lang_item4.GetId(), True)
if self.language == 'nl': self.lang.Check(self.lang_item5.GetId(), True)
if self.language == 'de': self.lang.Check(self.lang_item6.GetId(), True)
if self.language == 'it': self.lang.Check(self.lang_item7.GetId(), True)
if self.language == 'eu': self.lang.Check(self.lang_item8.GetId(), True)
if self.language == 'gl': self.lang.Check(self.lang_item9.GetId(), True)
def ShowMessage(self, w_msg):
wx.MessageBox(w_msg, 'Info', wx.OK | wx.ICON_INFORMATION)
def ShowStatusBar(self, w_msg, colour):
self.GetStatusBar().SetForegroundColour(colour)
self.SetStatusText(w_msg)
def ShowStatusBarRED(self, w_msg):
self.ShowStatusBar(w_msg, wx.RED)
def ShowStatusBarGREEN(self, w_msg):
self.ShowStatusBar(w_msg, wx.GREEN)
def ShowStatusBarBLACK(self, w_msg):
self.ShowStatusBar(w_msg, wx.BLACK)
def time_zone(self, event):
subprocess.Popen(['lxterminal', '-e', 'sudo dpkg-reconfigure tzdata'])
self.GetStatusBar().SetForegroundColour(wx.BLACK)
self.SetStatusText(_('Set time zone in the new window'))
def time_gps(self, event):
self.ShowStatusBarBLACK(_('Waiting for NMEA time...'))
time_gps_result = subprocess.check_output(['sudo', 'python', self.currentpath + '/time_gps.py'])
msg = ''
re = time_gps_result.splitlines()
for current in re:
msg+=current+' '
self.ShowStatusBarBLACK('')
self.ShowMessage(msg)
def reconfigure_gpsd(self, event):
subprocess.Popen(['lxterminal', '-e', 'sudo nano /etc/default/gpsd'])
self.ShowStatusBarBLACK(_('Set GPSD in the new window'))
def open_sdr_ais(self, event):
subprocess.call(['pkill', '-f', 'SDR_AIS.py'])
subprocess.Popen(['python', self.currentpath + '/tools/SDR_AIS.py'])
def on_deviation_table(self, e):
dlg = adddeviationsetting(self)
dlg.ShowModal()
dlg.Destroy()
def open_calculate(self, event):
subprocess.call(['pkill', '-f', 'calculate.py'])
subprocess.Popen(['python', self.currentpath + '/tools/calculate.py'])
def open_nmea_0183(self, event):
subprocess.call(['pkill', '-f', 'NMEA_0183_generator.py'])
subprocess.Popen(['python', self.currentpath + '/tools/NMEA_0183_generator.py'])
def open_nmea_2000(self, event):
subprocess.call(['pkill', '-f', 'NMEA_2000_generator.py'])
subprocess.Popen(['python', self.currentpath + '/tools/NMEA_2000_generator.py'])
def tool10(self, event):
menuId = event.Id
dlg = addTool10()
res = dlg.ShowModal()
res = dlg.ButtonNr
dlg.Destroy()
if res != 4:
if os.path.isfile(self.conf_folder + '/tools/' + self.tools_py[menuId][2]):
subprocess.call(['pkill', '-9', '-f', self.tools_py[menuId][2]])
if res == 2:
subprocess.Popen(['python', self.conf_folder + '/tools/' + self.tools_py[menuId][2]])
elif res == 1:
subprocess.Popen(['python', self.conf_folder + '/tools/' + self.tools_py[menuId][2], 'settings'])
else:
if os.path.isfile(self.currentpath + '/tools/' + self.tools_py[menuId][2]):
subprocess.call(['pkill', '-9', '-f', self.tools_py[menuId][2]])
if res == 2:
subprocess.Popen(['python', self.currentpath + '/tools/' + self.tools_py[menuId][2]])
elif res == 1:
subprocess.Popen(['python', self.currentpath + '/tools/' + self.tools_py[menuId][2], 'settings'])
else:
print 'file not found: ', self.tools_py[menuId][2]
def clear_lang(self):
self.lang.Check(self.lang_item1.GetId(), False)
self.lang.Check(self.lang_item2.GetId(), False)
self.lang.Check(self.lang_item3.GetId(), False)
self.lang.Check(self.lang_item4.GetId(), False)
self.lang.Check(self.lang_item5.GetId(), False)
self.lang.Check(self.lang_item6.GetId(), False)
self.lang.Check(self.lang_item7.GetId(), False)
self.lang.Check(self.lang_item8.GetId(), False)
self.lang.Check(self.lang_item9.GetId(), False)
self.ShowMessage(_('The selected language will be enabled when you restart'))
def lang_en(self, e):
self.clear_lang()
self.lang.Check(self.lang_item1.GetId(), True)
self.conf.set('GENERAL', 'lang', 'en')
def lang_ca(self, e):
self.clear_lang()
self.lang.Check(self.lang_item2.GetId(), True)
self.conf.set('GENERAL', 'lang', 'ca')
def lang_es(self, e):
self.clear_lang()
self.lang.Check(self.lang_item3.GetId(), True)
self.conf.set('GENERAL', 'lang', 'es')
def lang_fr(self, e):
self.clear_lang()
self.lang.Check(self.lang_item4.GetId(), True)
self.conf.set('GENERAL', 'lang', 'fr')
def lang_nl(self, e):
self.clear_lang()
self.lang.Check(self.lang_item5.GetId(), True)
self.conf.set('GENERAL', 'lang', 'nl')
def lang_de(self, e):
self.clear_lang()
self.lang.Check(self.lang_item6.GetId(), True)
self.conf.set('GENERAL', 'lang', 'de')
def lang_it(self, e):
self.clear_lang()
self.lang.Check(self.lang_item7.GetId(), True)
self.conf.set('GENERAL', 'lang', 'it')
def lang_eu(self, e):
self.clear_lang()
self.lang.Check(self.lang_item8.GetId(), True)
self.conf.set('GENERAL', 'lang', 'eu')
def lang_gl(self, e):
self.clear_lang()
self.lang.Check(self.lang_item9.GetId(), True)
self.conf.set('GENERAL', 'lang', 'gl')
def update_opencpn(self, e):
subprocess.Popen(['lxterminal', '-e', 'bash '+self.currentpath+ '/update/update_OpenCPN.sh'])
self.ShowStatusBarBLACK(_('Follow the instructions of the new window'))
def update_opencpn_plugins(self, e):
subprocess.Popen(['lxterminal', '-e', 'bash '+self.currentpath+ '/update/update_OpenCPN_plugins.sh'])
self.ShowStatusBarBLACK(_('Follow the instructions of the new window'))
def update_openplotter(self, e):
repository = self.conf.get('GENERAL', 'repository')
vl = self.conf.get('GENERAL', 'version')
sl = self.conf.get('GENERAL', 'state')
vl_list = vl.split('.')
local_xxx = int(vl_list[0])
local_oxx = int(vl_list[1])
local_oox = int(vl_list[2])
if not repository:
repository = 'openplotter'
self.conf.set('GENERAL', 'repository', repository)
try:
r_master = requests.get('https://raw.githubusercontent.com/'+repository+'/openplotter/master/openplotter.conf')
r_beta = requests.get('https://raw.githubusercontent.com/'+repository+'/openplotter/beta/openplotter.conf')
except:
self.ShowStatusBarRED(_('It was not possible to connect to Github.'))
return
try:
data_conf = ConfigParser.SafeConfigParser()
data_conf.readfp(io.StringIO(r_master.text))
vr = data_conf.get('GENERAL','version')
sr = data_conf.get('GENERAL','state')
vr_list = vr.split('.')
remote_xxx = int(vr_list[0])
remote_oxx = int(vr_list[1])
remote_oox = int(vr_list[2])
except:
self.ShowStatusBarRED(_('Error reading versions.'))
return
check_beta = True
if remote_xxx > local_xxx:
check_beta = False
elif remote_oxx > local_oxx:
check_beta = False
elif remote_oox > local_oox:
check_beta = False
if check_beta:
try:
data_conf = ConfigParser.SafeConfigParser()
data_conf.readfp(io.StringIO(r_beta.text))
vr = data_conf.get('GENERAL','version')
sr = data_conf.get('GENERAL','state')
vr_list = vr.split('.')
remote_xxx = int(vr_list[0])
remote_oxx = int(vr_list[1])
remote_oox = int(vr_list[2])
except:
self.ShowStatusBarRED(_('Error reading versions.'))
return
msg = ''
if sl == 'stable' and sr != 'stable':
msg += _('You are running a stable version. If you update to a non stable version you will have to keep updating until a stable stage is reached again.\n\n').decode('utf8')
if remote_xxx > local_xxx:
msg += _('There is a Raspbian upgrade, it is recommended to download the new OpenPlotter RPI image: v').decode('utf8')+str(remote_xxx)+'.x.x '+sr+'.\n'
self.ShowMessage(msg)
return
elif remote_oxx > local_oxx:
msg += _('There is a major OpenPlotter update.\n').decode('utf8')
msg += _('Please make a backup image of your system before updating.\n\n').decode('utf8')
major_update = '1'
elif remote_oox > local_oox:
msg += _('There is a minor OpenPlotter update.\n\n').decode('utf8')
major_update = '0'
else:
msg += 'OpenPlotter '+vl+' '+sl+_(' is up to date.\n').decode('utf8')
msg += _('You do not need to update but if you think something was wrong in your last update, you can force a major update.\n\n').decode('utf8')
sr = sl
major_update = '1'
msg += _('Are you sure you want to update: ').decode('utf8')+vl+' '+sl+' --> '+vr+' '+sr+'?'
dlg = wx.MessageDialog(None, msg, _('Question'), wx.YES_NO | wx.NO_DEFAULT | wx.ICON_EXCLAMATION)
if dlg.ShowModal() == wx.ID_YES:
subprocess.Popen(['lxterminal', '-e', 'bash '+self.currentpath+ '/update/update_OpenPlotter.sh', major_update, vr, sr, repository])
dlg.Destroy()
self.Close()
else: dlg.Destroy()
def default_desktop(self, e):
subprocess.Popen(['lxterminal', '-e', 'bash '+self.currentpath+ '/update/default_openplotter_desk.sh'])
self.ShowStatusBarBLACK(_('Follow the instructions of the new window'))
def OnAboutBox(self, e):
description = _(
"OpenPlotter is a DIY, open-source, low-cost, low-consumption, modular and scalable sailing platform to run on ARM boards.")
licence = """This program is free software: you can redistribute it
and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation, either version 2 of
the License, or any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see http://www.gnu.org/licenses/"""
info = wx.AboutDialogInfo()
info.SetName('OpenPlotter')
info.SetVersion(self.conf.get('GENERAL', 'version')+' '+self.conf.get('GENERAL', 'state'))
info.SetDescription(description)
info.SetCopyright('2017 Sailoog')
info.SetWebSite('http://www.sailoog.com')
info.SetLicence(licence)
info.AddDeveloper(
'Sailoog\nhttp://github.com/sailoog/openplotter\n-------------------\nOpenCPN: http://opencpn.org/ocpn/\nzyGrib: http://www.zygrib.org/\nMultiplexer: http://www.stripydog.com/kplex/index.html\nrtl-sdr: http://sdr.osmocom.org/trac/wiki/rtl-sdr\naisdecoder: http://www.aishub.net/aisdecoder-via-sound-card.html\ngeomag: http://github.com/cmweiss/geomag\nIMU sensor: http://github.com/richards-tech/RTIMULib2\nNMEA parser: http://github.com/Knio/pynmea2\ntwython: http://github.com/ryanmcgrath/twython\npyrtlsdr: http://github.com/roger-/pyrtlsdr\nkalibrate-rtl: http://github.com/steve-m/kalibrate-rtl\nSignalK: http://signalk.org/\n\n')
info.AddDocWriter('Sailoog\n\nDocumentation: http://sailoog.gitbooks.io/openplotter-documentation/')
info.AddTranslator('Catalan, English and Spanish by Sailoog\nFrench by Nicolas Janvier.')
wx.AboutBox(info)
def op_doc(self, e):
url = "http://sailoog.gitbooks.io/openplotter-documentation/"
webbrowser.open(url, new=2)
def op_doc_off(self, e):
subprocess.Popen(['xpdf', self.currentpath+'/docs/openplotter-documentation-en.pdf'])
def SerialWrongPort(self):
try:
self.context
except NameError:
self.context = pyudev.Context()
data = self.conf.get('UDEV', 'USBinst')
try:
temp_list = eval(data)
except:
temp_list = []
for ic in temp_list:
if ic[5] == 'port':
for device in self.context.list_devices(subsystem='usb'):
dp = ""
imi = ""
ivi = ""
imfd = ""
ivfd = ""
if 'DEVPATH' in device: dp = device['DEVPATH']
if dp.find(ic[4]) > 0:
if 'PRODUCT' in device:
pr = device['PRODUCT']
s = pr.split('/')
imi = s[1].zfill(4)
ivi = s[0].zfill(4)
if imi == ic[2] and ivi == ic[1]:
pass
else:
if 'ID_MODEL_FROM_DATABASE' in device: imfd = device['ID_MODEL_FROM_DATABASE']
if 'ID_VENDOR_FROM_DATABASE' in device: ivfd = device['ID_VENDOR_FROM_DATABASE']
self.ShowMessage(_('Warning: You have connected the "').decode('utf8') + ivfd + ', ' + imfd + _(
'" to the usb port which is reserved for another device').decode('utf8'))
def SerialCheck(self):
self.SerDevLs = []
self.SerDevLsCheck = []
self.context = pyudev.Context()
for device in self.context.list_devices(subsystem='tty'):
i = device['DEVNAME']
if '/dev/ttyU' in i or '/dev/ttyA' in i or '/dev/ttyS' in i or '/dev/ttyO' in i or '/dev/r' in i or '/dev/i' in i or '/dev/naviDev' in i:
self.SerDevLs.append(i)
try:
if 'DEVLINKS' in device:
ii = device['DEVLINKS']
value = ii[ii.rfind('/dev/ttyOP_'):]
if value.find('/dev/ttyOP_') >= 0:
self.SerDevLs.append(value.split(' ')[0])
except Exception, e:
print 'no tty DEVLINKS found', str(e)
try:
serial = device['ID_SERIAL_SHORT']
except:
serial = ''
try:
vendor_db = device['ID_VENDOR_ID']
except:
vendor_db = ''
try:
model_db = device['ID_MODEL_ID']
except:
model_db = ''
self.SerDevLsCheck.append(serial + ' ' + vendor_db + ' ' + model_db)
self.SerDevLs.sort()
self.SerDevLsCheck.sort()
self.can_usb.Clear()
self.sms_dev.Clear()
self.can_usb.AppendItems(self.SerDevLs)
self.sms_dev.AppendItems(self.SerDevLs)
bak = ''
for i in self.SerDevLsCheck:
if i == bak:
data = self.conf.get('UDEV', 'USBinst')
try:
temp_list = eval(data)
except:
temp_list = []
for ii in temp_list:
if bak == ii[3] + ' ' + ii[1] + ' ' + ii[2] and ii[5] == 'dev':
self.ShowMessage(_('Error: USB-Port with vendor product number: "'+ ii[1] + ' ' + ii[2] + ' ' + ii[3] + '" must be set to "Remember port"'))
bak = i
def Changingpage(self, e):
self.ShowStatusBarBLACK('')
def when_closed(self, e):
self.nb.Destroy()
sys.exit(0)
def util_process_exist(self, process_name):
pids = [pid for pid in os.listdir('/proc') if pid.isdigit()]
exist = False
for pid in pids:
try:
if process_name in open(os.path.join('/proc', pid, 'cmdline'), 'rb').read():
exist = True
except IOError: # proc has already terminated
continue
if exist:
break
return exist
########################################### startup
def page_startup(self):
wx.StaticBox(self.p_startup, size=(330, 50), pos=(10, 10))
wx.StaticText(self.p_startup, label=_('Delay (seconds)'), pos=(20, 30))
self.delay = wx.TextCtrl(self.p_startup, -1, size=(55, 32), pos=(170, 23))
button_ok_delay = wx.Button(self.p_startup, label=_('OK'), size=(70, 32), pos=(250, 23))
button_ok_delay.Bind(wx.EVT_BUTTON, self.on_ok_delay)
wx.StaticBox(self.p_startup, size=(330, 230), pos=(10, 65))
self.startup_opencpn = wx.CheckBox(self.p_startup, label='OpenCPN', pos=(20, 80))
self.startup_opencpn.Bind(wx.EVT_CHECKBOX, self.startup)
self.startup_opencpn_nopengl = wx.CheckBox(self.p_startup, label=_('no OpenGL'), pos=(40, 105))
self.startup_opencpn_nopengl.Bind(wx.EVT_CHECKBOX, self.startup)
self.startup_opencpn_fullscreen = wx.CheckBox(self.p_startup, label=_('fullscreen'), pos=(40, 130))
self.startup_opencpn_fullscreen.Bind(wx.EVT_CHECKBOX, self.startup)
self.startup_multiplexer = wx.CheckBox(self.p_startup, label=_('NMEA 0183 multiplexer'), pos=(20, 165))
self.startup_multiplexer.Bind(wx.EVT_CHECKBOX, self.startup)
self.startup_nmea_time = wx.CheckBox(self.p_startup, label=_('Set time from NMEA'), pos=(40, 190))
self.startup_nmea_time.Bind(wx.EVT_CHECKBOX, self.startup)
self.startup_remote_desktop = wx.CheckBox(self.p_startup, label=_('VNC remote desktop'), pos=(20, 225))
self.startup_remote_desktop.Bind(wx.EVT_CHECKBOX, self.startup)
self.startup_vnc_pass = wx.CheckBox(self.p_startup, label=_('use password'), pos=(40, 250))
self.startup_vnc_pass.Bind(wx.EVT_CHECKBOX, self.startup)
wx.StaticBox(self.p_startup, size=(330, 230), pos=(350, 65))
self.startup_play_sound = wx.CheckBox(self.p_startup, label=_('Play sound'), pos=(360, 80))
self.startup_play_sound.Bind(wx.EVT_CHECKBOX, self.startup)
self.startup_path_sound = wx.TextCtrl(self.p_startup, -1, size=(200, 32), pos=(360, 110))
self.button_select_sound = wx.Button(self.p_startup, label=_('File'), pos=(570, 110))
self.button_select_sound.Bind(wx.EVT_BUTTON, self.on_select_sound)
self.op_maximize = wx.CheckBox(self.p_startup, label=_('Maximize OpenPlotter'), pos=(360, 150))
self.op_maximize.Bind(wx.EVT_CHECKBOX, self.startup)
self.node_red = wx.CheckBox(self.p_startup, label=_('Node-Red (Dashboard, Freeboard)'), pos=(360, 180))
self.node_red.Bind(wx.EVT_CHECKBOX, self.startup)
def read_startup(self):
self.delay.SetValue(self.conf.get('STARTUP', 'delay'))
if self.conf.get('STARTUP', 'opencpn') == '1':
self.startup_opencpn.SetValue(True)
else:
self.startup_opencpn_nopengl.Disable()
self.startup_opencpn_fullscreen.Disable()
if self.conf.get('STARTUP', 'opencpn_no_opengl') == '1': self.startup_opencpn_nopengl.SetValue(True)
if self.conf.get('STARTUP', 'opencpn_fullscreen') == '1': self.startup_opencpn_fullscreen.SetValue(True)
if self.conf.get('STARTUP', 'kplex') == '1':
self.startup_multiplexer.SetValue(True)
else:
self.startup_nmea_time.Disable()
if self.conf.get('STARTUP', 'gps_time') == '1': self.startup_nmea_time.SetValue(True)
if self.conf.get('STARTUP', 'x11vnc') == '1':
self.startup_remote_desktop.SetValue(True)
else:
self.startup_vnc_pass.Disable()
if self.conf.get('STARTUP', 'vnc_pass') == '1': self.startup_vnc_pass.SetValue(True)
if self.conf.get('STARTUP', 'maximize') == '1':
self.op_maximize.SetValue(True)
self.Maximize()
if self.conf.get('STARTUP', 'node_red') == '1': self.node_red.SetValue(True)
self.startup_path_sound.SetValue(self.conf.get('STARTUP', 'sound'))
if self.conf.get('STARTUP', 'play') == '1':
self.startup_play_sound.SetValue(True)
def on_select_sound(self, e):
dlg = wx.FileDialog(self, message=_('Choose a file'), defaultDir=self.currentpath + '/sounds', defaultFile='',
wildcard=_('Audio files').decode('utf8') + ' (*.mp3)|*.mp3|' + _('All files').decode('utf8') + ' (*.*)|*.*',
style=wx.OPEN | wx.CHANGE_DIR)
if dlg.ShowModal() == wx.ID_OK:
file_path = dlg.GetPath()
self.startup_path_sound.SetValue(file_path)
self.conf.set('STARTUP', 'sound', file_path)
dlg.Destroy()
def on_ok_delay(self, e):
delay = self.delay.GetValue()
if not re.match('^[0-9]*$', delay):
self.ShowStatusBarRED(_('You can enter only numbers.'))
return
else:
if delay != '0': delay = delay.lstrip('0')
self.conf.set('STARTUP', 'delay', delay)
self.ShowStatusBarBLACK(_('Startup delay set to ').decode('utf8') + delay + _(' seconds').decode('utf8'))
def startup(self, e):
sender = e.GetEventObject()
if sender == self.startup_opencpn:
if self.startup_opencpn.GetValue():
self.startup_opencpn_nopengl.Enable()
self.startup_opencpn_fullscreen.Enable()
self.conf.set('STARTUP', 'opencpn', '1')
else:
self.startup_opencpn_nopengl.Disable()
self.startup_opencpn_fullscreen.Disable()
self.conf.set('STARTUP', 'opencpn', '0')
if sender == self.startup_opencpn_nopengl:
if self.startup_opencpn_nopengl.GetValue():
self.conf.set('STARTUP', 'opencpn_no_opengl', '1')
else:
self.conf.set('STARTUP', 'opencpn_no_opengl', '0')
if sender == self.startup_opencpn_fullscreen:
if self.startup_opencpn_fullscreen.GetValue():
self.conf.set('STARTUP', 'opencpn_fullscreen', '1')
else:
self.conf.set('STARTUP', 'opencpn_fullscreen', '0')
if sender == self.startup_multiplexer:
if self.startup_multiplexer.GetValue():
self.startup_nmea_time.Enable()
self.conf.set('STARTUP', 'kplex', '1')
else:
self.startup_nmea_time.Disable()
self.conf.set('STARTUP', 'kplex', '0')
if sender == self.startup_nmea_time:
if self.startup_nmea_time.GetValue():
self.conf.set('STARTUP', 'gps_time', '1')
else:
self.conf.set('STARTUP', 'gps_time', '0')
if sender == self.startup_remote_desktop:
if self.startup_remote_desktop.GetValue():
self.conf.set('STARTUP', 'x11vnc', '1')
self.startup_vnc_pass.Enable()
else:
self.conf.set('STARTUP', 'x11vnc', '0')
self.startup_vnc_pass.Disable()
if sender == self.startup_vnc_pass:
if self.startup_vnc_pass.GetValue():
self.conf.set('STARTUP', 'vnc_pass', '1')
dlg = wx.MessageDialog(None, _('Do you want to change your VNC-Password?'), _('Question'),
wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION)
if dlg.ShowModal() == wx.ID_YES:
subprocess.Popen(['lxterminal', '-e', 'x11vnc', '-storepasswd'])
dlg.Destroy()
else:
self.conf.set('STARTUP', 'vnc_pass', '0')
if sender == self.op_maximize:
if self.op_maximize.GetValue():
self.conf.set('STARTUP', 'maximize', '1')
else:
self.conf.set('STARTUP', 'maximize', '0')
if sender == self.startup_play_sound:
if self.startup_play_sound.GetValue():
self.conf.set('STARTUP', 'play', '1')
else:
self.conf.set('STARTUP', 'play', '0')
if sender == self.node_red:
if self.node_red.GetValue():
self.conf.set('STARTUP', 'node_red', '1')
else:
self.conf.set('STARTUP', 'node_red', '0')
########################################### WiFi AP
def page_wifi(self):
wx.StaticBox(self.p_wifi, size=(370, 315), pos=(10, 10))
self.wifi_enable = wx.CheckBox(self.p_wifi, label=_('Enable access point'), pos=(20, 25))
self.wifi_enable.Bind(wx.EVT_CHECKBOX, self.onwifi_enable)
self.bridge_enable = wx.CheckBox(self.p_wifi, label=_('Enable bridge to eth0'), pos=(180, 25))
self.available_wireless = []
output = subprocess.check_output('ifconfig')
for i in range(0, 9):
ii = str(i)
if 'wlan' + ii in output: self.available_wireless.append('wlan' + ii)
self.available_wireless_AP = []
for i in self.available_wireless:
try:
output2 = subprocess.check_output(['iw', i, 'info'], stderr=subprocess.STDOUT)
except:
output2 = ''
if output2 != '':
startpos = output2.find('wiphy') + 5
iwphy = int(output2[startpos:startpos + 3])
output2 = subprocess.check_output(['iw', 'phy' + str(iwphy), 'info'], stderr=subprocess.STDOUT)
startpos = output2.find('Supported interface modes')
if 'AP' in output2[startpos:startpos + 80]:
self.available_wireless_AP.append(i)
self.available_share = [_('none')]
for i in range(0, 9):
ii = str(i)
if 'eth' + ii in output: self.available_share.append('eth' + ii)
if 'ppp' + ii in output: self.available_share.append('ppp' + ii)
if 'usb' + ii in output: self.available_share.append('usb' + ii)
if 'wwan' + ii in output: self.available_share.append('wwan' + ii)
for i in self.available_wireless:
self.available_share.append(i)
share_old = self.conf.get('WIFI', 'share')
if share_old != '0' and share_old not in self.available_share: self.available_share.append(share_old)
self.wlan_label = wx.StaticText(self.p_wifi, label=_('Access point device'), pos=(20, 55))
self.wlan = wx.ComboBox(self.p_wifi, choices=self.available_wireless_AP, style=wx.CB_READONLY, size=(100, 32),
pos=(20, 75))
self.share_label = wx.StaticText(self.p_wifi, label=_('Sharing Internet device'), pos=(180, 55))
self.share = wx.ComboBox(self.p_wifi, choices=self.available_share, style=wx.CB_READONLY, size=(100, 32),
pos=(180, 75))
self.wifi_settings_label = wx.StaticText(self.p_wifi, label=_('Access point settings'), pos=(20, 120))
self.ssid = wx.TextCtrl(self.p_wifi, -1, size=(120, 32), pos=(20, 140))
self.ssid_label = wx.StaticText(self.p_wifi, label=_('SSID \nmaximum 32 characters'), pos=(160, 140))
self.passw = wx.TextCtrl(self.p_wifi, -1, size=(120, 32), pos=(20, 173))
self.passw_label = wx.StaticText(self.p_wifi, label=_('Password \nminimum 8 characters required'),
pos=(160, 175))
self.wifi_channel_list = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13']
self.wifi_channel = wx.ComboBox(self.p_wifi, choices=self.wifi_channel_list, style=wx.CB_READONLY,
size=(120, 32), pos=(20, 208))
self.wifi_channel_label = wx.StaticText(self.p_wifi, label=_('Channel'), pos=(160, 215))
self.wifi_mode_list = ['IEEE 802.11b', 'IEEE 802.11g']
self.wifi_mode = wx.ComboBox(self.p_wifi, choices=self.wifi_mode_list, style=wx.CB_READONLY, size=(120, 32),
pos=(20, 246))
self.wifi_mode_label = wx.StaticText(self.p_wifi, label=_('Mode'), pos=(160, 255))
self.wifi_wpa_list = [_('none'), 'WPA', 'WPA2', _('Both')]
self.wifi_wpa = wx.ComboBox(self.p_wifi, choices=self.wifi_wpa_list, style=wx.CB_READONLY, size=(120, 32),
pos=(20, 285))
self.wifi_wpa_label = wx.StaticText(self.p_wifi, label=_('WPA'), pos=(160, 290))
self.wifi_button_default = wx.Button(self.p_wifi, label=_('Defaults'), pos=(275, 240))
self.wifi_button_default.Bind(wx.EVT_BUTTON, self.on_wifi_default)
self.wifi_button_apply = wx.Button(self.p_wifi, label=_('Apply'), pos=(275, 280))
self.wifi_button_apply.Bind(wx.EVT_BUTTON, self.onwifi_apply)
wx.StaticBox(self.p_wifi, label=_(' Addresses '), size=(290, 315), pos=(385, 10))
self.ip_info = wx.TextCtrl(self.p_wifi, -1, style=wx.TE_MULTILINE | wx.TE_READONLY, size=(270, 245),
pos=(395, 30))
self.ip_info.SetBackgroundColour(wx.SystemSettings_GetColour(wx.SYS_COLOUR_INACTIVECAPTION))
self.button_refresh_ip = wx.Button(self.p_wifi, label=_('Refresh'), pos=(565, 280))
self.button_refresh_ip.Bind(wx.EVT_BUTTON, self.on_show_ip_info)
self.check_net_b = wx.Button(self.p_wifi, label=_('Status'), pos=(465, 280))
self.check_net_b.Bind(wx.EVT_BUTTON, self.on_check_net)
def read_wifi_conf(self):
if len(self.available_wireless) > 0:
self.wlan.SetValue(self.conf.get('WIFI', 'device'))
self.ssid.SetValue(self.conf.get('WIFI', 'ssid'))
self.wifi_channel.SetValue(self.conf.get('WIFI', 'channel'))
if self.conf.get('WIFI', 'password'): self.passw.SetValue('**********')
if self.conf.get('WIFI', 'share') == '0':
self.share.SetValue(_('none'))
else:
self.share.SetValue(self.conf.get('WIFI', 'share'))
if self.conf.get('WIFI', 'hw_mode') == 'b': self.wifi_mode.SetValue('IEEE 802.11b')
if self.conf.get('WIFI', 'hw_mode') == 'g': self.wifi_mode.SetValue('IEEE 802.11g')
if self.conf.get('WIFI', 'wpa') == '0': self.wifi_wpa.SetValue(_('none'))
if self.conf.get('WIFI', 'wpa') == '1': self.wifi_wpa.SetValue('WPA')
if self.conf.get('WIFI', 'wpa') == '2': self.wifi_wpa.SetValue('WPA2')
if self.conf.get('WIFI', 'wpa') == '3': self.wifi_wpa.SetValue(_('Both'))
if self.conf.get('WIFI', 'bridge') == '1':
self.bridge_enable.SetValue(True)
else:
self.bridge_enable.SetValue(False)
if self.conf.get('WIFI', 'enable') == '1':
self.enable_disable_wifi(1)
else:
self.enable_disable_wifi(0)
self.on_show_ip_info('')
def onwifi_enable(self, e):
if self.wifi_enable.GetValue():
self.wifi_active(True)
else:
self.wifi_active(False)
def wifi_active(self, status):
if status:
self.bridge_enable.Enable()
self.wlan_label.Enable()
self.wlan.Enable()
self.share_label.Enable()
self.share.Enable()
self.wifi_settings_label.Enable()
self.ssid.Enable()
self.ssid_label.Enable()
self.passw.Enable()
self.passw_label.Enable()
self.wifi_channel.Enable()
self.wifi_channel_label.Enable()
self.wifi_mode.Enable()
self.wifi_mode_label.Enable()
self.wifi_wpa.Enable()
self.wifi_wpa_label.Enable()
self.wifi_button_default.Enable()
else:
self.bridge_enable.Disable()
self.wlan_label.Disable()
self.wlan.Disable()
self.share_label.Disable()
self.share.Disable()
self.wifi_settings_label.Disable()
self.ssid.Disable()
self.ssid_label.Disable()
self.passw.Disable()
self.passw_label.Disable()
self.wifi_channel.Disable()
self.wifi_channel_label.Disable()
self.wifi_mode.Disable()
self.wifi_mode_label.Disable()
self.wifi_wpa.Disable()
self.wifi_wpa_label.Disable()
self.wifi_button_default.Disable()
def onwifi_apply(self, e):
isChecked = self.wifi_enable.GetValue()
wlan = self.wlan.GetValue()
ssid = self.ssid.GetValue()
share = self.share.GetValue()
if '*****' in self.passw.GetValue():
passw = self.conf.get('WIFI', 'password')
else:
passw = self.passw.GetValue()
if not wlan or not passw or not ssid or not share:
self.ShowStatusBarRED(_('Failed. You must fill in all fields.'))
return
if wlan == share:
self.ShowStatusBarRED(_('"Access point device" and "Sharing Internet device" must be different'))
return
if len(ssid) > 32 or len(passw) < 8:
self.ShowStatusBarRED(_('Your SSID must have a maximum of 32 characters and your password a minimum of 8.'))
return
channel = self.wifi_channel.GetValue()
mode = self.wifi_mode.GetValue()
wpa = self.wifi_wpa.GetValue()
bridge = '0'
if self.bridge_enable.GetValue(): bridge = '1'
if share == _('none'): share = '0'
if mode == 'IEEE 802.11b': mode = 'b'
if mode == 'IEEE 802.11g': mode = 'g'
if wpa == _('none'): wpa = '0'
if wpa == 'WPA': wpa = '1'
if wpa == 'WPA2': wpa = '2'
if wpa == _('Both'): wpa = '3'
if not isChecked and self.conf.get('WIFI', 'enable') == '1':
dlg = wx.MessageDialog(None, _(
'Access point will be disabled.\n\nIf you are on a headless system, you will not be able to reconnect again.\n\nAre you sure?'),
_('Question'), wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION)
if dlg.ShowModal() != wx.ID_YES:
self.enable_disable_wifi(1)