Skip to content

Commit

Permalink
Merge pull request #412 from vojtechtrefny/main_flags-auto-dev-updates
Browse files Browse the repository at this point in the history
Add a cmdline option to enabled blivet's auto_dev_updates flag
  • Loading branch information
vojtechtrefny authored Sep 12, 2023
2 parents 5ca82ad + 428b33c commit 0a9706c
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
5 changes: 4 additions & 1 deletion blivet-gui
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ def parse_options():
help=_("show version information"))
parser.add_argument("--keep-above", action="store_true", dest="keep_above", default=False,
help=_("keep blivet-gui window above other windows"))
parser.add_argument("--auto-dev-updates", action="store_true", dest="auto_dev_updates", default=False,
help="gather all information about devices even if it requires potentially dangerous operation \
like mounting or filesystem check")
parser.add_argument("disks", metavar="disk", type=str, nargs="*",
help="run blivet-gui only on specified disk(s) (optional)")

Expand Down Expand Up @@ -108,7 +111,7 @@ def main():
sockfile = output.split()[0]

client = BlivetGUIClient(server_socket=sockfile)
BlivetGUI(client, exclusive_disks=options.disks, keep_above=options.keep_above)
BlivetGUI(client, exclusive_disks=options.disks, keep_above=options.keep_above, auto_dev_updates=options.auto_dev_updates)


if __name__ == '__main__':
Expand Down
11 changes: 10 additions & 1 deletion blivetgui/blivet_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class BlivetUtils(object):

installer_mode = False

def __init__(self, ignored_disks=None, exclusive_disks=None):
def __init__(self, ignored_disks=None, exclusive_disks=None, flags=None):

self.ignored_disks = ignored_disks
self.exclusive_disks = exclusive_disks
Expand All @@ -164,9 +164,18 @@ def __init__(self, ignored_disks=None, exclusive_disks=None):
# ignore zram devices
blivet.udev.ignored_device_names.append(r"^zram")

# set blivet flags
if flags:
self._set_blivet_flags(flags)

self.blivet_reset()
self._update_min_sizes_info()

def _set_blivet_flags(self, flags):
for flag, value in flags.items():
self.log.info("setting blivet flag '%s' to '%s'", flag, value)
setattr(blivet.flags.flags, flag, value)

@property
def resizable_filesystems(self):
if self._resizable_filesystems is None:
Expand Down
8 changes: 6 additions & 2 deletions blivetgui/blivetgui.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class BlivetGUI(object):

installer_mode = False

def __init__(self, client, exclusive_disks=None, keep_above=False):
def __init__(self, client, exclusive_disks=None, keep_above=False, auto_dev_updates=False):

self.client = client

Expand All @@ -93,6 +93,10 @@ def __init__(self, client, exclusive_disks=None, keep_above=False):
# supported filesystems
self._supported_filesystems = []

self.flags = dict()
if auto_dev_updates:
self.flags["auto_dev_updates"] = True

# CSS styles
css_provider = Gtk.CssProvider()
css_provider.load_from_path(locate_css_file("rectangle.css"))
Expand Down Expand Up @@ -789,7 +793,7 @@ def _blivet_init_already_running(self):

def blivet_init(self):
loading_window = LoadingWindow(self.main_window)
ret = self._run_thread(loading_window, self.client.remote_control, ("init", self.ignored_disks, self.exclusive_disks))
ret = self._run_thread(loading_window, self.client.remote_control, ("init", self.ignored_disks, self.exclusive_disks, self.flags))

if not ret.success: # pylint: disable=maybe-no-member
# blivet-gui is already running --> quit
Expand Down
3 changes: 3 additions & 0 deletions man/blivet-gui.1
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ show version information and exit
.TP
.BR \-\-keep\-above
keep the blivet-gui window above other windows
.TP
.BR \-\-auto\-dev\-updates
gather all information about devices even if it requires potentially dangerous operation like mounting or filesystem check

.SH EXAMPLES
You can run blivet-gui from a command line and specify one or more disks.
Expand Down

0 comments on commit 0a9706c

Please sign in to comment.