Skip to content

Commit a6204d8

Browse files
author
Federico Fissore
committed
Revert "run of code inspection"
This reverts commit a3ccdf0.
1 parent a3ccdf0 commit a6204d8

File tree

7 files changed

+110
-110
lines changed

7 files changed

+110
-110
lines changed

linux/bridge/bridge.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,24 @@ class CommandProcessor:
99
def __init__(self):
1010
self.commands = { }
1111
self.runners = [ ]
12-
12+
1313
def register_runner(self, runner):
1414
self.runners.append(runner)
15-
15+
1616
def register(self, key, command):
1717
self.commands[key] = command
18-
18+
1919
def run(self):
2020
for runner in self.runners:
2121
runner.run()
22-
22+
2323
def process(self, data):
2424
if data == 'XX':
2525
for cmd in self.commands:
2626
if 'reset' in dir(cmd):
2727
cmd.reset()
2828
return ''
29-
29+
3030
cmd = self.commands[data[0]]
3131
return cmd.run(data[1:])
3232

@@ -53,6 +53,6 @@ def process(self, data):
5353
#while time.time() - start_time < 100:
5454
while True:
5555
res = pr.process()
56-
if not res:
56+
if res == False:
5757
break
5858

linux/bridge/console.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from socket import socket, AF_INET, SOCK_STREAM, SOL_SOCKET, SO_REUSEADDR
1+
from socket import socket, AF_INET, SOCK_STREAM, SOL_SOCKET, SO_REUSEADDR, gethostname
22
from select import select
33
import utils
44

@@ -103,8 +103,8 @@ def run(self, data):
103103

104104
class READ_Command:
105105
def run(self, data):
106-
length = ord(data[0])
107-
return console.read(length)
106+
len = ord(data[0])
107+
return console.read(len)
108108

109109
class CONNECTED_Command:
110110
def run(self, data):

linux/bridge/files.py

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -5,114 +5,114 @@ def __init__(self):
55
self.next_id = 0
66

77
def open(self, filename, mode):
8-
# Open a_file
8+
# Open file
99
try:
10-
a_file = open(filename, mode)
10+
file = open(filename, mode)
1111
except IOError, e:
1212
return [e.errno, None]
1313

14-
# Determine the next id to assign to a_file
14+
# Determine the next id to assign to file
1515
while self.next_id in self.files:
1616
self.next_id = (self.next_id + 1) % 256
17-
self.files[self.next_id] = a_file
17+
self.files[self.next_id] = file
1818
return [0, self.next_id]
1919

20-
def close(self, file_id):
21-
if file_id not in self.files:
20+
def close(self, id):
21+
if id not in self.files:
2222
return
23-
a_file = self.files[file_id]
23+
file = self.files[id]
2424
try:
25-
a_file.close()
25+
file.close()
2626
except:
2727
pass
28-
del self.files[file_id]
28+
del self.files[id]
2929

30-
def read(self, file_id, maxlen):
31-
if file_id not in self.files:
30+
def read(self, id, maxlen):
31+
if id not in self.files:
3232
return None
33-
a_file = self.files[file_id]
33+
file = self.files[id]
3434
try:
35-
return [0, a_file.read(maxlen)]
35+
return [0, file.read(maxlen)]
3636
except IOError, e:
3737
return [e.errno, None]
3838

39-
def write(self, file_id, data):
40-
if file_id not in self.files:
39+
def write(self, id, data):
40+
if id not in self.files:
4141
return None
42-
a_file = self.files[file_id]
42+
file = self.files[id]
4343
try:
44-
a_file.write(data)
45-
a_file.flush()
44+
file.write(data)
45+
file.flush()
4646
return 0
4747
except IOError, e:
4848
return e.errno
4949

50-
def seek(self, file_id, pos):
51-
if file_id not in self.files:
50+
def seek(self, id, pos):
51+
if id not in self.files:
5252
return None
53-
a_file = self.files[file_id]
53+
file = self.files[id]
5454
try:
55-
a_file.seek(pos)
55+
file.seek(pos)
5656
return 0
5757
except IOError, e:
5858
return e.errno
5959

60-
def tell(self, file_id):
61-
if file_id not in self.files:
60+
def tell(self, id):
61+
if id not in self.files:
6262
return [None, None]
63-
a_file = self.files[file_id]
63+
file = self.files[id]
6464
try:
65-
return [0, a_file.tell()]
65+
return [0, file.tell()]
6666
except IOError, e:
6767
return [e.errno, None]
6868

6969
files = Files()
7070

7171
class OPEN_Command:
7272
def run(self, data):
73-
[err, file_id] = files.open(data[1:], data[0]+'b')
73+
[err, id] = files.open(data[1:], data[0]+'b')
7474
if err!=0:
7575
return chr(err) + chr(0)
7676
else:
77-
return chr(0) + chr(file_id)
77+
return chr(0) + chr(id)
7878

7979
class CLOSE_Command:
8080
def run(self, data):
81-
file_id = ord(data[0])
82-
files.close(file_id)
81+
id = ord(data[0])
82+
files.close(id)
8383
return '\x00'
8484

8585
class READ_Command:
8686
def run(self, data):
87-
file_id = ord(data[0])
87+
id = ord(data[0])
8888
maxlen = ord(data[1])
89-
[err, res] = files.read(file_id, maxlen)
89+
[err, res] = files.read(id, maxlen)
9090
if err!=0:
9191
return chr(err)
9292
else:
9393
return chr(0) + res
9494

9595
class WRITE_Command:
9696
def run(self, data):
97-
file_id = ord(data[0])
97+
id = ord(data[0])
9898
data = data[1:]
99-
err = files.write(file_id, data)
99+
err = files.write(id, data)
100100
return chr(err)
101101

102102
class SEEK_Command:
103103
def run(self, data):
104-
file_id = ord(data[0])
104+
id = ord(data[0])
105105
pos = ord(data[1]) << 24
106106
pos += ord(data[2]) << 16
107107
pos += ord(data[3]) << 8
108108
pos += ord(data[4])
109-
err = files.seek(file_id, pos)
109+
err = files.seek(id, pos)
110110
return chr(err)
111111

112112
class TELL_Command:
113113
def run(self, data):
114-
file_id = ord(data[0])
115-
[err, pos] = files.tell(file_id)
114+
id = ord(data[0])
115+
[err, pos] = files.tell(id)
116116
if pos is None:
117117
pos = 0
118118
err = 255

linux/bridge/packet.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ def cbreak():
1515
termios.tcsetattr(stdin, termios.TCSADRAIN, old_attrs)
1616

1717
class CRC:
18-
def __init__(self, a_file):
18+
def __init__(self, file):
1919
self.result = 0xAAAA
20-
self.file = a_file
20+
self.file = file
2121

2222
def write(self, data):
2323
while len(data) > 0:
2424
if not self.file is None:
2525
self.file.write(data[0])
26-
self.result ^= ord(data[0])
26+
self.result = self.result ^ ord(data[0])
2727
self.result = (self.result >> 8) + ((self.result & 0xFF) << 8)
2828
data = data[1:]
2929

linux/bridge/processes.py

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -27,32 +27,32 @@ def create(self, cmd):
2727
self.processes[self.next_id] = proc
2828
return self.next_id
2929

30-
def is_running(self, proc_id):
31-
if proc_id not in self.processes:
30+
def is_running(self, id):
31+
if id not in self.processes:
3232
return False
33-
proc = self.processes[proc_id]
33+
proc = self.processes[id]
3434
if proc.poll() is None:
3535
return True
3636
else:
3737
return False
3838

39-
def wait(self, proc_id):
40-
if proc_id not in self.processes:
39+
def wait(self, id):
40+
if id not in self.processes:
4141
return None
42-
proc = self.processes[proc_id]
42+
proc = self.processes[id]
4343
return proc.wait()
4444

45-
def clean(self, proc_id):
46-
if proc_id not in self.processes:
45+
def clean(self, id):
46+
if id not in self.processes:
4747
return
48-
proc = self.processes[proc_id]
48+
proc = self.processes[id]
4949
if proc.poll() is None:
5050
try:
5151
proc.kill()
5252
except OSError:
5353
# Trap: [Errno 3] No such process
5454
pass
55-
del self.processes[proc_id]
55+
del self.processes[id]
5656

5757
def try_buffer_output(self, proc):
5858
if len(proc.buffered_out) < 32:
@@ -62,10 +62,10 @@ def try_buffer_output(self, proc):
6262
# Traps: [Errno 11] Resource temporarily unavailable
6363
pass
6464

65-
def read_output(self, proc_id, maxlen):
66-
if proc_id not in self.processes:
65+
def read_output(self, id, maxlen):
66+
if id not in self.processes:
6767
return None
68-
proc = self.processes[proc_id]
68+
proc = self.processes[id]
6969
self.try_buffer_output(proc)
7070
if len(proc.buffered_out) < maxlen:
7171
res = proc.buffered_out
@@ -75,17 +75,17 @@ def read_output(self, proc_id, maxlen):
7575
proc.buffered_out = proc.buffered_out[maxlen:]
7676
return res
7777

78-
def available_output(self, proc_id):
79-
if proc_id not in self.processes:
78+
def available_output(self, id):
79+
if id not in self.processes:
8080
return None
81-
proc = self.processes[proc_id]
81+
proc = self.processes[id]
8282
self.try_buffer_output(proc)
8383
return len(proc.buffered_out)
8484

85-
def write_input(self, proc_id, data):
86-
if proc_id not in self.processes:
85+
def write_input(self, id, data):
86+
if id not in self.processes:
8787
return
88-
proc = self.processes[proc_id]
88+
proc = self.processes[id]
8989
proc.stdin.write(data)
9090
proc.stdin.flush()
9191

@@ -96,18 +96,18 @@ def __init__(self, processes):
9696
self.proc = processes
9797

9898
def run(self, data):
99-
proc_id = self.proc.create(data.split('\xFE'))
100-
if proc_id is None:
101-
return chr(1) + chr(0)
102-
return chr(0) + chr(proc_id)
99+
id = self.proc.create(data.split('\xFE'))
100+
if id is None:
101+
return chr(1) + chr(0);
102+
return chr(0) + chr(id)
103103

104104
class RUNNING_Command:
105105
def __init__(self, processes):
106106
self.proc = processes
107107

108108
def run(self, data):
109-
proc_id = ord(data[0])
110-
res = self.proc.is_running(proc_id)
109+
id = ord(data[0])
110+
res = self.proc.is_running(id)
111111
if res:
112112
return '\x01'
113113
else:
@@ -118,8 +118,8 @@ def __init__(self, processes):
118118
self.proc = processes
119119

120120
def run(self, data):
121-
proc_id = ord(data[0])
122-
res = self.proc.wait(proc_id)
121+
id = ord(data[0])
122+
res = self.proc.wait(id)
123123
if res is None:
124124
res = 0
125125
return chr((res >> 8) & 0xFF) + chr(res & 0xFF)
@@ -129,18 +129,18 @@ def __init__(self, processes):
129129
self.proc = processes
130130

131131
def run(self, data):
132-
proc_id = ord(data[0])
133-
self.proc.clean(proc_id)
132+
id = ord(data[0])
133+
self.proc.clean(id)
134134
return ''
135135

136136
class READ_OUTPUT_Command:
137137
def __init__(self, processes):
138138
self.proc = processes
139139

140140
def run(self, data):
141-
proc_id = ord(data[0])
141+
id = ord(data[0])
142142
maxlen = ord(data[1])
143-
res = self.proc.read_output(proc_id, maxlen)
143+
res = self.proc.read_output(id, maxlen)
144144
if res is None:
145145
return ''
146146
return res
@@ -150,8 +150,8 @@ def __init__(self, processes):
150150
self.proc = processes
151151

152152
def run(self, data):
153-
proc_id = ord(data[0])
154-
avail = self.proc.available_output(proc_id)
153+
id = ord(data[0])
154+
avail = self.proc.available_output(id)
155155
if avail is None:
156156
avail = 0
157157
return chr(avail)
@@ -161,9 +161,9 @@ def __init__(self, processes):
161161
self.proc = processes
162162

163163
def run(self, data):
164-
proc_id = ord(data[0])
164+
id = ord(data[0])
165165
data = data[1:]
166-
self.proc.write_input(proc_id, data)
166+
self.proc.write_input(id, data)
167167
return ''
168168

169169
def init(command_processor):

0 commit comments

Comments
 (0)