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

Error message running android.py and androidkindlekey.py #10

Closed
ableeker opened this issue May 16, 2015 · 4 comments
Closed

Error message running android.py and androidkindlekey.py #10

ableeker opened this issue May 16, 2015 · 4 comments

Comments

@ableeker
Copy link
Contributor

On my machine android.py (and androidkindlekey.py) abort with an error message:

File “F:\eBooks\Android\android.py”, line 137, in get_serials2
tokens = [x[0].encode(‘utf8′) for x in cursor.fetchall()]
AttributeError: ‘NoneType’ object has no attribute ‘encode’

I think the encode part will only work as long as none of the results are NULL: if a result is NULL, you can’t encode it to UTF-8. On my machine at least, some results unfortunately are NULL. So what you’d like to do is only encode the particular result if it isn’t NULL. I’ve tried to do that by rewriting the line like so:

if not tokens:
[x[0].encode(‘utf-8′) for x in tokens]

This runs without an error message, but because I don’t know Python that well, I’m not entirely sure it does what I want. This produces different keys, but they don’t work, as in they don’t decrypt the ebook. This may well mean that statement is wrong, which wouldn’t surprise me at all.

However, at first I got rid of the error message by just 'ignoring' the token. I ignored the tokens by replacing the line with just 'tokens = ['']'. This produced a key which weirdly enough DOES work.

@apprenticeharper
Copy link
Owner

Thanks for reporting this bug.

@ableeker
Copy link
Contributor Author

Actually, what works is:

dsns = cursor.fetchall()

and

tokens = cursor.fetchall()

If you ignore tokens, you get just half a key. I was lucky, because on one of my devices this was the entire key, but on one of my other devices, I needed both halves, so tokens = [''] doesn't work. Is it really necessary to encode the keys in UTF-8 anyway? After all there's no difference if you only use 7-bits ASCII.

@apprenticeharper
Copy link
Owner

Thanks for the extra info. I’m putting android to one side briefly while I concentrate on getting the B&N URL fix done. (I tried doing both at once which was a mistake, just from a keeping things straight in my mind point of view.)

I’m currently working on a 6.2.2 without the android stuff, and once that’s done I’ll move on to getting a 6.3.1 release with the Android code in it. If I have problems at that point I might get back to you.

Thanks again for the interest,

Harper.

Sent from Windows Mail

From: ableeker
Sent: ‎Wednesday‎, ‎24‎ ‎June‎ ‎2015 ‎17‎:‎17
To: apprenticeharper/DeDRM_tools
Cc: apprenticeharper

Actually, what works is:

dsns = cursor.fetchall()

and

tokens = cursor.fetchall()

If you ignore tokens, you get just half a key. I was lucky, because on one of my devices this was the entire key, but on one of my other devices, I needed both halves, so tokens = [''] doesn't work. Is it really necessary to encode the keys in UTF-8 anyway? After all there's no difference if you only use 7-bits ASCII.


Reply to this email directly or view it on GitHub.

@apprenticeharper
Copy link
Owner

Fixed in the current release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants