Commit e65002dd authored by Anastasia Galkin's avatar Anastasia Galkin
Browse files

gardening

parent 062d3e88
#!/usr/bin/python
import sys
import time
import MySQLdb
from settings import *
log_name = '' + time.strftime("%Y%m%d_%H%M%S") + '_wordpress_stats.log'
file = open(log_name, "w")
logfile = open(log_name, "w")
# Open database connection
for i, wp in WORDPRESS_DATABASES.items():
file.write("Wordpress: '{0}' ".format(i) + '\n')
logfile.write("Wordpress: '{0}' ".format(i) + '\n')
nonews = True
db = MySQLdb.connect(wp['HOST'], wp['USER'], wp['PASSWORD'], wp['DATABASE'])
......@@ -26,18 +25,18 @@ for i, wp in WORDPRESS_DATABASES.items():
if int(count[0]) > 0:
nonews = False
file.write("{0} new {1}\n".format(''.join(map(str, count)), j))
file.write(stats['header'] + "\n")
logfile.write("{0} new {1}\n".format(''.join(map(str, count)), j))
logfile.write(stats['header'] + "\n")
cursor.execute(stats['query'])
for row in cursor:
file.write(' | '.join(map(str, row)) + '\n')
logfile.write(' | '.join(map(str, row)) + '\n')
if nonews:
file.write(' Nothing new here.')
logfile.write(' Nothing new here.')
file.write(' \n')
logfile.write(' \n')
db.close()
file.close()
logfile.close()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment