---
imgcreate/creator.py | 18 ++++++++++++++----
imgcreate/live.py | 16 ++++++++++++----
2 files changed, 26 insertions(+), 8 deletions(-)
diff --git a/imgcreate/creator.py b/imgcreate/creator.py
index 519735e..72ab132 100644
--- a/imgcreate/creator.py
+++ b/imgcreate/creator.py
@@ -169,7 +169,10 @@ class ImageCreator(object):
By default, this moves the install root into _outdir.
"""
- shutil.move(self._instroot, self._outdir + "/" + self.name)
+ try:
+ os.rename(self._instroot, self._outdir + "/" + self.name)
+ except Exception, e:
+ shutil.move(self._instroot, self._outdir + "/" + self.name)
def _get_required_packages(self):
"""Return a list of required packages.
@@ -750,8 +753,12 @@ class ImageCreator(object):
self._stage_final_image()
for f in os.listdir(self._outdir):
- shutil.move(os.path.join(self._outdir, f),
- os.path.join(destdir, f))
+ try:
+ os.rename(os.path.join(self._outdir, f),
+ os.path.join(destdir, f))
+ except Exception, e:
+ shutil.move(os.path.join(self._outdir, f),
+ os.path.join(destdir, f))
def create(self):
"""Install, configure and package an image.
@@ -932,4 +939,7 @@ class LoopImageCreator(ImageCreator):
def _stage_final_image(self):
self._resparse()
- shutil.move(self._image, self._outdir + "/" + self.name + ".img")
+ try:
+ os.rename(self._image, self._outdir + "/" + self.name + ".img")
+ except Exception, e:
+ shutil.move(self._image, self._outdir + "/" + self.name + ".img")
diff --git a/imgcreate/live.py b/imgcreate/live.py
index 17d3037..eab7be5 100644
--- a/imgcreate/live.py
+++ b/imgcreate/live.py
@@ -268,12 +268,20 @@ class LiveImageCreatorBase(LoopImageCreator):
self._image, minimal_size)
if self.skip_compression:
- shutil.move(self._image, self.__isodir + "/LiveOS/ext3fs.img")
+ try:
+ os.rename(self._image, self.__isodir + "/LiveOS/ext3fs.img")
+ except Execption, e:
+ shutil.move(self._image, self.__isodir + "/LiveOS/ext3fs.img")
else:
makedirs(os.path.join(os.path.dirname(self._image), "LiveOS"))
- shutil.move(self._image,
- os.path.join(os.path.dirname(self._image),
- "LiveOS", "ext3fs.img"))
+ try:
+ os.rename(self._image,
+ os.path.join(os.path.dirname(self._image),
+ "LiveOS", "ext3fs.img"))
+ except Exception, e:
+ shutil.move(self._image,
+ os.path.join(os.path.dirname(self._image),
+ "LiveOS", "ext3fs.img"))
mksquashfs(os.path.dirname(self._image),
self.__isodir + "/LiveOS/squashfs.img")
--
1.5.5.1