def find_audio_sink(): """Get the best audio sink available. Returns (element, description) or raises PlayerError. """ if is_windows(): sinks = [ "directsoundsink", "autoaudiosink", ] elif is_linux() and pulse_is_running(): sinks = [ "pulsesink", ] else: sinks = [ "autoaudiosink", # plugins-good "pulsesink", # plugins-good "alsasink", # plugins-base ] for name in sinks: element = Gst.ElementFactory.make(name, None) if element is not None: return (element, name) else: details = " (%s)" % ", ".join(sinks) if sinks else "" raise PlayerError(_("No GStreamer audio sink found") + details)
class Ttrash(TestCase): def setUp(self): config.init() def tearDown(self): config.quit() def test_use_trash_is_false_on_non_posix(self): old_os_name = os.name try: os.name = 'not posix' self.assertFalse(use_trash()) finally: os.name = old_os_name def test_use_trash_is_false_on_darwin(self): old_os_name = os.name old_sys_platform = sys.platform try: os.name = 'posix' sys.platform = 'darwin' self.assertFalse(use_trash()) finally: os.name = old_os_name sys.platform = old_sys_platform def test_use_trash_is_true_by_default_on_posix(self): old_os_name = os.name old_sys_platform = sys.platform try: os.name = 'posix' sys.platform = 'linux' if not is_flatpak(): self.assertTrue(use_trash()) finally: os.name = old_os_name sys.platform = old_sys_platform def test_use_trash_is_false_when_bypassed(self): old_os_name = os.name old_sys_platform = sys.platform try: config.set('settings', 'bypass_trash', "true") os.name = 'posix' sys.platform = 'linux' self.assertFalse(use_trash()) finally: os.name = old_os_name sys.platform = old_sys_platform @skipUnless(is_linux(), reason="Trash only supported for Linux") def test_trash_removes_file(self): filename = mkstemp()[1] with open(filename, "w") as f: f.write("\n") self.failUnless(os.path.exists(filename)) trash(filename) self.failIf(os.path.exists(filename))
def iter_backends(): if is_linux(): from .gnome import GnomeSessionClient yield GnomeSessionClient from .xfce import XfceSessionClient yield XfceSessionClient from .xsmp import XSMPSessionClient yield XSMPSessionClient # dummy one last yield SessionClient
def sink_options(): # People with Jack running probably want it more than any other options if config.getboolean("player", "gst_use_jack") and jack_is_running(): print_d("Using JACK output via Gstreamer") return [AudioSinks.JACK] elif is_windows(): return [AudioSinks.DIRECTSOUND] elif is_linux() and pulse_is_running(): return [AudioSinks.PULSE] else: return [ AudioSinks.AUTO, AudioSinks.PULSE, AudioSinks.ALSA, ]
def get_indicator_impl(): """Returns a BaseIndicator implementation depending on the environ""" use_app_indicator = ( is_linux() and dbus_name_owned("org.kde.StatusNotifierWatcher")) print_d("use app indicator: %s" % use_app_indicator) if not use_app_indicator: return SystemTray else: try: from .appindicator import AppIndicator except ImportError as e: print_w(f"Loading AppIndicator failed ({e}). Using {SystemTray}") # no indicator, fall back return SystemTray else: return AppIndicator
# 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 pytest from gi.repository import Gio, Soup, GLib from urllib.request import urlopen, build_opener from tests import TestCase, skipIf from quodlibet.util import is_linux, get_ca_file @pytest.mark.network @skipIf(is_linux(), "not on linux") class Thttps(TestCase): """For Windows/OSX to check if we can create a TLS connection using both openssl and whatever backend soup/gio uses. """ GOOD = ["https://sha256.badssl.com/"] BAD = [ "https://expired.badssl.com/", "https://wrong.host.badssl.com/", "https://self-signed.badssl.com/", ] def test_urllib(self): for url in self.GOOD: urlopen(url, cafile=get_ca_file()).close()
# This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. import requests from gi.repository import Gio, Soup, GLib from tests import TestCase, skipIf, skipUnlessNetwork from quodlibet.util import is_linux, is_osx, get_ca_file from quodlibet.compat import urlopen, build_opener @skipUnlessNetwork @skipIf(is_linux(), "not on linux") class Thttps(TestCase): """For Windows/OSX to check if we can create a TLS connection using both openssl and whatever backend soup/gio uses. """ GOOD = ["https://sha256.badssl.com/"] BAD = [ "https://expired.badssl.com/", "https://wrong.host.badssl.com/", "https://self-signed.badssl.com/", ] def test_urllib(self): for url in self.GOOD: urlopen(url, cafile=get_ca_file()).close()