Ejemplo n.º 1
0
    def GetIconName(self):
        if not self.IsExpandable():
            name, ext = os.path.splitext(self.path)
            if ext in ['.py']:  #, '.pyc','.pyo']:
                return "python"
            if ext.lower() in self.imagetypes:
                return "image"
            typ = Spiderutils.istextfile(self.path)
            if typ == 1:
                if Spiderutils.isSpiderDocfile(self.path):
                    return "docfile"
                elif Spiderutils.isSpiderBatchfile(self.path):
                    return "procfile"
                elif Spiderutils.isSpiderProcedurefile(self.path):
                    return "procfile"
                else:
                    return "text"
            elif typ == -1:
                return "unknown"

            spi = Spiderutils.isSpiderBin(self.path)
            if spi == "image" or spi == "Fourier" or spi == "stack":
                return "spider"
            elif spi == "volume":
                return "volume"

            return "binary"  # i.e. a non-spider binary file
Ejemplo n.º 2
0
    def OnDoubleClick(self):
        """Called on a double-click on the icon."""
        self.status.set(self.path)

        # Directories: list them in window
        if os.path.isdir(self.path):
            dirmax = int(self.textbox.limits[3].get())
            dirsize = os.path.getsize(self.path)
            if dirsize > dirmax:
                basename = os.path.basename(self.path)
                txt = "%s may contain a very large number of files.\nDisplay anyway?" % (
                    basename)
                if not askyesno("Warning", txt):
                    return

            cmd = "ls -lF %s " % self.path
            out = getoutput(cmd)
            filelisting = self.path + "\n" + out
            self.textbox.clear()
            self.textbox.settext(filelisting)

        # view text files in window (sometimes pdfs slip thru)
        elif self.ext != ".pdf" and Spiderutils.istextfile(self.path):
            # check if html files are sent to browser
            if self.ext == ".html" or self.ext == ".htm":
                browser = self.textbox.limits[4].get()
                if browser:
                    webbrowser.open(self.path)
                    return

            textmax = self.textbox.limits[2]
            tmax = int(textmax.get())
            textsize = os.path.getsize(self.path)

            if textsize > tmax:
                basename = os.path.basename(self.path)
                txt = "%s is %d bytes.\nDisplay anyway?" % (basename, textsize)
                if not askyesno("Warning", txt):
                    return
            try:
                fp = open(self.path, 'r')
                B = fp.readlines()
            except:
                pass
            fp.close()
            self.textbox.clear()
            for line in B:
                self.textbox.component('text').insert(END, str(line))

        # binaries
        else:
            spidertype = Spiderutils.isSpiderBin(self.path)
            if spidertype != 0:  #== "image":
                infotxt = self.getSpiderInfo(self.path)
                self.textbox.clear()
                self.textbox.component('text').insert(END, infotxt)
                if spidertype == "image":
                    self.putImage(self.path, clear=0)

            elif self.ext.lower() in self.imagetypes:
                self.putImage(self.path)