-
Notifications
You must be signed in to change notification settings - Fork 0
/
bit.py
70 lines (53 loc) · 2.19 KB
/
bit.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
from flask import Flask, render_template, request
from pymongo import Connection
import pulls, builds, githubAPI, configuration
app = Flask(__name__)
connection = Connection()
monDB = connection['bitcointesting']
owner = configuration.github_owner
repo = configuration.github_repo
bot_user = configuration.bot_user
@app.route("/", methods=['GET', 'POST'])
def home():
pulls = monDB['pulls'].find({'status':'active'})
#we have to add the nightly builds of the master branch, and have that as the first selectable option
return render_template('home.html', pulls)
@app.route("download", methods=['POST'])
def download():
binary = request.form['binary']
return render_template('download.html', binary)
#Grab all the comments on open pull requests, and filter out those made by the bot
def get_bot_comments():
pull_nums=githubAPI.get_pull_nums(owner,repo)
bot_comments = []
for pull in pull_nums:
bot_comments.append(githubAPI.get_user_comments(owner,repo,pull,bot_user))
return bot_comments
#Grab all the binaries from the bots comments and enforce 1:pull
def get_binaries():
comments = get_bot_comments()
binaries = []
return binaries
#save all the shit in the db
def updateDB():
#Grab the PB
try:
p = githubAPI.get_pulls('bitcoin','bitcoin')
b = builds.grabBuilds()
print "Pulls updated: " + p + " Builds updated: " + b
except Exception as e:
print "Could not update the DB with new pulls / builds: ", e
#Add the Jelly
try:
pulls = monDB['pulls'].find({'status':'active'})
for pull in pulls:
build = monDB['builds'].find_one({'pullnum':pull['pullnum'], 'status':'active'})
monDB['pulls'].update({'pullnum':pull['pullnum']}, {'$set':{'binary':build['url']}})
except Exception as e:
print "We ran out of bread: ", e
if __name__ == "__main__":
app.run()
#get all the open pull requests from github bitcoin/bitcoin that can be automatically merged.
#store them in the db. Name, author, date
#grab the build's file urls from matt's jenkins
#store them in the db. _id, url, system (win32, win64, ubuntu, etc.)