migration-tools/0002-modify-excel-report-content.patch
2024-11-01 15:39:59 +08:00

224 lines
7.9 KiB
Diff
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

From 2954e8c9e13cacb09bdd668e38adce53162c6e3a Mon Sep 17 00:00:00 2001
From: FanSheng Meng <mengfansheng@uniontech.com>
Date: Mon, 16 Oct 2023 14:30:12 +0800
Subject: [PATCH] =?UTF-8?q?=E8=A7=84=E8=8C=83=E4=BB=A3=E7=A0=81=E6=A0=BC?=
=?UTF-8?q?=E5=BC=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
func/Abitxt2xls.py | 103 +++++++-----------
.../centos7/uos/centos72uos.sh | 1 -
2 files changed, 40 insertions(+), 64 deletions(-)
diff --git a/func/Abitxt2xls.py b/func/Abitxt2xls.py
index 77c4ebd..d80ad4c 100644
--- a/func/Abitxt2xls.py
+++ b/func/Abitxt2xls.py
@@ -1,32 +1,24 @@
# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
# SPDX-License-Identifier: MulanPubL-2.0-or-later
-
# coding=utf-8
-'''''
-main function主要实现把txt中的每行数据写入到excel中
-'''
-#################
import datetime
import json
import socket
import xlwt
-
from func.share import *
-#检测报告导出绝对路径
-report_path_bef="/var/tmp/uos-migration/UOS_analysis_report/"
-report_path_ago='/var/tmp/uos-migration/UOS_migration_log/'
-
+report_path_bef = "/var/tmp/uos-migration/UOS_analysis_report/"
+report_path_ago = '/var/tmp/uos-migration/UOS_migration_log/'
txtFileName = '/var/tmp/uos-migration/data/exp-rst/abi-compat-pkg.txt'
txtFileName1 = '/var/tmp/uos-migration/data/exp-rst/abi-incompat-pkg.txt'
SysInfoFile = '/var/tmp/uos-migration/data/exp-rst/systeminfo.txt'
SysInfoFile_after = '/var/tmp/uos-migration/data/exp-rst/trans-end-sysinfo.txt'
-PkgCompFile1= '/var/tmp/uos-migration/data/exp-rst/pkginfo_1.txt'
-PkgCompFile2= '/var/tmp/uos-migration/data/exp-rst/pkginfo_2.txt'
-PkgCompFile3= '/var/tmp/uos-migration/data/exp-rst/pkginfo_3.txt'
-PkgCompFile4= '/var/tmp/uos-migration/data/exp-rst/pkginfo_4.txt'
-PkgCompFile1_after= '/var/tmp/uos-migration/data/exp-rst/pkginfo_1_trans.txt'
+PkgCompFile1 = '/var/tmp/uos-migration/data/exp-rst/pkginfo_1.txt'
+PkgCompFile2 = '/var/tmp/uos-migration/data/exp-rst/pkginfo_2.txt'
+PkgCompFile3 = '/var/tmp/uos-migration/data/exp-rst/pkginfo_3.txt'
+PkgCompFile4 = '/var/tmp/uos-migration/data/exp-rst/pkginfo_4.txt'
+PkgCompFile1_after = '/var/tmp/uos-migration/data/exp-rst/pkginfo_1_trans.txt'
def get_host_ip():
@@ -39,117 +31,102 @@ def get_host_ip():
return ip
-def accord_line_write(txtLineFile, sheet_line, line_num, colu_num):
+def accord_line_write(txt_line_file, sheet_line, line_num, column_num):
# 通过列的形式写入文件
- with open(txtLineFile,'r') as line_f:
+ with open(txt_line_file, 'r') as line_f:
x = line_num
- y = colu_num
+ y = column_num
sys_lines = line_f.readlines()
for line in sys_lines:
for value in line.strip().split("|"):
- sheet_line.write(x,y,value)
+ sheet_line.write(x, y, value)
y += 1
x += 1
y = 0
line_f.close()
-def accord_colu_write(txtColuFile,sheet_colu, line_num, colu_num):
+def accord_column_write(txt_column_file, sheet_column, line_num, column_num):
# 通过行的形式写入文件
- with open(txtColuFile,'r') as colu_f:
+ with open(txt_column_file, 'r') as column_f:
x = line_num
- y = colu_num
- sys_colus = colu_f.readlines()
- for line in sys_colus:
+ y = column_num
+ sys_columns = column_f.readlines()
+ for line in sys_columns:
for value in line.strip().split("|"):
- sheet_colu.write(x,y,value)
+ sheet_column.write(x, y, value)
x += 1
- colu_f.close()
+ column_f.close()
+
def system_info(check_file):
- #新建一个sheet
sheet_sysinfo = check_file.add_sheet("系统基本信息")
accord_line_write(SysInfoFile, sheet_sysinfo, 0, 0)
-#sheet1-系统基本信息
+# sheet1-系统基本信息
def system_info_after(sys):
- #新建一个sheet
sheet_sysinfo = sys.add_sheet("系统基本信息")
accord_line_write(SysInfoFile_after, sheet_sysinfo, 0, 0)
-#sheet2-软件包对比
+# sheet2-软件包对比
def pkg_comp(pkg):
- #新建一个sheet
sheet_pkgcomp = pkg.add_sheet("软件包对比")
accord_line_write(PkgCompFile1, sheet_pkgcomp, 0, 0)
- accord_colu_write(PkgCompFile2, sheet_pkgcomp, 3, 0)
- accord_colu_write(PkgCompFile4, sheet_pkgcomp, 3, 1)
+ accord_column_write(PkgCompFile2, sheet_pkgcomp, 3, 0)
+ accord_column_write(PkgCompFile4, sheet_pkgcomp, 3, 1)
-#sheet2-软件包对比
+# sheet2-软件包对比
def pkg_comp_after(pkg):
- #新建一个sheet
sheet_pkgcomp = pkg.add_sheet("软件包对比")
accord_line_write(PkgCompFile1_after, sheet_pkgcomp, 0, 0)
- accord_colu_write(PkgCompFile2, sheet_pkgcomp, 3, 0)
- accord_colu_write(PkgCompFile3, sheet_pkgcomp, 3, 1)
- accord_colu_write(PkgCompFile4, sheet_pkgcomp, 3, 2)
+ accord_column_write(PkgCompFile2, sheet_pkgcomp, 3, 0)
+ accord_column_write(PkgCompFile3, sheet_pkgcomp, 3, 1)
+ accord_column_write(PkgCompFile4, sheet_pkgcomp, 3, 2)
-#sheet4-ABI兼容
+# sheet4-ABI兼容
def abi_incomp_info(file_incomp):
- #新建一个sheet
sheet_comp = file_incomp.add_sheet("ABI兼容")
accord_line_write(txtFileName, sheet_comp, 0, 0)
-#sheet5-ABI不兼容
+
+# sheet5-ABI不兼容
def abi_comp_pkg(file_comp):
- #新建一个sheet
sheet_incomp = file_comp.add_sheet("ABI不兼容")
-
accord_line_write(txtFileName1, sheet_incomp, 0, 0)
+
def abi_txt2xls():
- #兼容性检查报告名规则UOS_migration_log_10.0.2.3_cy.server_202110192140.xls
- hostip = get_host_ip()
+ # 兼容性检查报告名规则UOS_migration_log_10.0.2.3_cy.server_202110192140.xls
+ host_ip = get_host_ip()
hostname = socket.gethostname()
- excelFileName = "UOS_migration_log_"+hostip+"_"+hostname+"_"+datetime.datetime.now().strftime('%Y%m%d%H%M')+".xls"
-
- report_name_check=report_path_bef+excelFileName
+ excel_file_name = "UOS_migration_log_"+host_ip+"_"+hostname+"_"+datetime.datetime.now().strftime('%Y%m%d%H%M')+".xls"
+ report_name_check = report_path_bef + excel_file_name
if os.path.exists(report_name_check):
os.remove(report_name_check)
-
- #新建一个excel文件
- check_file = xlwt.Workbook(encoding='utf-8',style_compression=0)
-
+ check_file = xlwt.Workbook(encoding='utf-8', style_compression=0)
system_info(check_file)
pkg_comp(check_file)
abi_incomp_info(check_file)
abi_comp_pkg(check_file)
-
check_file.save(report_name_check)
def abi_txt2xls_after_mig():
-
- hostip = get_host_ip()
+ host_ip = get_host_ip()
hostname = socket.gethostname()
- excelFileName_after = "UOS_migration_log_"+hostip+"_"+hostname+"_"+datetime.datetime.now().strftime('%Y%m%d%H%M')+".xls"
-
- report_name_after=report_path_ago+excelFileName_after
+ excel_file_name_after = "UOS_migration_log_"+host_ip+"_"+hostname+"_"+datetime.datetime.now().strftime('%Y%m%d%H%M')+".xls"
+ report_name_after = report_path_ago+excel_file_name_after
if os.path.exists(report_name_after):
os.remove(report_name_after)
-
- #新建一个excel文件
- after_mig_xls = xlwt.Workbook(encoding='utf-8',style_compression=0)
-
+ after_mig_xls = xlwt.Workbook(encoding='utf-8', style_compression=0)
system_info_after(after_mig_xls)
pkg_comp_after(after_mig_xls)
abi_incomp_info(after_mig_xls)
abi_comp_pkg(after_mig_xls)
-
after_mig_xls.save(report_name_after)
diff --git a/ut-Migration-tools-0.1/centos7/uos/centos72uos.sh b/ut-Migration-tools-0.1/centos7/uos/centos72uos.sh
index 7248b14..18a9ddf 100755
--- a/ut-Migration-tools-0.1/centos7/uos/centos72uos.sh
+++ b/ut-Migration-tools-0.1/centos7/uos/centos72uos.sh
@@ -1,6 +1,5 @@
#!/bin/bash
# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
-
# SPDX-License-Identifier: MulanPubL-2.0-or-later
set -x
--
2.20.1