Esempio n. 1
0
def render_folder(server, _id, path):
	'''
	creation of .json and .h5 files within the child `analogsignal` folder '''
	if _id:
		g_session = session.init()
		obj = g_session.pull('electrophysiology/analogsignal/%s' %_id)
		server.create(path + "/meta.json", 33345, 33204)
		server.write(path + "/meta.json", str(obj.__dict__), 0L)
		# print("analogsi id: %s,  data id: %s" %(_id, g_session._cache.h5_map[_id] ))
		if g_session._cache._Cache__h5_map.has_key(_id): # if data.h5 exists in the gnode cache directory	
			server.create(path + "/data.h5", 33345, 33204)
			server.write(path + "/data.h5", copy_content_h5(_id, g_session), 0L) # obj.tostring() != copy_content_h5()
Esempio n. 2
0
def render_structure(server, config_file='../default.json', models_file='../requirements.json'):
	'''
	this function is used for rendering the structure of the `/analogsignals` folder.
	The list of child folders are created within the `/analogsignals`. '''
	# stop()
	server.mkdir("/analogsignals", 509)
	g_session = session.init(config_file, models_file)
	items = g_session.ls('analogsignal', returnObj=True)
	cacheFuse = dict()
	for item in items:
		if item.name:
			cacheFuse[item.name] = item._gnode['id']
			path = "/analogsignals/%s" %item.name
			server.mkdir(path, 509, link=item._gnode['permalink'], _id=item._gnode['id'])
	save_cacheFuse(cacheFuse)
Esempio n. 3
0
			cacheFuse[item.name] = item._gnode['id']
			path = "/analogsignals/%s" %item.name
			server.mkdir(path, 509, link=item._gnode['permalink'], _id=item._gnode['id'])
	save_cacheFuse(cacheFuse)

def render_folder(server, _id, path):
	'''
	creation of .json and .h5 files within the child `analogsignal` folder '''
	if _id:
		g_session = session.init()
		obj = g_session.pull('electrophysiology/analogsignal/%s' %_id)
		server.create(path + "/meta.json", 33345, 33204)
		server.write(path + "/meta.json", str(obj.__dict__), 0L)
		# print("analogsi id: %s,  data id: %s" %(_id, g_session._cache.h5_map[_id] ))
		if g_session._cache._Cache__h5_map.has_key(_id): # if data.h5 exists in the gnode cache directory	
			server.create(path + "/data.h5", 33345, 33204)
			server.write(path + "/data.h5", copy_content_h5(_id, g_session), 0L) # obj.tostring() != copy_content_h5()
		

def copy_content_h5(_id, gnodeSession):
	file_cache = gnodeSession._cache._meta.cache_dir + "/%s.h5" %gnodeSession._cache._Cache__h5_map[_id] 
	with open(file_cache, 'r') as ifile:
		content = ifile.read()
	return content

if __name__ == '__main__':
	config_file='../gnode_client/default.json'
	models_file='../gnode_client/requirements.json'
   	g_session = session.init(config_file, models_file)
   	items = g_session.ls('analogsignal', returnObj=True)
   	# stop()
Esempio n. 4
0
	def __init__(self):
		self.g_session = session.init(GNODE_GONFIG, GNODE_MODELS)