[PATCH] Apply action for extended partition creation.
by David Lehman
Normally the action's apply method is called when registering the action,
but the action that creates an extended partition that was not explicitly
requested does not get registered since the device is already be in the
tree by the time the action is instantiated.
---
blivet/devicetree.py | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/blivet/devicetree.py b/blivet/devicetree.py
index 85c4ed0..b22cf47 100644
--- a/blivet/devicetree.py
+++ b/blivet/devicetree.py
@@ -266,7 +266,9 @@ class DeviceTree(object):
device.isExtended and not device.exists:
# don't properly register the action since the device is
# already in the tree
- self._actions.append(ActionCreateDevice(device))
+ action = ActionCreateDevice(device)
+ action.apply()
+ self._actions.append(action)
for action in self._actions:
log.debug("action: %s", action)
--
1.9.0
10 years
[PATCH] Extend format string checks to translated format strings.
by David Shea
This applies the existing pylint format and logging string checks to
translated format and logging strings. The two new warning IDs are not
emitted themselves but are necessary in order to provide an entry point
to the overriden visit_* functions.
---
tests/pylint/intl.py | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 88 insertions(+), 1 deletion(-)
diff --git a/tests/pylint/intl.py b/tests/pylint/intl.py
index c8baaf3..aec3414 100644
--- a/tests/pylint/intl.py
+++ b/tests/pylint/intl.py
@@ -22,11 +22,38 @@
import astroid
from pylint.checkers import BaseChecker
+from pylint.checkers.strings import StringFormatChecker
+from pylint.checkers.logging import LoggingChecker
from pylint.checkers.utils import check_messages
from pylint.interfaces import IAstroidChecker
+from copy import copy
+
translationMethods = ["_", "N_", "P_", "C_", "CN_", "CP_"]
+# Returns a list of the message strings for a given translation method call
+def _get_message_strings(node):
+ msgstrs = []
+
+ if node.func.name in ("_", "N_") and len(node.args) >= 1:
+ if isinstance(node.args[0], astroid.Const):
+ msgstrs.append(node.args[0].value)
+ elif node.func.name in ("C_", "CN_") and len(node.args) >= 2:
+ if isinstance(node.args[1], astroid.Const):
+ msgstrs.append(node.args[1].value)
+ elif node.func.name == "P_" and len(node.args) >= 2:
+ if isinstance(node.args[0], astroid.Const):
+ msgstrs.append(node.args[0].value)
+ if isinstance(node.args[1], astroid.Const):
+ msgstrs.append(node.args[1].value)
+ elif node.func.name == "CP_" and len(node.args) >= 3:
+ if isinstance(node.args[1], astroid.Const):
+ msgstrs.append(node.args[1].value)
+ if isinstance(node.args[2], astroid.Const):
+ msgstrs.append(node.args[2].value)
+
+ return msgstrs
+
class IntlChecker(BaseChecker):
__implements__ = (IAstroidChecker, )
name = "internationalization"
@@ -38,7 +65,7 @@ class IntlChecker(BaseChecker):
"Calling _ at the module or class level results in translations to the wrong language")
}
- @check_messages("W9901")
+ @check_messages("found-percent-in-_")
def visit_binop(self, node):
if node.op != "%":
return
@@ -58,6 +85,66 @@ class IntlChecker(BaseChecker):
if isinstance(node.scope(), astroid.Module) or isinstance(node.scope(), astroid.Class):
self.add_message("W9902", node=node)
+# Extend LoggingChecker to check translated logging strings
+class IntlLoggingChecker(LoggingChecker):
+ __implements__ = (IAstroidChecker,)
+
+ name = 'intl-logging'
+ msgs = {'W9903': ("Fake message for translated E/W120* checks",
+ "translated-log",
+ "This message is not emitted itself, but can be used to control the display of \
+ logging format messages extended for translated strings")
+ }
+
+ options = ()
+
+ @check_messages('translated-log')
+ def visit_callfunc(self, node):
+ if len(node.args) >= 1 and isinstance(node.args[0], astroid.CallFunc) and \
+ getattr(node.args[0].func, "name", "") in translationMethods:
+ for formatstr in _get_message_strings(node.args[0]):
+ # Both the node and the args need to be copied so we don't replace args
+ # on the original node.
+ copynode = copy(node)
+ copyargs = copy(node.args)
+ copyargs[0] = astroid.Const(formatstr)
+ copynode.args = copyargs
+ LoggingChecker.visit_callfunc(self, copynode)
+
+ def __init__(self, *args, **kwargs):
+ LoggingChecker.__init__(self, *args, **kwargs)
+
+ # Just set logging_modules to 'logging', instead of trying to take a parameter
+ # like LoggingChecker
+ self.config.logging_modules = ('logging',)
+
+# Extend StringFormatChecker to check translated format strings
+class IntlStringFormatChecker(StringFormatChecker):
+ __implements__ = (IAstroidChecker,)
+
+ name = 'intl-string'
+ msgs = {'W9904': ("Fake message for translated E/W130* checks",
+ "translated-format",
+ "This message is not emitted itself, but can be used to control the display of \
+ string format messages extended for translated strings")
+ }
+
+ options = ()
+
+ @check_messages('translated-format')
+ def visit_binop(self, node):
+ if node.op != '%':
+ return
+
+ if isinstance(node.left, astroid.CallFunc) and getattr(node.left.func, "name", "") in translationMethods:
+ for formatstr in _get_message_strings(node.left):
+ # Create a copy of the node with just the message string as the format
+ copynode = copy(node)
+ copynode.left = astroid.Const(formatstr)
+ StringFormatChecker.visit_binop(self, copynode)
+
def register(linter):
"""required method to auto register this checker """
linter.register_checker(IntlChecker(linter))
+ linter.register_checker(IntlLoggingChecker(linter))
+ linter.register_checker(IntlStringFormatChecker(linter))
--
1.9.0
10 years
[PATCH] Install specific lohit fonts instead of all of them (#1090390)
by Brian C. Lane
Tamil-Classical, Marathi, Nepali are variant of other lohit fonts.
Lohit Malayalam is not required as we are installing smc-meera-fonts.
---
share/runtime-install.tmpl | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/share/runtime-install.tmpl b/share/runtime-install.tmpl
index 3a87392..50dfd1a 100644
--- a/share/runtime-install.tmpl
+++ b/share/runtime-install.tmpl
@@ -114,7 +114,14 @@ installpkg dejavu-sans-fonts dejavu-sans-mono-fonts
installpkg kacst-farsi-fonts
installpkg kacst-qurn-fonts
installpkg lklug-fonts
-installpkg lohit-*-fonts
+installpkg lohit-assamese-fonts
+installpkg lohit-bengali-fonts
+installpkg lohit-devanagari-fonts
+installpkg lohit-gu*-fonts
+installpkg lohit-kannada-fonts
+installpkg lohit-odia-fonts
+installpkg lohit-tamil-fonts
+installpkg lohit-telugu-font
installpkg madan-fonts
installpkg nhn-nanum-gothic-fonts
installpkg smc-meera-fonts
--
1.9.0
10 years
[PATCH] Extend format string checks to translated format strings.
by David Shea
This applies the existing pylint format and logging string checks to
translated format and logging strings. The two new warning IDs are not
emitted themselves but are necessary in order to provide an entry point
to the overriden visit_* functions.
---
tests/pylint/intl.py | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 71 insertions(+), 1 deletion(-)
diff --git a/tests/pylint/intl.py b/tests/pylint/intl.py
index c8baaf3..dccf9b5 100644
--- a/tests/pylint/intl.py
+++ b/tests/pylint/intl.py
@@ -22,11 +22,38 @@
import astroid
from pylint.checkers import BaseChecker
+from pylint.checkers.strings import StringFormatChecker
+from pylint.checkers.logging import LoggingChecker
from pylint.checkers.utils import check_messages
from pylint.interfaces import IAstroidChecker
+from copy import copy
+
translationMethods = ["_", "N_", "P_", "C_", "CN_", "CP_"]
+# Returns a list of the message strings for a given translation method call
+def _get_message_strings(node):
+ msgstrs = []
+
+ if node.func.name in ("_", "N_") and len(node.args) >= 1:
+ if isinstance(node.args[0], astroid.Const):
+ msgstrs.append(node.args[0].value)
+ elif node.func.name in ("C_", "CN_") and len(node.args) >= 2:
+ if isinstance(node.args[1], astroid.Const):
+ msgstrs.append(node.args[1].value)
+ elif node.func.name == "P_" and len(node.args) >= 2:
+ if isinstance(node.args[0], astroid.Const):
+ msgstrs.append(node.args[0].value)
+ if isinstance(node.args[1], astroid.Const):
+ msgstrs.append(node.args[1].value)
+ elif node.func.name == "CP_" and len(node.args) >= 3:
+ if isinstance(node.args[1], astroid.Const):
+ msgstrs.append(node.args[1].value)
+ if isinstance(node.args[2], astroid.Const):
+ msgstrs.append(node.args[2].value)
+
+ return msgstrs
+
class IntlChecker(BaseChecker):
__implements__ = (IAstroidChecker, )
name = "internationalization"
@@ -38,7 +65,7 @@ class IntlChecker(BaseChecker):
"Calling _ at the module or class level results in translations to the wrong language")
}
- @check_messages("W9901")
+ @check_messages("found-percent-in-_")
def visit_binop(self, node):
if node.op != "%":
return
@@ -58,6 +85,49 @@ class IntlChecker(BaseChecker):
if isinstance(node.scope(), astroid.Module) or isinstance(node.scope(), astroid.Class):
self.add_message("W9902", node=node)
+# Extend LoggingChecker to check translated logging strings
+class IntlLoggingChecker(LoggingChecker):
+ msgs = {'W9903': ("Fake message for translated E/W120* checks",
+ "translated-log",
+ "This message is not emitted itself, but can be used to control the display of \
+ logging format messages extended for translated strings")
+ }
+
+ @check_messages('translated-log')
+ def visit_callfunc(self, node):
+ if len(node.args) >= 1 and isinstance(node.args[0], astroid.CallFunc) and \
+ getattr(node.args[0].func, "name", "") in translationMethods:
+ for formatstr in _get_message_strings(node.args[0]):
+ # Both the node and the args need to be copied so we don't replace args
+ # on the original node.
+ copynode = copy(node)
+ copyargs = copy(node.args)
+ copyargs[0] = astroid.Const(formatstr)
+ copynode.args = copyargs
+ LoggingChecker.visit_callfunc(self, copynode)
+
+# Extend StringFormatChecker to check translated format strings
+class IntlStringFormatChecker(StringFormatChecker):
+ msgs = {'W9904': ("Fake message for translated E/W130* checks",
+ "translated-format",
+ "This message is not emitted itself, but can be used to control the display of \
+ string format messages extended for translated strings")
+ }
+
+ @check_messages('translated-format')
+ def visit_binop(self, node):
+ if node.op != '%':
+ return
+
+ if isinstance(node.left, astroid.CallFunc) and getattr(node.left.func, "name", "") in translationMethods:
+ for formatstr in _get_message_strings(node.left):
+ # Create a copy of the node with just the message string as the format
+ copynode = copy(node)
+ copynode.left = astroid.Const(formatstr)
+ StringFormatChecker.visit_binop(self, copynode)
+
def register(linter):
"""required method to auto register this checker """
linter.register_checker(IntlChecker(linter))
+ linter.register_checker(IntlLoggingChecker(linter))
+ linter.register_checker(IntlStringFormatChecker(linter))
--
1.9.0
10 years
[PATCH 0/2] Fix missing "adding repo" message
by Martin Kolman
The message was part of a Fedora QA test case and they want it back. :)
The first patch reintroduces the message by switching the log level from
debug (which is not forwarded to the packaging log unless debug is present
on boot command line) to info (which should always end in the log).
The second patch is basically optional - it changes the format of the message
a bit so that empty strings are more evident.
Martin Kolman (2):
Fix missing log message about adding a repository (#1089297)
Improve the "adding yum repo" message structure
pyanaconda/packaging/yumpayload.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
--
1.9.0
10 years
[PATCH] Fix an issue introduced in commit a210eb5c.
by David Lehman
---
blivet/devicetree.py | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/blivet/devicetree.py b/blivet/devicetree.py
index adcb986..85c4ed0 100644
--- a/blivet/devicetree.py
+++ b/blivet/devicetree.py
@@ -1373,8 +1373,9 @@ class DeviceTree(object):
origin_device_name = "%s-%s" % (vg_name, origin_name)
addRequiredLV(origin_device_name, "failed to locate origin lv")
- log.debug("adding %s to %s snapshot total",
- lv_sizes[index], origin.name)
+ origin = self.getDeviceByName(origin_device_name)
+ log.debug("adding %s to %s snapshot total", lv_size,
+ origin.name)
origin.snapshotSpace += lv_size
return
elif lv_attr[0] == 'v':
--
1.9.0
10 years
[master][PATCH] Use human readable sizes with two decimal spaces in the GUI
by Vratislav Podzimek
Signed-off-by: Vratislav Podzimek <vpodzime(a)redhat.com>
---
pyanaconda/ui/gui/spokes/custom.py | 15 ++++++++++++---
pyanaconda/ui/gui/spokes/lib/custom_storage_helpers.py | 13 +++++++++----
2 files changed, 21 insertions(+), 7 deletions(-)
diff --git a/pyanaconda/ui/gui/spokes/custom.py b/pyanaconda/ui/gui/spokes/custom.py
index de1a498..bc44d34 100644
--- a/pyanaconda/ui/gui/spokes/custom.py
+++ b/pyanaconda/ui/gui/spokes/custom.py
@@ -148,6 +148,7 @@ class CustomPartitioningSpoke(NormalSpoke, StorageChecker):
self._fs_types = [] # list of supported fstypes
self._free_space = Size(bytes=0)
+ self._device_size_text = None
self._device_disks = []
self._device_container_name = None
self._device_container_raid_level = None
@@ -875,9 +876,16 @@ class CustomPartitioningSpoke(NormalSpoke, StorageChecker):
# SIZE
old_size = device.size
- size = size_from_entry(self._sizeEntry)
+
+ # we are interested in size human readable representation change because
+ # that's what the user sees
+ same_size = self._device_size_text == self._sizeEntry.get_text()
+ if same_size:
+ size = old_size
+ else:
+ size = size_from_entry(self._sizeEntry)
changed_size = ((use_dev.resizable or not use_dev.exists) and
- size != old_size)
+ not same_size)
old_device_info["size"] = old_size
new_device_info["size"] = size
@@ -1349,7 +1357,8 @@ class CustomPartitioningSpoke(NormalSpoke, StorageChecker):
self._labelEntry.set_text("")
fancy_set_sensitive(self._labelEntry, True)
- self._sizeEntry.set_text(device.size.humanReadable(max_places=None))
+ self._device_size_text = device.size.humanReadable(max_places=2)
+ self._sizeEntry.set_text(self._device_size_text)
self._reformatCheckbox.set_active(not device.format.exists)
fancy_set_sensitive(self._reformatCheckbox, not device.protected and
diff --git a/pyanaconda/ui/gui/spokes/lib/custom_storage_helpers.py b/pyanaconda/ui/gui/spokes/lib/custom_storage_helpers.py
index 892f357..b86f6d1 100644
--- a/pyanaconda/ui/gui/spokes/lib/custom_storage_helpers.py
+++ b/pyanaconda/ui/gui/spokes/lib/custom_storage_helpers.py
@@ -370,7 +370,9 @@ class ContainerDialog(GUIObject):
self._raidStoreFilter.refilter()
self._populate_raid()
- self._sizeEntry.set_text(self.size.humanReadable(max_places=None))
+ self._original_size = self.size
+ self._original_size_text = self.size.humanReadable(max_places=None)
+ self._sizeEntry.set_text(self._original_size_text)
if self.size_policy == SIZE_POLICY_AUTO:
self._sizeCombo.set_active(0)
elif self.size_policy == SIZE_POLICY_MAX:
@@ -442,9 +444,12 @@ class ContainerDialog(GUIObject):
elif idx == 1:
size = SIZE_POLICY_MAX
elif idx == 2:
- size = size_from_entry(self._sizeEntry)
- if size is None:
- size = SIZE_POLICY_MAX
+ if self._original_size_text != self._sizeEntry.get_text():
+ size = size_from_entry(self._sizeEntry)
+ if size is None:
+ size = SIZE_POLICY_MAX
+ else:
+ size = self._original_size
# now save the changes
--
1.9.0
10 years
[master] Last refactorization set for the Custom spoke
by Vratislav Podzimek
With these, I'm done with the refactorization of the code and I will jump on ~8
bugs I've identified when testing my changes.
Vratislav Podzimek (9):
Refactor out the code for adding device/mountpoint into a method
Use the @ui_storage_logged decorator for the _destroy_device method
Refactor out the code for removing empty parents
Split complex conditions into multiple lines with named parts
Give an opaque condition a better name explaining its real meaning
Switch the condition in long if-else statement
Refactor the btrfs magic into a separate method
Make the _resolve_btrfs_restrictions method's code nicer
Give include_btrfs variable a better name
pyanaconda/ui/gui/spokes/custom.py | 447 +++++++++++++++++++------------------
1 file changed, 230 insertions(+), 217 deletions(-)
--
1.9.0
10 years
[PATCH 0/2] New pylint changes for new pylint
by David Shea
In addition to these new warnings, pylint crashes on
pyanaconda/packaging/__init__.py and pyanaconda/bootloader.py. Still tracking
down the cause of that, but here's some super minor fixes in the meantime.
David Shea (2):
Specify string format arguments as logging function parameters
Ignore use of eval warnings.
pyanaconda/anaconda_log.py | 2 +-
pyanaconda/vnc.py | 8 ++++----
tests/pylint/runpylint.sh | 3 ++-
3 files changed, 7 insertions(+), 6 deletions(-)
--
1.9.0
10 years