Connect to bot services

Signed-off-by: Michal Čihař <michal@cihar.com>
This commit is contained in:
Michal Čihař 2019-05-25 10:21:26 +02:00
parent 9502fc75d5
commit 560911282c
3 changed files with 50 additions and 0 deletions

3
.gitignore vendored
View file

@ -102,3 +102,6 @@ venv.bak/
# mypy
.mypy_cache/
# configuration
rt2zammad.json

45
migrate.py Executable file
View file

@ -0,0 +1,45 @@
#!/usr/bin/env python
"""
Quick and dirty attempt to migrate issues from Request Tracker to Zammad.
"""
import json
import os
import sys
from requests.exceptions import HTTPError
from zammad_py import ZammadAPI
from rt import Rt
TEMPLATE = """{
"zammad_host": "",
"zammad_user": "",
"zammad_password": "",
"zammad_secure": true,
"rt_url": "",
"rt_user": "",
"rt_pass": ""
}
"""
if not os.path.exists('rt2zammad.json'):
print('Missing rt2zammad.json!')
print('Create one based on following template:')
print(TEMPLATE)
sys.exit(1)
with open('rt2zammad.json') as handle:
config = json.load(handle)
target = ZammadAPI(
host=config['zammad_host'],
username=config['zammad_user'],
password=config['zammad_password'],
is_secure=config['zammad_secure'],
)
target.user.me()
source = Rt(config['rt_url'], config['rt_user'], config['rt_pass'])
if not source.login():
print('Failed to login to RT!')
sys.exit(2)

2
requirements.txt Normal file
View file

@ -0,0 +1,2 @@
rt
zammad_py