def main(): conf2 = conf.Conf() currentdir = os.path.dirname(os.path.abspath(__file__)) currentLanguage = conf2.get('GENERAL', 'lang') language.Language(currentdir, 'openplotter-network', currentLanguage) print(_('Installing python packages...')) try: subprocess.call(['pip3', 'install', 'pyric']) print(_('DONE')) except Exception as e: print(_('FAILED: ') + str(e)) try: print(_('Editing config files...')) fo = open('/etc/default/hostapd', "w") fo.write('DAEMON_CONF="/etc/hostapd/hostapd.conf"') fo.close() fo = open('/etc/systemd/system/openplotter-network.service', "w") fo.write( '[Service]\nExecStart=' + conf2.home + '/.openplotter/start-ap-managed-wifi.sh\nStandardOutput=syslog\nStandardError=syslog\nWorkingDirectory=' + conf2.home + '/.openplotter\nUser=root\n\n[Install]\nWantedBy=multi-user.target\n' ) fo.close() fo = open( currentdir + '/Network/udev/rules.d/11-openplotter-usb0.rules', "w") fo.write('KERNEL=="usb0", SUBSYSTEMS=="net", RUN+="/bin/bash ' + conf2.home + '/.openplotter/Network/11-openplotter-usb0.sh"\n') fo.close() print(_('DONE')) except Exception as e: print(_('FAILED: ') + str(e)) try: print(_('Enabling services...')) subprocess.call(['systemctl', 'daemon-reload']) subprocess.call(['systemctl', 'unmask', 'hostapd.service']) subprocess.call(['systemctl', 'enable', 'openplotter-network']) if not os.path.exists('/etc/hostapd/hostapd.conf'): subprocess.call(['systemctl', 'disable', 'hostapd']) print(_('DONE')) except Exception as e: print(_('FAILED: ') + str(e)) print(_('Setting version...')) try: conf2.set('APPS', 'network', version) print(_('DONE')) except Exception as e: print(_('FAILED: ') + str(e))
def main(): conf2 = conf.Conf() currentdir = os.path.dirname(os.path.abspath(__file__)) currentLanguage = conf2.get('GENERAL', 'lang') language.Language(currentdir, 'openplotter-SKfilter', currentLanguage) platform2 = platform.Platform() try: print(_('Installing/Updating Node-Red (Signal K embedded)...')) if platform2.skDir: subprocess.call( ['npm', 'i', '--verbose', '@signalk/signalk-node-red'], cwd=platform2.skDir) subprocess.call(['chown', '-R', conf2.user, platform2.skDir]) subprocess.call(['systemctl', 'stop', 'signalk.service']) subprocess.call(['systemctl', 'stop', 'signalk.socket']) subprocess.call(['systemctl', 'start', 'signalk.socket']) subprocess.call(['systemctl', 'start', 'signalk.service']) else: print(_('Failed. Please, install Signal K server.')) print(_('DONE')) except Exception as e: print(_('FAILED: ') + str(e)) print(_('Setting version...')) try: conf2.set('APPS', 'SKfilter', version) print(_('DONE')) except Exception as e: print(_('FAILED: ') + str(e))
def main(): conf2 = conf.Conf() currentdir = os.path.dirname(os.path.abspath(__file__)) currentLanguage = conf2.get('GENERAL', 'lang') package = 'openplotter-sdr-vhf' language.Language(currentdir, package, currentLanguage) print(_('Removing python packages...')) try: subprocess.call(['pip3', 'uninstall', '-y', 'pyrtlsdr']) print(_('DONE')) except Exception as e: print(_('FAILED: ')+str(e)) print(_('Removing rtl_ais service...')) try: subprocess.call(('systemctl stop openplotter-rtl_ais').split()) subprocess.call(('systemctl disable openplotter-rtl_ais').split()) subprocess.call(('rm -f /etc/systemd/system/openplotter-rtl_ais.service').split()) subprocess.call(('systemctl daemon-reload').split()) print(_('DONE')) except Exception as e: print(_('FAILED: ')+str(e)) subprocess.call(('python3 '+currentdir+'/unInstallGqrx.py').split()) subprocess.call(('python3 '+currentdir+'/unInstallDvbt.py').split()) subprocess.call(('python3 '+currentdir+'/unInstallPiaware.py').split()) subprocess.call(('apt autoremove -y welle.io').split()) print(_('Removing version...')) try: conf2.set('APPS', 'sdr_vhf', '') print(_('DONE')) except Exception as e: print(_('FAILED: ')+str(e))
def __init__(self): keys = [] conf_ = conf.Conf() sk_folder = conf_.get('GENERAL', 'sk_folder') self.data = "" node_path_all = subprocess.check_output(['npm', 'config', 'get', 'prefix']).decode(sys.stdin.encoding) node_path_line = node_path_all.split('\n') node_path = '/usr' #print(node_path_line) if len(node_path_line) > 0: node_path = node_path_line[len(node_path_line) - 1] #print(node_path_line[len(node_path_line) - 1]) if len(node_path_line) > 1 and node_path == '': node_path = node_path_line[len(node_path_line) - 2] #print(node_path_line[len(node_path_line) - 2]) keyswithmetadata = node_path+'/lib/node_modules/signalk-server/node_modules/@signalk/signalk-schema/dist/keyswithmetadata.json' try: with open(keyswithmetadata) as data_file: self.data = ujson.load(data_file) except: self.ShowMessage(_('File not found: ')+keyswithmetadata) for i in self.data: if '/vessels/*/' in i: key = i.replace('/vessels/*/','') key = key.replace('RegExp','*') key = key.replace('[A-Za-z0-9]+','*') key = key.replace('/','.') if 'properties' in self.data[i]: for ii in self.data[i]['properties']: key2 = key+'.'+ii if 'description' in self.data[i]['properties'][ii]: description = self.data[i]['properties'][ii]['description'] else: description = '[missing]' if 'units' in self.data[i]['properties'][ii]: units = self.data[i]['properties'][ii]['units'] else: units = '' keys.append([str(key2),description,units]) else: if 'description' in self.data[i]: description = self.data[i]['description'] else: description = '[missing]' if 'units' in self.data[i]: units = self.data[i]['units'] else: units = '' keys.append([str(key),description,units]) list_tmp = [] groups = [_('ungrouped')] ungrouped = [] for i in keys: items=i[0].split('.') if not items[0] in list_tmp: list_tmp.append(items[0]) else: if not items[0] in groups: groups.append(items[0]) for i in list_tmp: if not i in groups: ungrouped.append(i) self.keys = sorted(keys) self.groups = sorted(groups) self.ungrouped = sorted(ungrouped)
def main(): conf2 = conf.Conf() currentdir = os.path.dirname(os.path.abspath(__file__)) currentLanguage = conf2.get('GENERAL', 'lang') language.Language(currentdir, 'openplotter-i2c', currentLanguage) print(_('Adding openplotter-i2c-read service...')) try: fo = open('/etc/systemd/system/openplotter-i2c-read.service', "w") fo.write( '[Service]\nExecStart=openplotter-i2c-read\nStandardOutput=syslog\nStandardError=syslog\nUser='******'\nRestart=always\nRestartSec=5\n\n[Install]\nWantedBy=multi-user.target' ) fo.close() subprocess.call(['systemctl', 'daemon-reload']) print(_('DONE')) except Exception as e: print(_('FAILED: ') + str(e)) print(_('Setting version...')) try: conf2.set('APPS', 'i2c', version) print(_('DONE')) except Exception as e: print(_('FAILED: ') + str(e))
def main(): conf2 = conf.Conf() currentdir = os.path.dirname(os.path.abspath(__file__)) currentLanguage = conf2.get('GENERAL', 'lang') language.Language(currentdir, 'openplotter-sdr-vhf', currentLanguage) print(_('Installing GQRX...')) try: subprocess.call(('apt install -y gqrx-sdr').split()) if not os.path.isdir(conf2.home + '/.config/gqrx'): subprocess.call(('mkdir ' + conf2.home + '/.config/gqrx').split()) print(_('DONE')) except Exception as e: print(_('FAILED: ') + str(e)) print(_('Configuring GQRX...')) try: file = conf2.home + '/.config/gqrx/bookmarks.csv' if not os.path.isfile(file): subprocess.call((' cp ' + currentdir + '/data/bookmarks.csv ' + conf2.home + '/.config/gqrx/').split()) file = conf2.home + '/.config/gqrx/default.conf' if not os.path.isfile(file): subprocess.call((' cp ' + currentdir + '/data/default.conf ' + conf2.home + '/.config/gqrx/').split()) subprocess.call( ['chown', '-R', conf2.user, conf2.home + '/.config/gqrx']) subprocess.call( ('rm -f /usr/share/applications/gnuradio-grc.desktop').split()) print(_('DONE')) except Exception as e: print(_('FAILED: ') + str(e))
def main(): conf2 = conf.Conf() currentdir = os.path.dirname(os.path.abspath(__file__)) currentLanguage = conf2.get('GENERAL', 'lang') language.Language(currentdir, 'openplotter-can', currentLanguage) context = pyudev.Context() monitor = pyudev.Monitor.from_netlink(context) monitor.filter_by(subsystem='tty') print( _('Please connect (or disconnect and reconnect) the CAN-USB adapter')) for device in iter(monitor.poll, None): if device.action == 'add': value = device.get('DEVPATH') port = value[len(value) - value.find('/tty'):] port = '/dev/' + port[port.rfind('/') + 1:] print(port) try: ser = serial.Serial(port, 9600, timeout=0.5) except: print( _('Can not open serial device (CAN-USB) connected on: ') + port) sys.exit(0) ser.write(('0').encode()) time.sleep(0.2) sertext = ser.readline().decode() if len(sertext) >= 1: c = '0' while c != '9': i = 20 while i > 0: if ser.inWaiting(): sertext = ser.readline().decode() print(sertext[:-1]) else: i -= 1 time.sleep(0.05) i = 180 with raw(sys.stdin): with nonblocking(sys.stdin): while i > 0: try: c = sys.stdin.read(1) #print(i,c) if c in [ '1', '2', '3', '4', '5', '6', '7', '8', '9', '0' ]: ser.write(c.encode()) i = -5 except IOError: print('Error') time.sleep(.1) i -= 1 if i > -2: ser.write(('0').encode()) sys.exit(0)
def main(): conf2 = conf.Conf() currentdir = os.path.dirname(os.path.abspath(__file__)) currentLanguage = conf2.get('GENERAL', 'lang') language.Language(currentdir, 'openplotter-sdr-vhf', currentLanguage) print(_('Installing w-scan and VLC...')) try: subprocess.call(('apt install -y w-scan vlc').split()) print(_('DONE')) except Exception as e: print(_('FAILED: ') + str(e)) print(_('Configuring VLC...')) try: fo = open('/usr/share/applications/DVB-T.desktop', "w") fo.write( '[Desktop Entry]\nVersion=1.0\nName=SDR DVB-T\nGenericName=SDR DVB-T\nComment=SDR DVB-T\nExec=/usr/bin/vlc ' + conf2.home + '/.openplotter/dvb.xspf\nTryExec=/usr/bin/vlc\nIcon=vlc\nTerminal=false\nType=Application\nCategories=AudioVideo;Player;Recorder;\nMimeType=application/ogg;application/x-ogg;audio/ogg;audio/vorbis;audio/x-vorbis;audio/x-vorbis+ogg;video/ogg;video/x-ogm;video/x-ogm+ogg;video/x-theora+ogg;video/x-theora;audio/x-speex;audio/opus;application/x-flac;audio/flac;audio/x-flac;audio/x-ms-asf;audio/x-ms-asx;audio/x-ms-wax;audio/x-ms-wma;video/x-ms-asf;video/x-ms-asf-plugin;video/x-ms-asx;video/x-ms-wm;video/x-ms-wmv;video/x-ms-wmx;video/x-ms-wvx;video/x-msvideo;audio/x-pn-windows-acm;video/divx;video/msvideo;video/vnd.divx;video/avi;video/x-avi;application/vnd.rn-realmedia;application/vnd.rn-realmedia-vbr;audio/vnd.rn-realaudio;audio/x-pn-realaudio;audio/x-pn-realaudio-plugin;audio/x-real-audio;audio/x-realaudio;video/vnd.rn-realvideo;audio/mpeg;audio/mpg;audio/mp1;audio/mp2;audio/mp3;audio/x-mp1;audio/x-mp2;audio/x-mp3;audio/x-mpeg;audio/x-mpg;video/mp2t;video/mpeg;video/mpeg-system;video/x-mpeg;video/x-mpeg2;video/x-mpeg-system;application/mpeg4-iod;application/mpeg4-muxcodetable;application/x-extension-m4a;application/x-extension-mp4;audio/aac;audio/m4a;audio/mp4;audio/x-m4a;audio/x-aac;video/mp4;video/mp4v-es;video/x-m4v;application/x-quicktime-media-link;application/x-quicktimeplayer;video/quicktime;application/x-matroska;audio/x-matroska;video/x-matroska;video/webm;audio/webm;audio/3gpp;audio/3gpp2;audio/AMR;audio/AMR-WB;video/3gp;video/3gpp;video/3gpp2;x-scheme-handler/mms;x-scheme-handler/mmsh;x-scheme-handler/rtsp;x-scheme-handler/rtp;x-scheme-handler/rtmp;x-scheme-handler/icy;x-scheme-handler/icyx;application/x-cd-image;x-content/video-vcd;x-content/video-svcd;x-content/video-dvd;x-content/audio-cdda;x-content/audio-player;application/ram;application/xspf+xml;audio/mpegurl;audio/x-mpegurl;audio/scpls;audio/x-scpls;text/google-video-pointer;text/x-google-video-pointer;video/vnd.mpegurl;application/vnd.apple.mpegurl;application/vnd.ms-asf;application/vnd.ms-wpl;application/sdp;audio/dv;video/dv;audio/x-aiff;audio/x-pn-aiff;video/x-anim;video/x-nsv;video/fli;video/flv;video/x-flc;video/x-fli;video/x-flv;audio/wav;audio/x-pn-au;audio/x-pn-wav;audio/x-wav;audio/x-adpcm;audio/ac3;audio/eac3;audio/vnd.dts;audio/vnd.dts.hd;audio/vnd.dolby.heaac.1;audio/vnd.dolby.heaac.2;audio/vnd.dolby.mlp;audio/basic;audio/midi;audio/x-ape;audio/x-gsm;audio/x-musepack;audio/x-tta;audio/x-wavpack;audio/x-shorten;application/x-shockwave-flash;application/x-flash-video;misc/ultravox;image/vnd.rn-realpix;audio/x-it;audio/x-mod;audio/x-s3m;audio/x-xm;application/mxf;video/h264;\nX-KDE-Protocols=ftp,http,https,mms,rtmp,rtsp,sftp,smb\nKeywords=Player;Capture;DVD;Audio;Video;Server;Broadcast;' ) fo.close() print(_('DONE')) except Exception as e: print(_('FAILED: ') + str(e))
def main(): conf2 = conf.Conf() currentdir = os.path.dirname(os.path.abspath(__file__)) currentLanguage = conf2.get('GENERAL', 'lang') package = 'openplotter-myapp' ### replace openplotter-myapp by the name of your package language.Language(currentdir, package, currentLanguage) print(_('Removing app from OpenPlotter...')) try: externalApps0 = eval(conf2.get('APPS', 'external_apps')) externalApps1 = [] for i in externalApps0: if i['package'] != package: externalApps1.append(i) conf2.set('APPS', 'external_apps', str(externalApps1)) os.system( 'rm -f /etc/apt/sources.list.d/myapp.list' ) ### replace myapp.list by the name of your sources file (see myappPostInstall.py script). os.system('apt update') print(_('DONE')) except Exception as e: print(_('FAILED: ') + str(e)) ### ### Do here whatever you need to remove files and programs before app uninstallation. This file will be executed as sudo. ### print(_('Removing version...')) try: conf2.set( 'APPS', 'myapp', '' ) ### replace myapp by the name of your app, use the same name in openplotterMyapp.py and myappPostInstall.py scripts. print(_('DONE')) except Exception as e: print(_('FAILED: ') + str(e))
def main(): conf2 = conf.Conf() currentdir = os.path.dirname(os.path.abspath(__file__)) currentLanguage = conf2.get('GENERAL', 'lang') language.Language(currentdir,'openplotter-sdr-vhf',currentLanguage) platform2 = platform.Platform() try: print(_('Uninstalling pavucontrol...')) subprocess.call((platform2.admin+' apt autoremove -y pavucontrol').split()) print(_('DONE')) except Exception as e: print(_('FAILED: ')+str(e)) if platform2.isRPI: try: print(_('Delete Raspberry pi settings for pulseaudio stereo...')) if not os.path.isdir(conf2.home+'/.config/pulse'): subprocess.call(('mkdir ' + conf2.home+'/.config/pulse').split()) file = conf2.home+'/.config/pulse/default.pa' if os.path.isfile(file): subprocess.call(('rm ' + conf2.home + '/.config/pulse/default.pa').split()) print(_('DONE')) except Exception as e: print(_('FAILED: ')+str(e))
def main(): conf2 = conf.Conf() currentdir = os.path.dirname(os.path.abspath(__file__)) currentLanguage = conf2.get('GENERAL', 'lang') language.Language(currentdir, 'openplotter-serial', currentLanguage) print(_('Editing GPSD config file...')) try: path = '/etc/default/gpsd' if not os.path.exists(path): fo = open(path, "w") fo.write( 'START_DAEMON="false"\nUSBAUTO="false"\nDEVICES=""\nGPSD_OPTIONS="-n -b"' ) fo.close() print(_('DONE')) except Exception as e: print(_('FAILED: ') + str(e)) print(_('Setting version...')) try: conf2.set('APPS', 'serial', version) print(_('DONE')) except Exception as e: print(_('FAILED: ') + str(e))
def __init__(self): import pyric.pyw as pyw self.conf = conf.Conf() self.conf_folder = self.conf.conf_folder self.platform = platform.Platform() self.currentdir = os.path.dirname(os.path.abspath(__file__)) currentLanguage = self.conf.get('GENERAL', 'lang') self.language = language.Language(self.currentdir,'openplotter-network',currentLanguage) wx.Frame.__init__(self, None, title=_('Network')+' '+version, size=(800,444)) self.SetFont(wx.Font(10, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL)) icon = wx.Icon(self.currentdir+"/data/openplotter-network.png", wx.BITMAP_TYPE_PNG) self.SetIcon(icon) self.CreateStatusBar() font_statusBar = self.GetStatusBar().GetFont() font_statusBar.SetWeight(wx.BOLD) self.GetStatusBar().SetFont(font_statusBar) self.toolbar1 = wx.ToolBar(self, style=wx.TB_TEXT) toolHelp = self.toolbar1.AddTool(101, _('Help'), wx.Bitmap(self.currentdir+"/data/help.png")) self.Bind(wx.EVT_TOOL, self.OnToolHelp, toolHelp) if not self.platform.isInstalled('openplotter-doc'): self.toolbar1.EnableTool(101,False) toolSettings = self.toolbar1.AddTool(102, _('Settings'), wx.Bitmap(self.currentdir+"/data/settings.png")) self.Bind(wx.EVT_TOOL, self.OnToolSettings, toolSettings) self.toolbar1.AddSeparator() toolAddresses = self.toolbar1.AddTool(103, _('Addresses and Ports'), wx.Bitmap(self.currentdir+"/data/ports.png")) self.Bind(wx.EVT_TOOL, self.OnToolAddresses, toolAddresses) toolCheck = self.toolbar1.AddTool(104, _('Check Network'), wx.Bitmap(self.currentdir+"/data/check.png")) self.Bind(wx.EVT_TOOL, self.OnToolCheck, toolCheck) self.toolbar1.AddSeparator() toolDrivers = self.toolbar1.AddTool(105, _('Install Wifi Drivers'), wx.Bitmap(self.currentdir+"/data/package.png"), shortHelp=_('This does only help for unrecognized usb wlan type:') + ' 8188eu,8188fu,8192eu,8192su,8812au,8822bu,mt7610,mt7612') self.Bind(wx.EVT_TOOL, self.OnToolDrivers, toolDrivers) self.notebook = wx.Notebook(self) self.notebook.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, self.onTabChange) self.ap = wx.Panel(self.notebook) self.output = wx.Panel(self.notebook) self.notebook.AddPage(self.ap, _('Access Point')) self.notebook.AddPage(self.output, '') self.il = wx.ImageList(24, 24) img0 = self.il.Add(wx.Bitmap(self.currentdir+"/data/ap.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) vbox = wx.BoxSizer(wx.VERTICAL) vbox.Add(self.toolbar1, 0, wx.EXPAND) vbox.Add(self.notebook, 1, wx.EXPAND) self.SetSizer(vbox) self.pageAp() self.pageOutput() self.read_wifi_conf() maxi = self.conf.get('GENERAL', 'maximize') if maxi == '1': self.Maximize() self.Centre()
def main(): conf2 = conf.Conf() currentdir = os.path.dirname(os.path.abspath(__file__)) currentLanguage = conf2.get('GENERAL', 'lang') language.Language(currentdir, 'openplotter-dashboards', currentLanguage) try: platform2 = platform.Platform() subprocess.call(['apt', 'install', '-y', 'grafana']) subprocess.call(['systemctl', 'stop', 'grafana-server']) subprocess.call([ 'sed', '-i', 's/http_port = 3000/http_port = 3001/g', '/usr/share/grafana/conf/defaults.ini' ]) subprocess.call([ 'sed', '-i', 's/;http_port = 3000/http_port = 3001/g', '/etc/grafana/grafana.ini' ]) subprocess.call(['systemctl', 'enable', 'grafana-server.service']) subprocess.call(['systemctl', 'start', 'grafana-server']) print(_('DONE')) except Exception as e: print(_('FAILED: ') + str(e))
def main(): conf2 = conf.Conf() currentdir = os.path.dirname(os.path.abspath(__file__)) currentLanguage = conf2.get('GENERAL', 'lang') package = 'openplotter-gpio' language.Language(currentdir, package, currentLanguage) print(_('Removing python packages...')) try: subprocess.call(['pip3', 'uninstall', '-y', 'w1thermsensor']) print(_('DONE')) except Exception as e: print(_('FAILED: ') + str(e)) print(_('Removing pigpiod and openplotter-gpio-read services...')) try: subprocess.call(['systemctl', 'disable', 'pigpiod']) subprocess.call(['systemctl', 'stop', 'pigpiod']) subprocess.call(['systemctl', 'disable', 'openplotter-gpio-read']) subprocess.call(['systemctl', 'stop', 'openplotter-gpio-read']) subprocess.call( ['rm', '-f', '/etc/systemd/system/openplotter-gpio-read.service']) subprocess.call(['systemctl', 'daemon-reload']) print(_('DONE')) except Exception as e: print(_('FAILED: ') + str(e)) print(_('Removing version...')) try: conf2.set('APPS', 'gpio', '') print(_('DONE')) except Exception as e: print(_('FAILED: ') + str(e))
def main(): conf2 = conf.Conf() currentdir = os.path.dirname(os.path.abspath(__file__)) currentLanguage = conf2.get('GENERAL', 'lang') language.Language(currentdir,'openplotter-dashboards',currentLanguage) try: platform2 = platform.Platform() subprocess.call(['systemctl', 'disable', 'kapacitor.service']) subprocess.call(['systemctl', 'stop', 'kapacitor']) subprocess.call(['systemctl', 'disable', 'influxdb.service']) subprocess.call(['systemctl', 'stop', 'influxdb']) subprocess.call(['systemctl', 'disable', 'chronograf.service']) subprocess.call(['systemctl', 'stop', 'chronograf']) subprocess.call(['apt', 'autoremove', '-y', 'influxdb', 'kapacitor', 'chronograf']) subprocess.call(['npm', 'uninstall', '--verbose', 'signalk-to-influxdb', '--save'], cwd = platform2.skDir) subprocess.call(['systemctl', 'stop', 'signalk.service']) subprocess.call(['systemctl', 'stop', 'signalk.socket']) subprocess.call(['systemctl', 'start', 'signalk.socket']) subprocess.call(['systemctl', 'start', 'signalk.service']) print(_('DONE')) except Exception as e: print(_('FAILED: ')+str(e))
def main(): conf2 = conf.Conf() currentdir = os.path.dirname(os.path.abspath(__file__)) currentLanguage = conf2.get('GENERAL', 'lang') language.Language(currentdir, 'openplotter-sdr-ais', currentLanguage) platform2 = platform.Platform() try: print(_('Adding rtl_ais service...')) subprocess.call((' systemctl stop openplotter-rtl_ais').split()) subprocess.call((' systemctl disable openplotter-rtl_ais').split()) subprocess.call((' systemctl daemon-reload').split()) subprocess.call( (platform2.admin + ' rm /etc/systemd/system/openplotter-rtl_ais.service').split()) print(_('DONE')) except Exception as e: print(_('FAILED: ') + str(e)) try: print(_('remove rtl_ais...')) subprocess.call((' rm /usr/local/bin/rtl_ais').split()) print(_('DONE')) except Exception as e: print(_('FAILED: ') + str(e))
def main(): conf2 = conf.Conf() currentdir = os.path.dirname(os.path.abspath(__file__)) currentLanguage = conf2.get('GENERAL', 'lang') language.Language(currentdir,'openplotter-moitessier',currentLanguage) print(_('Copying driver packages...')) try: confFolder = conf2.conf_folder+'/moitessier' if not os.path.exists(confFolder): os.mkdir(confFolder) packageFolder = currentdir+'/packages' if os.path.exists(packageFolder): tmp = os.listdir(packageFolder) for i in tmp: shutil.copy(packageFolder+'/'+i, confFolder) subprocess.call(['chown', '-R', conf2.user, confFolder]) print(_('DONE')) except Exception as e: print(_('FAILED: ')+str(e)) print(_('Setting version...')) try: conf2.set('APPS', 'moitessier', version) print(_('DONE')) except Exception as e: print(_('FAILED: ')+str(e))
def __init__(self, process): self.conf = conf.Conf() self.process = process self.platform = platform.Platform() self.currentdir = os.path.dirname(os.path.abspath(__file__)) currentLanguage = self.conf.get('GENERAL', 'lang') self.language = language.Language(self.currentdir,'openplotter-dashboards',currentLanguage) wx.Dialog.__init__(self, None, title=_('Process management for') + ' ' + process, size=(450,320)) pnl = wx.Panel(self) pnl.SetBackgroundColour(wx.Colour(230,230,230,255)) icon = wx.Icon(self.currentdir+"/data/openplotter-dashboards.png", wx.BITMAP_TYPE_PNG) self.SetIcon(icon) self.lblList = [_('Enable'),_('Disable')] self.systemdbox = wx.RadioBox(pnl, label = 'Autostart', choices = self.lblList, majorDimension = 1, style = wx.RA_SPECIFY_ROWS) self.systemdbox.Bind(wx.EVT_RADIOBOX,self.onSystemdBox) sbox0 = wx.BoxSizer(wx.VERTICAL) sbox0.Add(self.systemdbox, 0, wx.ALL, 5) #sbox0.Add(self.skbox, 0, wx.ALL, 5) sbox = wx.StaticBox(pnl, -1, _('Status')) self.aStatusList = [_('active'),_('inactive')] self.aStatusbox = wx.RadioBox(pnl, label = _('ActiveState'), choices = self.aStatusList, majorDimension = 1, style = wx.RA_SPECIFY_ROWS) self.aStatusbox.Enable(False) self.bStatusList = [_('running'),_('dead')] self.bStatusbox = wx.RadioBox(pnl, label = _('Substate'), choices = self.bStatusList, majorDimension = 1, style = wx.RA_SPECIFY_ROWS) self.bStatusbox.Enable(False) sbox1 = wx.StaticBoxSizer(sbox, wx.VERTICAL) sbox1.Add(self.aStatusbox, 0, wx.ALL, 5) sbox1.Add(self.bStatusbox, 0, wx.ALL, 5) hbox = wx.BoxSizer(wx.HORIZONTAL) hbox.Add(sbox0, 1, wx.ALL, 5) hbox.AddStretchSpacer(1) hbox.Add(sbox1, 1, wx.ALL, 5) self.start = wx.Button(pnl, label=_('Start')) self.start.Bind(wx.EVT_BUTTON, self.onStart) self.stop = wx.Button(pnl, label=_('Stop')) self.stop.Bind(wx.EVT_BUTTON, self.onStop) self.restart = wx.Button(pnl, label=_('Restart')) self.restart.Bind(wx.EVT_BUTTON, self.onRestart) vbox = wx.BoxSizer(wx.VERTICAL) vbox.Add(hbox, 0, wx.ALL, 0) vbox.AddStretchSpacer(1) vbox.Add(self.start, 0, wx.LEFT | wx.BOTTOM, 5) vbox.Add(self.stop, 0, wx.ALL, 5) vbox.Add(self.restart, 0, wx.ALL, 5) pnl.SetSizer(vbox) self.statusUpdate() self.Centre() self.Show(True)
def main(): conf2 = conf.Conf() platform2 = platform.Platform() currentdir = os.path.dirname(os.path.abspath(__file__)) currentLanguage = conf2.get('GENERAL', 'lang') package = 'openplotter-sdr-vhf' language.Language(currentdir, package, currentLanguage) print(_('Installing python packages...')) try: subprocess.call(['pip3', 'install', 'pyrtlsdr']) print(_('DONE')) except Exception as e: print(_('FAILED: ') + str(e)) print(_('Copying udev rules...')) try: subprocess.call([ 'cp', '-f', currentdir + '/data/rtl-sdr.rules', '/etc/udev/rules.d/' ]) subprocess.call(['udevadm', 'control', '--reload-rules']) subprocess.call(['udevadm', 'trigger']) print(_('DONE')) except Exception as e: print(_('FAILED: ') + str(e)) print(_('Setting version...')) try: conf2.set('APPS', 'sdr_vhf', version) print(_('DONE')) except Exception as e: print(_('FAILED: ') + str(e))
def main(): conf2 = conf.Conf() currentdir = os.path.dirname(os.path.abspath(__file__)) currentLanguage = conf2.get('GENERAL', 'lang') language.Language(currentdir, 'openplotter-kplex', currentLanguage) print(_('Adding kplex service...')) try: fo = open('/etc/systemd/system/openplotter-kplex.service', "w") fo.write( '[Unit]\n' + 'Description = NMEA 0183 Multiplexer\n' + 'Documentation = http://www.stripydog.com/kplex/configuration.html\n' + 'After=syslog.target network.target audit.service\n' + '[Service]\n' + 'Type=forking\n' + 'PIDFILE=/var/run/kplex.pid\n' + 'ExecStart=/usr/bin/kplex -p /var/run/kplex.pid -o mode=background\n' + 'KillMode=process\n' + '[Install]\n' + 'WantedBy=multi-user.target\n') #fo.write( #'[Service]\nExecStart=kplex\nStandardOutput=syslog\nStandardError=syslog\nUser='******'\nRestart=always\nRestartSec=5\n\n[#Install]\nWantedBy=multi-user.target') fo.close() subprocess.call(['systemctl', 'daemon-reload']) subprocess.call(['systemctl', 'enable', 'openplotter-kplex']) print(_('DONE')) except Exception as e: print(_('FAILED: ') + str(e)) print(_('Setting version...')) try: conf2.set('APPS', 'kplex', version) print(_('DONE')) except Exception as e: print(_('FAILED: ') + str(e))
def main(): # This file will be ran as sudo. Do here whatever you need to remove files and programs before app uninstall. conf2 = conf.Conf() currentdir = os.path.dirname(__file__) currentLanguage = conf2.get('GENERAL', 'lang') language.Language(currentdir, 'openplotter-MCS', currentLanguage) # here we remove the services print(_('Removing openplotter-read-MCS service...')) try: subprocess.call(['systemctl', 'disable', 'openplotter-MCS-read']) subprocess.call(['systemctl', 'stop', 'openplotter-MCS-read']) subprocess.call( ['rm', '-f', '/etc/systemd/system/openplotter-MCS-read.service']) subprocess.call(['systemctl', 'daemon-reload']) print(_('DONE')) except Exception as e: print(_('FAILED: ') + str(e)) ### Remove autoshutdown Service print(_('Removing openplotter-autoshutdown Service...')) try: subprocess.call(['systemctl', 'disable', 'openplotter-MCS-asd']) subprocess.call(['systemctl', 'stop', 'openplotter-MCS-asd']) subprocess.call( ['rm', '-f', '/etc/systemd/system/openplotter-MCS-asd.service']) subprocess.call(['systemctl', 'daemon-reload']) print(_('DONE')) except Exception as e: print(_('FAILED: ') + str(e)) try: fo1r = open('/boot/config.txt', "r") configcontent = fo1r.read() startpos = configcontent.find( "#MCS-Openplotter config (Do not delete or edit this part)(start)") endpos = configcontent.find( "#MCS-Openplotter config (Do not delete or edit this part)(end)" ) + 63 fo1r.close() before = "" behind = "" before = configcontent[:startpos] behind = configcontent[endpos:] newconfigcontent = before + behind if (startpos != -1): fo1 = open('/boot/config.txt', "w") fo1.write(newconfigcontent) fo1.close() print(_("config.txt entries deleted")) else: print(_("config.txt entries not exists")) except Exception as e: print(_('FAILED: ') + str(e))
def main(): conf2 = conf.Conf() active = False try: i2c_sensors = eval(conf2.get('I2C', 'sensors')) except: i2c_sensors = [] if i2c_sensors: for i in i2c_sensors: if 'BME280' in i: x1 = threading.Thread(target=work_BME280, args=(i, i2c_sensors[i]), daemon=True) x1.start() active = True elif 'MS5607-02BA03' in i: x2 = threading.Thread(target=work_MS5607, args=(i, i2c_sensors[i]), daemon=True) x2.start() active = True elif 'ADS1115' in i: x3 = threading.Thread(target=work_ADS1115, args=(i, i2c_sensors[i]), daemon=True) x3.start() active = True elif 'HTU21D' in i: x4 = threading.Thread(target=work_HTU21D, args=(i, i2c_sensors[i]), daemon=True) x4.start() active = True elif 'BMP280' in i: x5 = threading.Thread(target=work_BMP280, args=(i, i2c_sensors[i]), daemon=True) x5.start() active = True elif 'BMP3XX' in i: x6 = threading.Thread(target=work_BMP3XX, args=(i, i2c_sensors[i]), daemon=True) x6.start() active = True elif 'INA260' in i: x7 = threading.Thread(target=work_INA260, args=(i, i2c_sensors[i]), daemon=True) x7.start() active = True while active: time.sleep(0.1)
def main(): conf2 = conf.Conf() currentdir = os.path.dirname(os.path.abspath(__file__)) currentLanguage = conf2.get('GENERAL', 'lang') package = 'openplotter-gpio' language.Language(currentdir, package, currentLanguage) print(_('Installing python packages...')) try: subprocess.call( ['pip3', 'install', 'w1thermsensor>=2.0.0', 'websocket-client']) 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('GPIO') result = skConnections.checkConnection() if result[1]: print(result[1]) else: print(_('DONE')) except Exception as e: print(_('FAILED: ') + str(e)) print(_('Adding openplotter-gpio-read service...')) try: fo = open('/etc/systemd/system/openplotter-gpio-read.service', "w") fo.write( '[Service]\nExecStart=openplotter-gpio-read\nStandardOutput=syslog\nStandardError=syslog\nUser='******'\nRestart=always\nRestartSec=5\n\n[Install]\nWantedBy=multi-user.target' ) fo.close() subprocess.call(['systemctl', 'daemon-reload']) subprocess.call(['systemctl', 'enable', 'openplotter-gpio-read']) print(_('DONE')) except Exception as e: print(_('FAILED: ') + str(e)) print(_('Enabling pigpiod service...')) try: subprocess.call(['systemctl', 'enable', 'pigpiod']) subprocess.call(['systemctl', 'restart', 'pigpiod']) print(_('DONE')) except Exception as e: print(_('FAILED: ') + str(e)) print(_('Setting version...')) try: conf2.set('APPS', 'gpio', version) print(_('DONE')) except Exception as e: print(_('FAILED: ') + str(e))
def main(): conf2 = conf.Conf() currentdir = os.path.dirname(os.path.abspath(__file__)) currentLanguage = conf2.get('GENERAL', 'lang') language.Language(currentdir, 'openplotter-SKfilter', currentLanguage) print(_('Removing version...')) try: conf2.set('APPS', 'SKfilter', '') print(_('DONE')) except Exception as e: print(_('FAILED: ') + str(e))
def main(): conf2 = conf.Conf() currentdir = os.path.dirname(os.path.abspath(__file__)) currentLanguage = conf2.get('GENERAL', 'lang') language.Language(currentdir,'openplotter-sdr-vhf',currentLanguage) print(_('Uninstalling GQRX...')) try: subprocess.call(('apt autoremove -y gqrx-sdr').split()) subprocess.call(('rm -rf ' + conf2.home+'/.config/gqrx').split()) print(_('DONE')) except Exception as e: print(_('FAILED: ')+str(e))
def main(): conf2 = conf.Conf() currentdir = os.path.dirname(__file__) currentLanguage = conf2.get('GENERAL', 'lang') language.Language(currentdir,'openplotter-i2c',currentLanguage) print(_('Removing openplotter-i2c-read service...')) try: subprocess.call(['systemctl', 'disable', 'openplotter-i2c-read']) subprocess.call(['systemctl', 'stop', 'openplotter-i2c-read']) subprocess.call(['rm', '-f', '/etc/systemd/system/openplotter-i2c-read.service']) subprocess.call(['systemctl', 'daemon-reload']) print(_('DONE')) except Exception as e: print(_('FAILED: ')+str(e))
def main(): conf2 = conf.Conf() currentdir = os.path.dirname(os.path.abspath(__file__)) currentLanguage = conf2.get('GENERAL', 'lang') language.Language(currentdir, 'openplotter-sdr-vhf', currentLanguage) print(_('Uninstalling w-scan...')) try: subprocess.call(('apt autoremove -y w-scan').split()) subprocess.call( ('rm -rf /usr/share/applications/DVB-T.desktop').split()) print(_('DONE')) except Exception as e: print(_('FAILED: ') + str(e))
def main(): temp = 0 try: conf2 = conf.Conf() value = conf2.get('MCS', 'sending') port = conf2.get('MCS', 'MCSConn1') Sensor = conf2.get('MCS', 'owiresensors') config_osensors = eval(Sensor) except Exception as e: print(str(e)) return if value == '1': # this script sends data to Signal K servers by an UDP connection in client mode sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) k = 30 while True: values = "" k += 1 if k > 20: k = 0 xx = getlist() ########### for i in config_osensors: #try: if True: for ii in xx: if ii == i[0]: foo = open( "/sys/bus/w1/devices/" + ii + "/w1_slave", "r") data = foo.read() foo.close() spos = data.find("t=") tempx = (data[spos + 2:-1]) temp = int(tempx) / 1000 temp = temp + 273.15 #except Exception as e: print (str(e)) values += '{"path":"' + str( i[2]) + '","value":' + str(temp) + '},' #print (values) ############ values = values[0:-1] SignalK = '{"updates":[{"$source":"OpenPlotter.MCS.OWire","values":[' + values + ']}]}\n' #print (SignalK) sock.sendto(SignalK.encode('utf-8'), ('127.0.0.1', int(port))) time.sleep(2)
def main(): conf2 = conf.Conf() currentdir = os.path.dirname(os.path.abspath(__file__)) currentLanguage = conf2.get('GENERAL', 'lang') language.Language(currentdir,'openplotter-network',currentLanguage) print(_('Removing python packages...')) try: subprocess.call(['pip3', 'uninstall', '-y', 'pyric']) print(_('DONE')) except Exception as e: print(_('FAILED: ')+str(e)) try: print(_('Restoring network Debian defaults...')) subprocess.call(['bash', currentdir+'/Network/hostname_dot_local.sh', 'n']) subprocess.call(['cp', currentdir+'/Network/dhcpcd_default.conf', '/etc/dhcpcd.conf']) subprocess.call(['cp', currentdir+'/Network/nftables_default.conf', '/etc/nftables.conf']) subprocess.call(['rm', '-f', '/etc/network/interfaces.d/ap']) subprocess.call(['rm', '-f', '/etc/udev/rules.d/72-wireless.rules']) subprocess.call(['rm', '-f', '/etc/udev/rules.d/11-openplotter-usb0.rules']) subprocess.call(['rm', '-f', '/lib/dhcpcd/dhcpcd-hooks/10-wpa_supplicant_wlan9']) subprocess.call(['cp', currentdir+'/Network/dhcpcd-hooks/10-wpa_supplicant', '/lib/dhcpcd/dhcpcd-hooks']) subprocess.call(['rm', '-f', '/etc/systemd/network/bridge-br0.network']) subprocess.call(['rm', '-f', '/etc/systemd/network/bridge-br0-slave.network']) subprocess.call(['rm', '-f', '/etc/systemd/network/bridge-br0.netdev']) subprocess.call(['rm', '-rf', conf2.home+'/.openplotter/Network']) print(_('Removing openplotter-network service...')) subprocess.call(['systemctl', 'disable', 'dnsmasq']) subprocess.call(['systemctl', 'disable', 'hostapd']) subprocess.call(['systemctl', 'disable', 'systemd-networkd']) subprocess.call(['systemctl', 'disable', 'openplotter-network']) subprocess.call(['systemctl', 'disable', 'nftables.service']) subprocess.call(['systemctl', 'stop', 'nftables.service']) subprocess.call(['systemctl', 'stop', 'openplotter-network']) subprocess.call(['rm', '-f', '/etc/systemd/system/openplotter-network.service']) subprocess.call(['systemctl', 'daemon-reload']) subprocess.call(['rm', conf2.home+'/.openplotter/start-ap-managed-wifi.sh']) subprocess.call(['rm', conf2.home+'/.openplotter/start1.sh']) subprocess.call(['rm', conf2.home+'/.openplotter/wpa_cli_script.sh']) print(_('DONE. PLEASE REBOOT TO RESTORE NETWORK SETTINGS')) except Exception as e: print(_('FAILED: ')+str(e)) print(_('Removing version...')) try: conf2.set('APPS', 'network', '') print(_('DONE')) except Exception as e: print(_('FAILED: ')+str(e))
def main(): conf2 = conf.Conf() currentdir = os.path.dirname(os.path.abspath(__file__)) currentLanguage = conf2.get('GENERAL', 'lang') language.Language(currentdir, 'openplotter-dashboards', currentLanguage) try: platform2 = platform.Platform() subprocess.call(['systemctl', 'disable', 'kapacitor.service']) subprocess.call(['systemctl', 'stop', 'kapacitor']) subprocess.call(['apt', '-y', 'autoremove', 'kapacitor', 'chronograf']) print(_('DONE')) except Exception as e: print(_('FAILED: ') + str(e))