!55 modify excel report content
From: @xuezhizone Reviewed-by: @xingwei-liu Signed-off-by: @xingwei-liu
This commit is contained in:
commit
e2c0fab407
223
0002-modify-excel-report-content.patch
Normal file
223
0002-modify-excel-report-content.patch
Normal file
@ -0,0 +1,223 @@
|
||||
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
|
||||
|
||||
@ -1,13 +1,14 @@
|
||||
Name: migration-tools
|
||||
Version: 1.0.2
|
||||
Release: 1
|
||||
Release: 2
|
||||
License: MulanPSL-2.0
|
||||
Summary: A tool to help users migrate the Centos system to the UOS system and openEuler system
|
||||
Source0: migration-tools.tar.gz
|
||||
Source0: %{name}-%{version}.tar.gz
|
||||
Source1: requires.tar.gz
|
||||
Source2: xlwt-1.3.0-py2.py3-none-any.whl
|
||||
# patches
|
||||
Patch0: 0001-format-code.patch
|
||||
Patch1: 0002-modify-excel-report-content.patch
|
||||
|
||||
BuildArch: noarch
|
||||
BuildRequires: systemd
|
||||
@ -48,12 +49,11 @@ Migration software server side
|
||||
|
||||
|
||||
%prep
|
||||
%setup -c
|
||||
%autosetup -p1
|
||||
|
||||
%patch 0 -p1
|
||||
|
||||
%if 0%{?openEuler}
|
||||
mkdir agent-requires
|
||||
mkdir -p agent-requires/
|
||||
cp -f %SOURCE1 agent-requires/
|
||||
cp -f %SOURCE2 agent-requires/
|
||||
%endif
|
||||
@ -64,12 +64,13 @@ mkdir -p $RPM_BUILD_ROOT/usr/lib/migration-tools-server
|
||||
mkdir -p $RPM_BUILD_ROOT/var/tmp/uos-migration
|
||||
mkdir -p $RPM_BUILD_ROOT/etc/migration-tools
|
||||
mkdir -p $RPM_BUILD_ROOT%{_unitdir}
|
||||
%{__cp} -r * $RPM_BUILD_ROOT/usr/lib/migration-tools-server/
|
||||
|
||||
cp -r * $RPM_BUILD_ROOT/usr/lib/migration-tools-server/
|
||||
|
||||
%if 0%{?rhel} >= 7
|
||||
mkdir -p $RPM_BUILD_ROOT/usr/lib/migration-tools-agent
|
||||
cp -r * $RPM_BUILD_ROOT/usr/lib/migration-tools-agent/
|
||||
%{__cp} -r * $RPM_BUILD_ROOT/usr/lib/migration-tools-agent/
|
||||
|
||||
%{__cp} -r $RPM_BUILD_ROOT/usr/lib/migration-tools-server/server/migration-tools-agent.service $RPM_BUILD_ROOT%{_unitdir}
|
||||
%endif
|
||||
|
||||
@ -106,6 +107,9 @@ rm -rf /usr/bin/migration-tools
|
||||
%endif
|
||||
|
||||
%changelog
|
||||
* Fri Nov 1 2024 xuezhixin <xuezhixin@uniontech.com> - 1.0.2-2
|
||||
- add 0002-modify-excel-report-content.patch
|
||||
|
||||
* Thu Oct 31 2024 xuezhixin <xuezhixin@uniontech.com> - 1.0.2-1
|
||||
- add 0001-stander-code.patch
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user