Ejemplo n.º 1
0
    def test_libc(self):
        lib, name = util.load_library(["c"])
        self.assertEqual(name, "c")

        lib2, name = util.load_library(["c"])
        self.assertTrue(lib is lib2)

        lib3, name = util.load_library(["c"], shared=False)
        self.assertTrue(lib2 is not lib3)
Ejemplo n.º 2
0
    def test_libc(self):
        lib, name = util.load_library(["c"])
        self.assertEqual(name, "c")

        lib2, name = util.load_library(["c"])
        self.assertTrue(lib is lib2)

        lib3, name = util.load_library(["c"], shared=False)
        self.assertTrue(lib2 is not lib3)
Ejemplo n.º 3
0
 def test_glib(self):
     if sys.platform == "darwin":
         fn = "libglib-2.0.0.dylib"
     else:
         fn = "libglib-2.0.so.0"
     lib, name = util.load_library([fn])
     self.assertEqual(name, fn)
     self.assertTrue(lib)
Ejemplo n.º 4
0
 def test_glib(self):
     if sys.platform == "darwin":
         fn = "libglib-2.0.0.dylib"
     else:
         fn = "libglib-2.0.so.0"
     lib, name = util.load_library([fn])
     self.assertEqual(name, fn)
     self.assertTrue(lib)
Ejemplo n.º 5
0
def init():
    """Initialise the bindings. Raises OSError if udev isn't installed"""

    global _classes

    udevlib, name = load_library(["libudev.so.1", "libudev.so.0"])
    if name.endswith("1"):
        version = 1
    else:
        version = 0

    for info in _classes:
        _wrap_class(udevlib, version, *info)
Ejemplo n.º 6
0
def init():
    """Initialise the bindings. Raises OSError if udev isn't installed"""

    global _classes

    udevlib, name = load_library(["libudev.so.1", "libudev.so.0"])
    if name.endswith("1"):
        version = 1
    else:
        version = 0

    for info in _classes:
        _wrap_class(udevlib, version, *info)
Ejemplo n.º 7
0
def set_process_title(title):
    """Sets process name as visible in ps or top. Requires ctypes libc
    and is almost certainly *nix-only. See issue 736"""

    if os.name == "nt":
        return

    try:
        libc = load_library(["libc.so.6", "c"])[0]
        # 15 = PR_SET_NAME, apparently
        libc.prctl(15, title, 0, 0, 0)
    except (OSError, AttributeError):
        print_d("Couldn't find module libc.so.6 (ctypes). "
                "Not setting process title.")
Ejemplo n.º 8
0
# (at your option) any later version.

import os
import ctypes

from quodlibet.util import load_library

from ._audio import AudioFile, translate_errors


extensions = [
    '.669', '.amf', '.ams', '.dsm', '.far', '.it', '.med', '.mod', '.mt2',
    '.mtm', '.okt', '.s3m', '.stm', '.ult', '.gdm', '.xm']

try:
    _modplug = load_library(
        ["libmodplug.so.1", "libmodplug.so.0", "libmodplug-1.dll"])[0]
except OSError:
    extensions = []
else:
    _modplug.ModPlug_GetName.argtypes = [ctypes.c_void_p]
    _modplug.ModPlug_GetName.restype = ctypes.c_char_p

    _modplug.ModPlug_Load.argtypes = [ctypes.c_void_p, ctypes.c_int]
    _modplug.ModPlug_Load.restype = ctypes.c_void_p

    _modplug.ModPlug_GetLength.argtypes = [ctypes.c_void_p]
    _modplug.ModPlug_GetLength.restype = ctypes.c_int

    _modplug.ModPlug_Unload.argtypes = [ctypes.c_void_p]
    _modplug.ModPlug_Unload.restype = None
Ejemplo n.º 9
0
# -*- coding: utf-8 -*-
# Copyright 2006 Lukas Lalinsky
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.

import sys
import ctypes

from quodlibet.util import load_library

try:
    _libxine, name = load_library(["libxine.so.2", "libxine.so.1"])
except OSError as e:
    raise ImportError(e)

if name.endswith("2"):
    _version = 2
else:
    _version = 1


class xine_event_t(ctypes.Structure):
    if _version == 1:
        _fields_ = [
            ('type', ctypes.c_int),
            ('stream', ctypes.c_void_p),
            ('data', ctypes.c_void_p),
            ('data_length', ctypes.c_int),
Ejemplo n.º 10
0
# -*- coding: utf-8 -*-
# Copyright 2006 Lukas Lalinsky
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.

import ctypes

from quodlibet.util import load_library

try:
    _libxine, name = load_library(["libxine.so.2", "libxine.so.1"])
except OSError as e:
    raise ImportError(e)

if name.endswith("2"):
    _version = 2
else:
    _version = 1


class xine_event_t(ctypes.Structure):
    if _version == 1:
        _fields_ = [
            ('type', ctypes.c_int),
            ('stream', ctypes.c_void_p),
            ('data', ctypes.c_void_p),
            ('data_length', ctypes.c_int),
        ]
Ejemplo n.º 11
0
"""ctypes bindings for libgpod.

Similar to the in libgpod included swig bindings except:
  - Functions for pixbuf handling are missing (itdb_artwork_*)
  - Swig wrappers (sw_*) from the swig bindings are mostly missing

These are needed since the original bindings depend on pygtk which breaks
in combination with pygobject.
"""

from quodlibet.util import load_library
from ctypes import *


try:
    _glib = load_library(["libglib-2.0.so.0", "libglib-2.0.so", "glib-2.0"])[0]
except OSError:
    raise ImportError("Couldn't find libglib-2.0")


try:
    _lib = load_library(["libgpod.so.4"])[0]
except OSError:
    raise ImportError("Couldn't find libgpod")


gchar_p = c_char_p
gchar = c_char
guchar = c_uint8
guchar_p = POINTER(c_uint8)
guint = c_uint
Ejemplo n.º 12
0
"""ctypes bindings for libgpod.

Similar to the in libgpod included swig bindings except:
  - Functions for pixbuf handling are missing (itdb_artwork_*)
  - Swig wrappers (sw_*) from the swig bindings are mostly missing

These are needed since the original bindings depend on pygtk which breaks
in combination with pygobject.
"""

from quodlibet.util import load_library
from ctypes import *


try:
    _glib = load_library(["libglib-2.0.so.0", "libglib-2.0.so", "glib-2.0"])[0]
except OSError:
    raise ImportError("Couldn't find libglib-2.0")


try:
    _lib = load_library(["libgpod.so.4"])[0]
except OSError:
    raise ImportError("Couldn't find libgpod")


gchar_p = c_char_p
gchar = c_char
guchar = c_uint8
guchar_p = POINTER(c_uint8)
guint = c_uint
Ejemplo n.º 13
0
# published by the Free Software Foundation

import os
import ctypes

from quodlibet.util import load_library

from ._audio import AudioFile, translate_errors


extensions = [
    '.669', '.amf', '.ams', '.dsm', '.far', '.it', '.med', '.mod', '.mt2',
    '.mtm', '.okt', '.s3m', '.stm', '.ult', '.gdm', '.xm']

try:
    _modplug = load_library(
        ["libmodplug.so.1", "libmodplug.so.0", "libmodplug-1.dll"])[0]
except OSError:
    extensions = []
else:
    _modplug.ModPlug_GetName.argtypes = [ctypes.c_void_p]
    _modplug.ModPlug_GetName.restype = ctypes.c_char_p

    _modplug.ModPlug_Load.argtypes = [ctypes.c_void_p, ctypes.c_int]
    _modplug.ModPlug_Load.restype = ctypes.c_void_p

    _modplug.ModPlug_GetLength.argtypes = [ctypes.c_void_p]
    _modplug.ModPlug_GetLength.restype = ctypes.c_int

    _modplug.ModPlug_Unload.argtypes = [ctypes.c_void_p]
    _modplug.ModPlug_Unload.restype = None