コード例 #1
0
ファイル: main.py プロジェクト: Bugsbane/genesis
 def get_ui(self):
     ui = self.app.inflate('sysconfig:main')
     systime = SystemTime.get_datetime('%s, %s' \
         % (self.app.gconfig.get('genesis', 'dformat', '%d %b %Y'), 
             self.app.gconfig.get('genesis', 'tformat', '%H:%M')))
     offset = 0
     try:
         offset = SystemTime.get_offset()
     except Exception, e:
         self.app.log.error('Could not get Internet time. Please check your connection. Error: %s' % str(e))
         self.put_message('err', 'Could not get Internet time. Please check your connection.')
コード例 #2
0
ファイル: main.py プロジェクト: ardnet/genesis
 def get_ui(self):
     ui = self.app.inflate('sysconfig:main')
     systime = SystemTime.get_datetime('%s, %s' \
         % (self.app.gconfig.get('genesis', 'dformat', '%d %b %Y'),
             self.app.gconfig.get('genesis', 'tformat', '%H:%M')))
     offset = 0
     try:
         offset = SystemTime.get_offset()
     except Exception, e:
         self.app.log.error(
             'Could not get Internet time. Please check your connection. Error: %s'
             % str(e))
         self.put_message(
             'err',
             'Could not get Internet time. Please check your connection.')
コード例 #3
0
ファイル: main.py プロジェクト: gzsombor/genesis
class SysConfigPlugin(CategoryPlugin):
    text = 'System Settings'
    iconfont = 'gen-cog'
    folder = False

    def on_init(self):
        self._mgr = self.app.get_backend(apis.services.IServiceManager)
        self._be = backend.Config(self.app)
        self._st = SystemTime()
        self.hostname = self._be.gethostname()

    def get_ui(self):
        ui = self.app.inflate('sysconfig:main')
        systime = self._st.get_datetime('%d %B %Y, %H:%M:%S')
        offset = 0
        try:
            offset = self._st.get_offset()
        except Exception, e:
            self.app.log.error('Could not get Internet time. Please check your connection. Error: %s' % str(e))
            self.put_message('err', 'Could not get Internet time. Please check your connection.')

        # General
        ui.find('hostname').set('value', self.hostname)
        if os.path.exists('/etc/localtime'):
            tz_active = os.path.realpath('/etc/localtime').split('/usr/share/zoneinfo/')[1]
        tz_sel = [UI.SelectOption(text=x, value=x, 
            selected=True if tz_active in x else False)
            for x in zonelist.zones]
        ui.appendAll('zoneselect', *tz_sel)

        # Time
        ui.find('systime').set('text', systime)
        ui.find('offset').set('text', '%s seconds' % offset)

        # Tools
        if shell_cs('which logrunnerd')[0] != 0:
            lrstat = 'Not installed'
        else:
            if self._mgr.get_status('logrunner') == 'running':
                lrstat = 'Running'
                ui.find('fllogrunner').append(UI.Button(text="Stop", id="svc/logrunner/stop"))
            else:
                lrstat = 'Not running'
                ui.find('fllogrunner').append(UI.Button(text="Start", id="svc/logrunner/start"))
            if self._mgr.get_enabled('logrunner') == 'enabled':
                lrstat += ' and enabled on boot'
                ui.find('fllogrunner').append(UI.Button(text="Disable on boot", id="svc/logrunner/disable"))
            else:
                lrstat += ' and not enabled on boot'
                ui.find('fllogrunner').append(UI.Button(text="Enable on boot", id="svc/logrunner/enable"))
        if shell_cs('which beacond')[0] != 0:
            bestat = 'Not installed'
        else:
            if self._mgr.get_status('beacon') == 'running':
                lrstat = 'Running'
                ui.find('flbeacon').append(UI.Button(text="Stop", id="svc/beacon/stop"))
            else:
                lrstat = 'Not running'
                ui.find('flbeacon').append(UI.Button(text="Start", id="svc/beacon/start"))
            if self._mgr.get_enabled('beacon') == 'enabled':
                lrstat += ' and enabled on boot'
                ui.find('flbeacon').append(UI.Button(text="Disable on boot", id="svc/beacon/disable"))
            else:
                lrstat += ' and not enabled on boot'
                ui.find('flbeacon').append(UI.Button(text="Enable on boot", id="svc/beacon/enable"))
        ui.find('logrunner').set('text', lrstat)
        ui.find('beacon').set('text', bestat)

        if self._changed:
            self.put_message('warn', 'A restart is required for this setting change to take effect.')

        return ui
コード例 #4
0
ファイル: main.py プロジェクト: tewe/genesis
class SysConfigPlugin(CategoryPlugin):
    text = 'System Settings'
    iconfont = 'gen-cog'
    folder = False

    def on_init(self):
        self._mgr = self.app.get_backend(apis.services.IServiceManager)
        self._be = backend.Config(self.app)
        self._st = SystemTime()
        self.hostname = self._be.gethostname()

    def get_ui(self):
        ui = self.app.inflate('sysconfig:main')
        systime = self._st.get_datetime('%s, %s' \
            % (self.app.gconfig.get('genesis', 'dformat', '%d %b %Y'),
                self.app.gconfig.get('genesis', 'tformat', '%H:%M')))
        offset = 0
        try:
            offset = self._st.get_offset()
        except Exception, e:
            self.app.log.error(
                'Could not get Internet time. Please check your connection. Error: %s'
                % str(e))
            self.put_message(
                'err',
                'Could not get Internet time. Please check your connection.')

        # General
        ui.find('hostname').set('value', self.hostname)
        tz_active = os.path.realpath('/etc/localtime').split(
            '/usr/share/zoneinfo/')[1] if os.path.exists(
                '/etc/localtime') else ''
        tz_sel = [
            UI.SelectOption(text=x,
                            value=x,
                            selected=True if tz_active in x else False)
            for x in zonelist.zones
        ]
        ui.appendAll('zoneselect', *tz_sel)

        # Time
        ui.find('systime').set('text', systime)
        ui.find('offset').set('text', '%s seconds' % offset)

        # Tools
        if shell_cs('which logrunnerd')[0] != 0:
            lrstat = 'Not installed'
        else:
            if self._mgr.get_status('logrunner') == 'running':
                lrstat = 'Running'
                ui.find('fllogrunner').append(
                    UI.Button(text="Stop", id="svc/logrunner/stop"))
            else:
                lrstat = 'Not running'
                ui.find('fllogrunner').append(
                    UI.Button(text="Start", id="svc/logrunner/start"))
            if self._mgr.get_enabled('logrunner') == 'enabled':
                lrstat += ' and enabled on boot'
                ui.find('fllogrunner').append(
                    UI.Button(text="Disable on boot",
                              id="svc/logrunner/disable"))
            else:
                lrstat += ' and not enabled on boot'
                ui.find('fllogrunner').append(
                    UI.Button(text="Enable on boot",
                              id="svc/logrunner/enable"))
        if shell_cs('which beacond')[0] != 0:
            bestat = 'Not installed'
        else:
            if self._mgr.get_status('beacon') == 'running':
                bestat = 'Running'
                ui.find('flbeacon').append(
                    UI.Button(text="Stop", id="svc/beacon/stop"))
            else:
                bestat = 'Not running'
                ui.find('flbeacon').append(
                    UI.Button(text="Start", id="svc/beacon/start"))
            if self._mgr.get_enabled('beacon') == 'enabled':
                bestat += ' and enabled on boot'
                ui.find('flbeacon').append(
                    UI.Button(text="Disable on boot", id="svc/beacon/disable"))
            else:
                bestat += ' and not enabled on boot'
                ui.find('flbeacon').append(
                    UI.Button(text="Enable on boot", id="svc/beacon/enable"))
        ui.find('logrunner').set('text', lrstat)
        ui.find('beacon').set('text', bestat)

        if self._changed:
            self.put_message(
                'warn',
                'A restart is required for this setting change to take effect.'
            )

        return ui