Skip to content

Commit f588a6d

Browse files
committed
create grafana_backup package and add setup.py
This means we're ready to distribute this package on pypi.
1 parent c01dbc2 commit f588a6d

File tree

6 files changed

+90
-2
lines changed

6 files changed

+90
-2
lines changed

Diff for: .gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
*.json
22
venv
3+
4+
*.egg-info
5+
*.pyc
6+
*.swp

Diff for: README.rst

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
grafana-backup
2+
==============
3+
4+
Create dashboards backups using the Grafana API.
5+
6+
7+
Installation
8+
------------
9+
10+
The latest stable version can be installed from PyPi:
11+
12+
::
13+
14+
$ pip install kea-exporter
15+
16+
17+
and upgraded with:
18+
19+
::
20+
21+
$ pip install --upgrade kea-exporter
22+
23+
24+
Usage
25+
----
26+
27+
::
28+
29+
Usage: grafana-backup [OPTIONS]
30+
31+
Options:
32+
--api-key TEXT API key of the target grafana [required]
33+
--grafana-url TEXT base url of the target grafana [required]
34+
--help Show this message and exit.

Diff for: grafana_backup/__init__.py

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
__PROJECT__ = 'grafana-backup'
2+
__VERSION__ = '0.1.0'
3+
4+
from .grafana_backup import backup

Diff for: grafana_backup/__main__.py

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from .grafana_backup import *
2+
3+
if __name__ == '__main__':
4+
backup()

Diff for: grafana_backup.py renamed to grafana_backup/grafana_backup.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import click
77
import requests
88

9+
910
logging.basicConfig(level=logging.DEBUG)
1011

1112
class HTTPBearerAuthentication(requests.auth.AuthBase):
@@ -16,8 +17,6 @@ def __call__(self, r):
1617
r.headers['Authorization'] = 'Bearer {token}'.format(token=self._token)
1718
return r
1819

19-
# eyJrIjoiaXNjbGRlY1pWWDczTG1idlNRVjE2VFBhSEd0dEJGelAiLCJuIjoiYW5kaSBub3RlYm9vayIsImlkIjoxfQ=="
20-
2120
@click.command()
2221
@click.option('--api-key', help='API key of the target grafana', required=True, prompt=True)
2322
@click.option('--grafana-url', help='base url of the target grafana', required=True)

Diff for: setup.py

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import codecs
2+
import os.path
3+
4+
import sys
5+
from setuptools import setup, find_packages
6+
7+
from grafana_backup import __PROJECT__, __VERSION__
8+
9+
10+
if sys.argv[-1] == "publish":
11+
os.system("python setup.py sdist bdist_wheel upload")
12+
sys.exit()
13+
14+
here = os.path.abspath(os.path.dirname(__file__))
15+
16+
17+
# use README as long description
18+
with codecs.open(os.path.join(here, 'README.rst'), encoding='utf-8') as handle:
19+
long_description = handle.read()
20+
21+
# required dependencies
22+
required = [
23+
'click',
24+
'requests',
25+
]
26+
27+
28+
setup(
29+
name=__PROJECT__,
30+
version=__VERSION__,
31+
description='Create dashboards backups using the Grafana API.',
32+
long_description=long_description,
33+
author='Andreas Rammhold',
34+
author_email='[email protected]',
35+
url='https://www.github.com/freifunk-darmstadt/grafana-backup',
36+
license='GPLv2',
37+
install_requires=required,
38+
packages=find_packages(),
39+
entry_points={
40+
'console_scripts': ['grafana-backup=grafana_backup:backup']
41+
},
42+
)
43+

0 commit comments

Comments
 (0)