Пример #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
Пример #2
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
Пример #3
0
def writedoc(filename, column1=1, column2=0):
    column1 = integer(column1)
    column2 = integer(column2)
    # if file already exists
    if os.path.exists(filename):
        # if it's a doc file, try to get the last key
        if Spiderutils.isSpiderDocfile(filename):
            lastline = getoutput("tail -1 %s" % filename)
            if len(lastline) > 0:
                key = 1 + int(string.split(lastline)[0])
            else:
                key = 1
        else:
            # if it's not a doc file...
            os.remove(filename)
            key = 1

        data = "%5d 2 %11d% 11d\n" % (key, column1, column2)

        try:
            fp = open(filename, 'a')  # append
            fp.write(data)
            fp.close()
        except:
            print "unable to write to %s" % filename
            return 0
    # if it's a new file
    else:
        try:
            fp = open(filename, 'w')
            fname = os.path.basename(filename)
            ext = os.path.splitext(filename)[1]
            ext = ext[1:]  # remove dot
            date, time, id = Spiderutils.nowisthetime()
            h = " ;ctf/%s   %s AT %s   %s\n" % (ext, date, time, fname)
            fp.write(h)
            fp.write(" ; /     MICROGRAPH   DEFOCUS\n")
            key = 1
            data = "%5d 2 %11d %11d\n" % (key, column1, column2)
            fp.write(data)
            fp.close()
        except:
            print "unable to create %s" % filename
            return 0
    return 1
Пример #4
0
def writedoc(filename, column1=1, column2=0):
    column1 = integer(column1)
    column2 = integer(column2)
    # If file already exists
    if os.path.exists(filename):
        # if it's a doc file, try to get the last key
        if Spiderutils.isSpiderDocfile(filename):
            lastline = getoutput("tail -1 %s" % filename)
            if len(lastline) > 0:
                key = 1 + int(string.split(lastline)[0])
            else:
                key = 1
        else:
            # if it's not a doc file...
            os.remove(filename)
            key = 1
            
        data = "%5d 2 %11d% 11d\n" % (key, column1, column2)

        try:
            fp = open(filename, 'a')  # append
            fp.write(data)
            fp.close()
        except:
            print "Unable to write to %s" % filename
            return 0
    # if it's a new file
    else:
        try:
            fp    = open(filename, 'w')
            fname = os.path.basename(filename)
            ext   = os.path.splitext(filename)[1]
            ext   = ext[1:] # remove dot
            date,time,id = Spiderutils.nowisthetime()
            h = " ;ctf/%s   %s AT %s   %s\n" % (ext,date,time,fname)
            fp.write(h)
            fp.write(" ; /     MICROGRAPH   DEFOCUS\n")
            key  = 1
            data = "%5d 2 %11d %11d\n" % (key, column1, column2)
            fp.write(data)
            fp.close()
        except:
           print "Unable to create %s" % filename
           return 0
    return 1