Beispiel #1
0
def creat_report(html_path, filename, aab=False):
    '''
    /templates/report_template.html模板,生成单次报告,并更新rs.json
    '''

    gd = GetData()
    base_info = gd.get_base()
    pkg_info = gd.get_pkg_info()
    apk_info = gd.make_entries()
    apk_detail = gd.get_html_table()
    if pkg_info['package'] in internalapp:
        if aab:
            appname = internalapp[pkg_info['package']] + '_aab'
        else:
            appname = internalapp[pkg_info['package']]
    else:
        if aab:
            appname = pkg_info['package'] + '_aab'
        else:
            appname = pkg_info['package']

    context = {
        'filename': os.path.basename(filename),
        'package': pkg_info['package'],
        'appname': appname,
        'versionName': pkg_info['versionName'],
        'apksize': base_info['apksize'],
        'minSdkVersion': pkg_info['minSdkVersion'],
        'targetSdkVersion': pkg_info['targetSdkVersion'],
        'versionCode': pkg_info['versionCode'],
        'appinfo': apk_info,
        'appdetail': apk_detail,
        'create_time': time.strftime("%Y-%m-%d %H:%M:%S"),
    }
    logger.info('生成报告:%s' % html_path)
    if aab:
        apks_info = GetData().get_apks_size_info()
        context.update(apks_info)
        with open(html_path, 'w') as f:
            html = render_template("report_template_aab.html", context=context)
            f.write(html)
            f.close()
        del_files(config.tmp_apks_path)
        pkg = context['package'] + '_aab'

    else:
        with open(html_path, 'w') as f:
            html = render_template("report_template.html", context=context)
            f.write(html)
            f.close()
            pkg = context['package']
    logger.info('报告生成完成')
    context.pop('appinfo')
    context.pop('appdetail')
    context.update({'report_path': os.path.join('./', pkg, 'reports', os.path.basename(html_path))})
    return context
Beispiel #2
0
def html():
    '''
    拼接html报告
    '''
    gd = GetData()
    base_info = gd.get_base()
    pkg_info = gd.get_pkg_info()
    apk_info = gd.make_entries()
    apk_detail = gd.get_html_table()
    return render_template(
        "report_template.html",
        appname=pkg_info['package'],
        appversion=pkg_info['versionName'],
        appsize=base_info['apksize'],
        minSdkVersion=pkg_info['minSdkVersion'],
        targetSdkVersion=pkg_info['targetSdkVersion'],
        appinfo=apk_info,
        appdetail=apk_detail,
        reporttime=time.strftime("%Y-%m-%d %H:%M:%S"),
    )