Beispiel #1
0
def main():
    # Serves the update page
    fs = cgi.FieldStorage()
    content = get_view()
    view.setContent('Update', content)
    
    output(view, fs)
Beispiel #2
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)
Beispiel #3
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()
    config=Configuration()
    view = View(config.system.actions) 
    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('Radio', getView())
    else:
        player = MPlayer(form)
        player.startStream();
        view.setContent('Radio', getRunningView(form.getvalue("volume"),"0:0:0:0:0:0:0:0:0:0".split(':')))
    
    output(view, form)
def main():
    '''
    Application to manage the most used packages using apt-get.
    Unfinished.
    '''
    config=Configuration()
    view = View(config.system.actions)
    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 ( 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 :
        htmlcode = "\n<div id='packages-table'><table id='packages-table-id'>"
        htmlcode += "\n</table></div>"
        view.setContent('Package Management',\
        '<script src="/css/lazyLoading.js"></script>' + htmlcode )
        output(view, form)  
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)
def main():

    form = cgi.FieldStorage()
    
    cameraMgr = CameraManager()
    view.setContent('Pi Camera Controller', cameraMgr.generateView())
    output(view, form)
Beispiel #7
0
def Shield():
    framework.output('You pull out your shield, fearing the worst.',
                     'Do you stand and wait for the inevitable?')
    if framework.answer() == True:
        Continue()
    else:
        PutDown()
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())
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())
Beispiel #10
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())
Beispiel #11
0
def main():
    # Serves the update page
    fs = cgi.FieldStorage()
    content = get_view()
    view.setContent('Update', content)

    output(view, fs)
def main():
    # Serves the disk analyzer page
    fs = cgi.FieldStorage()
    content = get_view()
    view.setContent('Disk analyzer', content)
    
    output(view, fs)
Beispiel #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 += '''
        <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():
    # Serves the Volume manager page
    fs = cgi.FieldStorage()
    content = get_view()
    view.setContent('Volume manager', content)
    
    output(view, fs)
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())
Beispiel #17
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())
Beispiel #19
0
def Sword2():
    framework.output(
        "You grab the sword, feeling it's power. Meanwhile, the parasite has infected a large dog.",
        'Do you fight the dog?')
    if framework.answer() == True:
        Fight()
    else:
        Ignore()
Beispiel #20
0
def Vampire():
    framework.output(
        'You walk with the villager to his town. In the town square, you see  the dark shadow of a vampire.',
        'On the ground you see a large sword. Do you pick up the sword?')
    if framework.answer() == True:
        Sword()
    else:
        Shield()
Beispiel #21
0
def Sword():
    framework.output(
        'You weild the mighty sword in your hands, ready to fight the vampire.',
        'The vampire runs at you. Do you attack?')
    if framework.answer() == True:
        Attack()
    else:
        Dodge()
Beispiel #22
0
def start():
    framework.output(
        'You meet a villager from a nearby town. He begs you to help him fight off a vampire that is terrorizing his village. Do you accept?',
        '')
    if framework.answer() == True:
        Vampire()
    else:
        Parasite()
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)
Beispiel #24
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)
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)
Beispiel #26
0
def Parasite():
    framework.output(
        'You keep walking. In the trees you hear a parasite crawling towards  you.',
        'You are trying to put on your armor when you see a sword lying on the ground. Do you pick up the sword?'
    )
    if framework.answer() == True:
        Sword2()
    else:
        Armor()
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)
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 #29
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)
Beispiel #30
0
def main():
    '''
    Application to dipplay the iptables of raspberry to the user
    '''

    form = cgi.FieldStorage()
    
    sm=serviceManagerBuilder()
    config=Configuration()
    view = View(config.system.actions)

    #this is only for modifying iptables
    html_add_rule='<p></br>Choose action</br></p>'\
                    +'<form name="inputRule">'\
                    +'<select id="selectAction" class="form-control">'\
                        +'<option>Accept</option>'\
                        +'<option>Drop</option>'\
                        +'<option>Flush</option>'\
                    +'</select>'\
                    +'<select id="selectProtocol" class="form-control">'\
                        +'<option>ALL</option>'\
                        +'<option>TCP</option>'\
                        +'<option>UDPLITE</option>'\
                        +'<option>ICMP</option>'\
                        +'<option>ESP</option>'\
                        +'<option>AH</option>'\
                        +'<option>SCTP</option>'\
                    +'</select>'\
                    +'<input type="submit" value="Submit">'\
                    +'</form>' 
            
    
    html_tables='<div id="ip_overlay" style="display: none;">' +\
                '<div><h2>Add Rules</h2>'\
                + html_add_rule +'</div></div>'

    chain_els=[[]]
    iptables=IPTablesManager()
    header_list=['protocol', 'target', 'otherinfo','destination', 'source', 'option']       
    for chain in iptables.chains:
        html_tables+='<h4>' + chain +\
         ' (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)
Beispiel #31
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()
Beispiel #32
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()
Beispiel #33
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)
Beispiel #34
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 #35
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)
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()
Beispiel #37
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)
Beispiel #38
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)
Beispiel #39
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)
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)
Beispiel #41
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)
Beispiel #42
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)
Beispiel #43
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)
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():
    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():
    '''
    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)
Beispiel #47
0
def main():
    '''
Application for camera module
'''
    form = cgi.FieldStorage()
    
    sm=serviceManagerBuilder()
    config=Configuration()
    view = View(config.system.actions)
            
    f = open(os.environ['MY_HOME'] + '/html/camera_interface.html', 'r')
    html_interface= f.read()
    f.close()

    view.setContent('Camera Viewer', html_interface)
    output(view, cgi.FieldStorage())
Beispiel #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)
Beispiel #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)
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)  
Beispiel #51
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?")
        output(view, fs)
        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)
Beispiel #53
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)
Beispiel #54
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)
Beispiel #55
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)
Beispiel #56
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)
def main():
    '''
    Application to manage all the most used packages using apt-get.
    Unfinished.
    '''
    config=Configuration()
    view = View(config.system.actions)
    form = cgi.FieldStorage()
    if (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)
      return 
    
    htmlcode = ''

    ins = open( PACKAGES_LIST_PATH, "r" )
    packages = []
    for line in ins:
      line = line.rstrip() # strip the new line
      packages.append( line )

    allPackages = [[]]
    
    for pName in packages :
        checkedText = createOnOffSwitch( pName )
        descriptionText = getDpkgInfo( pName, "Description" )
        versionText = getDpkgInfo( pName, "Version" )
        allPackages.append( [ pName, checkedText, descriptionText, versionText ] )
    
    htmlcode += "\n<div id='packages-table'>"
    htmlcode += HTML.table( allPackages, header_row=['Package Name', 'Status', 'Description', 'Version'] )
    htmlcode += "\n</div>"

    view.setContent('Package Management', htmlcode )
    output(view, form)