Changeset - bee1c0747242
[Not reviewed]
default
0 7 0
Drew Perttula - 6 years ago 2019-05-27 10:46:29
drewp@bigasterisk.com
switch from cyclone.httpclient to treq everywhere
Ignore-this: 60dbd235b745a1198b14c90be9d4abe2
7 files changed with 48 insertions and 38 deletions:
0 comments (0 inline, 0 general)
light9/curvecalc/curveedit.py
Show inline comments
 
@@ -2,11 +2,13 @@
 
this may be split out from curvecalc someday, since it doesn't
 
need to be tied to a gui """
 
import cgi
 
from twisted.internet import reactor
 
import cyclone.web, cyclone.httpclient, cyclone.websocket
 

	
 
from louie import dispatcher
 
from rdflib import URIRef
 
from twisted.internet import reactor
 
import cyclone.web
 

	
 
from cycloneerr import PrettyErrorHandler
 
from louie import dispatcher
 

	
 

	
 
def serveCurveEdit(port, hoverTimeResponse, curveset):
light9/effect/edit.py
Show inline comments
 
import json
 
import cyclone.httpclient
 
from rdflib import URIRef, Literal
 
from twisted.internet.defer import inlineCallbacks, returnValue
 
from rdflib import URIRef, Literal
 
import treq
 

	
 
from light9 import networking
 
from light9.curvecalc.curve import CurveResource
 
from light9.namespaces import L9, RDF, RDFS
 
from rdfdb.patch import Patch
 
from light9.curvecalc.curve import CurveResource
 

	
 

	
 
def clamp(x, lo, hi):
 
@@ -15,10 +14,9 @@ def clamp(x, lo, hi):
 

	
 
@inlineCallbacks
 
def getMusicStatus():
 
    returnValue(
 
        json.loads(
 
            (yield cyclone.httpclient.fetch(networking.musicPlayer.path('time'),
 
                                            timeout=.5)).body))
 
    resp = yield treq.get(networking.musicPlayer.path('time'), timeout=.5)
 
    body = yield resp.json_content()
 
    returnValue(body)
 

	
 

	
 
@inlineCallbacks
light9/effecteval/effectloop.py
Show inline comments
 
import time, json, logging, traceback
 
import numpy
 
import serial
 
import time, logging, traceback
 

	
 
from rdflib import URIRef
 
from twisted.internet import reactor
 
from twisted.internet.defer import inlineCallbacks, returnValue, succeed
 
from twisted.internet.error import TimeoutError
 
from rdflib import URIRef
 
import cyclone.httpclient
 
from light9.namespaces import L9, RDF
 
from light9.effecteval.effect import EffectNode
 
import numpy
 
import serial
 
import treq
 

	
 
from light9 import Effects
 
from light9 import networking
 
from light9 import Submaster
 
from light9 import dmxclient
 
from light9 import networking
 
from light9.effecteval.effect import EffectNode
 
from light9.namespaces import L9, RDF
 

	
 
log = logging.getLogger('effectloop')
 

	
 

	
 
@@ -66,8 +69,8 @@ class EffectLoop(object):
 
        old = now - self.requestTime
 
        if old > self.coastSecs:
 
            try:
 
                response = json.loads((yield cyclone.httpclient.fetch(
 
                    networking.musicPlayer.path('time'), timeout=.5)).body)
 
                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:
light9/greplin_cyclone.py
Show inline comments
 
import cyclone.web, cyclone.websocket, cyclone.httpclient
 
import cyclone.web
 

	
 
import greplin.scales.twistedweb, greplin.scales.formats
 
from greplin import scales
light9/networking.py
Show inline comments
 
from urllib.parse import urlparse
 

	
 
from rdflib import URIRef
 
from urllib.parse import urlparse
 

	
 
from .showconfig import getGraph, showUri
 
from .namespaces import L9
 

	
 
@@ -33,8 +35,8 @@ class ServiceAddress(object):
 

	
 
    value = url
 

	
 
    def path(self, more):
 
        return self.url + str(more)
 
    def path(self, more: str) -> URIRef:
 
        return URIRef(self.url + more)
 

	
 

	
 
captureDevice = ServiceAddress(L9['captureDevice'])
light9/subcomposer/subcomposerweb.py
Show inline comments
 
import logging
 
import cyclone.web, cyclone.websocket, cyclone.httpclient
 

	
 
from rdflib import URIRef, Literal
 
from twisted.internet import reactor
 
import cyclone.web
 

	
 
from cycloneerr import PrettyErrorHandler
 
from light9 import networking
 
from rdflib import URIRef, Literal
 
from twisted.internet import reactor
 

	
 
log = logging.getLogger('web')
 

	
 

	
light9/vidref/musictime.py
Show inline comments
 
import time, json, logging
 
from light9 import networking
 
from typing import Dict
 

	
 
from twisted.internet import reactor
 
from cyclone.httpclient import fetch
 
from typing import Dict
 
import treq
 

	
 
from light9 import networking
 

	
 
log = logging.getLogger()
 

	
 

	
 
@@ -80,7 +83,7 @@ class MusicTime(object):
 
            log.warn("talking to ascoltami: %s", err.getErrorMessage())
 
            reactor.callLater(2, self.pollMusicTime)
 

	
 
        d = fetch(networking.musicPlayer.path("time"))
 
        d = treq.get(networking.musicPlayer.path("time").toPython())
 
        d.addCallback(cb)
 
        d.addErrback(eb)  # note this includes errors in cb()
 

	
 
@@ -117,17 +120,16 @@ class MusicTime(object):
 
            self.lastHoverTime = None
 
            reactor.callLater(2, self.pollCurvecalcTime)
 

	
 
        d = fetch(networking.curveCalc.path("hoverTime"))
 
        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"""
 
        fetch(
 
            method=b'POST',
 
            url=networking.musicPlayer.path('time'),
 
            postdata=json.dumps({
 
                "t": t
 
        treq.post(networking.musicPlayer.path('time'),
 
                  data=json.dumps({
 
                      "t": time
 
            }).encode('utf8'),
 
            headers={b"content-type": [b"application/json"]},
 
        )
 
        
0 comments (0 inline, 0 general)