costastf / locationsharinglib

A library to retrieve coordinates from an google account that has been shared locations of other accounts.
MIT License
170 stars 29 forks source link

TypeError: 'NoneType' object is not iterable #42

Closed sagilo closed 5 years ago

sagilo commented 6 years ago

I've install version 3.0.6 inside a virtual environment Running test.py:

service = Service(username, password, 'google_maps_location_sharing.conf')
for person in service.get_all_people():
    print(person)

Output:

Traceback (most recent call last):
  File "test.py", line 6, in <module>
    for person in service.get_all_people():
  File "/home/sagi/venv/temp/lib/python3.5/site-packages/locationsharinglib/locationsharinglib.py", line 459, in get_all_people
    people = self.get_shared_people() + [self.get_authenticated_person()]
  File "/home/sagi/venv/temp/lib/python3.5/site-packages/locationsharinglib/locationsharinglib.py", line 420, in get_shared_people
    for info in output[0]:
TypeError: 'NoneType' object is not iterable

Username & password belongs to a new google account which I've shared my location with. I've logged in using Firefox to the new account before running the program.

ctdf commented 6 years ago

Я получил эту работу без 2FA, и я просто хотел поделиться тем, что я сделал, если у кого-то еще остались проблемы. Сегодня я обновил свой домашний помощник до 0,81.1, и это все еще не удалось. обмен google_maps никогда не работал для меня. Вот что я сделал.

  1. Изменены люди переменной в get_all_people способом , как @insajd сделал. (Не уверен, что это необходимо, поскольку я все еще видел ошибки после этого) # 42 (комментарий)
  2. Заменил метод _authenticate кодом, предоставленным @lufton . (Это дало мне ошибку, говоря, что Regex не найден.) # 42 (комментарий)
  3. Я импортировал модуль Regex в locationharinglib.py , добавив импорт повторно в скрипт
  4. Затем я удалил каталог pycache в каталоге placesharinglib (/srv/homeassistant/lib/python3.5/site-packages/locationsharinglib) и удалил файл .google_maps_location_sharing.cookins из главного справочника помощника # 42 (комментарий)
  5. Запущен домашний помощник и мой трекер устройства.
  1. How do you update Locationsharinglib in Docker hasio?
ctdf commented 6 years ago

thx, in my case after the docker restart, it seems to revert back to the original locationsharinglib.py

I combined all the necessary files into one (google_maps.py, locationsharinglib.py and locationsharinglibexceptions.py). Then put in "custom_components\device_tracker\google_maps.py".

jdecker91 commented 6 years ago

Unfortunately I cannot help there as I am unfamiliar with running HASS.io in Docker. I am running a Hassbian image.

evilcorp9 commented 6 years ago

I just have tried lufton's commit, and also new version 3.0.7, but nothing worked properly.. Everytime shows up this error:

File "", line 1, in File "/srv/homeassistant/lib/python3.5/site-packages/locationsharinglib/locationsharinglib.py", line 433, in get_all_people people = self.get_shared_people() + [self.get_authenticated_person()] File "/srv/homeassistant/lib/python3.5/site-packages/locationsharinglib/locationsharinglib.py", line 394, in get_shared_people for info in output[0]: TypeError: 'NoneType' object is not iterable

In Google device activity i can see, that it logged to the account correctly: https://i.imgur.com/jVnlAcA.png

And this is output from cli, using correct credentials:

Traceback (most recent call last): File "cli.py", line 39, in from locationsharinglib import CookieGetter File "/srv/homeassistant/lib/python3.5/site-packages/locationsharinglib/locationsharinglib.py", line 44, in from .locationsharinglibexceptions import (InvalidCredentials, SystemError: Parent module '' not loaded, cannot perform relative import

slipx06 commented 5 years ago

I just have tried lufton's commit, and also new version 3.0.7, but nothing worked properly.. Everytime shows up this error:

File "", line 1, in File "/srv/homeassistant/lib/python3.5/site-packages/locationsharinglib/locationsharinglib.py", line 433, in get_all_people people = self.get_shared_people() + [self.get_authenticated_person()] File "/srv/homeassistant/lib/python3.5/site-packages/locationsharinglib/locationsharinglib.py", line 394, in get_shared_people for info in output[0]: TypeError: 'NoneType' object is not iterable

In Google device activity i can see, that it logged to the account correctly: https://i.imgur.com/jVnlAcA.png

And this is output from cli, using correct credentials:

Traceback (most recent call last): File "cli.py", line 39, in from locationsharinglib import CookieGetter File "/srv/homeassistant/lib/python3.5/site-packages/locationsharinglib/locationsharinglib.py", line 44, in from .locationsharinglibexceptions import (InvalidCredentials, SystemError: Parent module '' not loaded, cannot perform relative import

I have the same problem

My homeassistant.log

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/device_tracker/__init__.py", line 184, in async_setup_platform
    disc_info)
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/device_tracker/google_maps.py", line 46, in setup_scanner
    scanner = GoogleMapsScanner(hass, config, see)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/device_tracker/google_maps.py", line 66, in __init__
    self._update_info()
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/device_tracker/google_maps.py", line 78, in _update_info
    for person in self.service.get_all_people():
  File "/usr/local/lib/python3.6/site-packages/locationsharinglib/locationsharinglib.py", line 471, in get_all_people
    people = self.get_shared_people()
  File "/usr/local/lib/python3.6/site-packages/locationsharinglib/locationsharinglib.py", line 432, in get_shared_people
    for info in output[0]:
TypeError: 'NoneType' object is not iterable

Console output

Traceback (most recent call last):
  File "main.py", line 2, in <module>
    from locationsharinglib import Service
  File "/config/custom_components/device_tracker/locationsharinglib.py", line 45, in <module>
    from .locationsharinglibexceptions import (InvalidCredentials,
ImportError: attempted relative import with no known parent package
StyxyDog commented 5 years ago

@slipx06 Not sure if this will work for you, I am on hass.io on a pi. I created a single file with all the dependencies in it( and I removed the links to the external dependency files). I created a file called google_maps.py in /config/custom_components/device_tracker (I had to create some of that path).

This is the file (rename to google_maps.py), which I just copied and pasted from the original files.

google_maps.py.txt

lufton commented 5 years ago

I just have tried lufton's commit, and also new version 3.0.7, but nothing worked properly.

Yeah, I realize that my solution doesn't let script do get_authenticated_person. I assume it is because of some cookies it didn't get. But if you change get_all_people to something like people = self.get_shared_people() It should work.

Gby56 commented 5 years ago

When can we expect this to be fixed/merged ?

slipx06 commented 5 years ago

Finally got it working using @StyxyDog method. I had to delete the old cookie file and make the edits summarised by @jdecker91

costastf commented 5 years ago

I have commented on the code. It does not follow the design of the protect and it does not work for everybody, so marching something that is broken itself is not really a benefit. I am sorry that this got complicated and I will not have time to work on it before mid next month. Apologies.

lufton commented 5 years ago

Guys, I know a lot of you waiting for google_maps device tracker fix. For now I can share my temporary solution. Place custom_components from ZIP to your <config directory>: custom_components.zip It is dirty hack version, but it works for me. The google_maps.py wasn't modified much from original, locationsharinglib.py is slightly modified and merged with locationsharinglibexceptions.py. If you have 2FA enabled it might not work from first time you restart HA, try restarting HA until you stop receiving phone notifications to allow login. Congratulations! Now you are able to track devices.

physk commented 5 years ago

@lufton i still get the same error with that :/ no 2FA (UK Based)

2018-11-18 22:25:28 ERROR (SyncWorker_32) [custom_components.device_tracker.google_maps] Hey you!!! 2018-11-18 22:25:31 ERROR (MainThread) [homeassistant.components.device_tracker] Error setting up platform google_maps Traceback (most recent call last): File "/usr/src/app/homeassistant/components/device_tracker/__init__.py", line 184, in async_setup_platform disc_info) File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run result = self.fn(*self.args, **self.kwargs) File "/config/custom_components/device_tracker/google_maps.py", line 46, in setup_scanner scanner = GoogleMapsScanner(hass, config, see) File "/config/custom_components/device_tracker/google_maps.py", line 66, in __init__ self._update_info() File "/config/custom_components/device_tracker/google_maps.py", line 78, in _update_info for person in self.service.get_all_people(): File "/config/custom_components/device_tracker/locationsharinglib.py", line 453, in get_all_people people = self.get_shared_people() File "/config/custom_components/device_tracker/locationsharinglib.py", line 414, in get_shared_people for info in output[0]: TypeError: 'NoneType' object is not iterable

lufton commented 5 years ago

@lufton i still get the same error with that :/ no 2FA

2018-11-18 22:25:28 ERROR (SyncWorker_32) [custom_components.device_tracker.google_maps] Hey you!!! 2018-11-18 22:25:31 ERROR (MainThread) [homeassistant.components.device_tracker] Error setting up platform google_maps Traceback (most recent call last): File "/usr/src/app/homeassistant/components/device_tracker/__init__.py", line 184, in async_setup_platform disc_info) File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run result = self.fn(*self.args, **self.kwargs) File "/config/custom_components/device_tracker/google_maps.py", line 46, in setup_scanner scanner = GoogleMapsScanner(hass, config, see) File "/config/custom_components/device_tracker/google_maps.py", line 66, in __init__ self._update_info() File "/config/custom_components/device_tracker/google_maps.py", line 78, in _update_info for person in self.service.get_all_people(): File "/config/custom_components/device_tracker/locationsharinglib.py", line 453, in get_all_people people = self.get_shared_people() File "/config/custom_components/device_tracker/locationsharinglib.py", line 414, in get_shared_people for info in output[0]: TypeError: 'NoneType' object is not iterable

Okay, that is strange. Can you turn on 2FA to check if that cause problem.

physk commented 5 years ago

i just worked it out :) it wasn't picking up the shared device :) had to unshare and reshare and it's now working. Thanks :D

lufton commented 5 years ago

i just worked it out :) it wasn't picking up the shared device :) had to unshare and reshare and it's now working. Thanks :D

Glad it worked for you. Hopefully it wouldn't break soon.

sfnetwork commented 5 years ago

@lufton wow thanks, that worked perfectly!!! First time ever this works, FINALLY!!!

mkotlarz commented 5 years ago

I just have tried lufton's commit, and also new version 3.0.7, but nothing worked properly.. Everytime shows up this error:

File "", line 1, in File "/srv/homeassistant/lib/python3.5/site-packages/locationsharinglib/locationsharinglib.py", line 433, in get_all_people people = self.get_shared_people() + [self.get_authenticated_person()] File "/srv/homeassistant/lib/python3.5/site-packages/locationsharinglib/locationsharinglib.py", line 394, in get_shared_people for info in output[0]: TypeError: 'NoneType' object is not iterable

In Google device activity i can see, that it logged to the account correctly: https://i.imgur.com/jVnlAcA.png And this is output from cli, using correct credentials:

Traceback (most recent call last): File "cli.py", line 39, in from locationsharinglib import CookieGetter File "/srv/homeassistant/lib/python3.5/site-packages/locationsharinglib/locationsharinglib.py", line 44, in from .locationsharinglibexceptions import (InvalidCredentials, SystemError: Parent module '' not loaded, cannot perform relative import

I have the same problem

My homeassistant.log

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/device_tracker/__init__.py", line 184, in async_setup_platform
    disc_info)
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/device_tracker/google_maps.py", line 46, in setup_scanner
    scanner = GoogleMapsScanner(hass, config, see)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/device_tracker/google_maps.py", line 66, in __init__
    self._update_info()
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/device_tracker/google_maps.py", line 78, in _update_info
    for person in self.service.get_all_people():
  File "/usr/local/lib/python3.6/site-packages/locationsharinglib/locationsharinglib.py", line 471, in get_all_people
    people = self.get_shared_people()
  File "/usr/local/lib/python3.6/site-packages/locationsharinglib/locationsharinglib.py", line 432, in get_shared_people
    for info in output[0]:
TypeError: 'NoneType' object is not iterable

Console output

Traceback (most recent call last):
  File "main.py", line 2, in <module>
    from locationsharinglib import Service
  File "/config/custom_components/device_tracker/locationsharinglib.py", line 45, in <module>
    from .locationsharinglibexceptions import (InvalidCredentials,
ImportError: attempted relative import with no known parent package

@lufton OMG after days of torture your code got it working for me! Thanks!

As for the Import Error, did you pip install regex on your Hassio box?

I got this same error and I had to install regex (the import re ) library.
I might have done something else too, like delete cookie files etc, but I think the install may help here.

Mike K

lufton commented 5 years ago

As for the Import Error, did you pip install regex on your Hassio box?

This fix doesn't use regex library as parser it is parsed by json.

sasgoose commented 5 years ago

@lufton thank you so much! It worked perfectly!

CrazYoshi commented 5 years ago

@lufton thank you! It worked perfectly also for me. Could you please merge this change to the master branch in order to have it for the future version in HASS?

lufton commented 5 years ago

@lufton thank you! It worked perfectly also for me. Could you please merge this change to the master branch in order to have it for the future version in HASS?

You are welcome! I can't merge that as I'm not the owner of this plugin, @costastf is. More of that it is dirty hacked version, read his https://github.com/costastf/locationsharinglib/issues/42#issuecomment-439601385.

Kryzek commented 5 years ago

Custom component seems to work for me too. Thank you @lufton for putting this together while we wait for the proper fix to the library.

costastf commented 5 years ago

Hi everybody! Could everybody with issues with the latest version of this library, without @lufton 's patch please report country of origin so I can use a vpn service and try to fix this consistently for everyone? I am hoping to invest some time on this after coming week. Thanks in advance!

rgruebel commented 5 years ago

Germany

lufton commented 5 years ago

Ukraine (If you need I can setup Ukrainian VPN server on my mikrotik router)

StyxyDog commented 5 years ago

United Kingdom

On Wed, 28 Nov 2018 at 14:30, Дубовик Максим notifications@github.com wrote:

Ukraine

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/costastf/locationsharinglib/issues/42#issuecomment-442466105, or mute the thread https://github.com/notifications/unsubscribe-auth/AqWJ80nXx0x0h5NaIPQbfwNIrUUR9ZNnks5uzp32gaJpZM4XawWk .

Gby56 commented 5 years ago

Ireland

sagilo commented 5 years ago

Israel, Thank you!

slipx06 commented 5 years ago

South Africa

ragenhe commented 5 years ago

United States - Thank you Sir!!!!

pschmitt commented 5 years ago

And my 12 points go to... FRANCE! 🎆

Charli181 commented 5 years ago

Australia

ctdf commented 5 years ago

Russia

BertilJ commented 5 years ago

Sweden

Jayphen commented 5 years ago

Austria

cschriel commented 5 years ago

The Netherlands

shinyshoes16 commented 5 years ago

Canada

ivanfor commented 5 years ago

Spain ;)

marcootjehhh commented 5 years ago

The Netherlands

eggman0131 commented 5 years ago

I'm in the UK.

Thanks for the fix, Lufton

lufton commented 5 years ago

Thanks for the fix, Lufton

I'm just a human, do what I can )

blakadder commented 5 years ago

Croatia

costastf commented 5 years ago

Please remove the log, it contains personal information.

On Tue, Dec 4, 2018 at 10:35 AM blakadder notifications@github.com wrote:

Croatia

Here's the error log from get-maps-cookies https://hastebin.com/yizoduyeco.xml

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/costastf/locationsharinglib/issues/42#issuecomment-444033393, or mute the thread https://github.com/notifications/unsubscribe-auth/AEbFa7S3NJP-7XLxDsY5_nuzbwGPfjVVks5u1kHhgaJpZM4XawWk .

KrzysztofHajdamowicz commented 5 years ago

During waiting to fix this issue, I've used other option mentioned here (hardcode cookies into code). Will work for a while.

Kepler75 commented 5 years ago

Argentina

matmoscicki commented 5 years ago

Poland

Kryzek commented 5 years ago

Finland

DaveThe commented 5 years ago

Italy :)

CsepregiArtur commented 5 years ago

Romania

CsepregiArtur commented 5 years ago

please hepl me

Tue Dec 11 2018 21:31:56 GMT+0200 (Ora standard a Europei de Est)

Error setting up platform google_maps Traceback (most recent call last): File "/usr/local/lib/python3.6/site-packages/homeassistant/components/device_tracker/init.py", line 184, in async_setup_platform disc_info) File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run result = self.fn(*self.args, **self.kwargs) File "/usr/local/lib/python3.6/site-packages/homeassistant/components/device_tracker/google_maps.py", line 46, in setup_scanner scanner = GoogleMapsScanner(hass, config, see) File "/usr/local/lib/python3.6/site-packages/homeassistant/components/device_tracker/google_maps.py", line 66, in init self._update_info() File "/usr/local/lib/python3.6/site-packages/homeassistant/components/device_tracker/google_maps.py", line 78, in _update_info for person in self.service.get_all_people(): File "/usr/local/lib/python3.6/site-packages/locationsharinglib/locationsharinglib.py", line 465, in get_all_people people = self.get_shared_people() + [self.get_authenticated_person()] File "/usr/local/lib/python3.6/site-packages/locationsharinglib/locationsharinglib.py", line 426, in get_shared_people for info in output[0]: TypeError: 'NoneType' object is not iterable