示例#1
0
    def __new__(cls, parent, metadata):
        '''
		metadata should be a dict
		'''
        if not isinstance(metadata, dict): raise

        left = [str(k) for k in metadata.keys()]
        right = [str(v) for v in metadata.values()]

        from emform import EMParamTable, ParamDef, EMFormWidget

        params = []
        a = EMParamTable(name="Metadata",
                         desc_short="",
                         desc_long="Meta data associated with this image")
        pleft = ParamDef(name="key",
                         vartype="stringlist",
                         desc_short="Key",
                         desc_long="The key of the metadata value object",
                         property=None,
                         choices=left)
        pright = ParamDef(
            name="value",
            vartype="stringlist",
            desc_short="Value",
            desc_long="The value of the metadata object as a string",
            property=None,
            choices=right)

        a.append(pleft)
        a.append(pright)
        params.append(a)

        form = EMFormWidget(parent, params, disable_ok_cancel=True)
        return form
示例#2
0
	def __new__(cls,parent,metadata):
		'''
		metadata should be a dict
		'''
		if not isinstance(metadata,dict): raise
		
		left = [str(k) for k in metadata.keys()]
		right = [str(v) for v in metadata.values()]
		
		from emform import EMParamTable, ParamDef,EMFormWidget
		
		params = []
		a = EMParamTable(name="Metadata",desc_short="",desc_long="Meta data associated with this image")
		pleft = ParamDef(name="key",vartype="stringlist",desc_short="Key",desc_long="The key of the metadata value object",property=None,choices=left)
		pright = ParamDef(name="value",vartype="stringlist",desc_short="Value",desc_long="The value of the metadata object as a string",property=None,choices=right)

		
		a.append(pleft)
		a.append(pright)
		params.append(a)
		
		form = EMFormWidget(parent,params,disable_ok_cancel=True)
		return form
示例#3
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