mailr17786 - in /trunk: ansi.py dep_check.py info.py


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by edward on October 09, 2012 - 12:52:
Author: bugman
Date: Tue Oct  9 12:52:34 2012
New Revision: 17786

URL: http://svn.gna.org/viewcvs/relax?rev=17786&view=rev
Log:
Python 2.4 fixes - the ctypes module does not exist in Python versions 2.4 
and lower.

This is only used for some non-essential functionality on MS Windows, so now 
it is deactivated if
not present.


Modified:
    trunk/ansi.py
    trunk/dep_check.py
    trunk/info.py

Modified: trunk/ansi.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/ansi.py?rev=17786&r1=17785&r2=17786&view=diff
==============================================================================
--- trunk/ansi.py (original)
+++ trunk/ansi.py Tue Oct  9 12:52:34 2012
@@ -22,8 +22,14 @@
 # Module docstring.
 """Module containing ANSI escape sequences and helper functions for colour 
terminal output."""
 
+# Dependencies.
+import dep_check
+
 # Python module imports.
-import ctypes
+if dep_check.ctypes_module:
+    import ctypes
+else:
+    ctypes = None
 import sys
 
 # The relax prompt.

Modified: trunk/dep_check.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/dep_check.py?rev=17786&r1=17785&r2=17786&view=diff
==============================================================================
--- trunk/dep_check.py (original)
+++ trunk/dep_check.py Tue Oct  9 12:52:34 2012
@@ -205,6 +205,16 @@
         xml_version = ''
         xml_type = ''
 
+# ctypes module.
+try:
+    import ctypes
+    from ctypes import Structure
+    ctypes_module = True
+except ImportError:
+    message = sys.exc_info()[1]
+    ctypes_module = False
+    ctypes_module_message = message.args[0]
+
 
 
 # Compiled C modules.

Modified: trunk/info.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/info.py?rev=17786&r1=17785&r2=17786&view=diff
==============================================================================
--- trunk/info.py (original)
+++ trunk/info.py Tue Oct  9 12:52:34 2012
@@ -22,10 +22,18 @@
 # Module docstring.
 """Module containing the introductory text container."""
 
+# Dependencies.
+import dep_check
+
 # Python module imports.
-import ctypes
-if hasattr(ctypes, 'windll'):
-    import ctypes.wintypes
+if dep_check.ctypes_module:
+    import ctypes
+    from ctypes import Structure
+    if hasattr(ctypes, 'windll'):
+        import ctypes.wintypes
+else:
+    ctypes = None
+    Structure = object
 import numpy
 from os import environ, waitpid
 import platform
@@ -34,7 +42,6 @@
 from textwrap import wrap
 
 # relax module imports.
-import dep_check
 from status import Status; status = Status()
 from version import version, version_full
 
@@ -695,7 +702,7 @@
 
 
 
-class MemoryStatusEx(ctypes.Structure):
+class MemoryStatusEx(Structure):
     """Special object for obtaining hardware info in MS Windows."""
 
     if hasattr(ctypes, 'windll'):




Related Messages


Powered by MHonArc, Updated Tue Oct 09 13:00:02 2012