Changeset - 64eeba960168
[Not reviewed]
default
0 2 0
Drew Perttula - 6 years ago 2019-05-30 08:30:27
drewp@bigasterisk.com
type fixes
Ignore-this: 4d6140dec7479e7708e8cdd582ccfd38
2 files changed with 5 insertions and 5 deletions:
0 comments (0 inline, 0 general)
bin/musicPad
Show inline comments
 
@@ -6,31 +6,31 @@ import sys, wave, logging, os
 
sys.path.append(".")
 
from light9 import showconfig
 
from light9.ascoltami.playlist import Playlist
 
logging.basicConfig(level=logging.INFO)
 
log = logging.getLogger()
 

	
 
introPad = 4
 
postPad = 9  # 5 + autostop + 4
 

	
 
playlist = Playlist.fromShow(showconfig.getGraph(), showconfig.showUri())
 
for p in playlist.allSongPaths():
 
    log.info("read %s", p)
 
    inputWave = wave.open(p, 'r')
 
    inputWave = wave.open(p, 'rb')
 

	
 
    outputDir = os.path.join(os.path.dirname(p), "pad")
 
    try:
 
        os.makedirs(outputDir)
 
    except OSError:
 
        pass  # exists
 
    outputPath = os.path.join(outputDir, os.path.basename(p))
 
    outputWave = wave.open(outputPath, 'w')
 
    outputWave = wave.open(outputPath, 'wb')
 
    outputWave.setparams(inputWave.getparams())
 

	
 
    bytesPerSecond = (inputWave.getnchannels() * inputWave.getsampwidth() *
 
                      inputWave.getframerate())
 

	
 
    outputWave.writeframesraw("\x00" * (bytesPerSecond * introPad))
 
    outputWave.writeframesraw(b"\x00" * (bytesPerSecond * introPad))
 
    outputWave.writeframesraw(inputWave.readframes(inputWave.getnframes()))
 
    outputWave.writeframesraw("\x00" * (bytesPerSecond * postPad))
 
    outputWave.writeframesraw(b"\x00" * (bytesPerSecond * postPad))
 
    outputWave.close()
 
    log.info("wrote %s", outputPath)
light9/collector/collector_client.py
Show inline comments
 
@@ -30,25 +30,25 @@ def toCollectorJson(client, session, set
 
        'sendTime': time.time(),
 
    })
 

	
 

	
 
def sendToCollectorZmq(msg):
 
    global _zmqClient
 
    if _zmqClient is None:
 
        _zmqClient = TwistedZmqClient(networking.collectorZmq)
 
    _zmqClient.send(msg)
 
    return defer.succeed(0)
 

	
 

	
 
def sendToCollector(client, session, settings, useZmq=False):
 
def sendToCollector(client, session, settings: DeviceSettings, useZmq=False):
 
    """deferred to the time in seconds it took to get a response from collector"""
 
    sendTime = time.time()
 
    msg = toCollectorJson(client, session, settings).encode('utf8')
 

	
 
    if useZmq:
 
        d = sendToCollectorZmq(msg)
 
    else:
 
        d = treq.put(networking.collector.path('attrs'), data=msg, timeout=1)
 

	
 
    def onDone(result):
 
        dt = time.time() - sendTime
 
        if dt > .1:
0 comments (0 inline, 0 general)