Skip to content
This repository has been archived by the owner on Mar 22, 2021. It is now read-only.

unable to complete - TypeError: 'NoneType' object is not iterable #15

Closed
JoesphG opened this issue Jul 2, 2018 · 14 comments
Closed

unable to complete - TypeError: 'NoneType' object is not iterable #15

JoesphG opened this issue Jul 2, 2018 · 14 comments

Comments

@JoesphG
Copy link

JoesphG commented Jul 2, 2018

update:
Added explicit path for all files in the hangouts_to_sms.py file. still unable to run. Any ideas ? thanks heaps (by the way thanks for pulling this solution together will be great to get this working)

Traceback (most recent call last):
File "c:/hangouts_to_sms-develop/hangouts_to_sms.py", line 15, in
conversations, self_gaia_id = hangouts_parser.parse_input_file(HANGOUTS_JSON_FILE, YOUR_PHONE_NUMBER)
File "C:/hangouts_to_sms-develop/hangouts_parser.py", line 25, in parse_input_file
for conversation_state in data.conversation_state:
AttributeError: 'Namespace' object has no attribute 'conversation_state'

@JoesphG JoesphG changed the title unable to complete HANGOUTS_JSON_FILE: command not found unable to complete Jul 2, 2018
@JoesphG
Copy link
Author

JoesphG commented Jul 2, 2018

ok fixed a variables in hangouts_to_sms.py

25: data.conversation_state ---> data.conversations
27: getattr(conversation_state, "conversation_state", None) ---> getattr(conversation_state, "conversation", None)
57: getattr(state, "event", None) ---> getattr(conversation_state, "events", None)

now getting the following issue

Traceback (most recent call last):
File "/hangouts_to_sms-develop/hangouts_to_sms.py", line 18, in
titanium_output.create_output_file(conversations, self_gaia_id, OUTPUT_FILE)
File "C:\hangouts_to_sms-develop\titanium_backup_formatter.py", line 39, in create_output_file
for message in conversation.messages:
TypeError: 'NoneType' object is not iterable

Any ideas?

@JoesphG JoesphG changed the title unable to complete unable to complete - TypeError: 'NoneType' object is not iterable Jul 3, 2018
@jgroom33
Copy link

jgroom33 commented Jul 9, 2018

https://github.com/er0sin/hangouts_to_sms
^ this works (develop branch)
IMO, should be PR/merged
@er0sin

@JoesphG
Copy link
Author

JoesphG commented Jul 9, 2018

Thanks @jgroom33

I ran your branch, got the follow issues. Any chance you can help ?

Parsing Hangouts data file...
Traceback (most recent call last):
File "./hangouts_to_sms.py", line 15, in
conversations, self_gaia_id = hangouts_parser.parse_input_file(HANGOUTS_JSON_FILE, YOUR_PHONE_NUMBER)
File "C:\hangouts_to_sms-develop\hangouts_parser.py", line 27, in parse_input_file
data = json.load(data_file, object_hook=lambda d: Namespace(**d))
File "D:\python\lib\json_init_.py", line 293, in load
return loads(fp.read(),
File "D:\python\lib\encodings\cp1252.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x8d in position 766505: character maps to

@jgroom33
Copy link

Add a print statement on line 26 to see what value is causing the error.

@JoesphG
Copy link
Author

JoesphG commented Jul 12, 2018

sorry @jgroom33 im a bit of a novice, can you help correct my syntax?

Hangouts_parser.py

Line 23: conversations = []
Line 24: self_gaia_id = None # gaia_id for the phone owner
Line 25: with open(hangouts_file_name, 'rt') as data_file:
Line 26: print()

@JoesphG JoesphG closed this as completed Jul 12, 2018
@jgroom33
Copy link

looks like you have bad json (the code isn't even parsing the file). does it parse properly at jsoneditoronline.org

@JoesphG
Copy link
Author

JoesphG commented Jul 12, 2018

Yes its strange, it parses correctly.
Also have the hangouts.json in the same folder as the .py scripts. I also tried an explicit path name to the hangouts.json with the same error

image

@JoesphG JoesphG reopened this Jul 12, 2018
@jgroom33
Copy link

maybe try stripping the json file down to just a couple messages. unless you can figure out where character: position 766505

@JoesphG
Copy link
Author

JoesphG commented Jul 13, 2018

great found the offending characters, do you think we can alter the script to strip out any character that cant be decoded and replace them or delete them, im finding 100's of characters that are the offending issues are all emojis

@JoesphG
Copy link
Author

JoesphG commented Jul 13, 2018

did a regex in notepad++ to remove all non-ascii characters
this is the regex if anyone needs it
[^\x00-\x7F]+

@JoesphG
Copy link
Author

JoesphG commented Jul 13, 2018

so got the parser complete, now stuck at formatting. Any ideas? thanks again for all the help @jgroom33

C:\sms\hangouts_to_sms-develop>python hangouts_to_sms.py
Parsing Hangouts data file...
Done.
Converting to SMS export file...
Error: could not match sender gaia ID to participant IDs!
Error: could not match sender gaia ID to participant IDs!
Error: could not match sender gaia ID to participant IDs!
Error: could not match sender gaia ID to participant IDs!
Error: could not match sender gaia ID to participant IDs!
Error: could not match sender gaia ID to participant IDs!
Error: could not match sender gaia ID to participant IDs!
Error: could not match sender gaia ID to participant IDs!
Traceback (most recent call last):
File "hangouts_to_sms.py", line 18, in
titanium_output.create_output_file(conversations, self_gaia_id, OUTPUT_FILE)
File "C:\sms\hangouts_to_sms-develop\titanium_backup_formatter.py", line 74, in create_output_file
content_is_plain = self._is_ascii(message.content)
File "C:\sms\hangouts_to_sms-develop\titanium_backup_formatter.py", line 173, in _is_ascii
return len(text) == len(text.encode())
TypeError: object of type 'NoneType' has no len()

Looked at the suggestions in #12 but still get issues below @mrdehate

C:\sms\hangouts_to_sms-develop>python hangouts_to_sms.py
Traceback (most recent call last):
File "hangouts_to_sms.py", line 2, in
from titanium_backup_formatter import TitaniumBackupFormatter
File "C:\sms\hangouts_to_sms-develop\titanium_backup_formatter.py", line 83
message_string += "{}".format(escape(message.content) if content_is_plain else self._base64_text(message.content))
^
TabError: inconsistent use of tabs and spaces in indentation

here is the code snippet

image

@jgroom33
Copy link

I'd suggest trying to implement the character replacement using python and add it to this library.
Then open a new issue for the new problem.

@JoesphG
Copy link
Author

JoesphG commented Jul 13, 2018

great suggestion ill try to add in the character replacement in python and add in

@JoesphG JoesphG closed this as completed Jul 13, 2018
@jrwrigh
Copy link

jrwrigh commented Aug 10, 2018

I was able to get this to work by adding an encoding option to the open command on line 25:

 with open(hangouts_file_name, 'rt', encoding='utf-8') as data_file:

The xml format that came out of it also specified a encoding='UTF-8'. Looking at some old forum posts, it looks like that's what TitaniumBackup is expecting, but I'll just have to try to find out if it works.

Edit: It worked fine this way!

jrwrigh added a commit to jrwrigh/hangouts_to_sms that referenced this issue Aug 10, 2018
Addressing adein#15, changing the open to UTF-8 encoding to allow for basic emoji characters (and other characters).

I believe adein#15 only effected Windows users (as the `open` command would default to using `cp1215` encoding instead of `utf-8`), but the addition of the encoding generally makes the code more robust IMO.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants