Changeset - 17bee25a20cb
[Not reviewed]
default
0 11 0
Drew Perttula - 6 years ago 2019-05-28 06:46:08
drewp@bigasterisk.com
7 files changed with 12 insertions and 7 deletions:
0 comments (0 inline, 0 general)
bin/keyboardcomposer
Show inline comments
 
@@ -523,26 +523,27 @@ class KeyboardComposer(tk.Frame, SubClie
 
                               predicate=L9['group'],
 
                               newObject=group)
 

	
 
    def highlight_row(self, row):
 
        row = self.rows[row]
 
        row['bg'] = 'red'
 

	
 
    def unhighlight_row(self, row):
 
        row = self.rows[row]
 
        row['bg'] = 'black'
 

	
 
    def get_levels(self):
 
        return dict([(uri, box.getVal())
 
                     for uri, box in list(self.subbox.items())])
 
        return dict([
 
            (uri, box.getVal()) for uri, box in list(self.subbox.items())
 
        ])
 

	
 
    def get_output_settings(self, _graph=None):
 
        _graph = _graph or self.graph
 
        outputSettings = []
 
        for setting in _graph.objects(self.session, L9['subSetting']):
 
            effect = _graph.value(setting, L9['sub'])
 
            strength = _graph.value(setting, L9['level'])
 
            if strength:
 
                now = time.time()
 
                out, report = self.effectEval[effect].outputFromEffect(
 
                    [(L9['strength'], strength)],
 
                    songTime=now,
light9/FlyingFader.py
Show inline comments
 
from tkinter import tix
 
from time import time
 

	
 

	
 
class Mass:
 

	
 
    def __init__(self):
 
        self.x = 0  # position
 
        self.xgoal = 0  # position goal
 

	
 
        self.v = 0  # velocity
 
        self.maxspeed = .8  # maximum speed, in position/second
 
        self.maxaccel = 3  # maximum acceleration, in position/second^2
 
        self.eps = .03  # epsilon - numbers within this much are considered the same
 

	
 
        self._lastupdate = time()
light9/effecteval/effectloop.py
Show inline comments
 
@@ -60,25 +60,26 @@ class EffectLoop(object):
 
        for sub in self.graph.subjects(RDF.type, L9['Submaster']):
 
            for effectUri in self.graph.objects(sub, L9['drivesEffect']):
 
                self.currentEffects.append(EffectNode(self.graph, effectUri))
 

	
 
        log.info('now we have %s effects', len(self.currentEffects))
 

	
 
    @inlineCallbacks
 
    def getSongTime(self):
 
        now = time.time()
 
        old = now - self.requestTime
 
        if old > self.coastSecs:
 
            try:
 
                r = yield treq.get(networking.musicPlayer.path('time'), timeout=.5)
 
                r = yield treq.get(networking.musicPlayer.path('time'),
 
                                   timeout=.5)
 
                response = yield r.json_content()
 
            except TimeoutError:
 
                log.warning("TimeoutError: using stale time from %.1f ago", old)
 
            else:
 
                self.requestTime = now
 
                self.currentPlaying = response['playing']
 
                self.songTimeFromRequest = response['t']
 
                returnValue((response['t'], (response['song'] and
 
                                             URIRef(response['song']))))
 

	
 
        estimated = self.songTimeFromRequest
 
        if self.currentSong is not None and self.currentPlaying:
light9/showconfig.py
Show inline comments
 
@@ -49,25 +49,26 @@ def showUri() -> URIRef:
 

	
 
def songOnDisk(song: URIRef) -> bytes:
 
    """given a song URI, where's the on-disk file that mpd would read?"""
 
    graph = getGraph()
 
    root = graph.value(showUri(), L9['musicRoot'])
 
    if not root:
 
        raise ValueError("%s has no :musicRoot" % showUri())
 

	
 
    name = graph.value(song, L9['songFilename'])
 
    if not name:
 
        raise ValueError("Song %r has no :songFilename" % song)
 

	
 
    return path.abspath(path.join(
 
    return path.abspath(
 
        path.join(
 
        cast(Literal, root).toPython(),
 
        cast(Literal, name).toPython()))
 

	
 

	
 
def songFilenameFromURI(uri: URIRef) -> bytes:
 
    """
 
    'http://light9.bigasterisk.com/show/dance2007/song8' -> 'song8'
 

	
 
    everything that uses this should be deprecated for real URIs
 
    everywhere"""
 
    assert isinstance(uri, URIRef)
 
    return str(uri).split('/')[-1].encode('ascii')
light9/tkdnd.py
Show inline comments
 
from glob import glob
 
from os.path import join, basename
 
from typing import Dict, Any
 

	
 

	
 
class TkdndEvent(object):
 
    """
 
    see http://www.ellogon.org/petasis/tcltk-projects/tkdnd/tkdnd-man-page
 
    for details on the fields
 

	
 
    The longer attribute names (action instead of %A) were made up for
 
    this API.
 

	
 
    Not all attributes are visible yet, since I have not thought
 
    through what conversions they should receive and I don't want to
 
    unnecessarily change their types later.
 
    """
light9/vidref/musictime.py
Show inline comments
 
@@ -117,19 +117,19 @@ class MusicTime(object):
 
        def eb(err):
 
            if self.lastHoverTime:
 
                log.warn("talking to curveCalc: %s", err.getErrorMessage())
 
            self.lastHoverTime = None
 
            reactor.callLater(2, self.pollCurvecalcTime)
 

	
 
        d = treq.get(networking.curveCalc.path("hoverTime"))
 
        d.addCallback(cb)
 
        d.addErrback(eb)  # note this includes errors in cb()
 

	
 
    def sendTime(self, t):
 
        """request that the player go to this time"""
 
        treq.post(networking.musicPlayer.path('time'),
 
        treq.post(
 
            networking.musicPlayer.path('time'),
 
                  data=json.dumps({
 
                      "t": time
 
                  }).encode('utf8'),
 
                  headers={b"content-type": [b"application/json"]},
 
        )
 
        
tasks.py
Show inline comments
 
@@ -38,20 +38,20 @@ def mypy(ctx):
 

	
 
    sources = ' '.join(bin_sources + pkg_sources())
 
    ctx.run(f'env/bin/flake8 --ignore=E115,E123,E124,E126,E225,E231,E261,E262,E265,E301,E302,E303,E305,E306,E401,E402,E501,E701,E731,W291,W293,W391,W504 {sources}', warn=True)
 

	
 
    sources = ' '.join(pkg_sources())
 
    run(['bin/rdfdb'])
 
    run(['bin/keyboardcomposer'])
 
    #for src in bin_sources:
 
    #    print(f"mypy {src}")
 
    #    run([src])# + pkg_sources())
 
@task
 
def reformat(ctx):
 
    ctx.run("env/bin/yapf --verbose --parallel --in-place --style google light9/**/*.py `file --no-pad  bin/* | grep 'Python script' | perl -lpe 's/:.*//'`")
 
    ctx.run("env/bin/yapf --verbose --parallel --in-place --style google light9/*.py light9/*/*.py `file --no-pad  bin/* | grep 'Python script' | perl -lpe 's/:.*//'`")
 
    
 
@task
 
def test(ctx):
 
    ctx.run('docker build -f Dockerfile.build -t light9_build:latest .')
 
    ctx.run('docker run --rm -it -v `pwd`:/opt light9_build:latest'
 
            ' nose2 -v light9.currentstategraphapi_test light9.graphfile_test',
 
            pty=True)
0 comments (0 inline, 0 general)