Exemplo n.º 1
0
    def __init__(self, app):
        Module.__init__(self, app)
        # add template path
        app.jinja_loader.searchpath.append(
            u"{}/emonitor/modules/printers/templates".format(
                app.config.get('PROJECT_ROOT')))

        # add events and handler
        events.addHandlerClass('*',
                               'emonitor.modules.printers.printers.Printers',
                               Printers.handleEvent, ['in.printerid'])

        # subnavigation
        self.adminsubnavigation = [('/admin/printers', 'printers.main'),
                                   ('/admin/printers/settings',
                                    'module.printers.settings')]

        # static folders
        @app.route('/printer/inc/<path:filename>')
        def printer_static(filename):
            return send_from_directory(
                u"{}/emonitor/modules/printers/inc/".format(
                    app.config.get('PROJECT_ROOT')), filename)

        # translations
        babel.gettext(u'module.printers')
        babel.gettext(u'printers.main')
        babel.gettext(u'module.printers.settings')
        babel.gettext(u'emonitor.modules.printers.printers.Printers')
        babel.gettext(u'template.alarm_sum')
        babel.gettext(u'template.alarm_original')
Exemplo n.º 2
0
    def __init__(self, app):
        """
        Add specific parameters and configuration to app object

        :param app: flask wsgi application
        """
        Module.__init__(self, app)
        # add template path
        app.jinja_loader.searchpath.append("{}/emonitor/modules/persons/templates".format(app.config.get('PROJECT_ROOT')))

        # subnavigation
        self.updateAdminSubNavigation()

        # create database tables
        from emonitor.modules.persons.persons import Person

        # eventhandlers

        # signals and handlers

        from emonitor.modules.persons.message_birthday import BirthdayWidget
        from emonitor.modules.messages import addMessageType
        addMessageType(BirthdayWidget('message_birthday'))

        # translations
        babel.gettext(u'module.persons')
        babel.gettext(u'module.persons.0')
        babel.gettext(u'persons.upload.states-1')
        babel.gettext(u'persons.upload.states0')
        babel.gettext(u'persons.upload.states1')
        babel.gettext(u'birthday')
Exemplo n.º 3
0
    def __init__(self, app):
        """
        Add specific parameters and configuration to app object

        :param app: flask wsgi application
        """
        Module.__init__(self, app)

        # add template path
        app.jinja_loader.searchpath.append(
            u"{}/emonitor/modules/alarmkeys/templates".format(
                app.config.get('PROJECT_ROOT')))

        # create database tables
        from alarmkey import Alarmkey
        from alarmkeycar import AlarmkeyCars

        # static folders
        @app.route('/alarmkeys/inc/<path:filename>')
        def alarmkeys_static(filename):
            return send_from_directory(
                u"{}/emonitor/modules/alarmkeys/inc/".format(
                    app.config.get('PROJECT_ROOT')), filename)

        babel.gettext(u'module.alarmkeys')
        babel.gettext(u'alarmkeys.upload.states0')
        babel.gettext(u'alarmkeys.upload.states1')
        babel.gettext(u'alarmkeys.upload.states-1')
Exemplo n.º 4
0
    def __init__(self, app):
        Module.__init__(self, app)
        # add template path
        app.jinja_loader.searchpath.append("%s/emonitor/modules/textmod/templates" % app.config.get('PROJECT_ROOT'))

        # subnavigation
        self.adminsubnavigation = [('/admin/textmod', 'module.textmod.replace'), ('/admin/textmod/ocr', 'module.textmod.ocr'), ('/admin/textmod/ocrcustom', 'module.textmod.ocrcustom'), ('/admin/textmod/convert', 'module.textmod.convert')]
        
        # create database tables
        from .replace import Replace
        from .ocr import Ocr

        # eventhandlers
        events.addHandlerClass('file_added', 'emonitor.modules.textmod.TextmodModule', TextmodModule.handleEvent, ['in.path', 'in.filename', 'out.filename'])
        events.addHandlerClass('file_added', 'emonitor.modules.textmod.ocr.Ocr', Ocr.handleEvent, ['in.path', 'in.filename', 'out.text'])
        events.addHandlerClass('file_added', 'emonitor.modules.textmod.replace.Replace', Replace.handleEvent, ['in.text', 'out.text'])
        
        # translations
        babel.gettext(u'module.textmod')
        babel.gettext(u'module.textmod.replace')
        babel.gettext(u'module.textmod.ocr')
        babel.gettext(u'module.textmod.ocrcustom')
        babel.gettext(u'module.textmod.convert')
        babel.gettext(u'emonitor.modules.textmod.ocr.Ocr')
        babel.gettext(u'emonitor.modules.textmod.replace.Replace')
        babel.gettext(u'emonitor.modules.textmod.TextmodModule')
Exemplo n.º 5
0
    def __init__(self, app):
        """
        Add specific parameters and configuration to app object

        :param app: flask wsgi application
        """
        Module.__init__(self, app)
        # add template path
        app.jinja_loader.searchpath.append(
            "{}/emonitor/modules/persons/templates".format(
                app.config.get('PROJECT_ROOT')))

        # subnavigation
        self.updateAdminSubNavigation()

        # create database tables
        from emonitor.modules.persons.persons import Person

        # eventhandlers

        # signals and handlers

        from emonitor.modules.persons.message_birthday import BirthdayWidget
        from emonitor.modules.messages import addMessageType
        addMessageType(BirthdayWidget('message_birthday'))

        # translations
        babel.gettext(u'module.persons')
        babel.gettext(u'module.persons.0')
        babel.gettext(u'persons.upload.states-1')
        babel.gettext(u'persons.upload.states0')
        babel.gettext(u'persons.upload.states1')
        babel.gettext(u'birthday')
Exemplo n.º 6
0
    def __init__(self, app):
        Module.__init__(self, app)

        # add template path
        app.jinja_loader.searchpath.append("%s/emonitor/modules/monitors/templates" % app.config.get('PROJECT_ROOT'))

        # subnavigation
        self.adminsubnavigation = [('/admin/monitors', 'monitors.definition'), ('/admin/monitors/style', 'module.monitors.style'), ('/admin/monitors/current', 'module.monitors.current'), ('/admin/monitors/actions', 'module.monitors.actions')]
        self.widgets = [PlaceholderWidget('placeholder')]

        signal.connect('monitorserver', 'clientsearchdone', frontendMonitorHandler.handleClientSearch)
        signal.connect('monitorserver', 'clientanswer', frontendMonitorHandler.handleClientAnswer)

        # static folders
        @app.route('/monitors/inc/<path:filename>')
        def monitors_static(filename):
            return send_from_directory("%s/emonitor/modules/monitors/inc/" % app.config.get('PROJECT_ROOT'), filename)
            
        # translations
        babel.gettext(u'module.monitors')
        babel.gettext(u'monitors.definition')
        babel.gettext(u'module.monitors.style')
        babel.gettext(u'module.monitors.current')
        babel.gettext(u'module.monitors.actions')
        babel.gettext(u'monitors.landscape')
        babel.gettext(u'monitors.portrait')
        babel.gettext(u'monitors.orientation.0')
        babel.gettext(u'monitors.orientation.1')
        babel.gettext(u'placeholder')
Exemplo n.º 7
0
    def __init__(self, app):
        Module.__init__(self, app)
        # add template path
        app.jinja_loader.searchpath.append("%s/emonitor/modules/messages/templates" % app.config.get('PROJECT_ROOT'))

        # subnavigation
        self.adminsubnavigation = [('/admin/messages', 'messages.main'), ('/admin/messages/types', 'messages.types')]
        self.widgets = [MessageWidget('messages', size=(4, 2), template='widget.message.messages.html'), WeatherWidget('weather', size=(5, 4), template='widget.message.weather.html')]

        # static folders
        @app.route('/messages/inc/<path:filename>')
        def messages_static(filename):
            if filename.startswith('message/'):
                filename = filename.split('/')
                return send_from_directory("{}messages/{}/".format(app.config.get('PATH_DATA'), filename[-2]), filename[-1])
            else:
                return send_from_directory("%s/emonitor/modules/messages/inc/" % app.config.get('PROJECT_ROOT'), filename)

        # translations
        babel.gettext(u'module.messages')
        babel.gettext(u'messages.main')
        babel.gettext(u'messages.types')
        babel.gettext(u'weather')
        babel.gettext(u'messages')
        babel.gettext(u'messagestate.1')  # activated
        babel.gettext(u'messagestate.0')  # deactivated
        babel.gettext(u'message.state.1')  # active
        babel.gettext(u'message.state.0')  # in-active

        # init
        # Do init script for messages at start and add active messages
        try:
            Messages.initMessageTrigger()
        except ProgrammingError:
            pass
Exemplo n.º 8
0
    def __init__(self, app):
        """
        Add specific parameters and configuration to app object

        :param app: flask wsgi application
        """
        Module.__init__(self, app)
        # add template path
        app.jinja_loader.searchpath.append("%s/emonitor/modules/maps/templates" % app.config.get('PROJECT_ROOT'))

        # subnavigation
        self.adminsubnavigation = [('/admin/maps', 'maps.base'), ('/admin/maps/position', 'module.maps.position')]

        self.widgets = [MapWidget('maps_map')]

        # signals and handlers
        signal.connect('map', 'tiledownloadstart', adminMapHandler.handleMapDownloadStart)
        signal.connect('map', 'tiledownloadstop', adminMapHandler.handleMapDownloadStop)
        signal.connect('map', 'tiledownloaddone', adminMapHandler.handleMapDownloadDone)
        signal.connect('map', 'tiledownloadprogress', adminMapHandler.handleMapDownloadProgress)

        # static folders
        @app.route('/maps/inc/<path:filename>')
        def maps_static(filename):
            return send_from_directory("%s/emonitor/modules/maps/inc/" % app.config.get('PROJECT_ROOT'), filename)

        # translations
        babel.gettext(u'module.maps')
        babel.gettext(u'maps_map')
        babel.gettext(u'maps.base')
        babel.gettext(u'module.maps.position')
Exemplo n.º 9
0
    def __init__(self, app):
        Module.__init__(self, app)
        # add template path
        app.jinja_loader.searchpath.append(
            u"{}/emonitor/modules/streets/templates".format(
                app.config.get('PROJECT_ROOT')))

        # subnavigation
        self.widgets = [StreetWidget('streets_street')]

        signal.addSignal('housenumber', 'osm')
        signal.connect('housenumber', 'osm',
                       adminHousenumberHandler.handleOSMChanged)
        signal.connect('housenumber', 'osmdone',
                       adminHousenumberHandler.handleOSMDone)

        # static folders
        @app.route('/streets/inc/<path:filename>')
        def streets_static(filename):
            return send_from_directory(
                u"{}/emonitor/modules/streets/inc/".format(
                    app.config.get('PROJECT_ROOT')), filename)

        # translations
        babel.gettext(u'module.streets')
        babel.gettext(u'module.streets.0')
        babel.gettext(u'streets_street')  # widget name
Exemplo n.º 10
0
    def __init__(self, app):
        Module.__init__(self, app)
        # add template path
        app.jinja_loader.searchpath.append("%s/emonitor/modules/locations/templates" % app.config.get('PROJECT_ROOT'))

        # translations
        babel.gettext(u'module.locations')
Exemplo n.º 11
0
    def __init__(self, app):
        Module.__init__(self, app)
        # add template path
        app.jinja_loader.searchpath.append(
            "%s/emonitor/modules/locations/templates" %
            app.config.get('PROJECT_ROOT'))

        # translations
        babel.gettext(u'module.locations')
Exemplo n.º 12
0
 def __init__(self, app):
     Module.__init__(self, app)
     # add template path
     app.jinja_loader.searchpath.append("%s/emonitor/modules/user/templates" % app.config.get('PROJECT_ROOT'))
     
     babel.gettext(u'module.users')
     babel.gettext(u'userlevel.notset')
     babel.gettext(u'userlevel.admin')
     babel.gettext(u'userlevel.user')
Exemplo n.º 13
0
    def __init__(self, app):
        Module.__init__(self, app)
        # add template path
        app.jinja_loader.searchpath.append(
            "%s/emonitor/modules/settings/templates" %
            app.config.get('PROJECT_ROOT'))

        self.widgets = [CrestWidget('departmentcrest')]

        # subnavigation
        self.adminsubnavigation = [
            ('/admin/settings', 'settings.main'),
            ('/admin/settings/department', 'module.settings.department'),
            ('/admin/settings/cars', 'module.settings.cars'),
            ('/admin/settings/communication', 'module.settings.communication'),
            ('/admin/settings/start', 'module.settings.start')
        ]

        # static folders
        @app.route('/settings/inc/<path:filename>')
        def settings_static(filename):
            return send_from_directory(
                "%s/emonitor/modules/settings/inc/" %
                app.config.get('PROJECT_ROOT'), filename)

        # translations
        babel.gettext(u'module.settings')
        babel.gettext(u'settings.main')
        babel.gettext(u'module.settings.department')
        babel.gettext(u'module.settings.cars')
        babel.gettext(u'module.settings.communication')
        babel.gettext(u'module.settings.start')

        babel.gettext(u'settings.pathtype.pathdone')
        babel.gettext(u'settings.pathtype.pathtmp')
        babel.gettext(u'settings.pathtype.pathdata')
        babel.gettext(u'settings.pathtype.pathincome')

        babel.gettext(u'departmentcrest')
        babel.gettext(u'telegram.default.welcomemsg')

        # add default values
        if Settings.query.count() == 0:  # add default values
            db.session.add(Settings.set('defaultZoom', 15))
            db.session.add(Settings.set('startLat', ''))
            db.session.add(Settings.set('startLng', ''))
            db.session.add(Settings.set('homeLat', ''))
            db.session.add(Settings.set('homeLng', ''))
            db.session.add(
                Settings.set(
                    'alarms.evalfields',
                    '_bab_\r\n_train_\r\n_street_\r\n_default_city_\r\n_interchange_\r\n_kilometer_\r\n_bma_\r\n_bma_main_\r\n_bma_key_\r\n_train_identifier_'
                ))
            db.session.add(Settings('cartypes', "- [car, '#ffffff']\n"))
            db.session.commit()
Exemplo n.º 14
0
    def __init__(self, app):
        Module.__init__(self, app)
        # add template path
        app.jinja_loader.searchpath.append(
            "%s/emonitor/modules/user/templates" %
            app.config.get('PROJECT_ROOT'))

        babel.gettext(u'module.users')
        babel.gettext(u'userlevel.notset')
        babel.gettext(u'userlevel.admin')
        babel.gettext(u'userlevel.user')
Exemplo n.º 15
0
    def __init__(self, app):
        """
        Add event handler for *script-event*

        :param app: *Flask* app object
        """
        Module.__init__(self, app)

        # eventhandlers
        events.addHandlerClass('*', 'emonitor.modules.scripts.script.Script', Script.handleEvent, ['in.scriptname'])

        # translations
        babel.gettext(u'emonitor.modules.scripts.script.Script')
Exemplo n.º 16
0
    def __init__(self, app):
        """
        Add event handler for *script-event*

        :param app: *Flask* app object
        """
        Module.__init__(self, app)

        # eventhandlers
        events.addHandlerClass('*', 'emonitor.modules.scripts.script.Script',
                               Script.handleEvent, ['in.scriptname'])

        # translations
        babel.gettext(u'emonitor.modules.scripts.script.Script')
Exemplo n.º 17
0
    def __init__(self, app):
        """
        Add specific parameters and configuration to app object

        :param app: flask wsgi application
        """
        Module.__init__(self, app)

        # add template path
        app.jinja_loader.searchpath.append(
            u"{}/emonitor/modules/events/templates".format(
                app.config.get('PROJECT_ROOT')))

        # translations
        babel.gettext(u'module.events')
Exemplo n.º 18
0
    def __init__(self, app):
        """
        Add specific parameters and configuration to app object

        :param app: flask wsgi application
        """
        Module.__init__(self, app)

        # add template path
        app.jinja_loader.searchpath.append(
            u"{}/emonitor/modules/events/templates".format(app.config.get("PROJECT_ROOT"))
        )

        # translations
        babel.gettext(u"module.events")
Exemplo n.º 19
0
 def export_static(filename):
     filename, extension = os.path.splitext(filename)
     try:
         id, template = filename.split('-')
         if extension not in ['.pdf', '.html', '.png']:
             abort(404)
         elif extension == '.pdf':
             return Response(Module.getPdf(
                 Alarm.getExportData('.html',
                                     id=id,
                                     style=template,
                                     args=request.args)),
                             mimetype="application/pdf")
         elif extension == '.html':
             return Response(Alarm.getExportData(extension,
                                                 id=id,
                                                 style=template,
                                                 args=request.args),
                             mimetype="text/html")
         elif extension == '.png':
             return Response(Alarm.getExportData(extension,
                                                 id=id,
                                                 style=template,
                                                 filename=filename,
                                                 args=request.args),
                             mimetype="image/png")
     except ValueError:
         return abort(404)
Exemplo n.º 20
0
    def doPrint(self, **params):
        """
        Start printout of defined object

        :param params: checks for *alarmid*
        """
        from emonitor import app
        pl = PrintLayout('{}.{}'.format(self.module, self.layout))
        _params = {}
        for p in pl.getParameters(self.settings[1].split(
                ';')):  # load parameters from printer definition
            _params[p.getFullName()] = p.getFormatedValue()
        tmpfilename = random.random()
        callstring = self.getCallString(pdffilename='{}{}.pdf'.format(
            app.config.get('PATH_TMP'), tmpfilename),
                                        **params)
        if "id" in params:
            with app.test_request_context('/', method='get'):
                with open(
                        '{}{}.pdf'.format(app.config.get('PATH_TMP'),
                                          tmpfilename), 'wb') as tmpfile:
                    _params['id'] = params['id']
                    _params['style'] = self.layout[6:-5]
                    tmpfile.write(
                        Module.getPdf(params['object'].getExportData(
                            '.html', **_params)))
            try:
                subprocess.check_output(callstring,
                                        stderr=subprocess.STDOUT,
                                        shell=True)
                os.remove('{}{}.pdf'.format(app.config.get('PATH_TMP'),
                                            tmpfilename))
            except WindowsError:
                pass
Exemplo n.º 21
0
    def __init__(self, app):
        Module.__init__(self, app)
        # add template path
        app.jinja_loader.searchpath.append("%s/emonitor/modules/settings/templates" % app.config.get("PROJECT_ROOT"))

        # subnavigation
        self.adminsubnavigation = [
            ("/admin/settings", "settings.main"),
            ("/admin/settings/department", "module.settings.department"),
            ("/admin/settings/cars", "module.settings.cars"),
            ("/admin/settings/start", "module.settings.start"),
        ]

        # static folders
        @app.route("/settings/inc/<path:filename>")
        def settings_static(filename):
            return send_from_directory("%s/emonitor/modules/settings/inc/" % app.config.get("PROJECT_ROOT"), filename)

        # translations
        babel.gettext(u"module.settings")
        babel.gettext(u"settings.main")
        babel.gettext(u"module.settings.department")
        babel.gettext(u"module.settings.cars")
        babel.gettext(u"module.settings.start")

        babel.gettext(u"settings.pathtype.pathdone")
        babel.gettext(u"settings.pathtype.pathtmp")
        babel.gettext(u"settings.pathtype.pathdata")
        babel.gettext(u"settings.pathtype.pathincome")

        # add default values
        if Settings.query.count() == 0:  # add default values
            db.session.add(Settings.set("defaultZoom", 15))
            db.session.add(Settings.set("startLat", ""))
            db.session.add(Settings.set("startLng", ""))
            db.session.add(Settings.set("homeLat", ""))
            db.session.add(Settings.set("homeLng", ""))
            db.session.add(
                Settings.set(
                    "alarms.evalfields",
                    "_bab_\r\n_train_\r\n_street_\r\n_default_city_\r\n_interchange_\r\n_kilometer_\r\n_bma_\r\n_bma_main_\r\n_bma_key_\r\n_train_identifier_",
                )
            )
            db.session.add(Settings("cartypes", "- [car, '#ffffff']\n"))
            db.session.commit()
Exemplo n.º 22
0
    def __init__(self, app):
        Module.__init__(self, app)
        # add template path
        app.jinja_loader.searchpath.append(u"{}/emonitor/modules/alarmobjects/templates".format(app.config.get('PROJECT_ROOT')))

        # subnavigation
        self.adminsubnavigation = [(u'/admin/alarmobjects', u'module.alarmobjects.base'), (u'/admin/alarmobjects/types', u'module.alarmobjects.types'), (u'/admin/alarmobjects/fields', u'module.alarmobjects.fields')]

        # translations
        babel.gettext(u'module.alarmobjects')
        babel.gettext(u'module.alarmobjects.base')
        babel.gettext(u'module.alarmobjects.types')
        babel.gettext(u'module.alarmobjects.fields')

        @app.route('/alarmobjects/file/<path:filename>')  # filename = [id]-[filensme].ext
        def objectfile_static(filename):
            id, name = filename.split('-')
            alarmobjectfile = AlarmObjectFile.getFile(id=id, filename=name)
            return send_from_directory(u'{}alarmobjects/{}/'.format(current_app.config.get('PATH_DATA'), id), alarmobjectfile.filename)
Exemplo n.º 23
0
    def __init__(self, app):
        """
        Add specific parameters and configuration to app object

        :param app: flask wsgi application
        """
        Module.__init__(self, app)
        # add template path
        app.jinja_loader.searchpath.append("%s/emonitor/modules/cars/templates" % app.config.get('PROJECT_ROOT'))

        self.widgets = [CarWidget('cars')]

        # create database tables
        from emonitor.modules.cars.car import Car
        #classes.add('car', Car)
        #db.create_all()

        # translations
        babel.gettext(u'module.cars')
        babel.gettext(u'cars')
Exemplo n.º 24
0
    def __init__(self, app):
        """
        Add specific parameters and configuration to app object

        :param app: flask wsgi application
        """
        Module.__init__(self, app)

        # add template path
        app.jinja_loader.searchpath.append("%s/emonitor/modules/mapitems/templates" % app.config.get('PROJECT_ROOT'))

        # static folders
        @app.route('/mapitem/inc/<path:filename>')
        def mapitm_static(filename):
            return send_from_directory("%s/emonitor/modules/mapitem/inc/" % app.config.get('PROJECT_ROOT'), filename)

        # translations
        babel.gettext(u'module.mapitems')
        babel.gettext(u'module.mapitems.definition')
        babel.gettext(u'mapitems.definition')
Exemplo n.º 25
0
    def __init__(self, app):
        Module.__init__(self, app)
        # add template path
        app.jinja_loader.searchpath.append("%s/emonitor/modules/settings/templates" % app.config.get('PROJECT_ROOT'))

        self.widgets = [CrestWidget('departmentcrest')]

        # subnavigation
        self.adminsubnavigation = [('/admin/settings', 'settings.main'), ('/admin/settings/department', 'module.settings.department'), ('/admin/settings/cars', 'module.settings.cars'), ('/admin/settings/communication', 'module.settings.communication'), ('/admin/settings/start', 'module.settings.start')]

        # static folders
        @app.route('/settings/inc/<path:filename>')
        def settings_static(filename):
            return send_from_directory("%s/emonitor/modules/settings/inc/" % app.config.get('PROJECT_ROOT'), filename)
            
        # translations
        babel.gettext(u'module.settings')
        babel.gettext(u'settings.main')
        babel.gettext(u'module.settings.department')
        babel.gettext(u'module.settings.cars')
        babel.gettext(u'module.settings.communication')
        babel.gettext(u'module.settings.start')

        babel.gettext(u'settings.pathtype.pathdone')
        babel.gettext(u'settings.pathtype.pathtmp')
        babel.gettext(u'settings.pathtype.pathdata')
        babel.gettext(u'settings.pathtype.pathincome')

        babel.gettext(u'departmentcrest')
        babel.gettext(u'telegram.default.welcomemsg')

        # add default values
        if Settings.query.count() == 0:  # add default values
            db.session.add(Settings.set('defaultZoom', 15))
            db.session.add(Settings.set('startLat', ''))
            db.session.add(Settings.set('startLng', ''))
            db.session.add(Settings.set('homeLat', ''))
            db.session.add(Settings.set('homeLng', ''))
            db.session.add(Settings.set('alarms.evalfields', '_bab_\r\n_train_\r\n_street_\r\n_default_city_\r\n_interchange_\r\n_kilometer_\r\n_bma_\r\n_bma_main_\r\n_bma_key_\r\n_train_identifier_'))
            db.session.add(Settings('cartypes', "- [car, '#ffffff']\n"))
            db.session.commit()
Exemplo n.º 26
0
    def __init__(self, app):
        Module.__init__(self, app)
        # add template path
        app.jinja_loader.searchpath.append(u"{}/emonitor/modules/streets/templates".format(app.config.get('PROJECT_ROOT')))

        # subnavigation
        self.widgets = [StreetWidget('streets_street')]

        signal.addSignal('housenumber', 'osm')
        signal.connect('housenumber', 'osm', adminHousenumberHandler.handleOSMChanged)
        signal.connect('housenumber', 'osmdone', adminHousenumberHandler.handleOSMDone)

        # static folders
        @app.route('/streets/inc/<path:filename>')
        def streets_static(filename):
            return send_from_directory(u"{}/emonitor/modules/streets/inc/".format(app.config.get('PROJECT_ROOT')), filename)
            
        # translations
        babel.gettext(u'module.streets')
        babel.gettext(u'module.streets.0')
        babel.gettext(u'streets_street')  # widget name
Exemplo n.º 27
0
    def __init__(self, app):
        Module.__init__(self, app)

        # add template path
        app.jinja_loader.searchpath.append(
            "%s/emonitor/modules/monitors/templates" %
            app.config.get('PROJECT_ROOT'))

        # subnavigation
        self.adminsubnavigation = [
            ('/admin/monitors', 'monitors.definition'),
            ('/admin/monitors/style', 'module.monitors.style'),
            ('/admin/monitors/current', 'module.monitors.current'),
            ('/admin/monitors/actions', 'module.monitors.actions')
        ]
        self.widgets = [PlaceholderWidget('placeholder')]

        signal.connect('monitorserver', 'clientsearchdone',
                       frontendMonitorHandler.handleClientSearch)
        signal.connect('monitorserver', 'clientanswer',
                       frontendMonitorHandler.handleClientAnswer)

        # static folders
        @app.route('/monitors/inc/<path:filename>')
        def monitors_static(filename):
            return send_from_directory(
                "%s/emonitor/modules/monitors/inc/" %
                app.config.get('PROJECT_ROOT'), filename)

        # translations
        babel.gettext(u'module.monitors')
        babel.gettext(u'monitors.definition')
        babel.gettext(u'module.monitors.style')
        babel.gettext(u'module.monitors.current')
        babel.gettext(u'module.monitors.actions')
        babel.gettext(u'monitors.landscape')
        babel.gettext(u'monitors.portrait')
        babel.gettext(u'monitors.orientation.0')
        babel.gettext(u'monitors.orientation.1')
        babel.gettext(u'placeholder')
Exemplo n.º 28
0
    def __init__(self, app):
        """
        Add specific parameters and configuration to app object

        :param app: flask wsgi application
        """
        Module.__init__(self, app)
        # add template path
        app.jinja_loader.searchpath.append(
            "%s/emonitor/modules/cars/templates" %
            app.config.get('PROJECT_ROOT'))

        self.widgets = [CarWidget('cars')]

        # create database tables
        from emonitor.modules.cars.car import Car
        #classes.add('car', Car)
        #db.create_all()

        # translations
        babel.gettext(u'module.cars')
        babel.gettext(u'cars')
Exemplo n.º 29
0
 def export_static(filename):
     filename, extension = os.path.splitext(filename)
     try:
         id, template = filename.split('-')
         if extension not in ['.pdf', '.html', '.png']:
             abort(404)
         elif extension == '.pdf':
             return Response(Module.getPdf(Alarm.getExportData('.html', id=id, style=template, args=request.args)), mimetype="application/pdf")
         elif extension == '.html':
             return Response(Alarm.getExportData(extension, id=id, style=template, args=request.args), mimetype="text/html")
         elif extension == '.png':
             return Response(Alarm.getExportData(extension, id=id, style=template, filename=filename, args=request.args), mimetype="image/png")
     except ValueError:
         return abort(404)
Exemplo n.º 30
0
    def __init__(self, app):
        """
        Add specific parameters and configuration to app object

        :param app: flask wsgi application
        """
        Module.__init__(self, app)
        
        # add template path
        app.jinja_loader.searchpath.append(u"{}/emonitor/modules/alarmkeys/templates".format(app.config.get('PROJECT_ROOT')))

        # create database tables
        from alarmkey import Alarmkey
        from alarmkeycar import AlarmkeyCars

        # static folders
        @app.route('/alarmkeys/inc/<path:filename>')
        def alarmkeys_static(filename):
            return send_from_directory(u"{}/emonitor/modules/alarmkeys/inc/".format(app.config.get('PROJECT_ROOT')), filename)
            
        babel.gettext(u'module.alarmkeys')
        babel.gettext(u'alarmkeys.upload.states0')
        babel.gettext(u'alarmkeys.upload.states1')
        babel.gettext(u'alarmkeys.upload.states-1')
Exemplo n.º 31
0
    def __init__(self, app):
        """
        Add specific parameters and configuration to app object

        :param app: flask wsgi application
        """
        Module.__init__(self, app)

        # add template path
        app.jinja_loader.searchpath.append(
            "%s/emonitor/modules/mapitems/templates" %
            app.config.get('PROJECT_ROOT'))

        # static folders
        @app.route('/mapitem/inc/<path:filename>')
        def mapitm_static(filename):
            return send_from_directory(
                "%s/emonitor/modules/mapitem/inc/" %
                app.config.get('PROJECT_ROOT'), filename)

        # translations
        babel.gettext(u'module.mapitems')
        babel.gettext(u'module.mapitems.definition')
        babel.gettext(u'mapitems.definition')
Exemplo n.º 32
0
    def doPrint(self, **params):
        """
        Start printout of defined object

        :param params: checks for *alarmid*
        """
        from emonitor import app
        pl = PrintLayout('{}.{}'.format(self.module, self.layout))
        _params = {}
        for p in pl.getParameters(self.settings[1].split(';')):  # load parameters from printer definition
            _params[p.getFullName()] = p.getFormatedValue()
        tmpfilename = random.random()
        callstring = self.getCallString(pdffilename='{}{}.pdf'.format(app.config.get('PATH_TMP'), tmpfilename), **params)
        if "id" in params:
            with app.test_request_context('/', method='get'):
                with open('{}{}.pdf'.format(app.config.get('PATH_TMP'), tmpfilename), 'wb') as tmpfile:
                    _params['id'] = params['id']
                    _params['style'] = self.layout[6:-5]
                    tmpfile.write(Module.getPdf(params['object'].getExportData('.html', **_params)))
            try:
                subprocess.check_output(callstring, stderr=subprocess.STDOUT, shell=True)
                os.remove('{}{}.pdf'.format(app.config.get('PATH_TMP'), tmpfilename))
            except WindowsError:
                pass
Exemplo n.º 33
0
 def __init__(self, app):
     Module.__init__(self, app)
     babel.gettext(u'module.startpages')
     babel.gettext(u'emonitor.communication.Communication')
Exemplo n.º 34
0
 def __init__(self, app):
     Module.__init__(self, app)
     babel.gettext(u'module.startpages')
Exemplo n.º 35
0
 def __init__(self, app):
     Module.__init__(self, app)
     babel.gettext(u"module.startpages")
     babel.gettext(u"emonitor.communication.Communication")
Exemplo n.º 36
0
    def __init__(self, app):
        """
        Add specific parameters and configuration to app object

        :param app: flask wsgi application
        """
        Module.__init__(self, app)
        # add template path
        app.jinja_loader.searchpath.append(
            "{}/emonitor/modules/alarms/templates".format(
                app.config.get('PROJECT_ROOT')))

        # subnavigation
        self.adminsubnavigation = [
            ('/admin/alarms', 'alarms.base'),
            ('/admin/alarms/types', 'module.alarms.types'),
            ('/admin/alarms/report', 'module.alarms.report'),
            ('/admin/alarms/config', 'module.alarms.config'),
            ('/admin/alarms/test', 'module.alarms.test')
        ]

        # create database tables
        from emonitor.modules.alarms.alarm import Alarm
        from emonitor.modules.alarms.alarmhistory import AlarmHistory
        from emonitor.modules.alarms.alarmattribute import AlarmAttribute
        from emonitor.modules.alarms.alarmsection import AlarmSection
        from emonitor.modules.alarms.alarmtype import AlarmType

        self.widgets = [
            AlarmIncomeWidget('alarms_income'),
            AlarmWidget('alarms'),
            AlarmTimerWidget('alarms_timer'),
            AlarmRemarkWidget('alarms_remark')
        ]

        # eventhandlers
        for f in [
                f for f in os.listdir('{}/emonitor/modules/alarms/inc/'.format(
                    app.config.get('PROJECT_ROOT'))) if f.endswith('.py')
        ]:
            if not f.startswith('__'):
                cls = imp.load_source(
                    'emonitor.modules.alarms.inc',
                    '{}/emonitor/modules/alarms/inc/{}'.format(
                        app.config.get('PROJECT_ROOT'), f))
                checker = getattr(cls, cls.__all__[0])()
                if isinstance(checker,
                              AlarmFaxChecker) and checker.getId() != 'Dummy':
                    for at in AlarmType.getAlarmTypes():
                        if at.interpreter == f:
                            events.addEvent('alarm_added.{}'.format(at.name),
                                            handlers=[],
                                            parameters=['out.alarmid'])
                            events.addEvent(
                                'alarm_changestate.{}'.format(at.name),
                                handlers=[],
                                parameters=['out.alarmid', 'out.state'])

        events.addEvent('alarm_added', handlers=[],
                        parameters=['out.alarmid'])  # for all checkers
        events.addEvent('alarm_changestate',
                        handlers=[],
                        parameters=['out.alarmid',
                                    'out.state'])  # for all checkers

        events.addHandlerClass('file_added',
                               'emonitor.modules.alarms.alarm.Alarms',
                               Alarm.handleEvent,
                               ['in.text', 'out.id', 'out.fields'])
        events.addHandlerClass('file_added',
                               'emonitor.modules.alarms.alarmtype.AlarmTypes',
                               AlarmType.handleEvent, ['in.text', 'out.type'])

        events.addHandlerClass('incoming_serial_data',
                               'emonitor.modules.alarms.alarm.Alarms',
                               Alarm.handleSerialEvent,
                               ['in.text', 'out.id', 'out.fields'])
        events.addHandlerClass('incoming_serial_data',
                               'emonitor.modules.alarms.alarmtype.AlarmTypes',
                               AlarmType.handleEvent, ['in.text', 'out.type'])

        # signals and handlers
        signal.addSignal('alarm', 'changestate')
        signal.addSignal('alarm', 'added')
        signal.addSignal('alarm', 'updated')
        signal.addSignal('alarm', 'error')
        signal.connect('alarm', 'changestate',
                       frontendAlarmHandler.handleAlarmChanges)
        signal.connect('alarm', 'added',
                       frontendAlarmHandler.handleAlarmChanges)
        signal.connect('alarm', 'updated',
                       frontendAlarmHandler.handleAlarmChanges)
        signal.connect('alarm', 'deleted',
                       frontendAlarmHandler.handleAlarmChanges)
        signal.connect('alarm', 'error',
                       frontendAlarmHandler.handleAlarmErrors)

        signal.connect('alarm', 'testupload_start',
                       adminAlarmHandler.handleAlarmTestUpload)

        # static folders
        @app.route('/alarms/inc/<path:filename>')
        def alarms_static(filename):
            if filename.startswith('sample_'):  # deliver sample checker file
                clsname = filename.split('_')[1]
                return Response(AlarmType.getAlarmTypes(
                    clsname).interpreterclass().getSampleLayout(),
                                mimetype="image/jpeg")

            return send_from_directory(
                "{}/emonitor/modules/alarms/inc/".format(
                    app.config.get('PROJECT_ROOT')), filename)

        @app.route('/alarms/export/<path:filename>'
                   )  # filename = [id]-[style].pdf
        def export_static(filename):
            filename, extension = os.path.splitext(filename)
            try:
                id, template = filename.split('-')
                if extension not in ['.pdf', '.html', '.png']:
                    abort(404)
                elif extension == '.pdf':
                    return Response(Module.getPdf(
                        Alarm.getExportData('.html',
                                            id=id,
                                            style=template,
                                            args=request.args)),
                                    mimetype="application/pdf")
                elif extension == '.html':
                    return Response(Alarm.getExportData(extension,
                                                        id=id,
                                                        style=template,
                                                        args=request.args),
                                    mimetype="text/html")
                elif extension == '.png':
                    return Response(Alarm.getExportData(extension,
                                                        id=id,
                                                        style=template,
                                                        filename=filename,
                                                        args=request.args),
                                    mimetype="image/png")
            except ValueError:
                return abort(404)

        # add reportfolder
        if not os.path.exists('{}/alarmreports/'.format(
                app.config.get('PATH_DATA'))):
            os.makedirs('{}/alarmreports/'.format(app.config.get('PATH_DATA')))

        # translations
        babel.gettext(u'module.alarms')
        babel.gettext(u'alarms.base')
        babel.gettext(u'module.alarms.types')
        babel.gettext(u'module.alarms.report')
        babel.gettext(u'module.alarms.config')
        babel.gettext(u'module.alarms.test')
        babel.gettext(u'alarms_income')
        babel.gettext(u'alarms_timer')
        babel.gettext(u'alarms_remark')
        babel.gettext(u'alarms')
        babel.gettext(u'alarms.prio0')
        babel.gettext(u'alarms.prio1')
        babel.gettext(u'alarms.prio2')
        babel.gettext(u'emonitor.modules.alarms.alarm.Alarms')
        babel.gettext(u'emonitor.modules.alarms.alarmtype.AlarmTypes')
        babel.gettext(u'alarms.test.protocol')
        babel.gettext(u'alarms.test.result')
        babel.gettext(u'alarmstate.active')
        babel.gettext(u'alarmstate.created')
        babel.gettext(u'alarmstate.done')
        babel.gettext(u'alarmstate.archive')
        babel.gettext(u'active')
        babel.gettext(u'created')
        babel.gettext(u'done')
        babel.gettext(u'archive')
        babel.gettext(u'alarms.statechangeactivated')
        babel.gettext(u'alarms.prioshort0')
        babel.gettext(u'alarms.prioshort1')
        babel.gettext(u'alarms.prioshort2')
        babel.gettext(u'alarms.carsinuse')
        babel.gettext(u'history.autochangeState')
        babel.gettext(u'history.message')
        babel.gettext(u'trigger.alarm_added')
        babel.gettext(u'trigger.alarm_changestate')

        babel.gettext(u'trigger.alarm_added_sub')
        babel.gettext(u'trigger.alarm_changestate_sub')

        babel.gettext(u'alarms.print.slightleft')
        babel.gettext(u'alarms.print.slightright')
        babel.gettext(u'alarms.print.right')
        babel.gettext(u'alarms.print.left')
        babel.gettext(u'alarms.print.straight')
        babel.gettext(u'alarms.print.exit')
        babel.gettext(u'alarms.print.bus')
        babel.gettext(u'alarms.print.positive')
        babel.gettext(u'alarms.print.negative')

        babel.gettext(u'alarms.filter.0')
        babel.gettext(u'alarms.filter.1')
        babel.gettext(u'alarms.filter.7')
        babel.gettext(u'alarms.filter.31')

        babel.gettext(u'internal')
        babel.gettext(u'external')

        babel.gettext(u'AFAlerting')
        babel.gettext(u'AFCars')
        babel.gettext(u'AFMaterial')
        babel.gettext(u'AFReport')
        babel.gettext(u'AFTime')
        babel.gettext(u'AFDamage')
        babel.gettext(u'AFOthers')
        babel.gettext(u'AFPersons')

        babel.gettext(u'alarms.fields.simple')
        babel.gettext(u'alarms.fields.extended')
        babel.gettext(u'alarms.fields.persons.field.sum')
        babel.gettext(u'alarms.fields.persons.field.house')
        babel.gettext(u'alarms.fields.persons.field.pa_alarm')
        babel.gettext(u'alarms.fields.persons.field.el')
        babel.gettext(u'alarms.fields.persons.field.alarm')
        babel.gettext(u'alarms.fields.persons.field.pa')
        babel.gettext(u'alarms.fields.persons.field.pa_house')
        babel.gettext(u'alarms.fields.persons.field.elgrade')
        babel.gettext(u'alarms.fields.persons.field.style.simple')
        babel.gettext(u'alarms.fields.persons.field.style.extended')

        # init
        # Do init script for alarms at start and add alarms (state = 1 or 2) (active or done)
        for aalarm in Alarm.query.filter(Alarm.state == 1
                                         or Alarm.state == 2).all():
            aalarm.updateSchedules(reference=1)
Exemplo n.º 37
0
    def __init__(self, app):
        """
        Add specific parameters and configuration to app object

        :param app: flask wsgi application
        """
        Module.__init__(self, app)
        # add template path
        app.jinja_loader.searchpath.append("{}/emonitor/modules/alarms/templates".format(app.config.get('PROJECT_ROOT')))

        # subnavigation
        self.adminsubnavigation = [('/admin/alarms', 'alarms.base'), ('/admin/alarms/types', 'module.alarms.types'), ('/admin/alarms/report', 'module.alarms.report'), ('/admin/alarms/config', 'module.alarms.config'), ('/admin/alarms/test', 'module.alarms.test')]
        
        # create database tables
        from emonitor.modules.alarms.alarm import Alarm
        from emonitor.modules.alarms.alarmhistory import AlarmHistory
        from emonitor.modules.alarms.alarmattribute import AlarmAttribute
        from emonitor.modules.alarms.alarmsection import AlarmSection
        from emonitor.modules.alarms.alarmtype import AlarmType

        self.widgets = [AlarmIncomeWidget('alarms_income'), AlarmWidget('alarms'), AlarmTimerWidget('alarms_timer'), AlarmRemarkWidget('alarms_remark')]
        
        # eventhandlers
        for f in [f for f in os.listdir('{}/emonitor/modules/alarms/inc/'.format(app.config.get('PROJECT_ROOT'))) if f.endswith('.py')]:
            if not f.startswith('__'):
                cls = imp.load_source('emonitor.modules.alarms.inc', '{}/emonitor/modules/alarms/inc/{}'.format(app.config.get('PROJECT_ROOT'), f))
                checker = getattr(cls, cls.__all__[0])()
                if isinstance(checker, AlarmFaxChecker) and checker.getId() != 'Dummy':
                    events.addEvent('alarm_added.{}'.format(checker.getId()), handlers=[], parameters=['out.alarmid'])
                    events.addEvent('alarm_changestate.{}'.format(checker.getId()), handlers=[], parameters=['out.alarmid', 'out.state'])

        events.addEvent('alarm_added', handlers=[], parameters=['out.alarmid'])  # for all checkers
        events.addEvent('alarm_changestate', handlers=[], parameters=['out.alarmid', 'out.state'])  # for all checkers
        
        events.addHandlerClass('file_added', 'emonitor.modules.alarms.alarm.Alarms', Alarm.handleEvent, ['in.text', 'out.id', 'out.fields'])
        events.addHandlerClass('file_added', 'emonitor.modules.alarms.alarmtype.AlarmTypes', AlarmType.handleEvent, ['in.text', 'out.type'])

        # signals and handlers
        signal.addSignal('alarm', 'changestate')
        signal.addSignal('alarm', 'added')
        signal.addSignal('alarm', 'updated')
        signal.connect('alarm', 'changestate', frontendAlarmHandler.handleAlarmChanges)
        signal.connect('alarm', 'added', frontendAlarmHandler.handleAlarmChanges)
        signal.connect('alarm', 'updated', frontendAlarmHandler.handleAlarmChanges)
        signal.connect('alarm', 'deleted', frontendAlarmHandler.handleAlarmChanges)

        signal.connect('alarm', 'testupload_start', adminAlarmHandler.handleAlarmTestUpload)

        # static folders
        @app.route('/alarms/inc/<path:filename>')
        def alarms_static(filename):
            return send_from_directory("{}/emonitor/modules/alarms/inc/".format(app.config.get('PROJECT_ROOT')), filename)

        @app.route('/alarms/export/<path:filename>')  # filename = [id]-[style].pdf
        def export_static(filename):
            filename, extension = os.path.splitext(filename)
            try:
                id, template = filename.split('-')
                if extension not in ['.pdf', '.html', '.png']:
                    abort(404)
                elif extension == '.pdf':
                    return Response(Module.getPdf(Alarm.getExportData('.html', id=id, style=template, args=request.args)), mimetype="application/pdf")
                elif extension == '.html':
                    return Response(Alarm.getExportData(extension, id=id, style=template, args=request.args), mimetype="text/html")
                elif extension == '.png':
                    return Response(Alarm.getExportData(extension, id=id, style=template, filename=filename, args=request.args), mimetype="image/png")
            except ValueError:
                return abort(404)

        # add reportfolder
        if not os.path.exists('{}/alarmreports/'.format(app.config.get('PATH_DATA'))):
            os.makedirs('{}/alarmreports/'.format(app.config.get('PATH_DATA')))
            
        # translations
        babel.gettext(u'module.alarms')
        babel.gettext(u'alarms.base')
        babel.gettext(u'module.alarms.types')
        babel.gettext(u'module.alarms.report')
        babel.gettext(u'module.alarms.config')
        babel.gettext(u'module.alarms.test')
        babel.gettext(u'alarms_income')
        babel.gettext(u'alarms_timer')
        babel.gettext(u'alarms_remark')
        babel.gettext(u'alarms')
        babel.gettext(u'alarms.prio0')
        babel.gettext(u'alarms.prio1')
        babel.gettext(u'alarms.prio2')
        babel.gettext(u'emonitor.modules.alarms.alarm.Alarms')
        babel.gettext(u'emonitor.modules.alarms.alarmtype.AlarmTypes')
        babel.gettext(u'alarms.test.protocol')
        babel.gettext(u'alarms.test.result')
        babel.gettext(u'alarmstate.active')
        babel.gettext(u'alarmstate.created')
        babel.gettext(u'alarmstate.done')
        babel.gettext(u'alarmstate.archive')
        babel.gettext(u'active')
        babel.gettext(u'created')
        babel.gettext(u'done')
        babel.gettext(u'archive')
        babel.gettext(u'alarms.statechangeactivated')
        babel.gettext(u'alarms.prioshort0')
        babel.gettext(u'alarms.prioshort1')
        babel.gettext(u'alarms.prioshort2')
        babel.gettext(u'alarms.carsinuse')
        babel.gettext(u'history.autochangeState')
        babel.gettext(u'history.message')
        babel.gettext(u'trigger.alarm_added')
        babel.gettext(u'trigger.alarm_changestate')

        babel.gettext(u'trigger.alarm_added_sub')
        babel.gettext(u'trigger.alarm_changestate_sub')

        babel.gettext(u'alarms.print.slightleft')
        babel.gettext(u'alarms.print.slightright')
        babel.gettext(u'alarms.print.right')
        babel.gettext(u'alarms.print.left')
        babel.gettext(u'alarms.print.straight')
        babel.gettext(u'alarms.print.exit')
        babel.gettext(u'alarms.print.bus')
        babel.gettext(u'alarms.print.positive')
        babel.gettext(u'alarms.print.negative')

        babel.gettext(u'alarms.filter.0')
        babel.gettext(u'alarms.filter.1')
        babel.gettext(u'alarms.filter.7')
        babel.gettext(u'alarms.filter.31')

        babel.gettext(u'internal')
        babel.gettext(u'external')

        babel.gettext(u'AFAlerting')
        babel.gettext(u'AFCars')
        babel.gettext(u'AFMaterial')
        babel.gettext(u'AFReport')
        babel.gettext(u'AFTime')
        babel.gettext(u'AFDamage')
        babel.gettext(u'AFOthers')
        babel.gettext(u'AFPersons')

        babel.gettext(u'alarms.fields.simple')
        babel.gettext(u'alarms.fields.extended')
        babel.gettext(u'alarms.fields.persons.field.sum')
        babel.gettext(u'alarms.fields.persons.field.house')
        babel.gettext(u'alarms.fields.persons.field.pa_alarm')
        babel.gettext(u'alarms.fields.persons.field.el')
        babel.gettext(u'alarms.fields.persons.field.alarm')
        babel.gettext(u'alarms.fields.persons.field.pa')
        babel.gettext(u'alarms.fields.persons.field.pa_house')
        babel.gettext(u'alarms.fields.persons.field.elgrade')
        babel.gettext(u'alarms.fields.persons.field.style.simple')
        babel.gettext(u'alarms.fields.persons.field.style.extended')

        # init
        # Do init script for alarms at start and add alarms (state = 1 or 2) (active or done)
        for aalarm in Alarm.query.filter(Alarm.state in [1, 2]).all():
            aalarm.updateSchedules(reference=1)