[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [gettor/develop] Update report.py to use last month in report
commit eb03a4d194097ea61ac5faa5887f37e818d04453
Author: Sukhbir Singh <sukhbir@xxxxxxxxxxxxxx>
Date: Fri Jan 15 13:13:26 2016 -0500
Update report.py to use last month in report
---
report.py | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/report.py b/report.py
index b75d7c8..23821e3 100644
--- a/report.py
+++ b/report.py
@@ -16,7 +16,7 @@
import os
import sys
import ConfigParser
-from datetime import datetime as dt
+import datetime as dt
import sqlite3
@@ -109,12 +109,17 @@ DESC""".format(each))
if not each[0] == "none"])
self.requests.append(result)
+ # Get the last month since we run the script on the first day of every
+ # month and generate the report for the previous.
+ first_day_current = dt.datetime.today().replace(day=1)
+ last_month = first_day_current - dt.timedelta(days=1)
+
with open(OUTPUT, "a") as f:
- f.write(REPORT.format(dt.now().strftime("%B %Y"),
+ f.write(REPORT.format(last_month.strftime("%B %Y"),
self.requests[0][0],
- dt.now().strftime("%B"),
+ last_month.strftime("%B"),
self.requests[1][1],
- dt.strptime(self.requests[1][0], "%Y-%m-%d")
+ dt.datetime.strptime(self.requests[1][0], "%Y-%m-%d")
.strftime("%B %-d"),
*self.requests[2:]))
self.conn.close()
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits