AnswerBun.com

python program for wifi connected devices

Stack Overflow Asked by Utkarsh Trivedi on September 5, 2020

I saw this interesting idea from Kalle Hallden’s video. It is about alerting you when someone’s IP connects to the network

import sys
import subprocess
import os
from decouple import config

IP_NETWORK = config('IP_NETWORK')
IP_DEVICE = config('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", "Linnea just connected to the network"])

Error

Traceback (most recent call last):
  
File "C:UsersutkarDownloadsnet-listen.py", line 6, in <module>
    IP_NETWORK = config('IP_NETWORK')
  
File "C:UsersutkarAppDataLocalProgramsPythonPython38-32libsite-packagesdecouple.py", line 199, in __call__
    return self.config(*args, **kwargs)
  
File "C:UsersutkarAppDataLocalProgramsPythonPython38-32libsite-packagesdecouple.py", line 83, in __call__
    return self.get(*args, **kwargs)
  
File "C:UsersutkarAppDataLocalProgramsPythonPython38-32libsite-packagesdecouple.py", line 68, in get
    
raise UndefinedValueError('{} not found. Declare it as envvar or define a default value.'.format(option))
decouple.UndefinedValueError: IP_NETWORK not found. Declare it as envvar or define a default value.


Process returned 1 (0x1)        execution time : 0.150 s
Press any key to continue . . .

One Answer

Seems like you forgot to setup a settings.ini. It should look something like this:

[settings]
IP_Network=YOUR NETWORK IP
IP_DEVICE=YOUR DEVICE IP

Answered by Sumajo on September 5, 2020

Add your own answers!

Related Questions

DASK can’t recognize workers on EMR

0  Asked on December 25, 2021 by cphoenix

         

Use external help file for C# programmed powershell cmdlet

0  Asked on December 25, 2021 by rivers-shall

     

Generate lexicographic permutations

2  Asked on December 23, 2021 by vishnu-prakash

     

How can i add a black layer over top of image with opacity?

3  Asked on December 23, 2021 by user13851719

   

How to add function to onChange in Input cmponent?

2  Asked on December 23, 2021 by will-black

       

Global variable to available

3  Asked on December 23, 2021 by havard-kleven

     

Integrating HTML pages to laravel

3  Asked on December 23, 2021 by user11195802

       

Run a counter in the background

1  Asked on December 23, 2021 by legacy-coding

   

Read from .csv, calculate, write on .csv

2  Asked on December 23, 2021 by irham-dollah

         

How to synchronize data between threads

2  Asked on December 23, 2021 by summit

     

Output is not as expected

3  Asked on December 23, 2021 by a4n

   

AWS Lambda query to Redshift once a day

2  Asked on December 23, 2021 by xbeta

         

Ask a Question

Get help from others!

© 2022 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP, SolveDir