-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathrw_auto_pvp.py
executable file
·51 lines (45 loc) · 1.59 KB
/
rw_auto_pvp.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
#!/usr/bin/env python
import argparse
from datetime import datetime
from pytz import timezone
from libs import config
from libs import db
from libs import cache
from libs import log
from rainwave.events import pvpelection
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Rainwave PVP Hour generation script.")
parser.add_argument("--config", default=None)
args = parser.parse_args()
config.load(args.config)
log_file = "%s/rw_auto_pvp.log" % (config.get_directory("log_dir"),)
log.init(log_file, config.get("log_level"))
db.connect()
cache.connect()
dow_map = [(4, 5), (2, 1), (3, 4), (5, 2), (1, 3), (2, 4), (1, 3)]
# dow_map = [ (1, 1), (1, 1), (1, 1), (1, 1), (1, 1), (1, 1), (1, 1) ]
timezones = [(timezone("Europe/London"), 13, 0), (timezone("US/Eastern"), 13, 1)]
for tz in timezones:
start = datetime.now(tz[0]).replace(
hour=tz[1], minute=0, second=0, microsecond=0
)
sid = dow_map[start.weekday()][tz[2]]
start_e = (
start - datetime.fromtimestamp(0, timezone("US/Eastern"))
).total_seconds()
log.debug(
"auto_pvp",
"%04d/%02d/%02d %02d:%02d PVP %s %s"
% (
start.year,
start.month,
start.day,
start.hour,
start.minute,
config.station_id_friendly[sid],
tz[0].__class__.__name__,
),
)
pvpelection.PVPElectionProducer.create(
sid, start_e, start_e + 3600, name="PvP Hour"
)