Esempio n. 1
0
def main():
    '''
Application to display the iptables of raspberry to the user
'''

    form = cgi.FieldStorage()
    
    f = open(os.environ['MY_HOME'] + '/html/iptables_overlay_html', 'r')
    html_tables= f.read()
    f.close()

    chain_els=[[]]
    iptables=IPTablesManager()
    header_list=['protocol', 'target', 'otherinfo','destination', 'source', 'option']
    for chain in iptables.chains:
        html_tables+='<h4><a href="javascript:open_iptables_panel(\'' + chain + '\')">' + chain + '</a>'+' (Default Protocol: ' \
                        + iptables.chains[chain].policy + ')</h4>'
        if iptables.chains[chain]._isRulesEmpty():
            chain_els.append(['--','--','--','--','--','--'])
        else:
            for rule in iptables.chains[chain].rules:
                chain_els.append(list(rule.values()))
        html_tables+=HTML.table(chain_els, header_row=header_list)
        chain_els=[[]]
        html_tables+='</br>'
    
    view.setContent('IPTables', html_tables)
    output(view, form)
def main():

    form = cgi.FieldStorage()

    pictures, returncode = execute(
        "ls /usr/share/pi-web-agent/camera-media/*.jpg")
    linearray = pictures.split('\n')

    html = '''<div id="camera_toolbar">
                  <div class="btn-group btn-group-justified">
                      <a href='javascript:navigate("/cgi-bin/toolkit/camera.py?type=js")' class="btn btn-default">Live stream</a>
                      <a href='javascript:camera_utils("snapshot")' class="btn btn-default">Snapshot</a>
                      <a href='javascript:alert("Coming soon")' class="btn btn-default">Record</a>
                      <a href='javascript:camera_utils("stoprecord")' class="btn btn-default">Stop</a>
      
                 </div></div><br>
          '''
    html += '''<div id="gallery_thumbnails">'''

    for thisline in linearray:
        justname = thisline.split('/')[-1]
        if len(justname) <= 0:
            continue
        html += '<a href="/cgi-bin/toolkit/image_manager.py?image=' + justname + '" rel="thumbnail"><img style="padding:4px; border:2px solid #021a40;" src="/cgi-bin/toolkit/image_manager.py?image=' + justname.split(
            '.')[0] + '.png" style="width: 64px; height: 64px" /></a>'
    html += '</div><br>'

    view.setContent('Pi Camera Controller', html)
    output(view, cgi.FieldStorage())
Esempio n. 3
0
def main():

    form = cgi.FieldStorage()
    
    pictures, returncode = execute("ls /usr/share/pi-web-agent/camera-media/*.jpg")
    linearray = pictures.split('\n')
    
    html = '''<div id="camera_toolbar">
                  <div class="btn-group btn-group-justified">
                      <a href='javascript:navigate("/cgi-bin/toolkit/camera.py?type=js")' class="btn btn-default">Live stream</a>
                      <a href='javascript:camera_utils("snapshot")' class="btn btn-default">Snapshot</a>
                      <a href='javascript:alert("Coming soon")' class="btn btn-default">Record</a>
                      <a href='javascript:camera_utils("stoprecord")' class="btn btn-default">Stop</a>
      
                 </div></div><br>
          '''
    html += '''<div id="gallery_thumbnails">'''
    
    for thisline in linearray:
        justname = thisline.split('/')[-1]
        if len(justname) <= 0:
            continue
        html += '<a href="/cgi-bin/toolkit/image_manager.py?image='+justname +'" rel="thumbnail"><img style="padding:4px; border:2px solid #021a40;" src="/cgi-bin/toolkit/image_manager.py?image='+justname.split('.')[0]+'.png" style="width: 64px; height: 64px" /></a>'
    html += '</div><br>'

    view.setContent('Pi Camera Controller', html)
    output(view, cgi.FieldStorage())
Esempio n. 4
0
def main():
    # Serves the disk analyzer page
    fs = cgi.FieldStorage()
    content = get_view()
    view.setContent('Disk analyzer', content)
    
    output(view, fs)
Esempio n. 5
0
def main():
    '''
    generates an error page 
    '''
    fs=cgi.FieldStorage()
    view.setContent('Page not found', 'The requested page was not found. Did you type the url manually?')
    output(view, fs)
Esempio n. 6
0
def main():

    leftDirectionPins, rightDirectionPins = getDirections()
    leftValuesPins, rightValuesPins = getValues()

    pins = [[]]
    text = ''

    for index in range(len(leftPins)):
        leftDirectionText, leftValuesText = getFieldTexts(
            index, leftPins, leftDirectionPins, leftValuesPins)
        pins.append([leftDirectionText, leftValuesText, leftPins[index]])

    for index in range(len(rightPins)):
        rightDirectionText, rightValuesText = getFieldTexts(
            index, rightPins, rightDirectionPins, rightValuesPins)
        pins[index +
             1] += [rightPins[index], rightValuesText, rightDirectionText]

    html_code='<div style="clear: both">'+\
    '<h4 style="float: left">RPi.GPIO version: ' + str(GPIO.VERSION) + '</h4>'+\
    '<h4 style="float: right">RPi Board Revision: ' + str(GPIO.RPI_REVISION) + '</h4>' +\
    '</div>' +\
    '<hr />'
    html_code += '<div id="gpio_table">\n'
    html_code += HTML.table(pins,
                            header_row=[
                                'DIRECTION', 'VALUE', 'LEFT', 'RIGHT', 'VALUE',
                                'DIRECTION'
                            ])
    html_code += '</div>\n'
    html_code += '<center><div id="user_space"></div><button class="btn btn-primary" onclick="gpio_clear()">Cleanup GPIO</button></center>'
    view.setContent('GPIO Manager', html_code)
    output(view, cgi.FieldStorage())
Esempio n. 7
0
def main():

    leftDirectionPins, rightDirectionPins = getDirections()
    leftValuesPins, rightValuesPins = getValues()
        
    pins = [[]]
    text = ''
    
    for index in range(len(leftPins)):
        leftDirectionText, leftValuesText = getFieldTexts(index, leftPins, leftDirectionPins, leftValuesPins)
        pins.append( [ leftDirectionText, leftValuesText, leftPins[index] ] )

    
    for index in range(len(rightPins)):
        rightDirectionText, rightValuesText = getFieldTexts(index, rightPins, rightDirectionPins, rightValuesPins)
        pins[index+1]+=[rightPins[index], rightValuesText, rightDirectionText ]

    html_code='<div style="clear: both">'+\
    '<h4 style="float: left">RPi.GPIO version: ' + str(GPIO.VERSION) + '</h4>'+\
    '<h4 style="float: right">RPi Board Revision: ' + str(GPIO.RPI_REVISION) + '</h4>' +\
    '</div>' +\
    '<hr />'
    html_code += '<div id="gpio_table">\n'
    html_code += HTML.table( pins, header_row=[ 'DIRECTION', 'VALUE', 'LEFT', 'RIGHT', 'VALUE', 'DIRECTION' ] )
    html_code += '</div>\n'
    html_code += '''
        <div align="center">
            <div id="user_space"></div>
                <button style="float: left;" class="btn btn-primary" onclick="gpio_clear()">Cleanup GPIO</button>
                <button style="float: right;" type="button" class="btn btn-info" onclick="navigate(\'/cgi-bin/toolkit/gpio_manager.py?type=js\');">Refresh</button>
        </div>
    
    ''' 
    view.setContent('GPIO Manager', html_code)
    output(view, cgi.FieldStorage())
def main():

    form = cgi.FieldStorage()
    
    cameraMgr = CameraManager()
    view.setContent('Pi Camera Controller', cameraMgr.generateView())
    output(view, form)
Esempio n. 9
0
def main():
    # Serves the update page
    fs = cgi.FieldStorage()
    content = get_view()
    view.setContent('Update', content)
    
    output(view, fs)
Esempio n. 10
0
def main():

    form = cgi.FieldStorage()

    cameraMgr = CameraManager()
    view.setContent('Pi Camera Controller', cameraMgr.generateView())
    output(view, form)
def main():
    content = '''
        <ul id="bpath" class='breadcrumb' style="margin-bottom: 5px;">
        </ul>
        <table id="file-manager-table" class="table table-striped table-hover ">
            <thead>
                <tr>
                    <th>Name</th>
                    <th>Type</th>
                    <th>Modified</th>
                    <th>Owner</th>
                    <th>Group</th>
                    <th>Size</th>
                </tr>
            </thead>
        </table>
        <div id="openDialog" title="Open with.">
  				<p>Choose a web-agent application to open your file with</p>
  				<ul>
  				</ul>
		</div>
				<link rel="stylesheet" href="/css/jquery-ui.css">
		<script src="/css/jquery-ui.js"></script>
		<script src="/css/file_manager.js" type="text/javascript"></script>
        
		 <script src="/css/appDefinitions.js" type="text/javascript"></script>
        <link href="/css/openDialog.css" type="text/css" rel="stylesheet" />
    '''
    view.setContent('File manager', content)
    output(view, cgi.FieldStorage())
Esempio n. 12
0
def main():
    # Serves the Volume manager page
    fs = cgi.FieldStorage()
    content = get_view()
    view.setContent('Volume manager', content)
    
    output(view, fs)
Esempio n. 13
0
def main():

    leftDirectionPins, rightDirectionPins = getDirections()
    leftValuesPins, rightValuesPins = getValues()
        
    pins = [[]]
    text = ''
    
    for index in range(len(leftPins)):
        leftDirectionText, leftValuesText = getFieldTexts(index, leftPins, leftDirectionPins, leftValuesPins)
        pins.append( [ leftDirectionText, leftValuesText, leftPins[index] ] )

    
    for index in range(len(rightPins)):
        rightDirectionText, rightValuesText = getFieldTexts(index, rightPins, rightDirectionPins, rightValuesPins)
        pins[index+1]+=[rightPins[index], rightValuesText, rightDirectionText ]

    html_code='<div style="clear: both">'+\
    '<h4 style="float: left">RPi.GPIO version: ' + str(GPIO.VERSION) + '</h4>'+\
    '<h4 style="float: right">RPi Board Revision: ' + str(GPIO.RPI_REVISION) + '</h4>' +\
    '</div>' +\
    '<hr />'
    html_code += '<div id="gpio_table">\n'
    html_code += HTML.table( pins, header_row=[ 'DIRECTION', 'VALUE', 'LEFT', 'RIGHT', 'VALUE', 'DIRECTION' ] )
    html_code += '</div>\n'
    html_code += '<center><div id="user_space"></div><button class="btn btn-primary" onclick="gpio_clear()">Cleanup GPIO</button></center>' 
    view.setContent('GPIO Manager', html_code)
    view.output()
Esempio n. 14
0
def main():
    content = '''
        <ul id="bpath" class='breadcrumb' style="margin-bottom: 5px;">
        </ul>
        <table id="file-manager-table" class="table table-striped table-hover ">
            <thead>
                <tr>
                    <th>Name</th>
                    <th>Type</th>
                    <th>Modified</th>
                    <th>Owner</th>
                    <th>Group</th>
                    <th>Size</th>
                </tr>
            </thead>
        </table>
        <div id="openDialog" title="Open with.">
  				<p>Choose a web-agent application to open your file with</p>
  				<ul>
  				</ul>
		</div>
				<link rel="stylesheet" href="/css/jquery-ui.css">
		<script src="/css/jquery-ui.js"></script>
		<script src="/css/file_manager.js" type="text/javascript"></script>
        
		 <script src="/css/appDefinitions.js" type="text/javascript"></script>
        <link href="/css/openDialog.css" type="text/css" rel="stylesheet" />
    '''
    view.setContent('File manager', content)
    output(view, cgi.FieldStorage())
Esempio n. 15
0
def main():
    # Serves the update page
    fs = cgi.FieldStorage()
    content = get_view()
    view.setContent('Update', content)

    output(view, fs)
Esempio n. 16
0
def main():
    form = cgi.FieldStorage()
    
    f = open(get_template('gpio_controller'))
    html_tables= f.read()
    f.close()

    view.setContent('GPIO Controller', html_tables)
    output(view, form)
Esempio n. 17
0
def main():
    form = cgi.FieldStorage()

    f = open(get_template('gpio_controller'))
    html_tables = f.read()
    f.close()

    view.setContent('GPIO Controller', html_tables)
    output(view, form)
Esempio n. 18
0
def main():
    '''
    generates an error page 
    '''
    fs = cgi.FieldStorage()
    view.setContent(
        'Page not found',
        'The requested page was not found. Did you type the url manually?')
    output(view, fs)
Esempio n. 19
0
def main():
    '''
    generates an error page 
    '''
    fs = cgi.FieldStorage()
    view.setContent('Timeout error',
        'We are sorry that a timeout occured. '+\
        'We probably know that this task takes time and ' +\
        'we are working to fix it!')
    output(view, fs)
Esempio n. 20
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))
Esempio n. 21
0
def main():
    '''
    generates an error page 
    '''
    fs=cgi.FieldStorage()
    view.setContent('Timeout error', 
        'We are sorry that a timeout occured. '+\
        'We probably know that this task takes time and ' +\
        'we are working to fix it!')
    output(view, fs)
Esempio n. 22
0
def main():
    form = cgi.FieldStorage()
    updMgr = UpdateManager()

    if 'action' in form:       
        if form['action'].value == 'update':
            view.setContent('Update Manager', updMgr.performUpdate())
    else:
        view.setContent('Update Manager', updMgr.getDefaultView())
    view.output()
Esempio n. 23
0
def main():
    if password_changed():
        main_view_file = open(MAIN_VIEW)
        content = main_view_file.read()
        main_view_file.close()
        view.setContent('Welcome', content)
        fs=cgi.FieldStorage()
    
        output(view, fs)
    else:
        redirect()
Esempio n. 24
0
def main():
    if password_changed():
        main_view_file = open(MAIN_VIEW)
        content = main_view_file.read()
        main_view_file.close()
        view.setContent('Welcome', content)
        fs = cgi.FieldStorage()

        output(view, fs)
    else:
        redirect()
Esempio n. 25
0
def main():
    # Serves the mplayer page
    fs = cgi.FieldStorage()
    mpm = MediaPlayerManager()
    if (not mpm.check_status()):
        view.setContent('Media Player', mpm._generateMissingDependenciesView())
        output(view,fs)
        return
    content = get_view()
    view.setContent('Mplayer', content)
    
    output(view, fs)
Esempio n. 26
0
def main():
    #fs=cgi.FieldStorage()
    fs={'page':'System Information'}    
    ID=fs['page']
    try:
        action=config.system.actions[ID]
    except KeyError as ke:
        view.setContent('Page not found', 'The requested page was not found. Did you type the url manually?')
        view.output()
        return
    ada=AdapterAndroid(ID,view,action.command_groups)
    print ada.toAndroidXML()
Esempio n. 27
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))
Esempio n. 28
0
def main():
    # Serves the mplayer page
    fs = cgi.FieldStorage()
    mpm = MediaPlayerManager()
    if (not mpm.check_status()):
        view.setContent('Media Player', mpm._generateMissingDependenciesView())
        output(view, fs)
        return
    content = get_view()
    view.setContent('Mplayer', content)

    output(view, fs)
Esempio n. 29
0
def download(file_path):
    try:
        file_for_download = open(file_path)
    except IOError:
        view.setContent("Error 404", "Permission denied!")
        output(view, cgi.FieldStorage())
        return
    print "Content-type: application/octet-stream"
    print 'Content-Disposition: inline; filename="' + os.path.basename(file_path) + '"'
    print
    print file_for_download.read()
    file_for_download.close()
Esempio n. 30
0
def main():
    '''
Application to display the iptables of raspberry to the user
'''

    form = cgi.FieldStorage()

    f = open(get_template('firewall_controller'))
    html_tables = f.read()
    f.close()

    view.setContent('IPTables', html_tables)
    output(view, form)
Esempio n. 31
0
def main():
    '''
Application to display the iptables of raspberry to the user
'''

    form = cgi.FieldStorage()
    
    f = open(get_template('firewall_controller'))
    html_tables= f.read()
    f.close()

    view.setContent('IPTables', html_tables)
    output(view, form)
Esempio n. 32
0
def main():
    """
    The mplayer port for py web agent
    If you read this code, it is better acompanied
    with the following documentation for improved
    understanding:
    http://www.mplayerhq.hu/DOCS/man/en/mplayer.1.txt 
    You can also have a look at:
    http://jqueryui.com/slider/ for /css/sliders.js
    And for mplayer_status.py:
    	mplayer slave cmmands:
    		http://www.mplayerhq.hu/DOCS/tech/slave.txt
    	rfc3875:
    		http://www.ietf.org/rfc/rfc3875.txt
    If you have any questons about this feature send me an email at:
    andreasgalazis-AT-yahoo.com(replace -At- with @)
    or for more generic pi-web agent questions
    ask any member of the kupepia team.
    """
    form = cgi.FieldStorage()
    if execute('pidof mplayer')[1]==0:
        settingsReader=SettingsReader("/tmp/mplayer_status")
        settingsReader.read()
        view.setContent('Mplayer', getRunningView("",settingsReader.getVolume(), settingsReader.getEQ().split(':')))
    elif "uri" not in form and "volume" not in form:
        view.setContent('Mplayer', getView(None))
    elif "uri" not in form :
        view.setContent('Mplayer', getView("Please provide a uri"))
    else:
        player = MPlayer(form)
        player.startStream();
        view.setContent('Mplayer', getRunningView(form.getvalue("uri"),form.getvalue("volume"),"0:0:0:0:0:0:0:0:0:0".split(':')))
    
    output(view, form)
Esempio n. 33
0
def main():
    '''
    Services application to manage levels of each service.
    It will support only enable/disable for a service.
    Unfinished.
    '''
    form = cgi.FieldStorage()

    f = open(get_template('services_controller'))
    html_tables = f.read()
    f.close()

    view.setContent('Services Management App', html_tables)
    output(view, form)
Esempio n. 34
0
def main():
    '''
    Services application to manage levels of each service.
    It will support only enable/disable for a service.
    Unfinished.
    '''
    form = cgi.FieldStorage()
    
    f = open(get_template('services_controller'))
    html_tables= f.read()
    f.close()
    
    view.setContent('Services Management App', html_tables)
    output(view, form)
Esempio n. 35
0
def main():
    '''
    Services application to manage levels of each service.
    It will support only enable/disable for a service.
    Unfinished.
    '''
    form = cgi.FieldStorage()

    sm = serviceManagerBuilder()

    content = sm.getView()

    view.setContent('Services Management App', content)
    output(view, form)
Esempio n. 36
0
def main():
    pm=PowerManager()
    fs=cgi.FieldStorage()
    
    if "action_list" in fs:
        
        if pm.execute_command(fs["action_list"].value):
            content="System will " + fs["action_list"].value
        else:
            content=getView()
    else:
        content=getView()
    view.setContent('Power management', content)
    
    output(view, fs)
Esempio n. 37
0
def main():
    '''
    Services application to manage levels of each service.
    It will support only enable/disable for a service.
    Unfinished.
    '''
    form = cgi.FieldStorage()
    
        
    sm=serviceManagerBuilder()
            
    content=sm.getView()
    
    view.setContent('Services Management App', content)
    output(view, form)
Esempio n. 38
0
def main():
    pm = PowerManager()
    fs = cgi.FieldStorage()

    if "action_list" in fs:

        if pm.execute_command(fs["action_list"].value):
            content = "System will " + fs["action_list"].value
        else:
            content = getView()
    else:
        content = getView()
    view.setContent('Power management', content)

    output(view, fs)
def main():
    '''
    Application to manage the most used packages using apt-get.
    Still in progress.
    '''

    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 ) )
    else :
      if ( 'action' in form and form['action'].value == 'getPackageList' ) :
        #ajax call response
        composeJS( json.dumps( getPackageList( ) ) )
      elif ( getAptBusy( ) ):
        view.setContent('Package Management',\
        '<script src="/css/reloadBasedOnStatus.js"></script>\
        The package manager is busy right now. . . \
        This page will automatically reload once the service is available')
        output(view, form)
      else :
        #lazyloading will populate the table
        htmlcode = '<script src="/css/lazyLoading.js"></script>\
        \n<script src="/css/autocomplete.js"></script>'
        
        #enable search feature
        htmlcode += '\n<div class="form-group" style="margin-bottom: 0px;overflow: hidden;">\
        \n<input id="autocomplete" name="filter" \
        onkeyup="filter( \'autocomplete\',\'packages-table-id\',1 )" type="text" \
        class="form-control" style="float:left;width:20%;" placeholder="Search. . .">\
        \n\
        <div style="padding-top: 10px;">\
            <button id="extensive_search" style="float: right;" class="btn btn-primary" onclick="extensive_search();">\
            Search package</button>\
        </div>\
        </div>'
        
        htmlcode += "\n<div id='packages-table'><table id='packages-table-id'>"
        htmlcode += "\n</table></div>"
        view.setContent('Package Management', htmlcode )
        output(view, form)  
Esempio n. 40
0
def main():
    '''
    gets the ID from the url as key/value=page/action_id
    and through the adapter displays the result of
    the action with ID=action_id. This functionality composed
    with the GenericAdapter help in the portability and API design
    as importing new functions depends now solely on the xml 
    '''
    fs=cgi.FieldStorage()
    ID=fs["page"].value
    try:
        action=config.system.actions[ID]
    except KeyError as ke:
        view.setContent('Page not found', 'The requested page was not found. Did you type the url manually?')
        view.output()
        return
    adapter=GenericAdapter(ID, view, action.command_groups)
    adapter.page()
def main():
    '''
    Application to manage the most used packages using apt-get.
    Still in progress.
    '''

    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))
    else:
        if ('action' in form and form['action'].value == 'getPackageList'):
            #ajax call response
            composeJS(json.dumps(getPackageList()))
        elif (getAptBusy()):
            view.setContent('Package Management',\
            '<script src="/css/reloadBasedOnStatus.js"></script>\
        The package manager is busy right now. . . \
        This page will automatically reload once the service is available'                                                                              )
            output(view, form)
        else:
            #lazyloading will populate the table
            htmlcode = '<script src="/css/lazyLoading.js"></script>\
        \n<link rel="stylesheet" href="/css/jquery-ui.css">\
        \n<script src="/css/jquery-ui.js"></script>\
        \n<script src="/css/autocomplete.js"></script>'

            #enable search feature
            htmlcode += '\n<div class="form-group" style="margin-bottom: 0px;overflow: hidden;">\
        \n<input id="autocomplete" name="filter" \
        onkeyup="filter( \'autocomplete\',\'packages-table-id\',1 )" type="text" \
        class="form-control" style="float:left;width:20%;" placeholder="Search. . .">\
        \n</div>'

            htmlcode += "\n<div id='packages-table'><table id='packages-table-id'>"
            htmlcode += "\n</table></div>"
            view.setContent('Package Management', htmlcode)
            output(view, form)
Esempio n. 42
0
def main():

    form = cgi.FieldStorage()
    if 'cmd' in form:
        command = form['cmd'].value
        if command == 'start':
            response("0")
            p = subprocess.Popen(['/bin/bash', '/usr/bin/start-stream-cam.sh'],
                                 stdout=subprocess.PIPE,
                                 stderr=subprocess.STDOUT)
        elif command == 'stop':
            try:
                execute('sudo kill $(pidof raspivid)')
            except:
                pass
        response("0")
        return

    content = getView()
    view.setContent('Live camera', content)

    output(view, form)
Esempio n. 43
0
def main():
    '''
    gets the ID from the url as key/value=page/action_id
    and through the adapter displays the result of
    the action with ID=action_id. This functionality composed
    with the GenericAdapter help in the portability and API design
    as importing new functions depends now solely on the xml 
    '''
    fs = cgi.FieldStorage()
    try:
        ID = fs["page"].value
        action = config.system.cmdactions[ID]
    except KeyError as ke:
        view.setContent(
            'Page not found',
            'The requested page was not found. Did you type the url manually?')
        output(view, fs)
        return
    adapter = GenericAdapter(ID, action['command-group'])
    title, html = adapter.page()
    view.setContent(title, html)
    output(view, fs)
Esempio n. 44
0
def main():    
    
    form = cgi.FieldStorage()
    if 'cmd' in form:
        command = form['cmd'].value
        if command == 'start':
            response("0")
            p = subprocess.Popen(['/bin/bash', '/usr/bin/start-stream-cam.sh'], 
                            stdout=subprocess.PIPE,
                            stderr=subprocess.STDOUT)
        elif command == 'stop':
            try:
                execute('sudo kill $(pidof raspivid)')
            except:
                pass
        response("0")
        return
    
    content=getView()
    view.setContent('Live camera', content)
    
    output(view, form)
Esempio n. 45
0
def main():

    form = cgi.FieldStorage()
    
    pictures, returncode = execute("ls /usr/share/pi-web-agent/camera-media/*.jpg")
    linearray = pictures.split('\n')
    
    html = '<div id="camera_toolbar">\n'
    html += '<a id="makePreview" class="btn btn-primary" onclick=\'camera_utils("play")\'>Play</a>'
    html += '<a id="takeSnapshot" class="btn btn-primary" onclick=\'camera_utils("snapshot")\'>Snapshot</a>'
    html += '<a id="startRecord" class="btn btn-primary" onclick=\'camera_utils("startrecord")\'>Record</a>'
    html += '<a id="stopRecord" class="btn btn-primary" onclick=\'camera_utils("stoprecord")\'>Stop</a>'
    html += '</div><br>'
    html += '''<div id="gallery_thumbnails"<p>'''
    
    for thisline in linearray:
        justname = thisline.split('/')[-1]
        if len(justname) <= 0:
            continue
        html += '<a href="/cgi-bin/toolkit/image_manager.py?image='+justname +'" rel="thumbnail"><img style="padding:4px; border:2px solid #021a40;" src="/cgi-bin/toolkit/image_manager.py?image='+justname.split('.')[0]+'.png" style="width: 64px; height: 64px" /></a>'
    html += '</p></div><br>'

    view.setContent('Live camera', html)
    output(view, cgi.FieldStorage())
Esempio n. 46
0
def main():
    form = cgi.FieldStorage()
    if "passwd" not in form and "passwd_new1" not in form and "passwd_new2" not in form:
        view.setContent('User management', getView())
    else:
        pm = PasswordManager(form, 'admin')
        try:
            pm.doTransaction()
            view.setContent("User management", getSuccessView())

        except Exception as e:
            view.setContent("User management", getFailedView(e.strerror))

    output(view, form)
Esempio n. 47
0
def main():
    form = cgi.FieldStorage()
    if "passwd" not in form and "passwd_new1" not in form and "passwd_new2" not in form:
        view.setContent('User management', getView())
    else:
        pm = PasswordManager(form, 'admin')
        try:
            pm.doTransaction()
            view.setContent("User management", getSuccessView())
            
        except Exception as e:
            view.setContent("User management", getFailedView(e.strerror))

    output(view, form)
Esempio n. 48
0
def main():
    form = cgi.FieldStorage()
    if (getAptBusy( )):
      view.setContent('Update Manager',\
      '<script src="/css/reloadBasedOnStatus.js"></script>\
      The Update Manager is busy right now. . . \
      This page will automatically reload once the service is available')
      output(view, form)
      return 
    updMgr = UpdateManager()

    if 'action' in form:       
        if form['action'].value == 'update':
            view.setContent('Update Manager', updMgr.performUpdate())
    else:
        view.setContent('Update Manager', updMgr.getDefaultView())
    output(view, form)
Esempio n. 49
0
def main():
    form = cgi.FieldStorage()
    if (getAptBusy()):
        view.setContent('Update Manager',\
        '<script src="/css/reloadBasedOnStatus.js"></script>\
      The Update Manager is busy right now. . . \
      This page will automatically reload once the service is available'                                                                          )
        output(view, form)
        return
    updMgr = UpdateManager()

    if 'action' in form:
        if form['action'].value == 'update':
            view.setContent('Update Manager', updMgr.performUpdate())
    else:
        view.setContent('Update Manager', updMgr.getDefaultView())
    output(view, form)
Esempio n. 50
0
def main():
    vncMgr = VNCManager()
    html = vncMgr.generateView()
    view.setContent('VNC Viewer', html)
    output(view, cgi.FieldStorage())
Esempio n. 51
0
def main():
    tFile = open(get_template('file_manager_controller'))
    content = tFile.read()
    tFile.close()
    view.setContent('File manager', content)
    output(view, cgi.FieldStorage())
Esempio n. 52
0
def main():
    vncMgr = VNCManager()
    html = vncMgr.generateView()
    view.setContent('VNC Viewer', html)
    output(view, cgi.FieldStorage())
Esempio n. 53
0
def main():
    form = cgi.FieldStorage()
    startupMgr = StartupManager()
    view.setContent('Startup Manager', startupMgr.getView())
    output(view, form)