- Timestamp:
- 02/18/21 18:58:55 (4 years ago)
- Location:
- framspy
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
framspy/frams-test.py
r1081 r1083 2 2 import frams 3 3 4 frams path = sys.argv[1] # set to the directory where Framsticks binaries and libraries exist5 frams.init(frams path, "-Ddata") # "-D"+os.path.join(framspath,"data")) # not possible (maybe python windows issue) because of the need for os.chdir(). So we assume "data" is where the dll/so is4 frams_path = sys.argv[1] # set to the directory where Framsticks binaries and libraries exist 5 frams.init(frams_path, sys.argv[2] if len(sys.argv) > 2 else None, "-Ddata") # "-D"+os.path.join(framspath,"data")) # not possible (maybe python windows issue) because of the need for os.chdir(). So we assume "data" is where the dll/so is 6 6 7 7 print('Available objects:', dir(frams)) -
framspy/frams.py
r1081 r1083 20 20 21 21 class ExtValue(object): 22 """All Framsticks objects and values are instances of this class. """22 """All Framsticks objects and values are instances of this class. Read the documentation of the 'frams' module for more information.""" 23 23 24 24 _reInsideParens = re.compile('\((.*)\)') … … 248 248 249 249 250 def init(lib_path, *args): 250 def init(lib_path, lib_name, *args): 251 """ 252 Initializes the connection to Framsticks dll/so. 253 254 :param lib_path: the path where the dll/so file can be found 255 :param lib_name: the name of the dll/so (a complete name including file name extension) or None if you want to use the default name 256 :param args: optional arguments to pass to Framsticks initialization (try "-h") 257 """ 251 258 original_dir = os.getcwd() 252 os.chdir(lib_path) # because under Windows, frams .dll requires other dll's which reside in the same directory, so we must change current dir for them to be found while loading the main dll253 global c_api # access global variable 254 c_api = ctypes.CDLL( 'frams-objects.so' if os.name == 'posix' else 'frams-objects.dll')259 os.chdir(lib_path) # because under Windows, frams-objects.dll requires other dll's which reside in the same directory, so we must change current dir for them to be found while loading the main dll 260 global c_api # access global variable to initialize it 261 c_api = ctypes.CDLL(lib_name if lib_name is not None else 'frams-objects.so' if os.name == 'posix' else 'frams-objects.dll') 255 262 os.chdir(original_dir) 256 263
Note: See TracChangeset
for help on using the changeset viewer.