dax/dax_tools_utils.py
def upload_pbs(xnat, projects):
    """
    Upload all pbs files to XNAT

    :param xnat: pyxnat.Interface object
    :param projects: list of projects to upload to XNAT
    :return: None
    """
    pbs_list = get_pbs_list(projects)
    number_pbs = len(pbs_list)
    for index, pbsfile in enumerate(pbs_list):
        pbs_fpath = os.path.join(RESULTS_DIR, _PBS, pbsfile)
        mess = """   *Uploading PBS {index}/{max} -- File name: {file}"""
        LOGGER.info(mess.format(index=str(index + 1),
                                max=str(number_pbs),
                                file=pbsfile))
        assessor_label = os.path.splitext(pbsfile)[0]
        assessor_dict = get_assessor_dict(assessor_label, 'none')
        if not assessor_dict:
            LOGGER.warn('wrong assessor label for %s' % (pbsfile))
            os.rename(pbs_fpath, os.path.join(RESULTS_DIR, _TRASH, pbsfile))
        else:
            assessor_obj = select_assessor(xnat, assessor_dict)
            if not assessor_obj.exists():
                LOGGER.warn('assessor does not exist for %s' % (pbsfile))
                new_location = os.path.join(RESULTS_DIR, _TRASH, pbsfile)
                os.rename(pbs_fpath, new_location)
            else:
                resource_obj = assessor_obj.out_resource(_PBS)
                if resource_obj.exists():
                    label = assessor_dict['label']
                    msg = 'the PBS resource already exists for the assessor %s'
                    LOGGER.warn(msg % (label))
                    adir = os.path.join(RESULTS_DIR, assessor_dict['label'])
                    if os.path.isdir(adir):
                        msg = 'Copying the pbs file in the assessor folder...'
                        LOGGER.warn(msg)
                        pbs_folder = os.path.join(adir, _PBS)
                        if not os.path.exists(pbs_folder):
                            os.mkdir(pbs_folder)
                        os.rename(pbs_fpath, os.path.join(pbs_folder, pbsfile))
                    else:
                        LOGGER.warn('Copying the pbs file in the TRASH ...')
                        trash = os.path.join(RESULTS_DIR, _TRASH, pbsfile)
                        os.rename(pbs_fpath, trash)
                else:
                    # upload the file
                    try:
                        status = XnatUtils.upload_file_to_obj(pbs_fpath,
                                                              resource_obj)
                    except XnatUtilsError as err:
                        print(ERR_MSG % err)
                    if status:
                        os.remove(pbs_fpath)

    Upload all pbs files to XNAT

    :param xnat: pyxnat.Interface object
    :param projects: list of projects to upload to XNAT
    :return: None
    
Upload all pbs files to XNAT
Upload all pbs files to XNAT
def upload_pbs(xnat, projects):
    pbs_list = get_pbs_list(projects)
    number_pbs = len(pbs_list)
    for index, pbsfile in enumerate(pbs_list):
        pbs_fpath = os.path.join(RESULTS_DIR, _PBS, pbsfile)
        mess = """   *Uploading PBS {index}/{max} -- File name: {file}"""
        LOGGER.info(mess.format(index=str(index + 1),
                                max=str(number_pbs),
                                file=pbsfile))
        assessor_label = os.path.splitext(pbsfile)[0]
        assessor_dict = get_assessor_dict(assessor_label, 'none')
        if not assessor_dict:
            LOGGER.warn('wrong assessor label for %s' % (pbsfile))
            os.rename(pbs_fpath, os.path.join(RESULTS_DIR, _TRASH, pbsfile))
        else:
            assessor_obj = select_assessor(xnat, assessor_dict)
            if not assessor_obj.exists():
                LOGGER.warn('assessor does not exist for %s' % (pbsfile))
                new_location = os.path.join(RESULTS_DIR, _TRASH, pbsfile)
                os.rename(pbs_fpath, new_location)
            else:
                resource_obj = assessor_obj.out_resource(_PBS)
                if resource_obj.exists():
                    label = assessor_dict['label']
                    msg = 'the PBS resource already exists for the assessor %s'
                    LOGGER.warn(msg % (label))
                    adir = os.path.join(RESULTS_DIR, assessor_dict['label'])
                    if os.path.isdir(adir):
                        msg = 'Copying the pbs file in the assessor folder...'
                        LOGGER.warn(msg)
                        pbs_folder = os.path.join(adir, _PBS)
                        if not os.path.exists(pbs_folder):
                            os.mkdir(pbs_folder)
                        os.rename(pbs_fpath, os.path.join(pbs_folder, pbsfile))
                    else:
                        LOGGER.warn('Copying the pbs file in the TRASH ...')
                        trash = os.path.join(RESULTS_DIR, _TRASH, pbsfile)
                        os.rename(pbs_fpath, trash)
                else:
                    try:
                        status = XnatUtils.upload_file_to_obj(pbs_fpath,
                                                              resource_obj)
                    except XnatUtilsError as err:
                        print(ERR_MSG % err)
                    if status:
                        os.remove(pbs_fpath)
def upload_pbs ( xnat , projects ) : pbs_list = get_pbs_list ( projects ) number_pbs = len ( pbs_list ) for index , pbsfile in enumerate ( pbs_list ) : pbs_fpath = os . path . join ( RESULTS_DIR , _PBS , pbsfile ) mess = """   *Uploading PBS {index}/{max} -- File name: {file}""" LOGGER . info ( mess . format ( index = str ( index + 1 ) , max = str ( number_pbs ) , file = pbsfile ) ) assessor_label = os . path . splitext ( pbsfile ) [ 0 ] assessor_dict = get_assessor_dict ( assessor_label , 'none' ) if not assessor_dict : LOGGER . warn ( 'wrong assessor label for %s' % ( pbsfile ) ) os . rename ( pbs_fpath , os . path . join ( RESULTS_DIR , _TRASH , pbsfile ) ) else : assessor_obj = select_assessor ( xnat , assessor_dict ) if not assessor_obj . exists ( ) : LOGGER . warn ( 'assessor does not exist for %s' % ( pbsfile ) ) new_location = os . path . join ( RESULTS_DIR , _TRASH , pbsfile ) os . rename ( pbs_fpath , new_location ) else : resource_obj = assessor_obj . out_resource ( _PBS ) if resource_obj . exists ( ) : label = assessor_dict [ 'label' ] msg = 'the PBS resource already exists for the assessor %s' LOGGER . warn ( msg % ( label ) ) adir = os . path . join ( RESULTS_DIR , assessor_dict [ 'label' ] ) if os . path . isdir ( adir ) : msg = 'Copying the pbs file in the assessor folder...' LOGGER . warn ( msg ) pbs_folder = os . path . join ( adir , _PBS ) if not os . path . exists ( pbs_folder ) : os . mkdir ( pbs_folder ) os . rename ( pbs_fpath , os . path . join ( pbs_folder , pbsfile ) ) else : LOGGER . warn ( 'Copying the pbs file in the TRASH ...' ) trash = os . path . join ( RESULTS_DIR , _TRASH , pbsfile ) os . rename ( pbs_fpath , trash ) else : try : status = XnatUtils . upload_file_to_obj ( pbs_fpath , resource_obj ) except XnatUtilsError as err : print ( ERR_MSG % err ) if status : os . remove ( pbs_fpath )
Upload all pbs files to XNAT
Upload all pbs files to XNAT
"""
    Upload all pbs files to XNAT

    :param xnat: pyxnat.Interface object
    :param projects: list of projects to upload to XNAT
    :return: None
    """ # upload the file
None
xnat
None
projects
list of projects to upload to XNAT
list of projects to upload to XNAT