Refactor name of server for each stack to .server since udp or uxd is redundant as the type is

determined by the stack
This commit is contained in:
Samuel M Smith 2014-03-10 11:35:09 -06:00
parent 830e5fd2d5
commit 712792cba2
8 changed files with 41 additions and 40 deletions

View File

@ -117,7 +117,7 @@ class CloserStackUdpRaet(deeding.Deed): # pylint: disable=W0232
Close udp socket
'''
if self.stack.value and isinstance(self.stack.value, stacking.StackUdp):
self.stack.value.serverUdp.close()
self.stack.value.server.close()
class JoinerStackUdpRaet(deeding.Deed): # pylint: disable=W0232
'''
@ -312,7 +312,7 @@ class CloserStackUxdRaet(deeding.Deed): # pylint: disable=W0232
Close uxd socket
'''
if self.stack.value and isinstance(self.stack.value, stacking.StackUxd):
self.stack.value.serverUxd.close()
self.stack.value.server.close()
class AddYardStackUxdRaet(deeding.Deed): # pylint: disable=W0232
'''

View File

@ -91,9 +91,9 @@ class StackUdp(object):
main=main,
ha=ha)
self.estate.stack = self
self.serverUdp = aiding.SocketUdpNb(ha=self.estate.ha, bufsize=raeting.MAX_MESSAGE_SIZE)
self.serverUdp.reopen() # open socket
self.estate.ha = self.serverUdp.ha # update estate host address after open
self.server = aiding.SocketUdpNb(ha=self.estate.ha, bufsize=raeting.MAX_MESSAGE_SIZE)
self.server.reopen() # open socket
self.estate.ha = self.server.ha # update estate host address after open
self.dumpLocal() # save local estate data
kepts = self.loadAllRemote() # remote estates from saved data
@ -326,17 +326,17 @@ class StackUdp(object):
'''
Service the UDP receive and transmit queues
'''
if self.serverUdp:
if self.server:
while True:
rx, ra = self.serverUdp.receive() # if no data the duple is ('',None)
rx, ra = self.server.receive() # if no data the duple is ('',None)
if not rx: # no received data so break
break
# triple = ( packet, source address, destination address)
self.udpRxes.append((rx, ra, self.serverUdp.ha))
self.udpRxes.append((rx, ra, self.server.ha))
while self.udpTxes:
tx, ta = self.udpTxes.popleft() # duple = (packet, destination address)
self.serverUdp.send(tx, ta)
self.server.send(tx, ta)
return None
@ -351,13 +351,13 @@ class StackUdp(object):
UDP Socket send
'''
if self.serverUdp:
if self.server:
while True:
rx, ra = self.serverUdp.receive() # if no data the duple is ('',None)
rx, ra = self.server.receive() # if no data the duple is ('',None)
if not rx: # no received data so break
break
# triple = ( packet, source address, destination address)
self.udpRxes.append((rx, ra, self.serverUdp.ha))
self.udpRxes.append((rx, ra, self.server.ha))
self.serviceUdpRx()
@ -367,7 +367,7 @@ class StackUdp(object):
while self.udpTxes:
tx, ta = self.udpTxes.popleft() # duple = (packet, destination address)
self.serverUdp.send(tx, ta)
self.server.send(tx, ta)
return None
@ -620,9 +620,9 @@ class StackUxd(object):
self.uxdTxes = uxdTxes if uxdTxes is not None else deque() # uxd packets to transmit
self.lane = lane # or keeping.LaneKeep()
self.accept = self.Accept if accept is None else accept #accept uxd msg if not in lane
self.serverUxd = aiding.SocketUxdNb(ha=self.yard.ha, bufsize=raeting.MAX_MESSAGE_SIZE)
self.serverUxd.reopen() # open socket
self.yard.ha = self.serverUxd.ha # update estate host address after open
self.server = aiding.SocketUxdNb(ha=self.yard.ha, bufsize=raeting.MAX_MESSAGE_SIZE)
self.server.reopen() # open socket
self.yard.ha = self.server.ha # update estate host address after open
#self.lane.dumpLocalLane(self.yard)
@ -704,17 +704,17 @@ class StackUxd(object):
'''
Service the UXD receive and transmit queues
'''
if self.serverUxd:
if self.server:
while True:
rx, ra = self.serverUxd.receive() # if no data the duple is ('',None)
rx, ra = self.server.receive() # if no data the duple is ('',None)
if not rx: # no received data so break
break
# triple = ( packet, source address, destination address)
self.uxdRxes.append((rx, ra, self.serverUxd.ha))
self.uxdRxes.append((rx, ra, self.server.ha))
while self.uxdTxes:
tx, ta = self.uxdTxes.popleft() # duple = (packet, destination address)
self.serverUxd.send(tx, ta)
self.server.send(tx, ta)
return None
@ -728,13 +728,13 @@ class StackUxd(object):
Uxd Socket send
'''
if self.serverUxd:
if self.server:
while True:
rx, ra = self.serverUxd.receive() # if no data the duple is ('',None)
rx, ra = self.server.receive() # if no data the duple is ('',None)
if not rx: # no received data so break
break
# triple = ( packet, source address, destination address)
self.uxdRxes.append((rx, ra, self.serverUxd.ha))
self.uxdRxes.append((rx, ra, self.server.ha))
self.serviceUxdRx()
@ -742,7 +742,7 @@ class StackUxd(object):
while self.uxdTxes:
tx, ta = self.uxdTxes.popleft() # duple = (packet, destination address)
self.serverUxd.send(tx, ta)
self.server.send(tx, ta)
return None

View File

@ -115,8 +115,8 @@ def test():
print stack1.safe.loadLocalData()
print stack1.safe.loadAllRemoteData()
stack0.serverUdp.close()
stack1.serverUdp.close()
stack0.server.close()
stack1.server.close()
#master stack
dirpath = os.path.join(os.getcwd(), 'keep', 'master')

View File

@ -161,9 +161,9 @@ def test():
print stack1.safe.loadAllRemoteData()
print
stack0.serverUdp.close()
stack1.serverUdp.close()
stack2.serverUdp.close()
stack0.server.close()
stack1.server.close()
stack2.server.close()
#estate0 = stack0.loadLocal()
#print estate0.name, estate0.eid, estate0.sid, estate0.ha, estate0.signer, estate0.priver
@ -280,9 +280,9 @@ def test():
print "{0} estates=\n{1}".format(stack2.name, stack2.estates)
print "{0} transactions=\n{1}".format(stack2.name, stack2.transactions)
stack0.serverUdp.close()
stack1.serverUdp.close()
stack2.serverUdp.close()
stack0.server.close()
stack1.server.close()
stack2.server.close()
stack0.clearLocal()
stack0.clearAllRemote()

View File

@ -117,8 +117,8 @@ def test(preClearMaster=False, preClearMinion=False, postClearMaster=False, post
print stack1.safe.loadAllRemoteData()
print
stack0.serverUdp.close()
stack1.serverUdp.close()
stack0.server.close()
stack1.server.close()
if postClearMaster:
keeping.clearAllRoadSafe(masterDirpath)

View File

@ -301,8 +301,8 @@ def testStackUdp(bk=raeting.bodyKinds.json):
for msg in stack1.rxMsgs:
print msg
stack0.serverUdp.close()
stack1.serverUdp.close()
stack0.server.close()
stack1.server.close()
stack0.clearLocal()
stack0.clearAllRemote()

View File

@ -147,8 +147,8 @@ def test():
print stack1.safe.loadAllRemoteData()
print
stack0.serverUdp.close()
stack1.serverUdp.close()
stack0.server.close()
stack1.server.close()
#stack0.clearLocal()
#stack0.clearAllRemote()

View File

@ -20,7 +20,7 @@ def testStackUxd(kind=raeting.packKinds.json):
'''
console.reinit(verbosity=console.Wordage.verbose)
console.reinit(verbosity=console.Wordage.concise)
stacking.StackUxd.Pk = kind
@ -202,7 +202,8 @@ def testStackUxd(kind=raeting.packKinds.json):
print "{0} yards=\n{1}".format(stack1.name, stack1.yards)
print "{0} names=\n{1}".format(stack1.name, stack1.names)
stack0.server.close()
stack1.server.close()
if __name__ == "__main__":
testStackUxd(raeting.packKinds.json)