persistent wireless connection using Python

Artist trying to cobble together some scrips

Page 1 of 1

0 Replies - 946 Views - Last Post: 18 September 2008 - 11:39 AM Rate Topic: -----

#1 orionrush  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 11-April 08

persistent wireless connection using Python

Post icon  Posted 18 September 2008 - 11:39 AM

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
&& 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


#! /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 September 2008 - 11:57 AM


Is This A Good Question/Topic? 0
  • +

Page 1 of 1