示例#1
0
#!/usr/bin/env python

import sys

from myemsl.dbconnect import myemsldb_connect
from myemsl.getconfig import getconfig_secret
config = getconfig_secret()

from myemsl.logging import getLogger
from myemsl.metadata import get_proposals_from_user, get_custodian_instruments, get_proposals_from_instrument, get_proposal_info

logger = getLogger(__name__)

def get_network_id_to_person_id_hash():
	user_hash = {}
	try:
		sql = "select person_id, network_id from eus.users where network_id is not null"
		cnx = myemsldb_connect(myemsl_schema_versions=['1.0'])
		cursor = cnx.cursor()
		cursor.execute(sql)
		rows = cursor.fetchall()
		for row in rows:
			if row[1] != None and row[1] != '':
				user_hash[row[1].upper()] = row[0]
	except Exception, e:
		logger.error("%s", e)
		raise
	return user_hash

def get_permission_group_members(type, name):
	group_members = []
示例#2
0
#!/usr/bin/python

import os
import sys
import struct
import simplejson as json
import pymongo
import pymongo.errors
from myemsl.service.rmds.notify import notify
from myemsl.getconfig import getconfig_notification

config = getconfig_notification('rmds')

from myemsl.logging import getLogger

logger = getLogger(__name__)

def add(user, data):
	version = 1
	j = json.load(data)
	item_id = j['_id']
#FIXME make metadata collection usable with different mongodb host/database.
	host = config.notification.hostname
	port = config.notification.port
	client = pymongo.Connection(host, port)
#FIXME make this configurable
	db = 'pacifica_db'
	db = client[db]
	rmds_collection = pymongo.collection.Collection(db, "rmds_collection", create=False)
	try:
#FIXME make w configurable for safety.