コード例 #1
0
    def __init__(self):
        stats = SystemStats.get_system_stats()

        parts = []
        if stats.cpu.speed:
            parts.append(stats.cpu.speed)

        if stats.cpu.num:
            if int(stats.cpu.num) > 1:
                parts.append(_("%s Logical Processors") % (stats.cpu.num))
            elif int(stats.cpu.num) == 1:
                parts.append(_("%s Logical Processor") % (stats.cpu.num))

        if stats.cpu.cores:
            if int(stats.cpu.cores) > 1:
                parts.append(_("%s Cores") % (stats.cpu.cores))
            elif int(stats.cpu.cores) == 1:
                parts.append(_("%s Core") % (stats.cpu.cores))

        if parts:
            txt = ', '.join(parts)
        else:
            txt = _('Unknown Processor')

        CTK.RawHTML.__init__(self, txt)
コード例 #2
0
ファイル: SystemStatsWidgets.py プロジェクト: BeQ/webserver
    def __init__ (self):
        stats = SystemStats.get_system_stats()

        parts = []
        if stats.cpu.speed:
            parts.append (stats.cpu.speed)

        if stats.cpu.num:
            if int(stats.cpu.num) > 1:
                parts.append (_("%s Logical Processors") %(stats.cpu.num))
            elif int(stats.cpu.num) == 1:
                parts.append (_("%s Logical Processor") %(stats.cpu.num))

        if stats.cpu.cores:
            if int(stats.cpu.cores) > 1:
                parts.append (_("%s Cores") %(stats.cpu.cores))
            elif int(stats.cpu.cores) == 1:
                parts.append (_("%s Core") %(stats.cpu.cores))

        if parts:
            txt = ', '.join(parts)
        else:
            txt = _('Unknown Processor')

        CTK.RawHTML.__init__ (self, txt)
コード例 #3
0
ファイル: PageIndex.py プロジェクト: 304471720/webserver
    def __init__ (self):
        CTK.Box.__init__ (self, {'id': 'server-section', 'class': 'infosection'})

        infotable = CTK.Table({'class': 'info-table'})
        infotable.set_header (column=True, num=1)

        is_alive = Cherokee.server.is_alive()
        entry = lambda title, string: [CTK.RawHTML (title), CTK.RawHTML(str(string))]

        if is_alive:
            button = CTK.Button(_('Stop Server'), {'id': 'launch-button', 'class': 'button-stop'})
            button.bind ('click', CTK.JS.GotoURL('/stop'))
            infotable += [CTK.RawHTML(_(RUNNING_NOTICE)), button]
        else:
            button = CTK.Button(_('Start Server'), {'id': 'launch-button', 'class': 'button-start'})
            button.bind ('click', CTK.JS.GotoURL('/launch'))
            infotable += [CTK.RawHTML(_(STOPPED_NOTICE)), button]

        sys_stats = SystemStats.get_system_stats()
        infotable += entry(_('Hostname'), sys_stats.hostname)
        if CTK.cfg.file:
            cfg_file = '<span title="%s: %s">%s</span>' % (_('Modified'), self._get_cfg_ctime(), CTK.cfg.file)
        else:
            cfg_file = _('Not found')
        infotable += entry(_("Config File"), cfg_file)

        box = CTK.Box()
        box += infotable

        table = CTK.Table()
        table.set_header (column=True, num=1)
        table += [CTK.RawHTML (_('Server Information')), box]
        self += table
コード例 #4
0
ファイル: PageIndex.py プロジェクト: vlinhd11/webserver
    def __init__ (self):
        CTK.Box.__init__ (self, {'id': 'server-section', 'class': 'infosection'})

        infotable = CTK.Table({'class': 'info-table'})
        infotable.set_header (column=True, num=1)

        is_alive = Cherokee.server.is_alive()
        entry = lambda title, string: [CTK.RawHTML (title), CTK.RawHTML(str(string))]

        if is_alive:
            button = CTK.Button(_('Stop Server'), {'id': 'launch-button', 'class': 'button-stop'})
            button.bind ('click', CTK.JS.GotoURL('/stop'))
            infotable += [CTK.RawHTML(_(RUNNING_NOTICE)), button]
        else:
            button = CTK.Button(_('Start Server'), {'id': 'launch-button', 'class': 'button-start'})
            button.bind ('click', CTK.JS.GotoURL('/launch'))
            infotable += [CTK.RawHTML(_(STOPPED_NOTICE)), button]

        sys_stats = SystemStats.get_system_stats()
        infotable += entry(_('Hostname'), sys_stats.hostname)
        if CTK.cfg.file:
            cfg_file = '<span title="%s: %s">%s</span>' % (_('Modified'), self._get_cfg_ctime(), CTK.cfg.file)
        else:
            cfg_file = _('Not found')
        infotable += entry(_("Config File"), cfg_file)

        box = CTK.Box()
        box += infotable

        table = CTK.Table()
        table.set_header (column=True, num=1)
        table += [CTK.RawHTML (_('Server Information')), box]
        self += table
コード例 #5
0
def SystemStats_JSON():
    stats = SystemStats.get_system_stats()
    return {
        'mem': {
            'used': stats.mem.used,
            'total': stats.mem.total
        },
        'cpu': {
            'usage': stats.cpu.usage,
            'idle': stats.cpu.idle
        }
    }
コード例 #6
0
    def __init__(self):
        CTK.Box.__init__(self, {'class': 'ram-text'})

        stats = SystemStats.get_system_stats()

        if stats.mem.total:
            if stats.mem.total < (1024**2):
                total = "%dMB" % (stats.mem.total / 1024)
            else:
                total = "%.1fGB" % (stats.mem.total / (1024.0**2))
        else:
            total = _('Unknown RAM')

        self += CTK.RawHTML(total)
コード例 #7
0
ファイル: SystemStatsWidgets.py プロジェクト: BeQ/webserver
    def __init__ (self):
        CTK.Box.__init__ (self, {'class': 'ram-text'})

        stats = SystemStats.get_system_stats()

        if stats.mem.total:
            if stats.mem.total < (1024**2):
                total = "%dMB" %(stats.mem.total / 1024)
            else:
                total = "%.1fGB" %(stats.mem.total / (1024.0 ** 2))
        else:
            total = _('Unknown RAM')

        self += CTK.RawHTML (total)
コード例 #8
0
ファイル: server.py プロジェクト: Daniel15/webserver
            if not os.path.isdir (CHEROKEE_OWS_ROOT):
                try: os.makedirs (CHEROKEE_OWS_ROOT, 0755)
                except OSError: pass

        CTK.unpublish (r'')

    # Add the OWS plug-in directory
    CTK.add_plugin_dir (CHEROKEE_OWS_DIR)

    # Set up the error page
    import PageException
    CTK.error.page = PageException.Page

    # Launch the SystemStats ASAP
    import SystemStats
    SystemStats.get_system_stats()

    # Import the Pages
    import PageIndex
    import PageGeneral
    import PageVServers
    import PageVServer
    import PageRule
    import PageEntry
    import PageSources
    import PageSource
    import PageAdvanced
    import PageNewConfig
    import PageHelp
    import PageStatus
    import market
コード例 #9
0
    def __safe_call__(self):
        root = CTK.cfg.get_val('tmp!market!install!root')
        app_name = CTK.cfg.get_val('tmp!market!install!app!application_name')
        cfg_changes = CTK.cfg.get_val(
            'tmp!market!install!cfg_previous_changes')

        # Finished
        finished_file = os.path.join(root, "finished")
        Install_Log.log("Creating %s" % (finished_file))
        f = open(finished_file, 'w+')
        f.close()

        # Normalize CTK.cfg
        CTK.cfg.normalize('vserver')

        # Save configuration
        box = CTK.Box()

        if not int(cfg_changes):
            CTK.cfg.save()
            Install_Log.log("Configuration saved.")

            Cherokee.server.restart(graceful=True)
            Install_Log.log("Server gracefully restarted.")
            box += CTK.RawHTML(js=SaveButton.ButtonSave__JS_to_deactive())

        Install_Log.log("Finished")

        # Thank user for the install
        box += CTK.RawHTML('<h2>%s %s</h2>' %
                           (app_name, _("has been installed successfully")))
        box += CTK.RawHTML("<p>%s</p>" % (_(NOTE_THANKS_P1)))

        # Save / Visit
        if int(cfg_changes):
            box += CTK.Notice('information', CTK.RawHTML(_(NOTE_SAVE_RESTART)))

        elif Cherokee.server.is_alive():
            install_type = CTK.cfg.get_val('tmp!market!install!target')
            nick = CTK.cfg.get_val('tmp!market!install!target!vserver')
            vserver_n = CTK.cfg.get_val('tmp!market!install!target!vserver_n')
            directory = CTK.cfg.get_val('tmp!market!install!target!directory')

            # Host
            if vserver_n and not nick:
                nick = CTK.cfg.get_val("vserver!%s!nick" % (vserver_n))

            if not nick or nick.lower() == "default":
                sys_stats = SystemStats.get_system_stats()
                nick = sys_stats.hostname

            # Ports
            ports = []
            for b in CTK.cfg['server!bind'] or []:
                port = CTK.cfg.get_val('server!bind!%s!port' % (b))
                if port:
                    ports.append(port)

            nick_port = nick
            if ports and not '80' in ports:
                nick_port = '%s:%s' % (nick, ports[0])

            # URL
            url = ''
            if install_type == 'vserver' and nick:
                url = 'http://%s/' % (nick_port)
            elif install_type == 'directory' and vserver_n and directory:
                nick = CTK.cfg.get_val('vserver!%s!nick' % (vserver_n))
                url = 'http://%s%s/' % (nick_port, directory)

            if url:
                box += CTK.RawHTML('<p>%s ' % (_("You can now visit")))
                box += CTK.LinkWindow(url,
                                      CTK.RawHTML(_('your new application')))
                box += CTK.RawHTML(' on a new window.</p>')

        box += CTK.RawHTML("<h1>%s</h1>" % (_(NOTE_THANKS_P2)))

        buttons = CTK.DruidButtonsPanel()
        buttons += CTK.DruidButton_Close(_('Close'))
        box += buttons

        # Clean up CTK.cfg
        for k in CTK.cfg.keys('tmp!market!install'):
            if k != 'app':
                del (CTK.cfg['tmp!market!install!%s' % (k)])

        return box.Render().toStr()
コード例 #10
0
ファイル: SystemStatsWidgets.py プロジェクト: BeQ/webserver
def SystemStats_JSON():
    stats = SystemStats.get_system_stats()
    return {'mem': {'used':  stats.mem.used,
                    'total': stats.mem.total},
            'cpu': {'usage': stats.cpu.usage,
                    'idle':  stats.cpu.idle}}
コード例 #11
0
ファイル: server.py プロジェクト: nuxleus/cherokee-webserver
            if not os.path.isdir (CHEROKEE_OWS_ROOT):
                try: os.makedirs (CHEROKEE_OWS_ROOT, 0755)
                except OSError: pass

        CTK.unpublish (r'')

    # Add the OWS plug-in directory
    CTK.add_plugin_dir (CHEROKEE_OWS_DIR)

    # Set up the error page
    import PageException
    CTK.error.page = PageException.Page

    # Launch the SystemStats ASAP
    import SystemStats
    SystemStats.get_system_stats()

    # Import the Pages
    import PageIndex
    import PageGeneral
    import PageVServers
    import PageVServer
    import PageRule
    import PageEntry
    import PageSources
    import PageSource
    import PageAdvanced
    import PageNewConfig
    import PageHelp
    import PageStatus
    import market
コード例 #12
0
ファイル: Install.py プロジェクト: hikikomorime/webserver
    def __safe_call__(self):
        root = CTK.cfg.get_val("tmp!market!install!root")
        app_name = CTK.cfg.get_val("tmp!market!install!app!application_name")
        cfg_changes = CTK.cfg.get_val("tmp!market!install!cfg_previous_changes")

        # Finished
        finished_file = os.path.join(root, "finished")
        Install_Log.log("Creating %s" % (finished_file))
        f = open(finished_file, "w+")
        f.close()

        # Normalize CTK.cfg
        CTK.cfg.normalize("vserver")

        # Save configuration
        box = CTK.Box()

        if not int(cfg_changes):
            CTK.cfg.save()
            Install_Log.log("Configuration saved.")

            Cherokee.server.restart(graceful=True)
            Install_Log.log("Server gracefully restarted.")
            box += CTK.RawHTML(js=SaveButton.ButtonSave__JS_to_deactive())

        Install_Log.log("Finished")

        # Thank user for the install
        box += CTK.RawHTML("<h2>%s %s</h2>" % (app_name, _("has been installed successfully")))
        box += CTK.RawHTML("<p>%s</p>" % (_(NOTE_THANKS_P1)))

        # Save / Visit
        if int(cfg_changes):
            box += CTK.Notice("information", CTK.RawHTML(_(NOTE_SAVE_RESTART)))

        elif Cherokee.server.is_alive():
            install_type = CTK.cfg.get_val("tmp!market!install!target")
            nick = CTK.cfg.get_val("tmp!market!install!target!vserver")
            vserver_n = CTK.cfg.get_val("tmp!market!install!target!vserver_n")
            directory = CTK.cfg.get_val("tmp!market!install!target!directory")

            # Host
            if vserver_n and not nick:
                nick = CTK.cfg.get_val("vserver!%s!nick" % (vserver_n))

            if not nick or nick.lower() == "default":
                sys_stats = SystemStats.get_system_stats()
                nick = sys_stats.hostname

            # Ports
            ports = []
            for b in CTK.cfg["server!bind"] or []:
                port = CTK.cfg.get_val("server!bind!%s!port" % (b))
                if port:
                    ports.append(port)

            nick_port = nick
            if ports and not "80" in ports:
                nick_port = "%s:%s" % (nick, ports[0])

            # URL
            url = ""
            if install_type == "vserver" and nick:
                url = "http://%s/" % (nick_port)
            elif install_type == "directory" and vserver_n and directory:
                nick = CTK.cfg.get_val("vserver!%s!nick" % (vserver_n))
                url = "http://%s%s/" % (nick_port, directory)

            if url:
                box += CTK.RawHTML("<p>%s " % (_("You can now visit")))
                box += CTK.LinkWindow(url, CTK.RawHTML(_("your new application")))
                box += CTK.RawHTML(" on a new window.</p>")

        box += CTK.RawHTML("<h1>%s</h1>" % (_(NOTE_THANKS_P2)))

        buttons = CTK.DruidButtonsPanel()
        buttons += CTK.DruidButton_Close(_("Close"))
        box += buttons

        # Clean up CTK.cfg
        for k in CTK.cfg.keys("tmp!market!install"):
            if k != "app":
                del (CTK.cfg["tmp!market!install!%s" % (k)])

        return box.Render().toStr()