Giter VIP home page Giter VIP logo

pihole5-list-tool's People

Contributors

jessedp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pihole5-list-tool's Issues

Unable to add a list of urls from a file

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

docker not found running, continuing...
? Gravity Db to Update: /etc/pihole/gravity.db
? Add Blocklists or Allolists? Blocklists

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.

? Where are the block lists coming from? File | A file with urls of
? File to import /home/pi/Documents/blocklist.list
Traceback (most recent call last):
File "/usr/local/bin/pihole5-list-tool", line 10, in
sys.exit(main())
File "/usr/local/lib/python3.7/dist-packages/ph5lt.py", line 113, in main
process_blocklists(db_file)
File "/usr/local/lib/python3.7/dist-packages/ph5lt.py", line 156, in process_blocklists
import_list = utils.process_lines(import_file, f"File: {fname}")
File "/usr/local/lib/python3.7/dist-packages/utils.py", line 39, in process_lines
for line in data.split("\n"):
AttributeError: '_io.TextIOWrapper' object has no attribute 'split'

Error while installing on DietPi

Forms suck. But they can help a ton. Going free-form below is okay if you're certain you're providing all of the relevant information (or things aren't applicable)

Environment

Describe the system on which this issue occurred:

pihole5-list-tool 0.6.0

OS DietPi 8.3

Python 3.7.3 or 2.7.18 both same issue with pip or pip3

Using Docker? N

Issue Details

Get errors while trying to install the tool. Please see the logs below.

============================================

root@DietPi:~ sudo pip install pihole5-list-tool --upgrade
Collecting pihole5-list-tool
Using cached https://files.pythonhosted.org/packages/e0/4a/3e554deccec452a3eaa76d28f8612ec88d2c99a08f40a2b014ffbae74de0/pihole5_list_tool-0.6.0-py2.py3-none-any.whl
Collecting terminaltables (from pihole5-list-tool)
Using cached https://files.pythonhosted.org/packages/c4/fb/ea621e0a19733e01fe4005d46087d383693c0f4a8f824b47d8d4122c87e0/terminaltables-3.1.10-py2.py3-none-any.whl
Requirement already satisfied, skipping upgrade: ansicolors in /usr/local/lib/python3.7/dist-packages (from pihole5-list-tool) (1.1.8)
Collecting requests (from pihole5-list-tool)
Using cached https://files.pythonhosted.org/packages/2d/61/08076519c80041bc0ffa1a8af0cbd3bf3e2b62af10435d269a9d0f40564d/requests-2.27.1-py2.py3-none-any.whl
Collecting PyInquirer (from pihole5-list-tool)
Using cached https://files.pythonhosted.org/packages/fb/4c/434b7c454010a284b49d6f1d446fe8dc5960415613d8c0225b9e2efb6724/PyInquirer-1.0.3.tar.gz
Collecting charset-normalizer~=2.0.0; python_version >= "3" (from requests->pihole5-list-tool)
Using cached https://files.pythonhosted.org/packages/06/b3/24afc8868eba069a7f03650ac750a778862dc34941a4bebeb58706715726/charset_normalizer-2.0.12-py3-none-any.whl
Collecting certifi>=2017.4.17 (from requests->pihole5-list-tool)
Using cached https://files.pythonhosted.org/packages/37/45/946c02767aabb873146011e665728b680884cd8fe70dde973c640e45b775/certifi-2021.10.8-py2.py3-none-any.whl
Collecting urllib3<1.27,>=1.21.1 (from requests->pihole5-list-tool)
Using cached https://files.pythonhosted.org/packages/ec/03/062e6444ce4baf1eac17a6a0ebfe36bb1ad05e1df0e20b110de59c278498/urllib3-1.26.9-py2.py3-none-any.whl
Collecting idna<4,>=2.5; python_version >= "3" (from requests->pihole5-list-tool)
Using cached https://files.pythonhosted.org/packages/04/a2/d918dcd22354d8958fe113e1a3630137e0fc8b44859ade3063982eacd2a4/idna-3.3-py3-none-any.whl
Requirement already satisfied, skipping upgrade: prompt_toolkit==1.0.14 in /usr/local/lib/python3.7/dist-packages (from PyInquirer->pihole5-list-tool) (1.0.14)
Requirement already satisfied, skipping upgrade: Pygments>=2.2.0 in /usr/local/lib/python3.7/dist-packages (from PyInquirer->pihole5-list-tool) (2.12.0)
Collecting regex>=2016.11.21 (from PyInquirer->pihole5-list-tool)
Using cached https://files.pythonhosted.org/packages/b6/d9/b6971b194833ee2eccf4591f9097833b65e669cce0f8fc0ff2a118238f63/regex-2022.4.24.tar.gz
Requirement already satisfied, skipping upgrade: wcwidth in /usr/local/lib/python3.7/dist-packages (from prompt_toolkit==1.0.14->PyInquirer->pihole5-list-tool) (0.2.5)
Requirement already satisfied, skipping upgrade: six>=1.9.0 in /usr/local/lib/python3.7/dist-packages (from prompt_toolkit==1.0.14->PyInquirer->pihole5-list-tool) (1.16.0)
Building wheels for collected packages: PyInquirer, regex
Running setup.py bdist_wheel for PyInquirer ... error
Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;file='/tmp/pip-install-sp65idtw/PyInquirer/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" bdist_wheel -d /tmp/pip-wheel-6usmq1zj --python-tag cp37:
/usr/local/lib/python3.7/dist-packages/setuptools/dist.py:760: UserWarning: Usage of dash-separated 'description-file' will not be supported in future versions. Please use the underscore name 'description_file' instead
% (opt, underscore_opt)
usage: -c [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: -c --help [cmd1 cmd2 ...]
or: -c --help-commands
or: -c cmd --help

error: invalid command 'bdist_wheel'


Failed building wheel for PyInquirer
Running setup.py clean for PyInquirer
Running setup.py bdist_wheel for regex ... error
Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;file='/tmp/pip-install-sp65idtw/regex/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" bdist_wheel -d /tmp/pip-wheel-bg9azt6_ --python-tag cp37:
usage: -c [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: -c --help [cmd1 cmd2 ...]
or: -c --help-commands
or: -c cmd --help

error: invalid command 'bdist_wheel'


Failed building wheel for regex
Running setup.py clean for regex
Failed to build PyInquirer regex
Installing collected packages: terminaltables, charset-normalizer, certifi, urllib3, idna, requests, regex, PyInquirer, pihole5-list-tool
Running setup.py install for regex ... error
Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;file='/tmp/pip-install-sp65idtw/regex/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record /tmp/pip-record-y9am9g5r/install-record.txt --single-version-externally-managed --compile:
running install
/usr/local/lib/python3.7/dist-packages/setuptools/command/install.py:37: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
setuptools.SetuptoolsDeprecationWarning,
running build
running build_py
creating build
creating build/lib.linux-aarch64-cpython-37
creating build/lib.linux-aarch64-cpython-37/regex
copying regex_3/init.py -> build/lib.linux-aarch64-cpython-37/regex
copying regex_3/regex.py -> build/lib.linux-aarch64-cpython-37/regex
copying regex_3/_regex_core.py -> build/lib.linux-aarch64-cpython-37/regex
copying regex_3/test_regex.py -> build/lib.linux-aarch64-cpython-37/regex
running build_ext
building 'regex._regex' extension
creating build/temp.linux-aarch64-cpython-37
creating build/temp.linux-aarch64-cpython-37/regex_3
aarch64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python3.7m -c regex_3/_regex.c -o build/temp.linux-aarch64-cpython-37/regex_3/_regex.o
regex_3/_regex.c:50:10: fatal error: Python.h: No such file or directory
#include "Python.h"
^~~~~~~~~~
compilation terminated.
error: command '/usr/bin/aarch64-linux-gnu-gcc' failed with exit code 1

----------------------------------------

Command "/usr/bin/python3 -u -c "import setuptools, tokenize;file='/tmp/pip-install-sp65idtw/regex/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record /tmp/pip-record-y9am9g5r/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-sp65idtw/regex/

Adlist Group Management Group Selection Options

Requesting a feature to bulk assign lists added by script to Assignment Groups
image

During initial Q&A, submit each group assignment name with a checkbox allowing multi-selection, with the Default group pre-selected as per default behavior, but allowing user to unselect option if desired.

May need to consider handling duplicate/existing lists with group assignments that differ from user selection, and prompt for confirmation to overwrite the group assignments.

Issue when trying to add whitelists

Environment

pihole5-list-tool 0.4.7

OS Raspbian 10

Python 3.7.3

Using Docker? No

Issue Details

Output:

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

docker not found running, continuing...
? Gravity Db to Update:  /etc/pihole/gravity.db
? Add Blacklists or Whitelists?  Whitelists

    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.

? Where are the whitelists coming from?  AnudeepND | Whitelist+Optional :
? Add 337 white lists to /etc/pihole/gravity.db?  Yes
0 whitelists added! 1 already existed.
Traceback (most recent call last):
  File "/usr/local/bin/pihole5-list-tool", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.7/dist-packages/ph5lt.py", line 116, in main
    process_whitelists(db_file)
  File "/usr/local/lib/python3.7/dist-packages/ph5lt.py", line 234, in process_whitelists
    "SELECT COUNT(*) FROM domainlist WHERE domain = ?", (item["url"],)
sqlite3.ProgrammingError: Cannot operate on a closed cursor.

sqlite3 error

root@Pi-hole:/# pihole5-list-tool
Traceback (most recent call last):
File "/usr/local/bin/pihole5-list-tool", line 6, in
from ph5lt import main
File "/usr/local/lib/python3.7/site-packages/ph5lt.py", line 32, in
import sqlite3
File "/usr/local/lib/python3.7/sqlite3/init.py", line 23, in
from sqlite3.dbapi2 import *
File "/usr/local/lib/python3.7/sqlite3/dbapi2.py", line 27, in
from _sqlite3 import *
ModuleNotFoundError: No module named '_sqlite3'
root@Pi-hole:/# apt install libsqlite3-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
libsqlite3-dev is already the newest version (3.16.2-5+deb9u1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

Tool fails on a fresh install of Pi-Hole on a Raspberry Pi 4

Howdy,

It looks like a recent change to add auto-detection for Docker may be the cause of this, but I am not primarily a Python dev so I didn't dig super deep. If you aren't using Docker and instead installed directly on a Raspberry Pi with the latest release it fails.

    ┌──────────────────────────────────────────┐
    │       π-hole 5 list tool  v0.4.0         │
    └──────────────────────────────────────────┘
    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...
Traceback (most recent call last):
  File "/usr/local/bin/pihole5-list-tool", line 10, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.7/dist-packages/ph5lt.py", line 99, in main
    if not use_docker:
UnboundLocalError: local variable 'use_docker' referenced before assignment

Steps to Reproduce:

  1. From a fresh Raspbian 10 image, install Pi-Hole
  2. Run apt-get install python3-pip -y
  3. Run sudo pip3 install pihole5-list-tool --update
  4. Run sudo pihole5-list-tool

docker not found

Forms suck. But they can help a ton. Going free-form below is okay if you're certain you're providing all of the relevant information (or things aren't applicable)

Environment

Describe the system on which this issue occurred:

pihole5-list-tool v 0.5.0

OS v 10

Python v 3.8.0

Using Docker? Y
.....version 19.03.12

Issue Details

Briefly explain the issue and provide any pertinent stack traces, environment, etc.

when running command

sudo pihole5-list-tool

I get a message:

docker not found running, continuing....
gravity to update: /etc/pihole/gravity.db'

Then nothing else

SQLite error after attempting to add blocklists using $sudo pihole5-list-tool

After the installs and a few restarts I just can't get around this error.

`Traceback (most recent call last):
File "/usr/local/bin/pihole5-list-tool", line 10, in sys.exit(main())

File "/usr/local/lib/python3.7/dist-packages/ph5lt.py", line 95, in main process_blacklists(db_file)

File "/usr/local/lib/python3.7/dist-packages/ph5lt.py", line 140, in process_blacklists conn = sqlite3.connect(db_file)

sqlite3.OperationalError: unable to open database file
`
At first I tried the /etc/pihole/gravity.db path just to see if it would work because my install is on a docker image, it didnt. So I tried to direct it to the path I have /etc/pihole bound to which is /srv/disk-by-label-MEDIASERVER/appdata/pihole. I run an OpenMediaVault(v5) server using docker images for my media and pihole.

Here is a screenshot as well: https://i.imgur.com/mmEdhyA.png

According to your install guide I am sure I have the correct versions of the necessary software. Pihole works just fine I just get that error trying to use your tool.

Thanks in advance!

Expand to Support Whitelist(s)

It would be great if this script could also handle whitelists also. Additionally, if it could support the importing of the white and blacklist regex lists too, even better.

Thanks for a great script!

Downgrade list

Is there any way to change lists? I’m finding too many things are being blocked on I want to move back to the ticked list. When I re run the program it doesn’t remove the old list. Any help is greatly appreciated!

getting error

when I run sudo pihole5-list-tool I get this error:

Traceback (most recent call last): File "/usr/local/bin/pihole5-list-tool", line 10, in <module> sys.exit(main()) File "/usr/local/lib/python3.7/dist-packages/ph5lt.py", line 82, in main print(color(' \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510', fg='#b61042')) File "/usr/lib/python3.7/encodings/iso8859_15.py", line 19, in encode return codecs.charmap_encode(input,self.errors,encoding_table)[0] UnicodeEncodeError: 'charmap' codec can't encode characters in position 21-64: character maps to <undefined>

Parsing of Entry on Firebog List

Forms suck. But they can help a ton. Going free-form below is okay if you're certain you're providing all of the relevant information (or things aren't applicable)

Environment

Describe the system on which this issue occurred:

Version 0.6.0

Ubuntu 20.04.1 LTS

Python 3.8.5

Using Docker? N

Issue Details

I noticed that your tool is parsing an entry on the Firebog list incorrectly. The entry is https://raw.githubusercontent.com/Kees1958/W3C_annual_most_used_survey_blocklist/master/TOP_EU_US_Ads_Trackers_HOST but it shows up as https://github.com/Kees1958/W3C_annual_most_used_survey_blocklist/blob/master/TOP_EU_US_Ads_Trackers_HOST in Pi-Hole.

running sudo pihole5-list-tool gives an error

Forms suck. But they can help a ton. Going free-form below is okay if you're certain you're providing all of the relevant information (or things aren't applicable)

Environment

Describe the system on which this issue occurred: ubuntu 20.04

pihole5-list-tool (ex: 0.4.2, pip3 show pihole5-list-tool) :0.5.0

OS (ex: Ubuntu 20.20, lsb_release -a) :Ubuntu 20.04

Python (ex: 3.8.2, python --version) :3.8.2

Using Docker? Y/N
.....version (ex: 19.03.10, docker -v) :N

Issue Details

When I run sudo pihole5-list-tool it throws an error.

Expected behavior
To give the install screen. I've used this on 2 other devices and it's worked fine

Actual behavior
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/dist-packages/ph5lt.py", line 84, in main print(color(" \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510", fg="#b61042")) UnicodeEncodeError: 'latin-1' codec can't encode characters in position 21-64: ordinal not in range(256)

Supporting details
Attach or paste in stack traces, screenshots, and the such...

Anything else
Anything else you feel is valuable that wasn't asked for?

Issue with python3.10 - Maybe a dependecy issue rather than a pihole5-list-tool issue

Hello

I noticed that the script stopped working recently and I have traced this back to an update in python version.

Traceback (most recent call last):
File "/usr/local/bin/pihole5-list-tool", line 5, in
from ph5lt import main
File "/usr/local/lib/python3.10/dist-packages/ph5lt.py", line 34, in
import prompts
File "/usr/local/lib/python3.10/dist-packages/prompts.py", line 4, in
from PyInquirer import prompt, Validator, ValidationError, Separator
File "/usr/local/lib/python3.10/dist-packages/PyInquirer/init.py", line 6, in
from prompt_toolkit.token import Token
File "/usr/local/lib/python3.10/dist-packages/prompt_toolkit/init.py", line 16, in
from .interface import CommandLineInterface
File "/usr/local/lib/python3.10/dist-packages/prompt_toolkit/interface.py", line 19, in
from .application import Application, AbortAction
File "/usr/local/lib/python3.10/dist-packages/prompt_toolkit/application.py", line 8, in
from .key_binding.bindings.basic import load_basic_bindings
File "/usr/local/lib/python3.10/dist-packages/prompt_toolkit/key_binding/bindings/basic.py", line 9, in
from prompt_toolkit.renderer import HeightIsUnknownError
File "/usr/local/lib/python3.10/dist-packages/prompt_toolkit/renderer.py", line 11, in
from prompt_toolkit.styles import Style
File "/usr/local/lib/python3.10/dist-packages/prompt_toolkit/styles/init.py", line 8, in
from .from_dict import *
File "/usr/local/lib/python3.10/dist-packages/prompt_toolkit/styles/from_dict.py", line 9, in
from collections import Mapping
ImportError: cannot import name 'Mapping' from 'collections' (/usr/lib/python3.10/collections/init.py)

I am not a python expert, however from a bit of research it looks like Python3.10 has removed a deprecated feature to do with Collections:
https://docs.python.org/3.9/library/collections.html#module-collections

Deprecated since version 3.3, will be removed in version 3.10: Moved Collections Abstract Base Classes to the collections.abc module. For backwards compatibility, they continue to be visible in this module through Python 3.9.

I fixed the issue by the editing the named from_dict.py file and replacing:

from collections import Mapping
with
from collections.abc import Mapping

Again, I'm not an expert with Python, so I don't know if this is something that you can fix or if it is an issue with a dependency, however this may prove useful to someone else if they have the same issue.

This is a super useful tool, so thanks for creating it.
Many Thanks

error when running 'sudo pihole5-list-tool'

Hello jessedp, I'm having an error appear when trying to run your tool. I'm using a raspberry pi 4 on the latest version of raspbian (buster). I followed the instruction in your post for installation which reported fine, then when trying to run the tool I get the following:

Traceback (most recent call last): File "/usr/local/bin/pihole5-list-tool", line 10, in <module> sys.exit(main()) File "/usr/local/lib/python3.7/dist-packages/ph5lt.py", line 82, in main print(color(' \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510', fg='#b61042')) UnicodeEncodeError: 'latin-1' codec can't encode characters in position 21-64: ordinal not in range(256)

Seen this before? I will admit I know nothing of programming, and am a basic linux user. I followed many guides to get pi-hole 5 up and running and any help you can offer on this issue would be awesome. Thank you very much!

Won't accept Python version

Environment

Describe the system on which this issue occurred:
pihole5-list-tool (ex: 0.4.2, pip3 show pihole5-list-tool) :
OS (ex: Ubuntu 20.20, lsb_release -a) : Rasbpian 9.11
Python (ex: 3.8.2, python --version) : 3.8.0
Using Docker? No
.....version (ex: 19.03.10, docker -v) :

Hi all,

So running Python -V gives "Python 3.8.0" but running sudo pip3 install pihole5-list-tool --upgrade produces "this tool requires 3.6 or greater, you are running 3.5.3". What am I doing wrong? I've just upgraded, followed the guide here: https://installvirtual.com/how-to-install-python-3-8-on-raspberry-pi-raspbian/ rebooted and it's still not showing the correct version?

Installation Failure with Docker and Portainer

Hello, I use openmediavault with portainer and docker. And try to install the pihole adlist tool via docker exec -it pihole. I had to install python3.8, but then I get the error when I run the command. Is there a guide or help?

root@Pihole:/usr/bin/Python-3.8.2# pip install --upgrade setuptools
Requirement already up-to-date: setuptools in /usr/local/lib/python3.8/site-packages (47.1.1)

root@Pihole:/usr/bin/Python-3.8.2# sudo python3.8 -m pip install pihole5-list-tool
Collecting pihole5-list-tool
Using cached pihole5_list_tool-0.4.2-py2.py3-none-any.whl (10 kB)
Collecting PyInquirer
Using cached PyInquirer-1.0.3.tar.gz (27 kB)
ERROR: Command errored out with exit status 1:
command: /usr/local/bin/python3.8 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-vb0rpesu/PyInquirer/setup.py'"'"'; file='"'"'/tmp/pip-install-vb0rpesu/PyInquirer/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-kffb6gdg
cwd: /tmp/pip-install-vb0rpesu/PyInquirer/
Complete output (11 lines):
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python3.8/site-packages/setuptools/init.py", line 19, in
from setuptools.dist import Distribution
File "/usr/local/lib/python3.8/site-packages/setuptools/dist.py", line 34, in
from setuptools import windows_support
File "/usr/local/lib/python3.8/site-packages/setuptools/windows_support.py", line 2, in
import ctypes
File "/usr/local/lib/python3.8/ctypes/init.py", line 7, in
from _ctypes import Union, Structure, Array
ModuleNotFoundError: No module named '_ctypes'
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

pihole5-list tool command error on pi model 4b

Hi,

Im on a pi model 4b and getting an error if i try to execude the pihole5-list tool command:

Traceback (most recent call last):
File "/usr/local/bin/pihole5-list-tool", line 10, in
sys.exit(main())
File "/usr/local/lib/python3.7/dist-packages/ph5lt.py", line 84, in main
print(color(" \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u25
00\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u250
0\u2500\u2500\u2510", fg="#b61042"))
UnicodeEncodeError: 'latin-1' codec can't encode characters in position 21-64: ordinal not in range(256)

PiHole Docker Python 3.5

Hi i have installed PiHole docker and have been trying to get your script to work with no luck.

The docker image comes with python3.5 install as standard yet your script requires python3.6+, so i have installed python3.6 via source and then i have issues with the application able to install but not run due to errors such as ascii etc.

Any info would help just about to reinstall a clean pihole docker image right now to fix the issue of a broken os.

PiHole Docker's os is debian 9 stretch.

[Solved]

I managed to solve the issue, as to make it easier for everyone else i have created a simple bash script to do all the work.

https://github.com/solidus1983/pihole-docker-python3.7-install

Removing lists from database

Is your feature request related to a problem? Please describe.
Frustrated that when I'm on the command line, I can no longer manage lists of hosts in the gravity databases.

Describe the solution you'd like
Add a feature to the tool to delete files same way they were added.

Describe alternatives you've considered
Using the web server is not always an option for example when other web servers are already running. And they just complicate stuff.

Abnormal termination when trying to paste Blocklist

Environment

pihole5-list-tool 0.6.1 :

OS Raspbian GNU/Linux 11 (bullseye) :

Python 3.9.2 :

Using Docker? Y
.....version 20.10.22 :

Issue Details

When I perform the following operations,
Manage Blocklists -> add a list -> Paste | Paste urls of lists, 1 per line - opens editor, save, close
The Stack trace described below will be displayed and the program will terminate abnormally.

Supporting details

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/InquirerPy/resolver.py", line 213, in prompt
    result[question_name] = question_mapping[question_type](
KeyError: 'editor'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/pihole5-list-tool", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.9/dist-packages/ph5lt/app.py", line 75, in main
    save = blocklists.manage_blocklists(cur)
  File "/usr/local/lib/python3.9/dist-packages/ph5lt/blocklists.py", line 65, in manage_blocklists
    return add(cur)
  File "/usr/local/lib/python3.9/dist-packages/ph5lt/blocklists.py", line 98, in add
    import_list = prompts.ask_paste()
  File "/usr/local/lib/python3.9/dist-packages/ph5lt/prompts.py", line 233, in ask_paste
    result = key_prompt(questions)
  File "/usr/local/lib/python3.9/dist-packages/ph5lt/prompts.py", line 45, in key_prompt
    resp = prompt(questions)
  File "/usr/local/lib/python3.9/dist-packages/InquirerPy/resolver.py", line 217, in prompt
    raise RequiredKeyNotFound
InquirerPy.exceptions.RequiredKeyNotFound: required key not found

Anything else
The problem appears to be caused by the migration from PyInquirer to InquirerPy in response to issue #37.
InquirerPy does not currently support the editor prompt.

Migrating from PyInquirer - EditorPrompt

Best regards.

Dev requrements in separate file

Consider moving development dependencies to separate requirements-dev.txt file. Or even better try to use Poetry with .toml config - it will help you to keep dependencies and linter/formatters settings in one place.

Install doc Suggestion

Great work first off!
Might I add a little note for the install? Some folks, like me, didn't install python3, so pip3 doesn't work.

Perhaps add the dependency should be installed?
apt install python3-pip -y

Now you might wonder why in the world wouldn't I install python? Because I'm a perlmonk and love to code things which makes others go "hmmmmm?"

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

    ┌──────────────────────────────────────────┐
    │       π-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

Auto-updating whitelist with this tool?

Previously I used anudeepND's whitelist repo until I stumbled upon this tool and have been using it since. However, I've come to question whether or not updating gravity also updates the whitelist?

When using anudeepND's, he provides a script to update the whitelists, but there's no option to update here. pihole -g won't update the whitelist lists, right? So are we intended to re-add the lists with the tool? If so, could you perhaps add a feature to colorize the existing added selected default lists? Would be nice in case down the line we ever forgot which we initially added.

sudo pip3 install pihole5-list-tool --upgrade results in error

I tried to install but the result is the following. Am I missing something?

Collecting pihole5-list-tool
Using cached https://files.pythonhosted.org/packages/e0/3b/2e8d086b316737a94aca9c787978adee23a79561a6bdeb4965dd5706a50c/pihole5_list_tool-0.4.2-py2.py3-none-any.whl
Requirement already satisfied, skipping upgrade: requests in /usr/lib/python3/dist-packages (from pihole5-list-tool) (2.21.0)
Collecting ansicolors (from pihole5-list-tool)
Using cached https://files.pythonhosted.org/packages/53/18/a56e2fe47b259bb52201093a3a9d4a32014f9d85071ad07e9d60600890ca/ansicolors-1.1.8-py2.py3-none-any.whl
Collecting PyInquirer (from pihole5-list-tool)
Using cached https://files.pythonhosted.org/packages/fb/4c/434b7c454010a284b49d6f1d446fe8dc5960415613d8c0225b9e2efb6724/PyInquirer-1.0.3.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "", line 1, in
ModuleNotFoundError: No module named 'setuptools'

----------------------------------------

Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-mqie3vux/PyInquirer/

script hangs after printing the gravity db to update

I'm using a Pi 3 Model B with debian version 10.4, pihole5-list-tool version 0.4.5, python 3.7, not using docker.

when I start the script with 'sudo pihole5-list-tool' it gives the following output, and hangs for 10+ minutes. cpu and memory use are .1% and 2.2% respectively, which doesn't seem out of the ordinary to me.

┌──────────────────────────────────────────┐
│ π-hole 5 list tool v0.4.5 │ └──────────────────────────────────────────┘
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

Docker Friendly Script

Is it possible to build a Docker friendly script that could be added to a Dockerfile, so your tool is incorporated into a custom Pihole image build?

Ask User to automatically enable imported Black-/Whitelists if disabled ?

Hi jessedp,

I was able to import new blacklists successfully, but for existing blacklists that I had deactivated in the past, there was no request to activate them.

I do not recognize which of them are deactivated during import.

Would it be a big programming effort to show the user deactivated blacklists and ask the user if he wants to activate the already existing blacklist if it is deactivated?

┌──────────────────────────────────────────┐
│       π-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 90 block lists to /etc/pihole/gravity.db?  Yes
15 block lists added! 75 already existed.

Feature request for more detailed comments fields.

For example.. I just used this tool to import the "Non-crossed" list.
All of the comments fields are the same "Firebog | Non-crossed".
It would be nice if the ones which are also in the "Ticked" list showed as "Firebog | Ticked" instead, so I can tell them apart.

I'm just thinking that if I ever have an issue and need to whitelist, it will be useful to know if the list containing the site I am working on is Ticked or Non-Crossed.

I think I can probably get what I want by deleting them, and then re-running the tool twice. Once to add the Ticked list, and then again to add the Non-crossed list. (I'll give that a try next).

Whitelist tool added individual letters as regex whitelists instead of domains

It's a bit hard do explain, so I have this screenshot to convey what I mean.

image

It seems like the first 9 characters of the first domain on the anudeepND's whitelist were split into separate regex whitelists and the rest, I'm not sure where it comes from.

I doubt this is normal.

Here are my versions:

  • Pi-hole v5.0
  • AdminLTE v5.0
  • FTL v5.0
  • Python v3.7.3
  • pip v18.1
  • Pi-hole 5 List Tool v0.4.4

Any ideas?

Missing Python module requests had to be installed

I installed Python3 and pip3 on a Raspberry Pi Zero with Linux distro DietPi.
Following the instructions on your GitHub page and running sudo pihole5-list-tool I got an error message about missing Python module requests. After installing that with sudo pip3 install requests everything worked like a charm.
Perhaps you want to add a line to the section requirements?

Docker image pihole/pihole

Environment

Describe the system on which this issue occurred:

pihole5-list-tool (ex: 0.4.2, pip3 show pihole5-list-tool) :
π-hole 5 list tool v0.5.1

OS (ex: Ubuntu 20.20, lsb_release -a) :
Distributor ID: Raspbian
Description: Raspbian GNU/Linux 10 (buster)
Release: 10
Codename: buster

Python (ex: 3.8.2, python --version) :
Python 2.7.16

Using Docker? Y/N
.....version (ex: 19.03.10, docker -v) :
Docker version 19.03.12, build 48a6621

Hi,

I tried out your list tool for pihole, but had some issues, it's more user support than bugs.

  1. Firstly, it did not find my docker instance. Which for me is: pihole/pihole:latest, so in my case the command docker inspect pihole/pihole is required. I am a noob, so may have set up docker incorrectly via Portainer. If I am not the only one, it might be nice to add this as a fallback.

  2. Since I am using docker I know the location of my config (user data). I wondered if there was a way to provide the path to the gravity.db file. After running the command I saw I could edit the path. Cool!

  3. Not sure what the last step is (see trace below), i assume the gravity update, but it failed. Same docker issue? i.e. should update it, but doesn't know about it. I did the update via the UI. No big deal.

Thanks a lot for the program, just some feedback....

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

docker not found running, continuing...
? Gravity Db to Update:  gravity.db
? Add Blocklists or Allowlists?  Blocklists

    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.

? Where are the block lists coming from?  Firebog | Non-crossed lists : Use when someone is usually around to allow
? Add 48 block lists to gravity.db?  Yes
0 block lists added! 48 already existed.
? Update Gravity for immediate effect?  Yes

sh: 1: pihole: not found

"unable to find config for running docker pihole image, continuing..." even when pihole is running on docker

Environment

Describe the system on which this issue occurred:

pihole5-list-tool: 0.4.5

OS: Raspbian GNU/Linux 10 (buster)

Python: Python 3.7.3

Using Docker? Y
.....version: 19.03.11, build 42e35e6

Issue Details

Briefly explain the issue and provide any pertinent stack traces, environment, etc.
The tool warns "unable to find config for running docker pihole image, continuing..." even though pihole image is running as a docker container with the name "pihole"

Expected behavior
Should detect docker image, and populate the gravity DB path.

Actual behavior
Throws a warning and falls back to "/etc/pihole/gravity.db"

Supporting details
After running docker inspect pihole, the script looks for mounted volumes and performs an exact-match with "/etc/pihole" at https://github.com/jessedp/pihole5-list-tool/blob/master/utils.py#L110

The volume can be mounted as "/etc/pihole/" and which fails this check, returning a warning.
parts[1].startswith("/etc/pihole") should fix this issue.

Anything else
Thanks for making this awesome tool <3

Error running 0.4.1

Hello,
I tried to install it in lubuntu running pihole 5 but it fails like this
` ┌──────────────────────────────────────────┐
│ π-hole 5 list tool v0.4.1 │
└──────────────────────────────────────────┘
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.

Traceback (most recent call last):
File "/usr/local/bin/pihole5-list-tool", line 11, in
sys.exit(main())
File "/usr/local/lib/python3.6/dist-packages/ph5lt.py", line 92, in main
docker = utils.find_docker()
File "/usr/local/lib/python3.6/dist-packages/utils.py", line 74, in find_docker
result = subprocess.run(["docker", "inspect", "pihole"], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, text=True, check=True)
File "/usr/lib/python3.6/subprocess.py", line 423, in run
with Popen(*popenargs, **kwargs) as process:
TypeError: init() got an unexpected keyword argument 'text'`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.