コード例 #1
0
def upload_from_irods(username, password, host, port, zone, irods_fnames, res_files):
    """
    use iget to transfer selected data object from irods zone to local as a NamedTemporaryFile
    :param username: iRODS login account username used to download irods data object for uploading
    :param password: iRODS login account password used to download irods data object for uploading
    :param host: iRODS login host used to download irods data object for uploading
    :param port: iRODS login port used to download irods data object for uploading
    :param zone: iRODS login zone used to download irods data object for uploading
    :param irods_fnames: the data object file name to download to local for uploading
    :param res_files: list of files for uploading to create resources
    :raises SessionException(proc.returncode, stdout, stderr) defined in django_irods/icommands.py
            to capture iRODS exceptions raised from iRODS icommand subprocess run triggered from
            any method calls from IrodsStorage() if an error or exception ever occurs
    :return: None, but the downloaded file from the iRODS will be appended to res_files list for
    uploading
    """
    irods_storage = IrodsStorage()
    irods_storage.set_user_session(username=username, password=password, host=host, port=port,
                                   zone=zone)
    ifnames = string.split(irods_fnames, ',')
    for ifname in ifnames:
        size = irods_storage.size(ifname)
        tmpFile = irods_storage.download(ifname)
        fname = os.path.basename(ifname.rstrip(os.sep))
        fileobj = File(file=tmpFile, name=fname)
        fileobj.size = size
        res_files.append(fileobj)

    # delete the user session after iRODS file operations are done
    irods_storage.delete_user_session()
コード例 #2
0
ファイル: utils.py プロジェクト: kob-aha/hydroshare
def upload_from_irods(username, password, host, port, zone, irods_fname, res_files):
    try:
        irods_storage = IrodsStorage()
        irods_storage.set_user_session(username=username, password=password, host=host, port=port, zone=zone)
        tmpFile = irods_storage.download(irods_fname)
        fname = os.path.basename(irods_fname.rstrip(os.sep))
        res_files.append(UploadedFile(file=tmpFile, name=fname))
    except Exception as ex:
        raise iRODSException(ex.message)
コード例 #3
0
ファイル: testing.py プロジェクト: hydroshare/hydroshare
    def verify_user_quota_usage_avu_in_user_zone(self, attname, qsize):
        '''
        Have to use HS_USER_ZONE_PROXY_USER with rodsadmin role to get user type AVU in user zone
        and verify its quota usage is set correctly
        :param attname: quota usage attribute name set on iRODS proxy user in user zone
        :param qsize: quota size (type string) to be verified to equal to the value set for attname.
        '''
        istorage = IrodsStorage()
        istorage.set_user_session(username=settings.HS_USER_ZONE_PROXY_USER,
                                  password=settings.HS_USER_ZONE_PROXY_USER_PWD,
                                  host=settings.HS_USER_ZONE_HOST,
                                  port=settings.IRODS_PORT,
                                  zone=settings.HS_USER_IRODS_ZONE,
                                  sess_id='user_proxy_session')

        uz_bagit_path = os.path.join('/', settings.HS_USER_IRODS_ZONE, 'home',
                                     settings.HS_LOCAL_PROXY_USER_IN_FED_ZONE,
                                     settings.IRODS_BAGIT_PATH)
        get_qsize = istorage.getAVU(uz_bagit_path, attname)
        self.assertEqual(qsize, get_qsize)
コード例 #4
0
ファイル: testing.py プロジェクト: Lihao-CAU/hydroshare
    def verify_user_quota_usage_avu_in_user_zone(self, attname, qsize):
        '''
        Have to use LINUX_ADMIN_USER_FOR_HS_USER_ZONE with rodsadmin role to get user type AVU
        in user zone and verify its quota usage is set correctly
        :param attname: quota usage attribute name set on iRODS proxy user in user zone
        :param qsize: quota size (type string) to be verified to equal to the value set for attname.
        '''
        istorage = IrodsStorage()
        istorage.set_user_session(username=settings.LINUX_ADMIN_USER_FOR_HS_USER_ZONE,
                                  password=settings.LINUX_ADMIN_USER_PWD_FOR_HS_USER_ZONE,
                                  host=settings.HS_USER_ZONE_HOST,
                                  port=settings.IRODS_PORT,
                                  zone=settings.HS_USER_IRODS_ZONE,
                                  sess_id='user_proxy_session')

        uz_bagit_path = os.path.join('/', settings.HS_USER_IRODS_ZONE, 'home',
                                     settings.HS_IRODS_PROXY_USER_IN_USER_ZONE,
                                     settings.IRODS_BAGIT_PATH)
        get_qsize = istorage.getAVU(uz_bagit_path, attname)
        self.assertEqual(qsize, get_qsize)
コード例 #5
0
def get_size_and_avu_for_irods_ref_files(username, password, host, port, zone,
                                         irods_fnames):
    """
    use iget to transfer selected data object from irods zone to local as a NamedTemporaryFile
    :param username: iRODS login account username used to download irods data object for uploading
    :param password: iRODS login account password used to download irods data object for uploading
    :param host: iRODS login host used to download irods data object for uploading
    :param port: iRODS login port used to download irods data object for uploading
    :param zone: iRODS login zone used to download irods data object for uploading
    :param irods_fnames: the data object file name to download to local for uploading
    :raises SessionException(proc.returncode, stdout, stderr) defined in django_irods/icommands.py
            to capture iRODS exceptions raised from iRODS icommand subprocess run triggered from
            any method calls from IrodsStorage() if an error or exception ever occurs
    :return: list of file sizes corresponding to irods_fnames, and extra metadata dicts with each dict item
             corresponding to iRODS AVUs on the file or data object with file name preappended to attributes
    """
    irods_storage = IrodsStorage()
    irods_storage.set_user_session(username=username,
                                   password=password,
                                   host=host,
                                   port=port,
                                   zone=zone)
    ifnames = string.split(irods_fnames, ',')

    ifsizes = []
    ifextra_mds = {}
    for ifname in ifnames:
        size = irods_storage.size(ifname)
        ifsizes.append(size)
        extra_md_dict = irods_storage.getAVU(ifname, type='-d')
        for key, val in extra_md_dict.iteritems():
            ukey = ifname + '_' + key
            ifextra_mds[ukey] = val

    # delete the user session after iRODS file operations are done
    irods_storage.delete_user_session()
    return ifsizes, ifextra_mds