Ejemplo n.º 1
0
                chapter.add_context({"table": app_info})
                chapter.add_picture('image',
                                    os.path.join(doc_path, image),
                                    width=240)

                document.add_chapter(chapter, title="应用统计", level=3)

        document.add_context({
            'head_title':
            head_title,
            'doc_date':
            datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
        })

        document.render()
        document.save(os.path.join(doc_path, '%s云主机使用情况.docx' % (add_head)))

        file_name = '%s云主机使用情况.docx' % (add_head)
        local = os.path.join(
            '/home/aihc/bhc/robot-node/.toolkit/doc_1_20190807', file_name)
        # 远程下载文件主机目录配置
        remote = os.path.join('/home/maintain/mongoapp/aihc', file_name)

        upload_file(sftp_ip, sftp_port, sftp_username, sftp_password, local,
                    remote)

    finally:
        db_connect.close()
        pub.disconnect()
Ejemplo n.º 2
0
                result_doc.update({
                    'context':
                    result_doc.get('ExceptionType') + "," +
                    str(result_doc.get('count'))
                })
                result_doc.update({'sumCount': 1})
                host_mongo_query_exceptions.update({new_id: result_doc})
    # host_mongo_query_exceptions = sorted(host_mongo_query_exceptions.items(), key=lambda d: d[0])

    logging.info(
        f'host_mongo_query_exceptions is {host_mongo_query_exceptions}')
    # \\print(sorted(host_mongo_query_exceptions.items(), key=lambda d: d[0]))
    doc_path = '/Users/mtr/PycharmProjects/mongoQuery/com/asiainfo/aihc/doc_1_20190807'
    document = Document(os.path.join(doc_path, 'host-report-tpl.docx'))
    chapter = Chapter(
        os.path.join(doc_path, 'host-mongo_query_exceptions-tpl.docx'))

    # host_mongo_query_exceptions = [{'ip': '10.19.85.33', 'FunctionName': 'load', 'count': '10',
    #                                 'context': 'NullPointException:1,RuntimeException:3'},
    #                                {'ip': '10.19.85.34', 'FunctionName': 'serv', 'count': '20',
    #                                 'context': 'NullPointException:2,RuntimeException:6'}]
    excep_result = host_mongo_query_exceptions.values()
    logging.info(f'excep_result is {excep_result}')
    table = {'table': excep_result}
    chapter.add_context(table)
    print(f"host-mongo_query_exceptions table  is {table}")
    document.add_chapter(chapter, title="异常数量统计", level=2)
    document.render()
    document.save(
        os.path.join(doc_path, '%s云主机使用情况.docx' % ('mongo_query_exception')))