Public Member Functions | Public Attributes | Properties | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
samweb_client.client.SAMWebClient Class Reference
Inheritance diagram for samweb_client.client.SAMWebClient:
object

Public Member Functions

def __init__ (self, experiment=None, secure=False, cert=None, key=None, devel=None, timezone=None)
 
def get_role (self)
 
def set_role (self, newval)
 
def get_experiment (self)
 
def set_experiment (self, experiment)
 
def set_client_certificate (self, cert, key=None)
 
def set_host (host)
 
def set_ports (port, sslport)
 
def get_baseurl (self, secure=None)
 
def get_group (self)
 
def set_group (self, group)
 
def get_station (self)
 
def set_station (self, station)
 
def get_user (self)
 
def get_timezone (self)
 
def set_timezone (self, new_tz)
 
def getURL (self, url, params=None, args, kwargs)
 
def postURL (self, url, data=None, args, kwargs)
 
def putURL (self, url, data=None, args, kwargs)
 
def deleteURL (self, url, params=None, args, kwargs)
 
def get_verbose (self)
 
def set_verbose (self, verbose)
 
def get_socket_timeout (self)
 
def set_socket_timeout (self, timeout)
 

Public Attributes

 devel
 
 secure
 
 http_client
 
short int type
 
short int number
 
char name [SIZE_OF_OBJ_NAME]
 
cat_entry star
 

Properties

 role = property(get_role, set_role)
 
 experiment = property(get_experiment, set_experiment)
 
 baseurl = property(get_baseurl)
 
 group = property(get_group, set_group)
 
 station = property(get_station, set_station)
 
 user = property(get_user)
 
 timezone = property(get_timezone, set_timezone)
 
 verbose = property(get_verbose, set_verbose)
 
 socket_timeout = property(get_socket_timeout, set_socket_timeout)
 

Private Member Functions

def _prepareURL (self, url, secure=None)
 
def _doURL (self, method, url, params=None, data=None, secure=None, role=None, args, kwargs)
 

Private Attributes

 _role
 
 _host
 
 _port
 
 _sslport
 

Static Private Attributes

 _experiment = os.environ.get('SAM_EXPERIMENT')
 
string _host = os.environ.get('SAM_WEB_HOST')or'samweb.fnal.gov'
 
string _port = os.environ.get('SAM_WEB_PORT')or'8480'
 
string _sslport = os.environ.get('SAM_WEB_SSL_PORT')or'8483'
 
 _baseurl = os.environ.get('SAM_WEB_BASE_URL')
 
 _basesslurl = os.environ.get('SAM_WEB_BASE_SSL_URL')
 
 _group = os.environ.get('SAM_GROUP')
 
 _station = os.environ.get('SAM_STATION')
 
 _timezone = os.environ.get('SAM_TZ')
 
string _default_role = 'default'
 

Detailed Description

Definition at line 33 of file client.py.

Constructor & Destructor Documentation

def samweb_client.client.SAMWebClient.__init__ (   self,
  experiment = None,
  secure = False,
  cert = None,
  key = None,
  devel = None,
  timezone = None 
)

Definition at line 48 of file client.py.

Referenced by PandAna.core.core.spectrum.fill().

48  def __init__(self, experiment=None, secure=False, cert=None, key=None, devel=None, timezone=None):
49  self.devel = False
50  if experiment is not None: self.experiment = experiment
51  self.secure = secure
52  if devel is not None: self.devel = devel
53  self.http_client = http_client.get_client()
54  self.set_client_certificate(cert, key)
55  self.role = None
56  timezone = timezone or self._timezone
57  if timezone: self.timezone = timezone
58 
def __init__(self, experiment=None, secure=False, cert=None, key=None, devel=None, timezone=None)
Definition: client.py:48
def set_client_certificate(self, cert, key=None)
Definition: client.py:82

Member Function Documentation

def samweb_client.client.SAMWebClient._doURL (   self,
  method,
  url,
  params = None,
  data = None,
  secure = None,
  role = None,
  args,
  kwargs 
)
private

Definition at line 165 of file client.py.

References samweb_client.client.SAMWebClient._prepareURL(), samweb_client.client.SAMWebClient.role, and samweb_client.client.SAMWebClient.secure.

Referenced by samweb_client.http_client.SAMWebHTTPClient.deleteURL(), samweb_client.client.SAMWebClient.deleteURL(), samweb_client.http_client.SAMWebHTTPClient.getURL(), samweb_client.client.SAMWebClient.getURL(), samweb_client.http_client.SAMWebHTTPClient.postURL(), samweb_client.client.SAMWebClient.postURL(), samweb_client.http_client.SAMWebHTTPClient.putURL(), and samweb_client.client.SAMWebClient.putURL().

165  def _doURL(self, method, url, params=None, data=None, secure=None, role=None, *args, **kwargs):
166  secure = secure or self.secure
167  url = self._prepareURL(url, secure)
168  if secure: kwargs['role'] = role or self.role
169  return method(url, params=params, data=data, *args, **kwargs)
170 
def _prepareURL(self, url, secure=None)
Definition: client.py:147
def _doURL(self, method, url, params=None, data=None, secure=None, role=None, args, kwargs)
Definition: client.py:165
def samweb_client.client.SAMWebClient._prepareURL (   self,
  url,
  secure = None 
)
private

Definition at line 147 of file client.py.

References samweb_client.client.SAMWebClient.get_baseurl().

Referenced by samweb_client.client.SAMWebClient._doURL().

147  def _prepareURL(self, url, secure=None):
148  # if provided with a relative url, add the baseurl
149  if '://' not in url:
150  url = self.get_baseurl(secure) + url
151  return url
152 
def _prepareURL(self, url, secure=None)
Definition: client.py:147
def get_baseurl(self, secure=None)
Definition: client.py:92
def samweb_client.client.SAMWebClient.deleteURL (   self,
  url,
  params = None,
  args,
  kwargs 
)

Definition at line 162 of file client.py.

References samweb_client.client.SAMWebClient._doURL().

162  def deleteURL(self, url, params=None, *args, **kwargs):
163  return self._doURL(self.http_client.deleteURL, url, params=params, *args, **kwargs)
164 
def _doURL(self, method, url, params=None, data=None, secure=None, role=None, args, kwargs)
Definition: client.py:165
def deleteURL(self, url, params=None, args, kwargs)
Definition: client.py:162
def samweb_client.client.SAMWebClient.get_baseurl (   self,
  secure = None 
)
Return the base url. If secure is set this will be an
https url, if not it may not be 

Definition at line 92 of file client.py.

References samweb_client.client.SAMWebClient._basesslurl, samweb_client.client.SAMWebClient._baseurl, samweb_client.client.SAMWebClient._host, samweb_client.client.SAMWebClient._port, samweb_client.client.SAMWebClient._sslport, samweb_client.client.SAMWebClient.devel, and samweb_client.client.SAMWebClient.experiment.

Referenced by samweb_client.client.SAMWebClient._prepareURL().

92  def get_baseurl(self, secure=None):
93  """ Return the base url. If secure is set this will be an
94  https url, if not it may not be """
95  if not secure and self._baseurl is not None:
96  return self._baseurl
97  if secure and self._basesslurl is not None:
98  return self._basesslurl
99 
100  if self.devel:
101  path = "/sam/%s/dev/api" % self.experiment
102  else:
103  path = "/sam/%s/api" % self.experiment
104  if secure:
105  if self._baseurl:
106  import sys
107  sys.stderr.write('Warning: BASEURL is set, but using default SSL URL')
108  return "https://%s:%s%s" % (self._host, self._sslport, path)
109  else:
110  return "http://%s:%s%s" % (self._host, self._port, path)
111 
def get_baseurl(self, secure=None)
Definition: client.py:92
def samweb_client.client.SAMWebClient.get_experiment (   self)
def samweb_client.client.SAMWebClient.get_group (   self)

Definition at line 114 of file client.py.

References samweb_client.client.SAMWebClient._group, samweb_client.client.SAMWebClient.get_experiment(), and split().

114  def get_group(self):
115  if not self._group:
116  # if the group isn't set then get it from the experiment name
117  # knocking off anything after a trailing slash (ie hypot/dev -> hypot)
118  self._group = self.get_experiment().split('/', 1)[0]
119  return self._group
120 
void split(double tt, double *fr)
def samweb_client.client.SAMWebClient.get_role (   self)

Definition at line 59 of file client.py.

References samweb_client.client.SAMWebClient._role.

59  def get_role(self):
60  return self._role
def samweb_client.client.SAMWebClient.get_socket_timeout (   self)

Definition at line 178 of file client.py.

178  def get_socket_timeout(self): return self.http_client.socket_timeout
def samweb_client.client.SAMWebClient.get_station (   self)
def samweb_client.client.SAMWebClient.get_timezone (   self)

Definition at line 139 of file client.py.

139  def get_timezone(self):
140  return self.http_client.timezone
141 
def samweb_client.client.SAMWebClient.get_user (   self)

Definition at line 134 of file client.py.

134  def get_user(self):
135  return pwd.getpwuid(os.getuid()).pw_name
136 
def samweb_client.client.SAMWebClient.get_verbose (   self)

Definition at line 171 of file client.py.

171  def get_verbose(self):
172  return self.http_client.verbose
def samweb_client.client.SAMWebClient.getURL (   self,
  url,
  params = None,
  args,
  kwargs 
)

Definition at line 153 of file client.py.

References samweb_client.client.SAMWebClient._doURL().

153  def getURL(self, url, params=None, *args, **kwargs):
154  return self._doURL(self.http_client.getURL, url, params=params, *args, **kwargs)
155 
def getURL(self, url, params=None, args, kwargs)
Definition: client.py:153
def _doURL(self, method, url, params=None, data=None, secure=None, role=None, args, kwargs)
Definition: client.py:165
def samweb_client.client.SAMWebClient.postURL (   self,
  url,
  data = None,
  args,
  kwargs 
)

Definition at line 156 of file client.py.

References samweb_client.client.SAMWebClient._doURL().

156  def postURL(self, url, data=None, *args, **kwargs):
157  return self._doURL(self.http_client.postURL, url, data=data, *args, **kwargs)
158 
def _doURL(self, method, url, params=None, data=None, secure=None, role=None, args, kwargs)
Definition: client.py:165
def postURL(self, url, data=None, args, kwargs)
Definition: client.py:156
def samweb_client.client.SAMWebClient.putURL (   self,
  url,
  data = None,
  args,
  kwargs 
)

Definition at line 159 of file client.py.

References samweb_client.client.SAMWebClient._doURL().

159  def putURL(self, url, data=None, *args, **kwargs):
160  return self._doURL(self.http_client.putURL, url, data=data, *args, **kwargs)
161 
def putURL(self, url, data=None, args, kwargs)
Definition: client.py:159
def _doURL(self, method, url, params=None, data=None, secure=None, role=None, args, kwargs)
Definition: client.py:165
def samweb_client.client.SAMWebClient.set_client_certificate (   self,
  cert,
  key = None 
)

Definition at line 82 of file client.py.

82  def set_client_certificate(self, cert, key=None):
83  self.http_client.use_client_certificate(cert, key)
84 
def set_client_certificate(self, cert, key=None)
Definition: client.py:82
def samweb_client.client.SAMWebClient.set_experiment (   self,
  experiment 
)

Definition at line 74 of file client.py.

References samweb_client.client.SAMWebClient._experiment, and samweb_client.client.SAMWebClient.devel.

74  def set_experiment(self, experiment):
75  self._experiment = experiment
76  if self._experiment.endswith('/dev'):
77  self.devel = True
78  self._experiment = self._experiment[:-4]
79 
def set_experiment(self, experiment)
Definition: client.py:74
def samweb_client.client.SAMWebClient.set_group (   self,
  group 
)

Definition at line 121 of file client.py.

References samweb_client.client.SAMWebClient._group.

121  def set_group(self,group):
122  self._group = group
123 
def set_group(self, group)
Definition: client.py:121
def samweb_client.client.SAMWebClient.set_host (   host)

Definition at line 85 of file client.py.

85  def set_host(host):
86  self._host = host
87 
def samweb_client.client.SAMWebClient.set_ports (   port,
  sslport 
)

Definition at line 88 of file client.py.

88  def set_ports(port, sslport):
89  if port: self._port = port
90  if sslport: self._sslport = sslport
91 
def set_ports(port, sslport)
Definition: client.py:88
def samweb_client.client.SAMWebClient.set_role (   self,
  newval 
)

Definition at line 61 of file client.py.

61  def set_role(self, newval):
62  if newval is None:
63  self._role = self._default_role
64  else:
65  self._role = newval
66 
def set_role(self, newval)
Definition: client.py:61
def samweb_client.client.SAMWebClient.set_socket_timeout (   self,
  timeout 
)

Definition at line 179 of file client.py.

179  def set_socket_timeout(self, timeout): self.http_client.socket_timeout = timeout
def set_socket_timeout(self, timeout)
Definition: client.py:179
def samweb_client.client.SAMWebClient.set_station (   self,
  station 
)

Definition at line 129 of file client.py.

References samweb_client.client.SAMWebClient._station.

129  def set_station(self,station):
130  self._station = station
131 
def set_station(self, station)
Definition: client.py:129
def samweb_client.client.SAMWebClient.set_timezone (   self,
  new_tz 
)

Definition at line 142 of file client.py.

142  def set_timezone(self, new_tz):
143  self.http_client.timezone = new_tz
144 
def set_timezone(self, new_tz)
Definition: client.py:142
def samweb_client.client.SAMWebClient.set_verbose (   self,
  verbose 
)

Definition at line 173 of file client.py.

173  def set_verbose(self, verbose):
174  self.http_client.verbose = verbose
175 
def set_verbose(self, verbose)
Definition: client.py:173

Member Data Documentation

samweb_client.client.SAMWebClient._basesslurl = os.environ.get('SAM_WEB_BASE_SSL_URL')
staticprivate

Definition at line 39 of file client.py.

Referenced by samweb_client.client.SAMWebClient.get_baseurl().

samweb_client.client.SAMWebClient._baseurl = os.environ.get('SAM_WEB_BASE_URL')
staticprivate

Definition at line 38 of file client.py.

Referenced by samweb_client.client.SAMWebClient.get_baseurl().

string samweb_client.client.SAMWebClient._default_role = 'default'
staticprivate

Definition at line 46 of file client.py.

samweb_client.client.SAMWebClient._experiment = os.environ.get('SAM_EXPERIMENT')
staticprivate
samweb_client.client.SAMWebClient._group = os.environ.get('SAM_GROUP')
staticprivate
string samweb_client.client.SAMWebClient._host = os.environ.get('SAM_WEB_HOST')or'samweb.fnal.gov'
staticprivate

Definition at line 35 of file client.py.

Referenced by samweb_client.client.SAMWebClient.get_baseurl().

samweb_client.client.SAMWebClient._host
private

Definition at line 86 of file client.py.

string samweb_client.client.SAMWebClient._port = os.environ.get('SAM_WEB_PORT')or'8480'
staticprivate

Definition at line 36 of file client.py.

Referenced by samweb_client.client.SAMWebClient.get_baseurl().

samweb_client.client.SAMWebClient._port
private

Definition at line 89 of file client.py.

samweb_client.client.SAMWebClient._role
private

Definition at line 63 of file client.py.

Referenced by samweb_client.client.SAMWebClient.get_role().

string samweb_client.client.SAMWebClient._sslport = os.environ.get('SAM_WEB_SSL_PORT')or'8483'
staticprivate

Definition at line 37 of file client.py.

Referenced by samweb_client.client.SAMWebClient.get_baseurl().

samweb_client.client.SAMWebClient._sslport
private

Definition at line 90 of file client.py.

samweb_client.client.SAMWebClient._station = os.environ.get('SAM_STATION')
staticprivate
samweb_client.client.SAMWebClient._timezone = os.environ.get('SAM_TZ')
staticprivate

Definition at line 43 of file client.py.

samweb_client.client.SAMWebClient.devel
samweb_client.client.SAMWebClient.http_client

Definition at line 53 of file client.py.

char object::name
inherited
short int object::number
inherited

Definition at line 115 of file novas.h.

samweb_client.client.SAMWebClient.secure

Definition at line 51 of file client.py.

Referenced by samweb_client.client.SAMWebClient._doURL().

cat_entry object::star
inherited

Definition at line 117 of file novas.h.

short int object::type
inherited

Definition at line 114 of file novas.h.

Property Documentation

samweb_client.client.SAMWebClient.baseurl = property(get_baseurl)
static

Definition at line 112 of file client.py.

samweb_client.client.SAMWebClient.experiment = property(get_experiment, set_experiment)
static

Definition at line 80 of file client.py.

Referenced by samweb_client.client.SAMWebClient.get_baseurl().

samweb_client.client.SAMWebClient.group = property(get_group, set_group)
static
samweb_client.client.SAMWebClient.role = property(get_role, set_role)
static

Definition at line 67 of file client.py.

Referenced by samweb_client.client.SAMWebClient._doURL().

samweb_client.client.SAMWebClient.socket_timeout = property(get_socket_timeout, set_socket_timeout)
static
samweb_client.client.SAMWebClient.station = property(get_station, set_station)
static

Definition at line 132 of file client.py.

samweb_client.client.SAMWebClient.timezone = property(get_timezone, set_timezone)
static

Definition at line 145 of file client.py.

samweb_client.client.SAMWebClient.user = property(get_user)
static
samweb_client.client.SAMWebClient.verbose = property(get_verbose, set_verbose)
static

The documentation for this class was generated from the following file: