Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[config] Live reload of setup.cfg #333

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions sirmordred/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import configparser
import logging
from threading import Lock

from sirmordred._version import __version__

Expand All @@ -41,6 +42,8 @@
class Config():
"""Class aimed to manage sirmordred configuration"""

config_lock = Lock()

def __init__(self, conf_file, conf_list=[]):
"""Initialize object.

Expand Down Expand Up @@ -654,8 +657,11 @@ def create_config_file(cls, file_path):
parser.write(f)

def get_conf(self):
# TODO: Return a deepcopy to avoid uncontrolled changes in config?
return self.conf
"""Reload configuration files"""

with self.config_lock:
self.__read_conf_files()
return self.conf

def set_param(self, section, param, value):
""" Change a param in the config """
Expand Down
262 changes: 262 additions & 0 deletions tests/test-bad-study.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,262 @@
#
# Test config with only git and github activated
#


# Config values format
#
# List: [val1, val2 ...]
# Int: int_value
# Int as string: "Int"
# List as string: "[val1, val2 ...]"
# String: string_value
# None: None, none
# Boolean: true, True, False, false

[general]
short_name = Grimoire
update = false
min_update_delay = 10
debug = true
# /var/log/sigmordred/
logs_dir = logs
# Number of items per bulk request to Elasticsearch
bulk_size = 100
# Number of items to get from Elasticsearch when scrolling
scroll_size = 100

[projects]
projects_file = test-projects.json

[es_collection]
url = http://localhost:9200
# url = https://admin:admin@localhost:9200

[es_enrichment]
url = http://localhost:9200
# url = https://admin:admin@localhost:9200
autorefresh = false

[sortinghat]
host = 127.0.0.1
user = root
password =
database = test_sh
load_orgs = true
orgs_file = data/orgs_sortinghat.json
identities_api_token = 'xxxx'
identities_file = [data/perceval_identities_sortinghat.json]
affiliate = true
# commonly: Unknown
unaffiliated_group = Unknown
autoprofile = [customer,git,github]
matching = [email]
sleep_for = 120
# sleep_for = 1800
bots_names = [Beloved Bot]

[panels]
kibiter_time_from= "now-30y"
kibiter_default_index= "git"
kibiter_url = http://localhost:5601

[phases]
collection = true
identities = true
enrichment = true
panels = true

[askbot]
collect = false
raw_index = askbot_test-raw
enriched_index = askbot_test

[bugzilla]
raw_index = bugzilla_test-raw
enriched_index = bugzilla-test

[bugzillarest]
raw_index = bugzillarest_test-raw
enriched_index = bugzillarest_test

[confluence]
raw_index = confluence_test-raw
enriched_index = confluence_test

[discourse]
raw_index = discourse_test-raw
enriched_index = discourse_test

[dockerhub]
raw_index = dockerhub_test-raw
enriched_index = dockerhub_test

[functest]
collect=False
raw_index = functest_test-raw
enriched_index = functest_test

[gerrit]
raw_index = gerrit_test-raw
enriched_index = gerrit_test
user = acs

[git]
raw_index = git_test-raw
enriched_index = git_test
studies = [bad_study]

[enrich_demography:1]
date_field = grimoire_creation_date
author_field = author_uuid

[enrich_areas_of_code]
in_index = git_test-raw
out_index = git_test-aoc

[enrich_onion]
in_index = git_test
out_index = git_test-onion
contribs_field = hash
no_incremental = true

[github]
raw_index = github_test-raw
enriched_index = github_test
api-token = XXXXX
sleep-for-rate = true
archive-path = /tmp/test_github_archive
category = issue
sleep-time = 300

[github:pull]
raw_index = github_test-raw-pull
enriched_index = github_test-pull
api-token = XXXXX
sleep-for-rate = true
archive-path = /tmp/test_github_archive
category = pull_request
sleep-time = 300

[gitlab]
raw_index = test_gitlab-raw
enriched_index = test_gitlab
api-token = xxxx
no-archive = true

[google_hits]
raw_index = google_hits_test-raw
enriched_index =google_hits_test

[hyperkitty]
raw_index = hyperkitty_test-raw
enriched_index = hyperkitty_test
from-date = 2017-01-01

[jenkins]
raw_index = jenkins_test-raw
enriched_index = jenkins_test

[jira]
raw_index = jira_test-raw
enriched_index = jira_test
project = PUP

[mattermost]
raw_index = mattermost_test
enriched_index = mattermost_test_enriched
api-token = xxx

[mattermost:group1]
raw_index = mattermost_test_group1
enriched_index = mattermost_test_enriched_group1
api-token = xxx

[mattermost:group2]
raw_index = mattermost_test_group2
enriched_index = mattermost_test_enriched_group2
api-token = zzz

[mbox]
raw_index = mbox_test-raw
enriched_index = mbox_test

[kafka_kip]
no_incremental = true

[mediawiki]
raw_index = mediawiki_test-raw
enriched_index = mediawiki_test

[meetup]
raw_index = meetup_test-raw
enriched_index = meetup_test
api-token = XXXXX

[mozillaclub]
raw_index = mozillaclub_test-raw
enriched_index = mozillaclub_test

[nntp]
raw_index = nntp_grimoire_test-raw
enriched_index = nntp_grimoire_test

[phabricator]
raw_index = phabricator_test-raw
enriched_index = phabricator_test
api-token = XXXXX

[pipermail]
raw_index = pipermail_test-raw
enriched_index = pipermail_test

[puppetforge]
raw_index = puppetforge_test-raw
enriched_index = puppetforge_test

[redmine]
raw_index = redmine_test-raw
enriched_index = redmine_test
api-token = XXXXX

[remo]
raw_index = remo_test-raw
enriched_index = remo_test

[remo:activities]
# Perceval archive already used in [remo]
collect = false
raw_index = remo_activities_test-raw
enriched_index = remo_activities_test
no-archive = true

[rss]
raw_index = rss_test-raw
enriched_index = rss_test

[stackexchange]
es_collection_url = http://127.0.0.1:9200
raw_index = stackexchange_test-raw
enriched_index = stackexchange_test
api-token = XXXXX

[slack]
raw_index = slack_test-raw
enriched_index = slack_test
api-token = XXXXX

[supybot]
raw_index = supybot_test-raw
enriched_index = supybot_test
from-date = 2000-12-09

[telegram]
raw_index = telegram_test-raw
enriched_index = telegram_test
api-token = XXXXX

[twitter]
collect = false
raw_index = twitter_test-raw
enriched_index = twitter_test
api-token = XXXX
Loading