Address errors, improvements, formatting

- Removed unused code not portable due to buffer() use
- raw_input() does not exist in Python 3
- Fixed octal constant syntax for Python 3
- Fixed TypeError
- Replace if not exists: makedirs(path) with single call: using makedirs(path, exist_ok=True)
- Class inherits from object, can be safely removed from bases in python3: pylint's useless-object-inheritance (W0235) check

Signed-off-by: JoeLametta <JoeLametta@users.noreply.github.com>
This commit is contained in:
JoeLametta
2019-08-10 09:10:00 +00:00
parent 8446c290e7
commit 35201d5290
18 changed files with 31 additions and 65 deletions

View File

@@ -150,27 +150,3 @@ def recv_some(p, t=.1, e=1, tr=5, stderr=0):
else:
time.sleep(max((x - time.time()) / tr, 0))
return ''.join(x.decode() for x in y).encode()
def send_all(p, data):
while data:
sent = p.send(data)
if sent is None:
raise Exception(message)
data = buffer(data, sent)
if __name__ == '__main__':
if sys.platform == 'win32':
shell, commands, tail = ('cmd', ('dir /w', 'echo HELLO WORLD'), '\r\n')
else:
shell, commands, tail = ('sh', ('ls', 'echo HELLO WORLD'), '\n')
a = Popen(shell, stdin=PIPE, stdout=PIPE)
print(recv_some(a))
for cmd in commands:
send_all(a, cmd + tail)
print(recv_some(a))
send_all(a, 'exit' + tail)
print(recv_some(a, e=0))
a.wait()

View File

@@ -17,16 +17,13 @@
# USA
import sys
def digit_sum(i):
"""returns the sum of all digits for the given integer"""
return sum(map(int, str(i)))
class DiscID(object):
class DiscID:
def __init__(self, offsets, total_length, track_count, playable_length):
"""offsets is a list of track offsets, in CD frames
total_length is the total length of the disc, in seconds

View File

@@ -68,7 +68,7 @@ def _getExceptionMessage(exception, frame=-1, filename=None):
% locals()
class LogStub(object):
class LogStub:
"""
I am a stub for a log interface.
"""
@@ -243,7 +243,7 @@ class Task(LogStub):
# FIXME: should this become a real interface, like in zope ?
class ITaskListener(object):
class ITaskListener:
"""
I am an interface for objects listening to tasks.
"""