!82 json and list format interchange
From: @xuezhizone Reviewed-by: @xingwei-liu Signed-off-by: @xingwei-liu
This commit is contained in:
commit
b4a64c8a22
86
0029-json-and-list-format-interchange.patch
Normal file
86
0029-json-and-list-format-interchange.patch
Normal file
@ -0,0 +1,86 @@
|
||||
From dd381efe588297b6f450665d374fcaafab0206e5 Mon Sep 17 00:00:00 2001
|
||||
From: xuezhixin <xuezhixin@uniontech.com>
|
||||
Date: Fri, 10 Nov 2023 11:07:17 +0800
|
||||
Subject: [PATCH] =?UTF-8?q?json=E5=92=8Clist=E6=A0=BC=E5=BC=8F=E4=BA=92?=
|
||||
=?UTF-8?q?=E6=8D=A2?=
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
---
|
||||
sysmig_agent/share.py | 35 ++++++++++++++++++++++++++---------
|
||||
1 file changed, 26 insertions(+), 9 deletions(-)
|
||||
|
||||
diff --git a/sysmig_agent/share.py b/sysmig_agent/share.py
|
||||
index 68fcfa0..1a12a7e 100644
|
||||
--- a/sysmig_agent/share.py
|
||||
+++ b/sysmig_agent/share.py
|
||||
@@ -1,14 +1,17 @@
|
||||
# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
|
||||
# SPDX-License-Identifier: MulanPubL-2.0-or-later
|
||||
|
||||
-import logging
|
||||
import os
|
||||
-import platform
|
||||
+import sys
|
||||
+import json
|
||||
import re
|
||||
-import shutil
|
||||
import subprocess
|
||||
+import shutil
|
||||
import socket
|
||||
-from sysmig_agent.utils import list_to_json
|
||||
+import platform
|
||||
+import logging
|
||||
+
|
||||
+sys.path.append("..")
|
||||
from connect_sql import DBHelper
|
||||
|
||||
def get_local_ip():
|
||||
@@ -192,17 +195,19 @@ def get_disk_info(string):
|
||||
|
||||
|
||||
def add_boot_option():
|
||||
- print("Current system is uefi, add boot option to boot manager.")
|
||||
- subprocess.run('which efibootmgr > /dev/null 2>&1 || dnf install -y efibootmgr', shell=True)
|
||||
+ """
|
||||
+ Current system is uefi, add boot option to boot manager.
|
||||
+ """
|
||||
+ subprocess.run('which efibootmgr > /dev/null 2>&1 || yum install -y efibootmgr', shell=True)
|
||||
disk_name = subprocess.check_output('mount | grep /boot/efi | awk \'{print $1}\'', shell=True)
|
||||
disk_name = str(disk_name, 'utf-8')
|
||||
disk_name = disk_name.split('\n')[0]
|
||||
- dev_name,part_num = get_disk_info(disk_name)
|
||||
+ dev_name, part_num = get_disk_info(disk_name)
|
||||
if dev_name == "" or part_num == "":
|
||||
- print("Parse /boot/efi disk info failed, update boot loader failed.")
|
||||
+ # "Parse /boot/efi disk info failed, update boot loader failed.
|
||||
return
|
||||
|
||||
- cmd=""
|
||||
+ cmd = ""
|
||||
arch = platform.machine()
|
||||
if arch == "x86_64":
|
||||
cmd = 'efibootmgr -c -d ' + dev_name + ' -p ' + part_num + ' -l "/EFI/uos/grubx86.efi" -L "Uniontech OS"'
|
||||
@@ -296,6 +301,18 @@ def title_conf(oldosname):
|
||||
open(fpath, 'w').write(strall.replace(line, title))
|
||||
|
||||
|
||||
+def json_list_to_json(keylist, valuelist):
|
||||
+ res = dict(zip(keylist, valuelist))
|
||||
+ # logdss.info (res)
|
||||
+ return json.dumps(res)
|
||||
+
|
||||
+def list_to_json(keylist, valuelist):
|
||||
+ res = dict(zip(keylist, valuelist))
|
||||
+ res = json.dumps(res)
|
||||
+ # logdss.info (res)
|
||||
+ return json.dumps(res)
|
||||
+
|
||||
+
|
||||
def main_conf(osname):
|
||||
logger = logging.getLogger()
|
||||
logger.setLevel(logging.INFO)
|
||||
--
|
||||
2.20.1
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
Name: migration-tools
|
||||
Version: 1.0.2
|
||||
Release: 28
|
||||
Release: 29
|
||||
License: MulanPSL-2.0
|
||||
Summary: A tool to help users migrate the Centos system to the UOS system and openEuler system
|
||||
Source0: %{name}-%{version}.tar.gz
|
||||
@ -35,7 +35,7 @@ Patch25: 0025-update-migration-status-to-database.patch
|
||||
Patch26: 0026-create-repository-and-disable-local-repofile.patch
|
||||
Patch27: 0027-fix-grub-file-for-system-option.patch
|
||||
Patch28: 0028-send-agent-task.patch
|
||||
|
||||
Patch29: 0029-json-and-list-format-interchange.patch
|
||||
BuildArch: noarch
|
||||
BuildRequires: systemd
|
||||
%description
|
||||
@ -133,6 +133,9 @@ rm -rf /usr/bin/migration-tools
|
||||
%endif
|
||||
|
||||
%changelog
|
||||
* Tue Nov 5 2024 xuezhixin <xuezhixin@uniontech.com> - 1.0.2-29
|
||||
- 0029-json-and-list-format-interchange.patch
|
||||
|
||||
* Tue Nov 5 2024 xuezhixin <xuezhixin@uniontech.com> - 1.0.2-28
|
||||
- 0028-send-agent-task.patch
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user