Example #1
0
def display_file(filename,app,force_2d=False,usescenegraph=False):
	w = EMWidgetFromFile(filename,application=app,force_2d=force_2d)
	w.setWindowTitle(base_name(filename))
	app.show_specific(w)
	try: w.optimally_resize()
	except: pass
	try: w.raise_()
	except: pass
	return w
Example #2
0
def display_file(filename,app,force_2d=False,usescenegraph=False):
	w = EMWidgetFromFile(filename,application=app,force_2d=force_2d)
	w.setWindowTitle(base_name(filename))
	app.show_specific(w)
	try: w.optimally_resize()
	except: pass
	try: w.raise_()
	except: pass
	return w
Example #3
0
	def __init__(self,file_name):
		'''
		@param file_name the name of the file that which is being overwritten
		@exception raised if the file_name does not exist on the file system
		@exception raised if the file_name has a unrecognized (or no) type
		'''
		if not os.path.exists(file_name): raise
		splt = file_name.split(".")
		if len(splt) < 2: raise
		if EMUtil.get_image_ext_type(splt[-1]) == EMUtil.ImageType.IMAGE_UNKNOWN:
			raise
		self.__file_ext = "."+splt[-1]
		
		EMTmpFileHandleBase.__init__(self)
		self.__file_name = base_name(file_name)
		self.__full_file_name = file_name
		self.__tmp_file_name = None
		self.__establish_tmp_file_name()
Example #4
0
    def __init__(self, file_name):
        '''
		@param file_name the name of the file that which is being overwritten
		@exception if either the .hed or .img file corrsponding to the old_file_name does not exist on the file system
		@exception if the old_file_name is not an imagic file
		'''

        splt = file_name.split(".")
        if len(splt) < 2 or splt[-1] not in ["img", "hed"]: raise

        self.__file_name_root = base_name(file_name)

        if not os.path.exists(self.__file_name_root + ".img"): raise
        if not os.path.exists(self.__file_name_root + ".hed"): raise

        EMTmpFileHandleBase.__init__(self)
        self.__file_name_root_hed = self.__file_name_root + ".hed"
        self.__file_name_root_img = self.__file_name_root + ".img"
        self.__establish_tmp_file_name()
Example #5
0
	def __init__(self,file_name):
		'''
		@param file_name the name of the file that which is being overwritten
		@exception if either the .hed or .img file corrsponding to the old_file_name does not exist on the file system
		@exception if the old_file_name is not an imagic file
		'''
		
		splt = file_name.split(".")
		if len(splt) < 2 or splt[-1] not in ["img","hed"]: raise
		
		self.__file_name_root = base_name(file_name)
		
		if not os.path.exists(self.__file_name_root+".img"): raise
		if not os.path.exists(self.__file_name_root+".hed"): raise
		
		EMTmpFileHandleBase.__init__(self)
		self.__file_name_root_hed = self.__file_name_root+".hed"
		self.__file_name_root_img = self.__file_name_root+".img"
		self.__establish_tmp_file_name()
Example #6
0
    def get_history_table(self):
        from eman2_gui.emdatastorage import ParamDef
        try:
            import EMAN2db
            db = EMAN2db.EMAN2DB.open_db()
            db.open_dict("history")
        except:
            db = None

        params = []

        try:
            n = int(db.history["count"])
        except:
            n = 0

        if db == None or n == 0:
            params.append(
                ParamDef(name="blurb",
                         vartype="text",
                         desc_short="",
                         desc_long="",
                         property=None,
                         defaultunits=
                         "There appears to be no history in this directory",
                         choices=None))
        else:
            from eman2_gui.emform import EMParamTable
            start = []
            duration = []
            prgargs = []
            cmd = []
            full_cmd = []

            params.append(
                ParamDef(
                    name="blurb",
                    vartype="text",
                    desc_short="",
                    desc_long="",
                    property=None,
                    defaultunits=
                    "Use this form to examine the EMAN2 commands that have occurred in this directory.",
                    choices=None))
            p = EMParamTable(name="commands",
                             desc_short="Historical table of EMAN2 commands",
                             desc_long="")

            for i in range(n):
                try:
                    h = db.history[i + 1]
                except:
                    continue

                if h != None and "path" in h and h["path"] == self.wd:
                    start.append(local_datetime(h["start"]))
                    if "end" in h:
                        duration.append(time_diff(h["end"] - h["start"]))
                    else:
                        if "progress" in h:
                            try:
                                duration.append(
                                    str(int(h["progress"] * 100)) + "%")
                            except:
                                duration.append("incomplete")
                        else:
                            duration.append("incomplete")

                    args = h["args"]
                    if len(args) > 0:
                        cmd.append(base_name(args[0]))
                        full_cmd.append(args[0])
                        if len(args) > 1:
                            prgargs.append(" ".join(args[1:]))
                        else:
                            prgargs.append("")
                    else:
                        cmd.append("")
                        full_cmd.append("")
                        prgargs.append("")

            pcmd = ParamDef(
                name="cmd",
                vartype="stringlist",
                desc_short="Program",
                desc_long=
                "A shortened version of the name of a Python program that was executed",
                property=None,
                defaultunits=None,
                choices=cmd)
            pstart = ParamDef(
                name="start",
                vartype="stringlist",
                desc_short="Start time",
                desc_long="The time when the command was first executed",
                property=None,
                defaultunits=None,
                choices=start)
            pduration = ParamDef(
                name="duration",
                vartype="stringlist",
                desc_short="Duration",
                desc_long="The time taken to execute this command",
                property=None,
                defaultunits=None,
                choices=duration)
            pfull_cmd = ParamDef(name="fullcmd",
                                 vartype="stringlist",
                                 desc_short="File path",
                                 desc_long="The location of program on disk",
                                 property=None,
                                 defaultunits=None,
                                 choices=full_cmd)
            pargs = ParamDef(
                name="args",
                vartype="stringlist",
                desc_short="Arguments",
                desc_long="The arguments that were given to the program",
                property=None,
                defaultunits=None,
                choices=prgargs)

            p.append(pcmd)
            p.append(pstart)
            p.append(pduration)
            p.append(pargs)
            p.append(pfull_cmd)
            params.append(p)

        return params
Example #7
0
 	def get_history_table(self):
 		from emdatastorage import ParamDef
 		try:
			import EMAN2db
			db=EMAN2db.EMAN2DB.open_db()
			db.open_dict("history")
		except:
			db=None
		
		params = []
		
		try:
			n=int(db.history["count"])
		except:
			n = 0
		
		if db == None or n == 0:
			params.append(ParamDef(name="blurb",vartype="text",desc_short="",desc_long="",property=None,defaultunits="There appears to be no history in this directory",choices=None))
		else:
			from emform import EMParamTable
			start = []
			duration = []
			prgargs = []
			cmd = []
			full_cmd = []
			
			params.append(ParamDef(name="blurb",vartype="text",desc_short="",desc_long="",property=None,defaultunits="Use this form to examine the EMAN2 commands that have occurred in this directory.",choices=None))
			p = EMParamTable(name="commands",desc_short="Historical table of EMAN2 commands",desc_long="") 
			
			for i in range(n):
				try: h=db.history[i+1]
				except: continue
				
				if h != None and h.has_key("path") and h["path"]==self.wd:
					start.append(local_datetime(h["start"]))
					if h.has_key("end") :
						duration.append(time_diff(h["end"]-h["start"]))
					else:
						if h.has_key("progress"):
							try:
								duration.append(str(int(h["progress"]*100))+"%")
							except:
								duration.append("incomplete")
						else: duration.append("incomplete")
					
					
					args = h["args"]
					if len(args) > 0:
						cmd.append(base_name(args[0]))
						full_cmd.append(args[0])
						if len(args) > 1:
							prgargs.append(" ".join(args[1:]))
						else:prgargs.append("")
					else:
						cmd.append("")
						full_cmd.append("")
						prgargs.append("")
						
				
			pcmd = ParamDef(name="cmd",vartype="stringlist",desc_short="Program",desc_long="A shortened version of the name of a Python program that was executed",property=None,defaultunits=None,choices=cmd)
			pstart = ParamDef(name="start",vartype="stringlist",desc_short="Start time",desc_long="The time when the command was first executed",property=None,defaultunits=None,choices=start)
			pduration = ParamDef(name="duration",vartype="stringlist",desc_short="Duration",desc_long="The time taken to execute this command",property=None,defaultunits=None,choices=duration)
			pfull_cmd = ParamDef(name="fullcmd",vartype="stringlist",desc_short="File path",desc_long="The location of program on disk",property=None,defaultunits=None,choices=full_cmd)
			pargs = ParamDef(name="args",vartype="stringlist",desc_short="Arguments",desc_long="The arguments that were given to the program",property=None,defaultunits=None,choices=prgargs)
			
	
			p.append(pcmd)
			p.append(pstart)
			p.append(pduration)
			p.append(pargs)
			p.append(pfull_cmd)
			params.append(p)
	
	
 		return params