小编sku*_*erk的帖子

使用Pyrebase库拒绝Firebase权限

我已经设置了Firebase帐户和数据库.

我已将带有API密钥的配置复制到我的Python代码中.

我仍然在Python 3.5上获得401 Permission denied错误

import pyrebase
config = {
"apiKey": "*****",
"authDomain": "***-bot.firebaseapp.com",
"databaseURL": "https://***-bot.firebaseio.com",
"storageBucket": "ebo-bot.appspot.com"
}

firebase = pyrebase.initialize_app(config)
db = firebase.database()
data = {"name": "Mortimer 'Morty' Smith"}
db.child("users").child("Morty").set(data)
Run Code Online (Sandbox Code Playgroud)

我的数据库规则设置为:

{
 "rules": {
".read": "auth != null",
".write": "auth != null"
}
}
Run Code Online (Sandbox Code Playgroud)

firebase

4
推荐指数
1
解决办法
4001
查看次数

Docker 镜像无法在 Google Container Registry 上构建

我已经设置了一个从 Bitbucket 到 Google Container Registry 的触发器。我在根目录中有一个 Dockerfile,并且能够从我的本地机器上很好地构建容器。

当触发器运行时,我在 Google Container Registry 中收到此错误(我没有修改 GCR 想要运行的命令 - 这是默认设置)。我的项目名称已替换为“项目”:

FETCHSOURCE
Initialized empty Git repository in /workspace/.git/
From https://source.developers.google.com/p/project/r/bitbucket-project-gateway
* branch c65f16b3f52262a047c71e7140aecc4300265497 -> FETCH_HEAD
HEAD is now at c65f16b testing
BUILD
Already have image (with digest): gcr.io/cloud-builders/docker
invalid argument "gcr.io/project/bitbucket-project-gateway:" for t: invalid reference format
See 'docker build --help'.
ERROR
ERROR: build step "gcr.io/cloud-builders/docker@sha256:e576df764ae28d3c072019a235b6c8966df11eecb472c59b0963d783bb8a713b" failed: exit status 125
Run Code Online (Sandbox Code Playgroud)

google-cloud-platform google-container-registry

4
推荐指数
1
解决办法
4581
查看次数

在架构注册表中存储Avro架构

我正在使用Confluent的JDBC连接器以Avro格式将数据发送到Kafka.我需要将此架构存储在架构注册表中,但我不确定它接受的格式.我在这里阅读了文档,但没有提到太多.

我试过这个(将Avro输出并粘贴到 - 一个int和一个字符串字段):

curl -X POST -H "Content-Type: application/vnd.schemaregistry.v1+json"     --data '{"type":"struct","fields":[{"type":"int64","optional":true,"field":"id"},{"type":"string","optional":true,"field":"serial"}],"optional":false,"name":"test"}' http://localhost:8081/subjects/view/versions
Run Code Online (Sandbox Code Playgroud)

但我得到错误:{"error_code":422,"message":"无法识别的字段:类型"}

avro apache-kafka

3
推荐指数
2
解决办法
3584
查看次数

龙卷风异步队列不等待

我从这个 Tornado文档中使用生产者和消费者修改了示例队列,但传递给 get() 的超时参数似乎根本不起作用,因为消费者在抛出异常之前不会等待 10 秒。理想情况下,生产者和消费者将同时运行。另外,我不知道是将超时参数作为秒还是毫秒传递:

from tornado import gen
from tornado.ioloop import IOLoop
from tornado.queues import Queue

q = Queue()

@gen.coroutine
def consumer():
    try:
        while True:
            item = yield q.get(timeout=10000)
            try:
                print('Doing work on %s' % item)      
            finally:
                q.task_done()
    except gen.TimeoutError:
        print('timeout')
        return

@gen.coroutine
def producer():
    for item in range(5):
        yield q.put(item)
        print('Put %s' % item)
        yield gen.sleep(2)

@gen.coroutine
def main():
    # Start consumer without waiting (since it never finishes).
    IOLoop.current().spawn_callback(consumer)
    yield producer()     # Wait for producer …
Run Code Online (Sandbox Code Playgroud)

python queue tornado

1
推荐指数
1
解决办法
1149
查看次数

Facebook Messenger bot购买按钮

我正在尝试在我的messenger机器人中实现购买按钮,但是得到这两个错误:

{"error":{"message":"(#-1) Send API unexpected internal error","type":"OAuthException","code":-1,"error_subcode":2018012,"fbtrace_id":"BN47MpNqWNN"}} 

{"error":{"message":"(#100) Invalid button type","type":"OAuthException","code":100,"error_subcode":2018037,"fbtrace_id":"Agfk\/h+cEta"}}
Run Code Online (Sandbox Code Playgroud)

任何想法可能是什么问题?我在哪里可以查找这些错误代码?这是我发送给Facebook的Messenger API的消息:

{'message': {'attachment': {'type': 'template', 'payload': {'text': 'Please checkout.', 'template_type': 'button', 'buttons': [{'payment_summary': {'merchant_name': "Peter's Apparel", 'currency': 'USD', 'payment_type': 'FIXED_AMOUNT', 'price_list': [{'amount': '29.99', 'label': 'Subtotal'}, {'amount': '2.47', 'label': 'Taxes'}], 'requested_user_info': ['contact_name'], 'is_test_payment': True}, 'type': 'payment', 'payload': 'DEVELOPER_DEFINED_PAYLOAD', 'title': 'buy'}, {'type': 'postback', 'payload': '{"title": "Confirm Order", "event_value": "", "event_name": "confirm_order"}', 'title': 'Confirm Order'}, {'type': 'postback', 'payload': '{"title": "Add Coupon Code", "event_value": "", "event_name": "add_coupon"}', 'title': 'Add Coupon Code'}]}}}, 'recipient': …
Run Code Online (Sandbox Code Playgroud)

facebook facebook-messenger-bot

1
推荐指数
1
解决办法
484
查看次数

Kafka Connect 不输出 JSON

我正在使用 JDBC Kafka 连接器将数据从数据库读取到 Kafka。这有效,但它总是以 Avro 格式输出数据,即使我已经指定它应该使用 JSON。我知道这样做是因为当我在 python 中使用来自该主题的消息时,我会在每条消息的顶部看到模式。

我像这样运行连接器:

/usr/bin/connect-standalone /etc/schema-registry/connect-json-standalone.properties /etc/kafka-connect-jdbc/view.properties
Run Code Online (Sandbox Code Playgroud)

connect-json-standalone.properties 文件的内容是:

bootstrap.servers=localhost:9092

key.converter=org.apache.kafka.connect.json.JsonConverter
key.converter.schema.registry.url=http://localhost:8081
key.converter.schemas.enable=true
value.converter=org.apache.kafka.connect.json.JsonConverter
value.converter.schema.registry.url=http://localhost:8081
value.converter.schemas.enable=true

internal.key.converter=org.apache.kafka.connect.json.JsonConverter
internal.value.converter=org.apache.kafka.connect.json.JsonConverter
internal.key.converter.schemas.enable=false
internal.value.converter.schemas.enable=false

# Local storage file for offset data
offset.storage.file.filename=/tmp/connect.offsets
Run Code Online (Sandbox Code Playgroud)

/etc/kafka-connect-jdbc/view.properties 的内容是:

name=view-small-jdbc-daily
connector.class=io.confluent.connect.jdbc.JdbcSourceConnector
tasks.max=1
connection.url=jdbc:teradata://domain.com/charset=UTF8,DBS_PORT=1025,DATABASE=test,USER=***,PASSWORD=***,LOB_SUPPORT=OFF
mode=bulk
table.whitelist=test_table
topic.prefix=view5-
Run Code Online (Sandbox Code Playgroud)

apache-kafka apache-kafka-connect

0
推荐指数
1
解决办法
4058
查看次数