def main(): parser = argparse.ArgumentParser( description="Gather Bazel's issues and pull requests data") subparsers = parser.add_subparsers(dest="command", help="select a command") update_parser = subparsers.add_parser("update", help="update the datasets") update_parser.add_argument("--full", action='store_true', help="Do a full rather than incremental update") report_parser = subparsers.add_parser("report", help="generate a full report") garden_parser = subparsers.add_parser( "garden", help="generate issues/pull requests that need gardening attention") garden_parser.add_argument( '-i', '--list_issues', action='store_true', help="list issues that need attention (true/false)") garden_parser.add_argument( '-p', '--list_pull_requests', action='store_true', help="list pull requests that need attention (true/false)") garden_parser.add_argument( '-s', '--stale_for_days', type=int, default=0, help= "list issues/prs that have not been updated for more than the specified number of days (number, default is 0)" ) report_selector = report_parser.add_mutually_exclusive_group() report_selector.add_argument('-a', '--all', action="store_true", dest="all_reports", help="show all reports") report_selector.add_argument( "-r", "--report", action="append", choices=reports.report_names(), help="show selected report (multiple values possible)") args = parser.parse_args() if args.command == "update": update(args.full) elif args.command == "report": reports.report(args.report if args.report else reports.report_names()) elif args.command == "garden": reports.garden(args.list_issues, args.list_pull_requests, args.stale_for_days) else: parser.print_usage()
def report(self, _config, _build, opts, macros, format=None): if len(_build.main_package().name()) > 0 \ and not _build.macros.get('%{_disable_reporting}') \ and (not _build.opts.get_arg('--no-report') \ or _build.opts.get_arg('--mail')): if format is None: format = _build.opts.get_arg('--report-format') if format is not None: if len(format) != 2: raise error.general( 'invalid report format option: %s' % ('='.join(format))) format = format[1] if format is None: format = 'text' if format == 'text': ext = '.txt' elif format == 'asciidoc': ext = '.txt' elif format == 'html': ext = '.html' elif format == 'xml': ext = '.xml' elif format == 'ini': ext = '.ini' else: raise error.general('invalid report format: %s' % (format)) buildroot = _build.config.abspath('%{buildroot}') prefix = _build.macros.expand('%{_prefix}') name = _build.main_package().name() + ext log.notice('reporting: %s -> %s' % (_config, name)) if not _build.opts.get_arg('--no-report'): outpath = path.host( path.join(buildroot, prefix, 'share', 'rtems', 'rsb')) if not _build.opts.dry_run(): outname = path.host(path.join(outpath, name)) else: outname = None r = reports.report(format, self.configs, copy.copy(opts), copy.copy(macros)) r.introduction(_build.config.file_name()) r.generate(_build.config.file_name()) r.epilogue(_build.config.file_name()) if not _build.opts.dry_run(): _build.mkdir(outpath) r.write(outname) del r if _build.opts.get_arg('--mail'): r = reports.report('text', self.configs, copy.copy(opts), copy.copy(macros)) r.introduction(_build.config.file_name()) r.generate(_build.config.file_name()) r.epilogue(_build.config.file_name()) self.write_mail_report(r.out) del r
def main(argv): """Process the JSON data and generate a full report out of it.""" data = load_data("/home/student-00-e0f8d165ca2a/car_sales.json") summary = process_data(data) new_summary = '<br/>'.join(summary) print(summary) # TODO: turn this into a PDF report report('/tmp/cars.pdf', "Cars report", new_summary, cars_dict_to_table(data)) # TODO: send the PDF report as an email attachment msg = email_generate("*****@*****.**", "<username>@example.com", "Sales summary for last month", new_summary, "/tmp/cars.pdf") email_send(msg)
def report(self, _config, _build, opts, macros, format = None, mail = None): if len(_build.main_package().name()) > 0 \ and not _build.macros.get('%{_disable_reporting}') \ and (not _build.opts.get_arg('--no-report') \ or _build.opts.get_arg('--mail')): if format is None: format = _build.opts.get_arg('--report-format') if format is not None: if len(format) != 2: raise error.general('invalid report format option: %s' % \ ('='.join(format))) format = format[1] if format is None: format = 'text' if format == 'text': ext = '.txt' elif format == 'asciidoc': ext = '.txt' elif format == 'html': ext = '.html' elif format == 'xml': ext = '.xml' elif format == 'ini': ext = '.ini' else: raise error.general('invalid report format: %s' % (format)) buildroot = _build.config.abspath('%{buildroot}') prefix = _build.macros.expand('%{_prefix}') name = _build.main_package().name() + ext log.notice('reporting: %s -> %s' % (_config, name)) if not _build.opts.get_arg('--no-report'): outpath = path.host(path.join(buildroot, prefix, 'share', 'rtems', 'rsb')) if not _build.opts.dry_run(): outname = path.host(path.join(outpath, name)) else: outname = None r = reports.report(format, self.configs, copy.copy(opts), copy.copy(macros)) r.introduction(_build.config.file_name()) r.generate(_build.config.file_name()) r.epilogue(_build.config.file_name()) if not _build.opts.dry_run(): _build.mkdir(outpath) r.write(outname) del r if mail: r = reports.report('text', self.configs, copy.copy(opts), copy.copy(macros)) r.introduction(_build.config.file_name()) r.generate(_build.config.file_name()) r.epilogue(_build.config.file_name()) self.write_mail_report(r.get_output()) del r
def report(self, _config, _build): if not _build.opts.get_arg('--no-report') \ and not _build.macros.get('%{_disable_reporting}') \ and _build.opts.get_arg('--mail'): format = _build.opts.get_arg('--report-format') if format is None: format = 'html' ext = '.html' else: if len(format) != 2: raise error.general('invalid report format option: %s' % ('='.join(format))) if format[1] == 'text': format = 'text' ext = '.txt' elif format[1] == 'asciidoc': format = 'asciidoc' ext = '.txt' elif format[1] == 'html': format = 'html' ext = '.html' else: raise error.general('invalid report format: %s' % (format[1])) buildroot = _build.config.abspath('%{buildroot}') prefix = _build.macros.expand('%{_prefix}') name = _build.main_package().name() + ext log.notice('reporting: %s -> %s' % (_config, name)) if not _build.opts.get_arg('--no-report'): outpath = path.host( path.join(buildroot, prefix, 'share', 'rtems-source-builder')) outname = path.host(path.join(outpath, name)) r = reports.report(format, self.configs, _build.opts, _build.macros) r.setup() r.introduction(_build.config.file_name()) r.config(_build.config, _build.opts, _build.macros) if not _build.opts.dry_run(): _build.mkdir(outpath) r.write(outname) del r if not _build.macros.get('%{_disable_reporting}') \ and _build.opts.get_arg('--mail'): r = reports.report('text', self.configs, _build.opts, _build.macros) r.setup() r.introduction(_build.config.file_name()) r.config(_build.config, _build.opts, _build.macros) self.write_mail_report(r.out) del r
def report(self, _config, _build, opts, macros, format=None): if ( len(_build.main_package().name()) > 0 and not _build.macros.get("%{_disable_reporting}") and (not _build.opts.get_arg("--no-report") or _build.opts.get_arg("--mail")) ): if format is None: format = _build.opts.get_arg("--report-format") if format is not None: if len(format) != 2: raise error.general("invalid report format option: %s" % ("=".join(format))) format = format[1] if format is None: format = "text" if format == "text": ext = ".txt" elif format == "asciidoc": ext = ".txt" elif format == "html": ext = ".html" elif format == "xml": ext = ".xml" elif format == "ini": ext = ".ini" else: raise error.general("invalid report format: %s" % (format)) buildroot = _build.config.abspath("%{buildroot}") prefix = _build.macros.expand("%{_prefix}") name = _build.main_package().name() + ext log.notice("reporting: %s -> %s" % (_config, name)) if not _build.opts.get_arg("--no-report"): outpath = path.host(path.join(buildroot, prefix, "share", "rtems", "rsb")) if not _build.opts.dry_run(): outname = path.host(path.join(outpath, name)) else: outname = None r = reports.report(format, self.configs, copy.copy(opts), copy.copy(macros)) r.introduction(_build.config.file_name()) r.generate(_build.config.file_name()) r.epilogue(_build.config.file_name()) if not _build.opts.dry_run(): _build.mkdir(outpath) r.write(outname) del r if _build.opts.get_arg("--mail"): r = reports.report("text", self.configs, copy.copy(opts), copy.copy(macros)) r.introduction(_build.config.file_name()) r.generate(_build.config.file_name()) r.epilogue(_build.config.file_name()) self.write_mail_report(r.out) del r
def build_reports(rook_graph, queen_graph): logging.info('Building reports for rook- and queen-adjacency graphs.') rook_synopsis = report(rook_graph) queen_synopsis = report(queen_graph) logging.info('Comparing rook- and queen-adjacency graphs.') comparison = { 'rook_vs_queen_comparison': rook_vs_queen(rook_graph, queen_graph) } return { 'rook_graph_report': rook_synopsis, 'queen_graph_report': queen_synopsis, 'comparison': comparison }
def main(argv): """Process the JSON data and generate a full report out of it.""" data = load_data("car_sales.json") summary = process_data(data) new_summary = '<br/>'.join(summary) print(summary) # TODO: turn this into a PDF report report('/tmp/cars.pdf', "Cars report", new_summary, cars_dict_to_table(data)) # TODO: send the PDF report as an email attachment msg = email_generate("*****@*****.**", "{}@example.com".format(os.environ.get('USER')), "Sales summary for last month", new_summary, "/tmp/cars.pdf") email_send(msg)
def save_report(self): import random number = random.randint(34,80) variables.report_query_string = str(self.sqleditor.text()) variables.report_raw_data = self.response_table variables.report_database = str(self.interact_comboBox.currentText()) variables.report_server_type = variables.database_type variables.report_save_path = QtGui.QFileDialog.getSaveFileName(self,"Save Reports","hexorbase-report-%s"%(number),"HTML(*.html)") if variables.report_save_path: if not variables.report_database_ip_address: variables.report_database_ip_address = None if not variables.report_database_ip_adress_port: variables.report_database_ip_adress_port = None if not variables.report_server_type: variables.report_server_type = None if not variables.report_server_version: variables.report_server_version = None if not variables.report_database: variables.report_database = None if not variables.report_query_string: variables.report_query_string = None variables.report_html = variables.report_template % (variables.report_database_ip_address, variables.report_database_ip_adress_port, variables.report_server_type, variables.report_server_version, variables.report_database, str(variables.report_query_string)) report_class = reports.report() report_class.exec_()
def save_report(self): import random number = random.randint(34, 80) variables.report_query_string = str(self.sqleditor.text()) variables.report_raw_data = self.response_table variables.report_database = str(self.interact_comboBox.currentText()) variables.report_server_type = variables.database_type variables.report_save_path = QtGui.QFileDialog.getSaveFileName( self, "Save Reports", "hexorbase-report-%s" % (number), "HTML(*.html)") if variables.report_save_path: if not variables.report_database_ip_address: variables.report_database_ip_address = None if not variables.report_database_ip_adress_port: variables.report_database_ip_adress_port = None if not variables.report_server_type: variables.report_server_type = None if not variables.report_server_version: variables.report_server_version = None if not variables.report_database: variables.report_database = None if not variables.report_query_string: variables.report_query_string = None variables.report_html = variables.report_template % ( variables.report_database_ip_address, variables.report_database_ip_adress_port, variables.report_server_type, variables.report_server_version, variables.report_database, str(variables.report_query_string)) report_class = reports.report() report_class.exec_()
def main(argv): """Process the JSON data and generate a full report out of it.""" data = load_data("car_sales.json") summary = process_data(data) print(summary) edited_summary = '\n'.join(summary) # TODO: turn this into a PDF report report('/tmp/cars.pdf', "Cars Report", edited_summary, cars_dict_to_table(data)) # TODO: send the PDF report as an email attachment message = generate_email("*****@*****.**", "*****@*****.**", "Sales summary for last month", edited_summary, "/tmp/cars.pdf") send_email(message)
def main(argv): """Process the JSON data and generate a full report out of it.""" data = load_data("../car_sales.json") summary = process_data(data) new_summary = '\n'.join(summary) print(summary) # TODO: turn this into a PDF report report('/tmp/cars.pdf', "Cars Report", new_summary, cars_dict_to_table(data)) # TODO: send the PDF report as an email attachment message = email_generate('*****@*****.**', '*****@*****.**', 'Sales summary for last month', new_summary, '/tmp/cars.pdf') email_send(message)
def report(self, _config, _build): if not _build.opts.get_arg('--no-report') \ and not _build.macros.get('%{_disable_reporting}') \ and _build.opts.get_arg('--mail'): format = _build.opts.get_arg('--report-format') if format is None: format = 'html' ext = '.html' else: if len(format) != 2: raise error.general('invalid report format option: %s' % ('='.join(format))) if format[1] == 'text': format = 'text' ext = '.txt' elif format[1] == 'asciidoc': format = 'asciidoc' ext = '.txt' elif format[1] == 'html': format = 'html' ext = '.html' else: raise error.general('invalid report format: %s' % (format[1])) buildroot = _build.config.abspath('%{buildroot}') prefix = _build.macros.expand('%{_prefix}') name = _build.main_package().name() + ext log.notice('reporting: %s -> %s' % (_config, name)) if not _build.opts.get_arg('--no-report'): outpath = path.host(path.join(buildroot, prefix, 'share', 'rtems-source-builder')) outname = path.host(path.join(outpath, name)) r = reports.report(format, self.configs, _build.opts, _build.macros) r.setup() r.introduction(_build.config.file_name()) r.config(_build.config, _build.opts, _build.macros) if not _build.opts.dry_run(): _build.mkdir(outpath) r.write(outname) del r if not _build.macros.get('%{_disable_reporting}') \ and _build.opts.get_arg('--mail'): r = reports.report('text', self.configs, _build.opts, _build.macros) r.setup() r.introduction(_build.config.file_name()) r.config(_build.config, _build.opts, _build.macros) self.write_mail_report(r.out) del r
def test_report(self): output = reports.report("AB5, BC4, CD8, DC8, DE6, AD5, CE2, EB3, AE7") expected = """9 5 13 22 NO SUCH ROUTE 2 3 9 9 7 """ self.assertEqual(output, expected)
def run(allArticlesEn=False, allArticles=False, missingArticles=False, doOnly=False): if doOnly is not False: todo = [ doOnly ] else: todo = wprefs.keys() for wiki in todo: c = wprefs[wiki] r = reports.report(wiki) r.login() if allArticlesEn: r.allArticlesEn( c['prefix'] + 'All articles/en', c['langs'], c['blacklist'], c['summ-count'] ) if allArticles: r.allArticles( c['prefix'] + 'All articles/{0}', c['langs'], c['summ-count'] ) if missingArticles: r.missingArticles( c['prefix'] + 'Missing translations/{0}', c['langs'], c['prefix'] + 'All articles/en', c['prefix'] + 'All articles/{0}', c['blacklist-missingArticles'], c['summ-count'] ) print 'run.py > done.'
import client import balance import reports import menu while True: for i in menu.menu_items: print(i) menu_option = int(input('Select option:\n> ')) if menu_option == 1: client.add_client() elif menu_option == 2: client.check_client() elif menu_option == 3: balance.client_balance() elif menu_option == 4: reports.report() elif menu_option == 5: print('Program ended.') break else: print('Select valid option.') continue
"The {} generated the most revenue: ${}".format( format_car(data[revenue_key]["car"]), max(revenue)), "The {} had the most sales: {}".format( format_car(data[quantity_key]["car"]), max(numbersold)), "The most popular year was {} with {} sales.".format( maxyear, yearsold[maxyear]) ] return "\n".join(summary) def cars_dict_to_table(car_data): """Turns the data in car_data into a list of lists.""" table_data = [["ID", "Car", "Price", "Total Sales"]] for item in car_data: table_data.append([item["id"], format_car(item["car"]), item["price"], item["total_sales"]]) return table_data def main(argv): """Process the JSON data and generate a full report out of it.""" data = load_data("car_sales.json") summary = process_data(data) print(summary) # TODO: turn this into a PDF report report('/tmp/cars.pdf', "Cars report", summary, cars_dict_to_table(data)) # TODO: send the PDF report as an email attachment msg = email_generate("*****@*****.**", "student-03-4a1ed70a68a6@examp$ "Sales summary for last month", summary, "/tmp/cars.pd$ email_send(msg) if __name__ == "__main__": main(sys.argv)
def app(): #Append value to Validation Table Validation_key = database_insertValidation() #Read all files to database for project in file_paths: project_name = file_paths.index(project) print(project_name) for path in project: filenames = find_excel_filenames(path) for file in filenames: sheetName = pd.ExcelFile(path + file).sheet_names for sheet in sheetName: dataframe = pd.read_excel(path + file, sheet_name=sheet, header=[0, 1]) dataframe = dataframe_cleaning(dataframe) dataframe = dataframe_addColumns( dataframe=dataframe, file=file, project_name=project_name, sheet=sheet, Validation_key=Validation_key) database_insertExcelValues(dataframe) # Validation Test 1 and status report Validation_1 = Validation_1_query(Validation_key=Validation_key) #Validation Test 2 and status report Validation_2 = Validation_2_query(Validation_key=Validation_key) files = file_query(Validation_key) #Setup datetime for Report and MasterFile ts = time.time() dateTime = ( datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S')) #Update Validation Status if (len(Validation_1) > 0) and (len(Validation_2) > 0): status = "Failed both validation" elif (len(Validation_1) > 0) and (len(Validation_2) == 0): status = "Only validation 1 failed" elif (len(Validation_1) == 0) and (len(Validation_2) > 0): status = "Only Validation 2 failed" else: status = "OK" Master_File = pd.read_sql( "Select * From Excel_Values Where Validation_key=" + str(Validation_key), con) fileName = "MasterFile_" + str(dateTime) completeName = os.path.join("MasterFile/", fileName) Master_File.to_csv(completeName, index=False) #Update Status in Validation Table cur.execute('UPDATE validation SET status = ? WHERE Validation_key = ?', (status, Validation_key)) #Generate Reprot report(dateTime, Validation_1, Validation_2, files) return None
def main(): parser = argparse.ArgumentParser( description="Gather Bazel's issues and pull requests data") parser.add_argument( '--user_list_file', help='File of github handles used to filter reports by user.') parser.add_argument('--verbose', action='store_true', help='Be more verbose') subparsers = parser.add_subparsers(dest="command", help="select a command") update_parser = subparsers.add_parser("update", help="update the datasets") update_parser.add_argument("--full", action='store_true', help="Do a full rather than incremental update") update_parser.add_argument( '--repo', action='append', help='Repository to do an update for. May be repeated.') update_parser.add_argument('--repo_list_file', action='store', help='Get repositories listed in this file') update_parser.add_argument( '--reset_repo', action='append', help='Specific repository to do a full update for. May be repeated') garden_parser = subparsers.add_parser( "garden", help="generate issues/pull requests that need gardening attention") garden_parser.add_argument( '-i', '--list_issues', action='store_true', help="list issues that need attention (true/false)") garden_parser.add_argument( '-p', '--list_pull_requests', action='store_true', help="list pull requests that need attention (true/false)") garden_parser.add_argument( '-s', '--stale_for_days', type=int, default=0, help= "list issues/prs that have not been updated for more than the specified number of days (number, default is 0)" ) html_parser = subparsers.add_parser( "html", help="generate HTML for issues/pull requests that need attention") report_parser = subparsers.add_parser("report", help="generate a full report") report_selector = report_parser.add_mutually_exclusive_group() report_selector.add_argument('-a', '--all', action="store_true", dest="all_reports", help="show all reports") report_selector.add_argument( "-r", "--report", action="append", choices=reports.report_names(), help="show selected report (multiple values possible)") args = parser.parse_args() user_list = None if args.user_list_file: with open(args.user_list_file, 'r') as inp: user_list = [x.strip() for x in inp.read().split('\n')] if args.command == "update": repos = DEFAULT_REPOS if args.repo: repos = args.repo elif args.repo_list_file: with open(args.repo_list_file, 'r') as rf: repos = [l.strip() for l in rf.read().strip().split('\n')] update(repos, args.full, args.reset_repo, args.verbose) elif args.command == "report": reports.report(args.report if args.report else reports.report_names(), user_list=user_list) elif args.command == "garden": reports.garden(args.list_issues, args.list_pull_requests, args.stale_for_days) elif args.command == "html": reports.html_garden() else: parser.print_usage()
if __name__ == "__main__": # To get the username from environment variable USER = os.getenv('USER') # To set encoding to avoid ascii errors locale.setlocale(locale.LC_ALL, 'en_US.UTF8') # The directory which contains all the files with data in it. description_directory = '/home/{}/supplier-data/descriptions/'.format(USER) # Listing all the files in description directory description_files = os.listdir(description_directory) # The directory which contains all the images. image_directory = '/home/{}/supplier-data/images/'.format(USER) # URL to push the data to the website url = "http://localhost/fruits/" # Creating data in format "May 5, 2020" current_date = datetime.date.today().strftime("%B %d, %Y") # Title for the PDF file with the created date title = 'Processed Update on ' + str(current_date) # subject line give in assignment for email new_subject = 'Upload Completed - Online Fruit Store' # body line give in assignment for email new_body = 'All fruits are uploaded to our website successfully. A detailed list is attached to this email.' # calling the report function from custom module report('/tmp/processed.pdf', title, summary('pdf')) # structuring email and attaching the file. Then sending the email, using the custom module. email = email_generate("*****@*****.**", "{}@example.com".format(USER), new_subject, new_body, "/tmp/processed.pdf") email_send(email)