def _clean_up_files(directory, options): LOGGER.info('Cleaning up...') if options.nodelete: _move_nonmadx_files(directory, options) LOGGER.info("Output folder:" + directory) else: iotools.delete_item(directory)
def _clean_up(source_dir, corrections): """ Removes the results folders again """ for file in os.listdir(source_dir): if file.endswith(BASE_ID): iotools.delete_item(os.path.join(source_dir, file)) for folder in corrections: iotools.delete_item(os.path.join(folder, RESULTS_DIR))
def run_drive(sdds_file_path, start_turn, end_turn, tune_x, tune_y, nat_tune_x=None, nat_tune_y=None, clean_up=False, stdout=None, stderr=None, tune_window=0.01): output_path = os.path.abspath(os.path.dirname(sdds_file_path)) driving_terms_path = _generate_driving_terms(sdds_file_path, output_path, start_turn, end_turn) drive_inp_path = _generate_drive_inp(output_path, tune_x, tune_y, nat_tune_x, nat_tune_y, tune_window) _run_drive_exe(output_path, stdout, stderr) if clean_up: iotools.delete_item(driving_terms_path) iotools.delete_item(drive_inp_path)
BB_ROOT = os.path.abspath( os.path.join(os.path.dirname(os.path.abspath(__file__)), os.path.pardir, os.path.pardir)) if BB_ROOT not in sys.path: sys.path.append(BB_ROOT) from hole_in_one.hole_in_one import run_all from hole_in_one.io_handlers.input_handler import parse_args from utils import iotools REGR_DIR = join(BB_ROOT, "tests", "regression") TBTS = join(BB_ROOT, "tests", "inputs", "tbt_files") MODELS = join(BB_ROOT, "tests", "inputs", "models") if __name__ == '__main__': output_dir = join(REGR_DIR, "_out_hole_in_one_test_flat_3dkick") arguments = ("--file={file} --model={model} --output={output} clean " "harpy --tunex 0.27 --tuney 0.322 --tunez 4.5e-4 " "--nattunex 0.28 --nattuney 0.31".format( file=join(TBTS, "flat_beam1_3d.sdds"), model=join(MODELS, "flat_beam1", "twiss.dat"), output=output_dir)) iotools.create_dirs(output_dir) try: parsed_args = parse_args(arguments.split()) run_all(*parsed_args) finally: iotools.delete_item(output_dir)