class wxflow.Hsi(quiet: bool = True, echo_commands: bool = True, opts: str | List = [])[source]

Class offering an interface to HPSS via the hsi utility.

Examples:

>>> from wxflow import Hsi
>>> hsi = Hsi()  # Generates an Executable object of "hsi"
>>> output = hsi.put("some_local_file", "/HPSS/path/to/some_file") # Put a file onto HPSS
>>> output = hsi.ls("/HPSS/path/to/some_file") # List the file
>>> output = hsi.chgrp("rstprod", "/HPSS/pth/to/some_file") # Change the group to rstprod

Instantiate the hsi command

Parameters:

quietbool

Run hsi in quiet mode (suppress login information, transfer info, etc)

echo_commandsbool

Echo each command. Some commands will still not echo (e.g. chmod).

optsstr | list

Additional arguments to send to each hsi command.

chgrp(group_name: str, target: str, hsi_opts: str = '', chgrp_opts: str = '') str[source]

Method to change the group of a file or directory on HPSS

Parameters:
  • group_name (str) – The group to which ownership of the file/directory is to be set.

  • target (str) – Full path of the target location of the file on HPSS.

  • hsi_opts (str) – String of options to send to hsi.

  • chgrp_opts (str) – Options to send to chgrp. See “hsi chgrp -?” for more details.

Returns:

output – Concatenated output and error of the hsi chgrp command.

Return type:

str

chmod(mod: str, target: str, hsi_opts: List | str = '', chmod_opts: List | str = '') str[source]

Method to change the permissions of a file or directory on HPSS

Parameters:
  • mod (str) – Permissions to set for the file or directory, e.g. “640”, “o+r”, etc.

  • target (str) – Full path of the target location of the file on HPSS.

  • hsi_opts (list | str) – Options to send to hsi.

  • chmod_opts (list | str) – Options to send to chmod. See “hsi chmod -?” for more details.

Returns:

output – Concatenated output and error of the hsi chmod command.

Return type:

str

exists(target: str) bool[source]

Method to test the existence of a file/directory/glob on HPSS

Parameters:

target (str) – Full path of the target location on HPSS.

Returns:

pattern_exists – True if the target exists on HPSS.

Return type:

bool

get(source: str, target=None, opts: List | str = []) str[source]

Method to get a file from HPSS via hsi

Parameters:
  • source (str) – Full path location on HPSS of the file

  • target (str) – Location on the local machine to place the file. If not specified, then the file will be placed in the current directory.

  • opts (str | list) – List or string of additional options to send to hsi command.

Returns:

output – Concatenated output and error of the hsi get command.

Return type:

str

ls(target: str, hsi_opts: str = '', ls_opts: str = '', ignore_missing: bool = False) str[source]

Method to list files/directories on HPSS via hsi

Parameters:
  • target (str) – Full path of the target location on HPSS.

  • hsi_opts (str) – String of options to send to hsi.

  • ls_opts (str) – Options to send to ls. See “hsi ls -?” for more details.

  • ignore_missing (bool) – Flag to ignore missing files

Returns:

output – Concatenated output and error of the hsi ls command.

Return type:

str

mkdir(target: str, hsi_opts: str = '', mkdir_opts: str = '') str[source]

Method to delete a file or directory on HPSS via hsi

Parameters:
  • target (str) – Full path of the target location of the file on HPSS.

  • hsi_opts (str) – String of options to send to hsi.

Returns:

output – Concatenated output and error of the hsi mkdir command.

Return type:

str

put(source: str, target: str, opts: List | str = [], listing_file: str = None) str[source]

Method to put a file onto HPSS via hsi

Parameters:
  • source (str) – Location on the local machine of the source file to send to HPSS.

  • target (str) – Full path of the target location of the file on HPSS.

  • opts (str | List) – List or string of additional options to send to hsi.

Returns:

output – Concatenated output and error of the hsi put command.

Return type:

str

rm(target: str, recursive: bool = False, hsi_opts: str = '', rm_opts: str = '') str[source]

Method to delete a file or directory on HPSS via hsi

Parameters:
  • target (str) – Full path of the target location of the file on HPSS.

  • hsi_opts (str) – String of options to send to hsi.

  • rm_opts (str) – Options to send to rm. See “hsi rm -?” for more details.

  • recursive (bool) – Flag to indicate a call to rmdir.

Returns:

output – Concatenated output and error of the hsi rm command.

Return type:

str

rmdir(target: str, hsi_opts: str = '', rmdir_opts: str = '') str[source]

Method to delete an empty directory on HPSS via hsi

Parameters:
  • target (str) – Full path of the target location of the file on HPSS.

  • hsi_opts (str) – String of options to send to hsi.

  • rmdir_opts (str) – Options to send to rmdir. See “hsi rmdir -?” for more details.

Returns:

output – Concatenated output and error of the hsi rmdir command.

Return type:

str