anned20/begoneads

'begoneads.py install' raises an error Windows 10

Closed this issue · 8 comments

C:\Users\...\begoneads>python begoneads.py install
Traceback (most recent call last):
File "begoneads.py", line 55, in <module>
cli()
File "C:\Python\lib\site-packages\click\core.py", line 764, in __call__
return self.main(*args, **kwargs)
File "C:\Python\lib\site-packages\click\core.py", line 717, in main
rv = self.invoke(ctx)
File "C:\Python\lib\site-packages\click\core.py", line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "C:\Python\lib\site-packages\click\core.py", line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "C:\Python\lib\site-packages\click\core.py", line 555, in invoke
return callback(*args, **kwargs)
File "begoneads.py", line 17, in install
if os.getuid() != 0:
AttributeError: module 'os' has no attribute 'getuid'

I'm working on adding Windows support as we speak. Forgot to mention it was only for Linux and MacOS at the moment.

Could you try again @Nycticorax. Windows should be working now.

Better, but you might have closed the issue a bit too early... Good luck!

C:\Users\...\begoneads>python begoneads.py install
⋯ Collecting and parsing hosts
100%|██████████████████████████████████████████████████████████████████████████████████| 13/13 [00:07<00:00,  1.72it/s]
✓ Hosts collected
⋯ Parse current hosts file
⋯ Applying new hosts
⋯ Saving
Traceback (most recent call last):
  File "begoneads.py", line 70, in <module>
    cli()
  File "C:\Python\lib\site-packages\click\core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "C:\Python\lib\site-packages\click\core.py", line 717, in main
    rv = self.invoke(ctx)
  File "C:\Python\lib\site-packages\click\core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "C:\Python\lib\site-packages\click\core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Python\lib\site-packages\click\core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "begoneads.py", line 44, in install
    hosts_manager.commit()
  File "C:\Users\...\begoneads\hostsmanager.py", line 50, in commit
    file.write(self.content.replace('\r', ''))
  File "C:\Python\lib\encodings\cp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u0262' in position 21202: character maps to <undefined>

Can you try again @Nycticorax? It should work now.

Well played sir! Windows now officially supported!

C:\Users\...\begoneads>begoneads install
⋯ Collecting and parsing hosts
100%|██████████████████████████████████████████████████████████████████████████████████| 13/13 [00:08<00:00,  3.55it/s]
✓ Hosts collected
⋯ Parse current hosts file
⋯ Applying new hosts
⋯ Saving
✓ Hosts applied

Woups, now the uninstaller fails:

C:\Users\...\begoneads>begoneads uninstall
⋯ Parse current hosts file
Traceback (most recent call last):
  File "C:\Python\Scripts\begoneads-script.py", line 11, in <module>
    load_entry_point('begoneads==0.0.3', 'console_scripts', 'begoneads')()
  File "C:\Python\lib\site-packages\click\core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "C:\Python\lib\site-packages\click\core.py", line 717, in main
    rv = self.invoke(ctx)
  File "C:\Python\lib\site-packages\click\core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "C:\Python\lib\site-packages\click\core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Python\lib\site-packages\click\core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "C:\Python\lib\site-packages\begoneads-0.0.3-py3.6.egg\begoneads\begoneads.py", line 95, in uninstall
    hosts_manager = HostsManager('/etc/hosts')
  File "C:\Python\lib\site-packages\begoneads-0.0.3-py3.6.egg\begoneads\hostsmanager.py", line 18, in __init__
    self.get_content()
  File "C:\Python\lib\site-packages\begoneads-0.0.3-py3.6.egg\begoneads\hostsmanager.py", line 23, in get_content
    file = open(self.path, 'r', encoding='utf-8')
FileNotFoundError: [Errno 2] No such file or directory: '/etc/hosts'

Also can you confirm that the host file is the only system file that begoneads meddles with?

Uninstall should now work.

Another error message. I give up.