def test(self): environ = {'PYSTACIA_SKIP_PACKAGE': '1', 'PYSTACIA_SKIP_VIRTUAL_ENV': '1', 'PYSTACIA_SKIP_CWD': '1', 'PYSTACIA_SKIP_SYSTEM': '1'} self.assertRaisesRegexp(PystaciaException, 'Could not find or load', lambda: get_dll(environ=environ, isolated=True))
def c_call(obj, method, *args, **kw): if hasattr(obj.__class__, '_api_type'): api_type = obj.__class__._api_type else: api_type = obj msg = formattable('Translating method {0}.{1}') logger.debug(msg.format(api_type, method)) method_name, c_method = get_c_method(api_type, method) try: init = kw.pop('__init') except KeyError: init = True if init: get_dll() # if objects are casted here and then # there is only their resource passed # there is a risk that GC will collect # them and __del__ will be called between # driving Imagick to SIGSEGV # lets keep references to them keep_, args_, should_lock = prepare_args(c_method, obj, args) msg = formattable('Calling {0}') logger.debug(msg.format(method_name)) if pypy and should_lock: __lock.acquire() result = c_method(*args_) if pypy and should_lock: __lock.release() del keep_ return handle_result( result, c_method.restype, args_, c_method.argtypes)
def test(self): environ = { 'PYSTACIA_SKIP_PACKAGE': '1', 'PYSTACIA_SKIP_VIRTUAL_ENV': '1', 'PYSTACIA_SKIP_CWD': '1', 'PYSTACIA_SKIP_SYSTEM': '1' } self.assertRaisesRegexp( PystaciaException, 'Could not find or load', lambda: get_dll(environ=environ, isolated=True))
def get_c_method(api_type, method, throw=True): type_data = metadata[api_type] method_name = type_data['format'](method) if not throw and not hasattr(get_dll(False), method_name): return False c_method = getattr(get_dll(False), method_name) msg = formattable('Annoting {0}') logger.debug(msg.format(method_name)) method_data = type_data['symbols'][method] argtypes = method_data[0] if 'arg' in type_data: argtypes = (type_data['arg'],) + argtypes c_method.argtypes = argtypes restype = type_data.get('result', None) if len(method_data) == 2: restype = method_data[1] c_method.restype = restype return method_name, c_method
def get_options(): def get_options_hack(path): options = {} parser = ElementTree() root = parser.parse(path) for element in root.findall('configure'): attrs = element.attrib options[attrs['name']] = attrs['value'] return options dll_path = dirname(get_dll()._name) config_path = join(dll_path, 'configure.xml') if exists(config_path): return get_options_hack(config_path) else: return impl.get_options()
def info(): return { 'options': get_options(), 'formats': get_formats(), 'dll': get_dll()._name }
def info(): return {'options': get_options(), 'formats': get_formats(), 'dll': get_dll()._name}