112 lines
4.0 KiB
Diff
112 lines
4.0 KiB
Diff
From 79136996ad2cf9d5ea51cc0a053cfe5815785c41 Mon Sep 17 00:00:00 2001
|
|
From: Tomas Kasparek <tkasparek@redhat.com>
|
|
Date: Mon, 5 Mar 2018 11:34:57 +0100
|
|
Subject: [PATCH 07/17] Python 3 compatible string operations
|
|
|
|
---
|
|
koan/app.py | 9 ++++-----
|
|
koan/register.py | 3 +--
|
|
koan/utils.py | 7 +++----
|
|
3 files changed, 8 insertions(+), 11 deletions(-)
|
|
|
|
diff --git a/koan/app.py b/koan/app.py
|
|
index c1d79c2..e727932 100755
|
|
--- a/koan/app.py
|
|
+++ b/koan/app.py
|
|
@@ -40,7 +40,6 @@ try: #python2
|
|
import xmlrpclib
|
|
except ImportError: #python3
|
|
import xmlrpc.client as xmlrpclib
|
|
-import string
|
|
import re
|
|
from . import utils
|
|
|
|
@@ -880,7 +879,7 @@ class Koan:
|
|
cmd.append("--copy-default")
|
|
|
|
boot_probe_ret_code, probe_output = self.get_boot_loader_info()
|
|
- if boot_probe_ret_code == 0 and string.find(probe_output, "lilo") >= 0:
|
|
+ if boot_probe_ret_code == 0 and probe_output.find("lilo") >= 0:
|
|
cmd.append("--lilo")
|
|
|
|
if self.add_reinstall_entry:
|
|
@@ -929,7 +928,7 @@ class Koan:
|
|
else:
|
|
# if grubby --bootloader-probe returns lilo,
|
|
# apply lilo changes
|
|
- if boot_probe_ret_code == 0 and string.find(probe_output, "lilo") != -1:
|
|
+ if boot_probe_ret_code == 0 and probe_output.find("lilo") != -1:
|
|
print("- applying lilo changes")
|
|
cmd = [ "/sbin/lilo" ]
|
|
utils.subprocess_call(cmd)
|
|
@@ -1132,10 +1131,10 @@ class Koan:
|
|
hash2 = utils.input_string_or_hash(self.kopts_override)
|
|
hashv.update(hash2)
|
|
options = utils.hash_to_string(hashv)
|
|
- options = string.replace(options, "lang ","lang= ")
|
|
+ options = options.replace("lang ","lang= ")
|
|
# if using ksdevice=bootif that only works for PXE so replace
|
|
# it with something that will work
|
|
- options = string.replace(options, "ksdevice=bootif","ksdevice=link")
|
|
+ options = options.replace("ksdevice=bootif","ksdevice=link")
|
|
return options
|
|
|
|
#---------------------------------------------------
|
|
diff --git a/koan/register.py b/koan/register.py
|
|
index 5d28acd..a69f2d1 100755
|
|
--- a/koan/register.py
|
|
+++ b/koan/register.py
|
|
@@ -31,7 +31,6 @@ except ImportError: #python3
|
|
import xmlrpc.client as xmlrpclib
|
|
import socket
|
|
from . import utils
|
|
-import string
|
|
|
|
# usage: cobbler-register [--server=server] [--hostname=hostname] --profile=foo
|
|
|
|
@@ -84,7 +83,7 @@ def main():
|
|
except:
|
|
print(xa)
|
|
print(xb)
|
|
- print(string.join(traceback.format_list(traceback.extract_tb(tb))))
|
|
+ print("".join(traceback.format_list(traceback.extract_tb(tb))))
|
|
return 1
|
|
|
|
return 0
|
|
diff --git a/koan/utils.py b/koan/utils.py
|
|
index 1aee405..f2f2692 100644
|
|
--- a/koan/utils.py
|
|
+++ b/koan/utils.py
|
|
@@ -31,7 +31,6 @@ try: #python2
|
|
except ImportError: #python3
|
|
import urllib.request as urllib2
|
|
import xmlrpc.client as xmlrpclib
|
|
-import string
|
|
import shutil
|
|
import tempfile
|
|
import urlgrabber
|
|
@@ -181,9 +180,9 @@ def input_string_or_hash(options,delim=None,allow_multiples=True):
|
|
raise InfoException("No idea what to do with list: %s" % options)
|
|
elif type(options) == type(""):
|
|
new_dict = {}
|
|
- tokens = string.split(options, delim)
|
|
+ tokens = options.split(delim)
|
|
for t in tokens:
|
|
- tokens2 = string.split(t,"=",1)
|
|
+ tokens2 = t.split("=",1)
|
|
if len(tokens2) == 1:
|
|
# this is a singleton option, no value
|
|
key = tokens2[0]
|
|
@@ -246,7 +245,7 @@ def nfsmount(input_path):
|
|
# FIXME: move this function to util.py so other modules can use it
|
|
# we have to mount it first
|
|
filename = input_path.split("/")[-1]
|
|
- dirpath = string.join(input_path.split("/")[:-1],"/")
|
|
+ dirpath = "/".join(input_path.split("/")[:-1])
|
|
tempdir = tempfile.mkdtemp(suffix='.mnt', prefix='koan_', dir='/tmp')
|
|
mount_cmd = [
|
|
"/bin/mount", "-t", "nfs", "-o", "ro", dirpath, tempdir
|
|
--
|
|
2.5.5
|
|
|