• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python get_executables.get_executables函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中ranger.ext.get_executables.get_executables函数的典型用法代码示例。如果您正苦于以下问题:Python get_executables函数的具体用法?Python get_executables怎么用?Python get_executables使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_executables函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: execute

	def execute(self):
		command = os.environ.get('TERMCMD', os.environ.get('TERM'))
		if command not in get_executables():
			command = 'x-terminal-emulator'
		if command not in get_executables():
			command = 'xterm'
		self.fm.run(command, flags='d')
开发者ID:aspidites,项目名称:ranger,代码行数:7,代码来源:commands.py


示例2: execute

 def execute(self):
     command = os.environ.get("TERMCMD", os.environ.get("TERM"))
     if command not in get_executables():
         command = "x-terminal-emulator"
     if command not in get_executables():
         command = "xterm"
     self.fm.run(command, flags="f")
开发者ID:Virako,项目名称:dotfiles,代码行数:7,代码来源:commands.py


示例3: _eval_condition2

    def _eval_condition2(  # pylint: disable=too-many-return-statements,too-many-branches
            self, rule, files, label):
        # This function evaluates the condition, after _eval_condition() handled
        # negation of conditions starting with a "!".

        if not files:
            return False

        function = rule[0]
        argument = rule[1] if len(rule) > 1 else ''

        if function == 'ext':
            if os.path.isfile(files[0]):
                partitions = os.path.basename(files[0]).rpartition('.')
                if not partitions[0]:
                    return False
                return bool(re.search('^(' + argument + ')$', partitions[2].lower()))
        elif function == 'name':
            return bool(re.search(argument, os.path.basename(files[0])))
        elif function == 'match':
            return bool(re.search(argument, files[0]))
        elif function == 'file':
            return os.path.isfile(files[0])
        elif function == 'directory':
            return os.path.isdir(files[0])
        elif function == 'path':
            return bool(re.search(argument, os.path.abspath(files[0])))
        elif function == 'mime':
            return bool(re.search(argument, self.get_mimetype(files[0])))
        elif function == 'has':
            if argument.startswith("$"):
                if argument[1:] in os.environ:
                    return os.environ[argument[1:]] in get_executables()
                return False
            else:
                return argument in get_executables()
        elif function == 'terminal':
            return _is_terminal()
        elif function == 'number':
            if argument.isdigit():
                self._skip = int(argument)
            return True
        elif function == 'label':
            self._app_label = argument
            if label:
                return argument == label
            return True
        elif function == 'flag':
            self._app_flags = argument
            return True
        elif function == 'X':
            return sys.platform == 'darwin' or 'DISPLAY' in os.environ
        elif function == 'env':
            return bool(os.environ.get(argument))
        elif function == 'else':
            return True
        return None
开发者ID:dbosst,项目名称:ranger,代码行数:57,代码来源:rifle.py


示例4: execute

 def execute(self):
     import os
     from ranger.ext.get_executables import get_executables
     command = os.environ.get('TERMCMD', os.environ.get('TERM'))
     if command not in get_executables():
         command = 'sakura'
     if command not in get_executables():
         command = 'sakura'
     self.fm.run(command, flags='f')
开发者ID:jaberwokky,项目名称:configs,代码行数:9,代码来源:commands.py


示例5: execute

    def execute(self):
        import os
        from ranger.ext.get_executables import get_executables

        command = os.environ.get("TERMCMD", os.environ.get("TERM"))
        if command not in get_executables():
            command = "x-terminal-emulator"
        if command not in get_executables():
            # command = 'xterm'
            command = "urxvt"
        self.fm.run(command, flags="f")
开发者ID:4bcxyz,项目名称:dotfiles,代码行数:11,代码来源:commands.py


示例6: _eval_condition2

    def _eval_condition2(self, rule, files, label):
        # This function evaluates the condition, after _eval_condition() handled
        # negation of conditions starting with a "!".

        if not files:
            return False

        function = rule[0]
        argument = rule[1] if len(rule) > 1 else ''

        if function == 'ext':
            extension = os.path.basename(files[0]).rsplit('.', 1)[-1].lower()
            return bool(re.search('^(' + argument + ')$', extension))
        elif function == 'name':
            return bool(re.search(argument, os.path.basename(files[0])))
        elif function == 'match':
            return bool(re.search(argument, files[0]))
        elif function == 'file':
            return os.path.isfile(files[0])
        elif function == 'directory':
            return os.path.isdir(files[0])
        elif function == 'path':
            return bool(re.search(argument, os.path.abspath(files[0])))
        elif function == 'mime':
            return bool(re.search(argument, self._get_mimetype(files[0])))
        elif function == 'has':
            if argument.startswith("$"):
                if argument[1:] in os.environ:
                    return os.environ[argument[1:]] in get_executables()
                return False
            else:
                return argument in get_executables()
        elif function == 'terminal':
            return _is_terminal()
        elif function == 'number':
            if argument.isdigit():
                self._skip = int(argument)
            return True
        elif function == 'label':
            self._app_label = argument
            if label:
                return argument == label
            return True
        elif function == 'flag':
            self._app_flags = argument
            return True
        elif function == 'X':
            return 'DISPLAY' in os.environ
        elif function == 'env':
            return bool(os.environ.get(argument))
        elif function == 'else':
            return True
开发者ID:carriercomm,项目名称:ranger,代码行数:52,代码来源:rifle.py


示例7: _eval_condition2

    def _eval_condition2(self, rule, files, label):
        # This function evaluates the condition, after _eval_condition() handled
        # negation of conditions starting with a "!".

        if not files:
            return False

        function = rule[0]
        argument = rule[1] if len(rule) > 1 else ""

        if function == "ext":
            extension = os.path.basename(files[0]).rsplit(".", 1)[-1].lower()
            return bool(re.search("^(" + argument + ")$", extension))
        elif function == "name":
            return bool(re.search(argument, os.path.basename(files[0])))
        elif function == "match":
            return bool(re.search(argument, files[0]))
        elif function == "file":
            return os.path.isfile(files[0])
        elif function == "directory":
            return os.path.isdir(files[0])
        elif function == "path":
            return bool(re.search(argument, os.path.abspath(files[0])))
        elif function == "mime":
            return bool(re.search(argument, self._get_mimetype(files[0])))
        elif function == "has":
            if argument.startswith("$"):
                if argument[1:] in os.environ:
                    return os.environ[argument[1:]] in get_executables()
                return False
            else:
                return argument in get_executables()
        elif function == "terminal":
            return _is_terminal()
        elif function == "number":
            if argument.isdigit():
                self._skip = int(argument)
            return True
        elif function == "label":
            self._app_label = argument
            if label:
                return argument == label
            return True
        elif function == "flag":
            self._app_flags = argument
            return True
        elif function == "X":
            return "DISPLAY" in os.environ
        elif function == "else":
            return True
开发者ID:PotatoesMaster,项目名称:ranger,代码行数:50,代码来源:rifle.py


示例8: execute

    def execute(self):
        import subprocess
        from ranger.ext.get_executables import get_executables
        if not 'fd' in get_executables():
            self.fm.notify("Couldn't find fd on the PATH.", bad=True)
            return
        if self.arg(1):
            if self.arg(1)[:2] == '-d':
                depth = self.arg(1)
                target = self.rest(2)
            else:
                depth = '-d1'
                target = self.rest(1)
        else:
            self.fm.notify(":fd_search needs a query.", bad=True)
            return

        # For convenience, change which dict is used as result_sep to change
        # fd's behavior from splitting results by \0, which allows for newlines
        # in your filenames to splitting results by \n, which allows for \0 in
        # filenames.
        null_sep = {'arg': '-0', 'split': '\0'}
        nl_sep = {'arg': '', 'split': '\n'}
        result_sep = null_sep

        process = subprocess.Popen(['fd', result_sep['arg'], depth, target],
                universal_newlines=True, stdout=subprocess.PIPE)
        (search_results, _err) = process.communicate()
        global fd_deq
        fd_deq = deque((self.fm.thisdir.path + os.sep + rel for rel in
            sorted(search_results.split(result_sep['split']), key=str.lower)
            if rel != ''))
        if len(fd_deq) > 0:
            self.fm.select_file(fd_deq[0])
开发者ID:RanaExMachina,项目名称:dotfiles,代码行数:34,代码来源:commands.py


示例9: _apply_flags

 def _apply_flags(self, action, flags):
     # FIXME: Flags do not work properly when pipes are in the command.
     if "r" in flags:
         action = "sudo " + action
     if "t" in flags:
         if "TERMCMD" not in os.environ:
             term = os.environ["TERM"]
             if term.startswith("rxvt-unicode"):
                 term = "urxvt"
             if term not in get_executables():
                 self.hook_logger("Can not determine terminal command.  " "Please set $TERMCMD manually.")
             os.environ["TERMCMD"] = term
         action = "$TERMCMD -e %s" % action
     if "f" in flags:
         if "setsid" in get_executables():
             action = "setsid %s > /dev/null 2> /dev/null &" % action
         else:
             action = "nohup %s > /dev/null 2> /dev/null &" % action
     return action
开发者ID:aspidites,项目名称:ranger,代码行数:19,代码来源:rifle.py


示例10: either

	def either(self, context, *args):
		for app in args:
			try:
				application_handler = getattr(self, 'app_' + app)
			except AttributeError:
				if app in get_executables():
					return _generic_app(app, context)
				continue
			if self._meets_dependencies(application_handler):
				return application_handler(context)
开发者ID:sharklasers,项目名称:livarp_0.3.9,代码行数:10,代码来源:apps.py


示例11: _tab_through_executables

 def _tab_through_executables(self):
     from ranger.ext.get_executables import get_executables
     programs = [program for program in get_executables() if \
             program.startswith(self.rest(1))]
     if not programs:
         return
     if len(programs) == 1:
         return self.start(1) + programs[0]
     programs.sort()
     return (self.start(1) + program for program in programs)
开发者ID:PotatoesMaster,项目名称:ranger,代码行数:10,代码来源:commands.py


示例12: apply

	def apply(self, app, context):
		if not app:
			app = 'default'
		try:
			handler = getattr(self, 'app_' + app)
		except AttributeError:
			if app in get_executables():
				return _generic_app(app, context)
			handler = self.app_default
		return handler(context)
开发者ID:Dieterbe,项目名称:ranger,代码行数:10,代码来源:apps.py


示例13: _apply_flags

	def _apply_flags(self, action, flags):
		# FIXME: Flags do not work properly when pipes are in the command.
		if 'r' in flags:
			action = 'sudo ' + action
		if 't' in flags:
			if 'TERMCMD' not in os.environ:
				term = os.environ['TERM']
				if term.startswith('rxvt-unicode'):
					term = 'urxvt'
				if term not in get_executables():
					self.hook_logger("Can not determine terminal command.  "
						"Please set $TERMCMD manually.")
				os.environ['TERMCMD'] = term
			action = "$TERMCMD -e %s" % action
		if 'f' in flags:
			if 'setsid' in get_executables():
				action = "setsid %s > /dev/null 2> /dev/null &" % action
			else:
				action = "nohup %s > /dev/null 2> /dev/null &" % action
		return action
开发者ID:fsquillace,项目名称:ranger,代码行数:20,代码来源:rifle.py


示例14: app_editor

    def app_editor(self, c):
        try:
            default_editor = os.environ['EDITOR']
        except KeyError:
            pass
        else:
            parts = default_editor.split()
            exe_name = os.path.basename(parts[0])
            if exe_name in get_executables():
                return tuple(parts) + tuple(c)

        return self.either(c, 'vim', 'emacs', 'nano')
开发者ID:wwchang,项目名称:dotfiles,代码行数:12,代码来源:apps.py


示例15: execute

	def execute(self, files, number=0, label=None, flags=None, mimetype=None):
		"""
		Executes the given list of files.

		By default, this executes the first command where all conditions apply,
		but by specifying number=N you can run the 1+Nth command.

		If a label is specified, only rules with this label will be considered.

		If you specify the mimetype, rifle will not try to determine it itself.

		By specifying a flag, you extend the flag that is defined in the rule.
		Uppercase flags negate the respective lowercase flags.
		For example: if the flag in the rule is "pw" and you specify "Pf", then
		the "p" flag is negated and the "f" flag is added, resulting in "wf".
		"""
		command = None
		found_at_least_one = None

		# Determine command
		for count, cmd, lbl, flags in self.list_commands(files, mimetype):
			if label and label == lbl or not label and count == number:
				cmd = self.hook_command_preprocessing(cmd)
				command = self._build_command(files, cmd, flags)
				break
			else:
				found_at_least_one = True
		else:
			if label and label in get_executables():
				cmd = '%s -- "[email protected]"' % label
				command = self._build_command(files, cmd, flags)

		# Execute command
		if command is None:
			if found_at_least_one:
				if label:
					self.hook_logger("Label '%s' is undefined" % label)
				else:
					self.hook_logger("Method number %d is undefined." % number)
			else:
				self.hook_logger("No action found.")
		else:
			if 'PAGER' not in os.environ:
				os.environ['PAGER'] = DEFAULT_PAGER
			if 'EDITOR' not in os.environ:
				os.environ['EDITOR'] = DEFAULT_EDITOR
			command = self.hook_command_postprocessing(command)
			self.hook_before_executing(command, self._mimetype, self._app_flags)
			try:
				p = Popen(command, env=self.hook_environment(os.environ), shell=True)
				p.wait()
			finally:
				self.hook_after_executing(command, self._mimetype, self._app_flags)
开发者ID:fsquillace,项目名称:ranger,代码行数:53,代码来源:rifle.py


示例16: _meets_dependencies

	def _meets_dependencies(self, fnc):
		try:
			deps = fnc.dependencies
		except AttributeError:
			return True

		for dep in deps:
			if hasattr(dep, 'dependencies') \
			and not self._meets_dependencies(dep):
				return False
			if dep not in get_executables():
				return False

		return True
开发者ID:Dieterbe,项目名称:ranger,代码行数:14,代码来源:apps.py


示例17: _meets_dependencies

	def _meets_dependencies(self, fnc):
		try:
			deps = fnc.dependencies
		except AttributeError:
			return True

		for dep in deps:
			if dep == 'X':
				if 'DISPLAY' not in os.environ or not os.environ['DISPLAY']:
					return False
				continue
			if hasattr(dep, 'dependencies') \
			and not self._meets_dependencies(dep):
				return False
			if dep not in get_executables():
				return False

		return True
开发者ID:sharklasers,项目名称:livarp_0.3.9,代码行数:18,代码来源:apps.py


示例18: tab

	def tab(self):
		if self.arg(1) and self.arg(1)[0] == '-':
			command = self.rest(2)
		else:
			command = self.rest(1)
		start = self.line[0:len(self.line) - len(command)]

		try:
			position_of_last_space = command.rindex(" ")
		except ValueError:
			return (start + program + ' ' for program \
					in get_executables() if program.startswith(command))
		if position_of_last_space == len(command) - 1:
			return self.line + '%s '
		else:
			before_word, start_of_word = self.line.rsplit(' ', 1)
			return (before_word + ' ' + file.shell_escaped_basename \
					for file in self.fm.env.cwd.files \
					if file.shell_escaped_basename.startswith(start_of_word))
开发者ID:MattWoelk,项目名称:configuration-files,代码行数:19,代码来源:commands.py


示例19: apply

	def apply(self, app, context):
		if not app:
			app = 'default'
		try:
			handler = getattr(self, 'app_' + app)
		except AttributeError:
			if app in get_executables():
				return [app] + list(context)
			handler = self.app_default
		arguments = handler(context)
		# flatten
		if isinstance(arguments, str):
			return (arguments, )
		if arguments is None:
			return None
		result = []
		for obj in arguments:
			if isinstance(obj, (tuple, list, Context)):
				result.extend(obj)
			else:
				result.append(obj)
		return result
开发者ID:sharklasers,项目名称:livarp_0.3.9,代码行数:22,代码来源:apps.py


示例20: _eval_condition2

	def _eval_condition2(self, rule, files, label):
		# This function evaluates the condition, after _eval_condition() handled
		# negation of conditions starting with a "!".

		function = rule[0]
		argument = rule[1] if len(rule) > 1 else ''
		if not files:
			return False

		if function == 'ext':
			extension = os.path.basename(files[0]).rsplit('.', 1)[-1]
			return bool(re.search('^' + argument + '$', extension))
		if function == 'name':
			return bool(re.search(argument, os.path.basename(files[0])))
		if function == 'path':
			return bool(re.search(argument, os.path.abspath(files[0])))
		if function == 'mime':
			return bool(re.search(argument, self._get_mimetype(files[0])))
		if function == 'has':
			return argument in get_executables()
		if function == 'terminal':
			return _is_terminal()
		if function == 'number':
			if argument.isdigit():
				self._skip = int(argument)
			return True
		if function == 'label':
			self._app_label = argument
			if label:
				return argument == label
			return True
		if function == 'flag':
			self._app_flags = argument
			return True
		if function == 'X':
			return 'DISPLAY' in os.environ
		if function == 'else':
			return True
开发者ID:fsquillace,项目名称:ranger,代码行数:38,代码来源:rifle.py



注:本文中的ranger.ext.get_executables.get_executables函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python human_readable.human_readable函数代码示例发布时间:2022-05-26
下一篇:
Python direction.Direction类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap