Compare commits
3 Commits
nilmdb-1.9
...
nilmdb-1.9
Author | SHA1 | Date | |
---|---|---|---|
7d7b89b52f | |||
8d249273c6 | |||
abe431c663 |
@@ -9,7 +9,7 @@ import requests
|
|||||||
|
|
||||||
class HTTPClient(object):
|
class HTTPClient(object):
|
||||||
"""Class to manage and perform HTTP requests from the client"""
|
"""Class to manage and perform HTTP requests from the client"""
|
||||||
def __init__(self, baseurl = "", post_json = False):
|
def __init__(self, baseurl = "", post_json = False, verify_ssl = True):
|
||||||
"""If baseurl is supplied, all other functions that take
|
"""If baseurl is supplied, all other functions that take
|
||||||
a URL can be given a relative URL instead."""
|
a URL can be given a relative URL instead."""
|
||||||
# Verify / clean up URL
|
# Verify / clean up URL
|
||||||
@@ -19,6 +19,7 @@ class HTTPClient(object):
|
|||||||
self.baseurl = reparsed.rstrip('/') + '/'
|
self.baseurl = reparsed.rstrip('/') + '/'
|
||||||
|
|
||||||
# Build Requests session object, enable SSL verification
|
# Build Requests session object, enable SSL verification
|
||||||
|
self.verify_ssl = verify_ssl
|
||||||
self.session = requests.Session()
|
self.session = requests.Session()
|
||||||
self.session.verify = True
|
self.session.verify = True
|
||||||
|
|
||||||
@@ -67,7 +68,8 @@ class HTTPClient(object):
|
|||||||
params = query_data,
|
params = query_data,
|
||||||
data = body_data,
|
data = body_data,
|
||||||
stream = stream,
|
stream = stream,
|
||||||
headers = headers)
|
headers = headers,
|
||||||
|
verify = self.verify_ssl)
|
||||||
except requests.RequestException as e:
|
except requests.RequestException as e:
|
||||||
raise ServerError(status = "502 Error", url = url,
|
raise ServerError(status = "502 Error", url = url,
|
||||||
message = str(e.message))
|
message = str(e.message))
|
||||||
|
@@ -121,7 +121,7 @@ class Cmdline(object):
|
|||||||
group = self.parser.add_argument_group("General options")
|
group = self.parser.add_argument_group("General options")
|
||||||
group.add_argument("-h", "--help", action='help',
|
group.add_argument("-h", "--help", action='help',
|
||||||
help='show this help message and exit')
|
help='show this help message and exit')
|
||||||
group.add_argument("-V", "--version", action="version",
|
group.add_argument("-v", "--version", action="version",
|
||||||
version = nilmdb.__version__)
|
version = nilmdb.__version__)
|
||||||
|
|
||||||
group = self.parser.add_argument_group("Server")
|
group = self.parser.add_argument_group("Server")
|
||||||
|
@@ -45,6 +45,8 @@ def setup(self, sub):
|
|||||||
help="Show raw timestamps when printing times")
|
help="Show raw timestamps when printing times")
|
||||||
group.add_argument("-l", "--layout", action="store_true",
|
group.add_argument("-l", "--layout", action="store_true",
|
||||||
help="Show layout type next to path name")
|
help="Show layout type next to path name")
|
||||||
|
group.add_argument("-n", "--no-decim", action="store_true",
|
||||||
|
help="Skip paths containing \"~decim-\"")
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
|
|
||||||
@@ -71,6 +73,8 @@ def cmd_list(self):
|
|||||||
(path, layout, int_min, int_max, rows, time) = stream[:6]
|
(path, layout, int_min, int_max, rows, time) = stream[:6]
|
||||||
if not fnmatch.fnmatch(path, argpath):
|
if not fnmatch.fnmatch(path, argpath):
|
||||||
continue
|
continue
|
||||||
|
if self.args.no_decim and "~decim-" in path:
|
||||||
|
continue
|
||||||
|
|
||||||
if self.args.layout:
|
if self.args.layout:
|
||||||
printf("%s %s\n", path, layout)
|
printf("%s %s\n", path, layout)
|
||||||
|
@@ -10,9 +10,8 @@ def main():
|
|||||||
|
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
description = 'Check database consistency',
|
description = 'Check database consistency',
|
||||||
formatter_class = argparse.ArgumentDefaultsHelpFormatter)
|
formatter_class = argparse.ArgumentDefaultsHelpFormatter,
|
||||||
parser.add_argument("-V", "--version", action="version",
|
version = nilmdb.__version__)
|
||||||
version = nilmdb.__version__)
|
|
||||||
parser.add_argument("-f", "--fix", action="store_true",
|
parser.add_argument("-f", "--fix", action="store_true",
|
||||||
default=False, help = 'Fix errors when possible '
|
default=False, help = 'Fix errors when possible '
|
||||||
'(which may involve removing data)')
|
'(which may involve removing data)')
|
||||||
|
@@ -10,10 +10,8 @@ def main():
|
|||||||
|
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
description = 'Run the NilmDB server',
|
description = 'Run the NilmDB server',
|
||||||
formatter_class = argparse.ArgumentDefaultsHelpFormatter)
|
formatter_class = argparse.ArgumentDefaultsHelpFormatter,
|
||||||
|
version = nilmdb.__version__)
|
||||||
parser.add_argument("-V", "--version", action="version",
|
|
||||||
version = nilmdb.__version__)
|
|
||||||
|
|
||||||
group = parser.add_argument_group("Standard options")
|
group = parser.add_argument_group("Standard options")
|
||||||
group.add_argument('-a', '--address',
|
group.add_argument('-a', '--address',
|
||||||
|
Reference in New Issue
Block a user