todoist_interface/todoist_interface/__main__.py

34 lines
1.0 KiB
Python
Raw Normal View History

2021-11-06 19:06:34 +01:00
import settings
from todoist import TodoistAPI
2021-11-06 19:42:04 +01:00
from gitlab import GitlabAPI
2021-11-06 21:27:27 +01:00
from mantishub import MantishubAPI
from todoist_interface import mantishub
2021-11-06 20:07:57 +01:00
import utils
2021-11-06 19:06:34 +01:00
if __name__ == '__main__':
# initialise the settings
2021-11-06 19:34:33 +01:00
config = settings.read_config("todoist_interface.yml")
2021-11-06 19:06:34 +01:00
2021-11-06 20:07:57 +01:00
# initialise Todoist and Gitlab
2021-11-06 19:06:34 +01:00
todoist = TodoistAPI(config['todoist']['token'])
2021-11-06 21:27:27 +01:00
gitlab = GitlabAPI(config["gitlab"]["url"],
config["gitlab"]["token"],
config["gitlab"]["assignee"])
mantishub = MantishubAPI(config["mantishub"]["token"])
2021-11-06 20:07:57 +01:00
# Get the Todoist tasks
2021-11-06 19:06:34 +01:00
tasks = todoist.get_get_tasks_by_filter("@gitlab")
2021-11-06 20:07:57 +01:00
# Get the Gitlab issues
2021-11-06 21:27:27 +01:00
gitlab_tasks = gitlab.get_issues()
mantishub_tasks = mantishub.get_tickets()
missing_tasks = []
missing_tasks.append(utils.get_missing_tasks(tasks, gitlab_tasks))
missing_tasks.append(utils.get_missing_tasks(tasks, mantishub_tasks))
2021-11-06 20:07:57 +01:00
2021-11-06 20:48:30 +01:00
if missing_tasks:
todoist.create_tasks(missing_tasks)
2021-11-06 20:57:22 +01:00
exit(0)
2021-11-06 20:54:28 +01:00
print("Nothing new to add.")