示例#1
0
 def test_dateToTimeString(self):
     self.assertEqual(
         util.dateToTimeString(util.stringToTime("01.02.2017 02:00:00")),
         "2017-02-01T02:00:00+01:00")
     self.assertEqual(
         util.dateToTimeString(util.stringToTime("26.03.2017 02:00:00")),
         "2017-03-26T02:00:00+01:00")
     self.assertEqual(
         util.dateToTimeString(util.stringToTime("26.03.2017 03:00:00")),
         "2017-03-26T03:00:00+02:00")
示例#2
0
    def sendEmail(self, component, body):
        emailConfig = IntegrationConfig.getEmailConfig()
        if emailConfig is None:
            return
        if not self.canSendEmail(component):
            return
        msg = MIMEText(body + "\ntime:" +
                       util.dateToTimeString(AppConfig.getCurrentTime()) +
                       "\ncomponent:" + component)

        msg['Subject'] = 'Mediation monitoring: ' + component
        msg['From'] = emailConfig["from"]
        msg['To'] = emailConfig["to"]

        s = smtplib.SMTP(emailConfig["smtpHostname"])
        s.login(emailConfig["login"], emailConfig["password"])
        s.send_message(msg)
        self.lastComponentEmailTime[component] = AppConfig.getCurrentTime()
        s.quit()
fromDate = util.stringToTime("02.03.2017 00:00:00")
toDate = util.stringToTime("03.03.2017 00:00:00")
granularity = 15
q = DateRangeGroupQuery(
    fromDate, toDate,
    [MediationConfig.getLobWithCountry("CZ", "GSM")["flows"]["MSSBRN1A"]],
    granularity)
# q = DateRangeGroupQuery(fromDate, toDate, [MediationConfig.getLobWithCountry("CZ","ACI")["flows"]["GSM"]], granularity)
lob1Data = util.dateDataListToList(q.execute(), "MSSBRN1A")
lob1Data.append(0)
lob1Data.append(0)
lob1Data.append(0)
lob1Data.append(0)
dates = list(
    map(
        lambda x: util.dateToTimeString(x).split("+")[0].split("T")[1].split(
            ":")[0], util.dateDataListToList(q.execute(), "_id")))
dataTicks = []
dataTickPos = []
for i in range(0, len(dates)):
    if i % 4 == 0:
        dataTicks.append(dates[i])
        dataTickPos.append(i)

# lob1Data=[100,0,0,100,0,0,100,0,0,100,0,0,100,0,0,100,0,0,100,0,0,100,0,0]
plt.figure(figsize=(12, 6))
plt.plot(lob1Data, linewidth=0.3, color="#ff009f", label="actual data")

# Running mean lines
# plt.plot(cumulativeRunningMedian(lob1Data, 9), label='Cumulative median (9)', color="red")
# plt.plot(cumulativeRunningMedian(lob1Data, 7), label='Cumulative median (7)', color="green")
# plt.plot(cumulativeRunningMedian(lob1Data, 3), label='Cumulative median (3)', color="blue")
示例#4
0
def currentTime():
    return jsonify(
        {"currentTime": util.dateToTimeString(AppConfig.getCurrentTime())})