Exemple #1
0
    def __init__(self,hub,name,sdpfilename,w,h,dojpeg=True,dortp=True,netmode=True,jpeginfo="",h264info=""):
        # create two UdpServer
        self.size = (w,h)
        self.name = name
        self.process = None
        print ("ffmpeg subscriber",name)
        self.subscriber = aiopubsub.Subscriber(hub,"")
        self.subscriber.subscribe(name)
        self.subscriber.add_listener(name, self.push,last=True)
        self.netmode = netmode

        if dortp:
            self.rtppub = aiopubsub.Publisher(hub, prefix = aiopubsub.Key(name,'rtp'))
            self.hserver = RTPStreamServer(self.onrtp)
            self.hserver.bind(0,family=socket.AF_INET)
            self.hserver.start()
            hports = self.hserver.ports()
            #h264info.split(" ") +
            rtppart =  ["-f","rtp","-sdp_file",sdpfilename] +  ["rtp://127.0.0.0:%d" % hports[0]]
        else:
            hports = []
            self.rtppub = None
            self.hserver = None
            rtppart = []
            # TODO expose: new JPEG packet event 

        if dojpeg:
            self.jpegpub = aiopubsub.Publisher(hub, prefix = aiopubsub.Key(name,'jpeg'))
            self.jserver = JpegStreamServer(self.onjpeg)
            self.jserver.listen(0)
            jports = self.jserver.ports()
            #jpeginfo.split(" ") +
            jpegpart = ["-f","mjpeg"] +  ["tcp://127.0.0.0:%d" % jports[0]]
            # TODO expose: new RTP packet event 
        else:
            jports = []
            self.jpegpub = None
            self.jserver = None
            jpegpart = []

        if not dojpeg and not dortp:
            self.args = None
            return
        else:
            beforesource = ["ffmpeg","-y","-f","rawvideo","-r","30","-pix_fmt","rgb32","-s","%dx%d" % (w,h)]
            print ("ffmpeg: ","jports",jports,"hports",hports)
            if not self.netmode:
                args = beforesource + ["-i","-"] + jpegpart + rtppart
            else:
                self.lserver = ForwardStreamServer()
                self.lserver.listen(0)
                lports = self.lserver.ports()
                args = beforesource + ["-i","tcp://127.0.0.0:%d" % lports[0]] + jpegpart + rtppart
            self.args = args
        self.tl = None
Exemple #2
0
 def __init__(self,hub,name):
     self.name = name
     print ("PILCompressor subscribing to",name)
     self.jpegpub = aiopubsub.Publisher(hub, prefix = aiopubsub.Key(name,'jpeg'))
     self.subscriber = aiopubsub.Subscriber(hub,"")
     self.subscriber.subscribe(name)
     self.subscriber.add_listener(name, self.push,last=True)
Exemple #3
0
    def __init__(self, hub: aiopubsub.Hub, currency: mm_bot.model.currency.CurrencyPair,
            loop_delay, api_key: str, api_secret: str):
        self.side = 'taker'
        self._logger = logging.getLogger(self.__class__.__name__)
        self._client = binance.AsyncClient(api_key, api_secret)
        self._loop = aiopubsub.loop.Loop(self._run, delay = loop_delay)
        self._hub = hub
        self._publisher = aiopubsub.Publisher(self._hub, self.name)
        self._currency = currency
        self._last_ask_best: mm_bot.model.book.PriceLevel = None
        self._last_bid_best: mm_bot.model.book.PriceLevel = None

        # https://www.binance.com/en/trade-rule
        self.min_total_order_value = {
            'BTC': Decimal('0.02'),
            'ETH': Decimal('0.2'),
            'USDT': Decimal('60'),
        }
        # https://www.binance.com/en/trade-rule
        self.min_price_movement = {
            'BTC': '0.000001',
            'WAVESBTC': '0.0000001',
            'ETH': '0.000001',
            'USDT': '0.01',
            'NEOUSDT': '0.001',
            'WAVESUSDT': '0.0001',
        }
Exemple #4
0
    def __init__(self, hub: aiopubsub.Hub,
                 currency: mm_bot.model.currency.CurrencyPair, bc_address: str,
                 bc_scookie: str, bc_wallet_address: str,
                 bc_private_key_hex: str, base_address: str,
                 counter_address: str):
        self.side = 'maker'
        self.name = 'borderless'
        self._logger = logging.getLogger(self.__class__.__name__)
        self._loop = aiopubsub.loop.Loop(self._run,
                                         delay=config(
                                             'exchange_borderless_loop_delay',
                                             parser=int))
        self._hub = hub
        self._publisher = aiopubsub.Publisher(self._hub, self.name)
        self._currency = currency

        self._bc_rpc_address = bc_address
        self._bc_rpc_scookie = bc_scookie
        self._bc_wallet_address = bc_wallet_address
        self._bc_private_key_hex = bc_private_key_hex
        self._bc_base_address = base_address
        self._bc_counter_address = counter_address

        self._last_ask_best: mm_bot.model.book.PriceLevel = None
        self._last_bid_best: mm_bot.model.book.PriceLevel = None
Exemple #5
0
def init_pubsub():
    """Initiate pubsub module, create default publisher"""
    try:
        this.hub = aiopubsub.Hub()
        this.publisher = aiopubsub.Publisher(this.hub, prefix=aiopubsub.Key())
    except Exception:
        logger.exception('Error initiationg pubsub module')
        raise
Exemple #6
0
    def save(self):
        choice = self.cleaned_data["choice"]

        choice.votes += 1
        choice.save()

        publisher = aiopubsub.Publisher(hub, aiopubsub.Key("poll"))
        publisher.publish(aiopubsub.Key("on_vote"), self.poll)
Exemple #7
0
 def __init__(self,hub,parts=None,rate=30):
     self.sct = mss.mss()
     self.rate = rate
     self.consumers = []
     if parts is None:
         self.isfull = True
         self.parts = [(0,0,self.sct.monitors[1][0],self.sct.monitors[1][1])]
     else:
         self.isfull = False
         self.parts=parts
     self.pubs=[]
     for i in range(0,len(self.parts)):
         self.pubs.append(aiopubsub.Publisher(hub,aiopubsub.Key()))
Exemple #8
0
    def __init__(self):
        logwood.basic_config()
        self.hub = aiopubsub.Hub()
        self.publisher = aiopubsub.Publisher(self.hub,
                                             prefix=aiopubsub.Key('peer'))
        self.subscriber_epoch = aiopubsub.Subscriber(self.hub, 'epoch_subscr')
        self.subscriber_connection = aiopubsub.Subscriber(
            self.hub, 'conn_subscr')
        self.subscriber_pom = aiopubsub.Subscriber(self.hub, 'pom_subsrc')

        sub_key_epoch = aiopubsub.Key('peer', 'epoch')
        self.subscriber_epoch.subscribe(sub_key_epoch)

        sub_key_conn = aiopubsub.Key('peer', 'connection')
        self.subscriber_connection.subscribe(sub_key_conn)

        sub_key_pom = aiopubsub.Key('peer', 'pom')
        self.subscriber_pom.subscribe(sub_key_pom)
Exemple #9
0
import aiopubsub
import functools

from galacteek import log
from galacteek.core import runningApp

gHub = aiopubsub.Hub()

publisher = aiopubsub.Publisher(gHub, prefix=aiopubsub.Key('g'))


@functools.lru_cache(maxsize=256)
def makeKey(*args):
    if isinstance(args, str):
        return aiopubsub.Key(args)
    elif isinstance(args, tuple):
        return aiopubsub.Key(*args)


def makeKeyChatChannel(channel):
    return makeKey('g', 'chat', 'channels', channel)


def makeKeyChatUsersList(channel):
    return makeKey('g', 'pubsub', 'chatuserslist', channel)


def makeKeyPubChatTokens(channel):
    return makeKey('g', 'pubsub', 'tokens', 'pubchat', channel)

Exemple #10
0
import aiopubsub

hub = aiopubsub.Hub()

canbus_publisher = aiopubsub.Publisher(hub, prefix=aiopubsub.Key("canbus"))
lora_publisher = aiopubsub.Publisher(hub, prefix=aiopubsub.Key("lora"))
Exemple #11
0
def publisher(hub):
    return aiopubsub.Publisher(hub, 'Tester')