[Pkg-privacy-commits] [tails-installer] 31/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 b9ca317afbc860cc8aabee80cfd974b820a9f042
Author: intrigeri <intrigeri at boum.org>
Date: Thu Jul 21 17:29:44 2016 +0000
Refactor duplicated code into a function.
---
tails_installer/creator.py | 31 ++++++++++++++-----------------
1 file changed, 14 insertions(+), 17 deletions(-)
diff --git a/tails_installer/creator.py b/tails_installer/creator.py
index 397377b..154fbb2 100755
--- a/tails_installer/creator.py
+++ b/tails_installer/creator.py
@@ -864,15 +864,10 @@ class LinuxTailsInstallerCreator(TailsInstallerCreator):
raise
# Rescan the device as it seems this is not always done automatically.
- self.rescan_block_device(block)
-
- # Gets the new object after the rescan, then its 1st partition
+ # And get the new object after the rescan, then its 1st partition
# which is the one we just created on our new partition table.
- obj = self._get_object(self.drive['udi'])
- partition_table = obj.props.partition_table
- partitions = self._udisksclient.get_partitions(partition_table)
- self.log.debug("partitions: %(partitions)s" % {'partitions': partitions})
- system_partition = partitions[0]
+ self.rescan_block_device(block)
+ system_partition = self.first_partition(self.drive['udi'])
# Sets the partition type that is not set by call_create_partition_sync...
# because it is not implemented in UDisks as of version 2.1.5 (see
@@ -881,17 +876,10 @@ class LinuxTailsInstallerCreator(TailsInstallerCreator):
# XXX: sometimes fails (https://labs.riseup.net/code/issues/10987)
system_partition.call_set_type_sync(ESP_GUID, GLib.Variant('a{sv}', None))
- # XXX: let's try to get a fresh system_partition object
+ # Get a fresh system_partition object
# (https://labs.riseup.net/code/issues/10720#note-28)
self.rescan_block_device(block)
-
- # XXX: this code duplicates some code we have above, so if this works,
- # we'll want to refactor.
- obj = self._get_object(self.drive['udi'])
- partition_table = obj.props.partition_table
- partitions = self._udisksclient.get_partitions(partition_table)
- self.log.debug("partitions: %(partitions)s" % {'partitions': partitions})
- system_partition = partitions[0]
+ system_partition = self.first_partition(self.drive['udi'])
# XXX: sometimes fails (https://labs.riseup.net/code/issues/10987)
self._set_partition_flags(system_partition, SYSTEM_PARTITION_FLAGS)
@@ -1081,6 +1069,15 @@ class LinuxTailsInstallerCreator(TailsInstallerCreator):
udi = self.drive['udi']
return self._udisksclient.get_object(udi)
+ def first_partition(self, udi=None):
+ """Return the UDisks2.Partition object for the first partition on the drive"""
+ if not udi:
+ udi = self.drive['udi']
+ obj = self._get_object(udi)
+ partition_table = obj.props.partition_table
+ partitions = self._udisksclient.get_partitions(partition_table)
+ return partitions[0]
+
def terminate(self):
for pid in self.pids:
try:
--
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