Skip to content
This repository has been archived by the owner on Aug 5, 2022. It is now read-only.

Commit

Permalink
change __imgdir to protect member
Browse files Browse the repository at this point in the history
Change-Id: I2da8fc9d549374877f00c51924df4f7d0425d2c7
Signed-off-by: Gui Chen <gui.chen@intel.com>
  • Loading branch information
Gui Chen committed Sep 29, 2014
1 parent aea6d2f commit 1d3d84d
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions mic/imager/loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def __init__(self, creatoropts=None, pkgmgr=None,
self.__fsopts = None
self._instloops = []

self.__imgdir = None
self._imgdir = None

if self.ks:
self.__image_size = kickstart.get_image_size(self.ks,
Expand Down Expand Up @@ -213,9 +213,9 @@ def __set_fslabel(self, val):
fslabel = property(__get_fslabel, __set_fslabel)

def __get_image(self):
if self.__imgdir is None:
if self._imgdir is None:
raise CreatorError("_image is not valid before calling mount()")
return os.path.join(self.__imgdir, self._img_name)
return os.path.join(self._imgdir, self._img_name)
#The location of the image file.
#
#This is the path to the filesystem image. Subclasses may use this path
Expand Down Expand Up @@ -304,8 +304,8 @@ def _base_on(self, base_on=None):
shutil.copyfile(base_on, self._image)

def _check_imgdir(self):
if self.__imgdir is None:
self.__imgdir = self._mkdtemp()
if self._imgdir is None:
self._imgdir = self._mkdtemp()


#
Expand All @@ -314,7 +314,7 @@ def _check_imgdir(self):
def _mount_instroot(self, base_on=None):

if base_on and os.path.isfile(base_on):
self.__imgdir = os.path.dirname(base_on)
self._imgdir = os.path.dirname(base_on)
imgname = os.path.basename(base_on)
self._base_on(base_on)
self._set_image_size(misc.get_file_size(self._image))
Expand Down Expand Up @@ -350,7 +350,7 @@ def _mount_instroot(self, base_on=None):
raise MountError('Cannot support fstype: %s' % fstype)

loop['loop'] = MyDiskMount(fs.SparseLoopbackDisk(
os.path.join(self.__imgdir, imgname),
os.path.join(self._imgdir, imgname),
size),
mp,
fstype,
Expand Down Expand Up @@ -388,7 +388,7 @@ def _stage_final_image(self):
self._resparse()

for item in self._instloops:
imgfile = os.path.join(self.__imgdir, item['name'])
imgfile = os.path.join(self._imgdir, item['name'])
if item['fstype'] == "ext4":
runner.show('/sbin/tune2fs -O ^huge_file,extents,uninit_bg %s '
% imgfile)
Expand All @@ -402,13 +402,13 @@ def _stage_final_image(self):
self.image_files.setdefault('image_files', []).append(item['name'])

if not self.pack_to:
for item in os.listdir(self.__imgdir):
shutil.move(os.path.join(self.__imgdir, item),
for item in os.listdir(self._imgdir):
shutil.move(os.path.join(self._imgdir, item),
os.path.join(self._outdir, item))
else:
msger.info("Pack all loop images together to %s" % self.pack_to)
dstfile = os.path.join(self._outdir, self.pack_to)
packing(dstfile, self.__imgdir)
packing(dstfile, self._imgdir)
self.image_files['image_files'] = [self.pack_to]


Expand All @@ -432,7 +432,7 @@ def copy_attachment(self):
for item in self._attachment:
if not os.path.exists(item):
continue
dpath = os.path.join(self.__imgdir, os.path.basename(item))
dpath = os.path.join(self._imgdir, os.path.basename(item))
msger.verbose("Copy attachment %s to %s" % (item, dpath))
shutil.copy(item, dpath)

Expand Down

0 comments on commit 1d3d84d

Please sign in to comment.