Пример #1
0
    config = service_config()

    service = config.find_service(service_name)
    if not service:
        text = "Invalid service"
    else:
        send_event_to_port(stop_service(), service["port"])

        text = service["name"] + " on port " + str(service["port"]) + " stopped"

    text += "<br/>"

    sleep(2)

    max_retries = 3
    while ping(service_name).get_response() and max_retries > 0:
        sleep(1)
        max_retries -= 1

    script_path = "/home/bacso/project/myhouse/myhouse/"
    os.system("echo 'python " + script_path + service_name + ".py' | at -M now")

    sleep(2)

    if ping(service_name).get_response():
        text += service_name + " started"
    else:
        text += "failed to start " + service_name

    output.add_parameter("data", text)
    print output
Пример #2
0
    if service != 'app_starter':
        return True
    else:
        return False


require_private_access()

output = html_output('monitor.html')
user_agent = os.environ.get('HTTP_USER_AGENT', 'test_agent')
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
Пример #3
0
#  import cgitb; cgitb.enable()
import cgi
import os
from time import sleep

from myhouse.lib.cgi.session import require_private_access, html_output
from myhouse.lib.service.service_requests import ping


require_private_access()

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

    script_path = '/home/bacso/project/myhouse/myhouse/'
    service = data['service'].value

    os.system("echo 'python "+script_path+service+".py' | at -M now")

    sleep(2)

    if ping(service).get_response():
        text = service + ' started'
    else:
        text = 'failed to start ' + service

    output.add_parameter('data', text)

    print output