def copy_scans_tsv_file_to_loris_bids_dir(self, bids_sub_id, loris_bids_root_dir, data_dir): file = self.scans_tsv_file copy = loris_bids_root_dir + '/sub-' + bids_sub_id + '/' + os.path.basename( self.scans_tsv_file) utilities.copy_file(file, copy, self.verbose) # determine the relative path and return it relative_path = copy.replace(data_dir, "") return relative_path
def extract_iso_images(path): """Extract ISO images into webserver directory Args: path (str): Directory path containing ISOs Returns: list: Paths to extracted ISO images """ return_list = [] if not path.endswith('/'): path += '/' # Extract ISO into web directory for access over http for _file in os.listdir(path): if _file.endswith('.iso'): name = os.path.splitext(_file)[0] dest_dir = HTML_DIR + name # If dest dir already exists continue to next file if not os.path.isdir(dest_dir): os.mkdir(dest_dir) util.bash_cmd('xorriso -osirrox on -indev %s -extract / %s' % ((path + _file), dest_dir)) util.bash_cmd('chmod 755 $(find %s -type d)' % dest_dir) # Do not return paths to "mini" isos if not _file.endswith('mini.iso'): return_list.append(dest_dir) # Ubuntu ppc64el before 16.04.2 requires files from netboot mini iso for _file in os.listdir(path): if _file.endswith('mini.iso'): src_dir = (HTML_DIR + _file[:-4] + '/install/') dest_dir = (HTML_DIR + _file[:-9] + '/install/netboot/ubuntu-installer/ppc64el/') if not os.path.isdir(dest_dir): os.makedirs(dest_dir) for netboot_file in os.listdir(src_dir): util.copy_file(src_dir + netboot_file, dest_dir) return return_list
def setup_image_config_files(path, html_dir): """Setup image config files Args: path (str): Directory path image config files html_dir (str): Path to root http directory """ if not path.endswith('/'): path += '/' # Update preseed configurations with default user id # Copy preseed & kickstart files to cobbler kickstart directory for _file in os.listdir(path): if _file.endswith('.ks') or _file.endswith('.seed'): util.copy_file(path + _file, KICKSTARTS_DIR) # Copy custom snippets to cobbler snippets directory snippets_src_dir = path + 'snippets/' for _file in os.listdir(snippets_src_dir): util.copy_file(snippets_src_dir + _file, SNIPPETS_DIR) # Copy apt source lists to web repo directory if not os.path.isdir(html_dir + 'ubuntu_sources'): os.makedirs(html_dir + 'ubuntu_sources') for _file in os.listdir(path): if _file.endswith('.list'): util.copy_file(path + _file, html_dir + 'ubuntu_sources')
def copy_file_to_loris_bids_dir(self, file, derivatives_path=None): """ Wrapper around the utilities.copy_file function that copies the file to the LORIS BIDS import directory and returns the relative path of the file (without the data_dir part). :param file: full path to the original file :type file: str :param derivatives_path: path to the derivative folder :type derivatives_path: str :return: relative path to the copied file :rtype: str """ # determine the path of the copied file copy_file = self.loris_bids_eeg_rel_dir if self.bids_ses_id: copy_file += os.path.basename(file) else: # make sure the ses- is included in the new filename if using # default visit label from the LORIS config copy_file += str.replace( os.path.basename(file), "sub-" + self.bids_sub_id, "sub-" + self.bids_sub_id + "_ses-" + self.default_vl) if derivatives_path: # create derivative subject/vl/modality directory lib.utilities.create_dir( derivatives_path + self.loris_bids_eeg_rel_dir, self.verbose) copy_file = derivatives_path + copy_file else: copy_file = self.loris_bids_root_dir + copy_file # copy the file utilities.copy_file(file, copy_file, self.verbose) # determine the relative path and return it relative_path = copy_file.replace(self.data_dir, "") return relative_path