|
1 | 1 | # -*- coding: utf-8 -*- |
2 | 2 | # |
3 | | -# Copyright (C) 2014, 2015 Carlos Jenkins <carlos@jenkins.co.cr> |
| 3 | +# Copyright (C) 2014, 2015, 2016 Carlos Jenkins <carlos@jenkins.co.cr> |
4 | 4 | # |
5 | 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
6 | 6 | # you may not use this file except in compliance with the License. |
|
24 | 24 | from json import loads, dumps |
25 | 25 | from subprocess import Popen, PIPE |
26 | 26 | from tempfile import mkstemp |
27 | | -from os import access, X_OK, remove |
| 27 | +from os import access, X_OK, remove, fdopen |
28 | 28 | from os.path import isfile, abspath, normpath, dirname, join, basename |
29 | 29 |
|
30 | 30 | import requests |
@@ -72,7 +72,7 @@ def index(): |
72 | 72 | header_signature = request.headers.get('X-Hub-Signature') |
73 | 73 | if header_signature is None: |
74 | 74 | abort(403) |
75 | | - |
| 75 | + |
76 | 76 | sha_name, signature = header_signature.split('=') |
77 | 77 | if sha_name != 'sha1': |
78 | 78 | abort(501) |
@@ -154,8 +154,8 @@ def index(): |
154 | 154 | return '' |
155 | 155 |
|
156 | 156 | # Save payload to temporal file |
157 | | - _, tmpfile = mkstemp() |
158 | | - with open(tmpfile, 'w') as pf: |
| 157 | + osfd, tmpfile = mkstemp() |
| 158 | + with fdopen(osfd, 'w') as pf: |
159 | 159 | pf.write(dumps(payload)) |
160 | 160 |
|
161 | 161 | # Run scripts |
|
0 commit comments