Skip to content

Commit

Permalink
Fixes #6 turn off debug output by default
Browse files Browse the repository at this point in the history
  • Loading branch information
rfarley3 committed Aug 5, 2016
1 parent 2bd0624 commit 0056183
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 17 deletions.
20 changes: 12 additions & 8 deletions kibana/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ def getargs():
# '--export %s --pkg --outdir %s' % [all|config|dashboard], outpath
# '--export %s --outdir %s' % [all|config|dashboard], outpath
parser = argparse.ArgumentParser(description='.kibana interaction module')
parser.add_argument(
'--verbose', '-v',
action='store_true',
dest='pr_dbg',
default=False,
help='show debug output')
parser.add_argument(
'--status', '-s',
action='store',
Expand Down Expand Up @@ -83,7 +89,7 @@ def getargs():
action='store',
dest='host',
default='localhost:9200',
help='ES host to use, format ip:port')
help='ES (not kibana) host and port to use, format ip:port')
parser.add_argument(
'--index',
action='store',
Expand Down Expand Up @@ -117,27 +123,25 @@ def getargs():
if mode is None:
# usage
pass
is_pkg = results.pkg_flag
host_arr = results.host.split(':')
host = (host_arr[0], int(host_arr[1]))
outdir = results.output_path
index = results.index
args = {}
args['host'] = host
args['idx_pattern'] = idx_pattern
args['mode'] = mode
args['is_pkg'] = is_pkg
args['is_pkg'] = results.pkg_flag
args['map_cmd'] = map_cmd
args['infile'] = infile
args['exp_obj'] = exp_obj
args['outdir'] = outdir
args['index'] = index
args['outdir'] = results.output_path
args['index'] = results.index
args['pr_dbg'] = results.pr_dbg
return args


def main():
args = getargs()
dotk = DotKibana(index_pattern=args['idx_pattern'], host=args['host'], index=args['index'])
dotk = DotKibana(index_pattern=args['idx_pattern'], host=args['host'], index=args['index'], debug=args['pr_dbg'])
if args['mode'] == 'mapping':
return handle_mapping(dotk, args['map_cmd'])
elif args['mode'] == 'export':
Expand Down
7 changes: 4 additions & 3 deletions kibana/dotkibana.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@


class DotKibana():
def __init__(self, index_pattern='*', host=('localhost', 9200), index='.kibana'):
def __init__(self, index_pattern='*', host=('localhost', 9200), index='.kibana', debug=False):
self._host = host
self.index = index
self._index_pattern = index_pattern
self.mapping = KibanaMapping(
self.index,
self._index_pattern,
self._host)
self.manager = KibanaManager(self.index, self._host)
self._host,
debug)
self.manager = KibanaManager(self.index, self._host, debug)

@property
def index_pattern(self):
Expand Down
6 changes: 3 additions & 3 deletions kibana/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import sys


DEBUG = True
PY3 = False
if sys.version_info[0] >= 3:
PY3 = True
Expand Down Expand Up @@ -57,15 +56,16 @@ def iteritems(d):

class KibanaManager():
"""Import/Export Kibana objects"""
def __init__(self, index, host):
def __init__(self, index, host, debug=False):
self._host_ip = host[0]
self._host_port = host[1]
self.index = index
self.es = None
self.max_hits = 9999
self.debug = debug

def pr_dbg(self, msg):
if DEBUG:
if self.debug:
print('[DBG] Manager %s' % msg)

def pr_inf(self, msg):
Expand Down
6 changes: 3 additions & 3 deletions kibana/mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import sys


DEBUG = True
PY3 = False
if sys.version_info[0] >= 3:
PY3 = True
Expand All @@ -28,7 +27,7 @@ def iteritems(d):


class KibanaMapping():
def __init__(self, index, index_pattern, host):
def __init__(self, index, index_pattern, host, debug=False):
self.index = index
self._index_pattern = index_pattern
self._host = host
Expand All @@ -43,9 +42,10 @@ def __init__(self, index, index_pattern, host):
self.sys_mappings = ['_source', '_index', '_type', '_id']
# .kibana has some fields to ignore too:
self.mappings_ignore = ['count']
self.debug = debug

def pr_dbg(self, msg):
if DEBUG:
if self.debug:
print('[DBG] Mapping %s' % msg)

def pr_inf(self, msg):
Expand Down

0 comments on commit 0056183

Please sign in to comment.