# Path: epymc/modules.py
# class EmcModule(object):
#     name = ''
#     label = ''
#     icon = ''
#     info = ''
# 
#     def __init__(self):
#         pass
# 
#     def __shutdown__(self):
#         pass
# 
#     def __restart__(self):
#         self.__shutdown__()
#         self.__init__()


import os
import threading
import queue
import epymc.input_events as input_events
import epymc.ini as ini
from http.server import BaseHTTPRequestHandler, HTTPServer
from efl import ecore
from epymc.modules import EmcModule
    @staticmethod
    def queue_timer():
        if not input_queue.empty():
            input_events.event_emit(input_queue.get())
        return True  # renew


class RequestHandler(BaseHTTPRequestHandler):

    def log_message(self, format, *args):
        pass

    def do_GET(self):
        (host, port) = self.client_address
        DBG('GET from client: %s:%d [%s]' % (host, port, self.path))

        if self.path == '/':
            self.serve_file('main.html')
        elif self.path.startswith('/input/'):
            input_queue.put(self.path[7:])
            self.send_response(200)  # HTTP status code: OK
        else:
            self.serve_file(self.path[1:])

    def serve_file(self, path):
        try:
            skin = ini.get('webserver', 'skin')
            fname = os.path.join(os.path.dirname(__file__), skin, path)
            f = open(fname)
        except:

# Path: epymc/modules.py
# class EmcModule(object):
#     name = ''
#     label = ''
#     icon = ''
#     info = ''
# 
#     def __init__(self):
#         pass
# 
#     def __shutdown__(self):
#         pass
# 
#     def __restart__(self):
#         self.__shutdown__()
#         self.__init__()


# Path: epymc/plugins/input_webserver/webserver.py
import os
import threading
import queue
import epymc.input_events as input_events
import epymc.ini as ini
from http.server import BaseHTTPRequestHandler, HTTPServer
from efl import ecore
from epymc.modules import EmcModule

    @staticmethod
    def queue_timer():
        if not input_queue.empty():
            input_events.event_emit(input_queue.get())
        return True  # renew


class RequestHandler(BaseHTTPRequestHandler):

    def log_message(self, format, *args):
        pass

    def do_GET(self):
        (host, port) = self.client_address
        DBG('GET from client: %s:%d [%s]' % (host, port, self.path))

        if self.path == '/':
            self.serve_file('main.html')
        elif self.path.startswith('/input/'):
            input_queue.put(self.path[7:])
            self.send_response(200)  # HTTP status code: OK
        else:
            self.serve_file(self.path[1:])

    def serve_file(self, path):
        try:
            skin = ini.get('webserver', 'skin')
            fname = os.path.join(os.path.dirname(__file__), skin, path)
            f = open(fname)
        except:

            DBG('Cannot open file: ' + fname)