cobalt.py

changeset 32
88899b43810b
parent 31
4e3259daa425
child 33
2dcf980521a9
equal deleted inserted replaced
31:4e3259daa425 32:88899b43810b
276 if not match: 276 if not match:
277 chanlog ('malformed hg data: %s' % line) 277 chanlog ('malformed hg data: %s' % line)
278 continue 278 continue
279 #fi 279 #fi
280 280
281 commit_node = match.group (1)
282 commit_message = match.group (2)
283
281 try: 284 try:
282 commit_node = match.group (1)
283 commit_message = match.group (2)
284 285
285 rex = re.compile (r'^.*(fixes|resolves|addresses) ([0-9]+).*$') 286 rex = re.compile (r'^.*(fixes|resolves|addresses) ([0-9]+).*$')
286 match = rex.match (commit_message) 287 match = rex.match (commit_message)
287 288
288 if not match: 289 if not match:
407 suds_client.service.mc_issue_update (g_config['trackeruser'], g_config['trackerpassword'], ticket_id, ticket_data) 408 suds_client.service.mc_issue_update (g_config['trackeruser'], g_config['trackerpassword'], ticket_id, ticket_data)
408 #fi 409 #fi
409 410
410 suds_client.service.mc_issue_note_add (g_config['trackeruser'], g_config['trackerpassword'], ticket_id, { 'text': message }) 411 suds_client.service.mc_issue_note_add (g_config['trackeruser'], g_config['trackerpassword'], ticket_id, { 'text': message })
411 except Exception as e: 412 except Exception as e:
412 chanlog ('Error: %s' % `e`) 413 chanlog ('Error while processing %s: %s' % (commit_node, `e`))
413 failed = True 414 failed = True
414 #tried 415 #tried
415 416
416 if not failed: 417 commits_to_pull.append (commit_node)
417 commits_to_pull.append (commit_node)
418 #fi
419 #done 418 #done
420 419
421 if len (commits_to_pull) > 0: 420 if len (commits_to_pull) > 0:
422 pull_args = ['pull', '../zanstablecopy'] 421 pull_args = ['pull', '../zanstablecopy']
423 422
631 data = bt_getissue (ticket) 630 data = bt_getissue (ticket)
632 except Exception, e: 631 except Exception, e:
633 self.privmsg (replyto, "Failed to get info for issue %s: %s" % (ticket, `e`)) 632 self.privmsg (replyto, "Failed to get info for issue %s: %s" % (ticket, `e`))
634 633
635 if data: 634 if data:
635 if data['view_state']['name'] == 'private':
636 allowprivate = False
637
638 for channel in self.channels:
639 if channel['name'] == replyto and 'btprivate' in channel and channel['btprivate'] == True:
640 allowprivate = True
641 break
642 #fi
643 #done
644
645 if not allowprivate:
646 self.privmsg (replyto, 'Error: ticket %s is private' % ticket)
647 return
648 #fi
649 #fi
650
636 self.privmsg (replyto, "Issue %s: %s: Reporter: %s, assigned to: %s, status: %s (%s)" % \ 651 self.privmsg (replyto, "Issue %s: %s: Reporter: %s, assigned to: %s, status: %s (%s)" % \
637 (ticket, \ 652 (ticket, \
638 data.summary, \ 653 data.summary, \
639 data.reporter.name if hasattr (data.reporter, 'name') else "<unknown>", \ 654 data.reporter.name if hasattr (data.reporter, 'name') else "<unknown>", \
640 data.handler.name if hasattr (data, 'handler') else "nobody", \ 655 data.handler.name if hasattr (data, 'handler') else "nobody", \
641 data.status.name, \ 656 data.status.name, \
642 data.resolution.name)) 657 data.resolution.name))
643 658
644 if withlink: 659 if withlink:
645 self.privmsg (replyto, "Read all about it here: " + self.get_ticket_url (ticket)) 660 self.privmsg (replyto, "Read all about it here: " + self.get_ticket_url (ticket))
661 #fi
662 #fi
663 #enddef
646 664
647 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 665 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
648 # 666 #
649 # Process an IRC command 667 # Process an IRC command
650 # 668 #
781 self.write ('JOIN ' + channel['name'] + ' ' + (channel['password'] if hasattr (channel, 'password') else '')) 799 self.write ('JOIN ' + channel['name'] + ' ' + (channel['password'] if hasattr (channel, 'password') else ''))
782 elif key == 'password': 800 elif key == 'password':
783 channel['password'] = value 801 channel['password'] = value
784 elif key == 'btannounce': 802 elif key == 'btannounce':
785 channel['btannounce'] = bool_from_string (value) 803 channel['btannounce'] = bool_from_string (value)
804 elif key == 'btprivate':
805 channel['btprivate'] = bool_from_string (value)
786 elif key == 'logchannel': 806 elif key == 'logchannel':
787 channel['logchannel'] = bool_from_string (value) 807 channel['logchannel'] = bool_from_string (value)
788 else: 808 else:
789 raise logical_exception ('unknown key ' + key) 809 raise logical_exception ('unknown key ' + key)
790 810
921 def announce_ticket (self, data): 941 def announce_ticket (self, data):
922 idstring = "%d" % data.id 942 idstring = "%d" % data.id
923 while len(idstring) < 7: 943 while len(idstring) < 7:
924 idstring = "0" + idstring 944 idstring = "0" + idstring
925 945
946 isprivate = data['view_state']['name'] == 'private'
926 reporter = data['reporter']['name'] if hasattr (data['reporter'], 'name') else '<nobody>' 947 reporter = data['reporter']['name'] if hasattr (data['reporter'], 'name') else '<nobody>'
927 948
928 for channel in self.cfg['channels']: 949 for channel in self.cfg['channels']:
929 if 'btannounce' in channel and channel['btannounce'] == True: 950 if 'btannounce' in channel and channel['btannounce'] == True:
930 self.write ("PRIVMSG %s :[%s] New issue %s, reported by %s: %s: %s" % \ 951 if not isprivate or ('btprivate' in channel and channel['btprivate'] == True):
931 (channel['name'], data['project']['name'], idstring, reporter, data['summary'], self.get_ticket_url (idstring))) 952 self.write ("PRIVMSG %s :[%s] New issue %s, reported by %s: %s: %s" % \
953 (channel['name'], data['project']['name'], idstring, reporter,
954 data['summary'], self.get_ticket_url (idstring)))
955 #fi
956 #fi
957 #done
932 958
933 def handle_error(self): 959 def handle_error(self):
934 excepterm (traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback)) 960 excepterm (traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback))
935 961
936 def privmsg (self, channel, msg): 962 def privmsg (self, channel, msg):

mercurial