def lastFileName(self): session = Session(self.hostName, self.userName, self.password, self.rootUser, self.rootPasswd, "telnet", "ServerCheckFileBeforeCalling.log") print "***Got the billing before call***" try: session.waitUntil(self.timeout, 'login:'******'Password:'******'cdma184%') session.sendLine("cd " + self.fileDirectory + ";" + "ls -l" + "\n\r", 1) session.waitUntil(self.timeout, 'cdma184%') logPath = session.getLog() lastFileName = AnalyseText.analyseBillingList(logPath) print "\033[1;32;40m***Get the number( %s ) success*** [OK]\033[0m" %lastFileName return lastFileName except exception.TimeOutError, e: print "Timeout" return 1
def checkFile(self): session = Session(self.hostName, self.userName, self.password, self.rootUser, self.rootPasswd, "telnet", "ServerCheckFileBeforeCalling.log") #session.logfile = sys.stdout print "***Got the billing before call*** [2/5]" try: session.waitUntil(self.timeout, 'login:'******'Password:'******'cdma184%') session.sendLine("cd " + self.fileDirectory + ";" + "ls -l" + "\n\r", 1) session.waitUntil(self.timeout, 'cdma184%') logPath = session.getLog() lastestNum = analyse_text.analyseBillingList(logPath) print "\033[1;32;40m***Got the billing before call Success*** [OK]\033[0m" return 0, lastestNum except exception.TimeOutError, e: print "Timeout" return 1