KalleHallden / reddit_automations

318 stars 91 forks source link

net-listen.py not working #5

Open Nerez5k opened 4 years ago

Nerez5k commented 4 years ago

app.py: `import sys import subprocess import os from decouple import config from dotenv import load_dotenv from pathlib import Path load_dotenv()

env_path = Path('.') / '.env' load_dotenv(dotenv_path=env_path)

IP_NETWORK = os.getenv("IP_NETWORK") IP_DEVICE = os.getenv("IP_DEVICE")

proc = subprocess.Popen(["ping", IP_NETWORK],stdout=subprocess.PIPE) while True: line = proc.stdout.readline() if not line: break

the real code does filtering here

connected_ip = line.decode('utf-8').split()[3]

if connected_ip == IP_DEVICE: subprocess.Popen(["say", "Working!"])`

.env: IP_NETWORK=192.168.5.1 IP_DEVICE=192.168.5.3:

and im getting error: Traceback (most recent call last): File "app.py", line 21, in <module> connected_ip = line.decode('utf-8').split()[3] IndexError: list index out of range

3centroids commented 3 years ago

Duplicate See: #1