iothub_service_client_args.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:azure-iot-sdk-python 作者: Azure 项目源码 文件源码
def get_iothub_opt(
        argv,
        connection_string,
        device_id):
    if len(argv) > 0:
        try:
            opts, args = getopt.getopt(
                argv, "hd:c:", [
                    "connectionstring=", "deviceid="])
        except getopt.GetoptError as get_opt_error:
            raise OptionError("Error: %s" % get_opt_error.msg)
        for opt, arg in opts:
            if opt == '-h':
                raise OptionError("Help:")
            elif opt in ("-c", "--connectionstring"):
                connection_string = arg
            elif opt in ("-d", "--deviceid"):
                device_id = arg

    if connection_string.find("HostName") < 0:
        raise OptionError(
            "Error: Hostname not found, not a valid connection string")

    return connection_string, device_id
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号