def on_execute(self, item, action): if action: kpu.execute_default_action(self, item, action) else: kpu.web_browser_command(private_mode=self.force_private_mode, new_window=self.force_new_window, url=item.target(), execute=True)
def on_execute(self, item, action): if item.data_bag(): # open with a custom command parts = re.findall(r'(?=\s|\A)\s*([^" ]+|"[^"]*")(?=\s|\Z)', item.data_bag(), re.U) if len(parts) > 0: command, *params = parts kpu.shell_execute(command, params) else: self.info("Cannot open item with: '%s', parsed as %s" % (item.data_bag(), parts)) else: kpu.execute_default_action(self, item, action)
def on_execute(self, item, action): if item.category() == kp.ItemCategory.FILE: kpu.execute_default_action(self, item, action) return if item.category() != kp.ItemCategory.REFERENCE: return # extract info from item's target property try: item_target = kpu.kwargs_decode(item.target()) distro_name = item_target['dist'] if 'session' in item_target: session_name = item_target['session'] else: session_name = None if 'host_name' in item_target: host_name = item_target['host_name'] else: host_name = None except Exception as e: self.dbg(e) return # check if the desired distro is available and enabled if distro_name not in self._distros: self.warn( 'Could not execute item "{}". Distro "{}" not found.'.format( item.label(), distro_name)) return distro = self._distros[distro_name] if not distro['enabled']: self.warn( 'Could not execute item "{}". Distro "{}" is disabled.'.format( item.label(), distro_name)) return if host_name: kpu.shell_execute(distro['exe_file'], args=host_name) return # check if the desired session still exists if session_name not in distro['sessions']: self.warn( 'Could not execute item "{}". Session "{}" not found in distro "{}".' .format(item.label(), session_name, distro_name)) return # find the placeholder of the session name in the args list and execute sidx = distro['cmd_args'].index('%1') kpu.shell_execute(distro['exe_file'], args=distro['cmd_args'][0:sidx] + [session_name] + distro['cmd_args'][sidx + 1:])
def on_execute(self, item, action): if item.category() in [self.ITEMCAT_JOB_FOLDER, self.ITEMCAT_NODE]: if action and action.name() in ["open_url", "copy_url", "open_in_private"]: if action.name() == "open_url": kpu.web_browser_command(private_mode=None, new_window=None, url=item.target(), execute=True) elif action.name() == "copy_url": kpu.set_clipboard(item.target()) elif action.name() == "open_in_private": kpu.web_browser_command(private_mode=True, new_window=None, url=item.target(), execute=True) else: kpu.web_browser_command(private_mode=None, new_window=None, url=item.target(), execute=True) else: kpu.execute_default_action(self, item, action)
def on_execute(self, item, action): if item.category() == kp.ItemCategory.FILE: kpu.execute_default_action(self, item, action) elif item.category() == kp.ItemCategory.KEYWORD and item.target( ) == "rebuild_db": with self.mutex: try: client = evipc.Client() client.rebuild_db() except evipc.EverythingNotFound: self.warn("Everything instance not found") except: self.err( "Something bad happened while requesting Everything to perform your search." ) traceback.print_exc()
def on_execute(self, item, action): if item.category() == kp.ItemCategory.FILE: kpu.execute_default_action(self, item, action) return if item.category() != kp.ItemCategory.REFERENCE: return # extract info from item's target property try: item_target = kpu.kwargs_decode(item.target()) distro_name = item_target['dist'] if 'session' in item_target: session_name = item_target['session'] else: session_name = None if 'host_name' in item_target: host_name = item_target['host_name'] else: host_name = None except Exception as e: self.dbg(e) return # check if the desired distro is available and enabled if distro_name not in self._distros: self.warn('Could not execute item "{}". Distro "{}" not found.'.format(item.label(), distro_name)) return distro = self._distros[distro_name] if not distro['enabled']: self.warn('Could not execute item "{}". Distro "{}" is disabled.'.format(item.label(), distro_name)) return if host_name: kpu.shell_execute(distro['exe_file'], args=host_name) return # check if the desired session still exists if session_name not in distro['sessions']: self.warn('Could not execute item "{}". Session "{}" not found in distro "{}".'.format(item.label(), session_name, distro_name)) return # find the placeholder of the session name in the args list and execute sidx = distro['cmd_args'].index('%1') kpu.shell_execute( distro['exe_file'], args=distro['cmd_args'][0:sidx] + [session_name.replace(' ', '%20')] + distro['cmd_args'][sidx+1:])
def on_execute(self, item, action): if item.category() != kp.ItemCategory.URL: return url_scheme, corrected_url = self._extract_url_scheme(item.target()) if not url_scheme: self.warn("Could not guess URL scheme from URL:", item.target()) return scheme_registered = self._is_registered_url_scheme(url_scheme) if not scheme_registered: self.warn('URL cannot be launched because its scheme "{}" is not registered'.format(url_scheme)) return if url_scheme in self.WEB_SCHEMES: kpu.execute_default_action(self, item, action) else: kpu.shell_execute(item.target())
def on_execute(self, item, action): self.dbg("on_execute", item.target(), item.raw_args(), item.data_bag()) if item.target() == self.COMMAND_RESCAN: self._rescan() self.on_catalog() elif item.target() == self.COMMAND_OPEN_GIT_BASH: self._run_command(self._git_bash_path, None, False, item.raw_args()) elif item.target() == self.COMMAND_REMOVE_OLD: remove_repos = [] for repo in self._git_repos: if not os.path.exists(repo.path): remove_repos.append(repo) for repo in remove_repos: self._git_repos.remove(repo) self._save_repos() self.on_catalog() self.info("Removed", len(remove_repos), "repositories that don't exist anymore.") elif item.target() == self.COMMAND_RENAME: new_name = item.raw_args() repo_path = item.data_bag() for repo in self._git_repos: if repo.path == repo_path: self.info("renaming", repo.name, "to", new_name, repo_path) repo.name = new_name break self._save_repos() self.on_catalog() elif item.target() == self.COMMAND_COPY_PATH: repo_path = item.data_bag() kpu.set_clipboard(repo_path) elif item.target().startswith(self.COMMAND_CMD_ALL): cmd = eval(item.data_bag()) self.dbg(cmd) args = cmd.args for repo in self._git_repos: cmd.args = args.format(repo_path=repo.path) self.dbg(cmd) self._run_command(cmd.cmd, cmd.args, cmd.internal, repo.path) elif item.category() == kp.ItemCategory.FILE: kpu.execute_default_action(self, item, action) else: cmd = eval(item.data_bag()) self._run_command(cmd.cmd, item.raw_args(), cmd.internal, cmd.cwd)
def on_execute(self, item, action): if item.category() == kp.ItemCategory.FILE: kpu.execute_default_action(self, item, action)
def on_execute(self, item, action): kpu.execute_default_action(self, item, action)