CAOM-2.3 repo access and tools
Project description
This package implements a client for accessing a caom2repo Web service (WS)
The package can be used as a library as well as through the caom2-repo-client
command it installs.
1. Instantiate CAOM2RepoClient and use it to access the caom2repo WS.
The only mandatory argument that the CadcDataClient constructor takes is
a cadcutils.net.Subject that holds the user credentials. The client interacts with
the caom2repo WS through the get_observation, put_observation, post_observation,
delete_observation and visit functions of the client.
Example (appropriate credentials required):
from caom2repo import CAOM2RepoClient
from cadcutils import net
client = CAOM2RepoClient(net.Subject(certificate='/path/mycert.pem'))
print(client.get_observation('CFHT', '700000'))
2. Invoke the caom2repo entry point function. This is the function that
is used to generate the caom2-repo-client application
Example:
from caom2repo import main_app
import sys
sys.argv = ['caom2-repo-client', 'read', '--netrc', '/path/mynetrc',
--collection', 'CFHT', '700000']
main_app()
3. Invoke the caom2-repo-client as an external command
Example:
import os
os.system('caom2-repo-client read -n --collection CFHT 700000')
Method 1. is the recommended method as it does not required forking external processes
and also allows trapping the exceptions and reacting according to the type of the
error. Method 2 also works but the sys.exit needs to be trapped in order
to prevent the script from quiting. Method 3, while simple, must rely on inter
processes communication to determine the result of running the command.
The package can be used as a library as well as through the caom2-repo-client
command it installs.
1. Instantiate CAOM2RepoClient and use it to access the caom2repo WS.
The only mandatory argument that the CadcDataClient constructor takes is
a cadcutils.net.Subject that holds the user credentials. The client interacts with
the caom2repo WS through the get_observation, put_observation, post_observation,
delete_observation and visit functions of the client.
Example (appropriate credentials required):
from caom2repo import CAOM2RepoClient
from cadcutils import net
client = CAOM2RepoClient(net.Subject(certificate='/path/mycert.pem'))
print(client.get_observation('CFHT', '700000'))
2. Invoke the caom2repo entry point function. This is the function that
is used to generate the caom2-repo-client application
Example:
from caom2repo import main_app
import sys
sys.argv = ['caom2-repo-client', 'read', '--netrc', '/path/mynetrc',
--collection', 'CFHT', '700000']
main_app()
3. Invoke the caom2-repo-client as an external command
Example:
import os
os.system('caom2-repo-client read -n --collection CFHT 700000')
Method 1. is the recommended method as it does not required forking external processes
and also allows trapping the exceptions and reacting according to the type of the
error. Method 2 also works but the sys.exit needs to be trapped in order
to prevent the script from quiting. Method 3, while simple, must rely on inter
processes communication to determine the result of running the command.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
caom2repo-1.2.0a1.tar.gz
(23.0 kB
view details)
File details
Details for the file caom2repo-1.2.0a1.tar.gz
.
File metadata
- Download URL: caom2repo-1.2.0a1.tar.gz
- Upload date:
- Size: 23.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bd31d4154a20e4fcebb7e241349b651b51dbf3ee6d646695a6fea89d39cdf972 |
|
MD5 | 71674a462a9a89dc6fe7e760c3ec439b |
|
BLAKE2b-256 | c98f0f5e717617e5076ad6655fb71694e08539ef6dbab1b7a319c16dbc4b192b |