本文整理汇总了Python中quodlibet.util.is_windows函数的典型用法代码示例。如果您正苦于以下问题:Python is_windows函数的具体用法?Python is_windows怎么用?Python is_windows使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了is_windows函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _init_python
def _init_python():
if PY2 or is_release():
MinVersions.PYTHON2.check(sys.version_info)
else:
# for non release builds we allow Python3
MinVersions.PYTHON3.check(sys.version_info)
if is_osx():
# We build our own openssl on OSX and need to make sure that
# our own ca file is used in all cases as the non-system openssl
# doesn't use the system certs
install_urllib2_ca_file()
if is_windows():
# Not really needed on Windows as pygi-aio seems to work fine, but
# wine doesn't have certs which we use for testing.
install_urllib2_ca_file()
if is_windows() and os.sep != "\\":
# In the MSYS2 console MSYSTEM is set, which breaks os.sep/os.path.sep
# If you hit this do a "setup.py clean -all" to get rid of the
# bytecode cache then start things with "MSYSTEM= ..."
raise AssertionError("MSYSTEM is set (%r)" % environ.get("MSYSTEM"))
if is_windows():
# gdbm is broken under msys2, this makes shelve use another backend
sys.modules["gdbm"] = None
sys.modules["_gdbm"] = None
logging.getLogger().addHandler(PrintHandler())
开发者ID:ZDBioHazard,项目名称:quodlibet,代码行数:30,代码来源:_init.py
示例2: test_constrains
def test_constrains(self):
if is_py2exe():
self.assertEqual(is_py2exe_console(), not is_py2exe_window())
self.assertTrue(is_windows())
if is_windows():
self.assertFalse(is_osx())
if is_osx():
self.assertFalse(is_windows())
开发者ID:ZDBioHazard,项目名称:quodlibet,代码行数:10,代码来源:test_util_environment.py
示例3: find_audio_sink
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)
开发者ID:ZDBioHazard,项目名称:quodlibet,代码行数:29,代码来源:util.py
示例4: _get_chooser
def _get_chooser(accept_label, cancel_label):
"""
Args:
accept_label (str)
cancel_label (str)
Returns:
Gtk.FileChooser
"""
if hasattr(Gtk, "FileChooserNative"):
FileChooser = Gtk.FileChooserNative
else:
FileChooser = Gtk.FileChooserDialog
# https://github.com/quodlibet/quodlibet/issues/2406
if is_windows() and gtk_version < (3, 22, 16):
FileChooser = Gtk.FileChooserDialog
chooser = FileChooser()
if hasattr(chooser, "set_accept_label"):
chooser.set_accept_label(accept_label)
else:
chooser.add_button(accept_label, Gtk.ResponseType.ACCEPT)
chooser.set_default_response(Gtk.ResponseType.ACCEPT)
if hasattr(chooser, "set_cancel_label"):
chooser.set_cancel_label(cancel_label)
else:
chooser.add_button(cancel_label, Gtk.ResponseType.CANCEL)
return chooser
开发者ID:zsau,项目名称:quodlibet,代码行数:32,代码来源:chooser.py
示例5: test_all
def test_all(self):
self.assertTrue(isinstance(is_unity(), bool))
self.assertTrue(isinstance(is_windows(), bool))
self.assertTrue(isinstance(is_osx(), bool))
self.assertTrue(isinstance(is_py2exe(), bool))
self.assertTrue(isinstance(is_py2exe_console(), bool))
self.assertTrue(isinstance(is_py2exe_window(), bool))
开发者ID:ZDBioHazard,项目名称:quodlibet,代码行数:7,代码来源:test_util_environment.py
示例6: create_pool
def create_pool():
if is_wine() or(PY3 and is_windows()):
# ProcessPoolExecutor is broken under wine, and under py3+msys2
# https://github.com/Alexpux/MINGW-packages/issues/837
return ThreadPoolExecutor(1)
else:
return ProcessPoolExecutor(None)
开发者ID:ZDBioHazard,项目名称:quodlibet,代码行数:7,代码来源:test_pep8.py
示例7: test_basic
def test_basic(self):
if is_windows():
res = split_scan_dirs(u":Z:\\foo:C:/windows:")
self.assertEquals(res, [u"Z:\\foo", u"C:/windows"])
else:
res = split_scan_dirs(":%s:%s:" % (STANDARD_PATH, OTHER_PATH))
self.assertEquals(res, [STANDARD_PATH, OTHER_PATH])
开发者ID:ZDBioHazard,项目名称:quodlibet,代码行数:7,代码来源:test_util_library.py
示例8: test_parse
def test_parse(self):
if is_windows():
return
data = (b'file:///foo/bar\nfile:///home/user\n'
b'file:///home/user/Downloads Downloads\n')
paths = parse_gtk_bookmarks(data)
assert all(isinstance(p, fsnative) for p in paths)
开发者ID:LudoBike,项目名称:quodlibet,代码行数:8,代码来源:test_qltk_filesel.py
示例9: set_scan_dirs
def set_scan_dirs(dirs):
"""Saves a list of fs paths which should be scanned
Args:
list
"""
assert all(isinstance(d, fsnative) for d in dirs)
if is_windows():
joined = fsnative(u":").join(dirs)
else:
joined = join_escape(dirs, fsnative(u":"))
config.setbytes("settings", "scan", fsn2bytes(joined, "utf-8"))
开发者ID:piotrdrag,项目名称:quodlibet,代码行数:14,代码来源:library.py
示例10: init_devices
def init_devices():
global devices
load_pyc = util.is_windows() or util.is_osx()
modules = load_dir_modules(dirname(__file__),
package=__package__,
load_compiled=load_pyc)
for mod in modules:
try:
devices.extend(mod.devices)
except AttributeError:
print_w("%r doesn't contain any devices." % mod.__name__)
devices.sort()
开发者ID:virtuald,项目名称:quodlibet,代码行数:15,代码来源:__init__.py
示例11: split_scan_dirs
def split_scan_dirs(joined_paths):
"""Returns a list of paths
Args:
joined_paths (fsnative)
Return:
list
"""
assert isinstance(joined_paths, fsnative)
if is_windows():
# we used to separate this config with ":", so this is tricky
return list(filter(None, re.findall(r"[a-zA-Z]:[\\/][^:]*", joined_paths)))
else:
return list(filter(None, split_escape(joined_paths, ":")))
开发者ID:piotrdrag,项目名称:quodlibet,代码行数:16,代码来源:library.py
示例12: _py3_to_py2
def _py3_to_py2(items):
is_win = is_windows()
new_list = []
for i in items:
inst = dict.__new__(i.__class__)
for key, value in i.items():
if key in ("~filename", "~mountpoint") and not is_win:
value = fsn2bytes(value, None)
try:
key = key.encode("ascii")
except UnicodeEncodeError:
pass
dict.__setitem__(inst, key, value)
new_list.append(inst)
return new_list
开发者ID:zsau,项目名称:quodlibet,代码行数:16,代码来源:_serialize.py
示例13: _init_python
def _init_python():
if PY2 or is_release():
MinVersions.PYTHON2.check(sys.version_info)
else:
# for non release builds we allow Python3
MinVersions.PYTHON3.check(sys.version_info)
if is_osx():
# We build our own openssl on OSX and need to make sure that
# our own ca file is used in all cases as the non-system openssl
# doesn't use the system certs
util.install_urllib2_ca_file()
if is_windows():
# Not really needed on Windows as pygi-aio seems to work fine, but
# wine doesn't have certs which we use for testing.
util.install_urllib2_ca_file()
开发者ID:gbtami,项目名称:quodlibet,代码行数:17,代码来源:__init__.py
示例14: init
def init():
"""Import all browsers from this package and from the user directory.
After this is called the global `browers` list will contain all
classes sorted by priority.
Can be called multiple times.
"""
global browsers, default
# ignore double init (for the test suite)
if browsers:
return
this_dir = os.path.dirname(__file__)
load_pyc = util.is_windows() or util.is_osx()
modules = load_dir_modules(this_dir,
package=__package__,
load_compiled=load_pyc)
user_dir = os.path.join(quodlibet.get_user_dir(), "browsers")
if os.path.isdir(user_dir):
modules += load_dir_modules(user_dir,
package="quodlibet.fake.browsers",
load_compiled=load_pyc)
for browser in modules:
try:
browsers.extend(browser.browsers)
except AttributeError:
print_w("%r doesn't contain any browsers." % browser.__name__)
def is_browser(Kind):
return isinstance(Kind, type) and issubclass(Kind, Browser)
browsers = filter(is_browser, browsers)
if not browsers:
raise SystemExit("No browsers found!")
browsers.sort(key=lambda Kind: Kind.priority)
try:
default = get("SearchBar")
except ValueError:
raise SystemExit("Default browser not found!")
开发者ID:Tjorriemorrie,项目名称:quodlibet,代码行数:46,代码来源:__init__.py
示例15: init
def init():
"""Load/Import all formats.
Before this is called loading a file and unpickling will not work.
"""
global mimes, loaders, types
MinVersions.MUTAGEN.check(mutagen.version)
base = util.get_module_dir()
load_pyc = util.is_windows() or util.is_osx()
formats = load_dir_modules(base,
package=__package__,
load_compiled=load_pyc)
module_names = []
for format in formats:
name = format.__name__
for ext in format.extensions:
loaders[ext] = format.loader
types.update(format.types)
if format.extensions:
for type_ in format.types:
mimes.update(type_.mimes)
module_names.append(name.split(".")[-1])
# Migrate pre-0.16 library, which was using an undocumented "feature".
sys.modules[name.replace(".", "/")] = format
# Migrate old layout
if name.startswith("quodlibet."):
sys.modules[name.split(".", 1)[1]] = format
# This can be used for the quodlibet.desktop file
desktop_mime_types = "MimeType=" + \
";".join(sorted({m.split(";")[0] for m in mimes})) + ";"
print_d(desktop_mime_types)
s = ", ".join(sorted(module_names))
print_d("Supported formats: %s" % s)
if not loaders:
raise SystemExit("No formats found!")
开发者ID:LudoBike,项目名称:quodlibet,代码行数:46,代码来源:_misc.py
示例16: _show_files_win32
def _show_files_win32(dirname, entries):
if not is_windows():
raise BrowseError("windows only")
if not entries:
# open_folder_and_select_items will open the parent if no items
# are passed, so execute explorer directly for that case
try:
if subprocess.call(["explorer", dirname]) != 0:
raise EnvironmentError("explorer error return status")
except EnvironmentError as e:
raise BrowseError(e)
else:
from quodlibet.util.windows import open_folder_and_select_items
try:
open_folder_and_select_items(dirname, [])
except WindowsError as e:
raise BrowseError(e)
开发者ID:Muges,项目名称:quodlibet,代码行数:19,代码来源:showfiles.py
示例17: show_uri
def show_uri(label, uri):
"""Shows a uri. The uri can be anything handled by GIO or a quodlibet
specific one.
Currently handled quodlibet uris:
- quodlibet:///prefs/plugins/<plugin id>
Args:
label (str)
uri (str) the uri to show
Returns:
True on success, False on error
"""
parsed = urlparse(uri)
if parsed.scheme == "quodlibet":
if parsed.netloc != "":
print_w("Unknown QuodLibet URL format (%s)" % uri)
return False
else:
return __show_quodlibet_uri(parsed)
elif parsed.scheme == "file" and (is_windows() or is_osx()):
# Gio on non-Linux can't handle file URIs for some reason,
# fall back to our own implementation for now
from quodlibet.qltk.showfiles import show_files
try:
filepath = uri2fsn(uri)
except ValueError:
return False
else:
return show_files(filepath, [])
else:
# Gtk.show_uri_on_window exists since 3.22
try:
if hasattr(Gtk, "show_uri_on_window"):
from quodlibet.qltk import get_top_parent
return Gtk.show_uri_on_window(get_top_parent(label), uri, 0)
else:
return Gtk.show_uri(None, uri, 0)
except GLib.Error:
return False
开发者ID:LudoBike,项目名称:quodlibet,代码行数:42,代码来源:__init__.py
示例18: show_files
def show_files(dirname, entries=[]):
"""Shows the directory in the default file browser and if passed
a list of directory entries will highlight those.
Depending on the system/platform this might highlight all files passed,
or only one of them, or none at all.
Args:
dirname (fsnative): Path to the directory
entries (List[fsnative]): List of (relative) filenames in the directory
entries (List[fsnative]): List of (relative) filenames in the directory
Returns:
bool: if the action was successful or not
"""
assert isinstance(dirname, fsnative)
assert all(isinstance(e, fsnative) and os.path.basename(e) == e
for e in entries)
dirname = os.path.abspath(dirname)
if is_windows():
implementations = [_show_files_win32]
elif is_osx():
implementations = [_show_files_finder]
else:
implementations = [
_show_files_fdo,
_show_files_thunar,
_show_files_xdg_open,
_show_files_gnome_open,
]
for impl in implementations:
try:
impl(dirname, entries)
except BrowseError:
continue
else:
return True
return False
开发者ID:Muges,项目名称:quodlibet,代码行数:41,代码来源:showfiles.py
示例19: _py2_to_py3
def _py2_to_py3(items):
assert PY3
for i in items:
try:
l = list(i.items())
except AttributeError:
raise SerializationError
i.clear()
for k, v in l:
if isinstance(k, bytes):
k = k.decode("utf-8", "replace")
else:
# strip surrogates
try:
k.encode("utf-8")
except UnicodeEncodeError:
k = k.encode("utf-8", "replace").decode("utf-8")
if k == "~filename" or k == "~mountpoint":
if isinstance(v, bytes):
try:
v = bytes2fsn(v, "utf-8")
except ValueError:
# just in case, only on Windows
assert is_windows()
v = v.decode("utf-8", "replace")
elif isinstance(v, bytes):
v = v.decode("utf-8", "replace")
elif isinstance(v, text_type):
# strip surrogates
try:
v.encode("utf-8")
except UnicodeEncodeError:
v = v.encode("utf-8", "replace").decode("utf-8")
i[k] = v
return items
开发者ID:piotrdrag,项目名称:quodlibet,代码行数:39,代码来源:_serialize.py
示例20: test_set_scan_dirs_colons
def test_set_scan_dirs_colons(self):
set_scan_dirs([STANDARD_PATH, GVFS_PATH])
expected = GVFS_PATH if is_windows() else GVFS_PATH_ESCAPED
self.assertEqual(self.scan_dirs, "%s:%s" % (STANDARD_PATH, expected))
开发者ID:ZDBioHazard,项目名称:quodlibet,代码行数:4,代码来源:test_util_library.py
注:本文中的quodlibet.util.is_windows函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论