Beispiel #1
0
    def test_as_globus_path(self):
        # A Windows path
        if sys.platform == 'win32':
            # "/E/FlatIron/integration"
            actual = globus.as_globus_path('E:\\FlatIron\\integration')
            self.assertTrue(actual.startswith('/E/'))
            # A relative POSIX path
            actual = globus.as_globus_path('/mnt/foo/../data/integration')
            expected = '/mnt/data/integration'  # "/C/mnt/data/integration
            self.assertTrue(actual.endswith(expected))

        # A globus path
        actual = globus.as_globus_path('/E/FlatIron/integration')
        expected = '/E/FlatIron/integration'
        self.assertEqual(expected, actual)
Beispiel #2
0
try:
    gtc = globus.login_auto(GLOBUS_CLIENT_ID, str_app='globus/admin')
except ValueError:
    logger.info('User authentication required...')
    globus.setup(GLOBUS_CLIENT_ID)
    gtc = globus.login_auto(GLOBUS_CLIENT_ID)

# Check path exists
try:
    gtc.operation_ls(SERVER_ID, path=SRC_DIR)
except TransferAPIError as ex:
    logger.error(f'Failed to query source endpoint path {SRC_DIR}')
    raise ex

# Create the destination path if it does not exist
dst_directory = as_globus_path(DST_DIR)

try:
    gtc.operation_ls(LOCAL_REPO, path=dst_directory)
except TransferAPIError as ex:
    if ex.http_status == 404:
        # Directory not found; create it
        try:
            gtc.operation_mkdir(LOCAL_REPO, dst_directory)
            logger.info(f'Created directory: {dst_directory}')
        except TransferAPIError as tapie:
            logger.error(f'Failed to create directory: {tapie.message}')
            raise tapie
    else:
        raise ex