I have created a form that takes server ip, username and password. I use pexpect to ssh into remote server, run a particular command and get basic data related to that server. I am creating the form using controller and also doing ssh in same controller and returning both form and processed data from same controller. But, when I run the html it is not displaying correct result, I am also confused on how I can load a table below add button inside a same page but as different frame.
My Controller script as below: # coding: utf8# try something likedef display(): import pexpect import sys import time import cgi, cgitb import getpass import urllib3 import xml.etree.ElementTree as ET import json attr = ["Hostname", "Model Name", "Version", "connected count", "online Count"] form=FORM(DIV('server IP', INPUT(_name = 'ipaddr', requires = IS_NOT_EMPTY()), 'Username', INPUT(_name = 'uname', requires = IS_NOT_EMPTY()), 'Password',INPUT(_name = 'password', _type = 'password', requires = IS_NOT_EMPTY()), INPUT(_value='Add',_type='submit'))) valuelist = list() if form.accepts(request,session): response.flash = 'form accepted' ssh_cmd = 'ssh' username = request.vars['uname'].strip() ip_addr = request.vars['ipaddr'].strip() password = request.vars['password'].strip() command = ssh_cmd+" "+username+"@"+ip_addr try: child = pexpect.spawn(command) child.expect('(?i)password') child.sendline(password) child.expect('bash2.1# ') child.sendline('show sys-summary general') child.expect('bash2.1# ') except Exception, e: print e print child.before lines = child.before for line in lines.split("\n"): if any(word in line for word in attr): keyValue = line.split(":", 1) value = keyValue[1].strip() valuelist.append(value) sys.stdout.flush() if child.isalive(): child.sendline('exit') # Try to ask ftp child to exit. child.close() if child.isalive(): print('Child did not exit gracefully.') else: print('Child exited gracefully.') elif form.errors: response.flash = 'form has errors' else: response.flash = 'please fill the form' return dict(form=form, valuelist=valuelist) Now my html code is as below. It is just simple and I want to test whether that particular values has been received accordingly or not, hence I am just calling returned value View code is: {{extend 'layout.html'}}<h2>Controller Page</h2>{{=form}}<h2>Submitted variables</h2>{{=valuelist}}<h2>Accepted variables</h2>{{=BEAUTIFY(form.vars)}}<h2>Errors in form</h2>{{=BEAUTIFY(form.errors)}} Could some one suggest, what change I can make so that I can see details of server below add button itself ? Like Server IP: Username: Password: add 222.222.222.222 examplehostname 333modelno 3.2 44 connected 22 online Thanks ! -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.