[blivet] Allow / in the name of all kinds of btrfs device (#1183061)
by David Shea
---
blivet/devices/btrfs.py | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/blivet/devices/btrfs.py b/blivet/devices/btrfs.py
index 13adbb4..b5df2d0 100644
--- a/blivet/devices/btrfs.py
+++ b/blivet/devices/btrfs.py
@@ -138,6 +138,11 @@ class BTRFSDevice(StorageDevice):
spec = super(BTRFSDevice, self).fstabSpec
return spec
+ @classmethod
+ def isNameValid(cls, name):
+ # Override StorageDevice.isNameValid to allow /
+ return not('\x00' in name or name == '.' or name == '..')
+
class BTRFSVolumeDevice(BTRFSDevice, ContainerDevice, RaidDevice):
_type = "btrfs volume"
vol_id = btrfs.MAIN_VOLUME_ID
@@ -567,11 +572,6 @@ class BTRFSSubVolumeDevice(BTRFSDevice, RaidDevice):
data.name = self.name
data.preexist = self.exists
- @classmethod
- def isNameValid(cls, name):
- # Override StorageDevice.isNameValid to allow /
- return not('\x00' in name or name == '.' or name == '..')
-
class BTRFSSnapShotDevice(BTRFSSubVolumeDevice):
""" A btrfs snapshot pseudo-device.
--
2.1.0
9 years, 4 months
[lorax/master 1/4] livemedia-creator: Create parent dirs for logfile path
by Brian C. Lane
The directory where the --logfile is located is also used for other log
files and for the anaconda logs when using --no-virt. Create the parent
directories if they don't exist.
---
src/sbin/livemedia-creator | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/sbin/livemedia-creator b/src/sbin/livemedia-creator
index d8ee275..a9b29d7 100755
--- a/src/sbin/livemedia-creator
+++ b/src/sbin/livemedia-creator
@@ -1092,6 +1092,9 @@ def setup_logging(opts):
:param opts: options passed to livemedia-creator
:type opts: argparse options
"""
+ if not os.path.isdir(os.path.abspath(os.path.dirname(opts.logfile))):
+ os.makedirs(os.path.abspath(os.path.dirname(opts.logfile)))
+
# Setup logging to console and to logfile
log.setLevel(logging.DEBUG)
pylorax_log.setLevel(logging.DEBUG)
--
1.9.3
9 years, 4 months
[blivet/master] Add docstrings to the methods in loop.py
by Brian C. Lane
---
blivet/devicelibs/loop.py | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/blivet/devicelibs/loop.py b/blivet/devicelibs/loop.py
index 4270929..bd6d099 100644
--- a/blivet/devicelibs/loop.py
+++ b/blivet/devicelibs/loop.py
@@ -30,6 +30,13 @@ log = logging.getLogger("blivet")
def losetup(args, capture=False):
+ """ run losetup
+
+ :param list args: Arguments to pass to losetup
+ :param bool capture: When True the output is captured and returned
+ :returns: returncode when capture is False (default) or output when it is True.
+ :raises: LoopError if there is an OSError running losetup
+ """
if capture:
exec_func = util.capture_output
else:
@@ -44,6 +51,11 @@ def losetup(args, capture=False):
return ret
def get_backing_file(name):
+ """ Get the backing file for a loop device
+
+ :param str name: Name of loop device (loop0, loop1, etc.)
+ :returns: path of the backing file or ""
+ """
path = ""
sys_path = "/sys/class/block/%s/loop/backing_file" % name
if os.access(sys_path, os.R_OK):
@@ -52,6 +64,13 @@ def get_backing_file(name):
return path
def get_loop_name(path):
+ """ Get the name of the loop device associated with a file
+
+ :param str path: Path to the file
+ :returns: First loop device or ""
+
+ If multiple loop devices are associated with path this will return the first one.
+ """
args = ["-j", path]
buf = losetup(args, capture=True)
@@ -68,6 +87,11 @@ def get_loop_name(path):
return name
def loop_setup(path):
+ """ Setup a loop device backed by a file
+
+ :param str path: Path to the file to setup the loop device on
+ :raises: LoopError if there was an error setting up the loop device
+ """
args = ["-f", path]
msg = None
try:
@@ -79,6 +103,11 @@ def loop_setup(path):
raise LoopError("failed to set up loop for %s: %s" % (path, msg))
def loop_teardown(path):
+ """ Teardown the loop device associated with a file
+
+ :param str path: Path to the loop device
+ :raises: LoopError if there was an error tearing down the loop device
+ """
args = ["-d", path]
msg = None
try:
--
1.9.3
9 years, 4 months
[PATCH] Run AnacondaExceptionHandler in cmdline mode
by Brian C. Lane
cmdline mode still needs to have the exception handler run. It exits
anaconda when there are problems, without it you can get stuck in a loop
in the summary hub when there are incomplete spokes.
This adds an interactive argument to it so that when the handler runs in
cmdline mode it only prints out the error and calls sys.exit(1) --
skipping the call to the superclass from meh which tries to run a UI to
prompt for debugging.
---
anaconda | 6 ++----
pyanaconda/exception.py | 28 +++++++++++++++++-----------
2 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/anaconda b/anaconda
index d97b682..f27280d 100755
--- a/anaconda
+++ b/anaconda
@@ -1269,10 +1269,8 @@ if __name__ == "__main__":
if image_count:
anaconda.storage.setupDiskImages()
- # only install interactive exception handler in interactive modes
- if ksdata.displaymode.displayMode != DISPLAY_MODE_CMDLINE or flags.debug:
- from pyanaconda import exception
- anaconda.mehConfig = exception.initExceptionHandling(anaconda)
+ from pyanaconda import exception
+ anaconda.mehConfig = exception.initExceptionHandling(anaconda)
# add our own additional signal handlers
signal.signal(signal.SIGUSR1, lambda signum, frame:
diff --git a/pyanaconda/exception.py b/pyanaconda/exception.py
index b8b8f4f..4b46802 100644
--- a/pyanaconda/exception.py
+++ b/pyanaconda/exception.py
@@ -49,7 +49,7 @@ log = logging.getLogger("anaconda")
class AnacondaExceptionHandler(ExceptionHandler):
- def __init__(self, confObj, intfClass, exnClass, tty_num, gui_lock):
+ def __init__(self, confObj, intfClass, exnClass, tty_num, gui_lock, interactive):
"""
:see: python-meh's ExceptionHandler
:param tty_num: the number of tty the interface is running on
@@ -59,6 +59,7 @@ class AnacondaExceptionHandler(ExceptionHandler):
ExceptionHandler.__init__(self, confObj, intfClass, exnClass)
self._gui_lock = gui_lock
self._intf_tty_num = tty_num
+ self._interactive = interactive
def run_handleException(self, dump_info):
"""
@@ -128,15 +129,19 @@ class AnacondaExceptionHandler(ExceptionHandler):
# X not running (Gtk cannot be initialized)
if threadMgr.in_main_thread():
log.debug("In the main thread, running exception handler")
- if (issubclass (ty, CmdlineError)):
-
- cmdline_error_msg = _("\nThe installation was stopped due to "
- "incomplete spokes detected while running "
- "in non-interactive cmdline mode. Since there "
- "cannot be any questions in cmdline mode, "
- "edit your kickstart file and retry "
- "installation.\nThe exact error message is: "
- "\n\n%s.\n\nThe installer will now terminate.") % str(value)
+ if issubclass(ty, CmdlineError) or not self._interactive:
+ if issubclass(ty, CmdlineError):
+ cmdline_error_msg = _("\nThe installation was stopped due to "
+ "incomplete spokes detected while running "
+ "in non-interactive cmdline mode. Since there "
+ "cannot be any questions in cmdline mode, "
+ "edit your kickstart file and retry "
+ "installation.\nThe exact error message is: "
+ "\n\n%s.\n\nThe installer will now terminate.") % str(value)
+ else:
+ cmdline_error_msg = _("\nRunning in cmdline mode, no interactive debugging "
+ "allowed.\nThe exact error message is: "
+ "\n\n%s.\n\nThe installer will now terminate.") % str(value)
# since there is no UI in cmdline mode and it is completely
# non-interactive, we can't show a message window asking the user
@@ -259,9 +264,10 @@ def initExceptionHandling(anaconda):
# anaconda-tb file
conf.register_callback("journalctl", journalctl_callback, attchmnt_only=False)
+ interactive = not anaconda.displayMode == 'c'
handler = AnacondaExceptionHandler(conf, anaconda.intf.meh_interface,
ReverseExceptionDump, anaconda.intf.tty_num,
- anaconda.gui_initialized)
+ anaconda.gui_initialized, interactive)
handler.install(anaconda)
return conf
--
1.9.3
9 years, 4 months
[anaconda/lorax/initial-setup] Rearrange how we interact with the window manager
by David Shea
The live installer requires that certain things be configured in the window
manager that we're running in, but since we're running fullscreen it's kind of
hard to get back to it without just quitting. Instead, run maximized, and use a
GtkWindow property to hide the titlebar in GNOME and make things look a little
nicer.
To keep the fullscreen appearance on the non-live media, modify the metacity
theme, and that's where the lorax changes come in. Carry the metacity config
bits in anaconda instead of lorax, so initial-setup can use them too, and add
a copy of the theme that we were using, modified to remove the titlebar. Clean
up all the theme bits that lorax no longer cares about.
The anaconda change will need to be built first, since the lorax changes
remove all metacity theme files from the stage2, and without the one file
added back by anaconda metacity will not run.
anaconda:
Maximize anaconda instead of running fullscreen (#1164457)
Move metacity gsettings overrides into anaconda
Install a metacity theme to remove the titlebar.
anaconda | 11 +
anaconda.spec.in | 5 +
configure.ac | 3 +
data/Makefile.am | 2 +-
data/window-manager/Makefile.am | 20 +
data/window-manager/config/Makefile.am | 39 +
...g.gnome.desktop.wm.keybindings.gschema.override | 35 +
...g.gnome.desktop.wm.preferences.gschema.override | 5 +
data/window-manager/theme/Makefile.am | 22 +
data/window-manager/theme/metacity-theme-1.xml | 958 +++++++++++++++++++++
pyanaconda/ui/gui/__init__.py | 25 +-
scripts/makeupdates | 27 +-
12 files changed, 1131 insertions(+), 21 deletions(-)
create mode 100644 data/window-manager/Makefile.am
create mode 100644 data/window-manager/config/Makefile.am
create mode 100644 data/window-manager/config/org.gnome.desktop.wm.keybindings.gschema.override
create mode 100644 data/window-manager/config/org.gnome.desktop.wm.preferences.gschema.override
create mode 100644 data/window-manager/theme/Makefile.am
create mode 100644 data/window-manager/theme/metacity-theme-1.xml
lorax:
Remove the GSettings overrides for metacity
Remove fedora-gnome-theme
Remove fedora-icon-theme
...g.gnome.desktop.wm.keybindings.gschema.override | 35 ----------------------
...g.gnome.desktop.wm.preferences.gschema.override | 4 ---
share/runtime-cleanup.tmpl | 5 ----
share/runtime-install.tmpl | 6 ++--
share/runtime-postinstall.tmpl | 5 ----
5 files changed, 2 insertions(+), 53 deletions(-)
delete mode 100644 share/config_files/common/org.gnome.desktop.wm.keybindings.gschema.override
delete mode 100644 share/config_files/common/org.gnome.desktop.wm.preferences.gschema.override
initial-setup:
Use anaconda's metacity settings when running metacity
firstboot-windowmanager | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
--
2.1.0
9 years, 4 months
[blivet-rhel7/master] get_loop_name shoud return an empty name if it isn't found (#980510)
by Brian C. Lane
Callers expect a name or "" not an error.
Related: rhbz#980510
---
blivet/devicelibs/loop.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/blivet/devicelibs/loop.py b/blivet/devicelibs/loop.py
index 661a32e..4270929 100644
--- a/blivet/devicelibs/loop.py
+++ b/blivet/devicelibs/loop.py
@@ -57,7 +57,7 @@ def get_loop_name(path):
entries = buf.splitlines()
if not entries:
- raise LoopError("No loop associated with %s" % (path))
+ return ""
first_entry = entries[0]
if len(entries) > 1:
--
1.9.3
9 years, 4 months
[blivet-gui:master 0/9] Pylint patches
by Anne Mulhern
_Please_ note warning below.
Initial setup and some fixes. Attached below are remaining pylint errors.
Most are just unused-argument which are probably intentionally unused, due to
GUI interface requirements and probably just need to be suppressed.
A few are no-member; maybe set_margin_start should be set_margin_left, but
I am not sure.
It is customary to put this stuff in tests/pylint subdirectory, so I did.
I had to remove tests entry from .gitignore. Please make sure not to kill
your local private tests directory if such a thing exists, by applying
these patches. Thanks.
************* Module blivetgui/actions_toolbar.py
blivetgui/actions_toolbar.py:152: [W0613(unused-argument), ActionsToolbar.on_delete_clicked] Unused argument 'button'
blivetgui/actions_toolbar.py:158: [W0613(unused-argument), ActionsToolbar.on_add_clicked] Unused argument 'button'
blivetgui/actions_toolbar.py:164: [W0613(unused-argument), ActionsToolbar.on_edit_clicked] Unused argument 'button'
blivetgui/actions_toolbar.py:170: [W0613(unused-argument), ActionsToolbar.on_umount_clicked] Unused argument 'button'
blivetgui/actions_toolbar.py:176: [W0613(unused-argument), ActionsToolbar.on_decrypt_clicked] Unused argument 'button'
blivetgui/actions_toolbar.py:182: [W0613(unused-argument), ActionsToolbar.on_apply_clicked] Unused argument 'button'
blivetgui/actions_toolbar.py:188: [W0613(unused-argument), ActionsToolbar.on_clear_clicked] Unused argument 'button'
blivetgui/actions_toolbar.py:194: [W0613(unused-argument), ActionsToolbar.on_undo_clicked] Unused argument 'button'
************* Module blivetgui/dialogs/edit_dialog.py
blivetgui/dialogs/edit_dialog.py:164: [W0613(unused-argument), PartitionEditDialog.on_format_changed] Unused argument 'event'
blivetgui/dialogs/edit_dialog.py:382: [W0613(unused-argument), LVMEditDialog.on_cell_toggled] Unused argument 'toggle'
blivetgui/dialogs/edit_dialog.py:385: [W0613(unused-argument), LVMEditDialog.on_cell_radio_toggled] Unused argument 'toggle'
************* Module blivetgui/list_partitions.py
blivetgui/list_partitions.py:77: [E1101(no-member), ListPartitions.__init__] Instance of 'Label' has no 'set_margin_start' member
blivetgui/list_partitions.py:78: [E1101(no-member), ListPartitions.__init__] Instance of 'Label' has no 'set_margin_end' member
blivetgui/list_partitions.py:863: [W0613(unused-argument), ListPartitions.quit] Unused argument 'widget'
blivetgui/list_partitions.py:863: [W0613(unused-argument), ListPartitions.quit] Unused argument 'event'
************* Module blivetgui/dialogs/other_dialogs.py
blivetgui/dialogs/other_dialogs.py:187: [W0613(unused-argument), KickstartSelectDevicesDialog.on_cell_toggled] Unused argument 'event'
blivetgui/dialogs/other_dialogs.py:214: [W0613(unused-argument), KickstartSelectDevicesDialog.on_boot_changed] Unused argument 'event'
************* Module blivetgui/dialogs/add_dialog.py
blivetgui/dialogs/add_dialog.py:264: [W0613(unused-argument), SizeChooserArea.get_size_precision] Unused argument 'unit'
blivetgui/dialogs/add_dialog.py:683: [W0613(unused-argument), AddDialog.on_raid_type_changed] Unused argument 'event'
blivetgui/dialogs/add_dialog.py:807: [W0613(unused-argument), AddDialog.on_cell_toggled] Unused argument 'event'
blivetgui/dialogs/add_dialog.py:983: [W0613(unused-argument), AddDialog.on_md_type_changed] Unused argument 'event'
blivetgui/dialogs/add_dialog.py:1129: [W0613(unused-argument), AddDialog.on_devices_combo_changed] Unused argument 'event'
blivetgui/dialogs/add_dialog.py:1253: [W0613(unused-argument), AddDialog.on_ok_clicked] Unused argument 'event'
************* Module blivetgui/devicevisualization/device_canvas.py
blivetgui/devicevisualization/device_canvas.py:390: [W0613(unused-argument), DeviceCanvas.button_press_event] Unused argument 'darea'
************* Module blivetgui/actions_menu.py
blivetgui/actions_menu.py:129: [W0613(unused-argument), ActionsMenu.on_add_item] Unused argument 'event'
blivetgui/actions_menu.py:134: [W0613(unused-argument), ActionsMenu.on_delete_item] Unused argument 'event'
blivetgui/actions_menu.py:139: [W0613(unused-argument), ActionsMenu.on_edit_item] Unused argument 'event'
blivetgui/actions_menu.py:144: [W0613(unused-argument), ActionsMenu.on_umount_item] Unused argument 'event'
blivetgui/actions_menu.py:149: [W0613(unused-argument), ActionsMenu.on_decrypt_item] Unused argument 'event'
************* Module examples/embeded.py
examples/embeded.py:58: [W0613(unused-argument), SocketWindow.plugged_event] Unused argument 'widget'
************* Module blivetgui/main_menu.py
blivetgui/main_menu.py:256: [W0613(unused-argument), MainMenu.on_about_item] Unused argument 'args'
blivetgui/main_menu.py:262: [W0613(unused-argument), MainMenu.on_help_item] Unused argument 'args'
blivetgui/main_menu.py:295: [W0613(unused-argument), MainMenu.on_undo_item] Unused argument 'args'
blivetgui/main_menu.py:301: [W0613(unused-argument), MainMenu.on_clear_item] Unused argument 'args'
blivetgui/main_menu.py:307: [W0613(unused-argument), MainMenu.on_apply_item] Unused argument 'args'
blivetgui/main_menu.py:313: [W0613(unused-argument), MainMenu.on_add_item] Unused argument 'args'
blivetgui/main_menu.py:319: [W0613(unused-argument), MainMenu.on_delete_item] Unused argument 'args'
blivetgui/main_menu.py:325: [W0613(unused-argument), MainMenu.on_edit_item] Unused argument 'args'
blivetgui/main_menu.py:331: [W0613(unused-argument), MainMenu.on_umount_item] Unused argument 'args'
blivetgui/main_menu.py:337: [W0613(unused-argument), MainMenu.on_decrypt_item] Unused argument 'args'
blivetgui/main_menu.py:343: [W0613(unused-argument), MainMenu.on_quit_item] Unused argument 'args'
blivetgui/main_menu.py:349: [W0613(unused-argument), MainMenu.on_reload_item] Unused argument 'args'
************* Module blivetgui/processing_window.py
blivetgui/processing_window.py:112: [W0613(unused-argument), ProcessingActions.on_timeout] Unused argument 'user_data'
mulhern (9):
Initial pylint setup.
Fix bad indentation.
Do not use builtin name format as parameter name.
Do not use wildcard import.
Move % operator outside translation.
Omit needless imports.
Omit or hide unused variables and computations.
Change relative to absolute imports.
Suppress broad-except pylint errors.
.gitignore | 1 -
blivet-gui | 2 +-
blivetgui/devicevisualization/device_canvas.py | 2 +-
blivetgui/dialogs/edit_dialog.py | 6 +-
blivetgui/list_partitions.py | 2 +-
blivetgui/main.py | 8 +-
blivetgui/processing_window.py | 4 +-
blivetgui/udisks_loop.py | 3 -
blivetgui/utils.py | 16 +-
examples/embeded.py | 4 +-
tests/lib/testlib.sh | 37 ++++
tests/pylint/intl.py | 63 +++++++
tests/pylint/pointless-override.py | 252 +++++++++++++++++++++++++
tests/pylint/pylint-false-positives | 0
tests/pylint/pylint-one.sh | 33 ++++
tests/pylint/runpylint.sh | 125 ++++++++++++
tests/testenv.sh | 13 ++
17 files changed, 544 insertions(+), 27 deletions(-)
create mode 100644 tests/lib/testlib.sh
create mode 100644 tests/pylint/intl.py
create mode 100644 tests/pylint/pointless-override.py
create mode 100644 tests/pylint/pylint-false-positives
create mode 100755 tests/pylint/pylint-one.sh
create mode 100755 tests/pylint/runpylint.sh
create mode 100644 tests/testenv.sh
--
1.9.3
9 years, 4 months
[PATCH pyparted] Add new functions to extend exception handling.
by Chris Lumens
We've been avoiding this for an awful long time, but there is now a need for
users of pyparted to be able to specify what answers should be given to parted
exceptions that ask a question. Specifically, we need to be able to ask the
user whether to proceed with a disk containing a corrupted GPT disk label or not.
This adds a function to register a callback that can prompt the user (among other
possible actions) and a function to clear this callback to restore default
behavior.
---
src/_pedmodule.c | 135 ++++++++++++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 125 insertions(+), 10 deletions(-)
diff --git a/src/_pedmodule.c b/src/_pedmodule.c
index 1a90188..24b1050 100644
--- a/src/_pedmodule.c
+++ b/src/_pedmodule.c
@@ -5,7 +5,7 @@
* Python module that implements the libparted functionality via Python
* classes and other high level language features.
*
- * Copyright (C) 2007-2013 Red Hat, Inc.
+ * Copyright (C) 2007-2015 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
@@ -53,6 +53,8 @@
char *partedExnMessage = NULL;
unsigned int partedExnRaised = 0;
+PyObject *exn_handler = NULL;
+
/* Docs strings are broken out of the module structure here to be at least a
* little bit readable.
*/
@@ -199,6 +201,25 @@ PyDoc_STRVAR(unit_get_by_name_doc,
"Returns a Unit given its textual representation. Returns one of the\n"
"UNIT_* constants.");
+PyDoc_STRVAR(register_exn_handler_doc,
+"register_exn_handler(function)\n\n"
+"When parted raises an exception, the function registered here will be called\n"
+"to help determine what action to take. This does not bypass the exception\n"
+"handler pyparted uses. Instead, it can be used to pop up a dialog to ask the\n"
+"user which course of action to take, or to provide a different default answer,\n"
+"or other actions.\n\n"
+"The given function must accept as arguments: (1) an integer corresponding to\n"
+"one of the EXCEPTION_TYPE_* constants; (2) an integer corresponding to one of the\n"
+"EXCEPTION_OPT_* constants; and (3) a string that is the problem encountered by\n"
+"parted. This string will already be translated. The given function must return\n"
+"one of the EXCEPTION_RESOLVE_* constants instructing parted how to proceed.");
+
+PyDoc_STRVAR(clear_exn_handler_doc,
+"clear_exn_handler()\n\n"
+"Clear any previously added exception handling function. This means the\n"
+"default behavior for all parted exceptions will be used, so only safe\n"
+"answers to any questions parted asks will be automatically provided.");
+
PyDoc_STRVAR(_ped_doc,
"This module implements an interface to libparted.\n\n"
"pyparted provides two API layers: a lower level that exposes the complete\n"
@@ -213,6 +234,25 @@ PyDoc_STRVAR(_ped_doc,
"For complete documentation, refer to the docs strings for each _ped\n"
"method, exception class, and subclass.");
+PyObject *py_ped_register_exn_handler(PyObject *s, PyObject *args) {
+ PyObject *fn = NULL;
+
+ if (!PyArg_ParseTuple(args, "O", &fn)) {
+ return NULL;
+ }
+
+ Py_DECREF(exn_handler);
+ exn_handler = fn;
+
+ Py_RETURN_TRUE;
+}
+
+PyObject *py_ped_clear_exn_handler(PyObject *s, PyObject *args) {
+ exn_handler = Py_None;
+ Py_INCREF(exn_handler);
+ Py_RETURN_TRUE;
+}
+
/* all of the methods for the _ped module */
static struct PyMethodDef PyPedModuleMethods[] = {
{"libparted_version", (PyCFunction) py_libparted_get_version, METH_VARARGS,
@@ -220,6 +260,11 @@ static struct PyMethodDef PyPedModuleMethods[] = {
{"pyparted_version", (PyCFunction) py_pyparted_version, METH_VARARGS,
pyparted_version_doc},
+ {"register_exn_handler", (PyCFunction) py_ped_register_exn_handler, METH_VARARGS,
+ register_exn_handler_doc},
+ {"clear_exn_handler", (PyCFunction) py_ped_clear_exn_handler, METH_VARARGS,
+ clear_exn_handler_doc},
+
/* pyconstraint.c */
{"constraint_new_from_min_max", (PyCFunction) py_ped_constraint_new_from_min_max,
METH_VARARGS, constraint_new_from_min_max_doc},
@@ -365,6 +410,10 @@ PyObject *py_pyparted_version(PyObject *s, PyObject *args) {
* main motivation for this function is that methods in our parted module need
* to be able to raise specific, helpful exceptions instead of something
* generic.
+ *
+ * It is also possible for callers to specify a function to help in deciding
+ * what to do with parted exceptions. See the docs for the
+ * py_ped_register_exn_handler function.
*/
static PedExceptionOption partedExnHandler(PedException *e) {
switch (e->type) {
@@ -378,13 +427,29 @@ static PedExceptionOption partedExnHandler(PedException *e) {
if (partedExnMessage == NULL)
PyErr_NoMemory();
-
- /*
- * return 'no' for yes/no question exceptions in libparted,
- * prevent any potential disk destruction and pass up an
- * exception to our caller
- */
- return PED_EXCEPTION_NO;
+ else if (exn_handler && PyCallable_Check(exn_handler)) {
+ PyObject *args, *retval;
+
+ args = PyTuple_New(3);
+ PyTuple_SetItem(args, 0, PyInt_FromLong(e->type));
+ PyTuple_SetItem(args, 1, PyInt_FromLong(e->options));
+ PyTuple_SetItem(args, 2, PyUnicode_FromString(e->message));
+
+ retval = PyObject_CallObject(exn_handler, NULL);
+ Py_DECREF(args);
+ if (retval != NULL && (PyLong_AsLong(retval) == PED_EXCEPTION_UNHANDLED || (PyLong_AsLong(retval) & e->options) > 0))
+ return PyLong_AsLong(retval);
+ else
+ /* Call failed, use the default value. */
+ return PED_EXCEPTION_NO;
+ }
+ else {
+ /* If no exception handling function was registered to
+ * tell us what to do, return "no" for any yes/no
+ * questions to prevent any potential disk destruction.
+ */
+ return PED_EXCEPTION_NO;
+ }
} else {
partedExnRaised = 0;
return PED_EXCEPTION_IGNORE;
@@ -400,8 +465,29 @@ static PedExceptionOption partedExnHandler(PedException *e) {
if (partedExnMessage == NULL)
PyErr_NoMemory();
-
- return PED_EXCEPTION_CANCEL;
+ else if (exn_handler && PyCallable_Check(exn_handler)) {
+ PyObject *args, *retval;
+
+ args = PyTuple_New(3);
+ PyTuple_SetItem(args, 0, PyInt_FromLong(e->type));
+ PyTuple_SetItem(args, 1, PyInt_FromLong(e->options));
+ PyTuple_SetItem(args, 2, PyUnicode_FromString(e->message));
+
+ retval = PyObject_CallObject(exn_handler, NULL);
+ Py_DECREF(args);
+ if (retval != NULL && (PyLong_AsLong(retval) == PED_EXCEPTION_UNHANDLED || (PyLong_AsLong(retval) & e->options) > 0))
+ return PyLong_AsLong(retval);
+ else
+ /* Call failed, use the default value. */
+ return PED_EXCEPTION_CANCEL;
+ }
+ else {
+ /* If no exception handling function was registered to tell us
+ * what to do, return "cancel" for any questions to prevent
+ * any potential disk destruction.
+ */
+ return PED_EXCEPTION_CANCEL;
+ }
/* Raise exceptions for internal parted bugs immediately. */
case PED_EXCEPTION_BUG:
@@ -648,6 +734,35 @@ MOD_INIT(_ped) {
Py_INCREF(UnknownTypeException);
PyModule_AddObject(m, "UnknownTypeException", UnknownTypeException);
+ /* Exception type constants. */
+ PyModule_AddIntConstant(m, "EXCEPTION_TYPE_INFORMATION", PED_EXCEPTION_INFORMATION);
+ PyModule_AddIntConstant(m, "EXCEPTION_TYPE_WARNING", PED_EXCEPTION_WARNING);
+ PyModule_AddIntConstant(m, "EXCEPTION_TYPE_ERROR", PED_EXCEPTION_ERROR);
+ PyModule_AddIntConstant(m, "EXCEPTION_TYPE_FATAL", PED_EXCEPTION_FATAL);
+ PyModule_AddIntConstant(m, "EXCEPTION_TYPE_BUG", PED_EXCEPTION_BUG);
+ PyModule_AddIntConstant(m, "EXCEPTION_TYPE_NO_FEATURE", PED_EXCEPTION_NO_FEATURE);
+
+ /* Exception resolution constants. */
+ PyModule_AddIntConstant(m, "EXCEPTION_RESOLVE_UNHANDLED", PED_EXCEPTION_UNHANDLED);
+ PyModule_AddIntConstant(m, "EXCEPTION_RESOLVE_FIX", PED_EXCEPTION_FIX);
+ PyModule_AddIntConstant(m, "EXCEPTION_RESOLVE_YES", PED_EXCEPTION_YES);
+ PyModule_AddIntConstant(m, "EXCEPTION_RESOLVE_NO", PED_EXCEPTION_NO);
+ PyModule_AddIntConstant(m, "EXCEPTION_RESOLVE_OK", PED_EXCEPTION_OK);
+ PyModule_AddIntConstant(m, "EXCEPTION_RESOLVE_RETRY", PED_EXCEPTION_RETRY);
+ PyModule_AddIntConstant(m, "EXCEPTION_RESOLVE_IGNORE", PED_EXCEPTION_IGNORE);
+ PyModule_AddIntConstant(m, "EXCEPTION_RESOLVE_CANCEL", PED_EXCEPTION_CANCEL);
+
+ /* Exception option constants. */
+ PyModule_AddIntConstant(m, "EXCEPTION_OPT_OK_CANCEL", PED_EXCEPTION_OK_CANCEL);
+ PyModule_AddIntConstant(m, "EXCEPTION_OPT_YES_NO", PED_EXCEPTION_YES_NO);
+ PyModule_AddIntConstant(m, "EXCEPTION_OPT_YES_NO_CANCEL", PED_EXCEPTION_YES_NO_CANCEL);
+ PyModule_AddIntConstant(m, "EXCEPTION_OPT_IGNORE_CANCEL", PED_EXCEPTION_IGNORE_CANCEL);
+ PyModule_AddIntConstant(m, "EXCEPTION_OPT_RETRY_CANCEL", PED_EXCEPTION_RETRY_CANCEL);
+ PyModule_AddIntConstant(m, "EXCEPTION_OPT_RETRY_IGNORE_CANCEL", PED_EXCEPTION_RETRY_IGNORE_CANCEL);
+
+ exn_handler = Py_None;
+ Py_INCREF(exn_handler);
+
/* Set up our libparted exception handler. */
ped_exception_set_handler(partedExnHandler);
return MOD_SUCCESS_VAL(m);
--
1.9.3
9 years, 4 months
[lorax-rhel7] Use gcdaa64.efi and make boot.iso on aarch64 (#1174475)
by Brian C. Lane
From: Peter Jones <pjones(a)redhat.com>
Add iso creation and switch to using gcdaa64.efi instead of grubaa64.efi
Signed-off-by: Peter Jones <pjones(a)redhat.com>
Signed-off-by: Brian C. Lane <bcl(a)redhat.com>
(cherry picked from commit 8f582846afad0a992bc86b83d4e1926bc28da3db)
Resolves: rhbz#1174475
---
share/aarch64.tmpl | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/share/aarch64.tmpl b/share/aarch64.tmpl
index 66af43f..9f8c31c 100644
--- a/share/aarch64.tmpl
+++ b/share/aarch64.tmpl
@@ -25,7 +25,7 @@ mkdir ${KERNELDIR}
## WHeeeeeeee, EFI.
## We could remove the basearch restriction someday..
<% efiargs=""; efigraft="" %>
-%if exists("boot/efi/EFI/*/grubaa64.efi"):
+%if exists("boot/efi/EFI/*/gcdaa64.efi"):
<%
efiarch = 'AA64'
efigraft="EFI/BOOT={0}/EFI/BOOT".format(outroot)
@@ -35,5 +35,12 @@ mkdir ${KERNELDIR}
efigraft += " {0}={1}/{0}".format(img,outroot)
%>
<%include file="efi.tmpl" args="configdir=configdir, KERNELDIR=KERNELDIR, efiarch=efiarch, isolabel=isolabel"/>
-%endif
+ ## make boot.iso
+ runcmd mkisofs -o ${outroot}/images/boot.iso \
+ ${efiargs} -R -J -V '${isolabel}' -T -graft-points \
+ ${KERNELDIR}=${outroot}/${KERNELDIR} \
+ ${LIVEDIR}=${outroot}/${LIVEDIR} \
+ ${efigraft} ${imggraft}
+ treeinfo images-${basearch} boot.iso images/boot.iso
+%endif
--
1.9.3
9 years, 4 months