#!/usr/bin/python

import os
import shutil

def issue(s, p, m):
        return "<issue><severity>" +s+ "</severity><path>" +p+ "</path><message>" +m+ "</message></issue>"

if os.getenv("_SETUP") is None:
  print("ERROR: _SETUP environment variable is not set. This script should be called from ITRS Geneos Gateway Hooks.")
else:
  source = os.getenv("_SETUP")
  destination = '/tmp/gwhooks'
  try:
    os.mkdir(destination)
  except OSError:
    pass
  shutil.copy(source, destination)
  print "<validation><issues>"
  print issue("None", "/gateway", "The gateway XML merged with include files have been copied from " + source + " to " + destination)
  print "</issues></validation>"
