Пример #1
0
 def setUp(self):
     proj_name = u"dxclient_test_pröject"
     self.project = dxpy.api.project_new({"name": proj_name})['id']
     os.environ["DX_PROJECT_CONTEXT_ID"] = self.project
     subprocess.check_call(u"dx cd "+self.project+":/", shell=True)
     dxpy._initialize(suppress_warning=True)
     if 'DX_CLI_WD' in os.environ:
         del os.environ['DX_CLI_WD']
Пример #2
0
 def setUp(self):
     proj_name = u"dxclient_test_pröject"
     self.project = subprocess.check_output(u"dx new project '{p}' --brief".format(p=proj_name), shell=True).strip()
     os.environ["DX_PROJECT_CONTEXT_ID"] = self.project
     subprocess.check_call(u"dx cd " + self.project + ":/", shell=True)
     dxpy._initialize(suppress_warning=True)
     if "DX_CLI_WD" in os.environ:
         del os.environ["DX_CLI_WD"]
Пример #3
0
 def setUp(self):
     proj_name = u"dxclient_test_pröject"
     # Unplug stdin so that dx doesn't prompt user for input at the tty
     self.project = subprocess.check_output(u"dx new project '{p}' --brief".format(p=proj_name), shell=True, stdin=subprocess.PIPE).strip()
     os.environ["DX_PROJECT_CONTEXT_ID"] = self.project
     subprocess.check_call(u"dx cd "+self.project+":/", shell=True)
     dxpy._initialize(suppress_warning=True)
     if 'DX_CLI_WD' in os.environ:
         del os.environ['DX_CLI_WD']
Пример #4
0
 def setUp(self):
     proj_name = u"dxclient_test_pröject"
     self.project = subprocess.check_output(
         u"dx new project '{p}' --brief".format(p=proj_name),
         shell=True).strip()
     os.environ["DX_PROJECT_CONTEXT_ID"] = self.project
     subprocess.check_call(u"dx cd " + self.project + ":/", shell=True)
     dxpy._initialize(suppress_warning=True)
     if 'DX_CLI_WD' in os.environ:
         del os.environ['DX_CLI_WD']
Пример #5
0
 def setUp(self):
     proj_name = u"dxclient_test_pröject"
     self.project = subprocess.check_output(u"dx new project '{p}' --brief".format(p=proj_name), shell=True).strip()
     os.environ["DX_PROJECT_CONTEXT_ID"] = self.project
     # TODO: Fix this once process-wise sessions are in place.  For
     # now, have to save the old current directory and overwrite
     # the file.
     if os.path.exists(os.path.expanduser('~/.dnanexus_config/DX_CLI_WD')):
         with open(os.path.expanduser('~/.dnanexus_config/DX_CLI_WD')) as fd:
             self.old_cwd = fd.read()
         os.remove(os.path.expanduser('~/.dnanexus_config/DX_CLI_WD'))
     else:
         self.old_cwd = None
     if 'DX_CLI_WD' in os.environ:
         del os.environ['DX_CLI_WD']
     dxpy._initialize(suppress_warning=True)
Пример #6
0
    def setUpClass(cls):
        if 'DXTEST_FUSE' not in os.environ:
            return
        proj_name = u"dxclient_test_pröject"
        cls.project_id = subprocess.check_output(u"dx new project '{p}' --brief".format(p=proj_name), shell=True).strip()
        os.environ["DX_PROJECT_CONTEXT_ID"] = cls.project_id
        os.environ["DX_CLI_WD"] = '/'
        cls.project = dxpy.DXProject(cls.project_id)
        dxpy._initialize(suppress_warning=True)

        subprocess.check_call(['dx', 'mkdir', 'foo'])
        subprocess.check_call(['dx', 'mkdir', 'bar'])
        dxpy.upload_local_file(__file__, wait_on_close=True)
        dxpy.new_dxrecord(name="A/B testing")

        cls.mountpoint = tempfile.mkdtemp()
        # TODO: redirect logs to someplace in case we need to debug
        # problems in these tests
        subprocess.check_call(['dx-mount', cls.mountpoint])
Пример #7
0
    def setUpClass(cls):
        if 'DXTEST_FUSE' not in os.environ:
            return
        proj_name = u"dxclient_test_pröject"
        cls.project_id = subprocess.check_output(u"dx new project '{p}' --brief".format(p=proj_name), shell=True).strip()
        os.environ["DX_PROJECT_CONTEXT_ID"] = cls.project_id
        os.environ["DX_CLI_WD"] = '/'
        cls.project = dxpy.DXProject(cls.project_id)
        dxpy._initialize(suppress_warning=True)

        subprocess.check_call(['dx', 'mkdir', 'foo'])
        subprocess.check_call(['dx', 'mkdir', 'bar'])
        dxpy.upload_local_file(__file__, wait_on_close=True)

        cls.mountpoint = tempfile.mkdtemp()
        args = ['dx-mount', cls.mountpoint, '--foreground']
        args.append('--debug')
        cls.fuse_driver = subprocess.Popen(args)
        time.sleep(1)
        assert(cls.fuse_driver.poll() == None)
Пример #8
0
def set_env_from_args(args):
    ''' Sets the environment variables for this process from arguments (argparse.Namespace)
    and calls dxpy._initialize() to reset any values that it has already set.
    '''
    args = vars(args)

    require_initialize = False

    if args.get('apiserver_host') is not None:
        os.environ['DX_APISERVER_HOST'] = args['apiserver_host']
        require_initialize = True
    if args.get('apiserver_port') is not None:
        os.environ['DX_APISERVER_PORT'] = args['apiserver_port']
        require_initialize = True
    if args.get('apiserver_protocol') is not None:
        os.environ['DX_APISERVER_PROTOCOL'] = args['apiserver_protocol']
        require_initialize = True
    if args.get('project_context_id') is not None:
        os.environ['DX_PROJECT_CONTEXT_ID'] = args['project_context_id']
        require_initialize = True
    if args.get('workspace_id') is not None:
        os.environ['DX_WORKSPACE_ID'] = args['workspace_id']
        require_initialize = True
    if args.get('cli_wd') is not None:
        os.environ['DX_CLI_WD'] = args['cli_wd']
        require_initialize = True
    if args.get('security_context') is not None:
        os.environ['DX_SECURITY_CONTEXT'] = args['security_context']
        require_initialize = True
    if args.get('auth_token') is not None:
        os.environ['DX_SECURITY_CONTEXT'] = json.dumps({
            "auth_token":
            args['auth_token'],
            "auth_token_type":
            "Bearer"
        })
        require_initialize = True

    if require_initialize:
        from dxpy import _initialize
        _initialize(suppress_warning=True)
Пример #9
0
    def setUpClass(cls):
        if 'DXTEST_FUSE' not in os.environ:
            return
        proj_name = u"dxclient_test_pröject"
        cls.project_id = subprocess.check_output(
            u"dx new project '{p}' --brief".format(p=proj_name),
            shell=True).strip()
        os.environ["DX_PROJECT_CONTEXT_ID"] = cls.project_id
        os.environ["DX_CLI_WD"] = '/'
        cls.project = dxpy.DXProject(cls.project_id)
        dxpy._initialize(suppress_warning=True)

        subprocess.check_call(['dx', 'mkdir', 'foo'])
        subprocess.check_call(['dx', 'mkdir', 'bar'])
        dxpy.upload_local_file(__file__, wait_on_close=True)

        cls.mountpoint = tempfile.mkdtemp()
        args = ['dx-mount', cls.mountpoint, '--foreground']
        args.append('--debug')
        cls.fuse_driver = subprocess.Popen(args)
        time.sleep(1)
        assert (cls.fuse_driver.poll() == None)
Пример #10
0
def set_env_from_args(args):
    ''' Sets the environment variables for this process from arguments (argparse.Namespace)
    and calls dxpy._initialize() to reset any values that it has already set.
    '''
    args = vars(args)

    require_initialize = False

    if args.get('apiserver_host') is not None:
        os.environ['DX_APISERVER_HOST'] = args['apiserver_host']
        require_initialize = True
    if args.get('apiserver_port') is not None:
        os.environ['DX_APISERVER_PORT'] = args['apiserver_port']
        require_initialize = True
    if args.get('apiserver_protocol') is not None:
        os.environ['DX_APISERVER_PROTOCOL'] = args['apiserver_protocol']
        require_initialize = True
    if args.get('project_context_id') is not None:
        os.environ['DX_PROJECT_CONTEXT_ID'] = args['project_context_id']
        require_initialize = True
    if args.get('workspace_id') is not None:
        os.environ['DX_WORKSPACE_ID'] = args['workspace_id']
        require_initialize = True
    if args.get('cli_wd') is not None:
        os.environ['DX_CLI_WD'] = args['cli_wd']
        require_initialize = True
    if args.get('security_context') is not None:
        os.environ['DX_SECURITY_CONTEXT'] = args['security_context']
        require_initialize = True
    if args.get('auth_token') is not None:
        os.environ['DX_SECURITY_CONTEXT'] = json.dumps({"auth_token": args['auth_token'],
                                                        "auth_token_type": "Bearer"})
        require_initialize = True

    if require_initialize:
        from dxpy import _initialize
        _initialize(suppress_warning=True)