Add stub uuid function to make this module import when running under python2.4
authorDiane Trout <diane@caltech.edu>
Wed, 17 Jun 2009 19:09:50 +0000 (19:09 +0000)
committerDiane Trout <diane@caltech.edu>
Wed, 17 Jun 2009 19:09:50 +0000 (19:09 +0000)
htsworkflow/frontend/inventory/models.py

index 8f54fc3abcc87a43739f34c0d1c40a487fd1a69a..5926107d3ee010f209503717e79d1afd288b03be 100644 (file)
@@ -1,3 +1,5 @@
+import logging
+
 from django.db import models
 from django.db.models.signals import pre_save
 
@@ -5,7 +7,16 @@ from htsworkflow.frontend.samples.models import Library
 from htsworkflow.frontend.experiments.models import FlowCell
 
 
-import uuid
+try:
+    import uuid
+except ImportError, e:
+    # Some systems are using python 2.4, which doesn't have uuid
+    # this is a stub
+    logging.warning('Real uuid is not available, initializing fake uuid module')
+    class uuid:
+        def uuid1(self):
+            self.hex = None
+            return self
 
 def _assign_uuid(sender, instance, **kwargs):
     """
@@ -123,4 +134,5 @@ class LongTermStorage(models.Model):
     storage_devices = models.ManyToManyField(Item)
     
     def __unicode__(self):
-        return u"%s: %s" % (str(self.flowcell), ', '.join([ str(s) for s in self.storage_devices.iterator() ]))
\ No newline at end of file
+        return u"%s: %s" % (str(self.flowcell), ', '.join([ str(s) for s in self.storage_devices.iterator() ]))
+