#!/usr/bin/env python3 # This file is part of OpenPlotter. # Copyright (C) 2022 by Sailoog # # 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 . import os, subprocess from openplotterSettings import conf from openplotterSettings import language from .version import version def main(): conf2 = conf.Conf() currentdir = os.path.dirname(os.path.abspath(__file__)) currentLanguage = conf2.get('GENERAL', 'lang') package = 'openplotter-maiana' language.Language(currentdir, package, currentLanguage) print(_('Checking access to Signal K server...')) try: from openplotterSignalkInstaller import connections skConnections = connections.Connections('MAIANA') result = skConnections.checkConnection() if result[1]: print(result[1]) else: print(_('DONE')) except Exception as e: print(_('FAILED: ')+str(e)) #TODO switch from service to startup print(_('Adding openplotter-maiana-read service...')) try: fo = open('/etc/systemd/system/openplotter-maiana-read.service', "w") fo.write( '[Service]\nExecStart=openplotter-maiana-read\nStandardOutput=syslog\nStandardError=syslog\nUser='+conf2.user+'\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', 'maiana', version) print(_('DONE')) except Exception as e: print(_('FAILED: ')+str(e)) if __name__ == '__main__': main()