Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
authorAnton Leherbauer2012-01-26 03:59:52 -0500
committerAnton Leherbauer2012-01-26 03:59:52 -0500
commitafd9a45d5af37286c9e6101cbb409d99e277bea3 (patch)
tree447f183ffce3761208ac61f8330a67cb584d2aff /python
parent0c07df5f2a70a3af20dd8b1bd8f6a628b5085fbc (diff)
downloadorg.eclipse.tcf-afd9a45d5af37286c9e6101cbb409d99e277bea3.tar.gz
org.eclipse.tcf-afd9a45d5af37286c9e6101cbb409d99e277bea3.tar.xz
org.eclipse.tcf-afd9a45d5af37286c9e6101cbb409d99e277bea3.zip
TCF Python: Fix dangerous assignments to reserved names
Diffstat (limited to 'python')
-rw-r--r--python/src/tcf/channel/AbstractChannel.py7
-rw-r--r--python/src/tcf/channel/__init__.py16
-rw-r--r--python/src/tcf/services/filesystem.py4
-rw-r--r--python/src/tcf/services/local/LocatorService.py36
-rw-r--r--python/src/tcf/services/remote/DiagnosticsProxy.py18
-rw-r--r--python/src/tcf/services/remote/MemoryProxy.py6
-rw-r--r--python/src/tcf/services/remote/ProcessesProxy.py8
-rw-r--r--python/src/tcf/transport.py12
-rw-r--r--python/src/tcf/util/event.py4
9 files changed, 55 insertions, 56 deletions
diff --git a/python/src/tcf/channel/AbstractChannel.py b/python/src/tcf/channel/AbstractChannel.py
index b1d1d5427..f313cc252 100644
--- a/python/src/tcf/channel/AbstractChannel.py
+++ b/python/src/tcf/channel/AbstractChannel.py
@@ -60,8 +60,7 @@ class ReaderThread(threading.Thread):
def readString(self):
del self.buf[:]
- bytes = self.readBytes(0, self.buf)
- return bytes.decode("UTF8")
+ return self.readBytes(0, self.buf).decode("UTF8")
def run(self):
try:
@@ -672,8 +671,8 @@ class AbstractChannel(object):
l.event(msg.name, msg.data)
self.__sendCongestionLevel()
elif typeCode == 'F':
- len = len(msg.data)
- if len > 0 and msg.data[len - 1] == '\0': len -= 1
+ length = len(msg.data)
+ if length > 0 and msg.data[length - 1] == '\0': length -= 1
self.remote_congestion_level = int(msg.data)
else:
assert False
diff --git a/python/src/tcf/channel/__init__.py b/python/src/tcf/channel/__init__.py
index 8fd0031d1..1e89c0bbe 100644
--- a/python/src/tcf/channel/__init__.py
+++ b/python/src/tcf/channel/__init__.py
@@ -26,7 +26,7 @@ class TraceListener(object):
def onChannelClosed(self, error):
pass
-def Proxy(object):
+class Proxy(object):
def onCommand(self, token, service, name, data):
pass
@@ -151,11 +151,11 @@ def toJSONSequence(args):
buf.write('\0')
return buf.getvalue()
-def fromJSONSequence(bytes):
- if bytes[-1] == 0:
- del bytes[-1]
- str = bytes.decode("UTF-8")
- parts = str.split('\0')
+def fromJSONSequence(byteArray):
+ if byteArray[-1] == 0:
+ del byteArray[-1]
+ jsonStr = byteArray.decode("UTF-8")
+ parts = jsonStr.split('\0')
objects = []
for part in parts:
if part:
@@ -164,8 +164,8 @@ def fromJSONSequence(bytes):
objects.append(None)
return objects
-def dumpJSONObject(object, buf):
- json.dump(object, buf, separators=(',', ':'), cls=TCFJSONEncoder)
+def dumpJSONObject(obj, buf):
+ json.dump(obj, buf, separators=(',', ':'), cls=TCFJSONEncoder)
def toByteArray(data):
if data is None: return None
diff --git a/python/src/tcf/services/filesystem.py b/python/src/tcf/services/filesystem.py
index 726b71810..ed52f6d95 100644
--- a/python/src/tcf/services/filesystem.py
+++ b/python/src/tcf/services/filesystem.py
@@ -279,7 +279,7 @@ class FileSystemService(services.Service):
"""
raise NotImplementedError("Abstract methods")
- def read(self, handle, offset, len, done):
+ def read(self, handle, offset, length, done):
"""
Read bytes from an open file.
In response to this request, the server will read as many bytes as it
@@ -295,7 +295,7 @@ class FileSystemService(services.Service):
@param offset is the offset (in bytes) relative
to the beginning of the file from where to start reading.
If offset < 0 then reading starts from current position in the file.
- @param len is the maximum number of bytes to read.
+ @param length is the maximum number of bytes to read.
@param done is call back object.
@return pending command handle.
"""
diff --git a/python/src/tcf/services/local/LocatorService.py b/python/src/tcf/services/local/LocatorService.py
index 5a9271548..64f62cfe1 100644
--- a/python/src/tcf/services/local/LocatorService.py
+++ b/python/src/tcf/services/local/LocatorService.py
@@ -162,8 +162,8 @@ class LocatorService(locator.LocatorService):
self.out_buf = bytearray(MAX_PACKET_SIZE)
service = self
class TimerThread(threading.Thread):
- def __init__(self, callable):
- self._callable = callable
+ def __init__(self, _callable):
+ self._callable = _callable
super(TimerThread, self).__init__()
def run(self):
while service._alive:
@@ -211,8 +211,8 @@ class LocatorService(locator.LocatorService):
service._log("Unhandled exception in TCF discovery DNS lookup thread", x)
self.dns_lookup_thread = DNSLookupThread()
class InputThread(threading.Thread):
- def __init__(self, callable):
- self._callable = callable
+ def __init__(self, _callable):
+ self._callable = _callable
super(InputThread, self).__init__()
def run(self):
try:
@@ -404,13 +404,13 @@ class LocatorService(locator.LocatorService):
if s in self.subnets: continue
self.subnets.add(s)
if __TRACE_DISCOVERY__:
- str = cStringIO.StringIO()
- str.write("Refreshed subnet list:")
+ buf = cStringIO.StringIO()
+ buf.write("Refreshed subnet list:")
for subnet in self.subnets:
- str.write("\n\t* address=%s, broadcast=%s" % (subnet.address, subnet.broadcast))
- logging.trace(str.getvalue())
+ buf.write("\n\t* address=%s, broadcast=%s" % (subnet.address, subnet.broadcast))
+ logging.trace(buf.getvalue())
- def __getSubNetList(self, set):
+ def __getSubNetList(self, _set):
# TODO iterate over network interfaces to get proper broadcast addresses
hostname = socket.gethostname()
_, _, addresses = socket.gethostbyname_ex(hostname)
@@ -421,7 +421,7 @@ class LocatorService(locator.LocatorService):
if len(rawaddr) != 4: continue
rawaddr = rawaddr[:3] + '\xFF'
broadcast = socket.inet_ntoa(rawaddr)
- set.add(SubNet(24, InetAddress(hostname, address), InetAddress(None, broadcast)))
+ _set.add(SubNet(24, InetAddress(hostname, address), InetAddress(None, broadcast)))
def __getUTF8Bytes(self, s):
return s.encode("UTF-8")
@@ -610,8 +610,8 @@ class LocatorService(locator.LocatorService):
try:
tm = int(time.time() * 1000)
buf = p.getData()
- len = p.getLength()
- if len < 8: return
+ length = p.getLength()
+ if length < 8: return
if buf[0] != 'T': return
if buf[1] != 'C': return
if buf[2] != 'F': return
@@ -787,14 +787,14 @@ class LocatorService(locator.LocatorService):
# addr is a InputPacket
port = addr.getPort()
addr = addr.getAddress()
- str = cStringIO.StringIO()
- str.write(type)
- str.write((" sent to ", " received from ")[received])
- str.write("%s/%s" % (addr, port))
+ buf = cStringIO.StringIO()
+ buf.write(type)
+ buf.write((" sent to ", " received from ")[received])
+ buf.write("%s/%s" % (addr, port))
if attrs is not None:
for key, value in attrs.items():
- str.write("\n\t%s=%s" % (key, value))
- logging.trace(str.getvalue())
+ buf.write("\n\t%s=%s" % (key, value))
+ logging.trace(buf.getvalue())
class LocatorServiceProvider(services.ServiceProvider):
def getLocalService(self, _channel):
diff --git a/python/src/tcf/services/remote/DiagnosticsProxy.py b/python/src/tcf/services/remote/DiagnosticsProxy.py
index 944533ab6..9c1c63b70 100644
--- a/python/src/tcf/services/remote/DiagnosticsProxy.py
+++ b/python/src/tcf/services/remote/DiagnosticsProxy.py
@@ -25,11 +25,11 @@ class DiagnosticsProxy(diagnostics.DiagnosticsService):
def __init__(self):
super(EchoCommand, self).__init__(service.channel, service, "echo", (s,))
def done(self, error, args):
- str = None
+ result = None
if not error:
assert len(args) == 1
- str = args[0]
- done.doneEcho(self.token, error, str)
+ result = args[0]
+ done.doneEcho(self.token, error, result)
return EchoCommand().token
def echoFP(self, n, done):
@@ -63,12 +63,12 @@ class DiagnosticsProxy(diagnostics.DiagnosticsService):
super(EchoERRCommand, self).__init__(service.channel, service, "echoERR", (map,))
def done(self, error, args):
err = None
- str = None
+ result = None
if not error:
assert len(args) == 2
err = self.toError(args[0])
- str = args[1]
- done.doneEchoERR(self.token, error, err, str)
+ result = args[1]
+ done.doneEchoERR(self.token, error, err, result)
return EchoERRCommand().token
def getTestList(self, done):
@@ -93,12 +93,12 @@ class DiagnosticsProxy(diagnostics.DiagnosticsService):
def __init__(self):
super(RunTestCommand, self).__init__(service.channel, service, "runTest", (s,))
def done(self, error, args):
- str = None
+ result = None
if not error:
assert len(args) == 2
error = self.toError(args[0])
- str = args[1]
- done.doneRunTest(self.token, error, str)
+ result = args[1]
+ done.doneRunTest(self.token, error, result)
return RunTestCommand().token
def cancelTest(self, s, done):
diff --git a/python/src/tcf/services/remote/MemoryProxy.py b/python/src/tcf/services/remote/MemoryProxy.py
index 62f01bdcf..3812f6bad 100644
--- a/python/src/tcf/services/remote/MemoryProxy.py
+++ b/python/src/tcf/services/remote/MemoryProxy.py
@@ -114,9 +114,9 @@ class MemContext(memory.MemoryContext):
e = memory.MemoryError(error.message)
else:
assert len(args) == 3
- bytes = channel.toByteArray(args[0])
- assert len(bytes) <= size
- buf[offs:offs+len(bytes)] = bytes
+ byts = channel.toByteArray(args[0])
+ assert len(byts) <= size
+ buf[offs:offs+len(byts)] = byts
e = self.toMemoryError(args[1], args[2])
done.doneMemory(self.token, e)
return GetCommand().token
diff --git a/python/src/tcf/services/remote/ProcessesProxy.py b/python/src/tcf/services/remote/ProcessesProxy.py
index 9cfdcbd56..eeba4dcd6 100644
--- a/python/src/tcf/services/remote/ProcessesProxy.py
+++ b/python/src/tcf/services/remote/ProcessesProxy.py
@@ -208,8 +208,8 @@ def _toEnvStringArray(map):
def _toEnvMap(arr):
map = {}
if not arr: return map
- for str in arr:
- i = str.find('=')
- if i >= 0: map[str[:i]] = str[i + 1:]
- else: map[str] = ""
+ for env in arr:
+ i = env.find('=')
+ if i >= 0: map[env[:i]] = env[i + 1:]
+ else: map[env] = ""
return map
diff --git a/python/src/tcf/transport.py b/python/src/tcf/transport.py
index b22b2f9f0..ddfc5d122 100644
--- a/python/src/tcf/transport.py
+++ b/python/src/tcf/transport.py
@@ -140,18 +140,18 @@ def sync(done):
This is internal API, TCF clients should use protocol.sync().
"""
- set = set()
+ tokenSet = set()
class DoneSync(locator.DoneSync):
def doneSync(self, token):
- assert set.contains(token)
- set.remove(token)
- if len(set) == 0: done()
+ assert tokenSet.contains(token)
+ tokenSet.remove(token)
+ if len(tokenSet) == 0: done()
done_sync = DoneSync()
for c in _channels:
if c.getState() == channel.STATE_OPEN:
s = c.getRemoteService(locator.NAME)
- if s: set.append(s.sync(done_sync))
- if len(set) == 0: protocol.invokeLater(done)
+ if s: tokenSet.append(s.sync(done_sync))
+ if len(tokenSet) == 0: protocol.invokeLater(done)
# initialize TCP transport
addTransportProvider(TCPTransportProvider())
diff --git a/python/src/tcf/util/event.py b/python/src/tcf/util/event.py
index 2ca38df63..676f8c884 100644
--- a/python/src/tcf/util/event.py
+++ b/python/src/tcf/util/event.py
@@ -13,8 +13,8 @@ import threading
from tcf import protocol, channel
class DelegatingEventListener(channel.EventListener):
- def __init__(self, callable):
- self._callable = callable
+ def __init__(self, _callable):
+ self._callable = _callable
def event(self, name, data):
try:
args = channel.fromJSONSequence(data)

Back to the top