Commits

Anonymous committed 76e3837

Removed getProgName, writePID, daemonze - use circuits.app

Comments (0)

Files changed (1)

 class Error(Exception):
 	"Error Exception"
 
-
-def getProgName():
-	"""getProgName() -> str
-
-	Return the name of the current program being run
-	by working it out from the script's basename.
-	"""
-
-	return os.path.basename(sys.argv[0])
-
-
-def writePID(file):
-	"""writePID(file) -> None
-
-	Write the process-id of the currently running process
-	to the specified file. If an error occurs, Error is
-	raised.
-	"""
-
-	try:
-		fd = open(file, "w")
-		fd.write(str(os.getpid()))
-		fd.close()
-	except Exception, e:
-		raise Error("Error writing pid to %s: %s" % (file, e))
-
-
-def daemonize(stdin="/dev/null", stdout="/dev/null",
-		stderr="/dev/null", path="/"):
-	"""daemonize(stdin="/dev/null", stdout="/dev/null",
-			stderr="/dev/null", path="/") -> None
-
-	This forks the current process into a daemon.
-
-	The stdin, stdout, and stderr arguments are file names that
-	will be opened and be used to replace the standard file descriptors
-	in sys.stdin, sys.stdout, and sys.stderr. The path argument is
-	used to jail the process into the given path, defaults to /
-
-	Example:
-	{{{
-	#!python
-	if __name__ == "__main__":
-		daemonize("/dev/null", "/tmp/daemon.log",
-			"/tmp/daemon.log")
-		main()
-	}}}
-
-	Args:
-		stdin  : file to write standard input
-		stdout : file to write standard output
-		stderr : file to write standard error
-
-	These arguments are optional and default to /dev/null.
-
-	Note that stderr is opened unbuffered, so
-	if it shares a file with stdout then interleaved output
-	may not appear in the order that you expect.
-	"""
-
-	# Do first fork.
-	try:
-		pid = os.fork()
-		if pid > 0:
-			# Exit first parent
-			raise SystemExit, 0
-	except OSError, e:
-		print >> sys.stderr, "fork #1 failed: (%d) %s\n" % (
-				e.errno, e.strerror)
-		raise SystemExit, 1
-
-	# Decouple from parent environment.
-	os.chdir(path)
-	os.umask(077)
-	os.setsid()
-
-	# Do second fork.
-	try:
-		pid = os.fork()
-		if pid > 0:
-			# Exit second parent
-			raise SystemExit, 0
-	except OSError, e:
-		print >> sys.stderr, "fork #2 failed: (%d) %s\n" % (
-				e.errno, e.strerror)
-		raise SystemExit, 1
-
-	# Now I am a daemon!
-
-	# Redirect standard file descriptors.
-	si = open(os.path.abspath(os.path.expanduser(stdin)), "r")
-	so = open(os.path.abspath(os.path.expanduser(stdout)), "a+")
-	se = open(os.path.abspath(os.path.expanduser(stderr)), "a+", 0)
-	os.dup2(si.fileno(), sys.stdin.fileno())
-	os.dup2(so.fileno(), sys.stdout.fileno())
-	os.dup2(se.fileno(), sys.stderr.fileno())
-
-
 class State(object):
 	"""State() -> new state object