So im not a student computer sience per-say, but an a student getting my masters of fine art. I working on a piece of sculpture that incorporates a old mac G3 laptop and I need to ensure a persistent wireless connection. running cable isnt possible. Wireless is proving difficult given the space etc. OS X just don't seem to be able to hold onto it.
I found a bit of example code (below) but keep getting the following error
CODE
&& echo Exit status: $? && exit 1
Could really use some help, needs to be up soon and this looks to the best solution I've found.
many thanks your insight - ben
CODE
#! /usr/bin/python
import os
import time
import logging
CHECK_PERIOD_IN_SECONDS = 60
TEMPFILE = "connection-info.txt"
KEYWORD = "MyPlace"
LOGFILE = "airport-reconnect.log"
def is_connected():
# Generate connection info
os.system("/usr/sbin/airport -I >" + TEMPFILE)
# Read connection info
f = open(TEMPFILE, "r")
data = f.read()
f.close()
# Check
return KEYWORD in data
def connect(): os.system("/usr/sbin/airport -a")
logging.info("Re-connected.")
if __name__ == "__main__":
# Logger
try: os.remove(LOGFILE)
except: pass
logging.basicConfig(level=logging.DEBUG,
format='%(asctime)s %(levelname)-8s %(message)s',
filename=LOGFILE,
filemode='w')
# Loop
while True:
if not is_connected():
connect()
time.sleep(CHECK_PERIOD_IN_SECONDS)
This post has been edited by orionrush: 18 Sep, 2008 - 10:57 AM