From 725e8dd67a14cdec821dbd74df4467d9a76558c7 Mon Sep 17 00:00:00 2001 From: Clark Williams Date: Tue, 11 Aug 2009 16:58:49 -0500 Subject: conditionalize import of uuid package and avoid dependent code if import fails (as it will on RHEL5) --- py/mock/backend.py | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/py/mock/backend.py b/py/mock/backend.py index 64d7455..3f60a08 100644 --- a/py/mock/backend.py +++ b/py/mock/backend.py @@ -13,8 +13,13 @@ import logging import os import shutil import stat -import uuid import grp +try: + import uuid + gotuuid = True +except: + gotuuid = False + # our imports import mock.util @@ -244,14 +249,15 @@ class Root(object): os.remove(hostspath) shutil.copy2('/etc/hosts', etcdir) - # Anything that tries to use libdbus inside the chroot will require this - # FIXME - merge this code with other OS-image building code - machine_uuid = uuid.uuid4().hex - dbus_uuid_path = self.makeChrootPath('var', 'lib', 'dbus', 'machine-id') - f = open(dbus_uuid_path, 'w') - f.write(machine_uuid) - f.write('\n') - f.close() + if gotuuid: + # Anything that tries to use libdbus inside the chroot will require this + # FIXME - merge this code with other OS-image building code + machine_uuid = uuid.uuid4().hex + dbus_uuid_path = self.makeChrootPath('var', 'lib', 'dbus', 'machine-id') + f = open(dbus_uuid_path, 'w') + f.write(machine_uuid) + f.write('\n') + f.close() # files in /etc that need doing for key in self.chroot_file_contents: -- cgit