How to use the dax.XnatUtils.upload_file_to_obj function in dax

To help you get started, we’ve selected a few dax examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github VUIIS / dax / dax / launcher.py View on Github external
if auto_proc_list:
            LOGGER.debug('== Build auto processors ==')
            self.build_auto_processors(csess, auto_proc_list, sessions)

        # Close sess log
        LOGGER.handlers.pop()

        # Upload build log only if session was changed
        csess.refresh()
        final_timestamp = csess.cached_timestamp
        LOGGER.debug('initial timestamp={}, final timestamp={}'.format(
            init_timestamp, final_timestamp))
        if final_timestamp > init_timestamp:
            res_obj = csess.full_object().resource('BUILD_LOGS')
            LOGGER.debug('uploading session log:' + tmp_file)
            XnatUtils.upload_file_to_obj(tmp_file, res_obj)
        else:
            LOGGER.debug('session not modified, not uploading build log')
github VUIIS / dax / dax / dax_tools_utils.py View on Github external
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:
                        LOGGER.error((ERR_MSG % err))
                    if status:
                        os.remove(pbs_fpath)
github VUIIS / dax / dax / dax_tools_utils.py View on Github external
assessor_obj = select_assessor(xnat, 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(
                        assessor_obj.datatype() + '/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)
github VUIIS / dax / dax / dax_tools_utils.py View on Github external
ref_path = get_reference_path(resource_path)
                XnatUtils.upload_reference(ref_path, assessor_obj, resource)
            except XnatUtilsError as err:
                raise err
        elif len(rfiles_list) > 1 or os.path.isdir(rfiles_list[0]):
            try:
                XnatUtils.upload_folder_to_obj(
                    resource_path, assessor_obj.out_resource(resource),
                    resource, removeall=True)
            except XnatUtilsError as err:
                print((ERR_MSG % err))
        else:
            # One file, just upload it
            fpath = os.path.join(resource_path, rfiles_list[0])
            try:
                XnatUtils.upload_file_to_obj(
                    fpath, assessor_obj.out_resource(resource), removeall=True)
            except XnatUtilsError as err:
                print((ERR_MSG % err))