def configure(): """ Perform startup configuration of the session proxy. """ from twisted.internet import task from tops.core.network.telnet import prepareTelnetSession # lookup our connection parameters hostname = config.get('tcc.session','telnet_host') port= config.getint('tcc.session','telnet_port') username = config.get('tcc.session','telnet_user') password = config.getsecret('tcc.session','telnet_pw') # initialize our telnet sessions prepareTelnetSession(VMSSession('VMS',username,password,debug=False),hostname,port) prepareTelnetSession(TCCSession('TCC',username,password,debug=False),hostname,port) # initialize periodic commands task.LoopingCall(show_status).start(5.0,now=False) task.LoopingCall(show_users).start(5.0,now=False)
TelnetSession.do('localhost','pwd').addCallback(answer,'pwd') TelnetSession.do('localhost','whoami').addCallback(answer,'whoami') from getpass import getpass from twisted.internet import reactor from tops.core.network.telnet import prepareTelnetSession if __name__ == "__main__": from getpass import getpass from twisted.internet import reactor from tops.core.network.telnet import prepareTelnetSession # Update these connection parameters for your testing environment debug = False (hostname,port,username) = ('localhost',23,'david') password = getpass('Enter password for %s@%s: ' % (username,hostname)) # prepare two parallel telnet client sessions prepareTelnetSession(FTPSession('FTP',username,password,debug),hostname,port) prepareTelnetSession(LocalhostSession('localhost',username,password,debug),hostname,port) # schedule commands to be sent asynchronously to both sessions reactor.callLater(1.0,ftp_commands) reactor.callLater(1.1,localhost_commands) # schedule our program's exit reactor.callLater(3.0,reactor.stop) # fire up the reactor reactor.run()