[REVIEW]: code formatting and add comment
* remove tabs and place space(4) bzr revid: mga@mga-20100311055133-cftf0r5zuya3uax8
This commit is contained in:
parent
1c2abb3388
commit
44b340bf91
|
@ -151,9 +151,7 @@ def init_logger():
|
|||
if tools.config['syslog']:
|
||||
# SysLog Handler
|
||||
if os.name == 'nt':
|
||||
handler = logging.handlers.NTEventLogHandler("%s %s" %
|
||||
(release.description,
|
||||
release.version))
|
||||
handler = logging.handlers.NTEventLogHandler("%s %s" % (release.description, release.version))
|
||||
else:
|
||||
handler = logging.handlers.SysLogHandler('/dev/log')
|
||||
formatter = logging.Formatter("%s %s" % (release.description, release.version) + ':%(levelname)s:%(name)s:%(message)s')
|
||||
|
|
|
@ -81,4 +81,3 @@ def get_pool(db_name, force_demo=False, status=None, update_module=False):
|
|||
return pool
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
|
|
|
@ -25,12 +25,20 @@ import cStringIO
|
|||
import marshal
|
||||
|
||||
class Myexception(Exception):
|
||||
"""
|
||||
custome exception object store
|
||||
* faultcode
|
||||
* faulestring
|
||||
* args
|
||||
"""
|
||||
|
||||
def __init__(self, faultCode, faultString):
|
||||
self.faultCode = faultCode
|
||||
self.faultString = faultString
|
||||
self.args = (faultCode, faultString)
|
||||
|
||||
class mysocket:
|
||||
|
||||
def __init__(self, sock=None):
|
||||
if sock is None:
|
||||
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
|
@ -40,14 +48,17 @@ class mysocket:
|
|||
# prepare this socket for long operations: it may block for infinite
|
||||
# time, but should exit as soon as the net is down
|
||||
self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)
|
||||
|
||||
def connect(self, host, port=False):
|
||||
if not port:
|
||||
protocol, buf = host.split('//')
|
||||
host, port = buf.split(':')
|
||||
self.sock.connect((host, int(port)))
|
||||
|
||||
def disconnect(self):
|
||||
self.sock.shutdown(socket.SHUT_RDWR)
|
||||
self.sock.close()
|
||||
|
||||
def mysend(self, msg, exception=False, traceback=None):
|
||||
msg = cPickle.dumps([msg,traceback])
|
||||
size = len(msg)
|
||||
|
@ -59,6 +70,7 @@ class mysocket:
|
|||
if sent == 0:
|
||||
raise RuntimeError, "socket connection broken"
|
||||
totalsent = totalsent + sent
|
||||
|
||||
def myreceive(self):
|
||||
buf=''
|
||||
while len(buf) < 8:
|
||||
|
@ -89,6 +101,3 @@ class mysocket:
|
|||
raise res[0]
|
||||
else:
|
||||
return res[0]
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue