Welcome to Dream.In.Code
Getting Help is Easy!

Join 136,825 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,919 people online right now. Registration is fast and FREE... Join Now!




persistent wireless connection using Python

 
Reply to this topicStart new topic

persistent wireless connection using Python, Artist trying to cobble together some scrips

orionrush
18 Sep, 2008 - 10:39 AM
Post #1

New D.I.C Head
*

Joined: 11 Apr, 2008
Posts: 2

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
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/3/08 03:28PM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month