예제 #1
0
 def remote(self, server='localhost:8000'):
     ''' 
     Establishes identities for GUS and Code collab for proxy ticket update
     and code review creation.  Code collab client cannot activate review for
     remote.
     '''
     gus = BacklogClient()
     session_id = gus.session_id()
     cc = CodeCollabClient()
     author = cc.get_current_user()
     mrhat = MrHat()
     creds = mrhat.get_current_creds()
     commit = self.buildCommit()
     commit['gus_session'] = session_id
     commit['collab_user'] = author
     commit['jenkins_user'] = creds[0]
     commit['jenkins_token'] = creds[1]
     
     conn = httplib.HTTPConnection(server)
     head = {
         'Content-Type' : 'application/json',
         'Accept'       : 'application/json'
     }
     conn.request('POST','/service/post', json.dumps(commit), head)
     response = conn.getresponse()
     data = response.read()
     conn.close()
     
     print data
예제 #2
0
    def remote(self, server='localhost:8000'):
        ''' 
        Establishes identities for GUS and Code collab for proxy ticket update
        and code review creation.  Code collab client cannot activate review for
        remote.
        '''
        gus = BacklogClient()
        session_id = gus.session_id()
        cc = CodeCollabClient()
        author = cc.get_current_user()
        mrhat = MrHat()
        creds = mrhat.get_current_creds()
        commit = self.buildCommit()
        commit['gus_session'] = session_id
        commit['collab_user'] = author
        commit['jenkins_user'] = creds[0]
        commit['jenkins_token'] = creds[1]

        conn = httplib.HTTPConnection(server)
        head = {
            'Content-Type': 'application/json',
            'Accept': 'application/json'
        }
        conn.request('POST', '/service/post', json.dumps(commit), head)
        response = conn.getresponse()
        data = response.read()
        conn.close()

        print data
예제 #3
0
 def show_potential_work(self, messages):
     gus = BacklogClient()
     userid = gus.get_current_user_id()
     current_work = gus.get_potential_work_for_user(userid)
     
     if len(current_work) > 0:
         messages.append("Perhaps one of these:")
         for work in current_work:
             s = "\t%s (%s): %s" % (work[0], work[1], work[2])
             if s not in messages:
                 messages.append(s)    
예제 #4
0
 def valiate(self, comment):
     messages = []
     annotations = comment.annotations()
     if 'fixes' in annotations or 'updates' in annotations:
         if 'fixes' in annotations:
             gus_id = annotations['fixes']
         else:
             gus_id = annotations['updates']
             
         gus = BacklogClient()
         try:
             work = gus.find_work(gus_id)
             
             if work['Closed__c'] == 1:
                 messages.append("Work %s is already Closed.  This change needs a new work item." % gus_id)
         except:
             messages.append("Can't connect to GUS to check work status. Connect to vpn before committing.")
             
     return messages
예제 #5
0
 def validate(self, comment):
     messages = []
     annotations = comment.annotations()
     if 'fixes' in annotations:
         gus_id = annotations['fixes']
         gus = BacklogClient()
         try:
             work = gus.find_work(gus_id)
             status = work['Status__c']
             
             if status != 'In Progress':
                 messages.append("Work %s status is not In Progress, please update GUS before committing" % gus_id)
         except NoRecordException:
             messages.append("Invalid GUS id: %s.  Please use a valid W# in Gus" % gus_id)
             GusHelper().show_potential_work(messages)
         except:
             messages.append("Can't connect to GUS to check work status.  Connect to vpn before committing.")
             
     return messages
예제 #6
0
 def validate(self, comment):
     messages = []
     annotations = comment.annotations()
     build_id = None
     
     if 'scheduled_build' in annotations:
         build_id = annotations['scheduled_build']
     elif 'next' in annotations:
         mrhat = MrHat()
         build_id = mrhat.find_next_build(annotations['next'])
         
     if build_id is not None:
         try:
             gus = BacklogClient()
             gus.find_build_id(build_id)
         except NoRecordException:
             messages.append("Build label %s is not valid.  Please specify a valid build label with either @scheduled_build or @next." % build_id)
         except:
             messages.append("Unable to connect to Gus to validate build. Connect to vpn before committing")
         
     return messages
예제 #7
0
 def __gus_session__(self, commit):
     if 'gus_session' in commit:
         gus = BacklogClient(session_id=commit['gus_session'])
     else:
         gus = BacklogClient()
     return gus