How to use do_report method in molecule

Best Python code snippet using molecule_python

iq_report.py

Source:iq_report.py Github

copy

Full Screen

1#!/usr/bin/env python32# -*- coding: utf-8 -*-3"""4iqReport - Report management program.5Command line options:6 7 python iq_report.py <Launch parameters>8 9Launch parameters:10 [Help and debugging]11 --help|-h|-? Print help12 --version|-v Print version13 --debug|-d Debug mode14 --log|-l Log mode15 [Launch modes]16 --viewer|-V The mode of selecting a report and sending it to print17 --editor|-E Mode with support for calling the report editor18 --print=|-p= Run mode for generating a report with printing19 --preview=|-P= Report generation start-up mode with preview20 --export=|-E= Start-up mode for generating a report with subsequent conversion to office21 --select=|-S= The mode of launching the formation of the report with the subsequent choice of action22 --gen= Report generation launch mode with additional parameters23 --db= Indication of communication with the database (in the form of url)24 --sql= Specifying an SQL query to get a report table25 --postprint Print report after generation26 --postpreview Report preview after generation27 --postexport Convert Office report after generation28 --stylelib= Specify a style library for single reporting29 --var= Adding a variable to populate in the report30 --path= Specifying a Report Folder31 --no_gui Enabling console mode32"""33import sys34import os35import os.path36import getopt37import wx38from iq.util import log_func39from iq.util import file_func40from iq.util import global_func41from iq import global_data42try:43 from .report import do_report44except ModuleNotFoundError:45 from report import do_report46__version__ = (0, 0, 2, 2)47DEFAULT_REPORTS_PATH = os.path.join(file_func.getFrameworkPath(), 'reports')48LOG_FILENAME = os.path.join(file_func.getProfilePath(), 'iq_report')49def main(argv):50 """51 Main function.52 :param argv: A list of command line options.53 """54 # Parse command line options55 try:56 options, args = getopt.getopt(argv, 'h?vdVEDpPES',57 ['help', 'version', 'debug', 'log',58 'viewer', 'editor',59 'postprint', 'postpreview', 'postexport',60 'print=', 'preview=', 'export=', 'select=',61 'gen=', 'db=', 'sql=',62 'stylelib=', 'var=', 'path=',63 'no_gui'])64 except getopt.error as err:65 log_func.warning(err.msg, is_force_print=True)66 log_func.info(__doc__, is_force_print=True)67 sys.exit(2)68 report_filename = None69 db = None70 sql = None71 do_cmd = None72 stylelib = None73 variables = dict()74 path = None75 mode = 'default'76 mode_arg = None77 for option, arg in options:78 if option in ('-h', '--help', '-?'):79 log_func.info(__doc__, is_force_print=True)80 sys.exit(0) 81 elif option in ('-v', '--version'):82 version_txt = 'iqReport version: %s' % '.'.join([str(ver) for ver in __version__])83 log_func.info(version_txt, is_force_print=True)84 sys.exit(0)85 elif option in ('-d', '--debug'):86 global_func.setDebugMode()87 elif option in ('-l', '--log'):88 global_func.setLogMode()89 elif option in ('-V', '--viewer'):90 mode = 'view'91 elif option in ('-E', '--editor'):92 mode = 'edit'93 elif option in ('-p', '--print'):94 mode = 'print'95 mode_arg = arg96 elif option in ('-P', '--preview'):97 mode = 'preview'98 mode_arg = arg99 elif option in ('-E', '--export'):100 mode = 'export'101 mode_arg = arg102 elif option in ('-S', '--select'):103 mode = 'select'104 mode_arg = arg105 elif option in ('--gen',):106 report_filename = arg107 elif option in ('--db',):108 db = arg109 elif option in ('--sql',):110 sql = arg111 elif option in ('--postprint',):112 do_cmd = do_report.DO_COMMAND_PRINT113 elif option in ('--postpreview',):114 do_cmd = do_report.DO_COMMAND_PREVIEW115 elif option in ('--postexport',):116 do_cmd = do_report.DO_COMMAND_EXPORT117 elif option in ('--stylelib',):118 stylelib = arg119 elif option in ('--var',):120 var_name = arg.split('=')[0].strip()121 var_value = arg.split('=')[-1].strip()122 variables[var_name] = var_value123 log_func.debug(u'External variable <%s>. Value [%s]' % (str(var_name), str(var_value)))124 elif option in ('--path',):125 path = arg126 elif option in ('--no_gui', ):127 global_func.setEngineType(global_data.CUI_ENGINE_TYPE)128 log_func.init(LOG_FILENAME)129 # You must add the path to the report folder so that import of report modules130 if path is None:131 path = DEFAULT_REPORTS_PATH132 if os.path.exists(path) and os.path.isdir(path) and path not in sys.path:133 sys.path.append(path)134 app = wx.App()135 # locale = wx.Locale()136 # locale.Init(wx.LANGUAGE_RUSSIAN)137 if mode == 'default':138 if report_filename:139 # Run report generation from the command line140 do_report.doReport(report_filename=report_filename, report_dir=path,141 db_url=db, sql=sql, command=do_cmd,142 stylelib_filename=stylelib, variables=variables)143 elif mode == 'view':144 do_report.openReportViewer(report_dir=path)145 elif mode == 'edit':146 do_report.openReportEditor(report_dir=path)147 elif mode == 'print':148 do_report.printReport(report_filename=mode_arg, report_dir=path,149 db_url=db, sql=sql, command=do_cmd,150 stylelib_filename=stylelib, variables=variables)151 elif mode == 'preview':152 do_report.previewReport(report_filename=mode_arg, report_dir=path,153 db_url=db, sql=sql, command=do_cmd,154 stylelib_filename=stylelib, variables=variables)155 elif mode == 'export':156 do_report.exportReport(report_filename=mode_arg, report_dir=path,157 db_url=db, sql=sql, command=do_cmd,158 stylelib_filename=stylelib, variables=variables)159 elif mode == 'select':160 do_report.selectReport(report_filename=mode_arg, report_dir=path,161 db_url=db, sql=sql, command=do_cmd,162 stylelib_filename=stylelib, variables=variables)163 app.MainLoop()164if __name__ == '__main__':...

Full Screen

Full Screen

action.py

Source:action.py Github

copy

Full Screen

...31 raise_if_shutting_down()32 try:33 if not dry_run:34 self.do_action(bucket, reporter)35 self.do_report(bucket, reporter)36 except Exception as e:37 logger.exception('an exception occurred in a sync action')38 reporter.error(str(self) + ": " + repr(e) + ' ' + str(e))39 raise # Re-throw so we can identify failed actions40 @abstractmethod41 def get_bytes(self):42 """43 Returns the number of bytes to transfer for this action.44 """45 @abstractmethod46 def do_action(self, bucket, reporter):47 """48 Performs the action, returning only after the action is completed.49 """50 @abstractmethod51 def do_report(self, bucket, reporter):52 """53 Report the action performed.54 """55class B2UploadAction(AbstractAction):56 def __init__(self, local_full_path, relative_name, b2_file_name, mod_time_millis, size):57 self.local_full_path = local_full_path58 self.relative_name = relative_name59 self.b2_file_name = b2_file_name60 self.mod_time_millis = mod_time_millis61 self.size = size62 def get_bytes(self):63 return self.size64 def do_action(self, bucket, reporter):65 bucket.upload(66 UploadSourceLocalFile(self.local_full_path),67 self.b2_file_name,68 file_info={SRC_LAST_MODIFIED_MILLIS: str(self.mod_time_millis)},69 progress_listener=SyncFileReporter(reporter)70 )71 def do_report(self, bucket, reporter):72 reporter.print_completion('upload ' + self.relative_name)73 def __str__(self):74 return 'b2_upload(%s, %s, %s)' % (75 self.local_full_path, self.b2_file_name, self.mod_time_millis76 )77class B2HideAction(AbstractAction):78 def __init__(self, relative_name, b2_file_name):79 self.relative_name = relative_name80 self.b2_file_name = b2_file_name81 def get_bytes(self):82 return 083 def do_action(self, bucket, reporter):84 bucket.hide_file(self.b2_file_name)85 def do_report(self, bucket, reporter):86 reporter.update_transfer(1, 0)87 reporter.print_completion('hide ' + self.relative_name)88 def __str__(self):89 return 'b2_hide(%s)' % (self.b2_file_name,)90class B2DownloadAction(AbstractAction):91 def __init__(92 self, relative_name, b2_file_name, file_id, local_full_path, mod_time_millis, file_size93 ):94 self.relative_name = relative_name95 self.b2_file_name = b2_file_name96 self.file_id = file_id97 self.local_full_path = local_full_path98 self.mod_time_millis = mod_time_millis99 self.file_size = file_size100 def get_bytes(self):101 return self.file_size102 def do_action(self, bucket, reporter):103 # Make sure the directory exists104 parent_dir = os.path.dirname(self.local_full_path)105 if not os.path.isdir(parent_dir):106 try:107 os.makedirs(parent_dir)108 except OSError:109 pass110 if not os.path.isdir(parent_dir):111 raise Exception('could not create directory %s' % (parent_dir,))112 # Download the file to a .tmp file113 download_path = self.local_full_path + '.b2.sync.tmp'114 download_dest = DownloadDestLocalFile(download_path)115 bucket.download_file_by_name(self.b2_file_name, download_dest, SyncFileReporter(reporter))116 # Move the file into place117 try:118 os.unlink(self.local_full_path)119 except OSError:120 pass121 os.rename(download_path, self.local_full_path)122 def do_report(self, bucket, reporter):123 reporter.print_completion('dnload ' + self.relative_name)124 def __str__(self):125 return (126 'b2_download(%s, %s, %s, %d)' %127 (self.b2_file_name, self.file_id, self.local_full_path, self.mod_time_millis)128 )129class B2DeleteAction(AbstractAction):130 def __init__(self, relative_name, b2_file_name, file_id, note):131 self.relative_name = relative_name132 self.b2_file_name = b2_file_name133 self.file_id = file_id134 self.note = note135 def get_bytes(self):136 return 0137 def do_action(self, bucket, reporter):138 bucket.api.delete_file_version(self.file_id, self.b2_file_name)139 def do_report(self, bucket, reporter):140 reporter.update_transfer(1, 0)141 reporter.print_completion('delete ' + self.relative_name + ' ' + self.note)142 def __str__(self):143 return 'b2_delete(%s, %s, %s)' % (self.b2_file_name, self.file_id, self.note)144class LocalDeleteAction(AbstractAction):145 def __init__(self, relative_name, full_path):146 self.relative_name = relative_name147 self.full_path = full_path148 def get_bytes(self):149 return 0150 def do_action(self, bucket, reporter):151 os.unlink(self.full_path)152 def do_report(self, bucket, reporter):153 reporter.update_transfer(1, 0)154 reporter.print_completion('delete ' + self.relative_name)155 def __str__(self):...

Full Screen

Full Screen

python_composition.py

Source:python_composition.py Github

copy

Full Screen

...4 def __init__(self):5 self._name = type(self).__name__6 print("Creating", self._name)7 @abstractmethod8 def do_report(self):9 pass10class Page1(BasePage):11 def do_report(self):12 print(self._name, "creating Page 1")13class Page2(BasePage):14 def do_report(self):15 print(self._name, "creating Page 2")16class Page3(BasePage):17 def do_report(self):18 print(self._name, "creating Page 3")19class Report():20 def __init__(self):21 self._pages = []22 def add_page(self, page):23 self._pages.append(page)24 def print_report(self):25 print("REPORT HEADER")26 for page in self._pages:27 page.do_report()28 print("REPORT FOOTER")29r1 = Report()30p1 = Page1()31p2 = Page2()32r1.add_page(p1)33r1.add_page(p2)34r1.print_report()35print('-' * 60)36r2 = Report()37p1 = Page3()38p2 = Page1()39r2.add_page(p1)40r2.add_page(p2)41r2.print_report()

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 molecule 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