# Path: vcontrol/rest/helpers/get_allowed.py
# def get_allowed():
#     rest_url = ""
#     if "ALLOW_ORIGIN" in os.environ:
#         allow_origin = os.environ["ALLOW_ORIGIN"]
#         host_port = allow_origin.split("//")[1]
#         host = host_port.split(":")[0]
#         port = str(int(host_port.split(":")[1])+1)
#         rest_url = host+":"+port
#     else:
#         allow_origin = ""
#     return allow_origin, rest_url
# 
# Path: vcontrol/rest/helpers/json_yield.py
# def json_yield_none(fn):
#     def _(self, key, *o, **k):
# def json_yield_one(fn):
#     def _(self, arg, key, *o, **k):
# def json_yield_two(fn):
#     def _(self, arg1, arg2, key, *o, **k):


from ..helpers import get_allowed
from ..helpers import json_yield
import subprocess
import uuid
import web

      update();
    });
    </script>
    </head>
    <body>
    <div id="status">Cleaning, please wait...</div>
    </body>
    </html>
    """

    def GET(self, machine, category, o_type):
        web.header('Access-Control-Allow-Origin', self.allow_origin)

        client_session_id = uuid.uuid4().hex
        out = ""
        if o_type == 'a':
             out = self.INDEX_HTML%(machine, category, client_session_id) + \
                   self.INDEX_HTML_TYPE_A + \
                   self.INDEX_HTML_END
        elif o_type == 'b':
             out = self.INDEX_HTML%(machine, category, client_session_id) + \
                   self.INDEX_HTML_TYPE_B + \
                   self.INDEX_HTML_END
        return out

class CleanCommandOutputR:
    """
    This endpoint is for rendering the output of cleaning Docker containers on a machine in a particular category
    """

# Path: vcontrol/rest/helpers/get_allowed.py
# def get_allowed():
#     rest_url = ""
#     if "ALLOW_ORIGIN" in os.environ:
#         allow_origin = os.environ["ALLOW_ORIGIN"]
#         host_port = allow_origin.split("//")[1]
#         host = host_port.split(":")[0]
#         port = str(int(host_port.split(":")[1])+1)
#         rest_url = host+":"+port
#     else:
#         allow_origin = ""
#     return allow_origin, rest_url
# 
# Path: vcontrol/rest/helpers/json_yield.py
# def json_yield_none(fn):
#     def _(self, key, *o, **k):
# def json_yield_one(fn):
#     def _(self, arg, key, *o, **k):
# def json_yield_two(fn):
#     def _(self, arg1, arg2, key, *o, **k):


# Path: vcontrol/rest/commands/clean.py
from ..helpers import get_allowed
from ..helpers import json_yield
import subprocess
import uuid
import web


      update();
    });
    </script>
    </head>
    <body>
    <div id="status">Cleaning, please wait...</div>
    </body>
    </html>
    """

    def GET(self, machine, category, o_type):
        web.header('Access-Control-Allow-Origin', self.allow_origin)

        client_session_id = uuid.uuid4().hex
        out = ""
        if o_type == 'a':
             out = self.INDEX_HTML%(machine, category, client_session_id) + \
                   self.INDEX_HTML_TYPE_A + \
                   self.INDEX_HTML_END
        elif o_type == 'b':
             out = self.INDEX_HTML%(machine, category, client_session_id) + \
                   self.INDEX_HTML_TYPE_B + \
                   self.INDEX_HTML_END
        return out

class CleanCommandOutputR:
    """
    This endpoint is for rendering the output of cleaning Docker containers on a machine in a particular category
    """

    json_yield = json_yield.json_yield_two