-
Notifications
You must be signed in to change notification settings - Fork 8
/
.konchrc
52 lines (43 loc) · 1.36 KB
/
.konchrc
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
45
46
47
48
49
50
51
52
# -*- coding: utf-8 -*-
# vi: set ft=python :
import os
import django
from django.conf import settings
from django.utils.termcolors import colorize
from django.apps import apps
import konch
import elasticsearch_dsl
from elasticsearch_dsl import connections, Search
from elasticsearch_metrics.registry import registry
from elasticsearch_metrics.management.color import color_style
# Available options:
# 'context', 'banner', 'shell', 'prompt', 'output',
# 'context_format', 'ipy_extensions', 'ipy_autoreload',
# 'ipy_colors', 'ipy_highlighting_style'
context = {
"dsl": elasticsearch_dsl,
"Search": Search,
"registry": registry,
"apps": apps,
"settings": settings,
"style": color_style(),
}
konch.config(
{
"banner": colorize(
"Welcome to the django-elasticsearch-metrics shell. Happy hacking!",
opts=("bold",),
),
"ipy_colors": "linux",
}
)
def setup():
# Set up django and add the default elasticsearch-py client and Metric to the context
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "tests.settings")
django.setup()
from elasticsearch_metrics.metrics import Metric
context["client"] = connections.get_connection()
context["Metric"] = Metric
konch.config({"context": context})
if os.path.exists(".konchrc.local"):
konch.use_file(".konchrc.local", trust=True)