-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy path__init__.py
More file actions
181 lines (157 loc) · 4.33 KB
/
Copy path__init__.py
File metadata and controls
181 lines (157 loc) · 4.33 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
"""
Meeseeksbox main app module
"""
import os
import base64
import signal
org_whitelist = [
"MeeseeksBox",
"Jupyter",
"IPython",
"JupyterLab",
"Carreau",
"matplotlib",
"scikit-learn",
"pandas-dev",
"scikit-image",
]
usr_blacklist = []
usr_whitelist = [
"Carreau",
"gnestor",
"ivanov",
"fperez",
"mpacer",
"minrk",
"takluyver",
"sylvaincorlay",
"ellisonbg",
"blink1073",
"damianavila",
"jdfreder",
"rgbkrk",
"tacaswell",
"willingc",
"jhamrick",
"lgpage",
"jasongrout",
"ian-r-rose",
# matplotlib people
"tacaswell",
"QuLogic",
"anntzer",
"NelleV",
"dstansby",
"efiring",
"choldgraf",
"dstansby",
"dopplershift",
"jklymak",
"weathergod",
"timhoffm",
# pandas-dev
"jreback",
"jorisvandenbossche",
"gfyoung",
"TomAugspurger",
]
# https://github.com/integrations/meeseeksdev/installations/new
# already ? https://github.com/organizations/MeeseeksBox/settings/installations/4268
# https://github.com/integration/meeseeksdev
def load_config_from_env():
"""
Load the configuration, for now stored in the environment
"""
config = {}
integration_id = os.environ.get("GITHUB_INTEGRATION_ID")
botname = os.environ.get("GITHUB_BOT_NAME", None)
if not integration_id:
raise ValueError("Please set GITHUB_INTEGRATION_ID")
if not botname:
raise ValueError("Need to set a botname")
if "@" in botname:
print("Don't include @ in the botname !")
botname = botname.replace("@", "")
at_botname = "@" + botname
integration_id = int(integration_id)
config["key"] = base64.b64decode(bytes(os.environ.get("B64KEY"), "ASCII"))
config["botname"] = botname
config["at_botname"] = at_botname
config["integration_id"] = integration_id
config["webhook_secret"] = os.environ.get("WEBHOOK_SECRET")
config["port"] = int(os.environ.get("PORT", 5000))
# config option to forward requests as-is to a test server.
config["forward_staging_url"] = os.environ.get("FORWARD_STAGING_URL", "")
print("saw config forward", config["forward_staging_url"])
# Despite their names, this are not __your__ account, but an account created
# for some functionalities of mr-meeseeks. Indeed, github does not allow
# cross repositories pull-requests with Applications, so I use a personal
# account just for that.
config["personnal_account_name"] = os.environ.get("PERSONAL_ACCOUNT_NAME")
config["personnal_account_token"] = os.environ.get("PERSONAL_ACCOUNT_TOKEN")
return Config(**config).validate()
from .meeseeksbox.core import MeeseeksBox
from .meeseeksbox.core import Config
from .meeseeksbox.commands import (
replyuser,
zen,
tag,
untag,
blackify,
black_suggest,
quote,
say,
debug,
party,
safe_backport,
)
from .commands import (
close,
open as _open,
migrate_issue_request,
ready,
merge,
help_make,
)
green = "\x1b[0;32m"
yellow = "\x1b[0;33m"
blue = "\x1b[0;34m"
red = "\x1b[0;31m"
normal = "\x1b[0m"
def main():
print(blue + "====== (re) starting ======" + normal)
config = load_config_from_env()
app_v = os.environ.get("HEROKU_RELEASE_VERSION", None)
if app_v:
import keen
keen.add_event("deploy", {"version": int(app_v[1:])})
config.org_whitelist = org_whitelist + [o.lower() for o in org_whitelist]
config.user_whitelist = usr_whitelist + [u.lower() for u in usr_whitelist]
config.user_blacklist = usr_blacklist + [u.lower() for u in usr_blacklist]
commands = {
"hello": replyuser,
"zen": zen,
"backport": safe_backport,
"safe_backport": safe_backport,
"migrate": migrate_issue_request,
"tag": tag,
"untag": untag,
"open": _open,
"close": close,
"autopep8": blackify,
"reformat": blackify,
"black": blackify,
"suggestions": black_suggest,
"ready": ready,
"merge": merge,
"say": say,
"debug": debug,
"party": party,
}
commands["help"] = help_make(commands)
box = MeeseeksBox(commands=commands, config=config)
signal.signal(signal.SIGTERM, box.sig_handler)
signal.signal(signal.SIGINT, box.sig_handler)
box.start()
if __name__ == "__main__":
main()