Exemplo n.º 1
0
cdll = ctypes.cdll
if iswindows:
    class Structure(_Structure):
        _pack_ = 1
    _librar_name = 'unrar'
    cdll = ctypes.windll
else:
    Structure = _Structure
if hasattr(sys, 'frozen') and iswindows:
    lp = os.path.join(os.path.dirname(sys.executable), 'DLLs', 'unrar.dll')
    _libunrar = cdll.LoadLibrary(lp)
elif hasattr(sys, 'frozen_path'):
    lp = os.path.join(sys.frozen_path, 'lib', 'libunrar.so')
    _libunrar = cdll.LoadLibrary(lp)
else:
    _libunrar = load_library(_librar_name, cdll)

RAR_OM_LIST    = 0
RAR_OM_EXTRACT = 1

ERAR_END_ARCHIVE      =  10
ERAR_NO_MEMORY        =  11
ERAR_BAD_DATA         =  12
ERAR_BAD_ARCHIVE      =  13
ERAR_UNKNOWN_FORMAT   =  14
ERAR_EOPEN            =  15
ERAR_ECREATE          =  16
ERAR_ECLOSE           =  17
ERAR_EREAD            =  18
ERAR_EWRITE           =  19
ERAR_SMALL_BUF        =  20
Exemplo n.º 2
0
from errno import EBUSY, ENOMEM

from calibre import iswindows, isosx, isbsd, load_library

_libusb_name = 'libusb'
PATH_MAX = 511 if iswindows else 1024 if (isosx or isbsd) else 4096
if iswindows:
    class Structure(_Structure):
        _pack_ = 1
    _libusb_name = 'libusb0'
else:
    Structure = _Structure

try:
    try:
        _libusb = load_library(_libusb_name, cdll)
    except OSError:
        _libusb = cdll.LoadLibrary('libusb-0.1.so.4')
    has_library = True
except:
    _libusb = None
    has_library = False

class DeviceDescriptor(Structure):
    _fields_ = [\
                ('Length', c_ubyte), \
                ('DescriptorType', c_ubyte), \
                ('bcdUSB', c_ushort), \
                ('DeviceClass', c_ubyte), \
                ('DeviceSubClass', c_ubyte), \
                ('DeviceProtocol', c_ubyte), \
Exemplo n.º 3
0
from calibre import load_library

try:
    _lib_name = 'libBambookCore'
    cdll = ctypes.cdll
    if iswindows:
        _lib_name = 'BambookCore'
    if hasattr(sys, 'frozen') and iswindows:
        lp = os.path.join(os.path.dirname(sys.executable), 'DLLs',
                          'BambookCore.dll')
        lib_handle = cdll.LoadLibrary(lp)
    elif hasattr(sys, 'frozen_path'):
        lp = os.path.join(sys.frozen_path, 'lib', 'libBambookCore.so')
        lib_handle = cdll.LoadLibrary(lp)
    else:
        lib_handle = load_library(_lib_name, cdll)
except:
    lib_handle = None

text_encoding = 'utf-8'
if iswindows:
    text_encoding = 'mbcs'


def is_bambook_lib_ready():
    return lib_handle != None


# Constant
DEFAULT_BAMBOOK_IP = '192.168.250.2'
BAMBOOK_SDK_VERSION = 0x00090000
Exemplo n.º 4
0
from calibre import iswindows, isosx, isbsd, load_library

_libusb_name = 'libusb'
PATH_MAX = 511 if iswindows else 1024 if (isosx or isbsd) else 4096
if iswindows:

    class Structure(_Structure):
        _pack_ = 1

    _libusb_name = 'libusb0'
else:
    Structure = _Structure

try:
    try:
        _libusb = load_library(_libusb_name, cdll)
    except OSError:
        _libusb = cdll.LoadLibrary('libusb-0.1.so.4')
    has_library = True
except:
    _libusb = None
    has_library = False


class DeviceDescriptor(Structure):
    _fields_ = [\
                ('Length', c_ubyte), \
                ('DescriptorType', c_ubyte), \
                ('bcdUSB', c_ushort), \
                ('DeviceClass', c_ubyte), \
                ('DeviceSubClass', c_ubyte), \
Exemplo n.º 5
0
from calibre.constants import iswindows
from calibre import load_library

try:
    _lib_name = 'libBambookCore'
    cdll = ctypes.cdll
    if iswindows:
        _lib_name = 'BambookCore'
    if hasattr(sys, 'frozen') and iswindows:
        lp = os.path.join(os.path.dirname(sys.executable), 'DLLs', 'BambookCore.dll')
        lib_handle = cdll.LoadLibrary(lp)
    elif hasattr(sys, 'frozen_path'):
        lp = os.path.join(sys.frozen_path, 'lib', 'libBambookCore.so')
        lib_handle = cdll.LoadLibrary(lp)
    else:
        lib_handle = load_library(_lib_name, cdll)
except:
    lib_handle = None

text_encoding = 'utf-8'
if iswindows:
    text_encoding = 'mbcs'

def is_bambook_lib_ready():
    return lib_handle != None

# Constant
DEFAULT_BAMBOOK_IP = '192.168.250.2'
BAMBOOK_SDK_VERSION = 0x00090000
BR_SUCC             = 0     # 操作成功
BR_FAIL             = 1001  # 操作失败