From: Ed Bartosh <ed.bartosh@linux.intel.com>
To: openembedded-core@lists.openembedded.org
Subject: [wic][PATCH 4/4] wic: pylinted partitionedfs.py
Date: Fri, 5 Jun 2015 09:13:09 +0300 [thread overview]
Message-ID: <1433484789-304-5-git-send-email-ed.bartosh@linux.intel.com> (raw)
In-Reply-To: <1433484789-304-1-git-send-email-ed.bartosh@linux.intel.com>
Fixed some pylint findings in partitionedfs.py
Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
diff --git a/scripts/lib/wic/utils/partitionedfs.py b/scripts/lib/wic/utils/partitionedfs.py
index dcb63e5..902548f 100644
--- a/scripts/lib/wic/utils/partitionedfs.py
+++ b/scripts/lib/wic/utils/partitionedfs.py
@@ -31,7 +31,7 @@ GPT_OVERHEAD = 34
# Size of a sector in bytes
SECTOR_SIZE = 512
-class Image:
+class Image(object):
"""
Generic base object for an image.
@@ -58,14 +58,14 @@ class Image:
assert not self._partitions_layed_out
self.disks[disk_name] = \
- { 'disk': None, # Disk object
- 'numpart': 0, # Number of allocate partitions
- 'realpart': 0, # Number of partitions in the partition table
- 'partitions': [], # Indexes to self.partitions
- 'offset': 0, # Offset of next partition (in sectors)
- # Minimum required disk size to fit all partitions (in bytes)
- 'min_size': 0,
- 'ptable_format': "msdos" } # Partition table format
+ {'disk': None, # Disk object
+ 'numpart': 0, # Number of allocate partitions
+ 'realpart': 0, # Number of partitions in the partition table
+ 'partitions': [], # Indexes to self.partitions
+ 'offset': 0, # Offset of next partition (in sectors)
+ # Minimum required disk size to fit all partitions (in bytes)
+ 'min_size': 0,
+ 'ptable_format': "msdos"} # Partition table format
def add_disk(self, disk_name, disk_obj):
""" Add a disk object which have to be partitioned. More than one disk
@@ -97,20 +97,20 @@ class Image:
# We still need partition for "/" or non-subvolume
if mountpoint == "/" or not fsopts:
- part = { 'ks_pnum' : ks_pnum, # Partition number in the KS file
- 'size': size, # In sectors
- 'mountpoint': mountpoint, # Mount relative to chroot
- 'source_file': source_file, # partition contents
- 'fstype': fstype, # Filesystem type
- 'fsopts': fsopts, # Filesystem mount options
- 'label': label, # Partition label
- 'disk_name': disk_name, # physical disk name holding partition
- 'device': None, # kpartx device node for partition
- 'num': None, # Partition number
- 'boot': boot, # Bootable flag
- 'align': align, # Partition alignment
- 'no_table' : no_table, # Partition does not appear in partition table
- 'part_type' : part_type } # Partition type
+ part = {'ks_pnum': ks_pnum, # Partition number in the KS file
+ 'size': size, # In sectors
+ 'mountpoint': mountpoint, # Mount relative to chroot
+ 'source_file': source_file, # partition contents
+ 'fstype': fstype, # Filesystem type
+ 'fsopts': fsopts, # Filesystem mount options
+ 'label': label, # Partition label
+ 'disk_name': disk_name, # physical disk name holding partition
+ 'device': None, # kpartx device node for partition
+ 'num': None, # Partition number
+ 'boot': boot, # Bootable flag
+ 'align': align, # Partition alignment
+ 'no_table' : no_table, # Partition does not appear in partition table
+ 'part_type' : part_type} # Partition type
self.__add_partition(part)
@@ -213,7 +213,7 @@ class Image:
# Once all the partitions have been layed out, we can calculate the
# minumim disk sizes.
- for disk_name, d in self.disks.items():
+ for d in self.disks.values():
d['min_size'] = d['offset']
if d['ptable_format'] == "gpt":
d['min_size'] += GPT_OVERHEAD
@@ -314,14 +314,14 @@ class Image:
def cleanup(self):
if self.disks:
- for dev in self.disks.keys():
+ for dev in self.disks:
d = self.disks[dev]
try:
d['disk'].cleanup()
except:
pass
- def __write_partition(self, num, source_file, start, size):
+ def __write_partition(self, num, source_file, start, size, image_file):
"""
Install source_file contents into a partition.
"""
@@ -330,23 +330,20 @@ class Image:
# Start is included in the size so need to substract one from the end.
end = start + size - 1
- msger.debug("Installed %s in partition %d, sectors %d-%d, size %d sectors" % (source_file, num, start, end, size))
+ msger.debug("Installed %s in partition %d, sectors %d-%d, "
+ "size %d sectors" % (source_file, num, start, end, size))
dd_cmd = "dd if=%s of=%s bs=%d seek=%d count=%d conv=notrunc" % \
- (source_file, self.image_file, self.sector_size, start, size)
+ (source_file, image_file, self.sector_size, start, size)
exec_cmd(dd_cmd)
def assemble(self, image_file):
msger.debug("Installing partitions")
- self.image_file = image_file
-
for p in self.partitions:
- d = self.disks[p['disk_name']]
-
self.__write_partition(p['num'], p['source_file'],
- p['start'], p['size'])
+ p['start'], p['size'], image_file)
def create(self):
for dev in self.disks.keys():
--
2.1.4
prev parent reply other threads:[~2015-06-05 8:06 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-05 6:13 [wic][PATCH 0/4] Code cleanup and refactoring Ed Bartosh
2015-06-05 6:13 ` [wic][PATCH 1/4] wic: removed exec_cmd_quiet and exec_native_cmd_quiet Ed Bartosh
2015-06-05 6:13 ` [wic][PATCH 2/4] wic: move checks to exec_native_cmd Ed Bartosh
2015-06-05 6:13 ` [wic][PATCH 3/4] wic: replaced __run_parted with exec_native_cmd Ed Bartosh
2015-06-05 16:33 ` Ross Burton
2015-06-08 9:46 ` Ed Bartosh
2015-06-05 6:13 ` Ed Bartosh [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1433484789-304-5-git-send-email-ed.bartosh@linux.intel.com \
--to=ed.bartosh@linux.intel.com \
--cc=openembedded-core@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.