#!/usr/bin/env python
###############################################################################
# (c) Copyright 2016 CERN                                                     #
#                                                                             #
# This software is distributed under the terms of the GNU General Public      #
# Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING".   #
#                                                                             #
# In applying this licence, CERN does not waive the privileges and immunities #
# granted to it by virtue of its status as an Intergovernmental Organization  #
# or submit itself to any jurisdiction.                                       #
###############################################################################
'''
Send the message that a build for a project has been done

'''
__author__ = 'Ben Couturier <ben.couturier@cern.ch>'

import sys
import LbMsg.BuildMsg
from LbNightlyTools.Scripts.Common import PlainScript


class Script(PlainScript):
    '''
    Sends the message that a build has been done
    '''
    __usage__ = '%prog <slot> <project> <config> <buildId>'
    __version__ = ''


    def main(self):
        '''
        Main function of the script.
        '''
        # Checking the arguments
        if len(self.args) != 4:
            self.log.error('Please specify <slot> <project> <config> <buildId>')
            exit(1)

        slot = self.args[0]
        project = self.args[1]
        config = self.args[2]
        buildId = self.args[3]

        msg = LbMsg.BuildMsg.NightliesMessenger()
        msg.sendBuildDone(slot, project, config, buildId)


if __name__ == "__main__":
    sys.exit(Script().run())
