<html><body>
<p>6 new commits in yt:</p>
<p><a href="https://bitbucket.org/yt_analysis/yt/commits/c3614f50759e/">https://bitbucket.org/yt_analysis/yt/commits/c3614f50759e/</a> Changeset: c3614f50759e Branch: yt User: xarthisius Date: 2016-04-07 16:52:44+00:00 Summary: Add a ‘delete_image’ subcommand for a convenient image deletion from imagebin Affected #: 1 file</p>
<p>diff -r d5af145f1ac7993c2f94c2a4cc0d75824d019f98 -r c3614f50759e13a85d56d38aefe280e667b703aa yt/utilities/command_line.py --- a/yt/utilities/command_line.py +++ b/yt/utilities/command_line.py @@ -1061,6 +1061,37 @@</p>
<pre> print("updating to the newest changeset.")
print()
</pre>
<p>+class YTDeleteImageCmd(YTCommand): + args = (dict(short="delete_hash", type=str),) + description = \ + """ + Delete image from imgur.com. + + """ + name = “delete_image” + def __call__(self, args): + delete_hash = args.delete_hash + api_key = ‘e1977d9195fe39e’ + headers = {'Authorization': ‘Client-ID %s’ % api_key} + delete_url = '<a href="https://api.imgur.com/3/image/">https://api.imgur.com/3/image/</a>{delete_hash}' + req = urllib.request.Request( + delete_url.format(delete_hash=delete_hash), + headers=headers, method='DELETE') + try: + response = urllib.request.urlopen(req).read().decode() + except urllib.error.HTTPError as e: + print("ERROR", e) + return {'deleted': False} + + rv = json.loads(response) + if ‘success’ in rv and rv["success"]: + print("\nImage successfully deleted!\n") + else: + print() + print("Something has gone wrong! Here is the server response:") + print() + +</p>
<pre>class YTUploadImageCmd(YTCommand):
args = (dict(short="file", type=str),)
description = \</pre>
<p>@@ -1090,18 +1121,12 @@</p>
<pre>return {'uploaded':False}
rv = json.loads(response)
if 'data' in rv and 'link' in rv['data']:</pre>
<ul><li><p>delete_cmd = (</p></li>
<li><p>“curl -X DELETE -H 'Authorization: Client-ID {secret}'”</p></li>
<li><p>" <a href="https://api.imgur.com/3/image/">https://api.imgur.com/3/image/</a>{delete_hash}"</p></li>
<li><p>) print() print("Image successfully uploaded! You can find it at:") print(" %s" % (rv['data']['link'])) print() print("If you'd like to delete it, use the following")</p></li>
<li><p>print(" %s" %</p></li>
<li><p>delete_cmd.format(secret=api_key,</p></li>
<li><p>delete_hash=rv['data']['deletehash']))</p></li></ul>
<p>+ print(" yt delete_image %s" % rv['data']['deletehash'])</p>
<pre>print()
else:
print()</pre>
<p><a href="https://bitbucket.org/yt_analysis/yt/commits/eb46a94c88fe/">https://bitbucket.org/yt_analysis/yt/commits/eb46a94c88fe/</a> Changeset: eb46a94c88fe Branch: yt User: xarthisius Date: 2016-04-07 17:07:09+00:00 Summary: Move api_key and urls for image upload/delete to config. This will allow to switch to mediagoblin by editing defaults in the future Affected #: 2 files</p>
<p>diff -r c3614f50759e13a85d56d38aefe280e667b703aa -r eb46a94c88fec68657953471e4e5d936a76d153a yt/config.py --- a/yt/config.py +++ b/yt/config.py @@ -57,6 +57,9 @@</p>
<pre>local_standard_filename = 'local001',
answer_tests_url = 'http://answers.yt-project.org/{1}_{2}',
sketchfab_api_key = 'None',</pre>
<p>+ imagebin_api_key = ‘e1977d9195fe39e’, + imagebin_upload_url = '<a href="https://api.imgur.com/3/upload">https://api.imgur.com/3/upload</a>', + imagebin_delete_url = '<a href="https://api.imgur.com/3/image/">https://api.imgur.com/3/image/</a>{delete_hash}',</p>
<pre>thread_field_detection = 'False',
ignore_invalid_unit_operation_errors = 'False',
chunk_size = '1000',</pre>
<p>diff -r c3614f50759e13a85d56d38aefe280e667b703aa -r eb46a94c88fec68657953471e4e5d936a76d153a yt/utilities/command_line.py --- a/yt/utilities/command_line.py +++ b/yt/utilities/command_line.py @@ -1061,6 +1061,7 @@</p>
<pre> print("updating to the newest changeset.")
print()
</pre>
<p>+</p>
<pre>class YTDeleteImageCmd(YTCommand):
args = (dict(short="delete_hash", type=str),)
description = \</pre>
<p>@@ -1070,12 +1071,12 @@</p>
<pre> """
name = "delete_image"
def __call__(self, args):</pre>
<ul><li><p>delete_hash = args.delete_hash</p></li>
<li><p>api_key = ‘e1977d9195fe39e’</p></li>
<li><p>headers = {'Authorization': ‘Client-ID %s’ % api_key}</p></li>
<li><p>delete_url = '<a href="https://api.imgur.com/3/image/">https://api.imgur.com/3/image/</a>{delete_hash}'</p></li></ul>
<p>+ headers = {'Authorization': + 'Client-ID {}'.format(ytcfg.get("yt", “imagebin_api_key"))} + + delete_url = ytcfg.get("yt”, “imagebin_delete_url”)</p>
<pre>req = urllib.request.Request(</pre>
<ul><li><p>delete_url.format(delete_hash=delete_hash),</p></li></ul>
<p>+ delete_url.format(delete_hash=args.delete_hash),</p>
<pre>headers=headers, method='DELETE')
try:
response = urllib.request.urlopen(req).read().decode()</pre>
<p>@@ -1105,15 +1106,16 @@</p>
<pre> if not filename.endswith(".png"):
print("File must be a PNG file!")
return 1</pre>
<p>+ headers = {'Authorization': + 'Client-ID {}'.format(ytcfg.get("yt", "imagebin_api_key"))} +</p>
<pre>image_data = base64.b64encode(open(filename, 'rb').read())</pre>
<ul><li><p>api_key = ‘e1977d9195fe39e’</p></li>
<li><p>headers = {'Authorization': ‘Client-ID %s’ % api_key} parameters = {'image': image_data, type: ‘base64’,</p>
<pre>'name': filename,
'title': "%s uploaded by yt" % filename}</pre>
<p>data = urllib.parse.urlencode(parameters).encode('utf-8')</p></li>
<li><p>req = urllib.request.Request('<a href="https://api.imgur.com/3/upload">https://api.imgur.com/3/upload</a>', data=data,</p></li>
<li><p>headers=headers)</p></li></ul>
<p>+ req = urllib.request.Request( + ytcfg.get("yt", "imagebin_upload_url"), data=data, headers=headers)</p>
<pre> try:
response = urllib.request.urlopen(req).read().decode()
except urllib.error.HTTPError as e:</pre>
<p><a href="https://bitbucket.org/yt_analysis/yt/commits/ab7d9c5b177a/">https://bitbucket.org/yt_analysis/yt/commits/ab7d9c5b177a/</a> Changeset: ab7d9c5b177a Branch: yt User: xarthisius Date: 2016-04-07 19:09:38+00:00 Summary: Add server response Affected #: 1 file</p>
<p>diff -r eb46a94c88fec68657953471e4e5d936a76d153a -r ab7d9c5b177a14368284b69fddc13f7177f99b69 yt/utilities/command_line.py --- a/yt/utilities/command_line.py +++ b/yt/utilities/command_line.py @@ -1091,6 +1091,7 @@</p>
<pre>print()
print("Something has gone wrong! Here is the server response:")
print()</pre>
<p>+ pprint.pprint(rv)</p>
<pre>class YTUploadImageCmd(YTCommand):</pre>
<p><a href="https://bitbucket.org/yt_analysis/yt/commits/9988be109243/">https://bitbucket.org/yt_analysis/yt/commits/9988be109243/</a> Changeset: 9988be109243 Branch: yt User: xarthisius Date: 2016-04-07 19:24:01+00:00 Summary: update docs Affected #: 1 file</p>
<p>diff -r ab7d9c5b177a14368284b69fddc13f7177f99b69 -r 9988be109243a794185e23c699048766f7608d51 doc/source/reference/command-line.rst --- a/doc/source/reference/command-line.rst +++ b/doc/source/reference/command-line.rst @@ -80,6 +80,7 @@</p>
<pre>requested), for one or more datasets (default field is
Density)
update Update the yt installation to the most recent version</pre>
<p>+ delete_image Delete image from imgur.com.</p>
<pre> upload_image Upload an image to imgur.com. Must be PNG.
</pre>
<p>@@ -264,3 +265,9 @@</p>
<pre>uploads it anonymously to the website `imgur.com <http://imgur.com/>`_ and
provides you with a link to share with your collaborators. Note that the
image *must* be in the PNG format in order to use this function.</pre>
<p>+ +delete_image +++++++++++++ +The image uploaded using ``upload_image`` is assigned with a unique hash that +can be used to remove it. This subcommand provides an easy way to send a delete +request directly to the `imgur.com <<a href="http://imgur.com/">http://imgur.com/</a>>`_.</p>
<p><a href="https://bitbucket.org/yt_analysis/yt/commits/ac856c691d6e/">https://bitbucket.org/yt_analysis/yt/commits/ac856c691d6e/</a> Changeset: ac856c691d6e Branch: yt User: xarthisius Date: 2016-04-07 19:27:13+00:00 Summary: Fix sphinx syntax Affected #: 1 file</p>
<p>diff -r 9988be109243a794185e23c699048766f7608d51 -r ac856c691d6e47e589340e3421d1ba84e5bcd49c doc/source/reference/command-line.rst --- a/doc/source/reference/command-line.rst +++ b/doc/source/reference/command-line.rst @@ -268,6 +268,7 @@</p>
<pre>delete_image
++++++++++++</pre>
<p>+</p>
<pre>The image uploaded using ``upload_image`` is assigned with a unique hash that
can be used to remove it. This subcommand provides an easy way to send a delete
request directly to the `imgur.com <http://imgur.com/>`_.</pre>
<p><a href="https://bitbucket.org/yt_analysis/yt/commits/454b81690191/">https://bitbucket.org/yt_analysis/yt/commits/454b81690191/</a> Changeset: 454b81690191 Branch: yt User: ngoldbaum Date: 2016-04-20 18:13:09+00:00 Summary: Merged in xarthisius/yt (pull request #2119)</p>
<p>Enhance commandline image upload/delete Affected #: 3 files</p>
<p>diff -r 605942cb9f98aaa215ee0bd67b0293bdd2302598 -r 454b81690191c4ee1c28f0120f39bf9ee99840ed doc/source/reference/command-line.rst --- a/doc/source/reference/command-line.rst +++ b/doc/source/reference/command-line.rst @@ -80,6 +80,7 @@</p>
<pre>requested), for one or more datasets (default field is
Density)
update Update the yt installation to the most recent version</pre>
<p>+ delete_image Delete image from imgur.com.</p>
<pre> upload_image Upload an image to imgur.com. Must be PNG.
</pre>
<p>@@ -264,3 +265,10 @@</p>
<pre>uploads it anonymously to the website `imgur.com <http://imgur.com/>`_ and
provides you with a link to share with your collaborators. Note that the
image *must* be in the PNG format in order to use this function.</pre>
<p>+ +delete_image +++++++++++++ + +The image uploaded using ``upload_image`` is assigned with a unique hash that +can be used to remove it. This subcommand provides an easy way to send a delete +request directly to the `imgur.com <<a href="http://imgur.com/">http://imgur.com/</a>>`_.</p>
<p>diff -r 605942cb9f98aaa215ee0bd67b0293bdd2302598 -r 454b81690191c4ee1c28f0120f39bf9ee99840ed yt/config.py --- a/yt/config.py +++ b/yt/config.py @@ -57,6 +57,9 @@</p>
<pre>local_standard_filename = 'local001',
answer_tests_url = 'http://answers.yt-project.org/{1}_{2}',
sketchfab_api_key = 'None',</pre>
<p>+ imagebin_api_key = ‘e1977d9195fe39e’, + imagebin_upload_url = '<a href="https://api.imgur.com/3/upload">https://api.imgur.com/3/upload</a>', + imagebin_delete_url = '<a href="https://api.imgur.com/3/image/">https://api.imgur.com/3/image/</a>{delete_hash}',</p>
<pre>thread_field_detection = 'False',
ignore_invalid_unit_operation_errors = 'False',
chunk_size = '1000',</pre>
<p>diff -r 605942cb9f98aaa215ee0bd67b0293bdd2302598 -r 454b81690191c4ee1c28f0120f39bf9ee99840ed yt/utilities/command_line.py --- a/yt/utilities/command_line.py +++ b/yt/utilities/command_line.py @@ -1049,6 +1049,39 @@</p>
<pre> else:
_print_failed_source_update(opts.reinstall)
</pre>
<p>+ +class YTDeleteImageCmd(YTCommand): + args = (dict(short="delete_hash", type=str),) + description = \ + """ + Delete image from imgur.com. + + """ + name = “delete_image” + def __call__(self, args): + headers = {'Authorization': + ‘Client-ID {}'.format(ytcfg.get("yt", “imagebin_api_key"))} + + delete_url = ytcfg.get("yt”, “imagebin_delete_url”) + req = urllib.request.Request( + delete_url.format(delete_hash=args.delete_hash), + headers=headers, method='DELETE’) + try: + response = urllib.request.urlopen(req).read().decode() + except urllib.error.HTTPError as e: + print("ERROR", e) + return {'deleted': False} + + rv = json.loads(response) + if ‘success’ in rv and rv["success"]: + print("\nImage successfully deleted!\n") + else: + print() + print("Something has gone wrong! Here is the server response:") + print() + pprint.pprint(rv) + +</p>
<pre>class YTUploadImageCmd(YTCommand):
args = (dict(short="file", type=str),)
description = \</pre>
<p>@@ -1062,15 +1095,16 @@</p>
<pre> if not filename.endswith(".png"):
print("File must be a PNG file!")
return 1</pre>
<p>+ headers = {'Authorization': + 'Client-ID {}'.format(ytcfg.get("yt", "imagebin_api_key"))} +</p>
<pre>image_data = base64.b64encode(open(filename, 'rb').read())</pre>
<ul><li><p>api_key = ‘e1977d9195fe39e’</p></li>
<li><p>headers = {'Authorization': ‘Client-ID %s’ % api_key} parameters = {'image': image_data, type: ‘base64’,</p>
<pre>'name': filename,
'title': "%s uploaded by yt" % filename}</pre>
<p>data = urllib.parse.urlencode(parameters).encode('utf-8')</p></li>
<li><p>req = urllib.request.Request('<a href="https://api.imgur.com/3/upload">https://api.imgur.com/3/upload</a>', data=data,</p></li>
<li><p>headers=headers)</p></li></ul>
<p>+ req = urllib.request.Request( + ytcfg.get("yt", "imagebin_upload_url"), data=data, headers=headers)</p>
<pre> try:
response = urllib.request.urlopen(req).read().decode()
except urllib.error.HTTPError as e:</pre>
<p>@@ -1078,18 +1112,12 @@</p>
<pre>return {'uploaded':False}
rv = json.loads(response)
if 'data' in rv and 'link' in rv['data']:</pre>
<ul><li><p>delete_cmd = (</p></li>
<li><p>“curl -X DELETE -H 'Authorization: Client-ID {secret}'”</p></li>
<li><p>" <a href="https://api.imgur.com/3/image/">https://api.imgur.com/3/image/</a>{delete_hash}"</p></li>
<li><p>) print() print("Image successfully uploaded! You can find it at:") print(" %s" % (rv['data']['link'])) print() print("If you'd like to delete it, use the following")</p></li>
<li><p>print(" %s" %</p></li>
<li><p>delete_cmd.format(secret=api_key,</p></li>
<li><p>delete_hash=rv['data']['deletehash']))</p></li></ul>
<p>+ print(" yt delete_image %s" % rv['data']['deletehash'])</p>
<pre>print()
else:
print()</pre>
<p>Repository URL: <a href="https://bitbucket.org/yt_analysis/yt/">https://bitbucket.org/yt_analysis/yt/</a></p>
<p>—</p>
<p>This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.</p>
<img src="http://link.bitbucket.org/wf/open?upn=ll4ctv0L-2ByeRZFC1LslHcg6aJmnQ70VruLbmeLQr27C8sDximcmQBUxU2pWiq1n3YK8ZdYPQHeUiz0RQ14Pt1BDFP-2Bi0NglWguECZPkj-2BCjJ992pWj3wHuqhRokCElmo7cIwy-2BCeG9Tey9C-2BDWcB8dEO2zxH4R8P938w8xBiwm7-2BZct-2FxTNrR7poN2PcozV456ZE9SOuR-2Fsdb89LRrIHHE-2FMU52BIKBk8V-2BvcaYlbxE-3D" alt="" width="1" height="1" border="0" style="height:1px !important;width:1px !important;border-width:0 !important;margin-top:0 !important;margin-bottom:0 !important;margin-right:0 !important;margin-left:0 !important;padding-top:0 !important;padding-bottom:0 !important;padding-right:0 !important;padding-left:0 !important;"/>
</body></html>