Beispiel #1
0
    def __init__(self, service_logic):
        self._logger_port = service_config().find_service('logger')['port']
        self.event_queue = Queue()
        self.request_queue = Queue()
        self.threads = []

        self.listener = listener(service_logic.ip, service_logic.port)
        self._service_logic = service_logic

        self._add_thread(self.listener, 'listener')
        self._add_thread(self._service_logic, 'service_logic')
Beispiel #2
0
    def __init__(self, name, service, payload=None, timeout=2):
        service_data = config.service_config().find_service(service)

        self.name = name
        self.payload = payload
        self.service = service
        self.receiver_port = service_data["port"]
        self.sender_port = 0
        self.is_response_sent = False
        self.timeout = timeout

        for e in all_requests:
            self.__dict__["is_" + e] = MethodType(lambda self: False, self, e)

        self.__dict__["is_" + name] = MethodType(lambda self: True, self, e)
Beispiel #3
0
    def __init__(self, name):
        config = service_config()
        self._logger_port = config.find_service(constant.LOGGER)['port']
        this_service = config.find_service(name)

        self.ip = config.host_ip
        self.port = this_service['port']
        self.name = this_service['name']

        self._event_process_interval = EVENT_PROCESS_INTERVAL_DEFAULT
        self.sleep_time = 10
        self.is_running = False

        self.debug_mode = False

        if name != constant.LOGGER:
            self.log("Service started")
Beispiel #4
0
if 'Android' in user_agent:
    output.add_parameter('stylesheet', 'mobile.css')
else:
    output.add_parameter('stylesheet', 'desktop.css')

is_monitor_online = ping(SERVICE_MONITOR).get_response()
if not is_monitor_online:
        table_data = _service_status_row(SERVICE_MONITOR, OFFLINE)
        table_data += _empty_cell()
        table_data += _empty_cell()
        #  status = '<td class="offline">offline</td>'
        #  status += _start_service_cell(SERVICE_MONITOR)
        html_data = '<tr><td>%s</td>%s</tr>' % (SERVICE_MONITOR, table_data)
else:
    html_data = ''
    services = service_config().services
    for service_data in services:
        service = service_data['name']
        if service == SERVICE_MONITOR:
            continue

        status = service_status_request(service).get_response()

        if status:
            table_data = _service_status_row(service, status)
            if _is_service_controllable(service):
                if status == ONLINE:
                    table_data += _restart_service_cell(service)
                    is_in_debug_mode = is_debug_mode_on_request(service).get_response()
                    if is_in_debug_mode:
                        table_data += _stop_debug_cell(service)
Beispiel #5
0
#!/usr/bin/env python

#  import cgitb; cgitb.enable()
import cgi

from myhouse.lib.cgi.session import require_private_access, html_output
from myhouse.lib.common.config import service_config
from myhouse.lib.common.network import send_event_to_port
from myhouse.lib.service.events import debug_mode_off


require_private_access()

data = cgi.FieldStorage()
if data:
    output = html_output('service.html')

    service_name = data['service'].value

    config = service_config()
    service = config.find_service(service_name)
    if not service:
        text = "Invalid service"
    else:
        send_event_to_port(debug_mode_off(), service['port'])
        text = service + ' debug mode off'

    output.add_parameter('data', text)

    print output
Beispiel #6
0
#!/usr/bin/env python

from myhouse.lib.cgi.session import require_private_access, html_output
from myhouse.lib.common.config import service_config
from myhouse.lib.common.network import send_event_to_port
from myhouse.lib.service.events import start_app
#  from myhouse.lib.tv import tv

require_private_access()

output = html_output('kodi.html')

service = service_config().find_service('app_starter')
if not service:
    text = 'Invalid service'
else:
    #  t = tv()
    #  t.power_on()
    #  t.switch_to_hdmi_input()

    send_event_to_port(start_app('kodi'), service['port'])

    text = 'kodi started'

output.add_parameter('data', text)
print output