jessedp / pihole5-list-tool

A tool for quickly and easily bulk adding allow and ad/block lists to a Pi-hole 5 installation
MIT License
312 stars 18 forks source link

AttributeError: '_io.TextIOWrapper' object has no attribute 'strip' #11

Closed MexSalem closed 4 years ago

MexSalem commented 4 years ago
    ┌──────────────────────────────────────────┐
    │       π-hole 5 list tool  v0.4.2         │
    └──────────────────────────────────────────┘
    https://github.com/jessedp/pihole5-list-tool

    Do not hit ENTER or Y if a step seems to hang!
    Use CTRL+C if you're sure it's hung and report it.

docker pihole image not found running, continuing...
? Gravity Db to Update:  /etc/pihole/gravity.db
? Add Blacklists or Whitelists?  Blacklists
? Where are the block lists coming from?  File    | A file with urls of lists, 1
? File to import  /home/neo/RPIList.txt
Traceback (most recent call last):
  File "/usr/local/bin/pihole5-list-tool", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.8/site-packages/ph5lt.py", line 106, in main
    process_blacklists(db_file)
  File "/usr/local/lib/python3.8/site-packages/ph5lt.py", line 146, in process_blacklists
    import_list = utils.process_lines(import_file, f'File: {fname}')
  File "/usr/local/lib/python3.8/site-packages/utils.py", line 38, in process_lines
    for line in data.strip().split("\n"):
AttributeError: '_io.TextIOWrapper' object has no attribute 'strip'

I wanted to use a text file as basis for the blacklist import. The structure of the text file is as follows:

$ cat /home/neo/RPIList.txt
https://raw.githubusercontent.com/RPiList/specials/master/Blocklisten/notserious
https://raw.githubusercontent.com/RPiList/specials/master/Blocklisten/Streaming
https://raw.githubusercontent.com/RPiList/specials/master/Blocklisten/Phishing-Angriffe
https://raw.githubusercontent.com/RPiList/specials/master/Blocklisten/spam.mails
jessedp commented 4 years ago

v0.4.3 fixes this. That was another bad error that I'd caught with the tests I haven't finished. Thank you for your patience and the assistance on other issues.

MexSalem commented 4 years ago

Thank you for fast fixing this issue. Now it's working. Thank you for sharing your code!

$ sudo pip3 install pihole5-list-tool --upgrade ... Successfully installed pihole5-list-tool-0.4.3 $ sudo pihole5-list-tool

   ┌──────────────────────────────────────────┐
    │       π-hole 5 list tool  v0.4.3         │
    └──────────────────────────────────────────┘
    https://github.com/jessedp/pihole5-list-tool

    Do not hit ENTER or Y if a step seems to hang!
    Use CTRL+C if you're sure it's hung and report it.

docker pihole image not found running, continuing...
? Gravity Db to Update:  /etc/pihole/gravity.db
? Add Blacklists or Whitelists?  Blacklists
? Where are the block lists coming from?  File    | A file with urls of lists, 1 per line
? File to import  /home/neo/RPIList.txt
? Add 17 block lists to /etc/pihole/gravity.db?  Yes
17 block lists added! 0 already existed.
? Update Gravity for immediate effect?  Yes