<commit_before>from pyomxplayer import OMXPlayer
import json
from time import sleep
from pprint import pprint
import threading
import zmq
import random
import sys
import time

if len(sys.argv) > 1:
    playerID =  int(sys.argv[1])
else:
    raise RuntimeError("specify player id: omxplayer.py [id]")

player = False
playerstatus = "standby"
exitnow = False
def playerHandler():
    global playerID
    context = zmq.Context()

    work_receiver = context.socket(zmq.SUB)
    port = 5501
    work_receiver.Linger = 250
    work_receiver.connect("tcp://192.168.1.233:5501")

    #poller = zmq.Poller()
    #poller.register(work_receiver, zmq.POLLIN)
    work_receiver.setsockopt(zmq.SUBSCRIBE, "1")
    work_receiver.setsockopt(zmq.SUBSCRIBE, "2")
    #work_receiver.setsockopt(zmq.SUBSCRIBE, str(playerID))

    while not exitnow:
        print "listen here"
        string = work_receiver.recv()
        print string
        topic, messagedata = string.split(" ", 1)
        doCommand(messagedata)
        #socks = dict(poller.poll(1000))
        #if socks:
                #if socks.get(work_receiver) == zmq.POLLIN:
        sleep(1)


def doCommand(cmdstr):
    try:
        cmd, messagedata = cmdstr.split(" ", 1)
    except:
        cmd = cmdstr
    if cmd == "reset":
        playerReset()
    elif cmd == "queue":
        args = json.loads(messagedata)
        playFile(args)
    elif cmd == "unpause":
        playerUnpause()

def playerReset():
    global playerstatus
    if player:
        player.stop()
    playerstatus = "reset"

def playFile(args):
    global player
    player = OMXPlayer(args["file"], args["args"])
    # The player will initially be paused
    if args.has_key("mute") and args["mute"]:
        player.toggle_mute()

def playerUnpause():
    global player
    if player.__dict__["paused"]:
        player.toggle_pause()

#player.toggle_mute()
#player.toggle_mute(.1)
#player.toggle_mute(.5)

port = "5556"
context = zmq.Context()
socket = context.socket(zmq.PUB)
socket.linger = 250
socket.bind("tcp://*:%s" % port)



def sendUpdate(messagedata):
    global playerID
    print "%d %s" % (playerID, messagedata)
    socket.send("%d %s" % (playerID, messagedata))<commit_msg>filter on topic == playerID<commit_after>from pyomxplayer import OMXPlayer
import json
from time import sleep
from pprint import pprint
import threading
import zmq
import random
import sys
import time

if len(sys.argv) > 1:
    playerID =  int(sys.argv[1])
else:
    raise RuntimeError("specify player id: omxplayer.py [id]")

player = False
playerstatus = "standby"
exitnow = False
def playerHandler():
    global playerID
    context = zmq.Context()

    work_receiver = context.socket(zmq.SUB)
    port = 5501
    work_receiver.Linger = 250
    work_receiver.connect("tcp://192.168.1.233:5501")

    #poller = zmq.Poller()
    #poller.register(work_receiver, zmq.POLLIN)
    work_receiver.setsockopt(zmq.SUBSCRIBE, "1")
    work_receiver.setsockopt(zmq.SUBSCRIBE, "2")
    #work_receiver.setsockopt(zmq.SUBSCRIBE, str(playerID))

    while not exitnow:
        print "listen here"
        string = work_receiver.recv()
        print string
        topic, messagedata = string.split(" ", 1)
        if int(topic) == playerID:
            doCommand(messagedata)
        #socks = dict(poller.poll(1000))
        #if socks:
                #if socks.get(work_receiver) == zmq.POLLIN:
        sleep(1)


def doCommand(cmdstr):
    try:
        cmd, messagedata = cmdstr.split(" ", 1)
    except:
        cmd = cmdstr
    if cmd == "reset":
        playerReset()
    elif cmd == "queue":
        args = json.loads(messagedata)
        playFile(args)
    elif cmd == "unpause":
        playerUnpause()

def playerReset():
    global playerstatus
    if player:
        player.stop()
    playerstatus = "reset"

def playFile(args):
    global player
    player = OMXPlayer(args["file"], args["args"])
    # The player will initially be paused
    if args.has_key("mute") and args["mute"]:
        player.toggle_mute()

def playerUnpause():
    global player
    if player.__dict__["paused"]:
        player.toggle_pause()

#player.toggle_mute()
#player.toggle_mute(.1)
#player.toggle_mute(.5)

port = "5556"
context = zmq.Context()
socket = context.socket(zmq.PUB)
socket.bind("tcp://*:%s" % port)



def sendUpdate(messagedata):
    global playerID
    print "%d %s" % (playerID, messagedata)
    socket.send("%d %s" % (playerID, messagedata))
{'fraction_non_alphanumeric': 0.12530933633295838, 'fraction_numerical': 0.01777277840269966, 'mean_word_length': 3.0381471389645776, 'pattern_counts': {'":': 6, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '170071', 'n_tokens_mistral': 1575, 'n_tokens_neox': 1506, 'n_words': 347}