【发布时间】:2020-03-01 14:38:55
【问题描述】:
我正在尝试将 Google Cloud Functions 配置为在触发该功能时下订单。
我在requirements.txt 文件中提到了kiteconnect
但是该功能没有被部署。引发错误“未知资源类型”。
完整的错误消息:
Deployment failure: Build failed: {"error": {"canonicalCode": "INVALID_ARGUMENT", "errorMessage": "`pip_download_wheels` had stderr output:\nCommand \"python setup.py egg_info\" failed with error code 1 in /tmp/pip-wheel-97dghcl9/logging/\n\nerror: `pip_download_wheels` returned code: 1", "errorType": "InternalError", "errorId": "67DBDBF3"}}
有没有人有使用云功能在 zerodah 下交易订单的经验?
以下是我尝试过的功能:
import logging
from kiteconnect import KiteConnect
logging.basicConfig(level=logging.DEBUG)
kite = KiteConnect(api_key="xxxxxxxxxxxxxxxxxxxxxxxx")
# Redirect the user to the login url obtained
# from kite.login_url(), and receive the request_token
# from the registered redirect url after the login flow.
# Once you have the request_token, obtain the access_token
# as follows.
data = kite.generate_session("xxxxxxxxxxxxxxxxxxxxxxxxx", secret="xxxxxxxxxxxxxxxxxxxxxxxxxx")
kite.set_access_token(data["xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"])
# Place an order
def orderPlace():
order_id = kite.place_order(
variety=kite.VARIETY_REGULAR,
exchange=kite.EXCHANGE_NSE,
tradingsymbol="INFY",
transaction_type=kite.TRANSACTION_TYPE_BUY,
quantity=1,
product=kite.PRODUCT_CNC,
order_type=kite.ORDER_TYPE_MARKET
)
logging.info("Order placed. ID is: {}".format(order_id))
except Exception as e:
logging.info("Order placement failed: {}".format(e.message))
requirements.txt 文件内容:
# Function dependencies, for example:
# package>=version
kiteconnect
【问题讨论】:
-
总是将完整的错误消息(从单词“Traceback”开始)作为文本(不是屏幕截图)放在有问题的(不是评论)中。还有其他有用的信息。
-
谢谢。但是 Traceback 没有错误消息。我可以在日志中看到以下内容:2019-11-05 12:40:02.628 IST Cloud Functions UpdateFunction us-central:pl_ord xxxxxxxxxxxxxxx@gmail.com INVALID_ARGUMENT
-
还发现:部署失败:构建失败:{"error": {"canonicalCode": "INVALID_ARGUMENT", "errorMessage": "
pip_download_wheelshad stderr output:\nCommand \"python setup .py egg_info\" 失败,错误代码 1 在 /tmp/pip-wheel-97dghcl9/logging/\n\nerror:pip_download_wheels返回代码: 1", "errorType": "InternalError", "errorId": "67DBDBF3 "}} -
所有有问题的日志消息 - 它们将更具可读性。其他人也会看到他们。他们可能会跳过 cmets。
-
请添加您的 requirements.txt 文件的内容。你在本地测试过这段代码吗?
标签: python python-3.x google-cloud-platform google-cloud-functions