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

    :param xnat: pyxnat.Interface object
    :param projects: list of projects to upload to XNAT
    :return: None
    """
    outlogs_list = os.listdir(os.path.join(RESULTS_DIR, _OUTLOG))
    if projects:
        outlogs_list = [logfile for logfile in outlogs_list
                        if logfile.split('-x-')[0] in projects]

    number_outlog = len(outlogs_list)
    for index, outlogfile in enumerate(outlogs_list):
        outlog_fpath = os.path.join(RESULTS_DIR, _OUTLOG, outlogfile)
        mess = """   *Checking OUTLOG {index}/{max} -- File name: {file}"""
        LOGGER.info(mess.format(index=str(index + 1),
                                max=str(number_outlog),
                                file=outlogfile))
        assessor_dict = get_assessor_dict(outlogfile[:-7], 'none')
        if not assessor_dict:
            LOGGER.warn('     wrong outlog file. You should remove it')
        else:
            assessor_obj = select_assessor(xnat, assessor_dict)
            xtp = get_xsitype(assessor_dict)
            if not assessor_obj.exists():
                msg = '     no assessor on XNAT -- moving file to trash.'
                LOGGER.warn(msg)
                new_location = os.path.join(RESULTS_DIR, _TRASH, outlogfile)
                os.rename(outlog_fpath, new_location)
            else:
                if assessor_obj.attrs.get(xtp + '/procstatus') == JOB_FAILED:
                    resource_obj = assessor_obj.out_resource(_OUTLOG)
                    if resource_obj.exists():
                        pass
                    else:
                        LOGGER.info('     uploading file.')
                        try:
                            status = XnatUtils.upload_file_to_obj(outlog_fpath,
                                                                  resource_obj)
                        except XnatUtilsError as err:
                            print(ERR_MSG % err)
                        if status:
                            os.remove(outlog_fpath)

    Upload all outlog files to XNAT

    :param xnat: pyxnat.Interface object
    :param projects: list of projects to upload to XNAT
    :return: None
    
Upload all outlog files to XNAT
Upload all outlog files to XNAT
def upload_outlog(xnat, projects):
    outlogs_list = os.listdir(os.path.join(RESULTS_DIR, _OUTLOG))
    if projects:
        outlogs_list = [logfile for logfile in outlogs_list
                        if logfile.split('-x-')[0] in projects]
    number_outlog = len(outlogs_list)
    for index, outlogfile in enumerate(outlogs_list):
        outlog_fpath = os.path.join(RESULTS_DIR, _OUTLOG, outlogfile)
        mess = """   *Checking OUTLOG {index}/{max} -- File name: {file}"""
        LOGGER.info(mess.format(index=str(index + 1),
                                max=str(number_outlog),
                                file=outlogfile))
        assessor_dict = get_assessor_dict(outlogfile[:-7], 'none')
        if not assessor_dict:
            LOGGER.warn('     wrong outlog file. You should remove it')
        else:
            assessor_obj = select_assessor(xnat, assessor_dict)
            xtp = get_xsitype(assessor_dict)
            if not assessor_obj.exists():
                msg = '     no assessor on XNAT -- moving file to trash.'
                LOGGER.warn(msg)
                new_location = os.path.join(RESULTS_DIR, _TRASH, outlogfile)
                os.rename(outlog_fpath, new_location)
            else:
                if assessor_obj.attrs.get(xtp + '/procstatus') == JOB_FAILED:
                    resource_obj = assessor_obj.out_resource(_OUTLOG)
                    if resource_obj.exists():
                        pass
                    else:
                        LOGGER.info('     uploading file.')
                        try:
                            status = XnatUtils.upload_file_to_obj(outlog_fpath,
                                                                  resource_obj)
                        except XnatUtilsError as err:
                            print(ERR_MSG % err)
                        if status:
                            os.remove(outlog_fpath)
def upload_outlog ( xnat , projects ) : outlogs_list = os . listdir ( os . path . join ( RESULTS_DIR , _OUTLOG ) ) if projects : outlogs_list = [ logfile for logfile in outlogs_list if logfile . split ( '-x-' ) [ 0 ] in projects ] number_outlog = len ( outlogs_list ) for index , outlogfile in enumerate ( outlogs_list ) : outlog_fpath = os . path . join ( RESULTS_DIR , _OUTLOG , outlogfile ) mess = """   *Checking OUTLOG {index}/{max} -- File name: {file}""" LOGGER . info ( mess . format ( index = str ( index + 1 ) , max = str ( number_outlog ) , file = outlogfile ) ) assessor_dict = get_assessor_dict ( outlogfile [ : - 7 ] , 'none' ) if not assessor_dict : LOGGER . warn ( '     wrong outlog file. You should remove it' ) else : assessor_obj = select_assessor ( xnat , assessor_dict ) xtp = get_xsitype ( assessor_dict ) if not assessor_obj . exists ( ) : msg = '     no assessor on XNAT -- moving file to trash.' LOGGER . warn ( msg ) new_location = os . path . join ( RESULTS_DIR , _TRASH , outlogfile ) os . rename ( outlog_fpath , new_location ) else : if assessor_obj . attrs . get ( xtp + '/procstatus' ) == JOB_FAILED : resource_obj = assessor_obj . out_resource ( _OUTLOG ) if resource_obj . exists ( ) : pass else : LOGGER . info ( '     uploading file.' ) try : status = XnatUtils . upload_file_to_obj ( outlog_fpath , resource_obj ) except XnatUtilsError as err : print ( ERR_MSG % err ) if status : os . remove ( outlog_fpath )
Upload all outlog files to XNAT
Upload all outlog files to XNAT
"""
    Upload all outlog files to XNAT

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