-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.py
74 lines (62 loc) · 1.55 KB
/
run.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
from slacker import Slacker
from slackbot.bot import Bot
from tododb import DB
from plugins.notice import Notice
import os
import threading
import datetime
import time
import sys
# 高速起動のためにnumpy,numbaをここで読み込む
import numpy
import numba
# 素数表の作成
k = 10000
pn = 0
primelist = list(range(int(k)))
del primelist[0]
del primelist[0]
p = 2
while p*p <= k:
for i in range(2, -(-k//p)):
if not primelist.count(int(i*p)) == 0:
tag = primelist.index(int(i*p))
del primelist[tag]
pn = pn + 1
p = primelist[pn]
def noticeThread():
time.sleep(10)
while True:
nt = Notice()
del nt
# デバックを容易にするため、待機は30秒のみ
time.sleep(30)
def botThread():
mybot = Bot()
mybot.run()
def stop():
try:
while True:
pass
except KeyboardInterrupt:
print('プログラムを終了します...')
sys.exit()
if __name__ == '__main__':
slack = Slacker(os.environ['API_TOKEN'])
channel = os.environ['SLACK_CHANNEL']
slack.chat.post_message(
channel, 'new version bot is deployed.', as_user=True)
dbname = os.environ['TODO_DB']
need_init = not os.path.exists(dbname)
database = DB(dbname)
if need_init:
database.init()
# 列追加、減少を自動反映
database.clean()
n_t = threading.Thread(target=noticeThread)
b_t = threading.Thread(target=botThread)
n_t.setDaemon(True)
b_t.setDaemon(True)
n_t.start()
b_t.start()
stop()