Utilities Python Module

Module that has the utility functionality for the cart.

class pacifica.cartd.utils.Cartutils

Class used to provide utility functions for the cart to use.

__init__()

Default constructor setting environment variable defaults.

__weakref__

list of weak references to the object (if defined)

static available_cart(uid)

Check if the asked for cart tar is available.

Returns the path to tar if yes, false if not. None if no cart.

static cart_status(uid)

Get the status of a specified cart.

static check_file_modified_time(response, cart_file, mycart)

Check response for file modified time.

Should be from Archive Interface head request

check_file_ready_pull(response, cart_file, mycart)

Check file ready state.

Check response (should be from Archive Interface head request) for bytes per level then returns True or False based on if the file is at level 1 (downloadable)

static check_file_size_needed(response, cart_file, mycart)

Check response (should be from Archive Interface head request) for file size.

check_space_requirements(cart_file, mycart, size_needed, deleted_flag)

Check to make sure there is enough space available on disk for the file to be downloaded.

Note it will recursively call itself if there isnt enough space. It will delete a cart first, then call itself until either there is enough space or there is no carts to delete

check_status_details(mycart, cart_file, size_needed, mod_time)

Check to see if status response is correct.

Data from the status response is all correct and ready to for the file to be pulled.

static create_bundle_directories(filepath)

Create all the directories in the given path if they do not already exist.

classmethod create_download_path(cart_file, mycart, abs_cart_file_path)

Create the directories that the file will be pulled to.

delete_cart_bundle(cart)

Get the path to where a carts file are.

Also attempt to delete the file tree.

static fix_absolute_path(filepath)

Remove / from front of path.

classmethod get_path_size(source)

Return the size of a specific directory, including all subdirectories and files.

lru_cart_delete(mycart)

Delete the least recently used cart that isnt this one.

Only delete one cart per call.

prepare_bundle(cartid)

Check to see if all the files are staged locally.

Before calling the bundling action. If not will call itself to continue the waiting process

remove_cart(uid)

Call when a DELETE request comes in.

Verifies there is a cart to delete then removes it.

static set_file_status(cart_file, cart, status, error)

Set the status and/or error for a cart.

tar_files(cartid)

Start to bundle all the files together.

The option to do streaming download or not is based on a system configuration.

classmethod update_cart_files(cart, file_ids)

Update the files associated to a cart.