• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python pusher.Pusher类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pusher.Pusher的典型用法代码示例。如果您正苦于以下问题:Python Pusher类的具体用法?Python Pusher怎么用?Python Pusher使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Pusher类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: pusher_auth

def pusher_auth(request):
    profile = ModelFactory.profile_from_request(request)

    log.debug('Pusher Auth called.')
    if request.method != 'POST':
        raise Http404('Unexpected method type for Pusher access.')

    p = Pusher(
    app_id=os.environ['PUSHER_APP_ID'],
        key=os.environ['PUSHER_APP_KEY'],
        secret=os.environ['PUSHER_APP_SECRET'],
        ssl=True,
        port=443
    )

    channel_name = request.POST.get('channel_name')
    socket_id = request.POST.get('socket_id')
    log.debug('Pusher Auth Channel_Name: {}'.format(channel_name))
    log.debug('Pusher Auth Socket ID: {}'.format(socket_id))
    data = {
        'user_id': str(profile.uuid),
        'user_info': {
            'name': profile.get_full_name(),
            'avatar_cropped_url': profile.avatar_cropped.url
        }
    }

    auth = p.authenticate(channel=channel_name, socket_id=socket_id, custom_data=data)
    return JsonResponse(auth)
开发者ID:kevcmk,项目名称:OpenEsperanto,代码行数:29,代码来源:auth_views.py


示例2: pusher_info

def pusher_info(sender, instance=None, created=False, **kwargs):
    pusher = Pusher(app_id=PUSHER_ID, key=PUSHER_KEY, secret=PUSHER_SECRET,
                    ssl=True)
    if created:
        if instance.group.channel:
            pusher.trigger(instance.group.channel, instance.group.event, {'message': instance.message})
        else:
            pusher.trigger(instance.group.channel, instance.group.event, {'message': instance.message})
开发者ID:UpgrAID,项目名称:UpgrAID,代码行数:8,代码来源:models.py


示例3: receive_votes

def receive_votes(request):
    pusher = Pusher(
        app_id=os.environ.get('PUSHER_APP', ''),
        key="ca2bcf928a3d000ae5e4",
        secret=os.environ.get('PUSHER_SECRET', '')
        )
    json_response = {"success": False}
    row = Voting.objects.get(pk=1)
    try:
        if request.method == "GET":
            data = request.GET
            if data["vote"] == "up":
                row.score = row.score + 1
                row.total_votes = row.total_votes + 1
                row.save()
                pusher.trigger(
                    "voting_channel",
                    "new_vote",
                    {"score": row.score}
                    )
                # success
                json_response = {"success": True}
                return HttpResponse(
                    json.dumps(json_response),
                    content_type="application/json"
                    )
            elif data["vote"] == "down":
                row.score = row.score - 1
                row.total_votes = row.total_votes + 1
                row.save()
                pusher.trigger(
                    "voting_channel",
                    "new_vote",
                    {"score": row.score}
                    )
                # success
                json_response = {"success": True}
                return HttpResponse(
                    json.dumps(json_response),
                    content_type="application/json"
                    )
            else:
                return HttpResponse(
                    json.dumps(json_response),
                    content_type="application/json"
                    )

        else:
            return HttpResponse(
                json.dumps(json_response),
                content_type="application/json"
                )
    except Exception as e:
        json_response = {"success": False, "error": str(e)}
        return HttpResponse(
            json.dumps(json_response),
            content_type="application/json"
            )
开发者ID:xoneco,项目名称:ajax_pusher_voting,代码行数:58,代码来源:views.py


示例4: stopService

   def stopService(self):
      self.stopped = True
      for k in self.connects:
         c = self.connects[k]
         if c.pushclient is not None:
            c.pushclient.stop()
            c.pushclient = None

      Pusher.stopService(self)
开发者ID:Inspire2Innovate,项目名称:crossbar,代码行数:9,代码来源:dbpusher.py


示例5: socketio_view

def socketio_view(request):
	print "called"
	p = Pusher(
	  app_id='135314',
	  key='92e6deea4ee5542dc495',
	  secret='712204ca7293ef75bd11',
	  ssl=True,
	  port=443
	)
	p.trigger('test_channel', 'my_event', {'message': 'hello world'})
开发者ID:jkol36,项目名称:gforce,代码行数:10,代码来源:views.py


示例6: startService

   def startService(self):
      Pusher.startService(self)

      self.stopped = False
      self.connects = {}
      self.dbpool.runInteraction(self.recache)

      ## current statistics
      self.stats = {}
      self.stats[None] = self._createPushStat(None)
      self.publishPusherStats()
开发者ID:Inspire2Innovate,项目名称:crossbar,代码行数:11,代码来源:dbpusher.py


示例7: handle

    def handle(self, *args, **options):
        message = ' '.join(options['message'])
        print(message)

        pusher = Pusher(
          app_id='121933',
          key='f1ebb516981a3315e492',
          secret='d9f31be884b8be02bcbc'
        )

        pusher.trigger('test_channel', 'my_event', {'message': message})
开发者ID:andela-osule,项目名称:djangocon-realtime,代码行数:11,代码来源:pusher.py


示例8: _publish

    def _publish(self, action):
        serializer = self.serializer_class(instance=self)
        data = serializer.serialize()

        pusher = Pusher(
            app_id=settings.PUSHER_APP_ID,
            key=settings.PUSHER_KEY,
            secret=settings.PUSHER_SECRET
        )

        pusher.trigger(self.channel_name, action, data)
开发者ID:aaronbassett,项目名称:djangocon-pusher,代码行数:11,代码来源:mixins.py


示例9: save_read

def save_read(sender, instance, created, raw, **kwargs):
    if not raw:
        if created:
            instance.user.num_unread_notis += 1
            instance.user.save()
            user = instance.user
            channel = "notification_" + user.user.username
            pusher = Pusher("216867", "df818e2c5c3828256440",
                            "5ff000997a9df3464eb5")

            serializer = A2AUserSerializer(user)
            event_data = serializer.data
            pusher.trigger(channel, 'new_noti', event_data)
开发者ID:Xuan-Duc,项目名称:tech2016,代码行数:13,代码来源:models.py


示例10: on_data

    def on_data(self, data):
        pusher = Pusher(
            app_id=u'',
            key=u'',
            secret=u''
        )

        temp_tokens = []

        if self.collection.count() == max_tweets:
            self.disconnect()

        data_dict = json.loads(data)
        self.collection.insert(json.loads(data))
        if 'retweeted_status' not in data_dict:
            text = data_dict['text']
            tweets = self.collection.count()

            encoded_text = text.encode('ascii', 'ignore').lower()
            temp_tokens.extend(regexp_tokenize(encoded_text, self.regex, gaps=False))
            filtered_tokens = [term for term in temp_tokens if not term in self.stop_words]

            num_tokens = len(filtered_tokens)
            print 'Tweet num: ' + str(self.collection.count()) + '\n' + encoded_text
            print 'Parsed and filtered: ' + str(filtered_tokens) + ' words'

            self.num_words += num_tokens

            print 'Total tokens: ' + str(self.num_words)

            self.tokens.extend(filtered_tokens)
            self.top_monograms = get_monograms_freqdist(self.tokens)
            self.top_bigrams = get_bigrams_freqdist(self.tokens)
            self.top_trigrams = get_trigrams_freqdist(self.tokens)

            colldata = get_dataframe_dict(self.top_monograms, 5, {}, tweets, self.collection)

            dataframe = colldata[0]
            labels = list(colldata[0].columns.values)
            # print str(time)
            print os.getcwd()

            # with open(os.getcwd() + '\wordstream\static\js\keywords.json', 'w') as outfile:
            #     json.dump(labels, outfile)

            pusher.trigger('my-channel', 'my-event', {
                'message': labels
            })
开发者ID:bdeloeste,项目名称:TweetCastr,代码行数:48,代码来源:tweet.py


示例11: test_initialize_from_env

    def test_initialize_from_env(self):
        with mock.patch.object(os, 'environ', new={'PUSHER_URL':'https://plah:[email protected]/apps/42'}):
            pusher = Pusher.from_env()
            self.assertEqual(pusher.ssl, True)
            self.assertEqual(pusher.key, u'plah')
            self.assertEqual(pusher.secret, u'bob')
            self.assertEqual(pusher.host, u'somehost')
            self.assertEqual(pusher.app_id, u'42')

        with mock.patch.object(os, 'environ', new={'PUSHER_DSN':'https://plah:[email protected]/apps/42'}):
            pusher = Pusher.from_env('PUSHER_DSN')
            self.assertEqual(pusher.ssl, True)
            self.assertEqual(pusher.key, u'plah')
            self.assertEqual(pusher.secret, u'bob')
            self.assertEqual(pusher.host, u'somehost')
            self.assertEqual(pusher.app_id, u'42')
开发者ID:Sendhub,项目名称:pusher_client_python,代码行数:16,代码来源:test_pusher.py


示例12: __init__

 def __init__(self, **kwargs):
     self.client = Pusher(app_id=getattr(settings, 'PUSHER_APP_ID'),
                          key=getattr(settings, 'PUSHER_KEY'),
                          secret=getattr(settings, 'PUSHER_SECRET'),
                          host=getattr(settings, 'PUSHER_HOST', u'127.0.0.1'),
                          port=getattr(settings, 'PUSHER_SEND_PORT', 4567),
                          ssl=getattr(settings, 'PUSHER_SEND_USE_SSL', False),)
开发者ID:rosscdh,项目名称:chute-client,代码行数:7,代码来源:services.py


示例13: test_validate_webhook_bad_time

    def test_validate_webhook_bad_time(self):
        pusher = Pusher.from_url(u'http://foo:[email protected]/apps/4')

        body = u'{"time_ms": 1000000}'
        signature = six.text_type(hmac.new(pusher.secret.encode('utf8'), body.encode('utf8'), hashlib.sha256).hexdigest())

        with mock.patch('time.time', return_value=1301):
            self.assertEqual(pusher.validate_webhook(pusher.key, signature, body), None)
开发者ID:Sendhub,项目名称:pusher_client_python,代码行数:8,代码来源:test_pusher.py


示例14: test_initialize_from_url

    def test_initialize_from_url(self):
        self.assertRaises(TypeError, lambda: Pusher.from_url(4))
        self.assertRaises(Exception, lambda: Pusher.from_url(u"httpsahsutaeh"))

        conf = Pusher.from_url(u"http://foo:[email protected]/apps/4")
        self.assertEqual(conf.ssl, False)
        self.assertEqual(conf.key, u"foo")
        self.assertEqual(conf.secret, u"bar")
        self.assertEqual(conf.host, u"host")
        self.assertEqual(conf.app_id, u"4")

        conf = Pusher.from_url(u"https://foo:[email protected]/apps/4")
        self.assertEqual(conf.ssl, True)
        self.assertEqual(conf.key, u"foo")
        self.assertEqual(conf.secret, u"bar")
        self.assertEqual(conf.host, u"host")
        self.assertEqual(conf.app_id, u"4")
开发者ID:rosscdh,项目名称:pusher-http-python,代码行数:17,代码来源:test_config.py


示例15: test_authenticate_for_private_channels

    def test_authenticate_for_private_channels(self):
        pusher = Pusher.from_url(u'http://foo:[email protected]/apps/4')

        expected = {
            u'auth': u"foo:89955e77e1b40e33df6d515a5ecbba86a01dc816a5b720da18a06fd26f7d92ff"
        }

        self.assertEqual(pusher.authenticate(u'private-channel', u'345.23'), expected)
开发者ID:Sendhub,项目名称:pusher_client_python,代码行数:8,代码来源:test_pusher.py


示例16: put

  def put(self, request, filename="image.png", format=None):
    pusher = Pusher(app_id=u'160687', key=u'0eb2780d9a8a875c0727', secret=u'b45f1f052cd3359c9ceb')

    username = request.data['username']
    names_file = request.data['names_file']
    prices_file = request.data['prices_file']

    user = User.objects.get(username=username)
    new_receipt = user.receipt_set.create(
      names_image = names_file, 
      prices_image = prices_file
    )

    p1 = subprocess.Popen(['tesseract', new_receipt.names_image.path, 'stdout', '-psm', '6'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    names_file_ocr = p1.communicate()[0]

    p2 = subprocess.Popen(['tesseract', new_receipt.prices_image.path, 'stdout', '-psm', '6'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    prices_file_ocr = p2.communicate()[0]

    names_split = names_file_ocr.decode().split('\n')
    prices_split = prices_file_ocr.decode().split('\n')

    print(names_split)
    print(prices_split)

    names_split = [x for x in names_split if x != '']
    prices_split = [x for x in prices_split if x != '']

    print(names_split)
    print(prices_split)

    for i in range(0, len(names_split)):
      name = names_split[i]

      price = prices_split[i]
      strippedPrice = ''.join([c for c in price if c in '1234567890.'])

      new_receipt.receiptitem_set.create(
        name = name,
        price = Decimal(strippedPrice),
      )

      pusher.trigger(u'receipt_channel', u'new_receipt', { "username": username })

    return Response(status=204)
开发者ID:SuNaden,项目名称:receiptScanner,代码行数:45,代码来源:views.py


示例17: pushNotification

def pushNotification(request,email,data,time,img,event):
    channel = u"customuser_{pk}".format(
        pk=email
    )
    pusher = Pusher(app_id=settings.PUSHER_APP_ID,
                    key=settings.PUSHER_KEY,
                    secret=settings.PUSHER_SECRET)
    event_data = {
        'object' : data,
        'user': request.user.email
    }
    if time != None:
        event_data.update({'time' : time,'img' : img})
    pusher.trigger(
        [channel,],
        event,
        event_data
    )
开发者ID:IshaanChawla,项目名称:OneBook,代码行数:18,代码来源:views.py


示例18: test_x_pusher_library_header

 def test_x_pusher_library_header(self):
     conf = Pusher.from_url(u'http://key:[email protected]/apps/4')
     req = Request(conf._pusher_client, u'GET', u'/some/obscure/api', {u'foo': u'bar'})
     self.assertTrue('X-Pusher-Library' in req.headers)
     pusherLib = req.headers['X-Pusher-Library']
     regex = r'^pusher-http-python \d+(\.\d+)+(rc\d+)?$'
     if sys.version_info < (3,):
         self.assertRegexpMatches(pusherLib, regex)
     else:
         self.assertRegex(pusherLib, regex)
开发者ID:pusher,项目名称:pusher-http-python,代码行数:10,代码来源:test_request.py


示例19: test_validate_webhook_bad_signature

    def test_validate_webhook_bad_signature(self):
        pusher = Pusher.from_url(u'http://foo:[email protected]/apps/4')

        body = u'some body'
        signature = u'some signature'

        with mock.patch('time.time') as time_mock:
            self.assertEqual(pusher.validate_webhook(pusher.key, signature, body), None)

        time_mock.assert_not_called()
开发者ID:Sendhub,项目名称:pusher_client_python,代码行数:10,代码来源:test_pusher.py


示例20: __init__

 def __init__(self, bot, event, query, message):
     self.bot = bot
     self.event = event
     self.query = query
     self.message = message
     self.pusher = Pusher(
             app_id=u'144525',
             key=u'f87e45c335b6d8004e51',
             secret=u'37f03e68c7e0900fb045'
             )
开发者ID:alexako,项目名称:summonBot,代码行数:10,代码来源:pusher_trigger.py



注:本文中的pusher.Pusher类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python db.execute_cb函数代码示例发布时间:2022-05-25
下一篇:
Python pushbullet.Pushbullet类代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap