May-17-2020, 06:44 PM
May-17-2020, 06:50 PM
Ok? Why aren't you passing those values to
__init__
then? Note that showing your code would probably help.May-17-2020, 06:57 PM
i cant show my code because it contains an IP address and it the pihole plugin that is passing to __init__
May-17-2020, 07:06 PM
If you want help you really need to provide code. It doesn't have to be THE CODE. In fact it is better if it is not THE CODE, but rather something that is shorter but still exhibits the same problem.
May-17-2020, 07:08 PM
import pihole as ph
pihole = ph.pihole('IP_Of_Pihole')
pihole = ph.pihole('IP_Of_Pihole')
May-17-2020, 07:41 PM
The example.py for pihole shows it used this way:
import asyncio import json import aiohttp from pihole import PiHole async def main(): """Get the data from a Pi-hole instance.""" async with aiohttp.ClientSession() as session: data = PiHole('192.168.0.215', loop, session) await data.get_data() # Get the raw data print(json.dumps(data.data, indent=4, sort_keys=True)) print("Status:", data.status) print("Domains being blocked:", data.domains_being_blocked) loop = asyncio.get_event_loop() loop.run_until_complete(main())Where is your loop and session?
May-17-2020, 07:46 PM
the code i sent worked and then stopped working and that how it says to use it at https://pypi.org/project/PiHole-api/
May-17-2020, 08:04 PM
Ok, grabbed the code from GitHub
class PiHole(object): <snip> # Takes in an ip address of a pihole server def __init__(self, ip_address): self.ip_address = ip_address self.auth_data = None self.refresh() self.pw = NoneThe example.py must be some older version. Now I am confused about why you didn't get an error complaining about not finding ph.pyhole since the class is named PyHole. Very interesting that your original post mentions not providing arguments for loop and session. Are you having problems running your program on some machines but not others? Is there a pihole version skew problem?
May-17-2020, 08:18 PM
it only happens on the raspberry pi, i have just tested it, in need it to run on the raspberry pi as it is linked to a breadboard
i had re-install pihole not pihole-api, all works now
i had re-install pihole not pihole-api, all works now