def __init__(self, conf): self._init_keys(conf) config = cwconfig.instance_configuration(conf.get('cubicweb-instance')) repo = Repository(config, TasksManager(), vreg=None) portal = Portal(CubicWebSFTPRealm(repo, conf)) portal.registerChecker(CubicWebCredentialsChecker(repo)) self.portal = portal
def __init__(self, instance_name, login, password): """ Initialize the WaveImporter class. Parameters ---------- instance_name: str (mandatory) the name of the cubicweb instance based in the 'snapview' cube. login: str (mandatory) a login. password: str (mandatory) the corresponding password. """ # Create a cw session config = cwconfig.instance_configuration(instance_name) self.repo, self.cnx = in_memory_repo_cnx( config, login=login, password=password) self.session = self.repo._get_session(self.cnx.sessionid)
def __init__(self, conf): """ Initialize the 'CubicWebSSHdFactory' class. Parameters ---------- conf: logilab.common.configuration.Configuration (mandatory) the server configuration options. """ self._init_keys(conf) # Deal with multiple instances cw_instance_names = conf.get("cubicweb-instance").split(":") cw_repositories = [] for instance_name in cw_instance_names: config = cwconfig.instance_configuration(cw_instance_names[0]) cw_repositories.append( Repository(config, TasksManager(), vreg=None)) # A Portal associates one Realm with a collection of CredentialChecker # instances. portal = Portal( CubicWebSFTPRealm(cw_instance_names, cw_repositories, conf)) portal.registerChecker(CubicWebCredentialsChecker(cw_repositories)) self.portal = portal
def run(args): """run the command line tool""" try: opts, args = getopt.getopt(args, 'hn:t:u:p:P:o:', [ 'help', 'user='******'password='******'nb-times=', 'nb-threads=', 'profile', 'report-output=', ]) except Exception as ex: print(ex) usage(1) repeat = 100 threads = 1 user = os.environ.get('USER', os.environ.get('LOGNAME')) password = None report_output = sys.stdout prof_file = None for opt, val in opts: if opt in ('-h', '--help'): usage() if opt in ('-u', '--user'): user = val elif opt in ('-p', '--password'): password = val elif opt in ('-n', '--nb-times'): repeat = int(val) elif opt in ('-t', '--nb-threads'): threads = int(val) elif opt in ('-P', '--profile'): prof_file = val elif opt in ('-o', '--report-output'): report_output = open(val, 'w') if len(args) != 2: usage(1) queries = [query for query in lines(args[1]) if not query.startswith('#')] if user is None: user = raw_input('login: '******'password: '******'times' else: QueryExecutor(cnx, repeat, queries, reporter=reporter).run() reporter.dump_report(report_output)
"user2": { "login": "******", "password": "******", "group_names": ["toy_V1", "users"] }, "user3": { "login": "******", "password": "******", "group_names": ["toy", "users"] } } STUDY_NAME = "toy" CENTER_NAME = "home" # Create a cw session config = cwconfig.instance_configuration(instance_name) repo, cnx = in_memory_repo_cnx(config, login=login, password=password) session = repo._get_session(cnx.sessionid) # Parse the file system subjects = subject_parser(demo_path, STUDY_NAME) scans = scan_parser(demo_path, STUDY_NAME) questionnaires = questionnaire_parser(demo_path, STUDY_NAME) genetics = genetic_parser(demo_path, STUDY_NAME) processings = freesurfer_parser(demo_path, STUDY_NAME) # Define all the importers db_grp_importer = CWGroups(session, ["toy_V0", "toy_V1", "toy", "uploaders"], use_store=False) db_user_importer = CWUsers(session, USERS) db_subject_importer = Subjects(
"user2": { "login": "******", "password": "******", "group_names": ["toy_V1", "users"] }, "user3": { "login": "******", "password": "******", "group_names": ["toy", "users"] } } STUDY_NAME = "toy" CENTER_NAME = "home" # Create a cw session config = cwconfig.instance_configuration(instance_name) repo, cnx = in_memory_repo_cnx(config, login=login, password=password) session = repo._get_session(cnx.sessionid) # Parse the file system subjects = subject_parser(demo_path, STUDY_NAME) scans = scan_parser(demo_path, STUDY_NAME) questionnaires = questionnaire_parser(demo_path, STUDY_NAME) genetics = genetic_parser(demo_path, STUDY_NAME) processings = freesurfer_parser(demo_path, STUDY_NAME) # Define all the importers db_grp_importer = CWGroups(session, ["toy_V0", "toy_V1", "toy", "uploaders"], use_store=False) db_user_importer = CWUsers(session, USERS) db_subject_importer = Subjects(session, STUDY_NAME, subjects, use_store=False)