def recursiveProfileTest( username, password, testInterval, totalCount, startList): """Run a recursive get profile test.""" generator = recursiveTestGenerator( username, password, testInterval, totalCount, startList) while True: try: id, info, errorCode = generator.next() if not errorCode: log.info('Profile url: ' + RenrenAgent.getProfileUrl(id)) path = util.saveTestPage(info.html, id) log.info('Profile local path: file://'+path) printInfo(info) except Exception, e: log.error('Error happen or end: ' + str(e)) break
def getProfileTest(agent, id, filePath=''): if filePath: log.info('================= Get Profile test (Local Html) ======' +\ '=======================') log.info('Local Profile path: file://' + filePath) html = open(filePath).read() info, errorCode = agent.parseProfileHtml(html) if errorCode: log.error('Error happen in parse local html, path: ' + filePath) return else: log.info('================= Get Profile test (Online Html) =====' +\ '=======================') log.info('Profile url: ' + agent.getProfileUrl(id)) info, errorCode = agent.getProfile(id) if errorCode: log.error('Error happen in get profile, id: ' + id) return if not info.html: log.warning('No html') return path = util.saveTestPage(info.html, id) log.info('Online Profile path: file://'+path) printInfo(info)