def setUpClass(cls):
     token = environ.get('KB_AUTH_TOKEN', None)
     config_file = environ.get('KB_DEPLOYMENT_CONFIG', None)
     cls.cfg = {}
     config = ConfigParser()
     config.read(config_file)
     for nameval in config.items('AssemblyUtil'):
         cls.cfg[nameval[0]] = nameval[1]
     authServiceUrl = cls.cfg.get('auth-service-url',
                                  'https://kbase.us/services/authorization/Sessions/Login')
     auth_client = _KBaseAuth(authServiceUrl)
     user_id = auth_client.get_user(token)
     # WARNING: don't call any logging methods on the context object,
     # it'll result in a NoneType error
     cls.ctx = MethodContext(None)
     cls.ctx.update({'token': token,
                     'user_id': user_id,
                     'provenance': [
                         {'service': 'AssemblyUtil',
                          'method': 'please_never_use_it_in_production',
                          'method_params': []
                          }],
                     'authenticated': 1})
     cls.wsURL = cls.cfg['workspace-url']
     cls.wsClient = workspaceService(cls.wsURL, token=token)
     cls.serviceImpl = AssemblyUtil(cls.cfg)
예제 #2
0
 def setUpClass(cls):
     token = environ.get('KB_AUTH_TOKEN', None)
     config_file = environ.get('KB_DEPLOYMENT_CONFIG', None)
     cls.cfg = {}
     config = ConfigParser()
     config.read(config_file)
     for nameval in config.items('AssemblyUtil'):
         cls.cfg[nameval[0]] = nameval[1]
     authServiceUrl = cls.cfg.get(
         'auth-service-url',
         'https://kbase.us/services/authorization/Sessions/Login')
     auth_client = _KBaseAuth(authServiceUrl)
     user_id = auth_client.get_user(token)
     # WARNING: don't call any logging methods on the context object,
     # it'll result in a NoneType error
     cls.ctx = MethodContext(None)
     cls.ctx.update({
         'token':
         token,
         'user_id':
         user_id,
         'provenance': [{
             'service': 'AssemblyUtil',
             'method': 'please_never_use_it_in_production',
             'method_params': []
         }],
         'authenticated':
         1
     })
     cls.wsURL = cls.cfg['workspace-url']
     cls.wsClient = workspaceService(cls.wsURL, token=token)
     cls.serviceImpl = AssemblyUtil(cls.cfg)
     cls.scratch = cls.cfg['scratch']
     cls.callback_url = os.environ['SDK_CALLBACK_URL']
예제 #3
0
 def __init__(self):
     submod = get_service_name() or 'AssemblyUtil'
     self.userlog = log.log(
         submod, ip_address=True, authuser=True, module=True, method=True,
         call_id=True, changecallback=self.logcallback,
         config=get_config_file())
     self.serverlog = log.log(
         submod, ip_address=True, authuser=True, module=True, method=True,
         call_id=True, logfile=self.userlog.get_log_file())
     self.serverlog.set_log_level(6)
     self.rpc_service = JSONRPCServiceCustom()
     self.method_authentication = dict()
     self.rpc_service.add(impl_AssemblyUtil.get_assembly_as_fasta,
                          name='AssemblyUtil.get_assembly_as_fasta',
                          types=[dict])
     self.method_authentication['AssemblyUtil.get_assembly_as_fasta'] = 'required'  # noqa
     self.rpc_service.add(impl_AssemblyUtil.export_assembly_as_fasta,
                          name='AssemblyUtil.export_assembly_as_fasta',
                          types=[dict])
     self.method_authentication['AssemblyUtil.export_assembly_as_fasta'] = 'required'  # noqa
     self.rpc_service.add(impl_AssemblyUtil.save_assembly_from_fasta,
                          name='AssemblyUtil.save_assembly_from_fasta',
                          types=[dict])
     self.method_authentication['AssemblyUtil.save_assembly_from_fasta'] = 'required'  # noqa
     self.rpc_service.add(impl_AssemblyUtil.status,
                          name='AssemblyUtil.status',
                          types=[dict])
     authurl = config.get(AUTH) if config else None
     self.auth_client = _KBaseAuth(authurl)
예제 #4
0
 def setUpClass(cls):
     token = os.environ.get('KB_AUTH_TOKEN', None)
     config_file = os.environ.get('KB_DEPLOYMENT_CONFIG', None)
     cls.cfg = {}
     config = ConfigParser()
     config.read(config_file)
     for nameval in config.items('AssemblyUtil'):
         cls.cfg[nameval[0]] = nameval[1]
     # Getting username from Auth profile for token
     authServiceUrl = cls.cfg['auth-service-url']
     auth_client = _KBaseAuth(authServiceUrl)
     user_id = auth_client.get_user(token)
     # WARNING: don't call any logging methods on the context object,
     # it'll result in a NoneType error
     cls.ctx = MethodContext(None)
     cls.ctx.update({
         'token':
         token,
         'user_id':
         user_id,
         'provenance': [{
             'service': 'AssemblyUtil',
             'method': 'please_never_use_it_in_production',
             'method_params': []
         }],
         'authenticated':
         1
     })
     cls.wsURL = cls.cfg['workspace-url']
     cls.wsClient = Workspace(cls.wsURL)
     cls.serviceImpl = AssemblyUtil(cls.cfg)
     cls.scratch = cls.cfg['scratch']
     cls.callback_url = os.environ['SDK_CALLBACK_URL']
     shutil.copy2('data/NC_021490.fasta', cls.scratch)
 def __init__(self):
     submod = get_service_name() or 'AssemblyUtil'
     self.userlog = log.log(submod,
                            ip_address=True,
                            authuser=True,
                            module=True,
                            method=True,
                            call_id=True,
                            changecallback=self.logcallback,
                            config=get_config_file())
     self.serverlog = log.log(submod,
                              ip_address=True,
                              authuser=True,
                              module=True,
                              method=True,
                              call_id=True,
                              logfile=self.userlog.get_log_file())
     self.serverlog.set_log_level(6)
     self.rpc_service = JSONRPCServiceCustom()
     self.method_authentication = dict()
     self.rpc_service.add(impl_AssemblyUtil.get_assembly_as_fasta,
                          name='AssemblyUtil.get_assembly_as_fasta',
                          types=[dict])
     self.method_authentication[
         'AssemblyUtil.get_assembly_as_fasta'] = 'required'  # noqa
     self.rpc_service.add(impl_AssemblyUtil.get_fastas,
                          name='AssemblyUtil.get_fastas',
                          types=[dict])
     self.method_authentication[
         'AssemblyUtil.get_fastas'] = 'required'  # noqa
     self.rpc_service.add(impl_AssemblyUtil.export_assembly_as_fasta,
                          name='AssemblyUtil.export_assembly_as_fasta',
                          types=[dict])
     self.method_authentication[
         'AssemblyUtil.export_assembly_as_fasta'] = 'required'  # noqa
     self.rpc_service.add(impl_AssemblyUtil.save_assembly_from_fasta,
                          name='AssemblyUtil.save_assembly_from_fasta',
                          types=[dict])
     self.method_authentication[
         'AssemblyUtil.save_assembly_from_fasta'] = 'required'  # noqa
     self.rpc_service.add(impl_AssemblyUtil.status,
                          name='AssemblyUtil.status',
                          types=[dict])
     authurl = config.get(AUTH) if config else None
     self.auth_client = _KBaseAuth(authurl)
예제 #6
0
#!/usr/bin/env python
from ConfigParser import ConfigParser
from os import environ
from AssemblyUtil.authclient import KBaseAuth as _KBaseAuth


token = environ.get('KB_AUTH_TOKEN', None)
config_file = environ.get('KB_DEPLOYMENT_CONFIG', '/kb/module/deploy.cfg')
cfg = {}
config = ConfigParser()
config.read(config_file)
for nameval in config.items('AssemblyRAST'):
	cfg[nameval[0]] = nameval[1]
authServiceUrl = cfg.get('auth-service-url', "https://kbase.us/services/authorization/Sessions/Login")
auth_client = _KBaseAuth(authServiceUrl)
user_id = auth_client.get_user(token)
print user_id
예제 #7
0
#!/usr/bin/env python
from ConfigParser import ConfigParser
from os import environ
from AssemblyUtil.authclient import KBaseAuth as _KBaseAuth

token = environ.get('KB_AUTH_TOKEN', None)
config_file = environ.get('KB_DEPLOYMENT_CONFIG', '/kb/module/deploy.cfg')
cfg = {}
config = ConfigParser()
config.read(config_file)
for nameval in config.items('AssemblyRAST'):
    cfg[nameval[0]] = nameval[1]
authServiceUrl = cfg.get(
    'auth-service-url',
    "https://kbase.us/services/authorization/Sessions/Login")
auth_client = _KBaseAuth(authServiceUrl)
user_id = auth_client.get_user(token)
print user_id