当前位置: 首页>>代码示例>>Python>>正文


Python Rally.post方法代码示例

本文整理汇总了Python中pyral.Rally.post方法的典型用法代码示例。如果您正苦于以下问题:Python Rally.post方法的具体用法?Python Rally.post怎么用?Python Rally.post使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyral.Rally的用法示例。


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

示例1: Rally

# 需要导入模块: from pyral import Rally [as 别名]
# 或者: from pyral.Rally import post [as 别名]
NAME = re.search("([^a-z]{2}\d+)", PR_NAME).group(0)
SERVER = "rally1.rallydev.com"
USER = ""
PASSWORD = ""
WORKSPACE = "Crossroads - Ministry Platform"
PROJECT = "Crossroads IT Applications Service Line"
APIKEY = "Your API Key Here"

# Only run for opened PRs
if ACTION == "opened" or ACTION == "reopened":
    # Rally Service Layer
    rally = Rally(SERVER, USER, PASSWORD, apikey=APIKEY, workspace=WORKSPACE, project=PROJECT)
    rally.enableLogging('mypyral.log')
    query_criteria = 'FormattedID = "%s"' % NAME

    ARTIFACT_TYPES = ['Defect', 'UserStory']
    for atype in ARTIFACT_TYPES:
        response = rally.get(atype, fetch=True, query=query_criteria)

        # Here's where you tell Rally what to do
        item_data = {
            "FormattedID": NAME,
            "Ready": True
        }

        for artifact in response:
            # Green check items after successful PR (Devs)
            if artifact.c_CrossroadsKanbanState == 'Developing' and artifact.Blocked != True:
                rally.post(atype, itemData=item_data, workspace='current', project='current')
                print "PR Opened"
开发者ID:crdschurch,项目名称:utilities,代码行数:32,代码来源:greencheck.py

示例2: RallyClient

# 需要导入模块: from pyral import Rally [as 别名]
# 或者: from pyral.Rally import post [as 别名]
class RallyClient(object):
    def __init__(self, rally_server, username, password, oauth_key):
        print "Initializing RallyClient\n"
        self.rally_server = rally_server
        rally_url = self.rally_server['url']
        credentials = CredentialsFallback(self.rally_server, username, password).getCredentials()
        self.rest_api = None
        self.configure_proxy()
        self.rest_api = Rally(URI(rally_url), credentials['username'], credentials['password'],
                              apikey=oauth_key if oauth_key else self.rally_server['oAuthKey'], verify_ssl_cert=False)

    @staticmethod
    def create_client(rally_server, username, password, oauth_key):
        print "Executing create_client() in RallyClient class in RallyClient.py\n"
        return RallyClient(rally_server, username, password, oauth_key)

    def configure_proxy(self):
        if self.rally_server['proxyHost']:
            os.environ["HTTP_PROXY"] = "http://%s:%s" % (self.rally_server['proxyHost'], self.rally_server['proxyPort'])
            os.environ["HTTPS_PROXY"] = "https://%s:%s" % (self.rally_server['proxyHost'], self.rally_server['proxyPort'])
            
            if self.rally_server['proxyUsername']:
                os.environ["HTTP_PROXY"] = "http://%s:%[email protected]%s:%s" % (
                    self.rally_server['proxyUsername'], self.rally_server['proxyPassword'],
                    self.rally_server['proxyHost'],
                    self.rally_server['proxyPort'])
                os.environ["HTTPS_PROXY"] = "https://%s:%[email protected]%s:%s" % (
                    self.rally_server['proxyUsername'], self.rally_server['proxyPassword'],
                    self.rally_server['proxyHost'],
                    self.rally_server['proxyPort'])
            

    def lookup_item_by_formatted_id(self, workspace, project, type, formatted_id):
        self.rest_api.setWorkspace(workspace)
        self.rest_api.setProject(project)
        response = self.rest_api.get(type, fetch="ObjectID", query="FormattedID = %s" % formatted_id)

        if not response.errors:
            print("Total results: %d\n" % response.resultCount)
            result = response.next()
            return result.ObjectID
        else:
            print("The following errors occurred: ")
            for err in response.errors:
                print("\t" + err)
            return None

    def create_sub_item(self, workspace, project, properties, user_story_formatted_id, user_story_type, property_type,
                        item_type):
        self.rest_api.setWorkspace(workspace)
        self.rest_api.setProject(project)
        story_ref = self.lookup_item_by_formatted_id(workspace, project, user_story_type, user_story_formatted_id)

        property_dict = dict(ast.literal_eval(properties))
        property_dict[property_type] = story_ref

        return self.create_item(workspace, project, property_dict, item_type)

    def create_item(self, workspace, project, properties, item_type):
        self.rest_api.setWorkspace(workspace)
        self.rest_api.setProject(project)

        item_create_response = self.rest_api.put(item_type, properties)

        print "Executed successful on Rally"
        return item_create_response.FormattedID

    def update_item(self, workspace, project, properties, item_formatted_id, item_type):
        self.rest_api.setWorkspace(workspace)
        self.rest_api.setProject(project)
        item_object_id = self.lookup_item_by_formatted_id(workspace, project, item_type, item_formatted_id)
        property_dict = dict(ast.literal_eval(properties))
        property_dict["ObjectID"] = item_object_id

        update_response = self.rest_api.post(item_type, property_dict)

        print "Executed successful on Rally"
        return update_response.FormattedID
    
    def query(self, workspace, project, item_type, query, fetch="True", rollupdata=False):
        self.rest_api.setWorkspace(workspace)
        self.rest_api.setProject(project)
        response = self.rest_api.get(item_type, fetch=fetch, query=query, projectScopeDown=rollupdata)

        if not response.errors:
            print("Total results: %d\n" % response.resultCount)
            return response
        else:
            print("The following errors occurred: ")
            for err in response.errors:
                print("\t" + err)
            return None

    def get_user_object_id(self, owner_username=None, owner_name=None):
        response = self.rest_api.getUserInfo(username=owner_username, name=owner_name)

        return response[0].ObjectID
开发者ID:xebialabs-community,项目名称:xlr-rally-plugin,代码行数:99,代码来源:RallyClient.py


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