Ejemplo n.º 1
0
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)
Ejemplo n.º 2
0
def example_paged_complex(out_file_name='example.docx'):
    main.run(get_mock('grid_checks/complexpaged.json', ret_dict=False),
             out_file_name)
Ejemplo n.º 3
0
def example_table_new(out_file_name='example.docx'):
    main.run(get_mock('elements/table_new_json.json', ret_dict=False),
             out_file_name)
Ejemplo n.º 4
0
def example_image_svg(out_file_name='example.docx'):
    main.run(get_mock('elements/image-svg.json', ret_dict=False),
             out_file_name)
Ejemplo n.º 5
0
def example():
    main.run(get_mock('example.json', ret_dict=False), 'example.docx')
Ejemplo n.º 6
0
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}')
Ejemplo n.º 7
0
def example_items_section(out_file_name='example.docx'):
    main.run(get_mock('elements/items_section.json', ret_dict=False),
             out_file_name)
Ejemplo n.º 8
0
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'})
Ejemplo n.º 9
0
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'
Ejemplo n.º 10
0
def example_unimplemented(out_file_name='example.docx'):
    main.run(get_mock('elements/unimplemented.json', ret_dict=False),
             out_file_name)
Ejemplo n.º 11
0
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'})
Ejemplo n.º 12
0
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)
Ejemplo n.º 13
0
def example_old_json(out_file_name='example.docx'):
    main.run(get_mock('old_json.json', ret_dict=False), out_file_name)
Ejemplo n.º 14
0
def example_basic(out_file_name='example.docx'):
    main.run(get_mock('grid_checks/fullgrid.json', ret_dict=False),
             out_file_name)
Ejemplo n.º 15
0
def example_pie_chart(out_file_name='example.docx'):
    main.run(get_mock('elements/pie_chart.json', ret_dict=False),
             out_file_name)
Ejemplo n.º 16
0
def example_date(out_file_name='example.docx'):
    main.run(get_mock('elements/date.json', ret_dict=False), out_file_name)
Ejemplo n.º 17
0
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)
Ejemplo n.º 18
0
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}')