Exemple #1
0
    def __call__(self):
        show_status_message('Creating a Script...')
        scriptVars = _GetScriptVars()
        script, flags = show_prompt("New Script Name?")
        newScript = scriptVars['directory'] + os.sep + script
        if os.path.isdir(newScript):
            show_alert("This is a directory.")
        else:
            if os.path.isfile(newScript):
                show_alert("Script already exists.")
            else:
                #
                # Create the script file.
                #
                fp = open(newScript,"w+")
                fp.write("#!/bin/sh\n\n")
                fp.write("#\n# The following variable are usable:\n#\n")
                fp.write("# $FILES_SELECTED - The currently selected file\n")
                fp.write("# $LEFT_PANE - The directory of the left pane\n")
                fp.write("# $RIGHT_PANE - The directory of the right pane\n")
                fp.write("# $CURRENT_DIRECTORY - The currently selected directory\n")
                fp.write("# $LEFT_PANE_SELECTED_FILE - The currently selected file in the left pane\n")
                fp.write("# $RIGHT_PANE_SELECTED_FILE - The currently selected file in the right pane\n")
                fp.close()
                os.chmod(newScript,0o755)

                #
                # Edit the script file.
                #
                if self.pane.is_command_visible('open_with_editor'):
                    self.pane.run_command('open_with_editor',{'url': as_url(newScript)})
        clear_status_message()
Exemple #2
0
 def __call__(self):
     show_status_message('Regular Expressions Selection')
     result = show_quicksearch(self._suggest_projects)
     if result:
         query, regexp = result
         try:
             pattern = re.compile(regexp)
         except Exception as e:
             show_alert('Your Regular Expression statement is not valid.' +
                        str(e))
             self.__call__()
             return
         used = False
         lines = [""]
         if os.path.isfile(REGULAREXPRESSIONHIST):
             with open(REGULAREXPRESSIONHIST, "r") as f:
                 lines = f.readlines()
         for line in lines:
             if line.strip() == regexp:
                 used = True
         if not used:
             with open(REGULAREXPRESSIONHIST, "a") as f:
                 f.write(regexp + "\n")
         scheme, currentDir = splitscheme(self.pane.get_path())
         for filep in iterdir(self.pane.get_path()):
             if pattern.search(filep):
                 self.pane.toggle_selection(
                     as_url(currentDir + os.sep + filep, scheme))
     clear_status_message()
    def __call__(self):
        # check file under cursor
        current_file = self.pane.get_file_under_cursor()
        # simply checking the file extension
        if re.compile(r'\.lnk$').search(current_file):
            # ok, let's receive the real folder containing the target of that shortcut
            shellscript = os.path.dirname(__file__) + "\link_target.ps1 "
            command = "powershell -ExecutionPolicy Bypass -NoLogo -Noninteractive -noprofile"
            command += ' -file "' + shellscript + '"'
            command += ' -link "' + as_human_readable(current_file) + '"'
            #show_status_message("Command: " + command) # temporary
            target = as_url(os.popen(command).read().strip())
            show_status_message("Target: " + target, 2)

            # what did we get?
            if False == exists(target):
                # target is not reachable...
                show_alert(target + " doesn't exist.")
            elif is_dir(target):
                # target is a folder, we go to it
                self.pane.set_path(target)
            else:
                # target is a file, we go to its directory
                self.pane.set_path(dirname(target))
        else:
            # nope, wrong thing
            show_alert(current_file + " is not a shortcut.")
Exemple #4
0
 def setHideDotfile(self, value_default):
     _t = ('1', 't', 'true')
     _f = ('0', 'f', 'false')
     _tsep = "'" + "' or '".join(_t) + "'"
     _fsep = "'" + "' or '".join(_f) + "'"
     _accept = (_t + _f)
     value_cfg = str(self.cfgCurrent['HideDotfile'])
     prompt_msg      = "Please enter " +_tsep+ " to treat all .dotfiles on Windows as hidden files\n    even if they don't have a 'hidden' attribute" +'\n'\
         + "or " +_fsep+ " to treat them as regular files" +'\n'\
         + "or leave the field empty to restore the default ("+str(value_default) +'):'
     selection_start = 0
     value_new = ''
     value_new_fmt = value_new.casefold()
     while value_new_fmt not in _accept:
         value_new, ok = show_prompt(prompt_msg, value_cfg, selection_start)
         value_cfg = value_new  # preserve user input on multiple edits
         if not ok:
             show_status_message("StatusBarExtended: setup canceled")
             return
         if value_new.strip(' ') == '':
             self.cfgCurrent['HideDotfile'] = value_default
             return
         value_new_fmt = value_new.casefold()
         if value_new_fmt not in _accept:
             show_alert("You entered\n" + value_new +'\n'\
                 + "I parsed it as " + value_new_fmt +'\n'\
                 + "but the only acceptable values are:\n" +_tsep+ "\n" +_fsep)
     self.cfgCurrent['HideDotfile'] = True if value_new_fmt in _t else False
Exemple #5
0
def open_native_file_manager(dir_path):
	settings = load_json('Core Settings.json', default={})
	app = settings.get('native_file_manager', {})
	if app:
		_run_app_from_setting(app, dir_path)
	else:
		xdg_open = which('xdg-open')
		if xdg_open:
			app = {'args': [xdg_open, '{curr_dir}']}
			_run_app_from_setting(app, dir_path)
			if _is_gnome_based():
				try:
					fpl = \
						check_output(['dconf', 'read', _FOCUS_PREVENTION_LEVEL])
				except FileNotFoundError as dconf_not_installed:
					pass
				else:
					if fpl in (b'', b'1\n'):
						show_status_message(
							'Hint: If your OS\'s file manager opened in the '
							'background, click '
							'<a href="https://askubuntu.com/a/594301">here</a>.',
							timeout_secs=10
						)
		else:
			show_alert(
				'Could not determine the Popen(...) arguments for opening the '
				'native file manager. Please configure the '
				'"native_file_manager" dictionary in "Core Settings.json" '
				'similarly to what\'s explained '
				'<a href="https://fman.io/docs/terminal?s=f">here</a>.'
			)
Exemple #6
0
    def __call__(self):
        show_status_message('Launching a Mask Script...')
        if os.path.isfile(as_human_readable(self.pane.get_path()) + os.path.sep + 'package.json'):
            npmPackagePath = as_human_readable(self.pane.get_path()) + os.path.sep + 'maskfile.md'
            npmPackagePtr = open(npmPackagePath,"r")
            npmPackage = json.loads(npmPackagePtr.read())
            npmPackagePtr.close()
            result = show_quicksearch(self._suggest_script)
            if result:
                #
                # Launch the script given. Show the output.
                #
                query, script = result

                #
                # Get the variables for this plugin
                #
                scriptVars = _GetScriptVars()

                #
                # Run the script.
                #
                saveDir = os.getcwd()
                os.chdir(as_human_readable(self.pane.get_path()) + os.path.sep)
                Output = run("source " + scriptVars['local_shell'] + "; mask " + script,stdout=PIPE,shell=True)
                os.chdir(saveDir)
                if Output.returncode == 0:
                    if scriptVars['show_output']:
                        show_alert(Output.stdout.decode("utf-8"))
                else:
                    show_alert("Command line error.")
        else:
            show_alert("Not a Mask project directory.")
        clear_status_message()
Exemple #7
0
 def setSymbolHiddenF(self, value_default):
     value_cfg = " ".join(self.cfgCurrent['SymbolHiddenF'])
     prompt_msg      = "Please enter two symbols, separated by space, to indicate whether hidden files are Shown/Hidden" +'\n'\
         + "or leave the field empty to restore the default ("+str(value_default)+"):"
     selection_start = 0
     selection_end = 0
     value_new = ''
     value_new_list = []
     _len = len(value_new_list)
     len_def = len(value_default)
     while _len != len_def:
         value_new, ok = show_prompt(prompt_msg, value_cfg, selection_start,
                                     selection_end)
         value_cfg = value_new  # preserve user input on multiple edits
         if not ok:
             show_status_message("StatusBarExtended: setup canceled")
             return
         if value_new.strip(' ') == '':
             self.cfgCurrent['SymbolHiddenF'] = value_default
             return
         value_new_nosp = ' '.join(
             value_new.split())  # replace multiple spaces with 1
         value_new_list = value_new_nosp.split(' ')  # split by space
         _len = len(value_new_list)
         if _len != 2:
             show_alert("You entered\n" + value_new +'\n'\
                 + "I parsed it as " + str(value_new_list) + " with " + str(_len) + " element" + ("" if _len==1 else "s") +'\n'\
                 + "but was expecting " + str(len_def) + " elements")
     self.cfgCurrent['SymbolHiddenF'] = value_new_list
Exemple #8
0
 def setMaxGlob(self, value_default):
     value_cfg = str(self.cfgCurrent['MaxGlob'])
     prompt_msg      = "Please enter a natural number to set the threshold of the number of folders+files in a pane," +'\n'\
         + "above which the status bar for such a pane will not be updated to improve performance" +'\n'\
         + "or enter '0' to disable" +'\n'\
         + "or leave the field empty to restore the default ("+str(value_default)+"):"
     selection_start = 0
     value_new = ''
     while not isNat0(value_new):
         value_new, ok = show_prompt(prompt_msg, value_cfg, selection_start)
         value_cfg = value_new  # preserve user input on multiple edits
         if not ok:
             show_status_message("StatusBarExtended: setup canceled")
             return
         if value_new.strip(' ') == '':
             self.cfgCurrent['MaxGlob'] = value_default
             return
         if value_new.strip(' ') == '0':
             self.cfgCurrent['MaxGlob'] = 0
             return
         if not isInt(value_new):
             show_alert("You entered\n" + value_new +'\n'\
                 + "but I couldn't parse it as an integer")
         elif not isNat0(value_new):
             show_alert("You entered\n" + value_new +'\n'\
                 + "but I was expecting a non-negative integer 0,1,2,3–∞")
     self.cfgCurrent['MaxGlob'] = int(value_new)
Exemple #9
0
 def setEnabled(self, value_default):
     _t = ('1', 't', 'true')
     _f = ('0', 'f', 'false')
     _tsep = "'" + "' or '".join(_t) + "'"
     _fsep = "'" + "' or '".join(_f) + "'"
     _accept = (_t + _f)
     value_cfg = str(self.cfgCurrent['Enabled'])
     prompt_msg      = "Please enter " +_tsep+ " to enable this plugin" +'\n'\
         + "or " +_fsep+ " to disable it" +'\n'\
         + "or leave the field empty to restore the default ("+str(value_default) +'):'
     selection_start = 0
     value_new = ''
     value_new_fmt = value_new.casefold()
     while value_new_fmt not in _accept:
         value_new, ok = show_prompt(prompt_msg, value_cfg, selection_start)
         value_cfg = value_new  # preserve user input on multiple edits
         if not ok:
             show_status_message("StatusBarExtended: setup canceled")
             return
         if value_new.strip(' ') == '':
             self.cfgCurrent['Enabled'] = value_default
             return
         value_new_fmt = value_new.casefold()
         if value_new_fmt not in _accept:
             show_alert("You entered\n" + value_new +'\n'\
                 + "I parsed it as " + value_new_fmt +'\n'\
                 + "but the only acceptable values are:\n" +_tsep+ "\n" +_fsep)
     self.cfgCurrent['Enabled'] = True if value_new_fmt in _t else False
Exemple #10
0
 def __call__(self):
     pane_path = self.pane.get_path()
     clipboard.clear()
     clipboard.set_text(pane_path)
     clipboard.set_text(splitscheme(pane_path)[1])
     show_status_message('Copied ' + splitscheme(pane_path)[1] +
                         ' to the clipboard',
                         timeout_secs=3)
Exemple #11
0
    def __call__(self):
        show_status_message('Launching a Script...')
        result = show_quicksearch(self._suggest_script)
        if result:
            #
            # Launch the script given. Show the output.
            #
            query, script = result

            #
            # Get the variables for this plugin
            #
            scriptVars = _GetScriptVars()

            #
            # Get a list of selected files.
            #
            selected_files = self.pane.get_selected_files()
            if len(selected_files) >= 1 or (len(selected_files) == 0 and self.get_chosen_files()):
                if len(selected_files) == 0 and self.get_chosen_files():
                    selected_files.append(self.get_chosen_files()[0])
            fileList = ''
            first = True
            for file in selected_files:
                if first:
                    fileList += as_human_readable(file)
                else:
                    fileList += ',' + as_human_readable(file)

            #
            # Set the environment variables for the scripts to use.
            #
            os.putenv('CURRENT_DIRECTORY', as_human_readable(self.pane.get_path()))
            panes = self.pane.window.get_panes()
            os.putenv('LEFT_PANE', as_human_readable(panes[0].get_path()))
            path = panes[0].get_file_under_cursor()
            if path is not None:
                os.putenv('LEFT_PANE_SELECTED_FILE',as_human_readable(path))
            else:
                os.putenv('LEFT_PANE_SELECTED_FILE',"")
            os.putenv('RIGHT_PANE', as_human_readable(panes[1].get_path()))
            path = panes[1].get_file_under_cursor()
            if path is not None:
                os.putenv('RIGHT_PANE_SELECTED_FILE',as_human_readable(path))
            else:
                os.putenv('RIGHT_PANE_SELECTED_FILE',"")
            os.putenv('FILES_SELECTED',fileList)

            #
            # Run the script.
            #
            Output = run("source " + scriptVars['local_shell'] + "; '" + scriptVars['directory'] + "/" + script + "'",stdout=PIPE,shell=True)
            if Output.returncode == 0:
                if scriptVars['show_output']:
                    show_alert(Output.stdout.decode("utf-8"))
            else:
                show_alert("Command line error.")
        clear_status_message()
def _report_clipboard_action(verb, files, suffix='', ftype='file'):
    num = len(files)
    first_file = as_human_readable(files[0])
    if num == 1:
        message = '%s %s%s' % (verb, first_file, suffix)
    else:
        plural = 's' if num > 2 else ''
        message = '%s %s and %d other %s%s%s' % \
            (verb, first_file, num - 1, ftype, plural, suffix)
    show_status_message(message, timeout_secs=3)
Exemple #13
0
 def iterdir(self, path):
     # XXX avoid errors on URLs without connection details
     if not path:
         return
     show_status_message('Loading %s...' % (path, ))
     with FtpWrapper(self.scheme + path) as ftp:
         for name in ftp.conn.listdir(ftp.path):
             self.get_stats(pathjoin(path, name))
             yield name
     show_status_message('Ready.', timeout_secs=0)
Exemple #14
0
    def show_selected_files(self, cfg):
        panes = self.pane.window.get_panes()
        pane_id = panes.index(self.pane)
        cfg_show_hidden_files = load_json(
            'Panes.json')[pane_id]['show_hidden_files']
        selected = self.pane.get_selected_files()
        dir_folders = 0
        dir_files = 0
        dir_filesize = 0

        if selected:
            if cfg_show_hidden_files:
                for f in selected:
                    if is_dir(f):
                        dir_folders += 1
                    else:
                        dir_files += 1
                        dir_filesize += query(f, 'size_bytes')
            else:
                for f in selected:
                    if not is_hidden(as_path(f)):
                        if is_dir(f):
                            dir_folders += 1
                        else:
                            dir_files += 1
                            dir_filesize += query(f, 'size_bytes')

            bc = ByteConverter(dir_filesize)
            bcc = str(bc.calc())
            jFd = cfg['Justify']['folder']
            jFl = cfg['Justify']['file']
            jSz = cfg['Justify']['size']
            dir_foldK = "{0:,}".format(dir_folders)
            dir_fileK = "{0:,}".format(dir_files)
            statusbar = "Selected* "
            if dir_folders > 0:
                statusbar += "Dirs: " + dir_foldK.rjust(jFd, ' ') + "  "
                if dir_folders <= 9999:
                    statusbar += " "
            else:
                statusbar += "      " + ''.rjust(jFd, ' ') + "   "
            if dir_files > 0:
                statusbar += "Files: " + dir_fileK.rjust(jFl, ' ') + "   "
                if dir_files <= 9999:
                    statusbar += " "
            else:
                statusbar += "       " + ''.rjust(jFl, ' ') + "    "
            statusbar += "∑ Size: " + bcc.rjust(jSz, ' ') + "   "
            show_status_message(statusbar)

        else:
            StatusBarExtended.refresh(self, cfg)
Exemple #15
0
 def __call__(self):
     cfg = SBEcfg.SingletonConfig()
     cfgCurrent, exit_status = cfg.loadConfig()
     if  cfgCurrent is None:
         return
     if  cfgCurrent["Enabled"] == True:
         cfgCurrent["Enabled"]  = False
         cfg.saveConfig(cfgCurrent)
         show_status_message("Disabled StatusBarExtended", 1)
     else:
         cfgCurrent["Enabled"]  = True
         cfg.saveConfig(cfgCurrent)
         SBE.StatusBarExtended.refresh(self, cfgCurrent)
Exemple #16
0
 def on_path_changed(self):
     # Some times, get_path returns two paths, but the last is always correct
     try:
         current_path = self.pane.get_path().split("file://")[1]
     except:
         current_path = self.pane.get_path().split("file://")
     try:
         # This will throw an exception if it is not a repository here
         repo = Repo(current_path)
         branch_name = repo.active_branch
         show_status_message(branch_name.name)
     except:
         show_status_message("Not at a top level git repository")
Exemple #17
0
 def __call__(self):
     show_status_message('Project Selection')
     result = show_quicksearch(self._suggest_projects)
     if result:
         query, projectName = result
         if os.path.isfile(PROJECTSLIST):
             with open(PROJECTSLIST, "r") as f:
                 projects = f.readlines()
         for projectTuple in projects:
             parts = projectTuple.split('|')
             if parts[0].strip() == projectName:
                 self.pane.set_path(as_url(parts[1].strip()))
     clear_status_message()
Exemple #18
0
    def _execute(self, command, path=None, close_on_end=2):
        arg_command = '/command:' + command
        if path is None:
            pane_path = self.pane.get_path()
            path = as_human_readable(pane_path)
        arg_path = '/path:"{}"'.format(path)
        arg_close_on_end = '/closeonend={}'.format(close_on_end)
        exec_command = [
            "TortoiseGitProc.exe", arg_command, arg_path, arg_close_on_end
        ]

        show_status_message(' '.join(exec_command))
        subprocess.run(' '.join(exec_command))
Exemple #19
0
 def __call__(self):
     show_status_message('Remove Favorite Directory')
     result = show_quicksearch(self._suggest_favorite)
     if result:
         query, dirName = result
         if os.path.isfile(FAVORITELIST):
             with open(FAVORITELIST, "r") as f:
                 directories = f.readlines()
             with open(FAVORITELIST, "w") as f:
                 for dirTuple in directories:
                     favName = dirTuple.split('|')[0]
                     if favName != dirName:
                         f.write(dirTuple)
     clear_status_message()
Exemple #20
0
 def __call__(self):
     show_status_message('Remove Regular Expressions Selection')
     result = show_quicksearch(self._suggest_projects)
     if result:
         query, regexp = result
         lines = [""]
         if os.path.isfile(REGULAREXPRESSIONHIST):
             with open(REGULAREXPRESSIONHIST, "r") as f:
                 lines = f.readlines()
             with open(REGULAREXPRESSIONHIST, "w") as f:
                 for line in lines:
                     if line.strip() != regexp:
                         f.write(line + "\n")
     clear_status_message()
Exemple #21
0
 def __call__(self):
     show_status_message('Remove Project Selection')
     result = show_quicksearch(self._suggest_projects)
     if result:
         query, projectName = result
         if os.path.isfile(PROJECTSLIST):
             with open(PROJECTSLIST, "r") as f:
                 projects = f.readlines()
             with open(PROJECTSLIST, "w") as f:
                 for projectTuple in projects:
                     parts = projectTuple.split('|')
                     if parts[0].strip() != projectName:
                         f.write(projectTuple)
     clear_status_message()
Exemple #22
0
 def on_path_changed(self):
     try:
         cmd = 'git rev-parse --abbrev-ref HEAD'
         path = as_human_readable(self.pane.get_path())
         result = subprocess.run(cmd,
                                 stdout=subprocess.PIPE,
                                 cwd=path,
                                 shell=True)
         branch = result.stdout.decode(locale.getpreferredencoding())[:-1]
         if branch != '':
             show_status_message('Git branch ' + branch)
         else:
             show_status_message('')
     except NotADirectoryError as e:
         pass
Exemple #23
0
    def __call__(self):
        show_status_message('Launching a Command Line...')
        result = show_quicksearch(self._suggest_script)
        if result:
            #
            # Launch the script given. Show the output.
            #
            query, script = result
            if query != '':
                script = query

            #
            # Get the variables for this plugin
            #
            scriptVars = _GetScriptVars()

            #
            # Save the command line.
            #
            scriptVars['command_line_history'].append(script)

            #
            # Set the environment variables for the scripts to use.
            #
            os.putenv('cd', as_human_readable(self.pane.get_path()))
            panes = self.pane.window.get_panes()
            os.putenv('lp', as_human_readable(panes[0].get_path()))
            os.putenv('lpf',as_human_readable(panes[0].get_file_under_cursor()))
            os.putenv('rp', as_human_readable(panes[1].get_path()))
            os.putenv('rpf',as_human_readable(panes[1].get_file_under_cursor()))
            os.putenv('cf', os.path.basename(as_human_readable(self.pane.get_file_under_cursor())))

            #
            # Run the script.
            #
            saveDir = os.getcwd()
            os.chdir(as_human_readable(self.pane.get_path()) + os.path.sep)
            scriptLine = "source " + scriptVars['local_shell'] + "; " + script
            Output = run(scriptLine,stdout=PIPE,shell=True)
            os.chdir(saveDir)
            if Output.returncode == 0:
                if scriptVars['show_output']:
                    show_alert(Output.stdout.decode("utf-8"))
                scriptVars['command_line_history'] = CleanCommandLineHistory(scriptVars['command_line_history'])
                _SaveScriptVars(scriptVars)
            else:
                show_alert("Command line error.")
        clear_status_message()
    def __call__(self):
        chosen_files = self.get_chosen_files()

        if chosen_files:
            chosen_files_human_readable = [as_human_readable(resolve(chosen_file)) for chosen_file in chosen_files]

            foobar2000_exe = self._get_foobar2000_exe_path()

            if foobar2000_exe:
                args = [foobar2000_exe, '/immediate', '/add'] # add '/show' to bring foobar2000 to front
                args.extend(chosen_files_human_readable)

                show_status_message("Executed command: {}".format(" ".join(args)), timeout_secs=30) 
                subprocess.call(args)
            else:
                show_alert("SendToFoobar2000: No foobar2000 executable configured. Unable to continue.")
    def _suggest_my_subfolders_and_files(self, query):
        self.limit_file_count = self.FILE_COUNT_LIMIT
        self.folders_found = 0
        self.files_found = 0
        current_folder = as_human_readable(self.current_dir)
        lst_search_items = self.load_files_for_dir(query, current_folder, '')

        # show status message only when limit is reached
        is_full_message = ''
        if self.limit_file_count <= 0:
            is_full_message = "reached load limit"

        show_status_message(
            'folders/files found: ' + str(self.folders_found) + '/' +
            str(self.files_found) + ' ' + is_full_message, 5)

        return lst_search_items
Exemple #26
0
    def run(self):
        _, ext = path.splitext(self.filename)

        try:
            mime_type = types_map[ext]
        except KeyError:
            mime_type = "application/octet-stream"

        with open(self.filepath, 'rb') as f:
            data = f.read()

        headers = {
            "Accept": "*/*",
            "Accept-Encoding": "gzip,deflate",
            "Accept-Language": "en-US,en;q=0.8",
            "Connection": "keep-alive",
            "Content-Length": len(data),
            "Content-Type": mime_type,
            "Host": "transfer.sh",
            "Origin": "https://transfer.sh",
            "Referer": "https://transfer.sh/",
            "User-Agent": "Mozilla/5.0",
            "X_FILENAME": self.filename
        }

        url = "https://transfer.sh/" + self.filename

        req = request.Request(url, data=data, headers=headers, method="PUT")

        try:
            show_status_message("ShareFile: uploading file...")
            with request.urlopen(req, timeout=84600) as resp:
                if resp.status == 200:
                    body = resp.read()
                    share_link = body.decode('utf-8').strip('\n')
                    msg = template.format(share_link, "")
                    set_text(share_link)
                else:
                    msg = template.format("Could not upload file",
                                          str(resp.status) + " " + resp.reason)
                clear_status_message()
                show_alert(msg)
        except URLError as e:
            msg = template.format(e.reason, "")
            show_alert(msg)
Exemple #27
0
 def __call__(self):
     global DBDATA
     show_status_message('NotePad (A)ppend or Over(w)rite')
     npdata = load_json('CopyToNotePad.json')
     if npdata is None:
         npdata = dict()
         npdata['number'] = 3
         npdata['save'] = 'a'
     npappend, result = show_prompt(
         "The 'a'ppend or 'w'rite:")
     if not npappend:
         npappend = 'a'
     npappend = npappend.lower()
     if (npappend != 'a') and (npappend != 'w'):
         npappend = 'a'
     npdata['save'] = npappend
     save_json('CopyToNotePad.json', npdata)
     clear_status_message()
Exemple #28
0
 def __call__(self):
     show_status_message('Favorite Selection')
     result = show_quicksearch(self._suggest_directory)
     if result:
         query, dirName = result
         directories = ["Home|~"]
         if os.path.isfile(FAVORITELIST):
             with open(FAVORITELIST, "r") as f:
                 directories = f.readlines()
         for dirTuple in directories:
             if '|' in dirTuple:
                 favName, favPath = dirTuple.strip().split('|')[0:2]
                 if favName == dirName:
                     if '://' in favPath:
                        self.pane.set_path(expandDirPath(favPath + os.sep))
                     else:
                        self.pane.set_path(as_url(expandDirPath(favPath + os.sep)))
     clear_status_message()
Exemple #29
0
    def __call__(self):
        show_status_message('Getting Services...')
        result = show_quicksearch(self._suggest_script)
        if result:
            #
            # Launch the script given. Show the output.
            #
            query, script = result

            #
            # Run the script.
            #
            Output = run('', stdout=PIPE, shell=True)
            if Output.returncode == 0:
                show_alert(Output.stdout.decode("utf-8"))
            else:
                show_alert("Command line error.")
        clear_status_message()
Exemple #30
0
 def __call__(self):
     show_status_message('Setting the Scripts Directory')
     selected_files = self.pane.get_selected_files()
     if len(selected_files) >= 1 or (len(selected_files) == 0 and self.get_chosen_files()):
         if len(selected_files) == 0 and self.get_chosen_files():
             selected_files.append(self.get_chosen_files()[0])
         dirName = as_human_readable(selected_files[0])
         if os.path.isfile(dirName):
             #
             # It's a file, not a directory. Get the directory
             # name for this file's parent directory.
             #
             dirName = os.path.dirname(dirName)
         scriptDir = _GetScriptVars()
         scriptDir['directory'] = dirName
         _SaveScriptVars(scriptDir)
     else:
         show_alert("Directory not selected.")
     clear_status_message()