Exemplo n.º 1
0
    def save(self):
        """
        _save_

        Pack the data object into an IMProvNode

        """
        output = None
        try:
            try:
                config = os.environ.get("PRODAGENT_CONFIG", None)
                if config == None:
                    msg = "No ProdAgent Config file provided\n"
                    raise RuntimeError, msg

                cfgObject = ProdAgentConfiguration()
                cfgObject.loadFromFile(config)
                alertHandlerConfig = cfgObject.get("AlertHandler")
                workingDir = alertHandlerConfig['ComponentDir']

                dir = os.path.join(os.path.expandvars(workingDir), 'Alerts')

                if not os.path.exists(dir):
                    os.makedirs(dir)
                self.FileName = os.path.join(dir, "alert-%s.dat" % makeUUID())
                output = open(self.FileName, 'wb')
                pickle.dump(self, output)
            except Exception, ex:
                # to do: Exception handling
                print ex
                raise RuntimeError, str(ex)
        finally:
            if output:
                output.close()
        return