Fix all flake8 warnings in tools (#211)

This commit is contained in:
Stein Magnus Jodal 2012-10-16 14:48:58 +02:00
parent ac60bcdf8e
commit e65a612ac8
2 changed files with 95 additions and 92 deletions

View File

@ -6,7 +6,7 @@ import sys
from gevent import select, server, socket from gevent import select, server, socket
COLORS = ['\033[1;%dm' % (30+i) for i in range(8)] COLORS = ['\033[1;%dm' % (30 + i) for i in range(8)]
BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE = COLORS BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE = COLORS
RESET = "\033[0m" RESET = "\033[0m"
BOLD = "\033[1m" BOLD = "\033[1m"
@ -53,7 +53,8 @@ def loop(client, address, reference, actual):
# Consume banners from backends # Consume banners from backends
responses = dict() responses = dict()
disconnected = read([reference, actual], responses, find_response_end_token) disconnected = read(
[reference, actual], responses, find_response_end_token)
diff(address, '', responses[reference], responses[actual]) diff(address, '', responses[reference], responses[actual])
# We lost a backend, might as well give up. # We lost a backend, might as well give up.
@ -78,13 +79,15 @@ def loop(client, address, reference, actual):
actual.sendall(responses[client]) actual.sendall(responses[client])
# Get the entire resonse from both backends. # Get the entire resonse from both backends.
disconnected = read([reference, actual], responses, find_response_end_token) disconnected = read(
[reference, actual], responses, find_response_end_token)
# Send the client the complete reference response # Send the client the complete reference response
client.sendall(responses[reference]) client.sendall(responses[reference])
# Compare our responses # Compare our responses
diff(address, responses[client], responses[reference], responses[actual]) diff(address,
responses[client], responses[reference], responses[actual])
# Give up if we lost a backend. # Give up if we lost a backend.
if disconnected: if disconnected:

View File

@ -17,98 +17,98 @@ data = {'id': None, 'id2': None, 'url': url, 'artist': artist}
# Commands to run before test requests to coerce MPD into right state # Commands to run before test requests to coerce MPD into right state
setup_requests = [ setup_requests = [
'clear', 'clear',
'add "%(url)s"', 'add "%(url)s"',
'add "%(url)s"', 'add "%(url)s"',
'add "%(url)s"', 'add "%(url)s"',
'play', 'play',
# 'pause', # Uncomment to test paused idle behaviour #'pause', # Uncomment to test paused idle behaviour
# 'stop', # Uncomment to test stopped idle behaviour #'stop', # Uncomment to test stopped idle behaviour
] ]
# List of commands to test for idle behaviour. Ordering of list is important in # List of commands to test for idle behaviour. Ordering of list is important in
# order to keep MPD state as intended. Commands that are obviously # order to keep MPD state as intended. Commands that are obviously
# informational only or "harmfull" have been excluded. # informational only or "harmfull" have been excluded.
test_requests = [ test_requests = [
'add "%(url)s"', 'add "%(url)s"',
'addid "%(url)s" "1"', 'addid "%(url)s" "1"',
'clear', 'clear',
# 'clearerror', #'clearerror',
# 'close', #'close',
# 'commands', #'commands',
'consume "1"', 'consume "1"',
'consume "0"', 'consume "0"',
# 'count', # 'count',
'crossfade "1"', 'crossfade "1"',
'crossfade "0"', 'crossfade "0"',
# 'currentsong', #'currentsong',
# 'delete "1:2"', #'delete "1:2"',
'delete "0"', 'delete "0"',
'deleteid "%(id)s"', 'deleteid "%(id)s"',
'disableoutput "0"', 'disableoutput "0"',
'enableoutput "0"', 'enableoutput "0"',
# 'find', #'find',
# 'findadd "artist" "%(artist)s"', #'findadd "artist" "%(artist)s"',
# 'idle', #'idle',
# 'kill', #'kill',
# 'list', #'list',
# 'listall', #'listall',
# 'listallinfo', #'listallinfo',
# 'listplaylist', #'listplaylist',
# 'listplaylistinfo', #'listplaylistinfo',
# 'listplaylists', #'listplaylists',
# 'lsinfo', #'lsinfo',
'move "0:1" "2"', 'move "0:1" "2"',
'move "0" "1"', 'move "0" "1"',
'moveid "%(id)s" "1"', 'moveid "%(id)s" "1"',
'next', 'next',
# 'notcommands', #'notcommands',
# 'outputs', #'outputs',
# 'password', #'password',
'pause', 'pause',
# 'ping', #'ping',
'play', 'play',
'playid "%(id)s"', 'playid "%(id)s"',
# 'playlist', #'playlist',
'playlistadd "foo" "%(url)s"', 'playlistadd "foo" "%(url)s"',
'playlistclear "foo"', 'playlistclear "foo"',
'playlistadd "foo" "%(url)s"', 'playlistadd "foo" "%(url)s"',
'playlistdelete "foo" "0"', 'playlistdelete "foo" "0"',
# 'playlistfind', #'playlistfind',
# 'playlistid', #'playlistid',
# 'playlistinfo', #'playlistinfo',
'playlistadd "foo" "%(url)s"', 'playlistadd "foo" "%(url)s"',
'playlistadd "foo" "%(url)s"', 'playlistadd "foo" "%(url)s"',
'playlistmove "foo" "0" "1"', 'playlistmove "foo" "0" "1"',
# 'playlistsearch', #'playlistsearch',
# 'plchanges', #'plchanges',
# 'plchangesposid', #'plchangesposid',
'previous', 'previous',
'random "1"', 'random "1"',
'random "0"', 'random "0"',
'rm "bar"', 'rm "bar"',
'rename "foo" "bar"', 'rename "foo" "bar"',
'repeat "0"', 'repeat "0"',
'rm "bar"', 'rm "bar"',
'save "bar"', 'save "bar"',
'load "bar"', 'load "bar"',
# 'search', #'search',
'seek "1" "10"', 'seek "1" "10"',
'seekid "%(id)s" "10"', 'seekid "%(id)s" "10"',
# 'setvol "10"', #'setvol "10"',
'shuffle', 'shuffle',
'shuffle "0:1"', 'shuffle "0:1"',
'single "1"', 'single "1"',
'single "0"', 'single "0"',
# 'stats', #'stats',
# 'status', #'status',
'stop', 'stop',
'swap "1" "2"', 'swap "1" "2"',
'swapid "%(id)s" "%(id2)s"', 'swapid "%(id)s" "%(id2)s"',
# 'tagtypes', #'tagtypes',
# 'update', #'update',
# 'urlhandlers', #'urlhandlers',
# 'volume', #'volume',
] ]
@ -116,8 +116,8 @@ def create_socketfile():
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect((host, port)) sock.connect((host, port))
sock.settimeout(0.5) sock.settimeout(0.5)
fd = sock.makefile('rw', 1) # 1 = line buffered fd = sock.makefile('rw', 1) # 1 = line buffered
fd.readline() # Read banner fd.readline() # Read banner
return fd return fd