def __init__(self, *args, **kwargs):
     self.key = "de504dc5763aeef9ff52"
     self.channels = {}
     self.messages = {
         "live_trades": ["trade"],
         "order_book": ["data"],
         "diff_order_book": ["data"],
         "live_orders": ["order_created", "order_changed", "order_deleted"]
     }
     for channel in self.messages.keys():
         self.channels[channel] = []
         for pair in ["btceur", "eurusd"]:
             self.channels[channel + "_" + pair] = []
     self.orderbook = {
         "btc": {
             "eur": None,
             "usd": None
         },
         "eur": {
             "usd": None
         }
     }
     self.lastprice = self.orderbook
     self.openorders = self.orderbook
     for base in self.openorders.keys():
         for quote in self.openorders[base].keys():
             self.openorders[base][quote] = {"price": {}, "id": {}}
     self.pusher = pusherclient.Pusher(self.key)
     self.pusher.connect()
Пример #2
0
    def __init__(self,
                 broker_id,
                 username,
                 password,
                 websocket_url,
                 bid_fee=0.,
                 ask_fee=0.,
                 api_key=None,
                 api_secret=None,
                 dest_market='BTCUSD'):
        self.api_key = api_key
        self.api_secret = api_secret
        self.bid_fee = bid_fee
        self.ask_fee = ask_fee

        self.broker_id = broker_id
        self.username = username
        self.password = password
        self.websocket_url = websocket_url

        self.pusher = pusherclient.Pusher(key='de504dc5763aeef9ff52',
                                          log_level=logging.ERROR)
        self.pusher.connection.bind('pusher:connection_established',
                                    self.on_bitstamp_connect_handler)
        self.pusher.connection.bind('pusher:connection_failed',
                                    self.on_bitstamp_connect_failed_handler)

        self.arbitrator = BlinkTradeArbitrator(self.broker_id, self.username,
                                               self.password,
                                               self.websocket_url, dest_market)
        self.arbitrator.signal_order.connect(self.on_send_order_to_bitstamp)
        self.arbitrator.signal_logged.connect(self.on_blinktrade_logged)
        self.arbitrator.signal_disconnected.connect(
            self.on_blinktrade_discconnected)
        self.arbitrator.signal_connected.connect(self.on_blinktrade_connected)
Пример #3
0
 def __init__(self, ticker, *args, **kwargs):
     self.ticker = ticker
     self.pusher = pusherclient.Pusher(BTCUSDWorker.BITSTAMP_APP_KEY,
                                       log_level=logging.WARNING)
     self.pusher.connection.bind('pusher:connection_established',
                                 self.subscribe)
     self.pusher.connect()
Пример #4
0
 def __init__(self, recent_trades):
     self.recent_trades = recent_trades
     self.logger = logging.getLogger('trades')
     self.client = pusherclient.Pusher(BITSTAMP_PUSHER_KEY)
     self.client.connection.bind('pusher:connection_established',
                                 self.on_connect)
     self.client.connect()
Пример #5
0
    def __init__(self, bus):
        self.bus = bus
        with open(CLIENT_SECRETS_FILE) as data_file:
            data = json.load(data_file)

        self.p = pusherclient.Pusher(data['pusher']['key'])
        self.p.connection.bind('pusher:connection_established',
                               self.connect_handler)
        self.p.connect()
Пример #6
0
 def __init__(self, key, secret, channel_name, event_name,
              event_callback_function):
     self.channel_name = channel_name
     self.event_name = event_name
     self.event_callback_function = event_callback_function
     self.pusher = pusherclient.Pusher(key, secret)
     self.pusher.connection.bind('pusher:connection_established',
                                 self.connect_handler)
     self.pusher.connect()
Пример #7
0
def bitstamp_setup():

    def connect_handler(data):
        channel = pusher.subscribe('live_trades')
        channel.bind('trade', bitstamp_callback)

    appkey = BITSTAMP_APPKEY
    pusher = pusherclient.Pusher(appkey)
    pusher.connection.bind('pusher:connection_established', connect_handler)
    pusher.connect()
Пример #8
0
 def __init__(self, log_file_path, log_file_reload_path, pusher_key,
              channel, event):
     self.channel = channel
     self.event = event
     self.log_file_fd = open(log_file_path, "a")
     self.log_file_reload_path = log_file_reload_path
     self.pusher = pusherclient.Pusher(pusher_key)
     self.pusher.connection.logger.setLevel(logging.WARNING)
     self.pusher.connection.bind('pusher:connection_established',
                                 self.connect_handler)
     self.pusher.connect()
Пример #9
0
    def start(self):
        """
        Extension of Pusher.connect() method, which registers all callbacks with
        the relevant channels, before initializing a connection.
        :return:
        """
        super(BitstampWSS, self).start()

        self.pusher = pusherclient.Pusher(self.addr, **self.__pusher_options)
        self.pusher.connection.bind('pusher:connection_established',
                                    self._register_bindings)
        self.pusher.connect()
Пример #10
0
    def start(self):
        def connect_handler(data):
            print("connect_handler")
            trades_channel = pusher.subscribe("live_trades")
            trades_channel.bind('trade', trade_callback)
            order_book_channel = pusher.subscribe('order_book')
            order_book_channel.bind('data', order_book_callback)

        pusher = pusherclient.Pusher("de504dc5763aeef9ff52")
        pusher.connection.bind('pusher:connection_established',
                               connect_handler)
        pusher.connect()
        self.pusher = pusher
Пример #11
0
    def init(self, key, event, channel, symbol, depth, base, quote):
        self.event = event
        self.symbol = symbol
        self.depth = depth
        self.base = base
        self.quote = quote
        self.key = key

        if base == "btc" and quote == "usd":
            self.channel = channel
        else:
            self.channel = channel + "_" + self.symbol

        self.pusher = pusherclient.Pusher(self.key)
        self.pusher.connection.bind('pusher:connection_established',
                                    self.opened)
        self.pusher.connect()
Пример #12
0
    def __init__(self, pusher_api_key, callback_chan, logger=None):
        """Constructor

        Arguments:
            pusher_api_key: the key to authenticate with pusher with
            callback_chan: the channel to use to receive callbacks
        """
        self.logger = logger or logging.getLogger(__name__)
        self.pusher_connected_listeners = []
        self.pos_callback_chan = callback_chan
        self.pusher = pusherclient.Pusher(pusher_api_key)
        self.pusher.connection.logger.setLevel(logging.WARNING)
        self.pusher.connection.bind('pusher:connection_established',
                                    self._pusher_connect_handler)
        self.pusher.connect()
        self.pusherthread_stop = Event()
        self.pusherthread = Thread(target=self._runForever,
                                   args=(self.pusherthread_stop, ))
Пример #13
0
    def __call__(self):
        self._call_init()

        self.logger = logging.getLogger(self.__module__ + "." +
                                        self.__class__.__qualname__)
        self.pusher = pusherclient.Pusher(self.pusher_key,
                                          log_level=logging.WARNING)
        self.pusher.connection.bind('pusher:connection_established',
                                    self._connect_handler)
        self.pusher.connect()
        self.q = Queue()
        self.saver = Thread(target=self._saving_thread)
        self.saver.start()
        self.logger.info('Started')

        while not self.stop_flag.is_set():
            time.sleep(1)
        self.saver.join()
        self.logger.info('Exit')
Пример #14
0
def hvacsettings_callback(data):
    # TODO - update hvac settings
    
def hvactemp_callback(data):
    temp_data = json.loads(data)
    arduino.write('stmp' + json_data['temp'])
    
def connect_handler(data):
    lights_channel = pusher.subscribe("lights") 
    hvac_channel = pusher.subscribe("lights")
    lights_channel.bind('update_lights', lights_callback)
    hvac_channel.bind('update_settings', hvacsettings_callback)
    hvac_channel.bind('update_temp', hvacsettings_callback)
    
if __name__ == '__main__':
    pusher = pusherclient.Pusher('bbfd2fdfc81124a36b18')
    pusher.connection.bind('pusher:connection_established', connect_handler)
    while True:
        time.sleep(1)
    def __init__(self, *args, **kwargs):
        self.key = 'de504dc5763aeef9ff52'  # Bitstamp pusher key.
        self.channels = {}
        self.messages = {
            'live_trades': ['trade'],
            'order_book': ['data'],
            'diff_order_book': ['data'],
            'live_orders': ['order_created', 'order_changed', 'order_deleted']
        }
        self.lock = Lock()
        for channel in self.messages.keys():
            self.channels[channel] = []
            for pair in PAIRS:
                self.channels[channel + '_' + pair] = []

        self.lastprice_btcusd = generate_response_template()
        self.lastprice_btceur = generate_response_template()
        self.lastprice_eurusd = generate_response_template()
        self.lastprice_xrpusd = generate_response_template()
        self.lastprice_xrpeur = generate_response_template()
        self.lastprice_xrpbtc = generate_response_template()
        self.lastprice_ltcusd = generate_response_template()
        self.lastprice_ltceur = generate_response_template()
        self.lastprice_ltcbtc = generate_response_template()
        self.lastprice_ethusd = generate_response_template()
        self.lastprice_etheur = generate_response_template()
        self.lastprice_ethbtc = generate_response_template()
        self.lastprice_bchusd = generate_response_template()
        self.lastprice_bcheur = generate_response_template()
        self.lastprice_bchbtc = generate_response_template()

        self.orderbook_btceur = generate_response_template()
        self.orderbook_btcusd = generate_response_template()

        self.openorders = generate_response_template()
        for base in self.openorders.keys():
            for quote in self.openorders[base].keys():
                self.openorders[base][quote] = {'price': {}, 'id': {}}
        self.pusher = pusherclient.Pusher(self.key)
        self.pusher.connect()
Пример #16
0
def main():
    args = get_args()
    app = args.app[0]
    key = args.key[0]
    secret = args.secret[0]
    port = args.port[0]
    baud = args.baud[0]
    rx_channel, rx_event = args.rx_channel_event[0].split(':')
    tx_channel, tx_event = args.tx_channel_event[0].split(':')
    push = pusher.Pusher(app_id=app,
                         key=key,
                         secret=secret,
                         ssl=True,
                         port=443)
    push_client = pusherclient.Pusher(key, secret=secret)
    with PySerialDriver(port, baud) as driver:
        with Handler(Framer(driver.read, driver.write)) as handler:

            def push_it(sbp_msg):
                push.trigger(tx_channel, tx_event, sbp_msg.to_json_dict())

            def pull_it(data):
                handler(SBP.from_json(data))

            def connect_it(data):
                push_client.subscribe(rx_channel).bind(rx_event, pull_it)

            push_client.connection.bind('pusher:connection_established',
                                        connect_it)
            push_client.connect()

            try:
                for msg, metadata in handler.filter(OBS_MSG_LIST):
                    push_it(msg)
            except KeyboardInterrupt:
                pass
Пример #17
0
    """
    def __init__(self):
        super(Transactions, self).__init__()
        self.source = 'https://www.bitstamp.net/api/transactions/?time=hour'
        self.update_interval = 60


class TransactionsBackup(ObjectSignal):
    """
    Transactions Signal for Backup (Daily)
    """
    def __init__(self):
        super(TransactionsBackup, self).__init__()
        self.source = 'https://www.bitstamp.net/api/transactions/?time=day'
        self.update_interval = 60 * 60 * 3  # Every 3 hours


def connection_handler(data):
    global pusher

    order_book = pusher.subscribe('order_book')
    order_book.bind('data', OrderBook.update)

    live_trades = pusher.subscribe('live_trades')
    live_trades.bind('trade', Trades.update)


pusher = pusherclient.Pusher('de504dc5763aeef9ff52', log_level=logging.WARNING)
pusher.connection.bind('pusher:connection_established', connection_handler)
pusher.connect()
Пример #18
0
    bst_ticker['source'] = 'bst'
    bst_ticker['ask'] = float(ticker['asks'][0][0])
    bst_ticker['bid'] = float(ticker['bids'][0][0])
    bst_ticker['mid'] = round((bst_ticker['ask'] + bst_ticker['bid']) / 2, 2)
    bst_ticker['ts'] = time.time()
    bst = json.dumps(bst_ticker, ensure_ascii=False)
    print "BST: ", bst
    print r.set('bst', bst)
    print r.publish('bix-usd', bst)


def connect_handler(data):
    channel = pusher.subscribe("order_book")

    channel.bind('data', channel_callback)


if __name__ == '__main__':

    r = redis.StrictRedis(host='localhost', port=6379, db=0)

    appkey = 'de504dc5763aeef9ff52'

    pusher = pusherclient.Pusher(appkey)

    pusher.connection.bind('pusher:connection_established', connect_handler)
    pusher.connect()

    while True:
        time.sleep(0.1)
Пример #19
0
    clientDatas = json.loads(data)
    if 'message' in data:
        print("Test successful!")


def ping_handler():
    print("pinging...")


def run():
    global serialNumber
    global clientData
    while True:
        # Do other things in the meantime here...
        print("Listening for " + str(serialNumber) + "...")
        print clientData
        time.sleep(2)


initialize()
pusher = pusherclient.Pusher("f3a6952cc326ee48eb10", True,
                             "700363677ba4fd2d6f8c", {'cluster': 'eu'},
                             logging.INFO, True, None, 2)
pusher.connection.bind('pusher:connection_established', connect_handler)
pusher.connect()
while True:
    # Do other things in the meantime here...
    print("Listening for " + str(serialNumber) + "...")
    print clientData
    time.sleep(2)
Пример #20
0
global pusher

def print_usage(filename):
    print "Usage: python %s <appkey> <secret> <userid>" % filename

def channel_callback(data):
    print "Channel Callback: %s" % data

def connect_handler(data):
    channel = pusher.subscribe("presence-channel")

    channel.bind('my_event', channel_callback)


if __name__ == '__main__':
    if len(sys.argv) != 4:
        print_usage(sys.argv[0])
        sys.exit(1)

    appkey = sys.argv[1]
    secret = sys.argv[2]
    userid = sys.argv[3]

    pusher = pusherclient.Pusher(appkey, secret=secret, user_data={'user_id': userid})

    pusher.connection.bind('pusher:connection_established', connect_handler)
    pusher.connect()

    while True:
        time.sleep(1)
Пример #21
0
def show_loading():
    with canvas(device) as draw:
        draw.text((0, 0), "Awaiting a BTC trade...", font=font, fill="white")


def main():
    show_loading()
    while True:
        time.sleep(1)


def handler(signum, frame):
    pusher.disconnect()
    sys.exit()


pusher = pusherclient.Pusher(BITSTAMP_PUSHER_KEY)
pusher.connection.bind('pusher:connection_established', connect_handler)
pusher.connect()

signal.signal(signal.SIGINT, handler)

if __name__ == "__main__":
    try:
        serial = spi(device=0, port=0, cs_high=True)
        device = sh1106(serial)
        main()
    except KeyboardInterrupt:
        pass
Пример #22
0
 def __init__(self, callback, *chans):
     self.pusher = pusherclient.Pusher(PUSHER_APP_KEY)
     self._callback = callback
     self._chans = chans
Пример #23
0
global pusher


def garageEventCallback(data):
    print("Received an event")
    gic.startRecording(60)


# We can't subscribe until we've connected, so we use a callback handler
# to subscribe when able
def connect_handler(data):
    channel = pusher.subscribe('robomow')
    channel.bind('garage-event', garageEventCallback)


pusher = pusherclient.Pusher("dafdd16435b9b98c88fd")
#pusher = pusherclient.Pusher("cc46da1883d0ec0a6197")
pusher.connection.bind('pusher:connection_established', connect_handler)
pusher.connect()


#
# Manages detecting of the Robomow as it approaches or leaves the garage
#    the opening / closing of the garage door
#    the notification of events surrounding the garage
class GarageInternalCamera():
    #PUSHER_APP_ID = '487778'
    PUSHER_APP_ID = '489803'
    #PUSHER_KEY = 'cc46da1883d0ec0a6197'
    PUSHER_KEY = 'cc46da1883d0ec0a6197'
    #PUSHER_SECRET = 'cff575fc033daf5660a2'
Пример #24
0
                            asks_dict[asks_list[i]]))
                        print(out_string)
                    print()


def connect_handler(data):
    channel = pusher.subscribe(pusherchannel)
    channel.bind(pusherevent, callback)


logger = logging.getLogger()
logger.setLevel(logging.INFO)
log_stream_handler = logging.StreamHandler(Stream_Printer)
logger.addHandler(log_stream_handler)

pusher = pusherclient.Pusher(pusherkey)
pusher.connection.bind('pusher:connection_established', connect_handler)
pusher.connect()

try:
    while True:
        time.sleep(1)
except KeyboardInterrupt:
    print("\n\nKeyboard interrupt detected, exiting...\n")
    exit(0)
except:
    exit(1)

### pusherclient code license ###
'''
Copyright (c) 2011 Erik Kulyk
Пример #25
0
 def __init__(self):
     self.pusher = pusherclient.Pusher('82341182465af8c47698', cluster='eu')
     self.pusher.connection.bind('pusher:connection_established', self.pusher_connected)
     self.pusher.connect()
Пример #26
0
import pusherclient

# Import Homebrew



# Add a logging handler so we can see the raw communication data
import logging
root = logging.getLogger()
root.setLevel(logging.INFO)
ch = logging.StreamHandler(sys.stdout)
root.addHandler(ch)

global pusher

# We can't subscribe until we've connected, so we use a callback handler
# to subscribe when able
def connect_handler_BTCUSD(data):
    channel = pusher.subscribe('order_book')
    channel.bind('trade', callback)


pusher = pusherclient.Pusher('de504dc5763aeef9ff52')
pusher.connection.bind('pusher:connection_established', connect_handler_BTCUSD)
pusher.connect()

while True:
    # Do other things in the meantime here...
    time.sleep(1)

Пример #27
0
def pusher_server():
    # SETTING THE CHANNEL AND EVENT TO TRIGGER EACH TIME
    event = 'App\Events\eventTrigger'
    channel = 'petfeed'

    # THE CALLBACK FUNCTION THAT WILL RUN AFTER EACH TRIGGER
    def callback_function(data):
        data = ast.literal_eval(data)

        # IF THE KEY GET HAS STATUS RETURN THE STATUS OF DEVICE
        if 'get' in data.keys():
            with connection.cursor() as cursor:
                query = "SELECT DISTINCT id, email FROM users WHERE email=%s"
                try:
                    cursor.execute(query, data['user'])
                    user = cursor.fetchone()

                except:
                    user = None

            if user is not None:

                if data['get'] == 'status':

                    pusherEvent.trigger(
                        channel, event, {
                            'connection': 'global',
                            'user': user['email'],
                            'message': 'Device is running perfectly fine.',
                            'status': 'online'
                        })

                elif data['get'] == 'schedule':

                    with connection.cursor() as cursor:
                        try:
                            query = "SELECT * FROM schedules WHERE user_id=%s"

                            cursor.execute(query, user['id'])
                            schedules_result = cursor.fetchall()
                            schedules = []

                            for s in schedules_result:
                                scheduled_day = s['day']
                                scheduled_time = datetime.strftime(
                                    s['time'], "%H:%M")

                                schedules.append({
                                    "day": scheduled_day,
                                    "time": scheduled_time
                                })

                            pusherEvent.trigger(
                                channel, event, {
                                    'connection': 'global',
                                    'user': user['email'],
                                    'data': schedules,
                                    'status': 'Success'
                                })

                        except:
                            schedules = []

                            pusherEvent.trigger(
                                channel, event, {
                                    'connection':
                                    'global',
                                    'user':
                                    user['email'],
                                    'data':
                                    schedules,
                                    'status':
                                    'error',
                                    'message':
                                    'Could not find schedules for specified user. (Schedules not set yet)'
                                })

                elif data['get'] == 'restart':
                    pusherEvent.trigger(
                        channel, event, {
                            'connection': 'global',
                            'user': user['email'],
                            'status': 'restarting',
                            'message': 'Restarting your device.'
                        })
                    os.system('sudo restart')

                elif data['get'] == 'shutdown':
                    pusherEvent.trigger(
                        channel, event, {
                            'connection': 'global',
                            'user': user['email'],
                            'status': 'shuttingdown',
                            'message': 'Shutting down your device.'
                        })
                    os.system('sudo shutdown')

                else:
                    pusherEvent.trigger(
                        channel, event, {
                            'connection': 'global',
                            'status': 'error',
                            'message': 'invalid get'
                        })

            else:
                pusherEvent.trigger(
                    channel, event, {
                        'status': 'error',
                        'message': 'No device bound to the specified user.'
                    })

        # IF THE KEY FEED HAS THE VALUE FEED, FEED THE PET AND RETURN THE STATUS
        elif 'feed' in data.keys():

            try:
                user = data['user']

                with connection.cursor() as cursor:
                    query = "SELECT DISTINCT id, email FROM users WHERE email=%s"
                    cursor.execute(query, user)

                    user_result = cursor.fetchone()

                    if user_result is None:
                        pusherEvent.trigger(
                            channel, event, {
                                'connection':
                                'global',
                                'status':
                                'error',
                                'message':
                                'Specified user not registered to the device.'
                            })

                    else:
                        if data['feed'] == 'treat':
                            pusherEvent.trigger(
                                channel, event, {
                                    'connection': 'global',
                                    'status': 'online',
                                    'user': user_result['email'],
                                    'message': 'Feeding your pet, please wait.'
                                })
                            device_feed()
                            pusherEvent.trigger(
                                channel, event, {
                                    'connection': 'global',
                                    'status': 'online',
                                    'user': user_result['email'],
                                    'message':
                                    'Feeding completed successfully.'
                                })
                        else:
                            pusherEvent.trigger(
                                channel, event, {
                                    'connection': 'global',
                                    'status': 'error',
                                    'message': 'invalid value for feed:[]'
                                })

            except:
                pusherEvent.trigger(
                    channel, event, {
                        'connection': 'global',
                        'status': 'error',
                        'message': 'The user field isn\'t set'
                    })

        elif 'set' in data.keys():
            if data['set'] == 'schedule':
                try:
                    user = data['user']

                    with connection.cursor() as cursor:

                        query = "SELECT DISTINCT id, email FROM users WHERE email=%s"
                        cursor.execute(query, user)
                        user_result = cursor.fetchone()

                        if user_result is None:
                            pusherEvent.trigger(
                                channel, event, {
                                    'connection':
                                    'global',
                                    'status':
                                    'error',
                                    'message':
                                    'Specified user not registered to the device.'
                                })

                        else:
                            if data['data'] is not None:
                                for schedule in data['data']:
                                    day = schedule['day']
                                    feed_time = schedule['time']
                                    feed_time = datetime.strptime(
                                        feed_time, "%H:%M")

                                    sql = "INSERT INTO schedules (day, time, user_id) VALUES (%s, %s, %s)"
                                    cursor.execute(
                                        sql,
                                        (day, feed_time, user_result['id']))
                                connection.commit()

                                pusherEvent.trigger(
                                    channel, event, {
                                        'connection':
                                        'global',
                                        'status':
                                        'success',
                                        'message':
                                        'Your schedule was added successfully.'
                                    })
                            else:
                                pusherEvent.trigger(
                                    channel, event, {
                                        'connection': 'global',
                                        'status': 'error',
                                        'message': 'Empty data recieved.'
                                    })

                except:
                    with connection.cursor as cursor:
                        cursor.rollback()

                    pusherEvent.trigger(
                        channel, event, {
                            'connection':
                            'global',
                            'status':
                            'error',
                            'message':
                            'Internal error occurred while adding schedule'
                        })

            elif data['schedule'] == 'update':

                with connection.cursor() as cursor:
                    try:
                        user = data['user']

                        query = "SELECT DISTINCT id, email FROM users WHERE email=%s"
                        cursor.execute(query, user)
                        user_result = cursor.fetchone()

                        if user_result is None:
                            pusherEvent.trigger(
                                channel, event, {
                                    'connection':
                                    'global',
                                    'status':
                                    'error',
                                    'message':
                                    'Specified user not registered to the device.'
                                })

                        else:
                            query = "DELETE FROM schedules"
                            cursor.execute(query)

                            for schedule in data['data']:
                                day = schedule['day']
                                feed_time = schedule['time']
                                feed_time = datetime.strptime(
                                    feed_time, "%H:%M")

                                sql = "INSERT INTO schedules (day, time, user_id) VALUES (%s, %s, %s)"
                                cursor.execute(
                                    sql, (day, feed_time, user_result['id']))

                            connection.commit()

                            pusherEvent.trigger(
                                channel, event, {
                                    'connection':
                                    'global',
                                    'status':
                                    'success',
                                    'message':
                                    'Your schedule was updated successfully.'
                                })

                    except:
                        connection.rollback()

                    pusherEvent.trigger(
                        channel, event, {
                            'connection':
                            'global',
                            'status':
                            'error',
                            'message':
                            'Internal error occurred while updating schedule'
                        })

    def connect_handler(data):
        petfeed_channel = pusherClient.subscribe(channel)
        petfeed_channel.bind(event, callback_function)

    pusherClient = PusherClient.Pusher(key='0053280ec440a78036bc',
                                       secret='7bbae18dfe3989d432a6')
    pusherClient.connection.bind('pusher:connection_established',
                                 connect_handler)
    pusherClient.connect()

    pusherEvent = PusherEvent(app_id="440480",
                              key="0053280ec440a78036bc",
                              secret="7bbae18dfe3989d432a6",
                              cluster="mt1")

    while True:
        time.sleep(1)
Пример #28
0
    """
        Changes:
        -------
            Cluster: Added cluster in host name (also in process file arguments)
            Channel names, event names: Added chosen event names binding for given channel name
            
            -   Added cluster<string> parameter (<Pusher>)
                >   Added cluster in host name in <Pusher.__init__>
                >   Removed <Pusher._build_url> @classmethod attribute
            -   Added event_names<list> parameter (<Pusher>, <Connection>)
                >   Added event_names binding in <Connection.__init__>
                
            @acknowledgement:   Pysher (https://github.com/nlsdfnbch/Pysher/blob/master/pysher/pusher.py)
            @framework:         Pusher (https://pusher.com/tutorials/chat-widget-python)
    """
    event_names = []
    for c in channel_names:
        event_names += channel_names[c][1].keys()
    pusher = pusherclient.Pusher(appkey,
                                 cluster=appcluster,
                                 event_names=event_names)
    pusher.connection.bind('pusher:connection_established', connect_handler)

    pusher.connect()
    print
    print '------------------------------------------------------------'
    print

    while True:
        time.sleep(1)
Пример #29
0
 def __init__(self, channels=[]):
     self.channels = channels
     self.check_tradepair()
     self.currency = ''
     self.appkey = "de504dc5763aeef9ff52"
     self.pusher = pusherclient.Pusher(self.appkey)
Пример #30
0
import json
import time

import pusher
import pusherclient

app_key = 'a9afbec4cb2906a41792'


def transaction_handler(data):
    tx = json.loads(data)
    print('Received transaction:')
    print('\tSend {} from {} to {} with payload {}.'.format(
        tx['value'], tx['from'], tx['to'], tx['message']))


def connect_handler(data):
    channel = listener.subscribe('transactions')
    channel.bind('new-transaction', transaction_handler)


# HACK around library's lack of cluster support
pusherclient.Pusher.host = "ws-eu.pusher.com"

listener = pusherclient.Pusher(app_key)
listener.connection.bind('pusher:connection_established', connect_handler)
listener.connect()

while True:
    time.sleep(1)