# 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
            else:
                log = logs.get(log)

        cherrypy.response.headers['Content-Type'] = 'application/json; charset=utf-8'
        cherrypy.response.headers['Cache-Control'] = 'no-cache, no-store, must-revalidate'
        cherrypy.response.headers['Pragma'] = 'no-cache'
        cherrypy.response.headers['Expires'] = 0
        return json.dumps(prepare_log(log or LOG_FILE))

# # #

    @cherrypy.expose
    def reset_user(self, user):
        """ clean user related information """
        logFull('CeWebUi:reset_user user `{}`.'.format(user))
        self.project.reset_project(user)
        self.project.reset_logs(user)
        raise cherrypy.HTTPRedirect('http://{host}/web/users/{user}'.\
        format(host=cherrypy.request.headers['Host'], user=user))


    @cherrypy.expose
    def set_user_status(self, user, status):
        """ Update user status """
        logFull('CeWebUi:set_user_status user `{}`.'.format(user))
        output = Template(filename=TWISTER_PATH + '/server/template/rest_error.htm')
        try:
            status = int(status)
        except:
            return output.render(title='Error!', body='<b>Status value `{0}` is invalid!</b>'.format(status))

# 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

            else:
                log = logs.get(log)

        cherrypy.response.headers['Content-Type'] = 'application/json; charset=utf-8'
        cherrypy.response.headers['Cache-Control'] = 'no-cache, no-store, must-revalidate'
        cherrypy.response.headers['Pragma'] = 'no-cache'
        cherrypy.response.headers['Expires'] = 0
        return json.dumps(prepare_log(log or LOG_FILE))

# # #

    @cherrypy.expose
    def reset_user(self, user):
        """ clean user related information """
        logFull('CeWebUi:reset_user user `{}`.'.format(user))
        self.project.reset_project(user)
        self.project.reset_logs(user)
        raise cherrypy.HTTPRedirect('http://{host}/web/users/{user}'.\
        format(host=cherrypy.request.headers['Host'], user=user))


    @cherrypy.expose
    def set_user_status(self, user, status):
        """ Update user status """
        logFull('CeWebUi:set_user_status user `{}`.'.format(user))
        output = Template(filename=TWISTER_PATH + '/server/template/rest_error.htm')
        try:
            status = int(status)
        except:
            return output.render(title='Error!', body='<b>Status value `{0}` is invalid!</b>'.format(status))

        if status not in EXEC_STATUS.values():