コード例 #1
0
ファイル: yogo.py プロジェクト: gic888/mienblocks
 def download(self, event=None, record=None, append=True, refresh=True):
     if not record:
         ids = self.list(None)
         d = self.askParam([{"Name": "Which Record?", "Type": "List", "Value": ids}])
         if not d:
             return
         record = d[0]
     df = self.rest.getFile(record)
     doc = deserialize(df)
     if not append:
         self.Parent.newDoc(doc)
     else:
         m = self.rest.getInfo(record)["metadata"]
         m = dict([("meta_" + k, m[k]) for k in m])
         m["Name"] = record
         m["DBrecord"] = self.rest.path
         m["DBurl"] = self.rest.url
         m["color"] = (255, 255, 255)
         group = createElement("Group", m)
         self.Parent.document.newElement(group)
         for e in doc.elements[:]:
             e.move(group)
         if refresh:
             self.Parent.update_all(element=self.Parent.document, action="rebuild")
コード例 #2
0
ファイル: remoteeval.py プロジェクト: gic888/MIEN
	def run(self):
		doc=self.send('get object')
		self.doc=mzip.deserialize(doc)
		print 'client registered' 		
		while not self.abort:
			self.doJob()
コード例 #3
0
# This program is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc., 59 Temple
# Place, Suite 330, Boston, MA 02111-1307 USA
#

from mien.interface.cellview3D import CellViewer
import wx, os, sys, tempfile
from mien.parsers.mzip import deserialize
sys.path.append("/home/gic/mienblocks")
from ccbcv.rest import PSDB

URL = 'http://cercus.cns.montana.edu:8090'
PATH = '/CercalCellAfferent/'
CERCDB = PSDB(URL, PATH)
os.environ['DISPLAY'] = 'localhost:1.0'
record = sys.argv[1]
wxapp = wx.PySimpleApp()
x = CellViewer()
x.Show(True)
df = CERCDB.getFile(record)
doc = deserialize(df)
x.newDoc(doc)
fid, fname=tempfile.mkstemp('.png')
x.graph.screenShot(fname)
CERCDB.putFile(record, open(fname,'rb').read(), "snapshot", 'image/png')
os.unlink(fname)
コード例 #4
0
ファイル: scripts.py プロジェクト: gic888/mienblocks
def dbscript(lfn):
    """The first argument should be a command. Allowed commands are:
	add, set, del, list, info, pull, metas, file

	add takes a list of file names to add to the db. 
	set takes a DB id, meta tag, and value, and sets the indicated 
		tag on the indicated object to the value
	del deletes the listed DB ids. The first ID may be "all" to 
		clear the db.
	list takes no arguments and prints a list of ids of the db entries
	info takes a list of ids and prints detailed info about each
	pull takes a db id and a file name, and downloads the datafile
		associated to the id into the named file. 
	metas list all the defined metadata tags in the db
	file  takes a db id, an attribute name (e.g. image) and a file name
		downloads the named file attribute into the named file
	"""
    cmd = lfn[0]
    PATH = "/CercalSystem/"
    CERCDB = PSDB(URL, PATH)
    CERCDB.auth("gic", "graham")
    if cmd == "del":
        lfn = lfn[1:]
        if lfn and lfn[0] == "all":
            lfn = CERCDB.getIDList()
        for name in lfn:
            CERCDB.delete(name)
            print "deleted entry %s" % name
    elif cmd == "add":
        for fn in lfn[1:]:
            doc = io.read(fn)
            groups = doc.getElements("Group", depth=1)
            groups = [g for g in groups if g.attrib("DBrecord")]
            if groups:
                for grp in groups:
                    print ("Commiting db group %s from %s" % (grp.name(), fn))
                    m = dict([(k[5:], grp.attrib(k)) for k in grp.attributes if k.startswith("meta_")])
                    name = grp.name()
                    name = name.replace(".", "_")
                    s = serialize(None, grp)
                    if grp.attrib("DBurl") == URL and grp.attrib("DBrecord") == PATH:
                        db = CERCDB
                    else:
                        db = PSDB(grp.attrib("DBurl"), grp.attrib("DBrecord"))
                    db.addOrUpdate(name, m, s)
            else:
                m = db_getmetas(doc)
                if "dbid" in m:
                    name = m["dbid"]
                    del (m["dbid"])
                else:
                    name = "%s_%s_%s" % (m["length"][0].upper(), str(m["class"]), str(m["slide_number"]))
                print "commiting %s as %s" % (fn, name)
                s = serialize(None, doc)
                CERCDB.addOrUpdate(name, m, s)
    elif cmd == "set":
        iid = lfn[1]
        tag = lfn[2]
        val = lfn[3]
        nmd = {tag: val}
        CERCDB.update(iid, nmd)
    elif cmd == "list":
        for iid in CERCDB.getIDList():
            print (iid)
    elif cmd == "info":
        l = CERCDB.get(CERCDB.path)
        lidd = dict([(e["id"], e) for e in l])
        for id_ in lfn[1:]:
            e = lidd.get(id_, "No such entry")
            print (e)
    elif cmd == "pull":
        record = lfn[1]
        fname = lfn[2]
        df = CERCDB.getFile(record)
        doc = deserialize(df)
        doc = io.write(doc, fname, format="guess")
    elif cmd == "metas":
        l = CERCDB.get(CERCDB.path)
        metas = set([])
        for e in l:
            md = e["metadata"]
            for k in md:
                metas.add(k)
        for k in metas:
            print (k)
    elif cmd == "file":
        record = lfn[1]
        fpath = lfn[2]
        fname = lfn[3]
        df = CERCDB.getFile(record, fpath)
        open(fname, "wb").write(df)
コード例 #5
0
ファイル: pullVaric.py プロジェクト: gic888/mienblocks
def getVaric(iid):
	df = CERCDB.getFile(iid)
	doc = deserialize(df)
	var = doc.getElements('Fiducial', {"Style":"spheres"})
	return var