Merge lp:~milo/linaro-image-tools/disable-automount into lp:linaro-image-tools/11.11

Proposed by Milo Casagrande
Status: Merged
Approved by: James Tunnicliffe
Approved revision: 616
Merged at revision: 616
Proposed branch: lp:~milo/linaro-image-tools/disable-automount
Merge into: lp:linaro-image-tools/11.11
Diff against target: 108 lines (+57/-1)
3 files modified
linaro-android-media-create (+7/-1)
linaro-media-create (+7/-0)
linaro_image_tools/utils.py (+43/-0)
To merge this branch: bzr merge lp:~milo/linaro-image-tools/disable-automount
Reviewer Review Type Date Requested Status
James Tunnicliffe Pending
Review via email: mp+156794@code.launchpad.net

Commit message

Disable automount, and enable it at exit.

Description of the change

As said on bug 1034853, this branch adds dconf calls in order to disable
and re-enable back automount options.

Before running the commands, a check is performed for the dconf command to
be installed.

To post a comment you must log in.
Revision history for this message
James Tunnicliffe (dooferlad) wrote :

Looks good.

Unfortunate that we have so many PEP8 problems under the version shipping with Ubuntu 12.10. Will submit a patch.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'linaro-android-media-create'
--- linaro-android-media-create 2013-01-30 11:28:51 +0000
+++ linaro-android-media-create 2013-04-03 10:16:21 +0000
@@ -44,7 +44,9 @@
44 additional_android_option_checks,44 additional_android_option_checks,
45 andorid_hwpack_in_boot_tarball,45 andorid_hwpack_in_boot_tarball,
46 ensure_command,46 ensure_command,
47 get_logger47 get_logger,
48 disable_automount,
49 enable_automount,
48 )50 )
4951
5052
@@ -117,6 +119,10 @@
117119
118 ensure_required_commands(args)120 ensure_required_commands(args)
119121
122 # Do this by default, disable automount options and re-enable them at exit.
123 disable_automount()
124 atexit.register(enable_automount)
125
120 media = Media(args.device)126 media = Media(args.device)
121 if media.is_block_device:127 if media.is_block_device:
122 if not confirm_device_selection_and_ensure_it_is_ready(args.device):128 if not confirm_device_selection_and_ensure_it_is_ready(args.device):
123129
=== modified file 'linaro-media-create'
--- linaro-media-create 2013-02-25 18:18:09 +0000
+++ linaro-media-create 2013-04-03 10:16:21 +0000
@@ -57,6 +57,9 @@
57 path_in_tarfile_exists,57 path_in_tarfile_exists,
58 prep_media_path,58 prep_media_path,
59 get_logger,59 get_logger,
60 UnableToFindPackageProvidingCommand,
61 disable_automount,
62 enable_automount,
60 )63 )
6164
62# Just define the global variables65# Just define the global variables
@@ -136,6 +139,10 @@
136 logger.error(e.value)139 logger.error(e.value)
137 sys.exit(1)140 sys.exit(1)
138141
142 # Do this by default, disable automount options and re-enable them at exit.
143 disable_automount()
144 atexit.register(enable_automount)
145
139 board_config = get_board_config(args.dev)146 board_config = get_board_config(args.dev)
140 board_config.set_metadata(args.hwpacks, args.bootloader, args.dev)147 board_config.set_metadata(args.hwpacks, args.bootloader, args.dev)
141 board_config.add_boot_args(args.extra_boot_args)148 board_config.add_boot_args(args.extra_boot_args)
142149
=== modified file 'linaro_image_tools/utils.py'
--- linaro_image_tools/utils.py 2013-02-25 18:18:09 +0000
+++ linaro_image_tools/utils.py 2013-04-03 10:16:21 +0000
@@ -35,6 +35,10 @@
35# The name of the hwpack file found in the boot tarball.35# The name of the hwpack file found in the boot tarball.
36HWPACK_NAME = "config"36HWPACK_NAME = "config"
3737
38# dconf keys to disable automount options.
39AUTOMOUNT_DCONF_KEY = '/org/gnome/desktop/media-handling/automount'
40AUTOMOUNT_OPEN_DCONF_KEYU = '/org/gnome/desktop/media-handling/automount-open'
41
3842
39# try_import was copied from python-testtools 0.9.12 and was originally43# try_import was copied from python-testtools 0.9.12 and was originally
40# licensed under a MIT-style license but relicensed under the GPL in Linaro44# licensed under a MIT-style license but relicensed under the GPL in Linaro
@@ -406,3 +410,42 @@
406410
407 logger.addHandler(ch)411 logger.addHandler(ch)
408 return logger412 return logger
413
414
415def disable_automount():
416 """Disables the desktop environment automount option.
417
418 This will work only under GNOME with dconf installed.
419 """
420 logger = logging.getLogger(DEFAULT_LOGGER_NAME)
421
422 if has_command('dconf'):
423 logger.info("Disabling desktop environment automount option.")
424 try:
425 cmd_runner.run(
426 ['dconf', 'write', AUTOMOUNT_DCONF_KEY, 'false'],
427 stdout=open('/dev/null', 'w')).wait()
428 cmd_runner.run(
429 ['dconf', 'write', AUTOMOUNT_OPEN_DCONF_KEYU, 'false'],
430 stdout=open('/dev/null', 'w')).wait()
431 except cmd_runner.SubcommandNonZeroReturnValue:
432 logger.error("Error disabling desktop environemnt automount.")
433
434
435def enable_automount():
436 """Re-enables back the desktop environment automount option.
437
438 This will work only under GNOME with dconf installed. It should be run
439 as an atexit function.
440 """
441 logger = logging.getLogger(DEFAULT_LOGGER_NAME)
442 if has_command('dconf'):
443 try:
444 cmd_runner.run(
445 ['dconf', 'write', AUTOMOUNT_DCONF_KEY, 'true'],
446 stdout=open('/dev/null', 'w')).wait()
447 cmd_runner.run(
448 ['dconf', 'write', AUTOMOUNT_OPEN_DCONF_KEYU, 'true'],
449 stdout=open('/dev/null', 'w')).wait()
450 except cmd_runner.SubcommandNonZeroReturnValue:
451 logger.error("Error enabling back desktop environemnt automount.")

Subscribers

People subscribed via source and target branches