sdss_access.path.path.BasePath(pathfile, mirror=False, public=False, verbose=False)[source]¶Bases: object
Class for construction of paths in general.
| Variables: | templates (dict) – The set of templates read from the configuration file. |
|---|
any(filetype, **kwargs)[source]¶Checks if the local directory contains any of the type of file
| Parameters: | filetype (str) – File type parameter. |
|---|---|
| Returns: | any (bool) – Boolean indicating if the any files exist in the expanded path on disk. |
dir(filetype, **kwargs)[source]¶Return the directory containing a file of a given type.
| Parameters: | filetype (str) – File type parameter. |
|---|---|
| Returns: | dir (str) – Directory containing the file. |
exists(filetype, **kwargs)[source]¶Checks if the given type of file exists
| Parameters: | filetype (str) – File type parameter. |
|---|---|
| Returns: | exists (bool) – Boolean indicating if the file exists on disk. |
expand(filetype, **kwargs)[source]¶Expand a wildcard path locally
| Parameters: | |
|---|---|
| Returns: | expand (list) – List of expanded full paths of the given type. |
full(filetype, **kwargs)[source]¶Return the full name of a given type of file.
| Parameters: | filetype (str) – File type parameter. |
|---|---|
| Returns: | full (str) – The full path to the file. |
location(filetype, base_dir=None, **kwargs)[source]¶Return the location of the relative sas path of a given type of file.
| Parameters: | filetype (str) – File type parameter. |
|---|---|
| Returns: | full (str) – The relative sas path to the file. |
lookup_keys(name)[source]¶Lookup the keyword arguments needed for a given path name
| Parameters: | name (str) – The name of the path |
|---|---|
| Returns: | A list of keywords needed for filepath generation |
name(filetype, **kwargs)[source]¶Return the directory containing a file of a given type.
| Parameters: | filetype (str) – File type parameter. |
|---|---|
| Returns: | name (str) – Name of a file with no directory information. |
one(filetype, **kwargs)[source]¶Returns random one of the given type of file
| Parameters: | |
|---|---|
| Returns: | one (str) – Random file selected from the expanded list of full paths on disk. |
random(filetype, **kwargs)[source]¶Returns random number of the given type of file
| Parameters: | |
|---|---|
| Returns: | random (list) – Random file selected from the expanded list of full paths on disk. |
refine(filelist, regex, filterdir='out', **kwargs)[source]¶Returns a list of files filterd by a regular expression
| Parameters: |
|
|---|---|
| Returns: | refine (list) – A file list refined by an input regular expression. |
sdss_access.path.path.Path(mirror=False, public=False, verbose=False)[source]¶Bases: sdss_access.path.path.BasePath
Class for construction of paths in general. Sets a particular template file.
definitiondir(filetype, **kwargs)[source]¶Returns definition subdirectory in PLATELIST_DIR of the form: NNNNXX.
| Parameters: | |
|---|---|
| Returns: | definitiondir (str) – Definition directory in the format |
platedir(filetype, **kwargs)[source]¶Returns plate subdirectory in PLATELIST_DIR of the form: NNNNXX/NNNNNN.
| Parameters: | |
|---|---|
| Returns: | platedir (str) – Plate directory in the format |
sdss_access.sync.cli.Cli(label=None, data_dir=None, verbose=False)[source]¶Bases: object
Class for providing command line interface (cli) sync scripts, and logs to local disk
foreground_run(command, test=False, logger=None, logall=False, message=None, outname=None, errname=None)[source]¶A convenient wrapper to log and perform system calls.
| Parameters: |
|
|---|---|
| Returns: | (status,out,err) (tuple) – The exit status, stdout and stderr of the process |
Examples
>>> status,out,err = transfer.common.system_call('date')
tmp_dir = '/tmp'¶sdss_access.sync.http.HttpAccess(verbose=False)[source]¶Bases: sdss_access.path.path.Path
Class for providing HTTP access via urllib.request (python3) or urllib2 (python2) to SDSS SAS Paths
download_url_to_path(url, path, force=False)[source]¶Download a file from url via http, and put it at path
| Parameters: |
|---|
get(filetype, **kwargs)[source]¶Returns file name, downloading if remote access configured.
| Parameters: |
|---|
Notes
Path templates are defined in $DIMAGE_DIR/data/dimage_paths.ini
sdss_access.sync.rsync.RsyncAccess(label='sdss_rsync', stream_count=5, mirror=False, public=False, verbose=False)[source]¶Bases: sdss_access.path.path.Path
Class for providing Rsync access to SDSS SAS Paths
sdss_access.sync.system_call.system_call(command, test=False, logger=None, logall=False, message=None, outname=None, errname=None)[source]¶A convenient wrapper to log and perform system calls.
| Parameters: |
|
|---|---|
| Returns: | (status,out,err) (tuple) – The exit status, stdout and stderr of the process |
Examples
>>> status,out,err = transfer.common.system_call('date')