How to use set_stdout method in autotest

Best Python code snippet using autotest_python

bibauthorid_general_utils.py

Source:bibauthorid_general_utils.py Github

copy

Full Screen

...39 if fileout:40 FO = True41 if stdout:42 FO = False43def set_stdout():44 if FO:45 try:46 sys.stdout = pidfiles[PID()]47 except KeyError:48 pidfiles[PID()] = open('/tmp/bibauthorid_log_pid_'+str(PID()),'w')49 sys.stdout = pidfiles[PID()]50 print 'REDIRECTING TO PIDFILE '51#python2.4 compatibility layer.52try:53 any([True])54except:55 def any(x):56 for element in x:57 if element:58 return True59 return False60bai_any = any61try:62 all([True])63except:64 def all(x):65 for element in x:66 if not element:67 return False68 return True69bai_all = all70#end of python2.4 compatibility. Please remove this horror as soon as all systems will have71#been ported to python2.6+72def __print_func(*args):73 set_stdout()74 if PRINT_TS:75 print datetime.now(),76 for arg in args:77 print arg,78 print ""79 sys.stdout.flush()80def __dummy_print(*args):81 pass82def __create_conditional_print(cond):83 if cond:84 return __print_func85 else:86 return __dummy_print87bibauthor_print = __create_conditional_print(bconfig.DEBUG_OUTPUT)88name_comparison_print = __create_conditional_print(bconfig.DEBUG_NAME_COMPARISON_OUTPUT)89metadata_comparison_print = __create_conditional_print(bconfig.DEBUG_METADATA_COMPARISON_OUTPUT)90wedge_print = __create_conditional_print(bconfig.DEBUG_WEDGE_OUTPUT)91if bconfig.DEBUG_OUTPUT:92 status_len = 2093 comment_len = 4094 def padd(stry, l):95 return stry[:l].ljust(l)96 def update_status(percent, comment="", print_ts=False):97 set_stdout()98 filled = int(percent * status_len-2)99 bar = "[%s%s] " % ("#" * filled, "-" * (status_len-2 - filled))100 percent = ("%.2f%% done" % (percent * 100))101 progress = padd(bar + percent, status_len)102 comment = padd(comment, comment_len)103 if print_ts or PRINT_TS_US:104 print datetime.now(),105 print 'pid:',PID(),106 print progress, comment, TERMINATOR,107 sys.stdout.flush()108 def update_status_final(comment=""):109 set_stdout()110 update_status(1., comment, print_ts=PRINT_TS)111 print ""112 sys.stdout.flush()113else:114 def update_status(percent, comment=""):115 pass116 def update_status_final(comment=""):117 pass118def print_tortoise_memory_log(summary, fp):119 stry = "PID:\t%s\tPEAK:\t%s,%s\tEST:\t%s\tBIBS:\t%s\n" % (summary['pid'], summary['peak1'], summary['peak2'], summary['est'], summary['bibs'])120 fp.write(stry)121def parse_tortoise_memory_log(memfile_path):122 f = open(memfile_path)123 lines = f.readlines()...

Full Screen

Full Screen

log.py

Source:log.py Github

copy

Full Screen

...36 # create formatter37 self.formatter = logging.Formatter()38 # Default is to print to stdout39 self.ch = None40 self.set_stdout()41 def write(self, data):42 self.log.info(data)43 def flush(self):44 try:45 self.ch.flush()46 except Exception, e:47 pass48 def close(self):49 try:50 self.ch.close()51 except Exception, e:52 pass53 def set_quiet(self, state=True):54 level = logging.INFO55 if state:56 level = logging.ERROR57 self.log.setLevel(level)58 def set_debug(self, state=True):59 level = logging.INFO60 if state:61 level = logging.DEBUG62 self.log.setLevel(level)63 def set_logfile(self, filename, mode='w'):64 ch = logging.FileHandler(filename, mode=mode)65 ch.setFormatter(self.formatter)66 if self.ch:67 self.log.removeHandler(self.ch)68 self.log.addHandler(ch)69 self.ch = ch70 def set_fileobj(self, fileobj):71 pass72 def set_stdout(self):73 ch = logging.StreamHandler()74 ch.setFormatter(self.formatter)75 if self.ch:76 self.log.removeHandler(self.ch)77 self.log.addHandler(ch)78 self.ch = ch79# Singleton80logger = logger()81# Set the module functions.82log = logger.log.info83debug = logger.log.debug84info = logger.log.info85warn = logger.log.warn86error = logger.log.error...

Full Screen

Full Screen

notepad_pp.py

Source:notepad_pp.py Github

copy

Full Screen

...23 oResults.error = True24 oResults.set_violations(False)25 oResults.set_text(oInputArguments.text)26 sOutput = e.message27 oResults.set_stdout(sOutput)28 return oResults29 oVhdlFile.set_indent_map(oConfig.dIndent)30 oRules = rule_list.rule_list(oVhdlFile, oConfig.severity_list, commandLineArguments.local_rules)31 try:32 apply_rules.configure_rules(oConfig, oRules, oConfig.dIndent, iIndex, sFileName)33 except vsg.exceptions.ConfigurationError as e:34 oResults.error = True35 oResults.set_violations(False)36 oResults.set_text(oInputArguments.text)37 sOutput = e.message38 oResults.set_stdout(sOutput)39 return oResults40 oRules.fix(commandLineArguments.fix_phase, commandLineArguments.skip_phase, oConfig.dFixOnly)41 sOutput = '\n'.join(oVhdlFile.get_lines()[1:])42 oResults.set_text(sOutput)43 oRules.clear_violations()44 oRules.check_rules(45 bAllPhases=commandLineArguments.all_phases,46 lSkipPhase=commandLineArguments.skip_phase,47 )48 sStdOut, sIgnore = oRules.report_violations(commandLineArguments.output_format)49 oResults.set_stdout(sStdOut)50 oResults.set_violations(oRules.violations)51 return oResults52class InputArguments():53 def __init__(self):54 self.filename = str(None)55 self.text = None56 self.style = None57 self.configuration = []58 def set_text(self, sText):59 self.text = sText60 def set_style(self, sText):61 self.style = sText62 def add_configuration(self, sText):63 self.configuration.append(sText)64class Results():65 def __init__(self):66 self.text = None67 self.stdout = None68 self.violations = True69 self.error = False70 def set_text(self, sText):71 self.text = sText72 def get_text(self):73 return self.text74 def set_stdout(self, sText):75 self.stdout = sText76 def get_stdout(self):77 return self.stdout78 def has_violations(self):79 return self.violations80 def set_violations(self, bViolations):81 self.violations = bViolations82 def error_status(self):83 return self.error84class command_line_args():85 def __init__(self):86 self.fix = False87 self.style = None88 self.configuration = None...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful