def main(url, report, release, start_date, end_date, requestor_id, requestor_email, requestor_name, customer_name, customer_reference, format_, output_file): click.echo("pycounter SUSHI client for URL %s (%s R%s)" % (url, report, release)) if end_date is not None and start_date is None: click.echo('Cannot specify --end_date without --start_date', err=True) sys.exit(1) if start_date is None: converted_start_date = prev_month(datetime.datetime.now()) else: converted_start_date = convert_date_run(start_date) if end_date is None: converted_end_date = last_day(converted_start_date) else: converted_end_date = convert_date_run(end_date) report = sushi.get_report(wsdl_url=url, report=report, release=release, requestor_id=requestor_id, requestor_name=requestor_name, requestor_email=requestor_email, customer_reference=customer_reference, customer_name=customer_name, start_date=converted_start_date, end_date=converted_end_date) output_file = output_file % format_ report.write_to_file(output_file, format_)
def test_prevmonth(self): data = [ ((2000, 1, 1), (1999, 12, 1)), ((2000, 12, 1), (2000, 11, 1)), ((2000, 2, 29), (2000, 1, 1)), ((1999, 12, 6), (1999, 11, 1)), ] for pair in data: self.assertEqual(datetime.date(*pair[1]), prev_month(datetime.date(*pair[0])))
def main( url, report, release, start_date, end_date, requestor_id, requestor_email, requestor_name, customer_name, customer_reference, format_, output_file, dump, no_ssl_verify, no_delay, ): """Main function for the SUSHI client.""" click.echo("pycounter SUSHI client for URL %s (%s R%s)" % (url, report, release)) if end_date is not None and start_date is None: click.echo("Cannot specify --end_date without --start_date", err=True) sys.exit(1) if start_date is None: converted_start_date = prev_month(datetime.datetime.now()) else: converted_start_date = convert_date_run(start_date) if end_date is None: converted_end_date = last_day(converted_start_date) else: converted_end_date = convert_date_run(end_date) report = sushi.get_report( wsdl_url=url, report=report, release=release, requestor_id=requestor_id, requestor_name=requestor_name, requestor_email=requestor_email, customer_reference=customer_reference, customer_name=customer_name, start_date=converted_start_date, end_date=converted_end_date, sushi_dump=dump, no_delay=no_delay, verify=not no_ssl_verify, ) if "%s" in output_file: output_file = output_file % format_ report.write_to_file(output_file, format_)
def test_prevmonth(pair): assert datetime.date(*pair[1]) == prev_month(datetime.date(*pair[0]))