python script problem once build and package it

Posted by Apache on Stack Overflow See other posts from Stack Overflow or by Apache
Published on 2010-04-29T07:15:33Z Indexed on 2010/05/29 7:32 UTC
Read the original article Hit count: 158

Filed under:
|
|

hi expert, I've written python script to scan wifi and send data to the server, I set interval value, so it keep on scanning and send the data, it read from config.txt file where i set the interval value to scan, I also add yes/no in my config file, so is 'no' it will scan only once and if 'yes' it will scan according to the interval level,

my code as below

import time,.....

from threading import Event, Thread

class RepeatTimer(Thread):
    def __init__(self, interval, function, iterations=0, args=[], kwargs={}):
        Thread.__init__(self)
        self.interval = interval
        self.function = function
        self.iterations = iterations
        self.args = args
        self.kwargs = kwargs
        self.finished = Event()

    def run(self):
        count = 0
        while not self.finished.is_set() and (self.iterations <= 0 or count < self.iterations):
            self.finished.wait(self.interval)
            if not self.finished.is_set():
                self.function(*self.args, **self.kwargs)
                count += 1

    def cancel(self):
        self.finished.set()

    def scanWifi(self):
        #scanning process and sending data done here


obj = JW()
if status == "yes":
    t = RepeatTimer(int(intervalTime),obj.scanWifi)
    t.start()
else:
    obj.scanWifi()

once I package my code, its only run when I set my config file set to 'no' where it scan only once, but when I set my config file to 'yes', there is no progress at all, so I found that there is problem with my class RepeatTimer(Timer) once build, but don't know how to solve

can anyone help me

thanks

© Stack Overflow or respective owner

Related posts about python

Related posts about build