-
Notifications
You must be signed in to change notification settings - Fork 10
gettingstarted
Several configuration files are used by both the CLI tools and python API. See carchive.conf.example for a list of options.
For a Channel Archiver accessible as "http://myca.local/cgi-bin/ArchiveDataServer.cgi", the following is sufficient
[DEFAULT]
#urltype=classic # the default
host=myca.local
Additional sections my be included, and used with the '-C
' arguement, or the 'arsetdefault("section")' function.For an Archiver Appliance accessible as "http://hostname.local:17665/mgmt/bpl/getApplianceInfo"
[DEFAULT]
urltype=appl
host=hostname.local:17665
If the URL scheme or path differs from the default, then the full UR should be given as 'url='.
$ arinfo # uses [DEFAULT]
# or
$ arinfo -C section # uses [section]
Will list all Channel Archiver archive keys, or 'All' for Archiver Appliance. This demonstrates basic communication with the archive server.
>>> from carchive.untwisted import *
The following examples will demonstrate both CLI (beginning with '$') and python (beginning with '>>>').
The Channel Archiver backend is capable of simultaneous searching of several Archive Keys. The list of keys to search is given as a list of key names or numbers. Names are allowed to contain wildcard characters '?' and '*'.
The default is '*' which will search all keys. This may be overridden with the 'defaultarchs' configuration option.
To search the keys 'key1', 'key2', and all keys beginning with 'other':
$ argrep -a key1 -a key2 -a 'other*' ....
>>> arsearch(..., archs=['key1','key2','other*'])
Name searches are done with the CLI argrep or python arsearch(). As of 2.0 both support search by wildcard, regular expression, or exact string match. For historical reasons argrep default to regexp, arget default to exact string, and arsearch() defaults to wildcard syntax.
Wildcard and regexp. matching is partial. For example 'lo' will match 'hello'.
$ argrep --wildcard 'LTB*ICT*Q-I'
LTB-BI{ICT:1}Q-I
...
$ argrep --regexp 'LTB.*ICT.*Q-I'
LTB-BI{ICT:1}Q-I
...
>>> arsearch(['LTB*ICT*Q-I'], match=WILDCARD)
set(['LTB-BI{ICT:1}Q-I',
...)
>>> arsearch(['LTB.*ICT.*Q-I'], match=REGEXP)
set(['LTB-BI{ICT:1}Q-I',
...)
Note that the entries returned by arsearch() are a sub-class of 'str' having additional member variables. See the doc string for details.
$ arget --start '-1 min' --wildcard 'LTB*ICT*Q-I'
LTB-BI{ICT:1}Q-I
2015-03-18 18:51:44.711198 -0.00343209054212
...
Found 45 points
...
Retrieves data from the past minute. See the arget manpage for a list of time formats.
The text output format of arget is intended to mimic the format of camonitor, but may differ in some respects.
$ arget -E hdf5 --start '-1 min' --wildcard outfile.h5 'LTB*ICT*Q-I'
The layout of the HDF5 file is described in the arget manpage.
The python module carchive.h5data may be helpful in processing these files.
>>> retval=arget(['LTB*ICT*Q-I'], start='-1 m', match=WILDCARD)
The form of the returned value is a dictionary when the input is a list or tuple when a single name is requested. In either case the result is a pair of numpy arrays for each name. See the doc string for details.
When reporting problems or errors please enable full debugging output.
$ arget -vvv ...
>>> import logging
>>> logging.basicConfig(level=logging.DEBUG)