Package saga
[frames] | no frames]

Source Code for Package saga

  1  #  Copyright (c) 2005-2009 Hartmut Kaiser 
  2  #  
  3  #  Distributed under the Boost Software License, Version 1.0. (See accompanying 
  4  #  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 
  5   
  6  # This file must be located inside a directory named SAGA which in turn should  
  7  # be located in a directory listed in your PYTHON_PATH 
  8   
  9  import sys 
 10   
 11  required_ver_maj = str(2) 
 12  required_ver_min = str(7) 
 13  required_ver_sub = str(1) 
 14   
 15  python_version = str(sys.version[0:5]) 
 16  python_ver_maj = str(sys.version[0:1]) 
 17  python_ver_min = str(sys.version[2:3]) 
 18  python_ver_sub = str(sys.version[4:5]) 
 19   
 20  if (python_ver_maj != required_ver_maj or  
 21      python_ver_min != required_ver_min or 
 22      python_ver_sub != required_ver_sub): 
 23      sys.stderr.write("ERROR: The SAGA Python modules were compiled for " 
 24                       "Python "+required_ver_maj+"."+required_ver_min+"."+required_ver_sub+ 
 25                       " but you are using them with Python "+python_version+".\n") 
 26      exit(1) 
 27   
 28  from _engine import *         # import all classes from SAGA.engine 
 29   
 30  ############################################################################### 
 31  # try to load all the different packages, one at a time, and ignoring any errors 
 32  import os 
 33  SAGA_LOG = 0 
 34  try: 
 35      SAGA_LOG = long(os.getenv("SAGA_VERBOSE", "0")) 
 36  except: 
 37      pass 
 38   
 39  # load namespace package 
 40  try: 
 41      import saga.name_space 
 42      if (SAGA_LOG != 0): 
 43          print "Successfully loaded Python namespace package bindings" 
 44  except: 
 45      if (SAGA_LOG != 0): 
 46          print "Failed loading Python namespace package bindings" 
 47   
 48  # load filesystem package 
 49  try: 
 50      import saga.filesystem 
 51      if (SAGA_LOG != 0): 
 52          print "Successfully loaded Python filesystem package bindings" 
 53  except: 
 54      if (SAGA_LOG != 0): 
 55          print "Failed loading Python filesystem package bindings" 
 56   
 57  # load advert package 
 58  try: 
 59      import saga.advert 
 60      if (SAGA_LOG != 0): 
 61          print "Successfully loaded Python advert package bindings" 
 62  except: 
 63      if (SAGA_LOG != 0): 
 64          print "Failed loading Python advert package bindings" 
 65   
 66  # load job package 
 67  try: 
 68      import saga.job 
 69      if (SAGA_LOG != 0): 
 70          print "Successfully loaded Python job package bindings" 
 71  except: 
 72      if (SAGA_LOG != 0): 
 73          print "Failed loading Python job package bindings" 
 74   
 75  # load replica package 
 76  try: 
 77      import saga.replica 
 78      if (SAGA_LOG != 0): 
 79          print "Successfully loaded Python replica package bindings" 
 80  except: 
 81      if (SAGA_LOG != 0): 
 82          print "Failed loading Python replica package bindings" 
 83   
 84  # load cpr package 
 85  try: 
 86      import saga.cpr 
 87      if (SAGA_LOG != 0): 
 88          print "Successfully loaded Python cpr package bindings" 
 89  except:  
 90      if (SAGA_LOG != 0): 
 91          print "Failed loading Python cpr package bindings" 
 92   
 93  # load sd package 
 94  try: 
 95      import saga.sd 
 96      if (SAGA_LOG != 0): 
 97          print "Successfully loaded Python sd package bindings" 
 98  except:  
 99      if (SAGA_LOG != 0): 
100          print "Failed loading Python sd package bindings" 
101   
102  # load stream package 
103  try: 
104      import saga.stream 
105      if (SAGA_LOG != 0): 
106          print "Successfully loaded Python stream package bindings" 
107  except:  
108      if (SAGA_LOG != 0): 
109          print "Failed loading Python stream package bindings" 
110   
111  ############################################################################### 
112  # define classes needed for proper exception translation 
113  ############################################################################### 
114 -class exception(Exception):
115 - def __init__(self, error):
116 Exception.__init__(self) 117 self._pimpl = error
118
119 - def __str__(self):
120 return self._pimpl.get_message()
121
122 - def get_full_message(self):
123 return self._pimpl.get_full_message()
124
125 - def get_message(self):
126 return self._pimpl.get_message()
127
128 - def get_error(self):
129 return self._pimpl.get_error()
130
131 - def get_object(self):
132 return self._pimpl.get_object()
133
134 - def get_all_exceptions(self):
135 return self._pimpl.get_all_exceptions()
136
137 - def get_all_messages(self):
138 return self._pimpl.get_all_messages()
139
140 - def __getattribute__(self, attr):
141 my_pimpl = super(exception, self).__getattribute__("_pimpl") 142 try: 143 return getattr(my_pimpl, attr) 144 except AttributeError: 145 return super(exception, self).__getattribute__(attr)
146 147 _engine.exception = exception 148 _engine._exception.py_err_class = exception 149 150 ###############################################################################
151 -class not_implemented(exception): pass
152 153 _engine.not_implemented = not_implemented 154 _engine._not_implemented.py_err_class = not_implemented 155 156 ###############################################################################
157 -class parameter_exception(exception): pass
158 159 _engine.parameter_exception = parameter_exception 160 _engine._parameter_exception.py_err_class = parameter_exception 161 162 ###############################################################################
163 -class incorrect_url(parameter_exception): pass
164 165 _engine.incorrect_url = incorrect_url 166 _engine._incorrect_url.py_err_class = incorrect_url 167 168 ###############################################################################
169 -class bad_parameter(parameter_exception): pass
170 171 _engine.bad_parameter = bad_parameter 172 _engine._bad_parameter.py_err_class = bad_parameter 173 174 ###############################################################################
175 -class state_exception(exception): pass
176 177 _engine.state_exception = state_exception 178 _engine._state_exception.py_err_class = state_exception 179 180 ###############################################################################
181 -class already_exists(state_exception): pass
182 183 _engine.already_exists = already_exists 184 _engine._already_exists.py_err_class = already_exists 185 186 ###############################################################################
187 -class does_not_exist(state_exception): pass
188 189 _engine.does_not_exist = does_not_exist 190 _engine._does_not_exist.py_err_class = does_not_exist 191 192 ###############################################################################
193 -class incorrect_state(state_exception): pass
194 195 _engine.incorrect_state = incorrect_state 196 _engine._incorrect_state.py_err_class = incorrect_state 197 198 ###############################################################################
199 -class timeout(state_exception): pass
200 201 _engine.timeout = timeout 202 _engine._timeout.py_err_class = timeout 203 204 ###############################################################################
205 -class security_exception(exception): pass
206 207 _engine.security_exception = security_exception 208 _engine._security_exception.py_err_class = security_exception 209 210 ###############################################################################
211 -class permission_denied(security_exception): pass
212 213 _engine.permission_denied = permission_denied 214 _engine._permission_denied.py_err_class = permission_denied 215 216 ###############################################################################
217 -class authorization_failed(security_exception): pass
218 219 _engine.authorization_failed = authorization_failed 220 _engine._authorization_failed.py_err_class = authorization_failed 221 222 ###############################################################################
223 -class authentication_failed(security_exception): pass
224 225 _engine.authentication_failed = authentication_failed 226 _engine._authentication_failed.py_err_class = authentication_failed 227 228 ###############################################################################
229 -class no_success(exception): pass
230 231 _engine.no_success = no_success 232 _engine._no_success.py_err_class = no_success 233