From 560911282c78c71608cf5deef35d56e61c001c2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Sat, 25 May 2019 10:21:26 +0200 Subject: [PATCH] Connect to bot services MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michal Čihař --- .gitignore | 3 +++ migrate.py | 45 +++++++++++++++++++++++++++++++++++++++++++++ requirements.txt | 2 ++ 3 files changed, 50 insertions(+) create mode 100755 migrate.py create mode 100644 requirements.txt diff --git a/.gitignore b/.gitignore index 894a44c..3e80c5b 100644 --- a/.gitignore +++ b/.gitignore @@ -102,3 +102,6 @@ venv.bak/ # mypy .mypy_cache/ + +# configuration +rt2zammad.json diff --git a/migrate.py b/migrate.py new file mode 100755 index 0000000..0227fc3 --- /dev/null +++ b/migrate.py @@ -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) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..97d2f05 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +rt +zammad_py