Skip to content

Commit

Permalink
Fixes MeeGoIntegration#58 Added reading of conf files if exists
Browse files Browse the repository at this point in the history
  • Loading branch information
inhumanitas committed May 8, 2018
1 parent 937c944 commit 5bbf0e0
Showing 1 changed file with 31 additions and 2 deletions.
33 changes: 31 additions & 2 deletions src/webhook_launcher/app/boss.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,34 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

import json
import os

from django.conf import settings
from RuoteAMQP import Launcher


def get_process_params(pdef_file_path):
"""Read process configuration variables if exists
:param pdef_file_path: process file path,
config file should be with the same name and with '.conf' extension
:return Loaded variables or None if couldn't read the conf file
"""
params = None
if os.path.exists(pdef_file_path):
file_name, _file_ext = os.path.splitext(pdef_file_path)
conf_file_path = file_name + '.conf'
try:
params = json.load(open(conf_file_path))
except OSError:
pass

except ValueError as e:
print 'Error while loading json %s:\n%s' % (conf_file_path, str(e))

return params


def launch(process, fields):
""" BOSS process launcher
Expand All @@ -33,8 +58,12 @@ def launch(process, fields):
amqp_pass = settings.BOSS_PASS,
amqp_vhost = settings.BOSS_VHOST)

print "launching to (%s,%s)" %(settings.BOSS_HOST, settings.BOSS_VHOST)
launcher.launch(pdef, fields)
fields_dict = get_process_params(process) or {}
fields_dict.update(fields)

print "launching to (%s,%s)" % (settings.BOSS_HOST, settings.BOSS_VHOST)
launcher.launch(pdef, fields_dict)


def launch_queue(fields):
launch(settings.VCSCOMMIT_QUEUE, fields)
Expand Down

0 comments on commit 5bbf0e0

Please sign in to comment.