Blame SOURCES/0004-Python-3-compatible-prints.patch

1330ca
From d045ccd1730c6211252cd68cd69d387895df9641 Mon Sep 17 00:00:00 2001
1330ca
From: Tomas Kasparek <tkasparek@redhat.com>
1330ca
Date: Mon, 5 Mar 2018 11:15:58 +0100
1330ca
Subject: [PATCH 04/17] Python 3 compatible prints
1330ca
1330ca
---
1330ca
 koan/app.py         | 106 ++++++++++++++++++++++++++--------------------------
1330ca
 koan/register.py    |  24 ++++++------
1330ca
 koan/utils.py       |  36 +++++++++---------
1330ca
 koan/virtinstall.py |  12 +++---
1330ca
 koan/vmwcreate.py   |  22 +++++------
1330ca
 5 files changed, 100 insertions(+), 100 deletions(-)
1330ca
1330ca
diff --git a/koan/app.py b/koan/app.py
1330ca
index e4e8a6d..ce8c8c3 100755
1330ca
--- a/koan/app.py
1330ca
+++ b/koan/app.py
1330ca
@@ -217,11 +217,11 @@ def main():
1330ca
         (xa, xb, tb) = sys.exc_info()
1330ca
         try:
1330ca
             getattr(e,"from_koan")
1330ca
-            print str(e)[1:-1] # nice exception, no traceback needed
1330ca
+            print(str(e)[1:-1]) # nice exception, no traceback needed
1330ca
         except:
1330ca
-            print xa
1330ca
-            print xb
1330ca
-            print string.join(traceback.format_list(traceback.extract_tb(tb)))
1330ca
+            print(xa)
1330ca
+            print(xb)
1330ca
+            print(string.join(traceback.format_list(traceback.extract_tb(tb))))
1330ca
         return 1
1330ca
 
1330ca
     return 0
1330ca
@@ -307,9 +307,9 @@ class Koan:
1330ca
     
1330ca
         if not os.getuid() == 0:
1330ca
             if self.is_virt:
1330ca
-                print "warning: running as non root"
1330ca
+                print("warning: running as non root")
1330ca
             else:
1330ca
-                print "this operation requires root access"
1330ca
+                print("this operation requires root access")
1330ca
                 return 3
1330ca
         
1330ca
         # if both --profile and --system were ommitted, autodiscover
1330ca
@@ -372,20 +372,20 @@ class Koan:
1330ca
         try:
1330ca
             available_profiles = self.xmlrpc_server.get_profiles()
1330ca
         except:
1330ca
-            traceback.print_exc()
1330ca
+            traceback.print(_exc())
1330ca
             self.connect_fail()
1330ca
 
1330ca
-        print "\n- which profile to install?\n"
1330ca
+        print("\n- which profile to install?\n")
1330ca
       
1330ca
         for x in available_profiles:
1330ca
-            print "%s" % x["name"]
1330ca
+            print("%s" % x["name"])
1330ca
 
1330ca
         sys.stdout.write("\n?>")
1330ca
 
1330ca
         data = sys.stdin.readline().strip()
1330ca
  
1330ca
         for x in available_profiles:
1330ca
-            print "comp (%s,%s)" % (x["name"],data)
1330ca
+            print("comp (%s,%s)" % (x["name"],data))
1330ca
             if x["name"] == data:
1330ca
                 return data
1330ca
         return None
1330ca
@@ -432,7 +432,7 @@ class Koan:
1330ca
             else:
1330ca
                 return None
1330ca
         elif len(detected_systems) == 1:
1330ca
-            print "- Auto detected: %s" % detected_systems[0]
1330ca
+            print("- Auto detected: %s" % detected_systems[0])
1330ca
             return detected_systems[0]
1330ca
 
1330ca
     #---------------------------------------------------
1330ca
@@ -509,7 +509,7 @@ class Koan:
1330ca
                     raise InfoException("xmlfile based installations are not supported")
1330ca
 
1330ca
                 elif profile_data.has_key("file"):
1330ca
-                    print "- ISO or Image based installation, always uses --virt-type=qemu"
1330ca
+                    print("- ISO or Image based installation, always uses --virt-type=qemu")
1330ca
                     self.virt_type = "qemu"
1330ca
                     
1330ca
                 else:
1330ca
@@ -525,7 +525,7 @@ class Koan:
1330ca
                         # assume Xen, we'll check to see if virt-type is really usable later.
1330ca
                         raise InfoException, "Not running a Xen kernel and qemu is not installed"
1330ca
 
1330ca
-                print "- no virt-type specified, auto-selecting %s" % self.virt_type
1330ca
+                print("- no virt-type specified, auto-selecting %s" % self.virt_type)
1330ca
 
1330ca
             # now that we've figured out our virt-type, let's see if it is really usable
1330ca
             # rather than showing obscure error messages from Xen to the user :)
1330ca
@@ -628,9 +628,9 @@ class Koan:
1330ca
                         break
1330ca
 
1330ca
             if self.safe_load(profile_data,"install_tree"):
1330ca
-                print "install_tree:", profile_data["install_tree"]
1330ca
+                print("install_tree:", profile_data["install_tree"])
1330ca
             else:
1330ca
-                print "warning: kickstart found but no install_tree found"
1330ca
+                print("warning: kickstart found but no install_tree found")
1330ca
                         
1330ca
         except:
1330ca
             # unstable to download the kickstart, however this might not
1330ca
@@ -646,7 +646,7 @@ class Koan:
1330ca
         data = self.get_data(what)
1330ca
         for x in data:
1330ca
             if x.has_key("name"):
1330ca
-                print x["name"]
1330ca
+                print(x["name"])
1330ca
         return True
1330ca
 
1330ca
     #---------------------------------------------------
1330ca
@@ -658,7 +658,7 @@ class Koan:
1330ca
                     value = profile_data[x]
1330ca
                     if x == 'kernel_options':
1330ca
                         value = self.calc_kernel_args(profile_data)
1330ca
-                    print "%20s  : %s" % (x, value)
1330ca
+                    print("%20s  : %s" % (x, value))
1330ca
         return self.net_install(after_download)
1330ca
 
1330ca
     #---------------------------------------------------
1330ca
@@ -702,9 +702,9 @@ class Koan:
1330ca
         template_files = utils.input_string_or_hash(template_files)
1330ca
         template_keys  = template_files.keys()
1330ca
 
1330ca
-        print "- template map: %s" % template_files
1330ca
+        print("- template map: %s" % template_files)
1330ca
 
1330ca
-        print "- processing for files to download..."
1330ca
+        print("- processing for files to download...")
1330ca
         for src in template_keys: 
1330ca
             dest = template_files[src]
1330ca
             save_as = dest
1330ca
@@ -713,7 +713,7 @@ class Koan:
1330ca
             if not save_as.startswith("/"):
1330ca
                 # this is a file in the template system that is not to be downloaded
1330ca
                 continue
1330ca
-            print "- file: %s" % save_as
1330ca
+            print("- file: %s" % save_as)
1330ca
 
1330ca
             pattern = "http://%s/cblr/svc/op/template/%s/%s/path/%s"
1330ca
             if profile_data.has_key("interfaces"):
1330ca
@@ -780,7 +780,7 @@ class Koan:
1330ca
                 '--command-line=%s' % (k_args,),
1330ca
                 self.safe_load(profile_data,'kernel_local')
1330ca
             ])
1330ca
-            print "Kernel loaded; run 'kexec -e' to execute"
1330ca
+            print("Kernel loaded; run 'kexec -e' to execute")
1330ca
         return self.net_install(after_download)
1330ca
 
1330ca
 
1330ca
@@ -900,25 +900,25 @@ class Koan:
1330ca
             # Any post-grubby processing required (e.g. ybin, zipl, lilo)?
1330ca
             if arch.startswith("ppc") and "grub2" not in probe_output:
1330ca
                 # FIXME - CHRP hardware uses a 'PPC PReP Boot' partition and doesn't require running ybin
1330ca
-                print "- applying ybin changes"
1330ca
+                print("- applying ybin changes")
1330ca
                 cmd = [ "/sbin/ybin" ]
1330ca
                 utils.subprocess_call(cmd)
1330ca
             elif arch.startswith("s390"):
1330ca
-                print "- applying zipl changes"
1330ca
+                print("- applying zipl changes")
1330ca
                 cmd = [ "/sbin/zipl" ]
1330ca
                 utils.subprocess_call(cmd)
1330ca
             else:
1330ca
                 # if grubby --bootloader-probe returns lilo,
1330ca
                 #    apply lilo changes
1330ca
                 if boot_probe_ret_code == 0 and string.find(probe_output, "lilo") != -1:
1330ca
-                    print "- applying lilo changes"
1330ca
+                    print("- applying lilo changes")
1330ca
                     cmd = [ "/sbin/lilo" ]
1330ca
                     utils.subprocess_call(cmd)
1330ca
 
1330ca
             if not self.add_reinstall_entry:
1330ca
-                print "- reboot to apply changes"
1330ca
+                print("- reboot to apply changes")
1330ca
             else:
1330ca
-                print "- reinstallation entry added"
1330ca
+                print("- reinstallation entry added")
1330ca
 
1330ca
         return self.net_install(after_download)
1330ca
 
1330ca
@@ -986,7 +986,7 @@ class Koan:
1330ca
             else:
1330ca
                 data = getattr(self.xmlrpc_server, "get_%s_for_koan" % what)(name)
1330ca
         except:
1330ca
-            traceback.print_exc()
1330ca
+            traceback.print(_exc())
1330ca
             self.connect_fail()
1330ca
         if data == {}:
1330ca
             raise InfoException("No entry/entries found")
1330ca
@@ -1049,15 +1049,15 @@ class Koan:
1330ca
                 initrd = "http://%s/cobbler/images/%s/%s" % (self.server, distro, initrd_short)
1330ca
 
1330ca
         try:
1330ca
-            print "downloading initrd %s to %s" % (initrd_short, initrd_save)
1330ca
-            print "url=%s" % initrd
1330ca
+            print("downloading initrd %s to %s" % (initrd_short, initrd_save))
1330ca
+            print("url=%s" % initrd)
1330ca
             utils.urlgrab(initrd,initrd_save)
1330ca
 
1330ca
-            print "downloading kernel %s to %s" % (kernel_short, kernel_save)
1330ca
-            print "url=%s" % kernel
1330ca
+            print("downloading kernel %s to %s" % (kernel_short, kernel_save))
1330ca
+            print("url=%s" % kernel)
1330ca
             utils.urlgrab(kernel,kernel_save)
1330ca
         except:
1330ca
-            traceback.print_exc()
1330ca
+            traceback.print(_exc())
1330ca
             raise InfoException, "error downloading files"
1330ca
         profile_data['kernel_local'] = kernel_save
1330ca
         profile_data['initrd_local'] = initrd_save
1330ca
@@ -1166,11 +1166,11 @@ class Koan:
1330ca
                 noreboot          =  self.virtinstall_noreboot,
1330ca
         )
1330ca
 
1330ca
-        print results
1330ca
+        print(results)
1330ca
 
1330ca
         if can_poll is not None and self.should_poll:
1330ca
             import libvirt
1330ca
-            print "- polling for virt completion"
1330ca
+            print("- polling for virt completion")
1330ca
             conn = None
1330ca
             if can_poll == "xen":
1330ca
                conn = libvirt.open(None)
1330ca
@@ -1183,14 +1183,14 @@ class Koan:
1330ca
                time.sleep(3)
1330ca
                state = utils.get_vm_state(conn, virtname)
1330ca
                if state == "running":
1330ca
-                   print "- install is still running, sleeping for 1 minute (%s)" % ct
1330ca
+                   print("- install is still running, sleeping for 1 minute (%s)" % ct)
1330ca
                    ct = ct + 1
1330ca
                    time.sleep(60)
1330ca
                elif state == "crashed":
1330ca
-                   print "- the install seems to have crashed."
1330ca
+                   print("- the install seems to have crashed.")
1330ca
                    return "failed"
1330ca
                elif state == "shutdown":
1330ca
-                   print "- shutdown VM detected, is the install done?  Restarting!"
1330ca
+                   print("- shutdown VM detected, is the install done?  Restarting!")
1330ca
                    utils.find_vm(conn, virtname).create()    
1330ca
                    return results
1330ca
                else:
1330ca
@@ -1202,7 +1202,7 @@ class Koan:
1330ca
             elif self.virt_type == "qemu":
1330ca
                utils.libvirt_enable_autostart(virtname)
1330ca
             else:
1330ca
-                print "- warning: don't know how to autoboot this virt type yet"
1330ca
+                print("- warning: don't know how to autoboot this virt type yet")
1330ca
             # else...
1330ca
         return results
1330ca
 
1330ca
@@ -1255,8 +1255,8 @@ class Koan:
1330ca
             disks.append([path,size])
1330ca
             counter = counter + 1
1330ca
         if len(disks) == 0:
1330ca
-            print "paths: ", paths
1330ca
-            print "sizes: ", sizes
1330ca
+            print("paths: ", paths)
1330ca
+            print("sizes: ", sizes)
1330ca
             raise InfoException, "Disk configuration not resolvable!"
1330ca
         return disks
1330ca
 
1330ca
@@ -1320,7 +1320,7 @@ class Koan:
1330ca
         if size is None or size == '':
1330ca
             err = True
1330ca
         if err:
1330ca
-            print "invalid file size specified, using defaults"
1330ca
+            print("invalid file size specified, using defaults")
1330ca
             return default_filesize
1330ca
         return int(size)
1330ca
 
1330ca
@@ -1339,7 +1339,7 @@ class Koan:
1330ca
         if size is None or size == '' or int(size) < default_ram:
1330ca
             err = True
1330ca
         if err:
1330ca
-            print "invalid RAM size specified, using defaults."
1330ca
+            print("invalid RAM size specified, using defaults.")
1330ca
             return default_ram
1330ca
         return int(size)
1330ca
 
1330ca
@@ -1353,7 +1353,7 @@ class Koan:
1330ca
         try:
1330ca
             isize = int(size)
1330ca
         except:
1330ca
-            traceback.print_exc()
1330ca
+            traceback.print(_exc())
1330ca
             return default_cpus
1330ca
         return isize
1330ca
 
1330ca
@@ -1386,7 +1386,7 @@ class Koan:
1330ca
         if my_id is None or my_id == '' or not uuid_re.match(id):
1330ca
             err = True
1330ca
         if err and my_id is not None:
1330ca
-            print "invalid UUID specified.  randomizing..."
1330ca
+            print("invalid UUID specified.  randomizing...")
1330ca
             return None
1330ca
         return my_id
1330ca
 
1330ca
@@ -1415,7 +1415,7 @@ class Koan:
1330ca
            else:
1330ca
                prefix = "/var/lib/vmware/images/"
1330ca
            if not os.path.exists(prefix):
1330ca
-               print "- creating: %s" % prefix
1330ca
+               print("- creating: %s" % prefix)
1330ca
                os.makedirs(prefix)
1330ca
            return [ "%s/%s-disk0" % (prefix, name) ]
1330ca
 
1330ca
@@ -1456,7 +1456,7 @@ class Koan:
1330ca
             elif not os.path.exists(location) and os.path.isdir(os.path.dirname(location)):
1330ca
                 return location
1330ca
             elif not os.path.exists(os.path.dirname(location)):
1330ca
-                print "- creating: %s" % os.path.dirname(location)
1330ca
+                print("- creating: %s" % os.path.dirname(location))
1330ca
                 os.makedirs(os.path.dirname(location))
1330ca
                 return location
1330ca
             else:
1330ca
@@ -1470,21 +1470,21 @@ class Koan:
1330ca
         else:
1330ca
             # it's a volume group, verify that it exists
1330ca
             args = "vgs -o vg_name"
1330ca
-            print "%s" % args
1330ca
+            print("%s" % args)
1330ca
             vgnames = sub_process.Popen(args, shell=True, stdout=sub_process.PIPE).communicate()[0]
1330ca
-            print vgnames
1330ca
+            print(vgnames)
1330ca
 
1330ca
             if vgnames.find(location) == -1:
1330ca
                 raise InfoException, "The volume group [%s] does not exist." % location
1330ca
             
1330ca
             # check free space
1330ca
             args = "LANG=C vgs --noheadings -o vg_free --units g %s" % location
1330ca
-            print args
1330ca
+            print(args)
1330ca
             cmd = sub_process.Popen(args, stdout=sub_process.PIPE, shell=True)
1330ca
             freespace_str = cmd.communicate()[0]
1330ca
             freespace_str = freespace_str.split("\n")[0].strip()
1330ca
             freespace_str = freespace_str.lower().replace("g","") # remove gigabytes
1330ca
-            print "(%s)" % freespace_str
1330ca
+            print("(%s)" % freespace_str)
1330ca
             freespace = int(float(freespace_str))
1330ca
 
1330ca
             virt_size = self.calc_virt_filesize(pd)
1330ca
@@ -1498,16 +1498,16 @@ class Koan:
1330ca
             
1330ca
                 # look for LVM partition named foo, create if doesn't exist
1330ca
                 args = "lvs -o lv_name %s" % location
1330ca
-                print "%s" % args
1330ca
+                print("%s" % args)
1330ca
                 lvs_str=sub_process.Popen(args, stdout=sub_process.PIPE, shell=True).communicate()[0]
1330ca
-                print lvs_str
1330ca
+                print(lvs_str)
1330ca
          
1330ca
                 name = "%s-disk%s" % (name,offset)
1330ca
  
1330ca
                 # have to create it?
1330ca
                 if lvs_str.find(name) == -1:
1330ca
                     args = "lvcreate -L %sG -n %s %s" % (virt_size, name, location)
1330ca
-                    print "%s" % args
1330ca
+                    print("%s" % args)
1330ca
                     lv_create = sub_process.call(args, shell=True)
1330ca
                     if lv_create != 0:
1330ca
                         raise InfoException, "LVM creation failed"
1330ca
diff --git a/koan/register.py b/koan/register.py
1330ca
index cabd4a6..1157e5c 100755
1330ca
--- a/koan/register.py
1330ca
+++ b/koan/register.py
1330ca
@@ -65,7 +65,7 @@ def main():
1330ca
 
1330ca
     (options, args) = p.parse_args()
1330ca
     #if not os.getuid() == 0:
1330ca
-    #    print "koan requires root access"
1330ca
+    #    print("koan requires root access")
1330ca
     #    return 3
1330ca
 
1330ca
     try:
1330ca
@@ -80,11 +80,11 @@ def main():
1330ca
         (xa, xb, tb) = sys.exc_info()
1330ca
         try:
1330ca
             getattr(e,"from_koan")
1330ca
-            print str(e)[1:-1] # nice exception, no traceback needed
1330ca
+            print(str(e)[1:-1]) # nice exception, no traceback needed
1330ca
         except:
1330ca
-            print xa
1330ca
-            print xb
1330ca
-            print string.join(traceback.format_list(traceback.extract_tb(tb)))
1330ca
+            print(xa)
1330ca
+            print(xb)
1330ca
+            print(string.join(traceback.format_list(traceback.extract_tb(tb))))
1330ca
         return 1
1330ca
 
1330ca
     return 0
1330ca
@@ -127,13 +127,13 @@ class Register:
1330ca
         if os.getuid() != 0:
1330ca
            raise InfoException("root access is required to register")
1330ca
  
1330ca
-        print "- preparing to koan home"
1330ca
+        print("- preparing to koan home")
1330ca
         self.conn = utils.connect_to_server(self.server, self.port)
1330ca
         reg_info = {}
1330ca
-        print "- gathering network info"
1330ca
+        print("- gathering network info")
1330ca
         netinfo = utils.get_network_info()
1330ca
         reg_info["interfaces"] = netinfo
1330ca
-        print "- checking hostname"
1330ca
+        print("- checking hostname")
1330ca
         sysname = ""
1330ca
         if self.hostname != "" and self.hostname != "*AUTO*":
1330ca
             hostname = self.hostname
1330ca
@@ -171,14 +171,14 @@ class Register:
1330ca
 
1330ca
         if not self.batch:
1330ca
             self.conn.register_new_system(reg_info)
1330ca
-            print "- registration successful, new system name: %s" % sysname
1330ca
+            print("- registration successful, new system name: %s" % sysname)
1330ca
         else:
1330ca
             try:
1330ca
                 self.conn.register_new_system(reg_info)
1330ca
-                print "- registration successful, new system name: %s" % sysname
1330ca
+                print("- registration successful, new system name: %s" % sysname)
1330ca
             except:
1330ca
-                traceback.print_exc()
1330ca
-                print "- registration failed, ignoring because of --batch"
1330ca
+                traceback.print(_exc())
1330ca
+                print("- registration failed, ignoring because of --batch")
1330ca
 
1330ca
         return
1330ca
    
1330ca
diff --git a/koan/utils.py b/koan/utils.py
1330ca
index b8247e2..77d53b2 100644
1330ca
--- a/koan/utils.py
1330ca
+++ b/koan/utils.py
1330ca
@@ -90,7 +90,7 @@ def urlread(url):
1330ca
     parts of urlread and urlgrab from urlgrabber, in ways that
1330ca
     are less cool and less efficient.
1330ca
     """
1330ca
-    print "- reading URL: %s" % url
1330ca
+    print("- reading URL: %s" % url)
1330ca
     if url is None or url == "":
1330ca
         raise InfoException, "invalid URL: %s" % url
1330ca
 
1330ca
@@ -109,7 +109,7 @@ def urlread(url):
1330ca
             subprocess_call(cmd)
1330ca
             return data
1330ca
         except:
1330ca
-            traceback.print_exc()
1330ca
+            traceback.print(_exc())
1330ca
             raise InfoException, "Couldn't mount and read URL: %s" % url
1330ca
           
1330ca
     elif url[0:4] == "http":
1330ca
@@ -119,7 +119,7 @@ def urlread(url):
1330ca
             fd.close()
1330ca
             return data
1330ca
         except:
1330ca
-            traceback.print_exc()
1330ca
+            traceback.print(_exc())
1330ca
             raise InfoException, "Couldn't download: %s" % url
1330ca
     elif url[0:4] == "file":
1330ca
         try:
1330ca
@@ -147,7 +147,7 @@ def subprocess_call(cmd,ignore_rc=0):
1330ca
     """
1330ca
     Wrapper around subprocess.call(...)
1330ca
     """
1330ca
-    print "- %s" % cmd
1330ca
+    print("- %s" % cmd)
1330ca
     rc = sub_process.call(cmd)
1330ca
     if rc != 0 and not ignore_rc:
1330ca
         raise InfoException, "command failed (%s)" % rc
1330ca
@@ -157,7 +157,7 @@ def subprocess_get_response(cmd, ignore_rc=False):
1330ca
     """
1330ca
     Wrapper around subprocess.check_output(...)
1330ca
     """
1330ca
-    print "- %s" % cmd
1330ca
+    print("- %s" % cmd)
1330ca
     rc = 0
1330ca
     result = ""
1330ca
     p = sub_process.Popen(cmd, stdout=sub_process.PIPE, stderr=sub_process.STDOUT)
1330ca
@@ -219,7 +219,7 @@ def input_string_or_hash(options,delim=None,allow_multiples=True):
1330ca
 
1330ca
 def hash_to_string(hash):
1330ca
     """
1330ca
-    Convert a hash to a printable string.
1330ca
+    Convert a hash to a print(able string.)
1330ca
     used primarily in the kernel options string
1330ca
     and for some legacy stuff where koan expects strings
1330ca
     (though this last part should be changed to hashes)
1330ca
@@ -232,7 +232,7 @@ def hash_to_string(hash):
1330ca
        if value is None:
1330ca
            buffer = buffer + str(key) + " "
1330ca
        elif type(value) == list:
1330ca
-           # this value is an array, so we print out every
1330ca
+           # this value is an array, so we print(out every)
1330ca
            # key=value
1330ca
            for item in value:
1330ca
               buffer = buffer + str(key) + "=" + str(item) + " "
1330ca
@@ -251,14 +251,14 @@ def nfsmount(input_path):
1330ca
     mount_cmd = [
1330ca
          "/bin/mount", "-t", "nfs", "-o", "ro", dirpath, tempdir
1330ca
     ]
1330ca
-    print "- running: %s" % mount_cmd
1330ca
+    print("- running: %s" % mount_cmd)
1330ca
     rc = sub_process.call(mount_cmd)
1330ca
     if not rc == 0:
1330ca
         shutil.rmtree(tempdir, ignore_errors=True)
1330ca
         raise koan.InfoException("nfs mount failed: %s" % dirpath)
1330ca
     # NOTE: option for a blocking install might be nice, so we could do this
1330ca
     # automatically, if supported by virt-install
1330ca
-    print "after install completes, you may unmount and delete %s" % tempdir
1330ca
+    print("after install completes, you may unmount and delete %s" % tempdir)
1330ca
     return (tempdir, filename)
1330ca
 
1330ca
 
1330ca
@@ -411,7 +411,7 @@ def get_network_info():
1330ca
          "module"      : module
1330ca
       }
1330ca
 
1330ca
-   # print interfaces
1330ca
+   # print(interfaces)
1330ca
    return interfaces
1330ca
 
1330ca
 def connect_to_server(server=None,port=None):
1330ca
@@ -431,7 +431,7 @@ def connect_to_server(server=None,port=None):
1330ca
         "https://%s/cobbler_api" % (server),
1330ca
     ]
1330ca
     for url in try_urls:
1330ca
-        print "- looking for Cobbler at %s" % url
1330ca
+        print("- looking for Cobbler at %s" % url)
1330ca
         server = __try_connect(url)
1330ca
         if server is not None:
1330ca
            return server
1330ca
@@ -467,18 +467,18 @@ def libvirt_enable_autostart(domain_name):
1330ca
 def make_floppy(kickstart):
1330ca
 
1330ca
     (fd, floppy_path) = tempfile.mkstemp(suffix='.floppy', prefix='tmp', dir="/tmp")
1330ca
-    print "- creating floppy image at %s" % floppy_path
1330ca
+    print("- creating floppy image at %s" % floppy_path)
1330ca
 
1330ca
     # create the floppy image file
1330ca
     cmd = "dd if=/dev/zero of=%s bs=1440 count=1024" % floppy_path
1330ca
-    print "- %s" % cmd
1330ca
+    print("- %s" % cmd)
1330ca
     rc = os.system(cmd)
1330ca
     if not rc == 0:
1330ca
         raise InfoException("dd failed")
1330ca
 
1330ca
     # vfatify
1330ca
     cmd = "mkdosfs %s" % floppy_path
1330ca
-    print "- %s" % cmd
1330ca
+    print("- %s" % cmd)
1330ca
     rc = os.system(cmd)
1330ca
     if not rc == 0:
1330ca
         raise InfoException("mkdosfs failed")
1330ca
@@ -486,19 +486,19 @@ def make_floppy(kickstart):
1330ca
     # mount the floppy
1330ca
     mount_path = tempfile.mkdtemp(suffix=".mnt", prefix='tmp', dir="/tmp")
1330ca
     cmd = "mount -o loop -t vfat %s %s" % (floppy_path, mount_path)
1330ca
-    print "- %s" % cmd
1330ca
+    print("- %s" % cmd)
1330ca
     rc = os.system(cmd)
1330ca
     if not rc == 0:
1330ca
         raise InfoException("mount failed")
1330ca
 
1330ca
     # download the kickstart file onto the mounted floppy
1330ca
-    print "- downloading %s" % kickstart
1330ca
+    print("- downloading %s" % kickstart)
1330ca
     save_file = os.path.join(mount_path, "unattended.txt")
1330ca
     urlgrabber.urlgrab(kickstart,filename=save_file)
1330ca
 
1330ca
     # umount    
1330ca
     cmd = "umount %s" % mount_path
1330ca
-    print "- %s" % cmd
1330ca
+    print("- %s" % cmd)
1330ca
     rc = os.system(cmd)
1330ca
     if not rc == 0:
1330ca
         raise InfoException("umount failed")
1330ca
@@ -522,7 +522,7 @@ def __try_connect(url):
1330ca
         xmlrpc_server.ping()
1330ca
         return xmlrpc_server
1330ca
     except:
1330ca
-        traceback.print_exc()
1330ca
+        traceback.print(_exc())
1330ca
         return None
1330ca
 
1330ca
 
1330ca
diff --git a/koan/virtinstall.py b/koan/virtinstall.py
1330ca
index ca11e04..2d1f3df 100644
1330ca
--- a/koan/virtinstall.py
1330ca
+++ b/koan/virtinstall.py
1330ca
@@ -191,7 +191,7 @@ def build_commandline(uri,
1330ca
     oldstyle_accelerate = False
1330ca
 
1330ca
     if not virtinst_version:
1330ca
-        print ("- warning: old virt-install detected, a lot of features will be disabled")
1330ca
+        print(("- warning: old virt-install detected, a lot of features will be disabled"))
1330ca
         disable_autostart = True
1330ca
         disable_boot_opt = True
1330ca
         disable_virt_type = True
1330ca
@@ -239,7 +239,7 @@ def build_commandline(uri,
1330ca
 
1330ca
         # this is an image based installation
1330ca
         input_path = profile_data["file"]
1330ca
-        print "- using image location %s" % input_path
1330ca
+        print("- using image location %s" % input_path)
1330ca
         if input_path.find(":") == -1:
1330ca
             # this is not an NFS path
1330ca
             cdrom = input_path
1330ca
@@ -251,7 +251,7 @@ def build_commandline(uri,
1330ca
         if kickstart != "":
1330ca
             # we have a (windows?) answer file we have to provide
1330ca
             # to the ISO.
1330ca
-            print "I want to make a floppy for %s" % kickstart
1330ca
+            print("I want to make a floppy for %s" % kickstart)
1330ca
             floppy = utils.make_floppy(kickstart)
1330ca
     elif is_qemu or is_xen:
1330ca
         # images don't need to source this
1330ca
@@ -378,7 +378,7 @@ def build_commandline(uri,
1330ca
                 # compatibility in virt-install grumble grumble.
1330ca
                 cmd += "--os-variant %s" % os_version + ".0 "
1330ca
             else:
1330ca
-                print ("- warning: virt-install doesn't know this os_version, defaulting to generic26")
1330ca
+                print(("- warning: virt-install doesn't know this os_version, defaulting to generic26"))
1330ca
                 cmd += "--os-variant generic26 "
1330ca
         else:
1330ca
             distro = "unix"
1330ca
@@ -394,8 +394,8 @@ def build_commandline(uri,
1330ca
         cmd += "--disk path=%s " % importpath
1330ca
 
1330ca
     for path, size, driver_type in disks:
1330ca
-        print ("- adding disk: %s of size %s (driver type=%s)" %
1330ca
-               (path, size, driver_type))
1330ca
+        print(("- adding disk: %s of size %s (driver type=%s)" %
1330ca
+               (path, size, driver_type)))
1330ca
         cmd += "--disk path=%s" % (path)
1330ca
         if str(size) != "0":
1330ca
             cmd += ",size=%s" % size
1330ca
diff --git a/koan/vmwcreate.py b/koan/vmwcreate.py
1330ca
index 372173a..97e0ba2 100755
1330ca
--- a/koan/vmwcreate.py
1330ca
+++ b/koan/vmwcreate.py
1330ca
@@ -77,7 +77,7 @@ def random_mac():
1330ca
 
1330ca
 def make_disk(disksize,image):
1330ca
     cmd = "vmware-vdiskmanager -c -a lsilogic -s %sGb -t 0 %s" % (disksize, image)
1330ca
-    print "- %s" % cmd
1330ca
+    print("- %s" % cmd)
1330ca
     rc = os.system(cmd)
1330ca
     if rc != 0:
1330ca
        raise VirtCreateException("command failed")
1330ca
@@ -96,7 +96,7 @@ def make_vmx(path,vmdk_image,image_name,mac_address,memory):
1330ca
 
1330ca
 def register_vmx(vmx_file):
1330ca
     cmd = "vmware-cmd -s register %s" % vmx_file
1330ca
-    print "- %s" % cmd
1330ca
+    print("- %s" % cmd)
1330ca
     rc = os.system(cmd)
1330ca
     if rc!=0:
1330ca
        raise VirtCreateException("vmware registration failed")
1330ca
@@ -104,7 +104,7 @@ def register_vmx(vmx_file):
1330ca
 def start_vm(vmx_file):
1330ca
     os.chmod(vmx_file,0755)
1330ca
     cmd = "vmware-cmd %s start" % vmx_file
1330ca
-    print "- %s" % cmd
1330ca
+    print("- %s" % cmd)
1330ca
     rc = os.system(cmd)
1330ca
     if rc != 0:
1330ca
        raise VirtCreateException("vm start failed")
1330ca
@@ -129,19 +129,19 @@ def start_install(name=None,
1330ca
 
1330ca
     mac = None
1330ca
     if not profile_data.has_key("interfaces"):
1330ca
-        print "- vmware installation requires a system, not a profile"
1330ca
+        print("- vmware installation requires a system, not a profile")
1330ca
         return 1
1330ca
     for iname in profile_data["interfaces"]:
1330ca
         intf = profile_data["interfaces"][iname]
1330ca
         mac = intf["mac_address"]
1330ca
     if mac is None:
1330ca
-        print "- no MAC information available in this record, cannot install"
1330ca
+        print("- no MAC information available in this record, cannot install")
1330ca
         return 1
1330ca
 
1330ca
-    print "DEBUG: name=%s" % name
1330ca
-    print "DEBUG: ram=%s" % ram
1330ca
-    print "DEBUG: mac=%s" % mac
1330ca
-    print "DEBUG: disks=%s" % disks
1330ca
+    print("DEBUG: name=%s" % name)
1330ca
+    print("DEBUG: ram=%s" % ram)
1330ca
+    print("DEBUG: mac=%s" % mac)
1330ca
+    print("DEBUG: disks=%s" % disks)
1330ca
     # starts vmware using PXE.  disk/mem info come from Cobbler
1330ca
     # rest of the data comes from PXE which is also intended
1330ca
     # to be managed by Cobbler.
1330ca
@@ -158,10 +158,10 @@ def start_install(name=None,
1330ca
     disksize = disks[0][1]
1330ca
 
1330ca
     image = "%s/%s" % (IMAGE_DIR, name)
1330ca
-    print "- saving virt disk image as %s" % image
1330ca
+    print("- saving virt disk image as %s" % image)
1330ca
     make_disk(disksize,image)
1330ca
     vmx = "%s/%s" % (VMX_DIR, name)
1330ca
-    print "- saving vmx file as %s" % vmx
1330ca
+    print("- saving vmx file as %s" % vmx)
1330ca
     make_vmx(vmx,image,name,mac,ram)
1330ca
     register_vmx(vmx)
1330ca
     start_vm(vmx)
1330ca
-- 
1330ca
2.5.5
1330ca