/usr/lib/python3/dist-packages/consul/std.py is in python3-consul 0.7.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | import requests
from consul import base
__all__ = ['Consul']
class HTTPClient(base.HTTPClient):
def __init__(self, *args, **kwargs):
super(HTTPClient, self).__init__(*args, **kwargs)
self.session = requests.session()
def response(self, response):
response.encoding = 'utf-8'
return base.Response(
response.status_code, response.headers, response.text)
def get(self, callback, path, params=None):
uri = self.uri(path, params)
return callback(self.response(
self.session.get(uri, verify=self.verify, cert=self.cert)))
def put(self, callback, path, params=None, data=''):
uri = self.uri(path, params)
return callback(self.response(
self.session.put(uri, data=data, verify=self.verify,
cert=self.cert)))
def delete(self, callback, path, params=None):
uri = self.uri(path, params)
return callback(self.response(
self.session.delete(uri, verify=self.verify, cert=self.cert)))
def post(self, callback, path, params=None, data=''):
uri = self.uri(path, params)
return callback(self.response(
self.session.post(uri, data=data, verify=self.verify,
cert=self.cert)))
class Consul(base.Consul):
def connect(self, host, port, scheme, verify=True, cert=None):
return HTTPClient(host, port, scheme, verify, cert)
|