Created
September 8, 2016 20:06
-
-
Save nroi/0ef6a85d8ec2cbd09960ef0a37cc476e to your computer and use it in GitHub Desktop.
Demonstrate bug in mpd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import socket | |
from time import sleep | |
import sys | |
hostname = 'alarm.local' | |
port = 6600 | |
password = 'secret123' | |
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
s.connect((hostname, port)) | |
print(s.recv(64).decode('ascii'), end="") | |
s.sendall("password {}\n".format(password).encode('ascii')) | |
result = s.recv(128) | |
assert(result == b"OK\n") | |
for _ in range(0, 30): | |
s.sendall(b"seekcur 60\n") | |
result = s.recv(3) | |
assert(result == b"OK\n") | |
sleep(.005) | |
sleep(.5) | |
s.sendall(b"status\n") | |
answer = s.recv(1024).decode('ascii') | |
[elapsed_str] = [x.rstrip() for x in answer.split("\n") if x.startswith("elapsed")] | |
num_value = float(elapsed_str.split(": ")[1]) | |
print("seeked to position:", num_value) | |
if num_value < 60: | |
print("who did that?!") | |
sys.exit(1) | |
s.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment