def example_number_and_trend(out_file_name='example.docx'): main.run(get_mock('elements/number_and_trend.json', ret_dict=False), out_file_name)
def example_paged_complex(out_file_name='example.docx'): main.run(get_mock('grid_checks/complexpaged.json', ret_dict=False), out_file_name)
def example_table_new(out_file_name='example.docx'): main.run(get_mock('elements/table_new_json.json', ret_dict=False), out_file_name)
def example_image_svg(out_file_name='example.docx'): main.run(get_mock('elements/image-svg.json', ret_dict=False), out_file_name)
def example(): main.run(get_mock('example.json', ret_dict=False), 'example.docx')
import os import demistomock as demisto from CommonServerPython import * from CommonServerUserPython import * import base64 from sane_doc_reports.main import run OUTPUT_FILE_PATH = 'out.docx' try: sane_json_b64 = demisto.args().get('sane_docx_report_base64', '').encode("utf-8") with open('sane.json', 'wb') as f: f.write(base64.b64decode(sane_json_b64)) run('sane.json', OUTPUT_FILE_PATH) with open(OUTPUT_FILE_PATH, 'rb') as f: encoded = base64.b64encode(f.read()).decode("utf-8", "ignore") os.remove(OUTPUT_FILE_PATH) return_outputs(readable_output='Successfully generated docx', outputs={}, raw_response={'data': encoded}) except Exception as e: err = repr(e) return_error(f'[SaneDocReports Automation Error] - {err}')
def example_items_section(out_file_name='example.docx'): main.run(get_mock('elements/items_section.json', ret_dict=False), out_file_name)
def example_paper_size_a3(out_file_name='example.docx'): main.run(get_mock('grid_checks/fullgrid.json', ret_dict=False), out_file_name, {'paper_size': 'A3'})
OUTPUT_FILE_PATH = 'out.docx' try: sane_json_b64 = demisto.args().get('sane_docx_report_base64', '').encode('utf-8') orientation = demisto.args().get('orientation', 'portrait') paper_size = demisto.args().get('paperSize', 'A4') demistoLogo = demisto.args().get('demistoLogo', '') customerLogo = demisto.args().get('customerLogo', '') with open('sane.json', 'wb') as f: f.write(base64.b64decode(sane_json_b64)) run( 'sane.json', OUTPUT_FILE_PATH, { 'orientation': orientation, 'paper_size': paper_size, 'demistoLogo': demistoLogo, 'customerLogo': customerLogo, }) with open(OUTPUT_FILE_PATH, 'rb') as f: encoded = base64.b64encode(f.read()).decode('utf-8', 'ignore') os.remove(OUTPUT_FILE_PATH) return_outputs(readable_output='Successfully generated docx', outputs={}, raw_response={'data': encoded}) except Exception: tb = traceback.format_exc() wrap = "=====sane-doc-reports error=====" err = f'{wrap}\n{tb}{wrap}\n'
def example_unimplemented(out_file_name='example.docx'): main.run(get_mock('elements/unimplemented.json', ret_dict=False), out_file_name)
def example_orientation_landscape(out_file_name='example.docx'): main.run(get_mock('grid_checks/fullgrid.json', ret_dict=False), out_file_name, {'orientation': 'landscape'})
def _example_junk(out_file_name='example.docx'): # Generate a big elements file for testing main.run(get_mock('junkbig.json', ret_dict=False), out_file_name)
def example_old_json(out_file_name='example.docx'): main.run(get_mock('old_json.json', ret_dict=False), out_file_name)
def example_basic(out_file_name='example.docx'): main.run(get_mock('grid_checks/fullgrid.json', ret_dict=False), out_file_name)
def example_pie_chart(out_file_name='example.docx'): main.run(get_mock('elements/pie_chart.json', ret_dict=False), out_file_name)
def example_date(out_file_name='example.docx'): main.run(get_mock('elements/date.json', ret_dict=False), out_file_name)
def example_markdown_md_button(out_file_name='example.docx'): main.run(get_mock('elements/markdown_md_button.json', ret_dict=False), out_file_name)
from CommonServerUserPython import * import os import base64 from sane_doc_reports.main import run OUTPUT_FILE_PATH = 'out.docx' try: sane_json_b64 = demisto.args().get('sane_docx_report_base64', '').encode('utf-8') orientation = demisto.args().get('orientation', 'portrait').encode('utf-8') paper_size = demisto.args().get('paperSize', 'A4').encode('utf-8') with open('sane.json', 'wb') as f: f.write(base64.b64decode(sane_json_b64)) run( 'sane.json', OUTPUT_FILE_PATH, { 'orientation': orientation.decode('utf-8', 'ignore'), 'paper_size': paper_size.decode('utf-8', 'ignore') }) with open(OUTPUT_FILE_PATH, 'rb') as f: encoded = base64.b64encode(f.read()).decode('utf-8', 'ignore') os.remove(OUTPUT_FILE_PATH) return_outputs(readable_output='Successfully generated docx', outputs={}, raw_response={'data': encoded}) except Exception as e: err = repr(e) return_error(f'[SaneDocReports Automation Error] - {err}')