def init(stopfile=None, statusfile=None, freq=1): """ <Purpose> Prepares the module to run. <Arguments> stopfile: The name of the stopfile to check for. Set to None to disable checking for a stopfile. statusfile: The filename prefix for writing out our status. Set to None to disable a status file freq: The frequency of checks for the stopfile and status updates. 1 second is default. """ global stopfilename, statusfilename_prefix, frequency # Check for the stopfile if stopfile != None and os.path.exists(stopfile): raise Exception, "Stop file already exists! File:"+stopfile # Assign the values stopfilename = stopfile statusfilename_prefix = statusfile frequency = freq # Initialize statusstorage statusstorage.init(statusfilename_prefix)
def init(stopfile=None, statusfile=None, freq=1): """ <Purpose> Prepares the module to run. <Arguments> stopfile: The name of the stopfile to check for. Set to None to disable checking for a stopfile. statusfile: The filename prefix for writing out our status. Set to None to disable a status file freq: The frequency of checks for the stopfile and status updates. 1 second is default. """ global stopfilename, statusfilename_prefix, frequency # Check for the stopfile if stopfile != None and os.path.exists(stopfile): raise Exception, "Stop file already exists! File:" + stopfile # Assign the values stopfilename = stopfile statusfilename_prefix = statusfile frequency = freq # Initialize statusstorage statusstorage.init(statusfilename_prefix)
def _stopfile_exit(exitcode, pid): # On Windows, we are in the Repy process, so we can just use harshexit if harshexit.ostype in ["Windows", "WindowsCE"]: # Harshexit will store the appriopriate status for us harshexit.harshexit(exitcode) else: # On NIX we are on the external process try: if exitcode == 44: # Write out status information, repy was Stopped statusstorage.write_status("Stopped") else: # Status terminated statusstorage.write_status("Terminated") except: pass # Disable the other status thread, in case the resource thread detects we've killed repy statusstorage.init(None) # Kill repy harshexit.portablekill(pid) # Fix Derek proposed, this should solve the problem of # the monitor exiting before the repy process. time.sleep(1) # Exit harshexit.harshexit(78)