Esempio n. 1
0
# -----------------------------------------------------------------

# Create and setup the remote
remote = Remote()
remote.setup(config.remote)

# Open the task
task_path = fs.join(introspection.pts_run_dir, config.remote,
                    str(config.id) + ".task")
task = Task.from_file(task_path)

# Check whether the log file is present
log_output_path = task.remote_log_path
log_path = None
for filename in remote.files_in_path(log_output_path):
    if "log" in filename:
        log_path = fs.join(log_output_path, filename)
        break

if log_path is None: raise RuntimeError("Log does not exist remotely")

# Read the text file
lines = remote.read_lines(log_path)

# Print the lines of the log file
for line in lines:
    print(line)

    # -----------------------------------------------------------------
Esempio n. 2
0
# REMOTELY
if config.remote is not None:

    # Create remote
    remote = Remote(host_id=config.remote)

    # Determine path
    if config.remote_path is not None: find_path = remote.absolute_or_in_home(config.remote_path)
    else: find_path = remote.home_directory

    #print(find_path)

    #print(remote.items_in_path(find_path, recursive=True))

    # Loop over the files
    paths = remote.files_in_path(find_path, contains=config.contains, not_contains=config.not_contains, extension=config.extension, recursive=config.recursive, exact_name=config.exact_name, exact_not_name=config.exact_not_name)
    nfiles = len(paths)

    if nfiles == 0: log.warning("No files found")
    else:
        log.info(str(nfiles) + " files found")
        for path in paths:
            if config.full: print(path)
            else: print(path.split(find_path)[1])
            if config.remove: remote.remove_file(path)

# LOCALLY
else:

    # Determine path
    find_path = fs.cwd()
Esempio n. 3
0
# -----------------------------------------------------------------

remote_data_path = cached_directory_path_for_single_command(
    environment, "initialize_preparation", remote)
if not remote.is_directory(remote_data_path):
    remote.create_directory(remote_data_path)

# -----------------------------------------------------------------

# Reset?
if config.reset:

    # Loop over all FITS files in the remote data directory
    for name, path in remote.files_in_path(remote_data_path,
                                           recursive=True,
                                           extension="fits",
                                           returns=["name", "path"]):

        # Determine origin
        origin = instrument_to_origin(name.split("_")[1])

        # Determine local directory for this image
        origin_path = fs.join(environment.data_images_path, origin)
        if not fs.is_directory(origin_path): fs.create_directory(origin_path)

        # Determine local path
        local_path = fs.join(origin_path, name)

        #print("local_path")

        # Check whether the image is not present
Esempio n. 4
0
# REMOTELY
if config.remote is not None:

    # Create remote
    remote = Remote(host_id=config.remote)

    # Determine path
    if config.remote_path is not None: find_path = remote.absolute_or_in_home(config.remote_path)
    else: find_path = remote.home_directory

    #print(find_path)

    #print(remote.items_in_path(find_path, recursive=True))

    # Loop over the files
    paths = remote.files_in_path(find_path, contains=config.contains, not_contains=config.not_contains, extension=config.extension, recursive=config.recursive)

    if len(paths) == 0: log.warning("No files found")
    else:
        for path in paths:
            if config.full: print(path)
            else: print(path.split(find_path)[1])

# LOCALLY
else:

    # Determine path
    find_path = fs.cwd()

    # Loop over the files
    paths =  fs.files_in_path(find_path, contains=config.contains, extension=config.extension, recursive=config.recursive)
Esempio n. 5
0
# -----------------------------------------------------------------

filter_name = str(config.filter)
remote_truncation_path_filter = fs.join(remote_truncation_path, filter_name)
if not remote.is_directory(remote_truncation_path_filter):
    raise ValueError("Could not find cached data for the " + filter_name +
                     " image")

# -----------------------------------------------------------------

# Initialize variable
the_image_path = None

# Find the truncated image with the factor corresponding to the specified factor
for image_path, image_name in remote.files_in_path(
        remote_truncation_path_filter, extension="fits",
        returns=["path", "name"]):

    #print(image_path, image_name)

    # Determine the truncation factor
    factor = real(image_name)

    # Check the factor
    if np.isclose(factor, config.factor, rtol=0.01):
        the_image_path = image_path
        break

# Check
if the_image_path is None:
    raise ValueError("Could not find the truncated " + filter_name +