def main():
    form = cgi.FieldStorage()
    iptables=IPTablesManagerAPI()
    
    if "flush" in form:
        chain = form.getfirst("flush")
        composeJS(json.dumps(iptables.flushRules(chain)))
    else:
        composeJS(json.dumps(iptables.getJS()))
Beispiel #2
0
def main():
    form = cgi.FieldStorage()
    iptables = IPTablesManagerAPI()

    if "flush" in form:
        chain = form.getfirst("flush")
        composeJS(json.dumps(iptables.flushRules(chain)))
    else:
        composeJS(json.dumps(iptables.getJS()))
def main():
    form = cgi.FieldStorage()
    if not 'p' in form:
        view.setContent('Dependency Manager', 'This is the dependency manager for pi-web-agent extensions')     
        output(view, form)
    else:
        pm = PackageManager()
        dependencies = getDependencies(form['p'].value)
        pm.loadPackages(dependencies)
        composeJS(json.dumps(pm.packages))
Beispiel #4
0
def op_dispatch(form):
    op = form.getfirst("op")
    args = dict((k, form[k].value) for k in form.keys() if not k=="op")
    
    op_dict = {
        "direction" : partial(set_pin_direction, args=args),
        "value" : partial(set_pin_value, args=args),
    }

    op_func = op_dict.get(op, error)
    composeJS(json.dumps(op_func()))
def main():
    form = cgi.FieldStorage()
    if 'download' in form:
        download(form['download'].value)    
        return
    if not 'path' in form:
        composeJS('[error]')
    path = form['path'].value
    contents = getContents(path)
    composeJS(json.dumps(contents))
    return
Beispiel #6
0
def op_dispatch(form):
    op = form.getfirst("op")
    args = dict((k, form[k].value) for k in form.keys() if not k == "op")

    op_dict = {
        'search': partial(search_package, args=args),
        'check_group': partial(check_group_installed, args=args)
    }

    op_func = op_dict.get(op, error)
    composeJS(json.dumps(op_func()))
Beispiel #7
0
def op_dispatch(form):
    # Do a dispatch on the operation, only one so far though so...!
    op = form.getfirst("op")
    args = dict((k, form[k].value) for k in form.keys() if not k=="op")

    op_dict = {
        "get_usage" : partial(get_usage, args['top'])
    }

    op_func = op_dict.get(op, error)
    composeJS(op_func())
Beispiel #8
0
def op_dispatch(form):
    op = form.getfirst("op")
    args = dict((k, form[k].value) for k in form.keys() if not k == "op")

    op_dict = {
        "direction": partial(set_pin_direction, args=args),
        "value": partial(set_pin_value, args=args),
    }

    op_func = op_dict.get(op, error)
    composeJS(json.dumps(op_func()))
Beispiel #9
0
def op_dispatch(form):
    op = form.getfirst("op")
    args = dict((k, form[k].value) for k in form.keys() if not k=="op")
    
    op_dict = {
        'search': partial(search_package, args=args),
        'check_group': partial(check_group_installed, args=args)
    }

    op_func = op_dict.get(op, error)
    composeJS(json.dumps(op_func()))
Beispiel #10
0
def main():
    form = cgi.FieldStorage()
    if not 'p' in form:
        view.setContent(
            'Dependency Manager',
            'This is the dependency manager for pi-web-agent extensions')
        output(view, form)
    else:
        pm = PackageManager()
        dependencies = getDependencies(form['p'].value)
        pm.loadPackages(dependencies)
        composeJS(json.dumps(pm.packages))
Beispiel #11
0
def op_dispatch(form):
    # Do a dispatch on the operation
    op = form.getfirst("op")
    args = dict((k, form[k].value) for k in form.keys() if not k=="op")

    op_dict = {
        "get_status"   : get_status,
        "update"       : perform_update,
        "get_packages" : get_packages
    }

    op_func = op_dict.get(op, error)
    composeJS(op_func())
Beispiel #12
0
def op_dispatch(form):
    op = form.getfirst("op")
    args = dict((k, form[k].value) for k in form.keys() if not k=="op")
    
    op_dict = {
        "get_vol"    : partial(get_volume, args=args),
        "update_vol" : partial(set_volume, args=args),
        "mixers"     : partial(get_mixers, args=args),
        "toggle"     : partial(toggle_mute, args=args),
        "test"       : test_speakers
    }

    op_func = op_dict.get(op, error)
    composeJS(op_func())
Beispiel #13
0
def op_dispatch(form):
    op = form.getfirst("op")
    args = dict((k, form[k].value) for k in form.keys() if not k == "op")

    op_dict = {
        "get_vol": partial(get_volume, args=args),
        "update_vol": partial(set_volume, args=args),
        "mixers": partial(get_mixers, args=args),
        "toggle": partial(toggle_mute, args=args),
        "test": test_speakers
    }

    op_func = op_dict.get(op, error)
    composeJS(op_func())
def main():
    form = cgi.FieldStorage()
    chain = form['chain'].value
    protocol = form['protocol'].value
    action = form['action'].value
    ip_address = form['ipaddress'].value
    if protocol == "None":
        addIPRule(chain, action, ip_address)
    elif ip_address == "None":
        addProtocolRule(chain, action, protocol)
    else:
        addIPwithProtocolRule(chain, action, protocol, ip_address)
    response = {"code": 0}

    composeJS(json.dumps(response))
def main():   
    form = cgi.FieldStorage()
    chain = form['chain'].value
    protocol=form['protocol'].value
    action=form['action'].value
    ip_address=form['ipaddress'].value
    if protocol=="None":
        addIPRule(chain, action, ip_address)
    elif ip_address=="None":
        addProtocolRule(chain, action, protocol)
    else:
        addIPwithProtocolRule(chain, action, protocol, ip_address)
    response = {"code":0}
        
    composeJS(json.dumps(response))
def main():
    form = cgi.FieldStorage()

    if('index' in form and form['index'].value != -1 ) :
      packages = getTableRecord( form['index'].value )
      if packages != None :
        composeJS( json.dumps( packages ) )
      else :
        composeJS( json.dumps( STOP ) )
    elif ('op' in form and form['op'].value == 'status'):          
        composeJS(json.dumps({'status':not getAptBusy()}))
    else:
        composeJS(json.dumps({}))    
Beispiel #17
0
def main():
    form = cgi.FieldStorage()

    if ('index' in form and form['index'].value != -1):
        packages = getTableRecord(form['index'].value)
        if packages != None:
            composeJS(json.dumps(packages))
        else:
            composeJS(json.dumps(STOP))
    elif ('op' in form and form['op'].value == 'status'):
        composeJS(json.dumps({'status': not getAptBusy()}))
    else:
        composeJS(json.dumps({}))
def main(form):

    if 'cmd' in form:
        if form['cmd'].value == 'set':
            if (valid(form)):
                script = form['script'].value
                arguments = ""
                if 'args' in form:
                    arguments = form['args'].value
                result = set_definition(script, arguments)
                composeJS(json.dumps(result))
            else:
                composeJS(json.dumps({'status': 'INVALID_DATA'}))
        elif form['cmd'].value == 'get':
            result = get_current_definitions()
            composeJS(json.dumps(result))
        elif form['cmd'].value == 'remove' and 'index' in form:
            index = int(form['index'].value)
            result = remove_definition(index)
            composeJS(json.dumps(result))
    else:
        composeJS(json.dumps({'status': 'INVALID_DATA'}))
def main(form):
    
    if 'cmd' in form:
        if form['cmd'].value == 'set':
            if (valid(form)):
                script = form['script'].value
                arguments = ""
                if 'args' in form:
                    arguments = form['args'].value
                result = set_definition(script, arguments)
                composeJS(json.dumps(result))
            else:
                composeJS(json.dumps({'status':'INVALID_DATA'}))
        elif form['cmd'].value == 'get':
            result = get_current_definitions()
            composeJS(json.dumps(result))
        elif form['cmd'].value == 'remove' and 'index' in form:
            index = int(form['index'].value)
            result = remove_definition(index)
            composeJS(json.dumps(result))
    else:
        composeJS(json.dumps({'status':'INVALID_DATA'}))
def main(arg):
    switch = {'gallery': get_images}
    composeJS(switch[arg]())
#!/usr/bin/python
from camera_manager import CameraManager
import json

from view import composeJS
if 'MY_HOME' not in os.environ:
    os.environ['MY_HOME'] = '/usr/libexec/pi-web-agent'
sys.path.append(os.environ['MY_HOME'] + '/cgi-bin/chrome')
import cgi


def get_images():
    cMgr = CameraManager()
    json_data = cMgr.getImages()
    return json.dumps(json_data)


def main(arg):
    switch = {'gallery': get_images}
    composeJS(switch[arg]())


if __name__ == "__main__":
    form = cgi.FieldStorage()

    if (len(form) < 1):
        composeJS([len(form)])
    else:
        main(form['cmd'].value)
#!/usr/bin/python
from camera_manager import CameraManager
import json

from view import composeJS

if "MY_HOME" not in os.environ:
    os.environ["MY_HOME"] = "/usr/libexec/pi-web-agent"
sys.path.append(os.environ["MY_HOME"] + "/cgi-bin/chrome")
import cgi


def get_images():
    cMgr = CameraManager()
    json_data = cMgr.getImages()
    return json.dumps(json_data)


def main(arg):
    switch = {"gallery": get_images}
    composeJS(switch[arg]())


if __name__ == "__main__":
    form = cgi.FieldStorage()

    if len(form) < 1:
        composeJS([len(form)])
    else:
        main(form["cmd"].value)
def main(arg):
    switch = {"gallery": get_images}
    composeJS(switch[arg]())
Beispiel #24
0
    def startStream(self):
        '''
        try to use mplayer for the given parameters
        '''
        command=(os.environ['MY_HOME'] + "/scripts/mplayer.sh "+self.output+" "+str(self.volume)+" \""+self.uri + "\" "+os.environ['ssl_cert']+" "+os.environ['ssl_key']);
        fireAndForget(command)
        execute("echo '"+str(self.volume)+"\n0:0:0:0:0:0:0:0:0:0' > /tmp/mplayer_status")
        return 0;

if __name__ == '__main__':
    if os.environ['REQUEST_METHOD'] == 'GET':
        
        if execute('pidof mplayer')[1] == 0:
            fireAndForget('echo "get_property volume" > /tmp/mplayer-control;');
            composeJS('{ "status" : "playing" }')
        else:
            composeJS('{ "status" : "stoped" }')
    elif os.environ['REQUEST_METHOD'] == 'DELETE':

        if execute('echo "quit" > /tmp/mplayer-control')[1] == 0:
            composeJS('{ "status" : "success" }')
        else:
            composeJS('{ "status" : "failure" }',
                      httplib.INTERNAL_SERVER_ERROR)
    elif os.environ['REQUEST_METHOD'] == 'POST':
        data=json.loads(sys.stdin.read())
        try:
            if 'volume' in data:
                if 0 <= int(data['volume']) <= 100:
                    execute('echo "set_property volume '
Beispiel #25
0
def main():
    form = cgi.FieldStorage()
    try:
	op_dispatch(form)
    except:
    	composeJS(error())