Ejemplo n.º 1
0
    def checkRestart(self):

        step = int(self.initFile.get("Model", "step"))
        dt = int(self.initFile.get("Model", "dtOut"))
        step = step * dt
        ft = int(self.initFile.get("Model", "FrcTime"))
        outRoot = self.initFile.get("Model", "outRoot")
        runName = self.initFile.get("Model", "runName")

        nDate = self.cDate - datetime.timedelta(seconds=step)
        lDate = self.cDate - datetime.timedelta(seconds=dt * ft)
        date = nDate
        nT = step / dt

        return nDate, nT

        while date < nDate:
            path = os.path.join(
                outRoot, runName, "/NRT/%04d/%02d/%02d/%02/matsiro/main/RSTA" %
                (date.year, date.month, date.day, date.hour))
            print path
            if os.path.exists(path):
                return date, nT
            else:
                step = step + step
                date = date - datetime.timedelta(seconds=step)
                continue
        if self.slackNotify == True:
            user = "******"
            text = "Fatal: Cannot find restart file to reboot the system. \nDate:%s" % (
                self.cDate.strftime("%Y/%m/%d %H:%M"))
            slack.failed(user, text)
        sys.exit(1)
Ejemplo n.º 2
0
    def sendError(self, code, err):

        if self.initFile.getboolean("System", "slackNotify") == True:
            user = "******"
            text = "Error @ %s\n%s" % (code, err)
            slack.failed(user, text)
        else:
            text = "Error @ %s" % code
            sys.stderr.write(text)

        return 0
Ejemplo n.º 3
0
    def main(self):

        try:
            self.nrt(self.pDate.year,self.pDate.month,self.pDate.day,self.pDate.hour,self.nT)
            self.forecast(self.cDate.year,self.cDate.month,self.cDate.day,self.cDate.hour)
        except Exception as e:
            err = "%s\n%s" % (str(type(e)),e.message)
            if self.slackNotify == True:
                user = "******"
                text = "Error @ ForcingController\n%s" % (err)
                slack.failed(user,text)
            sys.exit(1)