本文整理汇总了Python中quodlibet.util.dprint.print_函数的典型用法代码示例。如果您正苦于以下问题:Python print_函数的具体用法?Python print_怎么用?Python print_使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了print_函数的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: control
def control(command, arg=None, ignore_error=False):
"""Sends command to the existing instance if possible and exits.
Will print any response it gets to stdout.
Does not return except if ignore_error is True and sending
the command failed.
"""
if not is_running():
if ignore_error:
return
exit_(_("Quod Libet is not running (add '--run' to start it)"),
notify_startup=True)
return
message = command
if arg is not None:
message += " " + arg
try:
response = Remote.send_message(message)
except RemoteError as e:
if ignore_error:
return
exit_(str(e), notify_startup=True)
else:
if response is not None:
print_(response, end="")
exit_(notify_startup=True)
开发者ID:bossjones,项目名称:quodlibet,代码行数:30,代码来源:cli.py
示例2: print_terse_table
def print_terse_table(rows, nicks, order):
"""Print a terse table"""
for row in filter_table(rows, nicks, order):
row = [r.replace("\\", "\\\\") for r in row]
row = [r.replace(":", r"\:") for r in row]
print_(":".join(row))
开发者ID:ZDBioHazard,项目名称:quodlibet,代码行数:7,代码来源:util.py
示例3: __request
def __request(self, line, raw=False, want_reply=True):
"""
Send a request to the server, if connected, and return its response
"""
line = line.strip()
if not (self.is_connected or line.split()[0] == 'login'):
print_d("Can't do '%s' - not connected" % line.split()[0], self)
return None
if self._debug:
print_(">>>> \"%s\"" % line)
try:
self.telnet.write(line + "\n")
if not want_reply:
return None
raw_response = self.telnet.read_until("\n").strip()
except socket.error as e:
print_w("Couldn't communicate with squeezebox (%s)" % e)
self.failures += 1
if self.failures >= self._MAX_FAILURES:
print_w("Too many Squeezebox failures. Disconnecting")
self.is_connected = False
return None
response = raw_response if raw else urllib.unquote(raw_response)
if self._debug:
print_("<<<< \"%s\"" % (response,))
return response[len(line) - 1:] if line.endswith("?")\
else response[len(line) + 1:]
开发者ID:bernd-wechner,项目名称:quodlibet,代码行数:29,代码来源:server.py
示例4: printErrors
def printErrors(self):
succ = self.testsRun - (len(self.errors) + len(self.failures))
v = Colorise.bold("%3d" % succ)
cv = Colorise.green(v) if succ == self.testsRun else Colorise.red(v)
count = self.TEST_RESULTS_WIDTH - self.testsRun
print_((" " * count) + cv)
self.printErrorList('ERROR', self.errors)
self.printErrorList('FAIL', self.failures)
开发者ID:bossjones,项目名称:quodlibet,代码行数:8,代码来源:__init__.py
示例5: print_exc
def print_exc(limit=None, file=None):
"""A wrapper preventing crashes on broken pipes in print_exc."""
if file is None:
if PY2:
file = sys.stderr
else:
file = sys.stderr.buffer
print_(traceback.format_exc(limit=limit), output=file)
开发者ID:michael-ball,项目名称:quodlibet,代码行数:8,代码来源:__init__.py
示例6: __init__
def __init__(self, test_name, num_tests, out=sys.stdout, failfast=False):
super(Result, self).__init__()
self.out = out
self.failfast = failfast
if hasattr(out, "flush"):
out.flush()
pref = "%s (%d): " % (Colorise.bold(test_name), num_tests)
line = pref + " " * (self.TEST_NAME_WIDTH - len(test_name) - 7 - int(num_tests and log(num_tests, 10) or 0))
print_(line, end="")
开发者ID:mistotebe,项目名称:quodlibet,代码行数:9,代码来源:__init__.py
示例7: exec_commands
def exec_commands(*args):
for cmd in cmds_todo:
try:
resp = cmd_registry.run(app, *cmd)
except CommandError:
pass
else:
if resp is not None:
print_(resp, end="")
开发者ID:mistotebe,项目名称:quodlibet,代码行数:9,代码来源:quodlibet.py
示例8: _print_help
def _print_help(main_cmd, parser, file=None):
"""Print a short help list for all commands"""
if file is None:
file = sys.stdout
parser.print_help(file=file)
cl = ["", "Commands:"]
for command in Command.COMMANDS:
cl.append(" %-17s %s" % (command.NAME, command.DESCRIPTION))
cl.append("")
cl.append("See '%s help <command>' for more information "
"on a specific command." % main_cmd)
print_("\n".join(cl), file)
开发者ID:bossjones,项目名称:quodlibet,代码行数:16,代码来源:main.py
示例9: printErrorList
def printErrorList(self, flavour, errors):
for test, err in errors:
print_(self.MAJOR_SEPARATOR)
print_(Colorise.red("%s: %s" % (flavour, str(test))))
print_(self.MINOR_SEPARATOR)
# tracebacks can contain encoded paths, not sure
# what the right fix is here, so use repr
for line in err.splitlines():
print_(repr(line)[1:-1])
开发者ID:bossjones,项目名称:quodlibet,代码行数:9,代码来源:__init__.py
示例10: parse
def parse(self, args=None):
if args is None:
args = argv[1:]
from getopt import getopt, GetoptError
try:
opts, args = getopt(args, self.__shorts(), self.__longs())
except GetoptError as s:
s = str(s)
text = []
if "not recognized" in s:
text.append(
_("Option %r not recognized.") % s.split()[1])
elif "requires argument" in s:
text.append(
_("Option %r requires an argument.") % s.split()[1])
elif "unique prefix" in s:
text.append(
_("%r is not a unique prefix.") % s.split()[1])
if "help" in self.__args:
text.append(_("Try %s --help.") % argv[0])
print_e("\n".join(text))
raise SystemExit(True)
else:
transopts = {}
for o, a in opts:
if o.startswith("--"):
o = self.__translate_long.get(o[2:], o[2:])
elif o.startswith("-"):
o = self.__translate_short.get(o[1:], o[1:])
if o == "help":
print_(self.help())
raise SystemExit
elif o == "version":
print_(self.version())
raise SystemExit
elif o == "debug":
from quodlibet import const
const.DEBUG = True
if self.__args[o]:
transopts[o] = a
else:
transopts[o] = True
return transopts, args
开发者ID:ZDBioHazard,项目名称:quodlibet,代码行数:45,代码来源:__init__.py
示例11: print_table
def print_table(rows, headers, nicks, order):
"""Print a fancy table"""
rows.insert(0, headers)
rows = filter_table(rows, nicks, order)
if not rows:
return
widths = []
for c in range(len(rows[0])):
widths.append(max(map(lambda r: len(r[c]), rows)))
seperator = " %s " % Colorise.gray("|")
format_string = seperator.join(["%%-%ds" % w for w in widths])
header = []
for i, h in enumerate(rows.pop(0)):
header.append(h.ljust(widths[i], " "))
line_width = len(" ".join(header)) + 2
header = [Colorise.bold(h) for h in header]
header_line = " " + (" %s " % Colorise.gray("|")).join(header)
print_(header_line.rstrip())
print_(Colorise.gray("-" * line_width))
for row in rows:
print_(" " + (format_string % tuple(row)).rstrip())
开发者ID:ZDBioHazard,项目名称:quodlibet,代码行数:27,代码来源:util.py
示例12: main
def main(argv):
main_cmd = os.path.basename(argv[0])
# the main optparser
usage = "%s [--version] [--help] [--verbose] <command> [<args>]" % main_cmd
parser = OptionParser(usage=usage)
parser.remove_option("--help")
parser.add_option("-h", "--help", action="store_true")
parser.add_option("--version", action="store_true",
help="print version")
parser.add_option("-v", "--verbose", action="store_true",
help="verbose output")
# no args, print help (might change in the future)
if len(argv) <= 1:
_print_help(main_cmd, parser, file=sys.stderr)
return 1
# collect options for the main command and get the command offset
offset = -1
pre_command = []
for i, a in enumerate(argv):
if i == 0:
continue
elif a.startswith("-"):
pre_command.append(a)
else:
offset = i
break
# parse the global options
options = parser.parse_args(pre_command)[0]
# --help somewhere
if options.help:
_print_help(main_cmd, parser)
return 0
# --version somewhere
if options.version:
print_("%s version %s" % (main_cmd, const.VERSION))
return 0
# no sub command followed, help to stderr
if offset == -1:
_print_help(main_cmd, parser, file=sys.stderr)
return 1
arg = argv[offset]
# special case help and list all commands
if arg == "help":
# no command, list all commands
if len(argv) == 2:
_print_help(main_cmd, parser)
return 0
# get the right sub command and pass the remaining args
for command in Command.COMMANDS:
if command.NAME == arg:
cmd = command(main_cmd, options)
try:
cmd.execute(argv[offset + 1:])
except CommandError as e:
print_(u"%s: %s" % (command.NAME, e), sys.stderr)
return 1
break
else:
print_(u"Unknown command '%s'. See '%s help'." % (arg, main_cmd),
sys.stderr)
return 1
return 0
开发者ID:bossjones,项目名称:quodlibet,代码行数:73,代码来源:main.py
示例13: addError
def addError(self, test, err):
unittest.TestResult.addError(self, test, err)
print_(Colorise.red(self.CHAR_ERROR), end="")
开发者ID:bossjones,项目名称:quodlibet,代码行数:3,代码来源:__init__.py
示例14: addFailure
def addFailure(self, test, err):
unittest.TestResult.addFailure(self, test, err)
print_(Colorise.red(self.CHAR_FAILURE), end="")
开发者ID:bossjones,项目名称:quodlibet,代码行数:3,代码来源:__init__.py
示例15: print_exc
def print_exc(limit=None, file=None):
"""A wrapper preventing crashes on broken pipes in print_exc."""
if not file:
file = sys.stderr
print_(traceback.format_exc(limit=limit), output=file)
开发者ID:akdor1154,项目名称:quodlibet,代码行数:5,代码来源:__init__.py
示例16: _
text.append(
_("%r is not a unique prefix.") % s.split()[1])
if "help" in self.__args:
text.append(_("Try %s --help.") % sys.argv[0])
print_e("\n".join(text))
raise SystemExit(True)
else:
transopts = {}
for o, a in opts:
if o.startswith("--"):
o = self.__translate_long.get(o[2:], o[2:])
elif o.startswith("-"):
o = self.__translate_short.get(o[1:], o[1:])
if o == "help":
print_(self.help())
raise SystemExit
elif o == "version":
print_(self.version())
raise SystemExit
elif o == "debug":
from quodlibet import const
const.DEBUG = True
if self.__args[o]:
transopts[o] = a
else:
transopts[o] = True
return transopts, args
开发者ID:akdor1154,项目名称:quodlibet,代码行数:29,代码来源:__init__.py
示例17: addSuccess
def addSuccess(self, test):
unittest.TestResult.addSuccess(self, test)
print_(Colorise.green(self.CHAR_SUCCESS), end="")
开发者ID:bossjones,项目名称:quodlibet,代码行数:3,代码来源:__init__.py
注:本文中的quodlibet.util.dprint.print_函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论