本文整理汇总了Python中quodlibet.util.spawn函数的典型用法代码示例。如果您正苦于以下问题:Python spawn函数的具体用法?Python spawn怎么用?Python spawn使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了spawn函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
def run(self, songs):
"""
Runs this command on `songs`,
splitting into multiple calls if necessary
"""
args = []
if self.parameter:
value = GetStringDialog(None, _("Input value"),
_("Value for %s?") % self.parameter).run()
self.command = self.command.format(**{self.parameter: value})
print_d("Actual command=%s" % self.command)
for song in songs:
arg = str(self.__pat.format(song))
if not arg:
print_w("Couldn't build shell command using \"%s\"."
"Check your pattern?" % self.pattern)
break
if not self.unique:
args.append(arg)
elif arg not in args:
args.append(arg)
max = int((self.max_args or 10000))
com_words = self.command.split(" ")
while args:
print_d("Running %s with %d substituted arg(s) (of %d%s total)..."
% (self.command, min(max, len(args)), len(args),
" unique" if self.unique else ""))
util.spawn(com_words + args[:max])
args = args[max:]
示例2: __save
def __save(self, *data):
"""Save the cover and spawn the program to edit it if selected"""
save_format = self.name_combo.get_active_text()
# Allow use of patterns in creating cover filenames
pattern = ArbitraryExtensionFileFromPattern(
save_format.decode("utf-8"))
filename = pattern.format(self.song)
print_d("Using '%s' as filename based on %s" % (filename, save_format))
file_path = os.path.join(self.dirname, filename)
if os.path.exists(file_path):
resp = ConfirmFileReplace(self, file_path).run()
if resp != ConfirmFileReplace.RESPONSE_REPLACE:
return
try:
f = open(file_path, 'wb')
f.write(self.current_data)
f.close()
except IOError:
qltk.ErrorMessage(None, _('Saving failed'),
_('Unable to save "%s".') % file_path).run()
else:
if self.open_check.get_active():
try:
util.spawn([self.cmd.get_text(), file_path])
except:
pass
app.cover_manager.cover_changed([self.song])
self.main_win.destroy()
示例3: plugin_songs
def plugin_songs(self, songs):
if self.prog_name is None:
return
args, reverse = self.burn_programs[self.prog_name]
songs = sorted(songs, key=lambda s: s.sort_key, reverse=reverse)
util.spawn(args + [song['~filename'] for song in songs])
示例4: run
def run(self, songs):
if self.type == self.FOLDERS:
files = [song("~dirname") for song in songs]
elif self.type == self.FILES:
files = [song("~filename") for song in songs]
elif self.type == self.URIS:
files = [song("~uri") for song in songs]
files = dict.fromkeys(files).keys()
util.spawn(self.command.split() + files)
示例5: run
def run(self, songs, playlist_name=None):
"""
Runs this command on `songs`,
splitting into multiple calls if necessary.
`playlist_name` if populated contains the Playlist's name.
"""
args = []
template_vars = {}
if self.parameter:
value = GetStringDialog(None, _("Input value"),
_("Value for %s?") % self.parameter).run()
template_vars[self.parameter] = value
if playlist_name:
print_d("Playlist command for %s" % playlist_name)
template_vars["PLAYLIST"] = playlist_name
self.command = self.command.format(**template_vars)
print_d("Actual command=%s" % self.command)
for i, song in enumerate(songs):
wrapped = SongWrapper(song)
if playlist_name:
wrapped["~playlistname"] = playlist_name
wrapped["~playlistindex"] = str(i + 1)
wrapped["~#playlistindex"] = i + 1
arg = str(self.__pat.format(wrapped))
if not arg:
print_w("Couldn't build shell command using \"%s\"."
"Check your pattern?" % self.pattern)
break
if not self.unique:
args.append(arg)
elif arg not in args:
args.append(arg)
max = int((self.max_args or 10000))
com_words = self.command.split(" ")
while args:
print_d("Running %s with %d substituted arg(s) (of %d%s total)..."
% (self.command, min(max, len(args)), len(args),
" unique" if self.unique else ""))
util.spawn(com_words + args[:max])
args = args[max:]
示例6: plugin_songs
def plugin_songs(self, songs):
if self.prog_name is None:
return
cmd, arg = self.burn_programs[self.prog_name]
util.spawn([cmd, arg] + [song['~filename'] for song in songs])
示例7: test_get_output
def test_get_output(self):
if is_win:
return
fileobj = util.spawn(["echo", "'$1'", '"$2"', ">3"], stdout=True)
self.failUnlessEqual(fileobj.read().split(), ["'$1'", '"$2"', ">3"])
示例8: test_simple
def test_simple(self):
if is_win:
return
self.failUnless(util.spawn(["ls", "."], stdout=True))
示例9: __stack_row_activated
def __stack_row_activated(self, view, path, column):
model = view.get_model()
filename = model[path][0]
line = model[path][2]
util.spawn(["sensible-editor", "+%d" % line, filename])
示例10: test_simple
def test_simple(self):
self.failUnless(util.spawn(["ls", "."], stdout=True))