Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用python访问azure开发人员操作数据,例如日期之间的变更集?_Python_Azure_Azure Devops_Azure Devops Rest Api - Fatal编程技术网

如何使用python访问azure开发人员操作数据,例如日期之间的变更集?

如何使用python访问azure开发人员操作数据,例如日期之间的变更集?,python,azure,azure-devops,azure-devops-rest-api,Python,Azure,Azure Devops,Azure Devops Rest Api,我正在尝试连接到AZURE开发人员操作系统并获取更改集信息,以使用PYTHON自动化发布说明的准备 在阅读了from link中提供的文档和流程后,我使用了以下内容: from azure.devops.connection import Connection from msrest.authentication import BasicAuthentication import pprint # Fill in with your personal access token and org

我正在尝试连接到AZURE开发人员操作系统并获取更改集信息,以使用PYTHON自动化发布说明的准备

在阅读了from link中提供的文档和流程后,我使用了以下内容:

from azure.devops.connection import Connection
from msrest.authentication import BasicAuthentication
import pprint

# Fill in with your personal access token and org URL
personal_access_token = 'mypattokenvalue'
organization_url = 'https://dev.azure.com/myorg'

# Create a connection to the org
credentials = BasicAuthentication('', personal_access_token)
connection = Connection(base_url=organization_url, creds=credentials)
tfsv_client = connection.clients.get_tfvc_client()
project_name="myprojname"
search_criteria=".item_path='$/myprojname/Trunk/Main',.fromDate:'01-01-2019',.toDate:'11-13-2019-2:00PM'"

changeset_info = tfvcclient.get_changesets(project=project_name,search_criteria=search_criteria)
执行代码时抛出错误:

'str' object has no attribute 'item_path' in following line of code of the package eventhoughi provided Item_path value:

   255         if search_criteria is not None:
--> 256             if search_criteria.item_path is not None:
    257                 query_parameters['searchCriteria.itemPath'] = search_criteria.item_path
我曾尝试以字典的形式给出搜索条件,但也出现了同样的错误。如果根本不提供项路径,它将抛出相同的错误

因此,我不确定如何将数据提供到搜索条件参数中,以用于get_changesets方法

我请求任何人提供有关如何提供数据的帮助,以便我可以使用PYTHON从AZURE Dev Ops在给定项目的主分支下使用日期范围查询变更集的信息

在2019年11月15日的现有后期更新中添加其他查询:

这是软件包中的一个缺陷/bug,因为它没有采用我试图提供的值,或者我提供搜索条件的方式是错误的? 如果这是一个合法的问题,你能让我知道我在哪里可以记录它的缺陷? 如果提供的值或我提供的值的方式有误,请向我展示/解释正确的方式好吗

提前谢谢

问候


ChaitayaNG

,因为错误表明
str'对象没有属性“item\u path”
。您定义的变量search\u criteria
str
类型。无法获取str搜索条件不存在的属性
item\u path

您应该定义搜索条件的对象类型,例如,请检查下面的代码

  search_criteria = type('',(object,),{"item_path":'$/myprojname/Trunk/Main',"fromDate":'01-01-2019', "toDate":'11-13-2019-2:00PM'})

根据您的错误消息,它不是包中的缺陷/bug。您的
搜索\u条件
变量类型不支持这种方式
搜索\u条件。获取值的项路径
。我认为您应该更改您的
搜索条件
类型,以确保您可以获取
项目路径
起始日期
toDate
成功。正如我在上面试图解释的那样,如果我在表单字典中创建搜索条件,我也会收到相同类型的错误,指出:“dict”对象没有属性“item\u path”,并且在同一行代码中。事实上,我试图按原样执行代码,提供您定义的搜索条件,用实际的项目名称替换项目名称,但我得到了相同的错误。能否请您在同一时间再次提供输入?提前感谢您的帮助和时间。我更新了上面的答案,将搜索条件定义为一个对象。现在可以通过
搜索条件引用项目路径。项目路径
。感谢Levi提供的快速解决方案和时间。这在我这一方奏效了。但是您能告诉我您是如何得出结论的,或者您如何推断搜索条件应该作为对象类型传递的?我只是想知道这些信息来提高我的知识水平,以便在需要时也可以在其他领域使用这种方法。从您发布的错误中,我们可以知道代码将项目路径视为搜索条件的属性。如果我们将搜索条件定义为str或dict,那么item_path不是它的属性。我还检查以确保搜索条件应定义为具有item_path属性的对象