# Path: common/tool_connect.py
# class ToolConnect:
#     def __init__(self, server_name, port):
#     def _ill_formed_request(self, conn, data):
#     def wait_request(self):
#     def send_text_reply(self, conn, data):
#     def send_reply(self, conn, data):
#     def close(self):
# 
# Path: common/common_html.py
# def get_head(title, css = None, html5 = False):
# 
# Path: common/job_queue.py
# class JobQueue:
#     def __init__(self, filename = None):
#     def put(self, *args):
#     def remove(self):
#     def get(self):
#     def copy_items(self, get_last = False):
#     def save(self, filename):
#     def empty(self):
#     def _load(self, filename):
#     def expect(func, data, *args):
#     def put_get_save_test():
#     def thread_test():
#         def thread1(jobs):
#         def thread2(jobs):


import sys
import os
import thread
import time
from common import tool_connect
from common import common_html
from common import job_queue

    return ret_val(E_OK, "exec ok: " + title)

# cmd title t tools conn
def html_for_queue(queue):
    html = u''
    for i in queue:
        mtitle = i[1]

        html += date_s(i[1]) + ' ' + mtitle + "<br/>"
    return html

def do_status(queue):
    queue = queue.copy_items(True)

    html = common_html.get_head(u'Dummy robot')
    html += u"<body><div>The robot is running.<br/><hr/>"
    html += u"<br/>%d jobs in dummy robot queue.<br/>" % len(queue)
    html += html_for_queue(queue)
    html += u'</div></body></html>'
    return html

def bot_listening(queue):

    print date_s(time.time()) + " START"

    tools = tool_connect.ToolConnect('dummy_robot', 45139)

    try:
        while True:

# Path: common/tool_connect.py
# class ToolConnect:
#     def __init__(self, server_name, port):
#     def _ill_formed_request(self, conn, data):
#     def wait_request(self):
#     def send_text_reply(self, conn, data):
#     def send_reply(self, conn, data):
#     def close(self):
# 
# Path: common/common_html.py
# def get_head(title, css = None, html5 = False):
# 
# Path: common/job_queue.py
# class JobQueue:
#     def __init__(self, filename = None):
#     def put(self, *args):
#     def remove(self):
#     def get(self):
#     def copy_items(self, get_last = False):
#     def save(self, filename):
#     def empty(self):
#     def _load(self, filename):
#     def expect(func, data, *args):
#     def put_get_save_test():
#     def thread_test():
#         def thread1(jobs):
#         def thread2(jobs):


# Path: dummy_robot/dummy_robot.py
import sys
import os
import thread
import time
from common import tool_connect
from common import common_html
from common import job_queue


    return ret_val(E_OK, "exec ok: " + title)

# cmd title t tools conn
def html_for_queue(queue):
    html = u''
    for i in queue:
        mtitle = i[1]

        html += date_s(i[1]) + ' ' + mtitle + "<br/>"
    return html

def do_status(queue):
    queue = queue.copy_items(True)

    html = common_html.get_head(u'Dummy robot')
    html += u"<body><div>The robot is running.<br/><hr/>"
    html += u"<br/>%d jobs in dummy robot queue.<br/>" % len(queue)
    html += html_for_queue(queue)
    html += u'</div></body></html>'
    return html

def bot_listening(queue):

    print date_s(time.time()) + " START"

    tools = tool_connect.ToolConnect('dummy_robot', 45139)

    try:
        while True:

            request, conn = tools.wait_request()