Пример #1
0
def finish_command(ctx, acommand, stdout, stderr, post_result=True):
	"""Show async error if @acommand returns error output & error status.
	Else post async result if @post_result.
	"""
	max_error_msg=512
	pretty.print_debug(__name__, "Exited:", acommand)
	if acommand.exit_status != 0 and not stdout and stderr:
		errstr = kupferstring.fromlocale(stderr)[:max_error_msg]
		ctx.register_late_error(OperationError(errstr))
	elif post_result:
		leaf = TextLeaf(kupferstring.fromlocale(stdout))
		ctx.register_late_result(leaf)
Пример #2
0
def finish_command(ctx, acommand, stdout, stderr, post_result=True):
	"""Show async error if @acommand returns error output & error status.
	Else post async result if @post_result.
	"""
	max_error_msg=512
	pretty.print_debug(__name__, "Exited:", acommand)
	if acommand.exit_status != 0 and not stdout and stderr:
		errstr = kupferstring.fromlocale(stderr)[:max_error_msg]
		ctx.register_late_error(OperationError(errstr))
	elif post_result:
		leaf = TextLeaf(kupferstring.fromlocale(stdout))
		ctx.register_late_result(leaf)
Пример #3
0
def finish_command(token, acommand, stdout, stderr, post_result=True):
	"""Show async error if @acommand returns error output & error status.
	Else post async result if @post_result.
	"""
	max_error_msg=512
	pretty.print_debug(__name__, "Exited:", acommand)
	ctx = commandexec.DefaultActionExecutionContext()
	if acommand.exit_status != 0 and not stdout and stderr:
		try:
			errstr = kupferstring.fromlocale(stderr)[:max_error_msg]
			raise OperationError(errstr)
		except OperationError:
			ctx.register_late_error(token)
	elif post_result:
		leaf = TextLeaf(kupferstring.fromlocale(stdout))
		ctx.register_late_result(token, leaf)
Пример #4
0
def get_current_song():
    toolProc = subprocess.Popen([AUDTOOL, "current-song"],
            stdout=subprocess.PIPE)
    stdout, stderr = toolProc.communicate()
    for line in stdout.splitlines():
        return kupferstring.fromlocale(line)
    return None
Пример #5
0
def get_current_song():
    toolProc = subprocess.Popen([AUDTOOL, "current-song"],
                                stdout=subprocess.PIPE)
    stdout, stderr = toolProc.communicate()
    for line in stdout.splitlines():
        return kupferstring.fromlocale(line)
    return None
Пример #6
0
 def get_items(self):
     package = self.query
     P = subprocess.PIPE
     acp = subprocess.Popen("apt-cache search --names-only '%s'" % package, shell=True, stdout=P, stderr=P)
     acp_out, acp_err = acp.communicate()
     for line in kupferstring.fromlocale(acp_out).splitlines():
         if not line.strip():
             continue
         package, desc = line.split(" - ", 1)
         yield Package(package, desc)
Пример #7
0
	def thread_do(self):
		P = subprocess.PIPE
		apt = subprocess.Popen("aptitude show '%s'" % self.text, shell=True,
				stdout=P, stderr=P)
		acp = subprocess.Popen("apt-cache policy '%s'" % self.text, shell=True,
				stdout=P, stderr=P)
		apt_out, apt_err = apt.communicate()
		acp_out, acp_err = acp.communicate()
		# Commandline output is encoded according to locale
		self.info = u"".join(kupferstring.fromlocale(s)
				for s in (apt_err, acp_err, apt_out, acp_out))
Пример #8
0
 def get_items(self):
     package = kupferstring.tolocale(self.query)
     p = subprocess.run(['apt-cache', 'search', '--names-only', package],
                        capture_output=True)
     for line in kupferstring.fromlocale(p.stdout).splitlines():
         if not line.strip():
             continue
         if not " - " in line:
             self.output_error("apt-cache: ", line)
             continue
         package, desc = line.split(" - ", 1)
         yield Package(package, desc)
Пример #9
0
def get_playlist_songs():
    """Yield tuples of (position, name) for playlist songs"""
    toolProc = subprocess.Popen([AUDTOOL, "playlist-display"],
                                stdout=subprocess.PIPE)
    stdout, stderr = toolProc.communicate()
    for line in stdout.splitlines():
        if not line.count('|') >= 2:
            continue
        position, rest = line.split('|', 1)
        songname, rest = rest.rsplit('|', 1)
        pos = int(position.strip())
        nam = kupferstring.fromlocale(songname.strip())
        yield (pos, nam)
Пример #10
0
def get_playlist_songs():
	"""Yield tuples of (position, name) for playlist songs"""
	toolProc = subprocess.Popen([AUDTOOL, "playlist-display"],
			stdout=subprocess.PIPE)
	stdout, stderr = toolProc.communicate()
	for line in stdout.splitlines():
		if not line.count('|') >= 2:
			continue
		position, rest = line.split('|', 1)
		songname, rest = rest.rsplit('|', 1)
		pos = int(position.strip())
		nam = kupferstring.fromlocale(songname.strip())
		yield (pos, nam)
Пример #11
0
	def get_items(self):
		package = kupferstring.tolocale(self.query)
		c_in, c_out_err = os.popen4(['apt-cache', 'search', '--names-only', package])
		try:
			c_in.close()
			acp_out = c_out_err.read()
			for line in kupferstring.fromlocale(acp_out).splitlines():
				if not line.strip():
					continue
				if not " - " in line:
					self.output_error("apt-cache: ", line)
					continue
				package, desc = line.split(" - ", 1)
				yield Package(package, desc)
		finally:
			c_out_err.close()
Пример #12
0
 def get_items(self):
     package = kupferstring.tolocale(self.query)
     c_in, c_out_err = os.popen4(
         ['apt-cache', 'search', '--names-only', package])
     try:
         c_in.close()
         acp_out = c_out_err.read()
         for line in kupferstring.fromlocale(acp_out).splitlines():
             if not line.strip():
                 continue
             if not " - " in line:
                 self.output_error("apt-cache: ", line)
                 continue
             package, desc = line.split(" - ", 1)
             yield Package(package, desc)
     finally:
         c_out_err.close()
Пример #13
0
	def finish_callback(self, acommand, stdout, stderr):
		ctx = commandexec.DefaultActionExecutionContext()
		leaf = TextLeaf(kupferstring.fromlocale(stdout))
		ctx.register_late_result(acommand.token, leaf)
Пример #14
0
	def activate(self, leaf):
		with open(leaf.object, "rb") as infile:
			l_text = infile.read()
			us_text = kupferstring.fromlocale(l_text)
		return TextLeaf(us_text)
Пример #15
0
def cmd_output_lines(cmd):
    return kupferstring.fromlocale(os.popen(cmd).read()).splitlines()
Пример #16
0
def cmd_output_lines(cmd):
	return kupferstring.fromlocale(os.popen(cmd).read()).splitlines()
Пример #17
0
	def _check_end(self):
		if self.aptitude is not None and self.apt_cache is not None:
			self.finish(u"".join(kupferstring.fromlocale(s)
			            for s in (self.aptitude, self.apt_cache)))
Пример #18
0
 def __init__(self, s):
     OperationError.__init__(self, kupferstring.fromlocale(s))
Пример #19
0
 def get_items(self):
     for x in self.serverids:
         yield VimApp(x, _("Vim Session %s") % kupferstring.fromlocale(x))
Пример #20
0
 def get_locate_output(proc, offset=0):
     out, ignored_err = proc.communicate()
     return (ConstructFileLeaf(kupferstring.fromlocale(f))
             for f in out.split(b'\x00')[offset:-1])
Пример #21
0
 def get_items(self):
     for x in self.serverids:
         yield VimApp(x, _("Vim Session %s") % kupferstring.fromlocale(x))
Пример #22
0
 def get_locate_output(proc, offset=0):
     out, ignored_err = proc.communicate()
     return (ConstructFileLeaf(kupferstring.fromlocale(f))
             for f in out.split(b'\x00')[offset:-1])
Пример #23
0
 def __init__(self, s):
     OperationError.__init__(self, kupferstring.fromlocale(s))
Пример #24
0
 def activate(self, leaf):
     with open(leaf.object, "rb") as infile:
         l_text = infile.read()
         us_text = kupferstring.fromlocale(l_text)
     return TextLeaf(us_text)
Пример #25
0
 def _check_end(self):
     if self.aptitude is not None and self.apt_cache is not None:
         self.finish(u"".join(
             kupferstring.fromlocale(s)
             for s in (self.aptitude, self.apt_cache)))