Exemple #1
0
    def action_open(self, wf):

        path = wf.localPath
        # todo: get pwd, pass to proc_exec
        cmdstr = Settings.instance()['cmd_edit_text']

        proc_exec(cmdstr % (path))
Exemple #2
0
def _compress(pwd, arc_path, paths):

    # TODO: method to override the mode
    #  flag `--mode tar.xz` when type cannot be infered from ext
    # pass mode, submode into this function, instead of extracting from path
    # TODO: mode transforms
    #   e.g. 7zip -> 7z

    mode,submode = _mode(arc_path)

    if mode == "7z":
        cmd = ["7za", "a", arc_path] + paths
    elif mode == "zip":
        cmd = ["zip", arc_path] + paths
    elif submode == "tar":
        if mode == "gz":
            cmd = ["tar", "-czvf", arc_path] + paths
        elif mode == "bz2":
            cmd = ["tar", "-cjvf", arc_path] + paths
        else:
            cmd = ["tar", "-cvf", arc_path] + paths
    else:
        raise Exception("Unrecognized mode: %s.%s"%(submode,mode))

    proc_exec(cmd, pwd, blocking=True)
Exemple #3
0
    def action_edit(self, item):

        path = self.view.realpath(item['name'])

        if self.view.isdir(path):
            pwd = path
        else:
            pwd, _ = self.view.split(path)

        if FileAssoc.isImage(path):
            cmdstr = Settings.instance()['cmd_edit_image']
            proc_exec(cmdstr % (path), pwd)
        else:  #if FileAssoc.isText(path):

            cmdstr = Settings.instance()['cmd_edit_text']
            proc_exec(cmdstr % (path), pwd)
Exemple #4
0
def _extract(arc_path, directory):

    mode,submode = _mode(arc_path)

    if mode == "7z":
        cmd = ["7za", "x", arc_path]
    elif mode == "zip":
        cmd = ["unzip", arc_path]
    elif submode == "tar":
        if mode == "gz":
            cmd = ["tar", "-xzvf", arc_path]
        elif mode == "bz2":
            cmd = ["tar", "-xjvf", arc_path]
        else:
            cmd = ["tar", "-xvf", arc_path]
    else:
        raise Exception("Unrecognized mode: %s.%s"%(submode,mode))

    os.chdir(directory)

    proc_exec(cmd, directory, blocking=True)
Exemple #5
0
    def _action_open_file_local(self, view, path):
        cmdstr_img = Settings.instance()['cmd_edit_image']

        if view.isdir(path):
            pwd = path
        else:
            pwd, _ = view.split(path)

        if isArchiveFile(path):
            self.openAsTab.emit(view, path)

        elif FileAssoc.isImage(path) and cmdstr_img:
            proc_exec(cmdstr_img % (path), pwd)
        elif FileAssoc.isText(path):
            cmdstr = Settings.instance()['cmd_edit_text']
            proc_exec(cmdstr % (path), pwd)
        elif FileAssoc.isAudio(path):
            cmdstr = Settings.instance()['cmd_play_audio']
            proc_exec(cmdstr % (path), pwd)
        elif FileAssoc.isMovie(path):
            cmdstr = Settings.instance()['cmd_play_video']
            proc_exec(cmdstr % (path), pwd)
        elif not fileIsBinary(view, path):
            cmdstr = Settings.instance()['cmd_edit_text']
            proc_exec(cmdstr % (path), pwd)
        else:
            cmdstr = Settings.instance()['cmd_open_native']
            proc_exec(cmdstr % (path), pwd)
Exemple #6
0
    def action_open_term(self):

        cmdstr = Settings.instance()['cmd_launch_terminal']
        path = self.view.pwd()
        proc_exec(cmdstr % (path), path)
Exemple #7
0
 def action_openas(self, cmdstr_base, item):
     path = self.view.realpath(item['name'])
     if self.view.isdir(path):
         return
     pwd, _ = self.view.split(path)
     proc_exec(cmdstr_base % (path), pwd)
Exemple #8
0
    def editSettings(self):

        cmdstr = Settings.instance()['cmd_edit_text']
        path = YmlSettings.instance().path()
        proc_exec(cmdstr % (path), os.getcwd())