481faf5f2ca51014da4ecafb1498b967e1c7220d
2 Copyright 2007-2008, Red Hat, Inc
5 This software may be freely redistributed under the terms of the GNU
6 general public license.
8 You should have received a copy of the GNU General Public License
9 along with this program; if not, write to the Free Software
10 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 REMOTE_ERROR
= "REMOTE_ERROR"
23 x
= traceback
.extract_stack()
24 bar
= string
.join(traceback
.format_list(x
))
27 def daemonize(pidfile
=None):
29 Daemonize this process with the UNIX double-fork trick.
30 Writes the new PID to the provided file name if not None.
42 if pidfile
is not None:
43 open(pidfile
, "w").write(str(pid
))
46 def nice_exception(etype
, evalue
, etb
):
48 lefti
= etype
.index("'") + 1
49 righti
= etype
.rindex("'")
50 nicetype
= etype
[lefti
:righti
]
51 nicestack
= string
.join(traceback
.format_list(traceback
.extract_tb(etb
)))
52 return [ REMOTE_ERROR
, nicetype
, str(evalue
), nicestack
]
55 fqdn
= socket
.getfqdn()
56 host
= socket
.gethostname()
57 if fqdn
.find(host
) != -1:
64 if type(result
) != list:
68 if result
[0] == REMOTE_ERROR
: