[PATCH] network: add first tests for nm.py
by Radek Vykydal
---
tests/pyanaconda_tests/nm_test.py | 44 +++++++++++++++++++++++++++++++++++++++
1 file changed, 44 insertions(+)
create mode 100644 tests/pyanaconda_tests/nm_test.py
diff --git a/tests/pyanaconda_tests/nm_test.py b/tests/pyanaconda_tests/nm_test.py
new file mode 100644
index 0000000..177a525
--- /dev/null
+++ b/tests/pyanaconda_tests/nm_test.py
@@ -0,0 +1,44 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2014 Red Hat, Inc.
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions of
+# the GNU General Public License v.2, or (at your option) any later version.
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY expressed or implied, including the implied warranties of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details. You should have received a copy of the
+# GNU General Public License along with this program; if not, write to the
+# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA. Any Red Hat trademarks that are incorporated in the
+# source code or documentation are not subject to the GNU General Public
+# License and may only be used or replicated with the express permission of
+# Red Hat, Inc.
+#
+# Red Hat Author(s): Radek Vykydal <rvykydal(a)redhat.com>
+
+from pyanaconda import nm
+import unittest
+
+class UtilityFunctionsTests(unittest.TestCase):
+
+ def ipv6_address_convert_test(self):
+ addresses = ["::",
+ "ef:ef:eeef:ef:ef:eeef:efff:ef"]
+ for address in addresses:
+ self.assertEqual(nm.nm_dbus_ay_to_ipv6(nm.nm_ipv6_to_dbus_ay(address)),
+ address)
+
+ self.assertEqual(nm.nm_ipv6_to_dbus_ay("ef:ef:eeef:ef:ef:eeef:efff:ef"),
+ [0, 239, 0, 239, 238, 239, 0, 239, 0, 239, 238, 239, 239, 255, 0, 239])
+
+ def ipv4_address_convert_test(self):
+ addresses = ["192.168.102.1"]
+ for address in addresses:
+ self.assertEqual(nm.nm_dbus_int_to_ipv4(nm.nm_ipv4_to_dbus_int(address)),
+ address)
+
+ self.assertEqual(nm.nm_ipv4_to_dbus_int("192.168.102.1"),
+ 23505088)
+
--
1.9.0
10 years
[anaconda][master][PATCH 0/2] Improving the anaconda CLI help - foundations
by Martin Kolman
As I've started on improving our CLI help, I've noticed that if Anaconda is currently called
with either one of the -h or --help switches, it takes up to a couple of seconds to react
and also spams the stdout with confusing messages such as:
Starting installer, one moment...
dm.c: 1693: not running as root returning empty list
The first patch gets rid of both the delay and the spam by starting option-parsing
at once when "--help" or "-h" is detected in the CLI options.
The second one is a nice-to-have/optional patch, which removes the need to query Anaconda
version (and thus to import iutil) when only the help text is being returned.
This makes it possible to get the Anaconda CLI help even if the given Anaconda does not have
a compiled iutil (fresh clone from Git, etc.).
Martin Kolman (2):
Return CLI help text at once
Don't check anaconda version if just returning the CLI help text
anaconda | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
--
1.9.0
10 years
[anaconda][master][PATCH] Short-circuit initialization when printing out Anaconda version
by Martin Kolman
We already short-circuit the initialization when printing out
the help and we should also short-circuit when printing
the Anaconda version information.
Signed-off-by: Martin Kolman <mkolman(a)redhat.com>
---
anaconda | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/anaconda b/anaconda
index 7499bc3..a77c426 100755
--- a/anaconda
+++ b/anaconda
@@ -747,7 +747,7 @@ def cleanPStore():
if __name__ == "__main__":
# check if the CLI help is requested and return it at once,
# without importing random stuff and spamming stdout
- if ("--help" in sys.argv) or ("-h" in sys.argv):
+ if ("--help" in sys.argv) or ("-h" in sys.argv) or ("--version" in sys.argv):
parseArguments()
print("Starting installer, one moment...")
--
1.9.0
10 years
[PATCH] Fix the handling of set_const options pulled in from the boot cmdline
by David Shea
We lost option.process when switching to argparse, so we need handle the
set_const case ourselves in parse_boot_cmdline.
---
pyanaconda/anaconda_argparse.py | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/pyanaconda/anaconda_argparse.py b/pyanaconda/anaconda_argparse.py
index ed7fa20..cfee657 100644
--- a/pyanaconda/anaconda_argparse.py
+++ b/pyanaconda/anaconda_argparse.py
@@ -189,12 +189,21 @@ class AnacondaArgumentParser(ArgumentParser):
if option.nargs != 0 and val is None:
# nargs == 0 -> option does not take any values, skip it
continue # TODO: emit a warning or something there?
- if option.nargs == 0 and option.const is True and val in ("0", "no", "off"):
+ if option.nargs == 0 and option.const:
# nargs == 0 & constr == True -> store_true
# (we could also check the class, but it begins with an
# underscore, so it would be ugly)
# special case: "mpath=0" would otherwise set mpath to True
- setattr(namespace, option.dest, False)
+ if option.const is True and val in ("0", "no", "off"):
+ setattr(namespace, option.dest, False)
+ # Set all other set_const cases to the const specified
+ else:
+ setattr(namespace, option.dest, option.const)
+
+ # anaconda considers cases such as noselinux=off to be a negative
+ # concord, which is to say that selinux will be set to False and
+ # we hate you.
+
continue
setattr(namespace, option.dest, val)
return namespace
--
1.9.0
10 years
[PATCH] Replace print statements with print function calls
by Martin Kolman
The print statement has been dropped in Python 3 and the print function
works in both Python 2 and Python 3. So there is really no reason to not
just use the print function and make Anaconda a bit more Python 3
friendly.
Signed-off-by: Martin Kolman <mkolman(a)redhat.com>
---
anaconda | 10 +--
data/command-stubs/list-harddrives-stub | 2 +-
dracut/parse-kickstart | 2 +-
dracut/python-deps | 10 +--
pyanaconda/geoloc.py | 26 ++++----
pyanaconda/kickstart.py | 4 +-
pyanaconda/nm.py | 82 ++++++++++++------------
pyanaconda/packaging/__init__.py | 14 ++--
pyanaconda/rescue.py | 2 +-
pyanaconda/ui/gui/tools/run-spoke.py | 16 ++---
pyanaconda/ui/tui/simpleline/base.py | 14 ++--
pyanaconda/ui/tui/simpleline/widgets.py | 6 +-
pyanaconda/ui/tui/spokes/__init__.py | 4 +-
pyanaconda/ui/tui/spokes/askvnc.py | 10 +--
pyanaconda/ui/tui/spokes/storage.py | 4 +-
pyanaconda/ui/tui/tools/run-text-spoke.py | 18 +++---
scripts/githooks/pre-commit | 6 +-
scripts/makebumpver | 38 +++++------
tests/glade/pw_visibility/check_pw_visibility.py | 8 +--
tests/storage/cases/__init__.py | 12 ++--
20 files changed, 144 insertions(+), 144 deletions(-)
diff --git a/anaconda b/anaconda
index 4ccbd00..7499bc3 100755
--- a/anaconda
+++ b/anaconda
@@ -63,8 +63,8 @@ def exitHandler(rebootData, storage, exitCode=None):
if "nokill" in flags.cmdline:
iutil.vtActivate(1)
- print "anaconda halting due to nokill flag."
- print "The system will be rebooted when you press Ctrl-Alt-Delete."
+ print("anaconda halting due to nokill flag.")
+ print("The system will be rebooted when you press Ctrl-Alt-Delete.")
while True:
time.sleep(10000)
@@ -750,7 +750,7 @@ if __name__ == "__main__":
if ("--help" in sys.argv) or ("-h" in sys.argv):
parseArguments()
- print "Starting installer, one moment..."
+ print("Starting installer, one moment...")
# Allow a file to be loaded as early as possible
try:
@@ -843,9 +843,9 @@ if __name__ == "__main__":
verdesc = "%s for %s %s" % (getAnacondaVersion(),
product.productName, product.productVersion)
if product.isFinal:
- print "anaconda %s started." % verdesc
+ print("anaconda %s started." % verdesc)
else:
- print "anaconda %s (pre-release) started." % verdesc
+ print("anaconda %s (pre-release) started." % verdesc)
from pyanaconda.anaconda import Anaconda
anaconda = Anaconda()
diff --git a/data/command-stubs/list-harddrives-stub b/data/command-stubs/list-harddrives-stub
index 01c0931..ae5e6b9 100755
--- a/data/command-stubs/list-harddrives-stub
+++ b/data/command-stubs/list-harddrives-stub
@@ -35,7 +35,7 @@ def main(argv):
lst = list(lst)
lst.sort()
for dev, size in lst:
- print dev, size
+ print(dev, size)
if __name__ == "__main__":
main(sys.argv)
diff --git a/dracut/parse-kickstart b/dracut/parse-kickstart
index c2eaca9..6659d1e 100755
--- a/dracut/parse-kickstart
+++ b/dracut/parse-kickstart
@@ -493,4 +493,4 @@ if __name__ == '__main__':
for path in sys.argv[1:]:
outfile, output = process_kickstart(path)
for line in filter(None, output):
- print line
+ print(line)
diff --git a/dracut/python-deps b/dracut/python-deps
index a2dabca..e626ff4 100755
--- a/dracut/python-deps
+++ b/dracut/python-deps
@@ -46,11 +46,11 @@ for script in sys.argv[1:]:
mods.append(moddir)
# Include some bits that the python install itself needs
-print get_makefile_filename()
-print get_config_h_filename()
-print os.path.join(libdir,'site.py')
-print os.path.join(libdir,'sysconfig.py')
+print(get_makefile_filename())
+print(get_config_h_filename())
+print(os.path.join(libdir,'site.py'))
+print(os.path.join(libdir,'sysconfig.py'))
# And print the list of deps.
for d in deps:
- print d
+ print(d)
diff --git a/pyanaconda/geoloc.py b/pyanaconda/geoloc.py
index 76771ff..7b8dc0d 100644
--- a/pyanaconda/geoloc.py
+++ b/pyanaconda/geoloc.py
@@ -863,30 +863,30 @@ class WiFiAccessPoint(object):
"(signal strength): %d" % (self.bssid, self.ssid, self.rssi)
if __name__ == "__main__":
- print "GeoIP directly started"
+ print("GeoIP directly started")
- print "trying the default backend"
+ print("trying the default backend")
location_info = LocationInfo()
location_info.refresh()
- print " provider used: %s" % location_info._provider
- print " territory code: %s" % location_info.get_territory_code()
+ print(" provider used: %s" % location_info._provider)
+ print(" territory code: %s" % location_info.get_territory_code())
- print "trying the Fedora GeoIP backend"
+ print("trying the Fedora GeoIP backend")
location_info = LocationInfo(provider_id=
constants.GEOLOC_PROVIDER_FEDORA_GEOIP)
location_info.refresh()
- print " provider used: %s" % location_info._provider
- print " territory code: %s" % location_info.get_territory_code()
+ print(" provider used: %s" % location_info._provider)
+ print(" territory code: %s" % location_info.get_territory_code())
- print "trying the Google WiFi location backend"
+ print("trying the Google WiFi location backend")
location_info = LocationInfo(provider_id=
constants.GEOLOC_PROVIDER_GOOGLE_WIFI)
location_info.refresh()
- print " provider used: %s" % location_info._provider
- print " territory code: %s" % location_info.get_territory_code()
+ print(" provider used: %s" % location_info._provider)
+ print(" territory code: %s" % location_info.get_territory_code())
- print "trying the Hostip backend"
+ print("trying the Hostip backend")
location_info = LocationInfo(provider_id=constants.GEOLOC_PROVIDER_HOSTIP)
location_info.refresh()
- print " provider used: %s" % location_info._provider
- print " territory code: %s" % location_info.get_territory_code()
+ print(" provider used: %s" % location_info._provider)
+ print(" territory code: %s" % location_info.get_territory_code())
diff --git a/pyanaconda/kickstart.py b/pyanaconda/kickstart.py
index 781bd90..2435ee5 100644
--- a/pyanaconda/kickstart.py
+++ b/pyanaconda/kickstart.py
@@ -1813,7 +1813,7 @@ def preScriptPass(f):
except KickstartError as e:
# We do not have an interface here yet, so we cannot use our error
# handling callback.
- print e
+ print(e)
sys.exit(1)
# run %pre scripts
@@ -1840,7 +1840,7 @@ def parseKickstart(f):
except KickstartError as e:
# We do not have an interface here yet, so we cannot use our error
# handling callback.
- print e
+ print(e)
sys.exit(1)
return handler
diff --git a/pyanaconda/nm.py b/pyanaconda/nm.py
index 40058f3..09dff20 100644
--- a/pyanaconda/nm.py
+++ b/pyanaconda/nm.py
@@ -978,11 +978,11 @@ def nm_dbus_int_to_ipv4(address):
return socket.inet_ntop(socket.AF_INET, struct.pack('=L', address))
def test():
- print "NM state: %s:" % nm_state()
- print "NM is connected: %s" % nm_is_connected()
+ print("NM state: %s:" % nm_state())
+ print("NM is connected: %s" % nm_is_connected())
- print "Devices: %s" % nm_devices()
- print "Activated devices: %s" % nm_activated_devices()
+ print("Devices: %s" % nm_devices())
+ print("Activated devices: %s" % nm_activated_devices())
wireless_device = ""
@@ -990,108 +990,108 @@ def test():
devs.append("nonexisting")
for devname in devs:
- print devname
+ print(devname)
try:
devtype = nm_device_type(devname)
except UnknownDeviceError as e:
- print " %s" % e
+ print(" %s" % e)
devtype = None
if devtype == NetworkManager.DeviceType.ETHERNET:
- print " type %s" % "ETHERNET"
+ print(" type %s" % "ETHERNET")
elif devtype == NetworkManager.DeviceType.WIFI:
- print " type %s" % "WIFI"
+ print(" type %s" % "WIFI")
wireless_device = devname
try:
- print " Wifi device: %s" % nm_device_type_is_wifi(devname)
+ print(" Wifi device: %s" % nm_device_type_is_wifi(devname))
except UnknownDeviceError as e:
- print " %s" % e
+ print(" %s" % e)
try:
hwaddr = nm_device_hwaddress(devname)
- print " HwAaddress: %s" % hwaddr
+ print(" HwAaddress: %s" % hwaddr)
except ValueError as e:
- print " %s" % e
+ print(" %s" % e)
hwaddr = ""
try:
- print " Carrier: %s" % nm_device_carrier(devname)
+ print(" Carrier: %s" % nm_device_carrier(devname))
except ValueError as e:
- print " %s" % e
+ print(" %s" % e)
try:
- print " IP4 config: %s" % nm_device_ip_config(devname)
- print " IP6 config: %s" % nm_device_ip_config(devname, version=6)
- print " IP4 addrs: %s" % nm_device_ip_addresses(devname)
- print " IP6 addrs: %s" % nm_device_ip_addresses(devname, version=6)
- print " Udi: %s" % nm_device_property(devname, "Udi")
+ print(" IP4 config: %s" % nm_device_ip_config(devname))
+ print(" IP6 config: %s" % nm_device_ip_config(devname, version=6))
+ print(" IP4 addrs: %s" % nm_device_ip_addresses(devname))
+ print(" IP6 addrs: %s" % nm_device_ip_addresses(devname, version=6))
+ print(" Udi: %s" % nm_device_property(devname, "Udi"))
except UnknownDeviceError as e:
- print " %s" % e
+ print(" %s" % e)
if devname in nm_devices():
try:
- print " Nonexisting: %s" % nm_device_property(devname, "Nonexisting")
+ print(" Nonexisting: %s" % nm_device_property(devname, "Nonexisting"))
except PropertyNotFoundError as e:
- print " %s" % e
+ print(" %s" % e)
try:
- print " Nonexisting: %s" % nm_device_property(devname, "Nonexisting")
+ print(" Nonexisting: %s" % nm_device_property(devname, "Nonexisting"))
except ValueError as e:
- print " %s" % e
+ print(" %s" % e)
try:
- print " Settings: %s" % _device_settings(devname)
+ print(" Settings: %s" % _device_settings(devname))
except UnknownDeviceError as e:
- print " %s" % e
+ print(" %s" % e)
try:
- print " Settings for hwaddr %s: %s" % (hwaddr, _settings_for_hwaddr(hwaddr))
+ print(" Settings for hwaddr %s: %s" % (hwaddr, _settings_for_hwaddr(hwaddr)))
except UnknownDeviceError as e:
- print " %s" % e
+ print(" %s" % e)
try:
- print " Setting value %s %s: %s" % ("ipv6", "method", nm_device_setting_value(devname, "ipv6", "method"))
+ print(" Setting value %s %s: %s" % ("ipv6", "method", nm_device_setting_value(devname, "ipv6", "method")))
except ValueError as e:
- print " %s" % e
+ print(" %s" % e)
try:
- print " Setting value %s %s: %s" % ("ipv7", "method", nm_device_setting_value(devname, "ipv7", "method"))
+ print(" Setting value %s %s: %s" % ("ipv7", "method", nm_device_setting_value(devname, "ipv7", "method")))
except ValueError as e:
- print " %s" % e
+ print(" %s" % e)
ssid = "Red Hat Guest"
- print "Settings for AP %s: %s" % (ssid, _settings_for_ap(ssid))
+ print("Settings for AP %s: %s" % (ssid, _settings_for_ap(ssid)))
ssid = "nonexisting"
- print "Settings for AP %s: %s" % (ssid, _settings_for_ap(ssid))
+ print("Settings for AP %s: %s" % (ssid, _settings_for_ap(ssid)))
devname = devs[0]
key1 = "connection"
key2 = "autoconnect"
original_value = nm_device_setting_value(devname, key1, key2)
- print "Value of setting %s %s: %s" % (key1, key2, original_value)
+ print("Value of setting %s %s: %s" % (key1, key2, original_value))
# None means default in this case, which is true
if original_value in (None, True):
new_value = False
else:
new_value = True
- print "Updating to %s" % new_value
+ print("Updating to %s" % new_value)
nm_update_settings_of_device(devname, [[key1, key2, new_value, None]])
- print "Value of setting %s %s: %s" % (key1, key2, nm_device_setting_value(devname, key1, key2))
+ print("Value of setting %s %s: %s" % (key1, key2, nm_device_setting_value(devname, key1, key2)))
nm_update_settings_of_device(devname, [[key1, key2, original_value, None]])
- print "Value of setting %s %s: %s" % (key1, key2, nm_device_setting_value(devname, key1, key2))
+ print("Value of setting %s %s: %s" % (key1, key2, nm_device_setting_value(devname, key1, key2)))
nm_update_settings_of_device(devname, [[key1, key2, original_value, "b"]])
- print "Value of setting %s %s: %s" % (key1, key2, nm_device_setting_value(devname, key1, key2))
+ print("Value of setting %s %s: %s" % (key1, key2, nm_device_setting_value(devname, key1, key2)))
nm_update_settings_of_device(devname, [[key1, "nonexisting", new_value, None]])
nm_update_settings_of_device(devname, [["nonexisting", "nonexisting", new_value, None]])
try:
nm_update_settings_of_device("nonexixting", [[key1, key2, new_value, None]])
except UnknownDeviceError as e:
- print "%s" % e
+ print("%s" % e)
if wireless_device:
try:
nm_update_settings_of_device(wireless_device, [[key1, key2, new_value, None]])
except SettingsNotFoundError as e:
- print "%s" % e
+ print("%s" % e)
#nm_update_settings_of_device(devname, [["connection", "id", "test", None]])
#nm_update_settings_of_device(devname, [["connection", "timestamp", 11111111, None]])
diff --git a/pyanaconda/packaging/__init__.py b/pyanaconda/packaging/__init__.py
index 725319b..9c9b7a5 100644
--- a/pyanaconda/packaging/__init__.py
+++ b/pyanaconda/packaging/__init__.py
@@ -27,7 +27,7 @@
- document all methods
"""
-
+from __future__ import print_function
import os, sys
from urlgrabber.grabber import URLGrabber
from urlgrabber.grabber import URLGrabError
@@ -1049,21 +1049,21 @@ def show_groups(payload):
import pprint
- print "==== DESKTOPS ===="
+ print("==== DESKTOPS ====")
pprint.pprint(desktops)
- print "==== ADDONS ===="
+ print("==== ADDONS ====")
pprint.pprint(addons)
- print payload.groups
+ print(payload.groups)
def print_txmbrs(payload, f=None):
if f is None:
f = sys.stdout
- print >> f, "###########"
+ print("###########", file=f)
for txmbr in payload._yum.tsInfo.getMembers():
- print >> f, txmbr
- print >> f, "###########"
+ print(txmbr, file=f)
+ print("###########", file=f)
def write_txmbrs(payload, filename):
if os.path.exists(filename):
diff --git a/pyanaconda/rescue.py b/pyanaconda/rescue.py
index 14f0ea6..63bc0c1 100644
--- a/pyanaconda/rescue.py
+++ b/pyanaconda/rescue.py
@@ -177,7 +177,7 @@ def runShell(screen = None, msg=""):
print
if msg:
- print (msg)
+ print(msg)
if flags.imageInstall:
print(_("Run %s to unmount the system when you are finished.")
diff --git a/pyanaconda/ui/gui/tools/run-spoke.py b/pyanaconda/ui/gui/tools/run-spoke.py
index 6ac3b75..10a8923 100755
--- a/pyanaconda/ui/gui/tools/run-spoke.py
+++ b/pyanaconda/ui/gui/tools/run-spoke.py
@@ -16,7 +16,7 @@ import os.path
# Check command line arguments
if len(sys.argv)<2:
- print "Usage: $0 <spoke module name> [<spoke widget class>]"
+ print("Usage: $0 <spoke module name> [<spoke widget class>]")
sys.exit(1)
# This is a hack to make sure the AnacondaWidgets library gets loaded
@@ -54,7 +54,7 @@ elif os.path.basename(sys.argv[0]) == "run-hub.py":
spokeText = "hub"
SpokeText = "Hub"
else:
- print "You have to run this command as run-spoke.py or run-hub.py."
+ print("You have to run this command as run-spoke.py or run-hub.py.")
sys.exit(1)
# Set default spoke class
@@ -82,11 +82,11 @@ if not spokeClass:
try:
spokeClass = getattr(spokeModule, spokeClassName)
except KeyError:
- print "%s %s could not be found in %s" % (SpokeText, spokeClassName, spokeModuleName)
+ print("%s %s could not be found in %s" % (SpokeText, spokeClassName, spokeModuleName))
sys.exit(1)
-print "Running %s %s from %s" % (spokeText, spokeClass, spokeModule)
+print("Running %s %s from %s" % (spokeText, spokeClass, spokeModule))
ksdata = makeVersion()
storage = Blivet(ksdata=ksdata)
@@ -114,7 +114,7 @@ if hasattr(spoke, "set_path"):
spoke.initialize()
if not spoke.showable:
- print "This %s is not showable, but I'll continue anyway." % spokeText
+ print("This %s is not showable, but I'll continue anyway." % spokeText)
spoke.refresh()
spoke.window.set_beta(True)
@@ -124,7 +124,7 @@ spoke.window.show_all()
Gtk.main()
if hasattr(spoke, "status"):
- print "%s status:\n%s\n" % (SpokeText, spoke.status)
+ print("%s status:\n%s\n" % (SpokeText, spoke.status))
if hasattr(spoke, "completed"):
- print "%s completed:\n%s\n" % (SpokeText, spoke.completed)
-print "%s kickstart fragment:\n%s" % (SpokeText, ksdata)
+ print("%s completed:\n%s\n" % (SpokeText, spoke.completed))
+print("%s kickstart fragment:\n%s" % (SpokeText, ksdata))
diff --git a/pyanaconda/ui/tui/simpleline/base.py b/pyanaconda/ui/tui/simpleline/base.py
index eae5c48..0ae0f57 100644
--- a/pyanaconda/ui/tui/simpleline/base.py
+++ b/pyanaconda/ui/tui/simpleline/base.py
@@ -322,7 +322,7 @@ class App(object):
# if redraw is needed, separate the content on the screen from the
# stuff we are about to display now
if self._redraw:
- print self._spacer
+ print(self._spacer)
try:
# draw the screen if redraw is needed or the screen changed
@@ -550,7 +550,7 @@ class UIScreen(object):
if num_lines < self._screen_height - 2:
# widget plus prompt are shorter than screen height, just print the widget
- print u"\n".join(lines)
+ print(u"\n".join(lines))
return
# long widget, print it in steps and prompt user to continue
@@ -560,12 +560,12 @@ class UIScreen(object):
# enough space to print the rest of the widget plus regular
# prompt (2 lines)
for line in lines[pos:]:
- print line
+ print(line)
pos += self._screen_height - 1
else:
# print part with a prompt to continue
for line in lines[pos:(pos + self._screen_height - 2)]:
- print line
+ print(line)
self._app.raw_input(_("Press ENTER to continue"))
pos += self._screen_height - 1
@@ -579,10 +579,10 @@ class UIScreen(object):
if isinstance(w, Widget):
self._print_long_widget(w)
elif type(w) == str:
- print w.decode("utf-8")
+ print(w.decode("utf-8"))
else:
# not a widget, just print its unicode representation
- print unicode(w)
+ print(unicode(w))
show = show_all
def hide(self):
@@ -825,7 +825,7 @@ class Widget(object):
if __name__ == "__main__":
class HelloWorld(UIScreen):
def show(self, args = None):
- print """Hello World\nquit by typing 'quit'"""
+ print("""Hello World\nquit by typing 'quit'""")
return True
a = App("Hello World")
diff --git a/pyanaconda/ui/tui/simpleline/widgets.py b/pyanaconda/ui/tui/simpleline/widgets.py
index fef1d01..b3d8508 100644
--- a/pyanaconda/ui/tui/simpleline/widgets.py
+++ b/pyanaconda/ui/tui/simpleline/widgets.py
@@ -205,10 +205,10 @@ if __name__ == "__main__":
c = ColumnWidget([(15, [t1, t2, t3]), (10, [t4, t5])], spacing = 1)
c.render(80)
- print u"\n".join(c.get_lines())
+ print(u"\n".join(c.get_lines()))
- print 80*"-"
+ print(80*"-")
c = ColumnWidget([(20, [t1, t2, t3]), (25, [t4, t5]), (15, [t1, t2, t3])], spacing = 3)
c.render(80)
- print u"\n".join(c.get_lines())
+ print(u"\n".join(c.get_lines()))
diff --git a/pyanaconda/ui/tui/spokes/__init__.py b/pyanaconda/ui/tui/spokes/__init__.py
index a1d7f9a..f908295 100644
--- a/pyanaconda/ui/tui/spokes/__init__.py
+++ b/pyanaconda/ui/tui/spokes/__init__.py
@@ -161,8 +161,8 @@ class EditTUIDialog(NormalTUISpoke):
self.close()
return True
else:
- print _("You have provided an invalid username: %s\n"
- "Do not use spaces or capital letters.\n") % key
+ print(_("You have provided an invalid username: %s\n"
+ "Do not use spaces or capital letters.\n") % key)
return NormalTUISpoke.input(self, entry, key)
class OneShotEditTUIDialog(EditTUIDialog):
diff --git a/pyanaconda/ui/tui/spokes/askvnc.py b/pyanaconda/ui/tui/spokes/askvnc.py
index dc9273e..d3835a0 100644
--- a/pyanaconda/ui/tui/spokes/askvnc.py
+++ b/pyanaconda/ui/tui/spokes/askvnc.py
@@ -138,15 +138,15 @@ class VNCPassSpoke(NormalTUISpoke):
p2 = getpass.getpass(_("Password (confirm): "))
if p1 != p2:
- print _("Passwords do not match!")
+ print(_("Passwords do not match!"))
return None
elif 0 < len(p1) < 6:
- print _("The password must be at least "
- "six characters long.")
+ print(_("The password must be at least "
+ "six characters long."))
return None
elif len(p1) > 8:
- print _("The password cannot be more than "
- "eight characters long.")
+ print(_("The password cannot be more than "
+ "eight characters long."))
return None
else:
self._password = p1
diff --git a/pyanaconda/ui/tui/spokes/storage.py b/pyanaconda/ui/tui/spokes/storage.py
index 2fdebe9..f0d38d5 100644
--- a/pyanaconda/ui/tui/spokes/storage.py
+++ b/pyanaconda/ui/tui/spokes/storage.py
@@ -374,7 +374,7 @@ class StorageSpoke(NormalTUISpoke):
doKickstartStorage(self.storage, self.data, self.instclass)
except (StorageError, KickstartValueError) as e:
log.error("storage configuration failed: %s", e)
- print _("storage configuration failed: %s") % e
+ print(_("storage configuration failed: %s") % e)
self.errors = [str(e)]
self.data.bootloader.bootDrive = ""
self.data.clearpart.type = CLEARPART_TYPE_ALL
@@ -387,7 +387,7 @@ class StorageSpoke(NormalTUISpoke):
self._ready = True
except BootLoaderError as e:
log.error("BootLoader setup failed: %s", e)
- print _("storage configuration failed: %s") % e
+ print(_("storage configuration failed: %s") % e)
self.errors = [str(e)]
self.data.bootloader.bootDrive = ""
self._ready = True
diff --git a/pyanaconda/ui/tui/tools/run-text-spoke.py b/pyanaconda/ui/tui/tools/run-text-spoke.py
index 09c91a3..c503cdc 100755
--- a/pyanaconda/ui/tui/tools/run-text-spoke.py
+++ b/pyanaconda/ui/tui/tools/run-text-spoke.py
@@ -5,7 +5,7 @@ import os.path
# Check command line arguments
if len(sys.argv)<2:
- print "Usage: $0 <spoke module name> [<spoke widget class>]"
+ print("Usage: $0 <spoke module name> [<spoke widget class>]")
sys.exit(1)
# Logging always needs to be set up first thing, or there'll be tracebacks.
@@ -42,7 +42,7 @@ elif os.path.basename(sys.argv[0]) == "run-text-hub.py":
spokeText = "hub"
SpokeText = "Hub"
else:
- print "You have to run this command as run-spoke.py or run-hub.py."
+ print("You have to run this command as run-spoke.py or run-hub.py.")
sys.exit(1)
# Set default spoke class
@@ -61,7 +61,7 @@ except IndexError:
spokeModule = sys.modules[spokeModuleName]
for k,v in vars(spokeModule).iteritems():
try:
- print k,v
+ print(k,v)
if issubclass(v, spokeBaseClass) and v != spokeBaseClass:
spokeClassName = k
spokeClass = v
@@ -72,11 +72,11 @@ if not spokeClass:
try:
spokeClass = getattr(spokeModule, spokeClassName)
except KeyError:
- print "%s %s could not be found in %s" % (SpokeText, spokeClassName, spokeModuleName)
+ print("%s %s could not be found in %s" % (SpokeText, spokeClassName, spokeModuleName))
sys.exit(1)
-print "Running %s %s from %s" % (spokeText, spokeClass, spokeModule)
+print("Running %s %s from %s" % (spokeText, spokeClass, spokeModule))
ksdata = makeVersion()
storage = Blivet(ksdata=ksdata)
@@ -91,13 +91,13 @@ payload.install_log = sys.stdout
spoke = spokeClass(app, ksdata, storage, payload, instclass)
if not spoke.showable:
- print "This %s is not showable, but I'll continue anyway." % spokeText
+ print("This %s is not showable, but I'll continue anyway." % spokeText)
app.schedule_screen(spoke)
app.run()
if hasattr(spoke, "status"):
- print "%s status:\n%s\n" % (SpokeText, spoke.status)
+ print("%s status:\n%s\n" % (SpokeText, spoke.status))
if hasattr(spoke, "completed"):
- print "%s completed:\n%s\n" % (SpokeText, spoke.completed)
-print "%s kickstart fragment:\n%s" % (SpokeText, ksdata)
+ print("%s completed:\n%s\n" % (SpokeText, spoke.completed))
+print("%s kickstart fragment:\n%s" % (SpokeText, ksdata))
diff --git a/scripts/githooks/pre-commit b/scripts/githooks/pre-commit
index 5704b28..c8832ef 100755
--- a/scripts/githooks/pre-commit
+++ b/scripts/githooks/pre-commit
@@ -25,7 +25,7 @@ def is_python(filename):
OTHER_MODULES_PATH = ".:../blivet/:../pykickstart/"
if "NOPYLINT" in os.environ:
- print "Skipping pre-commit pylint run"
+ print("Skipping pre-commit pylint run")
sys.exit(0)
# run pylint on all the python files changed by this commit
@@ -63,11 +63,11 @@ if not pylint_files:
env = os.environ.copy()
env["PYTHONPATH"] = OTHER_MODULES_PATH
-print "Running pylint on %s" % " ".join(pylint_files)
+print("Running pylint on %s" % " ".join(pylint_files))
try:
check_output(["./tests/pylint/runpylint.sh"] + pylint_files, env=env)
except CalledProcessError as e:
- print e.output
+ print(e.output)
sys.exit(1)
sys.exit(0)
diff --git a/scripts/makebumpver b/scripts/makebumpver
index 7e25178..1d56129 100755
--- a/scripts/makebumpver
+++ b/scripts/makebumpver
@@ -166,47 +166,47 @@ class MakeBumpVer:
bzentry = self._queryBug(bug)
if not bzentry:
- print "*** Bugzilla query for %s failed.\n" % bug
+ print("*** Bugzilla query for %s failed.\n" % bug)
return False
if bzentry.product.startswith('Red Hat Enterprise Linux'):
return True
else:
- print "*** Bug %s is not a RHEL bug." % bug
- print "*** Commit: %s" % commit
- print "*** %s\n" % summary
+ print("*** Bug %s is not a RHEL bug." % bug)
+ print("*** Commit: %s" % commit)
+ print("*** %s\n" % summary)
return False
def _isRHELBugInCorrectState(self, bug, commit, summary):
bzentry = self._queryBug(bug)
if not bzentry:
- print "*** Bugzilla query for %s failed.\n" % bug
+ print("*** Bugzilla query for %s failed.\n" % bug)
return False
if bzentry.bug_status in ['MODIFIED', 'ON_QA']:
return True
else:
- print "*** Bug %s is not in MODIFIED or ON_QA." % bug
- print "*** Commit: %s" % commit
- print "*** %s\n" % summary
+ print("*** Bug %s is not in MODIFIED or ON_QA." % bug)
+ print("*** Commit: %s" % commit)
+ print("*** %s\n" % summary)
return False
def _isRHELBugFixedInVersion(self, bug, commit, summary, fixedIn):
bzentry = self._queryBug(bug)
if not bzentry:
- print "*** Bugzilla query for %s failed.\n" % bug
+ print("*** Bugzilla query for %s failed.\n" % bug)
return False
if bzentry.fixed_in == fixedIn:
return True
else:
- print "*** Bug %s does not have correct Fixed In Version." % bug
- print "*** Found: %s" % bzentry.fixed_in
- print "*** Expected: %s" % fixedIn
- print "*** Commit: %s" % commit
- print "*** %s\n" % summary
+ print("*** Bug %s does not have correct Fixed In Version." % bug)
+ print("*** Found: %s" % bzentry.fixed_in)
+ print("*** Expected: %s" % fixedIn)
+ print("*** Commit: %s" % commit)
+ print("*** %s\n" % summary)
return False
def _isRHELBugAcked(self, bug, commit, summary):
@@ -221,9 +221,9 @@ class MakeBumpVer:
if re.match(ack_pattern, f['name']) and f['status'] == '+':
return True
- print "*** Bug %s does not have ACK" % bug
- print "*** Commit: %s" % commit
- print "*** %s\n" % summary
+ print("*** Bug %s does not have ACK" % bug)
+ print("*** Commit: %s" % commit)
+ print("*** %s\n" % summary)
return False
def _rpmLog(self, fixedIn):
@@ -346,12 +346,12 @@ class MakeBumpVer:
bad = True
elif valid and action == 'Related' and \
self._isRHELBugAcked(ckbug, commit, summary):
- print "*** Bug %s Related commit %s is allowed\n" % (bug, commit)
+ print("*** Bug %s Related commit %s is allowed\n" % (bug, commit))
# Related bugs only need to be valid and have an ack
bad = False
if len(rhbz) == 0:
- print "*** No bugs referenced in commit %s\n" % commit
+ print("*** No bugs referenced in commit %s\n" % commit)
bad = True
rpm_log.append((summary.strip(), list(rhbz)))
diff --git a/tests/glade/pw_visibility/check_pw_visibility.py b/tests/glade/pw_visibility/check_pw_visibility.py
index 33fea2c..0e9a99f 100755
--- a/tests/glade/pw_visibility/check_pw_visibility.py
+++ b/tests/glade/pw_visibility/check_pw_visibility.py
@@ -44,20 +44,20 @@ def check_glade_file(glade_file_path):
# no entry should have visibility specified multiple times
if len(visibility_props) > 1:
- print "Visibility specified multiple times for the entry %s (%s)" % (entry_id, fpath)
+ print("Visibility specified multiple times for the entry %s (%s)" % (entry_id, fpath))
succ = False
# password entry should have visibility set to False
if any(ind in entry_id.lower() for ind in PW_ID_INDICATORS):
if not visibility_props:
- print "Visibility not specified for the password entry %s (%s)" % (entry_id, fpath)
+ print("Visibility not specified for the password entry %s (%s)" % (entry_id, fpath))
succ = False
elif visibility_props[0].text.strip() != "False":
- print "Visibility not set properly for the password entry %s (%s)" % (entry_id, fpath)
+ print("Visibility not set properly for the password entry %s (%s)" % (entry_id, fpath))
succ = False
# only password entries should have the visibility set to False
elif visibility_props and visibility_props[0].text.strip() == "False":
- print "Non-password entry %s (%s) has the visibility set to False (bad id?)" % (entry_id, fpath)
+ print("Non-password entry %s (%s) has the visibility set to False (bad id?)" % (entry_id, fpath))
succ = False
return succ
diff --git a/tests/storage/cases/__init__.py b/tests/storage/cases/__init__.py
index 00e0fed..87882a9 100644
--- a/tests/storage/cases/__init__.py
+++ b/tests/storage/cases/__init__.py
@@ -70,7 +70,7 @@ class TestCase(object):
failures = 0
if self.platforms and blivet.platform.getPlatform().__class__.__name__ not in self.platforms:
- print "Test %s skipped: not valid for this platform" % self.name
+ print("Test %s skipped: not valid for this platform" % self.name)
return
for c in self.components:
@@ -79,16 +79,16 @@ class TestCase(object):
try:
obj._run()
except FailedTest as e:
- print "Test %s-%s failed:\n\tExpected: %s\n\tGot: %s" % (self.name, obj.name, e.expected, e.got)
+ print("Test %s-%s failed:\n\tExpected: %s\n\tGot: %s" % (self.name, obj.name, e.expected, e.got))
failures += 1
continue
- print "Test %s-%s succeeded" % (self.name, obj.name)
+ print("Test %s-%s succeeded" % (self.name, obj.name))
successes += 1
- print "Test %s summary:" % self.name
- print "\tSuccesses: %s" % successes
- print "\tFailures: %s" % failures
+ print("Test %s summary:" % self.name)
+ print("\tSuccesses: %s" % successes)
+ print("\tFailures: %s" % failures)
return failures
class TestCaseComponent(object):
--
1.9.0
10 years
[PATCH] Fix the modify software tooltip on the installation options dialogs.
by Chris Lumens
The tooltip indicating metadata was still being downloaded was not displaying.
This is because the link in the label's markup had no title and GTK really
wants a title. So, give it one and remove the tooltip from the rest of the
label.
While I was at it, I changed _add_modify_watcher to just take a widget that
we already have instead of a name, and removed a pointless show_all.
---
pyanaconda/ui/gui/spokes/storage.py | 18 ++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)
diff --git a/pyanaconda/ui/gui/spokes/storage.py b/pyanaconda/ui/gui/spokes/storage.py
index 118f471..61826ef 100644
--- a/pyanaconda/ui/gui/spokes/storage.py
+++ b/pyanaconda/ui/gui/spokes/storage.py
@@ -109,11 +109,13 @@ class InstallOptionsDialogBase(GUIObject):
return True
def _get_sw_needs_text(self, required_space, auto_swap):
- sw_text = (_("Your current <a href=\"\"><b>%(product)s</b> software "
+ tooltip = _("Please wait... software metadata still loading.")
+ sw_text = (_("Your current <a href=\"\" title=\"%(tooltip)s\"><b>%(product)s</b> software "
"selection</a> requires <b>%(total)s</b> of available "
"space, including <b>%(software)s</b> for software and "
"<b>%(swap)s</b> for swap space.")
- % {"product": escape_markup(productName),
+ % {"tooltip": escape_markup(tooltip),
+ "product": escape_markup(productName),
"total": escape_markup(str(required_space + auto_swap)),
"software": escape_markup(str(required_space)),
"swap": escape_markup(str(auto_swap))})
@@ -131,20 +133,18 @@ class InstallOptionsDialogBase(GUIObject):
def _check_for_storage_thread(self, button):
if self._software_is_ready():
button.set_has_tooltip(False)
- button.show_all()
# False means this function should never be called again.
return False
else:
return True
- def _add_modify_watcher(self, widgetName):
+ def _add_modify_watcher(self, widget):
# If the payload fetching thread is still running, the user can't go to
# modify the software selection screen. Thus, we have to set the button
# insensitive and wait until software selection is ready to go.
- modify_widget = self.builder.get_object(widgetName)
if not self._software_is_ready():
- GLib.timeout_add_seconds(1, self._check_for_storage_thread, modify_widget)
+ GLib.timeout_add_seconds(1, self._check_for_storage_thread, widget)
class NeedSpaceDialog(InstallOptionsDialogBase):
builderObjects = ["need_space_dialog"]
@@ -165,7 +165,6 @@ class NeedSpaceDialog(InstallOptionsDialogBase):
"amounts of free space:") % sw_text
label = self.builder.get_object("need_space_desc_label")
label.set_markup(label_text)
- label.set_tooltip_text(_("Please wait... software metadata still loading."))
label.connect("activate-link", self._modify_sw_link_clicked)
self._set_free_space_labels(disk_free, fs_free)
@@ -177,7 +176,7 @@ class NeedSpaceDialog(InstallOptionsDialogBase):
"interface.") % escape_markup(productName)
self.builder.get_object("need_space_options_label").set_markup(label_text)
- self._add_modify_watcher("need_space_desc_label")
+ self._add_modify_watcher(label)
class NoSpaceDialog(InstallOptionsDialogBase):
builderObjects = ["no_space_dialog"]
@@ -201,7 +200,6 @@ class NoSpaceDialog(InstallOptionsDialogBase):
"product": escape_markup(productName)})
label = self.builder.get_object("no_space_desc_label")
label.set_markup(label_text)
- label.set_tooltip_text(_("Please wait... software metadata still loading."))
label.connect("activate-link", self._modify_sw_link_clicked)
self._set_free_space_labels(disk_free, fs_free)
@@ -215,7 +213,7 @@ class NoSpaceDialog(InstallOptionsDialogBase):
{"productName": escape_markup(productName)}
self.builder.get_object("no_space_options_label").set_markup(label_text)
- self._add_modify_watcher("no_space_desc_label")
+ self._add_modify_watcher(label)
class StorageSpoke(NormalSpoke, StorageChecker):
builderObjects = ["storageWindow", "addSpecializedImage"]
--
1.9.0
10 years
[master][PATCH] Better visually distinguish TUI spokes states
by Vratislav Podzimek
If a TUI spoke is mandatory and completed, it's status "icon" should be [!], if
it is not mandatory and is completed, it should be [x] and if it is not
mandatory and not completed, it should be [ ].
Otherwise e.g. the User spoke looks like completed even when just root password
is set (which makes the User spoke not mandatory) which might be confusing.
Signed-off-by: Vratislav Podzimek <vpodzime(a)redhat.com>
---
pyanaconda/ui/tui/spokes/__init__.py | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/pyanaconda/ui/tui/spokes/__init__.py b/pyanaconda/ui/tui/spokes/__init__.py
index a1d7f9a..76c1dfa 100644
--- a/pyanaconda/ui/tui/spokes/__init__.py
+++ b/pyanaconda/ui/tui/spokes/__init__.py
@@ -77,8 +77,10 @@ class TUISpoke(TUIObject, tui.Widget, Spoke):
if self.mandatory and not self.completed:
key = "!"
- else:
+ elif self.completed:
key = "x"
+ else:
+ key = " "
# always set completed = True here; otherwise key value won't be
# displayed if completed (spoke value from above) is False
--
1.9.0
10 years
[rhel6-branch] Rm device from lvm reject filter if in action list. (#885755)
by Samantha N. Bueno
(Re-worked the patch for #885755 based on irc discussion with dlehman.
Still waiting on reporter to let me know if this works; didn't think
it'd be this long.)
Modelled after a blivet patch from bcl. Check for partitions in the
lvm filter which depend on devices being operated on. If a device is
in the action list it is removed from the lvm reject filter.
Resolves: rhbz#885755
---
storage/devicelibs/lvm.py | 10 ++++++++++
storage/devicetree.py | 4 ++++
2 files changed, 14 insertions(+)
diff --git a/storage/devicelibs/lvm.py b/storage/devicelibs/lvm.py
index c4ad88d..f9c0c51 100644
--- a/storage/devicelibs/lvm.py
+++ b/storage/devicelibs/lvm.py
@@ -100,6 +100,16 @@ def lvm_cc_addFilterRejectRegexp(regexp):
# compoes config once more.
_composeConfig()
+def lvm_cc_removeFilterRejectRegexp(regexp):
+ """ Remove a regular expression from the --config string. """
+ global config_args_data
+ log.debug("lvm filter: removing %s from the reject list", regexp)
+ try:
+ config_args_data["filterRejects"].remove(regexp)
+ except ValueError:
+ log.debug("%s wasn't in the reject list", regexp)
+ return
+
def lvm_cc_resetFilter():
global config_args, config_args_data
config_args_data["filterRejects"] = []
diff --git a/storage/devicetree.py b/storage/devicetree.py
index 310f955..53678d1 100644
--- a/storage/devicetree.py
+++ b/storage/devicetree.py
@@ -706,6 +706,10 @@ class DeviceTree(object):
for action in self._actions:
log.debug("action: %s" % action)
+ # Remove lvm filters for devices we are operating on
+ for device in (d for d in self._devices if d.dependsOn(action.device)):
+ lvm.lvm_cc_removeFilterRejectRegexp(device.name)
+
for action in self._actions:
log.info("executing action: %s" % action)
if not dryRun:
--
1.8.3.1
10 years
[blivet 0/2] Validate things for LVM, v3
by David Shea
Changes the isNameValid property from the previous version to a classmethod,
and uses this method during __init__ and in the new name setter.
No changes to the anaconda patch, so I'm not resending it.
David Shea (2):
Use a setter for Device.name as foretold by the prophecy of TODO
Validate device names
blivet/__init__.py | 8 +++-
blivet/devicefactory.py | 14 +++---
blivet/devices.py | 120 +++++++++++++++++++++++++++++++++++++++++-------
tests/devices_test.py | 40 ++++++++++++++++
4 files changed, 156 insertions(+), 26 deletions(-)
--
1.9.0
10 years
[blivet][master][PATCH] Replace print statements with print function calls
by Martin Kolman
The print statement has been dropped in Python 3 and the print function
works in both Python 2 and Python 3. So there is really no reason to not
just use the print function and make Blivet a bit more Python 3
friendly.
Signed-off-by: Martin Kolman <mkolman(a)redhat.com>
---
blivet/tsort.py | 6 +++---
doc/intro.rst | 2 +-
examples/common.py | 4 ++--
scripts/makebumpver | 40 ++++++++++++++++++++--------------------
scripts/pylintcodediff | 4 ++--
5 files changed, 28 insertions(+), 28 deletions(-)
diff --git a/blivet/tsort.py b/blivet/tsort.py
index 4c02e14..183331d 100644
--- a/blivet/tsort.py
+++ b/blivet/tsort.py
@@ -93,11 +93,11 @@ def main():
items = [5, 2, 3, 4, 1]
edges = [(1, 2), (2, 4), (4, 5), (3, 2)]
- print items
- print edges
+ print(items)
+ print(edges)
graph = create_graph(items, edges)
- print tsort(graph)
+ print(tsort(graph))
if __name__ == "__main__":
main()
diff --git a/doc/intro.rst b/doc/intro.rst
index 2f7dc5a..3aefa7d 100644
--- a/doc/intro.rst
+++ b/doc/intro.rst
@@ -75,7 +75,7 @@ Next, scan the system's storage configuration and store it in the tree::
Now, you can do some simple things like listing the devices::
for device in b.devices:
- print device
+ print(device)
To make changes to the configuration you'll schedule actions, but
:class:`~.Blivet` provides some convenience methods to hide the details. Here's an example of removing partition '/dev/sda3'::
diff --git a/examples/common.py b/examples/common.py
index 90c735f..110026f 100644
--- a/examples/common.py
+++ b/examples/common.py
@@ -1,6 +1,6 @@
def print_devices(b):
for device in sorted(b.devices, key=lambda d: len(d.ancestors)):
- print device # this is a blivet.devices.StorageDevice instance
+ print(device) # this is a blivet.devices.StorageDevice instance
- print
+ print()
diff --git a/scripts/makebumpver b/scripts/makebumpver
index b5cb5dd..da0e060 100755
--- a/scripts/makebumpver
+++ b/scripts/makebumpver
@@ -167,47 +167,47 @@ class MakeBumpVer:
bzentry = self._queryBug(bug)
if not bzentry:
- print "*** Bugzilla query for %s failed.\n" % bug
+ print("*** Bugzilla query for %s failed.\n" % bug)
return False
if bzentry.product.startswith('Red Hat Enterprise Linux'):
return True
else:
- print "*** Bug %s is not a RHEL bug." % bug
- print "*** Commit: %s" % commit
- print "*** %s\n" % summary
+ print("*** Bug %s is not a RHEL bug." % bug)
+ print("*** Commit: %s" % commit)
+ print("*** %s\n" % summary)
return False
def _isRHELBugInCorrectState(self, bug, commit, summary):
bzentry = self._queryBug(bug)
if not bzentry:
- print "*** Bugzilla query for %s failed.\n" % bug
+ print("*** Bugzilla query for %s failed.\n" % bug)
return False
if bzentry.bug_status in ['MODIFIED', 'ON_QA']:
return True
else:
- print "*** Bug %s is not in MODIFIED or ON_QA." % bug
- print "*** Commit: %s" % commit
- print "*** %s\n" % summary
+ print("*** Bug %s is not in MODIFIED or ON_QA." % bug)
+ print("*** Commit: %s" % commit)
+ print("*** %s\n" % summary)
return False
def _isRHELBugFixedInVersion(self, bug, commit, summary, fixedIn):
bzentry = self._queryBug(bug)
if not bzentry:
- print "*** Bugzilla query for %s failed.\n" % bug
+ print("*** Bugzilla query for %s failed.\n" % bug)
return False
if bzentry.fixed_in == fixedIn:
return True
else:
- print "*** Bug %s does not have correct Fixed In Version." % bug
- print "*** Found: %s" % bzentry.fixed_in
- print "*** Expected: %s" % fixedIn
- print "*** Commit: %s" % commit
- print "*** %s\n" % summary
+ print("*** Bug %s does not have correct Fixed In Version." % bug)
+ print("*** Found: %s" % bzentry.fixed_in)
+ print("*** Expected: %s" % fixedIn)
+ print("*** Commit: %s" % commit)
+ print("*** %s\n" % summary)
return False
def _isRHELBugAcked(self, bug, commit, summary):
@@ -222,9 +222,9 @@ class MakeBumpVer:
if re.match(ack_pattern, f['name']) and f['status'] == '+':
return True
- print "*** Bug %s does not have ACK" % bug
- print "*** Commit: %s" % commit
- print "*** %s\n" % summary
+ print("*** Bug %s does not have ACK" % bug)
+ print("*** Commit: %s" % commit)
+ print("*** %s\n" % summary)
return False
def _rpmLog(self, fixedIn):
@@ -347,12 +347,12 @@ class MakeBumpVer:
bad = True
elif valid and action == 'Related' and \
self._isRHELBugAcked(ckbug, commit, summary):
- print "*** Bug %s Related commit %s is allowed\n" % (bug, commit)
+ print("*** Bug %s Related commit %s is allowed\n" % (bug, commit))
# Related bugs only need to be valid and have an ack
bad = False
if len(rhbz) == 0:
- print "*** No bugs referenced in commit %s\n" % commit
+ print("*** No bugs referenced in commit %s\n" % commit)
bad = True
rpm_log.append((summary.strip(), list(rhbz)))
@@ -374,7 +374,7 @@ class MakeBumpVer:
if l.find(search) > -1:
break
else:
- print "!!! Failed to replace '%s' with '%s'" % (search, replace)
+ print("!!! Failed to replace '%s' with '%s'" % (search, replace))
sys.exit(1)
lines[i] = re.sub(search, replace, lines[i]) # pylint: disable=undefined-loop-variable
diff --git a/scripts/pylintcodediff b/scripts/pylintcodediff
index 705b014..4e30453 100755
--- a/scripts/pylintcodediff
+++ b/scripts/pylintcodediff
@@ -19,7 +19,7 @@
#
# Author: Anne Mulhern <amulhern(a)redhat.com>
-
+from __future__ import print_function
import argparse
import os
import subprocess
@@ -163,7 +163,7 @@ def main():
reset(commit)
diff_quality(pylint_log)
except RuntimeError as e:
- print >> sys.stderr, "Couldn't complete testing, trying to clean up: %s." % e
+ print("Couldn't complete testing, trying to clean up: %s." % e, file=sys.stderr)
try:
checkout_branch(current_branch, force=True)
--
1.9.0
10 years