# Path: common/constants.py
# STATUS_INVALID = 8 # Invalid status
# 
# EXEC_STATUS = {'stopped':STATUS_STOP, 'paused':STATUS_PAUSED, 'running':STATUS_RUNNING, 'resume':STATUS_RESUME,
# 	'invalid':STATUS_INVALID, 'interact': STATUS_INTERACT, 'restart': STATUS_RESTART}


import os, sys
import json
import platform
import mako
import cherrypy
from mako.template import Template
from binascii import unhexlify as decode
from common.constants  import STATUS_INVALID, EXEC_STATUS
from common.helpers    import calcMemory, calcCpu, dirList
from common.tsclogging import logWarning, logFull, logDebug, LOG_FILE
        srv_type = self.project.server_init['ce_server_type']
        ip_port = cherrypy.request.headers['Host']
        machine = platform.uname()[1]
        system = ' '.join(platform.linux_distribution())
        users = self.project.list_users()

        output = Template(filename=TWISTER_PATH + '/server/template/rest_main.htm')
        return output.render(srv_type=srv_type, srv_ver=srv_ver,\
        ip_port=ip_port, machine=machine, system=system, users=users)


    @cherrypy.expose
    def users(self, user=''):
        """ list all users """
        logFull('CeWebUi:users')
        if self.user_agent() == 'x':
            return 0
        if not user:
            raise cherrypy.HTTPRedirect('/web/#tab_users')

        host = cherrypy.request.headers['Host']
        rev_dict = dict((v, k) for k, v in EXEC_STATUS.iteritems())
        int_status = self.project.get_user_info(user, 'status') or STATUS_INVALID
        status = rev_dict[int_status]
        try:
            eps_file = self.project.parsers[user].project_globals['ep_names']
        except:
            eps_file = ''

        eps = self.project.get_user_info(user, 'eps')

# Path: common/constants.py
# STATUS_INVALID = 8 # Invalid status
# 
# EXEC_STATUS = {'stopped':STATUS_STOP, 'paused':STATUS_PAUSED, 'running':STATUS_RUNNING, 'resume':STATUS_RESUME,
# 	'invalid':STATUS_INVALID, 'interact': STATUS_INTERACT, 'restart': STATUS_RESTART}


# Path: server/CeWebUi.py
import os, sys
import json
import platform
import mako
import cherrypy
from mako.template import Template
from binascii import unhexlify as decode
from common.constants  import STATUS_INVALID, EXEC_STATUS
from common.helpers    import calcMemory, calcCpu, dirList
from common.tsclogging import logWarning, logFull, logDebug, LOG_FILE

        srv_type = self.project.server_init['ce_server_type']
        ip_port = cherrypy.request.headers['Host']
        machine = platform.uname()[1]
        system = ' '.join(platform.linux_distribution())
        users = self.project.list_users()

        output = Template(filename=TWISTER_PATH + '/server/template/rest_main.htm')
        return output.render(srv_type=srv_type, srv_ver=srv_ver,\
        ip_port=ip_port, machine=machine, system=system, users=users)


    @cherrypy.expose
    def users(self, user=''):
        """ list all users """
        logFull('CeWebUi:users')
        if self.user_agent() == 'x':
            return 0
        if not user:
            raise cherrypy.HTTPRedirect('/web/#tab_users')

        host = cherrypy.request.headers['Host']
        rev_dict = dict((v, k) for k, v in EXEC_STATUS.iteritems())
        int_status = self.project.get_user_info(user, 'status') or STATUS_INVALID
        status = rev_dict[int_status]
        try:
            eps_file = self.project.parsers[user].project_globals['ep_names']
        except:
            eps_file = ''

        eps = self.project.get_user_info(user, 'eps')

        ep_statuses = [rev_dict[eps[ep].get('status', STATUS_INVALID)] \