-
Notifications
You must be signed in to change notification settings - Fork 40
/
rebuild_docs.py
51 lines (36 loc) · 1.41 KB
/
rebuild_docs.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
#!/usr/bin/env python3
###-------------------------------------------------------------------
### This file is part of the CernVM File System.
###-------------------------------------------------------------------
from optparse import OptionParser
import requests
def do_trigger(token, branches, verbose):
data = {'token' : token,
'branches' : branches}
headers = {'Content-type' : 'application/json'}
url = 'https://readthedocs.org/api/v2/webhook/cvmfs/27468/'
reply = requests.post(url, json = data, headers = headers)
if verbose:
print('Reply: status: {}, json: {}'.format(reply.status_code, reply.json()))
else:
print(reply.json())
def main():
usage = "{}\n\n{}".format("Usage: %prog [options] TOKEN [BRANCHES]",
"Ex: %prog <API_TOKEN> stable master")
parser = OptionParser(usage)
parser.add_option("-v", "--verbose", dest="verbose", action="store_true",
help="verbose output")
(options, args) = parser.parse_args()
if len(args) < 1 :
parser.error("incorrect number of arguments")
token = args[0]
branches = ["latest"]
if len(args) > 1 :
branches = args[1:]
if options.verbose:
print("Token: {}".format(token))
print("Branches: {}".format(branches))
print()
do_trigger(token, branches, options.verbose)
if __name__ == '__main__':
main()