-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathquarter-hourly.py
executable file
·56 lines (46 loc) · 1.68 KB
/
quarter-hourly.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/python
# -*- coding: utf-8 -*-
import datetime
import time
import MySQLdb
import os, sys
#print('I exit from quarter hourly!!!')
#sys.exit()
import sys
sys.path.append( '/home/hroest/')
sys.path.append( '/home/hroest/scripts/')
sys.path.append( '/data/project/hroest/meta' )
sys.path.append( '/data/project/hroest/bot/pywikibot-compat/' )
import create_flagged_data
import replag_lib
import general_lib
import flagged_lib
today = datetime.date.today()
now = datetime.datetime.now()
this_year = today.year
this_month = today.month
db = MySQLdb.connect(read_default_file=general_lib.mysql_config_file, host=general_lib.mysql_host)
###########################################################################
logfile = open('%s/logs/quarter-hourly.log' % general_lib.root, 'a')
logfile.write( '\nrun started:\n')
logfile.write( '\tstart time %s\n' % now)
## 1. Calculate current replication lag
replag_lib.insert_db(db, logfile)
logfile.write( '\tinserted row into db\n' )
## 2. Delete old picture and release older lock
os.system( 'touch %s/public_html/tmp/pics/tmp_mytmptmp' % general_lib.root)
os.system( 'rm %s/public_html/tmp/pics/tmp*' % general_lib.root)
logfile.write( '\tdeleted all pics like tmp/pics/tmp*\n' )
#get rid of a lock that is older than an hour
general_lib.release_pywiki_lock_if_older_than(3600)
## 3. Compute lagging users
flagged_lib.create_lagging_user(db)
now = datetime.datetime.now()
logfile.write( '\tcreated lagging user table %s\n' % now )
now = datetime.datetime.now()
flagged_lib.create_never_reviewed(db)
logfile.write( '\tcreated unflagged pages table %s\n' % now )
## 4. Done
now = datetime.datetime.now()
logfile.write( '\tend time %s\n' % now)
logfile.close()