[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']:
|
if tools.config['syslog']:
|
||||||
# SysLog Handler
|
# SysLog Handler
|
||||||
if os.name == 'nt':
|
if os.name == 'nt':
|
||||||
handler = logging.handlers.NTEventLogHandler("%s %s" %
|
handler = logging.handlers.NTEventLogHandler("%s %s" % (release.description, release.version))
|
||||||
(release.description,
|
|
||||||
release.version))
|
|
||||||
else:
|
else:
|
||||||
handler = logging.handlers.SysLogHandler('/dev/log')
|
handler = logging.handlers.SysLogHandler('/dev/log')
|
||||||
formatter = logging.Formatter("%s %s" % (release.description, release.version) + ':%(levelname)s:%(name)s:%(message)s')
|
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
|
return pool
|
||||||
|
|
||||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||||
|
|
||||||
|
|
|
@ -25,12 +25,20 @@ import cStringIO
|
||||||
import marshal
|
import marshal
|
||||||
|
|
||||||
class Myexception(Exception):
|
class Myexception(Exception):
|
||||||
|
"""
|
||||||
|
custome exception object store
|
||||||
|
* faultcode
|
||||||
|
* faulestring
|
||||||
|
* args
|
||||||
|
"""
|
||||||
|
|
||||||
def __init__(self, faultCode, faultString):
|
def __init__(self, faultCode, faultString):
|
||||||
self.faultCode = faultCode
|
self.faultCode = faultCode
|
||||||
self.faultString = faultString
|
self.faultString = faultString
|
||||||
self.args = (faultCode, faultString)
|
self.args = (faultCode, faultString)
|
||||||
|
|
||||||
class mysocket:
|
class mysocket:
|
||||||
|
|
||||||
def __init__(self, sock=None):
|
def __init__(self, sock=None):
|
||||||
if sock is None:
|
if sock is None:
|
||||||
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
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
|
# prepare this socket for long operations: it may block for infinite
|
||||||
# time, but should exit as soon as the net is down
|
# time, but should exit as soon as the net is down
|
||||||
self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)
|
self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)
|
||||||
|
|
||||||
def connect(self, host, port=False):
|
def connect(self, host, port=False):
|
||||||
if not port:
|
if not port:
|
||||||
protocol, buf = host.split('//')
|
protocol, buf = host.split('//')
|
||||||
host, port = buf.split(':')
|
host, port = buf.split(':')
|
||||||
self.sock.connect((host, int(port)))
|
self.sock.connect((host, int(port)))
|
||||||
|
|
||||||
def disconnect(self):
|
def disconnect(self):
|
||||||
self.sock.shutdown(socket.SHUT_RDWR)
|
self.sock.shutdown(socket.SHUT_RDWR)
|
||||||
self.sock.close()
|
self.sock.close()
|
||||||
|
|
||||||
def mysend(self, msg, exception=False, traceback=None):
|
def mysend(self, msg, exception=False, traceback=None):
|
||||||
msg = cPickle.dumps([msg,traceback])
|
msg = cPickle.dumps([msg,traceback])
|
||||||
size = len(msg)
|
size = len(msg)
|
||||||
|
@ -59,6 +70,7 @@ class mysocket:
|
||||||
if sent == 0:
|
if sent == 0:
|
||||||
raise RuntimeError, "socket connection broken"
|
raise RuntimeError, "socket connection broken"
|
||||||
totalsent = totalsent + sent
|
totalsent = totalsent + sent
|
||||||
|
|
||||||
def myreceive(self):
|
def myreceive(self):
|
||||||
buf=''
|
buf=''
|
||||||
while len(buf) < 8:
|
while len(buf) < 8:
|
||||||
|
@ -89,6 +101,3 @@ class mysocket:
|
||||||
raise res[0]
|
raise res[0]
|
||||||
else:
|
else:
|
||||||
return res[0]
|
return res[0]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue