TechWiz-3 / who-unfollowed-me

😡 Python CLI tool that shows you who has unfollowed you on GitHub. PRs welcome!
GNU General Public License v3.0
11 stars 24 forks source link

Crash if ~/.unfollow is missing #39

Closed Dinoosawruss closed 1 year ago

Dinoosawruss commented 2 years ago

If you delete ~/.unfollow, the program appears to crash

Happy to work on a fix for this

TechWiz-3 commented 2 years ago

That's really weird. What's the error?

Dinoosawruss commented 2 years ago

It's a FileNotFoundError which is raised "when you are trying to access a file or a directory that doesn't exist"

So think get_config() just needs a os.path.isdir check and if it doesn't create the directory

TechWiz-3 commented 2 years ago

What's the full traceback? I assume it's happening from cli.py when getting the config cecause get_user() has that feature already https://github.com/TechWiz-3/who-unfollowed-me/blob/main/unfollow/unfollow.py#L46

Dinoosawruss commented 2 years ago
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Python310\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "C:\Users\mdorm\onedrive\documents\code\python\who-unfollowed-me\unfollow\cli.py", line 17, in <module>
    config = get_config()
  File "C:\Users\mdorm\onedrive\documents\code\python\who-unfollowed-me\unfollow\config.py", line 290, in get_config
    with open(f"{UNFOLLOW_PATH}/unfollow.toml", "w", encoding='utf-8') as config_file:
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\mdorm/.unfollow/unfollow.toml'
Dinoosawruss commented 2 years ago

Should be fixed in #41

donno2048 commented 2 years ago

Actually this is still an issue, on Pydroid I get the same error which disappears after

$ mkdir ~/.unfollow
TechWiz-3 commented 2 years ago

Could you please show the full error traceback?

donno2048 commented 2 years ago
/storage/emulated/0 $ unfollow
Traceback (most recent call last):
  File "/data/user/0/ru.iiec.pydroid3/files/arm-linux-androideabi/bin/unfollow", line 5, in <module>
    from unfollow.cli import main
  File "/data/user/0/ru.iiec.pydroid3/files/arm-linux-androideabi/lib/python3.9/site-packages/unfollow/cli.py", line 17, in <module>
    config = get_config()
  File "/data/user/0/ru.iiec.pydroid3/files/arm-linux-androideabi/lib/python3.9/site-packages/unfollow/config.py", line 58, in get_config
    with open(f"{UNFOLLOW_PATH}/unfollow.toml", "w") as config_file:
FileNotFoundError: [Errno 2] No such file or directory: '/data/user/0/ru.iiec.pydroid3/app_HOME/.unfollow/unfollow.toml'/storage/emulated/0 $

(In Pydroid ~ is /data/user/0/ru.iiec.pydroid3/app_HOME/)

TechWiz-3 commented 2 years ago

Hmm, I'm quite confused as to why this would happen, you're sure you're using the latest version of unfollow?

IF you are, could you please remove/delete the directory you created then open an interactive Python shell and try:

import os
os.path.exists(os.path.expanduser("~/.unfollow"))

And send output, whether it was True or False

donno2048 commented 2 years ago
/storage/emulated/0 $ pip list | grep unfollow
unfollow           3.0.0
/storage/emulated/0 $ python
Python 3.9.7 (default, Oct  9 2021, 08:02:40)
[GCC 11.1.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.path.exists(os.path.expanduser("~/.unfollow"))
False
>>>
TechWiz-3 commented 2 years ago

Ok please do pip install -U unfollow

Ensure your version is 5.0.0. The issue should be fixed

donno2048 commented 2 years ago

Well, now I get this

...
    from unfollow.cli import main
  File "/data/user/0/ru.iiec.pydroid3/files/arm-linux-androideabi/lib/python3.9/site-packages/unfollow/cli.py", line 17, in <module>
    config = get_config()
  File "/data/user/0/ru.iiec.pydroid3/files/arm-linux-androideabi/lib/python3.9/site-packages/unfollow/config.py", line 683, in get_config
    config = toml.loads(default_config)
  File "/data/user/0/ru.iiec.pydroid3/files/arm-linux-androideabi/lib/python3.9/site-packages/toml/decoder.py", line 478, in loads
    raise TomlDecodeError("What? " + group +
toml.decoder.TomlDecodeError: What? bubbles already exists?{'simple': {'welcome_message': 'Welcome to who-unfollowed-me Python implementation by Zac the Wise', 'fetched_followers_message': 'Fetched github followers', 'no_unfollows_message': 'No unfollows!', 'end_message': 'You have {follower_num} followers. Keep up the good work\n', 'thankyou_message': 'Thanks for using this project'}, 'regular': {'welcome_message': ':dancer: [purple]Welcome to[/purple] [red]who-unfollowed-me[/red][blue] Python implementation[/blue] by [#FFD700]Zac the Wise[#FFD700]', 'fetched_followers_message': '[green]✔ [underline]Fetched github followers', 'last_week_unfollowers': '[purple]✔ [underline]Unfollowers from last week', 'no_unfollows_message': '[green]:raised_hands: [underline]No unfollows!', 'end_message': ':fire: You have {follower_num} followers. Keep up the good work\n', 'thankyou_message': ':pray: Thanks for using this project'}, 'panels': {'welcome_message': ':dancer: [purple]Welcome to[/purple] [red]who-unfollowed-me[/red][blue] Python implementation[/blue] by [#FFD700]Zac the Wise[#FFD700]', 'fetched_followers_message': '[green]✔ [underline]Fetched github followers', 'last_week_unfollowers': '[purple]✔ [underline]Unfollowers from last week', 'no_unfollows_message': '[white on #308012] No unfollows! [/white on #308012]                                ', 'end_message': ':fire: You have {follower_num} followers. Keep up the good work\n', 'thankyou_message': ':pray: Thanks for using this project'}, 'bubbles': {'welcome_message_a': '[white on purple]Welcome to[/white on purple]', 'welcome_message_b': '[white on red]who-unfollowed-me[/white on red]', 'welcome_message_c': '[white on blue]the Python implementation[/white on blue]', 'welcome_message_d': '[white on dark_goldenrod]by Zac the Wise[/white on dark_goldenrod]', 'fetched_followers_message': '[white on cyan]Fetched github followers[/white on cyan]', 'last_week_unfollowers': '[purple]✔ [underline]Unfollowers from last week', 'no_unfollows_message': '[white on green4]No unfollows![/white on green4]', 'end_message_a': '[white on purple]You have {follower_num} followers.[/white on purple]', 'end_message_b': '[white on magenta]Keep up the good work![/white on magenta]', 'thankyou_message': '[white on blue]Thanks for using this project[/white on blue]'}} (line 380 column 1 char 23604)
TechWiz-3 commented 2 years ago

delete .unfollow directory then run again

donno2048 commented 2 years ago

Same result

TechWiz-3 commented 2 years ago

That's really weird, any ideas @Dinoosawruss?

Dinoosawruss commented 2 years ago

Same result

Could you send the error traceback just incase it's not the same

Can't really think of why it's should be any different because ultimately it's still running Python 3.9.7

TechWiz-3 commented 2 years ago

@donno2048 ^^

donno2048 commented 1 year ago
/storage/emulated/0 $ unfollow
Traceback (most recent call last):
  File "/data/user/0/ru.iiec.pydroid3/files/arm-linux-androideabi/bin/unfollow", line 5, in <module>
    from unfollow.cli import main
  File "/data/user/0/ru.iiec.pydroid3/files/arm-linux-androideabi/lib/python3.9/site-packages/unfollow/cli.py", line 26, in <module>
    handled_version = config_version_handle(0)
  File "/data/user/0/ru.iiec.pydroid3/files/arm-linux-androideabi/lib/python3.9/site-packages/unfollow/config.py", line 697, in config_version_handle
    _ = get_config(overwrite=True)
  File "/data/user/0/ru.iiec.pydroid3/files/arm-linux-androideabi/lib/python3.9/site-packages/unfollow/config.py", line 677, in get_config
    config = toml.loads(default_config)
  File "/data/user/0/ru.iiec.pydroid3/files/arm-linux-androideabi/lib/python3.9/site-packages/toml/decoder.py", line 478, in loads
    raise TomlDecodeError("What? " + group +
toml.decoder.TomlDecodeError: What? bubbles already exists?{'simple': {'welcome_message': 'Welcome to who-unfollowed-me Python implementation by Zac the Wise', 'fetched_followers_message': 'Fetched github followers', 'no_unfollows_message': 'No unfollows!', 'end_message': 'You have {follower_num} followers. Keep up the good work\n', 'thankyou_message': 'Thanks for using this project'}, 'regular': {'welcome_message': ':dancer: [purple]Welcome to[/purple] [red]who-unfollowed-me[/red][blue] Python implementation[/blue] by [#FFD700]Zac the Wise[#FFD700]', 'fetched_followers_message': '[green]✔ [underline]Fetched github followers', 'last_week_unfollowers': '[purple]✔ [underline]Unfollowers from last week', 'no_unfollows_message': '[green]:raised_hands: [underline]No unfollows!', 'end_message': ':fire: You have {follower_num} followers. Keep up the good work\n', 'thankyou_message': ':pray: Thanks for using this project'}, 'panels': {'welcome_message': ':dancer: [purple]Welcome to[/purple] [red]who-unfollowed-me[/red][blue] Python implementation[/blue] by [#FFD700]Zac the Wise[#FFD700]', 'fetched_followers_message': '[green]✔ [underline]Fetched github followers', 'last_week_unfollowers': '[purple]✔ [underline]Unfollowers from last week', 'no_unfollows_message': '[white on #308012] No unfollows! [/white on #308012]                                ', 'end_message': ':fire: You have {follower_num} followers. Keep up the good work\n', 'thankyou_message': ':pray: Thanks for using this project'}, 'bubbles': {'welcome_message_a': '[white on purple]Welcome to[/white on purple]', 'welcome_message_b': '[white on red]who-unfollowed-me[/white on red]', 'welcome_message_c': '[white on blue]the Python implementation[/white on blue]', 'welcome_message_d': '[white on dark_goldenrod]by Zac the Wise[/white on dark_goldenrod]', 'fetched_followers_message': '[white on cyan]Fetched github followers[/white on cyan]', 'last_week_unfollowers': '[purple]✔ [underline]Unfollowers from last week', 'no_unfollows_message': '[white on green4]No unfollows![/white on green4]', 'end_message_a': '[white on purple]You have {follower_num} followers.[/white on purple]', 'end_message_b': '[white on magenta]Keep up the good work![/white on magenta]', 'thankyou_message': '[white on blue]Thanks for using this project[/white on blue]'}} (line 380 column 1 char 23604)
/storage/emulated/0 $
Dinoosawruss commented 1 year ago

Can you send the config file please? @donno2048

TechWiz-3 commented 1 year ago

The plot thickens 😂

Dinoosawruss commented 1 year ago

Any update @donno2048

donno2048 commented 1 year ago

What config file?

TechWiz-3 commented 1 year ago

What config file?

~/.unfollow/unfollow.toml

TechWiz-3 commented 1 year ago

I converted the dict from donno's traceback to a toml file and got this:

[simple]
welcome_message = "Welcome to who-unfollowed-me Python implementation by Zac the Wise"
fetched_followers_message = "Fetched github followers"
no_unfollows_message = "No unfollows!"
end_message = "You have {follower_num} followers. Keep up the good work\n"
thankyou_message = "Thanks for using this project"

[regular]
welcome_message = ":dancer: [purple]Welcome to[/purple] [red]who-unfollowed-me[/red][blue] Python implementation[/blue] by [#FFD700]Zac the Wise[#FFD700]"
fetched_followers_message = "[green]✔ [underline]Fetched github followers"
last_week_unfollowers = "[purple]✔ [underline]Unfollowers from last week"
no_unfollows_message = "[green]:raised_hands: [underline]No unfollows!"
end_message = ":fire: You have {follower_num} followers. Keep up the good work\n"
thankyou_message = ":pray: Thanks for using this project"

[panels]
welcome_message = ":dancer: [purple]Welcome to[/purple] [red]who-unfollowed-me[/red][blue] Python implementation[/blue] by [#FFD700]Zac the Wise[#FFD700]"
fetched_followers_message = "[green]✔ [underline]Fetched github followers"
last_week_unfollowers = "[purple]✔ [underline]Unfollowers from last week"
no_unfollows_message = "[white on #308012] No unfollows! [/white on #308012]                                "
end_message = ":fire: You have {follower_num} followers. Keep up the good work\n"
thankyou_message = ":pray: Thanks for using this project"

[bubbles]
welcome_message_a = "[white on purple]Welcome to[/white on purple]"
welcome_message_b = "[white on red]who-unfollowed-me[/white on red]"
welcome_message_c = "[white on blue]the Python implementation[/white on blue]"
welcome_message_d = "[white on dark_goldenrod]by Zac the Wise[/white on dark_goldenrod]"
fetched_followers_message = "[white on cyan]Fetched github followers[/white on cyan]"
last_week_unfollowers = "[purple]✔ [underline]Unfollowers from last week"
no_unfollows_message = "[white on green4]No unfollows![/white on green4]"
end_message_a = "[white on purple]You have {follower_num} followers.[/white on purple]"
end_message_b = "[white on magenta]Keep up the good work![/white on magenta]"
thankyou_message = "[white on blue]Thanks for using this project[/white on blue]"
Dinoosawruss commented 1 year ago

Can't see anything there but would still be nice to get the full file

Dinoosawruss commented 1 year ago

@donno2048 any update?

donno2048 commented 1 year ago

What config file?

~/.unfollow/unfollow.toml

It's empty

Dinoosawruss commented 1 year ago

Even if you delete the file and rerun?

donno2048 commented 1 year ago

Yes

TechWiz-3 commented 1 year ago

What version are you on now?

donno2048 commented 1 year ago

Ok please do pip install -U unfollow

Ensure your version is 5.0.0. The issue should be fixed

...

Dinoosawruss commented 1 year ago

Can you delete the ~/.unfollow directory, rerun the program and see if anything is created?

EDIT: I have tried to recreate the problem but can't

Could you possibly give recreate steps on how you're running it etc

Dinoosawruss commented 1 year ago

Update: successfully recreated on BlueStacks... investigating

Dinoosawruss commented 1 year ago

Diagnosis:

I ran a couple of things in Pydroid on Bluestacks and found that /data/user/0/ru.iiec.pydroid3/app_HOME seems to be the home directory when running in Pydroid image

I tried to create a file here to test if we can, which worked image It did

I ran an ls -a against the home dir and found that .unfollowand unfollow.toml were created image image

I noticed that the error was complaining about line 380 of unfollow.toml so checked this and it seems we have some invalid toml which is ultimately causing the issue image

I will commit this change and PR it and hopefully, that will fix the issue. Quite unsure why this doesn't also happen on Windows/other Linux OSs but have struggled to recreate it outside of Pydroid

I cannot test this fix as have no way of running the full code on Pydroid but am assuming that this is the cause

Dinoosawruss commented 1 year ago

See #67

Dinoosawruss commented 1 year ago

Hey @donno2048 just checking that PR fixed the issue you were having?

TechWiz-3 commented 1 year ago

Remember to update to version 5.0.1

Dinoosawruss commented 1 year ago

image The error appears to be gone on BlueStacks

donno2048 commented 1 year ago

Hey @donno2048 just checking that PR fixed the issue you were having?

Yes!

TechWiz-3 commented 1 year ago

🥳 thanks guys