def wr(self, *msg, **kwargs): """ Print out run time message using command name as channel unless given as channel=<Name>. """ from q import Q channel = kwargs.get('channel') if not channel: channel = '@' + self.__class__.__name__[7:] Q.wr(channel, *msg)
def create_ticket(self, ticket): from q import Q proxy = self.proxy() id = proxy.ticket.create(ticket['Title'], ticket['Notes'], { 'status': '-', 'substatus': '-', 'milestone': self.settings.TRAC_INITIAL_MILESTONE}) if not id: raise QError("Failed to create new ticket.") Q.wr('Ticketing', "New ticket %r created in the remote." % id) return str(id)
def wr(self, *msg, **kwargs): """ Print out run time message. """ from q import Q channel = kwargs.get('channel') if not channel: if self.code: channel = "#" + self.code else: channel = "#NoTicket" Q.wr(channel, *msg, **kwargs)
def all_codes(self): """ Collect a list of all ticket codes of this project. """ from q import Q if not self.settings.WORKDIR: raise QError("Ticket storage directory WORKDIR is not set.") if not os.path.isdir(self.settings.WORKDIR): Q.wr("Initialize", "Creating ticket directory '%s'.", self.settings.WORKDIR) mkpath(self.settings.WORKDIR) ret = [] for p in os.listdir(self.settings.WORKDIR): if os.path.isfile(self.settings.WORKDIR + "/" + p + "/README"): ret.append(p) return ret
def _set_ticket(self, code, comment, **attributes): """ Fetch the ticket data for code. """ from q import Q Q.wr('Ticketing', "Updating remote ticket %r:" % code) for k in attributes: parts = unicode(attributes[k]).split("\n") if len(parts) == 1: v = parts[0] else: v = "\\n ".join(parts) Q.wr('Ticketing', " %s = %s" % (k, v)) proxy = self.proxy() try: proxy.ticket.update(code, comment, attributes) except xmlrpclib.Fault: raise QError("Cannot find ticket '" + code + "'.")
def review_start(self, ticket, file): if not self._vsts_query: raise QError( "When using ReviewByVSTS, also TicketingByVSTS must be in user." ) # TODO: VSTS: Enable once this is working # # repo_id = self._find_vsts_git_repository() # text = self.edit_review_comments(ticket) # params = { # 'sourceRefName': 'refs/heads/' + ticket['Branch'], # 'targetRefName': 'refs/heads/master', # 'title': self.get_review_title(ticket), # 'description': text, # 'reviewers': [] # } # print params # data = self._vsts_query('git/repositories/' + repo_id + '/pullrequests', post=params) # print data data = self._vsts_query('wit/workitems/' + ticket.code) if 'Microsoft.VSTS.Scheduling.RemainingWork' in data['fields']: patch = [{ 'op': 'replace', 'path': '/fields/Microsoft.VSTS.Scheduling.RemainingWork', 'value': 0.0 }] self._vsts_query('wit/workitems/' + ticket.code, patch=patch) from q import Q Q.wr('Review', 'Finish review manually:') Q.wr( 'Review', 'https://phones.visualstudio.com/DefaultCollection/PhonesSW/SWCustomizationVT/_git/Z_Neo_Service/pullrequests' ) return '1'
def wr(self, *msg): """ Print out run time message. """ from q import Q Q.wr('*' + self.__class__.__name__, *msg)