Пример #1
0
from myhouse.lib.service.events import stop_service
from myhouse.lib.service.service_requests import ping

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(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")
Пример #2
0
#!/usr/bin/env python

import sys
import myhouse.lib.service.events as events
from myhouse.lib.common.network import send_event_to_port

port = int(sys.argv[1])

print 'killing ' + str(port)
send_event_to_port(events.stop_service(), port)
Пример #3
0
#!/usr/bin/env python

#  import cgitb; cgitb.enable()
import cgi

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

require_private_access()

data = cgi.FieldStorage()
if data:
    output = html_output('service.html')
    service_string = data['service'].value
    config = service_config()

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

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

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