Exemplo n.º 1
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
Exemplo n.º 2
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
Exemplo n.º 3
0
 def __call__(self):
     cfg = SingletonConfig()
     cfgCurrent, exit_status = cfg.loadConfig()
     if cfgCurrent is None:
         return
     cfg_fmt = "StatusBarExtended's configuration:" +'\n\n'\
         + "Option" + '\t      ' + 'Current' + '\t' + 'Default' +'\n'
     for key in cfg.Default:  # Default is odict, preserving the key order
         if key in ('SizeDivisor'):
             cfg_fmt += key + '\t  =  ' + str(int(
                 cfgCurrent[key])) + "\t" + str(int(
                     cfg.Default[key])) + '\n'
         elif key in ('SymbolPane'):
             cfg_fmt += key + '\t  =  ' + " ".join(
                 cfgCurrent[key]) + "\t" + " ".join(cfg.Default[key]) + '\n'
         elif key in ('SymbolHiddenF'):
             cfg_fmt += key + '=' + " ".join(
                 cfgCurrent[key]) + "\t" + " ".join(cfg.Default[key]) + '\n'
         elif key in ('Justify'):
             cfg_fmt += key + '\t  =  ' + " ".join(
                 str(v)
                 for v in cfgCurrent['Justify'].values()) + "\t" + " ".join(
                     str(v) for v in cfg.Default['Justify'].values()) + '\n'
         else:
             cfg_fmt += key + '\t  =  ' + str(cfgCurrent[key]) + "\t" + str(
                 cfg.Default[key]) + '\n'
     show_alert(cfg_fmt)
Exemplo n.º 4
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)
Exemplo n.º 5
0
    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.")
Exemplo n.º 6
0
    def __call__(self):
        path_to_open = self.pane.get_path()

        if exists(as_human_readable(path_to_open)):
            super().__call__(path_to_open)
        else:
            show_alert('No current path detected!')
Exemplo n.º 7
0
 def safe_file_opened(self, url):
     try:
         self.file_opened(url)
     except:
         # Display a nice error message. (If we don't, fman will display a generic error and swallow the details.)
         show_alert('Error opening path: %s\n\n%s' %
                    (url, traceback.format_exc()))
Exemplo n.º 8
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>.'
			)
Exemplo n.º 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
Exemplo n.º 10
0
def _get_hash(url, hash_type='crc32', consider_names=False):
    # Valid values for hash_type: crc32, crc64, sha1, sha256, blake2sp

    startupinfo = None
    if osname == u'nt':
        startupinfo = subprocess.STARTUPINFO()
        startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW

    # Considering names isn't practical when comparing directories because
    #  it results in a mismatch if only the names of the directories
    #  being compared differ.


#    if consider_names:
#        regHashSearch = re.compile(r'and names:', re.U).search
#        hashIndex = 5
#    else:
#        regHashSearch = re.compile(r'for data:', re.U).search
#        hashIndex = 3
    regHashSearch = re.compile(r'for data:', re.U).search
    hashIndex = 3

    regErrMatch = re.compile(
        u'^(Error:.+|.+     Data Error?|Sub items Errors:.+)', re.U).match

    if _USER_7ZIP:
        sevenZipBinary = _USER_7ZIP
    else:
        sevenZipBinary = _FMAN_7ZIP

    workingFile = as_human_readable(url)

    command = u'"%s" h "-scrc%s" "%s"' % (sevenZipBinary, hash_type,
                                          workingFile)
    if PLATFORM == "Windows":
        command += u' -sccWIN'

    proc = subprocess.Popen(command,
                            stdout=subprocess.PIPE,
                            bufsize=1,
                            stdin=subprocess.PIPE,
                            startupinfo=startupinfo)
    errorLine = u''

    with proc.stdout as out:
        for line in iter(out.readline, b''):
            line = str(line, 'utf8')
            if regErrMatch(line):
                errorLine = line + u''.join(out)
                break
            if regHashSearch(line):
                dataHash = line.split()[hashIndex]

    returnCode = proc.wait()
    if returnCode or errorLine:
        show_alert(u'%s: Get hash failed:\nReturn value: %s\n%s' %
                   (basename(workingFile), str(returnCode), errorLine))
        return None
    else:
        return dataHash
Exemplo n.º 11
0
 def __call__(self):
     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])
         #
         # Loop through each file/directory selected.
         #
         for filedir in selected_files:
             p = as_human_readable(filedir)
             filepath = os.path.abspath(p)
             if os.path.isdir(filepath):
                 #
                 # It is a directory. Process as a directory.
                 #
                 newDir = filepath + "-copy"
                 copy(as_url(filepath), as_url(newDir))
             else:
                 if os.path.isfile(filepath):
                     #
                     # It is a file. Process as a file.
                     #
                     dirPath, ofilenmc = os.path.split(filepath)
                     ofilenm, ext = os.path.splitext(ofilenmc)
                     nfilenm = os.path.join(dirPath,
                                            ofilenm + "-copy" + ext)
                     copy(as_url(filepath), as_url(nfilenm))
                 else:
                     show_alert('Bad file path : {0}'.format(filepath))
Exemplo n.º 12
0
    def __call__(self, url=None):

        if url is None:
            workingFile = self.pane.get_file_under_cursor()
            if workingFile:
                url = workingFile

        oppositePane = _get_opposite_pane(self.pane)
        oppositePaneUrl = oppositePane.get_file_under_cursor()

        # Considering names isn't practical when comparing directories because
        #  it results in a mismatch if only the names of the directories
        #  being compared differ.
        #        if is_dir(url) and is_dir(oppositePaneUrl):
        #            considerNames=True
        #        else:
        #            considerNames=False
        considerNames = False

        thisHash = _get_hash(url,
                             hash_type=_COMPARE_HASH,
                             consider_names=considerNames)
        thatHash = _get_hash(oppositePaneUrl,
                             hash_type=_COMPARE_HASH,
                             consider_names=considerNames)

        if thisHash == thatHash:
            show_alert("Files match.")
        else:
            show_alert("Files differ.")

        return
Exemplo n.º 13
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()
Exemplo n.º 14
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()
Exemplo n.º 15
0
 def __call__(self):
     subprocess.check_call([
         'defaults', 'write', '-g', 'NSFileViewer', '-string',
         'io.fman.fman'
     ])
     show_alert(
         '"Show in Finder" should now open fman instead. Go fman!\n\n'
         'If this doesn\'t take effect in some app, restart that app.')
Exemplo n.º 16
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()
Exemplo n.º 17
0
 def __call__(self):
     scheme = splitscheme(self.pane.get_path())[0]
     if scheme not in ('file://', 'drives://', 'network://'):
         show_alert('Sorry, showing the properties of %s files is not '
                    'yet supported.' % scheme)
     else:
         action = self._get_action()
         if action:
             action()
Exemplo n.º 18
0
 def __call__(self):
     scriptVars = _GetScriptVars()
     shellFile, status = show_prompt("What is your shell script?")
     shellFile = os.path.expanduser(shellFile)
     if not os.path.isfile(shellFile):
         show_alert("Not a real file.")
     else:
         scriptVars['local_shell'] = shellFile
         _SaveScriptVars(scriptVars)
Exemplo n.º 19
0
 def __call__(self):
     fileName = as_human_readable(self.get_chosen_files()[0])
     gpg = GPG()
     myPass, ok = show_prompt('Passphrase')
     # https://stackoverflow.com/questions/4444923/get-filename-without-extension-in-python
     fileNameOut, ok = show_prompt('Target',
                                   default=os.path.splitext(fileName)[0])
     with open(fileName, 'rb') as f:
         status = gpg.decrypt_file(f, passphrase=myPass, output=fileNameOut)
     show_alert('Status: ' + status.status)
Exemplo n.º 20
0
	def __call__(self):
		file_under_cursor = self.pane.get_file_under_cursor()
		if file_under_cursor:
			if platform.system() == "Windows":
				Popen('"%s" %s' % (GITHUB_BINARY, file_under_cursor), shell=True)
			else:
				Popen('%s "%s"' % (GITHUB_BINARY, file_under_cursor), shell=True)

		else:
			show_alert("No file selected.")
Exemplo n.º 21
0
 def __call__(self):
     fileName = as_human_readable(self.get_chosen_files()[0])
     gpg = GPG()
     default_recipient = self._get_default_recipient()
     recipient, ok = show_prompt('Recipient', default=default_recipient)
     with open(fileName, 'rb') as f:
         status = gpg.encrypt_file(f,
                                   recipients=[recipient],
                                   output=fileName + '.gpg')
     show_alert('Status: ' + status.status)
Exemplo n.º 22
0
    def __call__(self):
        url = self.pane.get_path()
        scheme, path = splitscheme(url)

        paths = []
        paths.append(as_url(path))
        if scheme != 'file://':
            show_alert('{} is not supported'.format(url))
            return

        openCommand(" /command:repobrowser /path:", paths, path)
Exemplo n.º 23
0
 def __call__(self):
     #
     # Get the directory path.
     #
     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)
         #
         # Set the directory obtained as a project directory.
         #
         with open(PROJECTDIR, "w") as f:
             f.write(dirName)
         #
         # Add to the list of projects. Get a name
         # from the user.
         #
         projName, checked = show_prompt("Name this Project:")
         projEntry = projName + "|" + dirName
         writeappend = 'w'
         if os.path.isfile(PROJECTSLIST):
             writeappend = 'a'
         with open(PROJECTSLIST, writeappend) as f:
             f.write(projEntry + "\n")
         #
         # Create the launch script file and open in the
         # editor.
         #
         scriptFile = dirName + "/.startproject"
         with open(scriptFile, 'w') as f:
             f.write("#!/bin/sh\n\n")
         os.chmod(scriptFile, stat.S_IEXEC | stat.S_IRUSR | stat.S_IWUSR)
         if (_THIRDPARTY_PLUGINS_DIR +
                 "/OpenWithEditor") in _get_thirdparty_plugins():
             self.pane.run_command("my_open_with_editor",
                                   args={'url': as_url(scriptFile)})
         else:
             self.pane.run_command("open_with_editor",
                                   args={'url': as_url(scriptFile)})
     else:
         #
         # Technically, this will never be reached. Just here
         # for completeness.
         #
         show_alert("No directory selected")
Exemplo n.º 24
0
    def __call__(self):
        outlook = win32.Dispatch('outlook.application')
        mail = outlook.CreateItem(0)
        chosen_files = self.pane.get_selected_files()
        if not chosen_files:
            show_alert('No file selected.')
            return
        for chosen_file in chosen_files:
            file_to_send = as_human_readable(chosen_file)
            mail.Attachments.Add(Source=file_to_send)

        mail.Display(True)
Exemplo n.º 25
0
    def __call__(self):
        selected_files = self.pane.get_selected_files()
        files_num = 0
        files_size = 0
        folders_num = 0
        fsubfiles = 0
        output = "Properties\n\n"

        if len(selected_files) > 1:
            for n in selected_files:
                if path.isdir(n):
                    folders_num += 1
                    fsubfiles += calculate_size_subdirectories(n)
                else:
                    files_num += 1
                    files_size += stat(n).st_size
            if files_num >= 1:
                output += "Selected files:\t\t\t" + str(files_num) + "\n"
                output += "Combined filesize:\t\t" + str(
                    convert_bytes(files_size)) + "\n\n"
            if folders_num >= 1:
                output += "Selected directories:\t\t" + str(folders_num) + "\n"
                output += "Combined size for directories::\t" + str(
                    convert_bytes(fsubfiles)) + "\n\n"

        elif len(selected_files) == 1 or (len(selected_files) == 0
                                          and self.get_chosen_files()):
            if len(selected_files) == 1:
                n = selected_files[0]
            elif len(selected_files) == 0 and self.get_chosen_files():
                n = self.get_chosen_files()[0]
            files_size += stat(n).st_size
            finfo = stat(n)
            flastmodified = datetime.date.fromtimestamp(finfo.st_mtime)
            flastaccessed = datetime.date.fromtimestamp(finfo.st_atime)
            fsize = finfo.st_size
            output += n + "\n\n"
            output += "Last viewed:\t\t\t" + str(flastaccessed) + "\n"
            output += "Last modified:\t\t\t" + str(flastmodified) + "\n\n"
            output += "Size:\t\t\t" + str(convert_bytes(fsize)) + "\n"
            if path.isdir(n):
                folders_num += 1
                fsubfiles = calculate_size_subdirectories(n)
                output += "Total size subdirectories and files:\t" + str(
                    convert_bytes(fsubfiles)) + "\n"
            else:
                files_num += 1

        else:
            output += "No files or directories selected"

        show_alert(output)
Exemplo n.º 26
0
 def __call__(self):
     url = self.pane.get_path()
     scheme, path = splitscheme(url)
     if scheme != 'file://':
         show_alert('Not supported.')
         return
     local_path = as_human_readable(url)
     if platform.system() == 'Windows' and os.path.isfile(self.GIT_BASH):
         subprocess.call('{bash_exe} --cd="{cd}"'.format(
             bash_exe=self.GIT_BASH,
             cd=local_path))
     else:
         self.pane.run_command('open_terminal')
Exemplo n.º 27
0
    def __call__(self, url=None):

        if url is None:
            workingFile = self.pane.get_file_under_cursor()
            if workingFile:
                url = workingFile

        hash = _get_hash(url, hash_type=_HASH)

        if hash:
            show_alert(hash)

        return
Exemplo n.º 28
0
    def __call__(self):
        keybindings_json = load_json('Key Bindings.json')
        keybindings_output = ""

        for keybind in keybindings_json:
            command = str(keybind['command'].capitalize().replace('_', ' '))
            key = str(keybind['keys']).replace('[\'', '').replace('\']', '')
            tab = "\t"
            tab_num = 1
            keybindings_output += key + (tab *
                                         tab_num) + " = " + command + "\n"

        show_alert(keybindings_output)
Exemplo n.º 29
0
 def __call__(self):
     fmanVer = "unknown"
     try:
         fmanVer = fman.FMAN_VERSION
     except:
         fmanVer = "unknown"
     apiVer = "unknown"
     try:
         apiVer = fman.API_VERSION
     except:
         apiVer = "unknown"
     outStr = "fman Version:\t{0}\n".format(fmanVer)
     outStr += "fman Api Version:\t{0}\n".format(apiVer)
     outStr += "Python Version:\t{0}.{1}.{2}\n".format(sys.version_info[0], sys.version_info[1], sys.version_info[2])
     fman.show_alert(outStr)
Exemplo n.º 30
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()