Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rm pycryptodome #141

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -544,12 +544,16 @@ Create Scoped Keys (**Deprecated**)
''''''''''''''''''

The Python client enables you to create `Scoped Keys <https://keen.io/docs/security/#scoped-key>`_ easily, but Access Keys are better!
If you need to use them anyway, for legacy reasons, here's how:
If you need to use them anyway, here's how:

::

pip install pycryptodome

.. code-block:: python

from keen.client import KeenClient
from keen import scoped_keys
from keen import scoped_keys # You must have pycryptodome installed!

api_key = KEEN_MASTER_KEY

Expand Down
9 changes: 8 additions & 1 deletion keen/scoped_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@
import json
import os
import six
from Crypto.Cipher import AES

try:
from Crypto.Cipher import AES
except ImportError as ie:
ie.args = (ie.args[0] + ' -- Scoped Keys are deprecated in favor'
' of Access Keys. To use Scoped Keys anyway, run: '
'`pip install pycryptodome` and try this again.',)
raise ie
Copy link
Contributor

@masojus masojus Oct 26, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will blow away the original stack, right? raise ie in python 2 will blow away the stack anyway since you have to use the 3-arg raise, and in python 3, by replacing the entire args tuple we're disregarding any information previously stored on the exception except the message, right? In this case, maybe the message is enough, but if not, we could use the six module's reraise which I think forwards to the future utils in python 2 and uses the raise ... from ... and/or the with_traceback() facility in python 3. Just a thought.


from keen import Padding

__author__ = 'dkador'
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
pycryptodome>=3.4
requests>=2.5,<3.0
six~=1.10.0
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
reqs = reqs_file.readlines()
reqs_file.close()

tests_require = ['nose', 'mock', 'responses==0.5.1', 'unittest2']
tests_require = ['nose', 'mock', 'responses==0.5.1', 'unittest2', 'pycryptodome>=3.4']

setup(
name="keen",
Expand Down