[Pkg-privacy-commits] [tails-installer] 30/43: Refactor duplicated code into a function.

Ulrike Uhlig u-guest at moszumanska.debian.org
Tue Nov 15 23:30:22 UTC 2016


This is an automated email from the git hooks/post-receive script.

u-guest pushed a commit to branch debian/sid
in repository tails-installer.

commit 8819927a1124ee3e9b4eee6c6c8006b36a9bd6f6
Author: intrigeri <intrigeri at boum.org>
Date:   Thu Jul 21 17:17:13 2016 +0000

    Refactor duplicated code into a function.
---
 tails_installer/creator.py | 28 +++++++++++-----------------
 1 file changed, 11 insertions(+), 17 deletions(-)

diff --git a/tails_installer/creator.py b/tails_installer/creator.py
index c0446ac..397377b 100755
--- a/tails_installer/creator.py
+++ b/tails_installer/creator.py
@@ -863,13 +863,8 @@ class LinuxTailsInstallerCreator(TailsInstallerCreator):
             else:
                 raise
 
-        self._udisksclient.settle()
-        self.flush_buffers(silent=True)
-        time.sleep(5)
-
         # Rescan the device as it seems this is not always done automatically.
-        # XXX: this should only be needed when call_create_partition_sync fails.
-        block.call_rescan_sync(GLib.Variant('a{sv}', None))
+        self.rescan_block_device(block)
 
         # Gets the new object after the rescan, then its 1st partition
         # which is the one we just created on our new partition table.
@@ -888,12 +883,10 @@ class LinuxTailsInstallerCreator(TailsInstallerCreator):
 
         # XXX: let's try to get a fresh system_partition object
         # (https://labs.riseup.net/code/issues/10720#note-28)
-        # This code duplicates some code we have above, so if this works,
+        self.rescan_block_device(block)
+
+        # XXX: this code duplicates some code we have above, so if this works,
         # we'll want to refactor.
-        self._udisksclient.settle()
-        self.flush_buffers(silent=True)
-        time.sleep(5)
-        block.call_rescan_sync(GLib.Variant('a{sv}', None))
         obj = self._get_object(self.drive['udi'])
         partition_table = obj.props.partition_table
         partitions = self._udisksclient.get_partitions(partition_table)
@@ -905,12 +898,7 @@ class LinuxTailsInstallerCreator(TailsInstallerCreator):
 
         # XXX: give the system some more time to recognize the updated partition
         # (https://labs.riseup.net/code/issues/10720#note-30)
-        # This code duplicates some code we have above, so if this works,
-        # we'll want to refactor.
-        self._udisksclient.settle()
-        self.flush_buffers(silent=True)
-        time.sleep(5)
-        block.call_rescan_sync(GLib.Variant('a{sv}', None))
+        self.rescan_block_device(block)
 
     def update_system_partition_properties(self):
         self.log.info(_('Updating properties of system partition %(system_partition)s') % {
@@ -1324,6 +1312,12 @@ class LinuxTailsInstallerCreator(TailsInstallerCreator):
             self.log.info(_("Synchronizing data on disk..."))
         self.popen('sync')
 
+    def rescan_block_device(self, block):
+        self._udisksclient.settle()
+        self.flush_buffers(silent=True)
+        time.sleep(5)
+        block.call_rescan_sync(GLib.Variant('a{sv}', None))
+
     def is_admin(self):
         return os.getuid() == 0
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/tails-installer.git



More information about the Pkg-privacy-commits mailing list