def create_user_from_email(context, email): if not context: m = 'Context is "{0}"'.format(context) raise ValueError(m) if type(email) not in (str, unicode): m = 'Email is a "{0}", not a string'.format(type(email)) raise TypeError(m) if not email: m = 'The email address is "{0}"'.format(email) raise ValueError(m) if '@' not in email: m = 'No "@" in the email "{0}"'.format(email) raise ValueError(m) m = 'utils.create_user_from_email: Creating a new user for the '\ 'address <%s>' % email log.info(m) userNum = long(new_md5(asctime() + email).hexdigest(), 16) userId = str(convert_int2b62(userNum)) # Ensure that the user ID is unique. There is also a race # condition, and the loop is non-deterministic. acl_users = __get_acl_users_for_context(context) while (acl_users.getUserById(userId)): userNum = long(new_md5(asctime() + email).hexdigest(), 16) userId = str(convert_int2b62(userNum)) displayName = email.split('@')[0] user = acl_users.simple_register_user(email, userId, displayName) userInfo = IGSUserInfo(user) emailUser = EmailUser(context, userInfo) emailUser.set_delivery(email) # --=mpj17=-- Ensure that the user's profile is owned by the user, and # *only* the user. p = '/'.join(acl_users.getPhysicalPath()).encode('ascii', 'ignore') assign_ownership(user, user.getId(), recursive=0, acl_user_path=p) user.manage_delLocalRoles( [uid for uid in user.users_with_local_role('Owner') if uid != userId]) m = 'utils.create_user_from_email: Created a new user {name} ({id})' msg = m.format(name=user.getProperty('fn', ''), id=user.getId()) log.info(msg) assert user assert isinstance(user, CustomUser) return user
def simplehash(data): """ generate a hex hashkey for a simple dict """ h = new_md5() for key, value in sorted(data.items()): h.update('%s=%s,' % (repr(key), repr(value))) return h.hexdigest()
def perform_experiment_a(experiment_config): from md5 import new as new_md5 from pickle import dumps as pickle_dump from platform import uname from datetime import datetime from threading import Thread from pprint import PrettyPrinter from simple_run import run_test pp = PrettyPrinter(indent=4) print "Running experiment with config:" pp.pprint(experiment_config) current_experiment_id = new_md5( pickle_dump(experiment_config) + str(datetime.now())).hexdigest() info_dict = { 'experiment_id': current_experiment_id, 'start_time': str(datetime.now()), 'scheduler': experiment_config['scheduler'], 'uname_a': ' '.join(uname()), 'cpufreq_governor': get_governor_string(), 'mt_mc_state': get_smt_mc_power_savings(), 'target_load_level': experiment_config['target_load_level'], 'num_of_process': experiment_config['num_of_process'], 'num_of_ops': experiment_config['num_of_ops'] } info_dict.update(get_kernel_olord_settings()) info_dict.update(get_ondemand_settings()) eii.execute(info_dict) test_args = { 'n': experiment_config['num_of_process'], 'a': 'dont_set', 'l': experiment_config['target_load_level'], 'o': experiment_config['num_of_ops'] } class TestThread(Thread): def __init__(self, args): self.args = args Thread.__init__(self) def run(self): self.total_time = run_test(self.args) tt = TestThread(test_args) tt.start() start_time = time() data_counter = 0 while tt.is_alive(): t = time() - start_time data_dict = { 'data_id': current_experiment_id + str(data_counter).zfill(16), 'experiment_id': current_experiment_id, 'time': t, 'voltage': psl.voltage, 'current': psl.current, 'power': psl.power, 'temperature': tl.temperature, 'cpus_online': ocl.online_cpus } eid.execute(data_dict) sleep_time = 1.0 - time() + (t + start_time) sleep_time = 0.0 if (sleep_time < 0) else sleep_time #print sleep_time sleep(sleep_time) data_counter += 1 r = session.query(ExperimentInfo).filter_by( experiment_id=current_experiment_id).first() r.end_time = str(datetime.now()) r.total_time = float(tt.total_time) session.commit()
def perform_experiment_a(experiment_config): from md5 import new as new_md5 from pickle import dumps as pickle_dump from platform import uname from datetime import datetime from threading import Thread from pprint import PrettyPrinter from simple_run import run_test pp = PrettyPrinter(indent = 4) print "Running experiment with config:" pp.pprint(experiment_config) current_experiment_id = new_md5(pickle_dump(experiment_config) + str(datetime.now())).hexdigest() info_dict = {'experiment_id': current_experiment_id, 'start_time': str(datetime.now()), 'scheduler': experiment_config['scheduler'], 'uname_a': ' '.join(uname()), 'cpufreq_governor': get_governor_string(), 'mt_mc_state': get_smt_mc_power_savings(), 'target_load_level': experiment_config['target_load_level'], 'num_of_process': experiment_config['num_of_process'], 'num_of_ops': experiment_config['num_of_ops']} info_dict.update(get_kernel_olord_settings()) info_dict.update(get_ondemand_settings()) eii.execute(info_dict) test_args = {'n': experiment_config['num_of_process'], 'a': 'dont_set', 'l': experiment_config['target_load_level'], 'o': experiment_config['num_of_ops']} class TestThread(Thread): def __init__(self, args): self.args = args Thread.__init__(self) def run(self): self.total_time = run_test(self.args) tt = TestThread(test_args) tt.start() start_time = time() data_counter = 0 while tt.is_alive(): t = time() - start_time data_dict = {'data_id': current_experiment_id + str(data_counter).zfill(16), 'experiment_id': current_experiment_id, 'time': t, 'voltage': psl.voltage, 'current': psl.current, 'power': psl.power, 'temperature': tl.temperature, 'cpus_online': ocl.online_cpus} eid.execute(data_dict) sleep_time = 1.0 - time() + (t + start_time) sleep_time = 0.0 if (sleep_time < 0) else sleep_time #print sleep_time sleep(sleep_time) data_counter += 1 r = session.query(ExperimentInfo).filter_by(experiment_id = current_experiment_id).first() r.end_time = str(datetime.now()) r.total_time = float(tt.total_time) session.commit()