_userinfo_regex = re.compile(r'window.current_user_attributes = ({.*})')
# this is for older version of D*
_userinfo_regex_2 = re.compile(r'gon.user=({.*});gon.preloads')
+ _verify_SSL = True
def __init__(self, pod, username, password, schema='https'):
"""
"""
if not direct: url = '{0}/{1}'.format(self.pod, string)
else: url = string
- return self._session.get(url, params=params, headers=headers, **kwargs)
+ return self._session.get(url, params=params, headers=headers, verify=self._verify_SSL, **kwargs)
def post(self, string, data, headers={}, params={}, **kwargs):
"""This method posts data to session.
:type params: dict
"""
string = '{0}/{1}'.format(self.pod, string)
- request = self._session.post(string, data, headers=headers, params=params, **kwargs)
+ request = self._session.post(string, data, headers=headers, params=params, verify=self._verify_SSL, **kwargs)
return request
def put(self, string, data=None, headers={}, params={}, **kwargs):
"""
string = '{0}/{1}'.format(self.pod, string)
if data is not None: request = self._session.put(string, data, headers=headers, params=params, **kwargs)
- else: request = self._session.put(string, headers=headers, params=params, **kwargs)
+ else: request = self._session.put(string, headers=headers, params=params, verify=self._verify_SSL, **kwargs)
return request
def delete(self, string, data, headers={}, **kwargs):
if userdata is None: raise errors.DiaspyError('cannot find user data')
userdata = userdata.group(1)
return json.loads(userdata)
+
+ def set_verify_SSL(self, verify):
+ """Sets whether there should be an error if a SSL-Certificate could not be verified.
+ """
+ self._verify_SSL = verify
return self['guid']
def __repr__(self):
- return '{0} ({1})'.format(self['diaspora_name'], self['guid'])
+ return '{0} ({1})'.format(self['handle'], self['guid'])
def _fetchstream(self):
self.stream = Outer(self._connection, location='people/{0}.json'.format(self['guid']))
def fetchprofile(self):
"""Fetches user data.
"""
- data = search.Search(self._connection).user(self['handle'])[0]
- self.data = data
+ result = search.Search(self._connection).user(self['handle'])
+
+ # Check if there were any results at all
+ if len(result) < 1:
+ raise errors.UserError('could not fetch profile of user: {0}'.format(self['handle']))
+
+ self.data = result[0]
def getHCard(self):
"""Returns XML string containing user HCard.