()
| 181 | # - x86 or x86_64 |
| 182 | # - libsplinter-x-y.so / splinter-x-y.dll |
| 183 | def __locate_splinter(): |
| 184 | import os |
| 185 | import platform # Detect OS |
| 186 | |
| 187 | is_linux = platform.system() == 'Linux' |
| 188 | is_windows = platform.system() == 'Windows' |
| 189 | is_mac = platform.system() == 'Darwin' |
| 190 | |
| 191 | full_path = os.path.realpath(__file__) # Path to this file |
| 192 | # Go two folders up (yes, two is correct, because the first dirname gives us the directory this file resides in). |
| 193 | splinter_python_main_dir = os.path.dirname(os.path.dirname(os.path.dirname(full_path))) |
| 194 | |
| 195 | # Locate version file. If we cannot find it then we won't be able to find splinter either |
| 196 | version_file = os.path.join(splinter_python_main_dir, "version") |
| 197 | if not os.path.exists(version_file): |
| 198 | return None |
| 199 | |
| 200 | f = open(version_file) |
| 201 | splinter_version = f.read().strip() |
| 202 | |
| 203 | splinter_basename = "splinter-" + splinter_version |
| 204 | if is_windows: |
| 205 | splinter_name = splinter_basename + ".dll" |
| 206 | elif is_linux or is_mac: |
| 207 | splinter_name = "lib" + splinter_basename + ".so" |
| 208 | else: |
| 209 | raise("Unknown platform: " + platform.system()) |
| 210 | |
| 211 | operating_system = "unknown" |
| 212 | if is_linux: |
| 213 | operating_system = "linux" |
| 214 | elif is_windows: |
| 215 | operating_system = "windows" |
| 216 | elif is_mac: |
| 217 | operating_system = "osx" |
| 218 | |
| 219 | lib_splinter = os.path.join(splinter_python_main_dir, "lib", operating_system, get_architecture(), splinter_name) |
| 220 | |
| 221 | if os.path.exists(lib_splinter): |
| 222 | return lib_splinter |
| 223 | |
| 224 | return None |
| 225 | |
| 226 | |
| 227 | def _call(function, *args): |
no test coverage detected