Module EDInstallFabio_v0_0_7
[hide private]
[frames] | no frames]

Source Code for Module EDInstallFabio_v0_0_7

 1  #!/usr/bin/env python 
 2  # -*- coding: utf8 -*- 
 3  # 
 4  #    Project: EDNA Libraries 
 5  #             http://www.edna-site.org 
 6  # 
 7  #    File: "$Id$" 
 8  # 
 9  #    Copyright (C) European Synchrotron Radiation Facility, Grenoble, France 
10  # 
11  #    Principal authors:   Olof Svensson (svensson@esrf.fr) 
12  #                         Jerome Kieffer (Jerome.Kieffer@ESRF.eu) 
13  # 
14  #    This program is free software: you can redistribute it and/or modify 
15  #    it under the terms of the GNU General Public License as published by 
16  #    the Free Software Foundation, either version 3 of the License, or 
17  #    (at your option) any later version. 
18  # 
19  #    This program is distributed in the hope that it will be useful, 
20  #    but WITHOUT ANY WARRANTY; without even the implied warranty of 
21  #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
22  #    GNU General Public License for more details. 
23  # 
24  #    You should have received a copy of the GNU General Public License 
25  #    along with this program.  If not, see <http://www.gnu.org/licenses/>. 
26  # 
27  # 
28  # 
29   
30  """EDNA installer for Fabio v0.0.7""" 
31   
32  __authors__ = ["Olof Svensson", "Jerome Kieffer"] 
33  __contact__ = "svensson@esrf.fr" 
34  __license__ = "GPLv3+" 
35  __copyright__ = "European Synchrotron Radiation Facility, Grenoble, France" 
36  __date__ = "20110722" 
37  import os, sys 
38  if "EDNA_HOME" not in os.environ: 
39      EDNA_HOME = os.path.dirname(os.path.dirname(__file__)) 
40      os.environ["EDNA_HOME"] = EDNA_HOME 
41  else: 
42      EDNA_HOME = os.environ["EDNA_HOME"] 
43  kernel_src = os.path.join(EDNA_HOME, "kernel", "src") 
44  if kernel_src not in sys.path: 
45      sys.path.append(kernel_src) 
46   
47  from EDVerbose                  import EDVerbose 
48  from EDUtilsPlatform            import EDUtilsPlatform 
49  from EDUtilsLibraryInstaller    import EDUtilsLibraryInstaller, installLibrary 
50  from EDFactoryPluginStatic      import EDFactoryPluginStatic 
51   
52  moduleName = "fabio" 
53  modulePath = os.path.join(os.environ["EDNA_HOME"], "libraries", "FabIO-0.0.7", EDUtilsPlatform.architecture) 
54  moduleVersion = "0.0.7" 
55  ################################################################################ 
56  # Import the good version of FabIO ...  
57  ################################################################################ 
58  if os.name == "posix": 
59      oModule = EDFactoryPluginStatic.preImport(moduleName) 
60      if not oModule: 
61          oModule = EDFactoryPluginStatic.preImport(moduleName, modulePath) 
62          if oModule is None: 
63              installLibrary(modulePath) 
64              oModule = EDFactoryPluginStatic.preImport(moduleName, modulePath) 
65      try: 
66          version = oModule.version 
67      except AttributeError: 
68          version = "0.0.0" 
69   
70      if version.split(".") < moduleVersion.split("."): 
71          EDVerbose.screen("Wrong %s library:  %s " % (moduleName, version)) 
72          EDFactoryPluginStatic.unImport(moduleName) 
73          oModule = EDFactoryPluginStatic.preImport(moduleName, modulePath, moduleVersion) 
74   
75      if oModule is None: 
76          EDVerbose.ERROR("Unable to download, compile or install module %s" % moduleName) 
77      else: 
78          EDVerbose.screen("Version of %s: %s from %s" % (moduleName, oModule.version, oModule.__file__)) 
79