diff --git a/__init__.py b/__init__.py index 20d3dc8..02faa81 100644 --- a/__init__.py +++ b/__init__.py @@ -30,22 +30,7 @@ this code is currently used: from servicemanager.base import ServiceManager, ServiceDown, UsageError, get_config from servicemanager.nicosman import NicosManager from servicemanager.seaman import SeaManager - - -class FrappyManager(ServiceManager): - group = 'frappy' - services = ('main', 'stick', 'addons') - USAGE = """ - Usage: - - frappy list [] - frappy start - frappy restart [] [] - frappy stop [] - - is one of main, stick, addons - is one of %s - """ +from servicemanager.frappyman import FrappyManager class SewebManager(ServiceManager): @@ -85,7 +70,7 @@ def run(group, arglist): except AttributeError: raise UsageError("do not know '%s'" % ' '.join([serv.group, action] + arglist)) except UsageError as e: - print(repr(e)) - print(serv.usage()) + serv.usage() + print('ERROR:', str(e)) diff --git a/base.py b/base.py index ef43ed9..6dbc35c 100644 --- a/base.py +++ b/base.py @@ -399,9 +399,8 @@ class ServiceManager: try: method(*args) except TypeError as e: - raise errtxt = str(e) - if ' do_%s(' % action in errtxt and 'argument' in errtxt: + if 'do_%s(' % action in errtxt and 'argument' in errtxt: raise UsageError(errtxt) raise diff --git a/frappyman.py b/frappyman.py new file mode 100644 index 0000000..8433033 --- /dev/null +++ b/frappyman.py @@ -0,0 +1,66 @@ +# -*- coding: utf-8 -*- +# ***************************************************************************** +# +# 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 (at your option) 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, write to the Free Software Foundation, Inc., +# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# Module authors: +# Markus Zolliker +# +# ***************************************************************************** + +#import os +from servicemanager.base import ServiceManager, ServiceDown, UsageError + + +class FrappyManager(ServiceManager): + group = 'frappy' + services = ('main', 'stick', 'addons') + USAGE = """ + Usage: + + frappy list [] + frappy start + frappy restart [] [] + frappy stop [] + + is one of main, stick, addons + is one of %s + """ + + def do_gui(self, ins='', service='main'): + try: + self.check_running(ins, service) + except ServiceDown as e: + raise UsageError('frappy %s %s is not running' % (ins, service)) + return + except KeyError: + if not ins: + raise UsageError('missing instance') + raise UsageError('unknown instance %s' % ins) + + print('starting frappy gui %s' % ins) + + import mlzlog + + from secop.gui.qt import QApplication + from secop.gui.mainwindow import MainWindow + + mlzlog.initLogging('gui', 'info') + + app = QApplication([]) + win = MainWindow(['localhost:%d' % self.info[ins][service]]) + win.show() + + return app.exec_()