##// END OF EJS Templates
cleanup ununsed tools...
Matthias Bussonnier -
Show More
1 NO CONTENT: modified file chmod 100755 => 100644
NO CONTENT: modified file chmod 100755 => 100644
@@ -5,14 +5,12 b' try:'
5 except NameError:
5 except NameError:
6 pass
6 pass
7
7
8 import os
9 import re
8 import re
10 import sys
9 import sys
11
10
12 import requests
11 import requests
13 import getpass
12 import getpass
14 import json
13 import json
15 from pathlib import Path
16
14
17 try:
15 try:
18 import requests_cache
16 import requests_cache
@@ -82,28 +80,6 b' def get_auth_token():'
82 def make_auth_header():
80 def make_auth_header():
83 return {'Authorization': 'token ' + get_auth_token()}
81 return {'Authorization': 'token ' + get_auth_token()}
84
82
85 def post_issue_comment(project, num, body):
86 url = 'https://api.github.com/repos/{project}/issues/{num}/comments'.format(project=project, num=num)
87 payload = json.dumps({'body': body})
88 requests.post(url, data=payload, headers=make_auth_header())
89
90 def post_gist(content, description='', filename='file', auth=False):
91 """Post some text to a Gist, and return the URL."""
92 post_data = json.dumps({
93 "description": description,
94 "public": True,
95 "files": {
96 filename: {
97 "content": content
98 }
99 }
100 }).encode('utf-8')
101
102 headers = make_auth_header() if auth else {}
103 response = requests.post("https://api.github.com/gists", data=post_data, headers=headers)
104 response.raise_for_status()
105 response_data = json.loads(response.text)
106 return response_data['html_url']
107
83
108 def get_pull_request(project, num, auth=False):
84 def get_pull_request(project, num, auth=False):
109 """get pull request info by number
85 """get pull request info by number
@@ -118,15 +94,6 b' def get_pull_request(project, num, auth=False):'
118 response.raise_for_status()
94 response.raise_for_status()
119 return json.loads(response.text, object_hook=Obj)
95 return json.loads(response.text, object_hook=Obj)
120
96
121 def get_pull_request_files(project, num, auth=False):
122 """get list of files in a pull request"""
123 url = "https://api.github.com/repos/{project}/pulls/{num}/files".format(project=project, num=num)
124 if auth:
125 header = make_auth_header()
126 else:
127 header = None
128 return get_paged_request(url, headers=header)
129
130 element_pat = re.compile(r'<(.+?)>')
97 element_pat = re.compile(r'<(.+?)>')
131 rel_pat = re.compile(r'rel=[\'"](\w+)[\'"]')
98 rel_pat = re.compile(r'rel=[\'"](\w+)[\'"]')
132
99
@@ -149,17 +116,6 b' def get_paged_request(url, headers=None, **params):'
149 break
116 break
150 return results
117 return results
151
118
152 def get_pulls_list(project, auth=False, **params):
153 """get pull request list"""
154 params.setdefault("state", "closed")
155 url = "https://api.github.com/repos/{project}/pulls".format(project=project)
156 if auth:
157 headers = make_auth_header()
158 else:
159 headers = None
160 pages = get_paged_request(url, headers=headers, **params)
161 return pages
162
163 def get_issues_list(project, auth=False, **params):
119 def get_issues_list(project, auth=False, **params):
164 """get issues list"""
120 """get issues list"""
165 params.setdefault("state", "closed")
121 params.setdefault("state", "closed")
@@ -205,100 +161,3 b' def get_authors(pr):'
205 authors.append("%s <%s>" % (author['name'], author['email']))
161 authors.append("%s <%s>" % (author['name'], author['email']))
206 return authors
162 return authors
207
163
208 # encode_multipart_formdata is from urllib3.filepost
209 # The only change is to iter_fields, to enforce S3's required key ordering
210
211 def iter_fields(fields):
212 fields = fields.copy()
213 for key in ('key', 'acl', 'Filename', 'success_action_status', 'AWSAccessKeyId',
214 'Policy', 'Signature', 'Content-Type', 'file'):
215 yield (key, fields.pop(key))
216 for (k,v) in fields.items():
217 yield k,v
218
219 def encode_multipart_formdata(fields, boundary=None):
220 """
221 Encode a dictionary of ``fields`` using the multipart/form-data mime format.
222
223 :param fields:
224 Dictionary of fields or list of (key, value) field tuples. The key is
225 treated as the field name, and the value as the body of the form-data
226 bytes. If the value is a tuple of two elements, then the first element
227 is treated as the filename of the form-data section.
228
229 Field names and filenames must be unicode.
230
231 :param boundary:
232 If not specified, then a random boundary will be generated using
233 :func:`mimetools.choose_boundary`.
234 """
235 # copy requests imports in here:
236 from io import BytesIO
237 from requests.packages.urllib3.filepost import (
238 choose_boundary, six, writer, b, get_content_type
239 )
240 body = BytesIO()
241 if boundary is None:
242 boundary = choose_boundary()
243
244 for fieldname, value in iter_fields(fields):
245 body.write(b('--%s\r\n' % (boundary)))
246
247 if isinstance(value, tuple):
248 filename, data = value
249 writer(body).write('Content-Disposition: form-data; name="%s"; '
250 'filename="%s"\r\n' % (fieldname, filename))
251 body.write(b('Content-Type: %s\r\n\r\n' %
252 (get_content_type(filename))))
253 else:
254 data = value
255 writer(body).write('Content-Disposition: form-data; name="%s"\r\n'
256 % (fieldname))
257 body.write(b'Content-Type: text/plain\r\n\r\n')
258
259 if isinstance(data, int):
260 data = str(data) # Backwards compatibility
261 if isinstance(data, six.text_type):
262 writer(body).write(data)
263 else:
264 body.write(data)
265
266 body.write(b'\r\n')
267
268 body.write(b('--%s--\r\n' % (boundary)))
269
270 content_type = b('multipart/form-data; boundary=%s' % boundary)
271
272 return body.getvalue(), content_type
273
274
275 def post_download(project, filename, name=None, description=""):
276 """Upload a file to the GitHub downloads area"""
277 if name is None:
278 name = Path(filename).name
279 with open(filename, 'rb') as f:
280 filedata = f.read()
281
282 url = "https://api.github.com/repos/{project}/downloads".format(project=project)
283
284 payload = json.dumps(dict(name=name, size=len(filedata),
285 description=description))
286 response = requests.post(url, data=payload, headers=make_auth_header())
287 response.raise_for_status()
288 reply = json.loads(response.content)
289 s3_url = reply['s3_url']
290
291 fields = dict(
292 key=reply['path'],
293 acl=reply['acl'],
294 success_action_status=201,
295 Filename=reply['name'],
296 AWSAccessKeyId=reply['accesskeyid'],
297 Policy=reply['policy'],
298 Signature=reply['signature'],
299 file=(reply['name'], filedata),
300 )
301 fields['Content-Type'] = reply['mime_type']
302 data, content_type = encode_multipart_formdata(fields)
303 s3r = requests.post(s3_url, data=data, headers={'Content-Type': content_type})
304 return s3r
@@ -10,7 +10,6 b' To generate a report for IPython 2.0, run:'
10 #-----------------------------------------------------------------------------
10 #-----------------------------------------------------------------------------
11
11
12
12
13 import codecs
14 import sys
13 import sys
15
14
16 from argparse import ArgumentParser
15 from argparse import ArgumentParser
1 NO CONTENT: modified file chmod 100755 => 100644
NO CONTENT: modified file chmod 100755 => 100644
@@ -12,7 +12,6 b' import sys'
12
12
13 from toollib import (get_ipdir, pjoin, cd, execfile, sh, archive,
13 from toollib import (get_ipdir, pjoin, cd, execfile, sh, archive,
14 archive_user, archive_dir)
14 archive_user, archive_dir)
15 from gh_api import post_download
16
15
17 # Get main ipython dir, this will raise if it doesn't pass some checks
16 # Get main ipython dir, this will raise if it doesn't pass some checks
18 ipdir = get_ipdir()
17 ipdir = get_ipdir()
@@ -53,12 +52,6 b" if 'upload' in sys.argv:"
53
52
54 # do not upload OS specific files like .DS_Store
53 # do not upload OS specific files like .DS_Store
55 to_upload = glob('*.whl')+glob('*.tar.gz')
54 to_upload = glob('*.whl')+glob('*.tar.gz')
56 for fname in to_upload:
57 # TODO: update to GitHub releases API
58 continue
59 print('uploading %s to GitHub' % fname)
60 desc = "IPython %s source distribution" % version
61 post_download("ipython/ipython", fname, description=desc)
62
55
63 # Make target dir if it doesn't exist
56 # Make target dir if it doesn't exist
64 print('1. Uploading IPython to archive.ipython.org')
57 print('1. Uploading IPython to archive.ipython.org')
1 NO CONTENT: modified file chmod 100755 => 100644
NO CONTENT: modified file chmod 100755 => 100644
1 NO CONTENT: file was removed
NO CONTENT: file was removed
1 NO CONTENT: file was removed
NO CONTENT: file was removed
1 NO CONTENT: file was removed
NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now