- fine tuning, added .hg command

Sat, 04 Oct 2014 17:58:34 +0300

author
Teemu Piippo <crimsondusk64@gmail.com>
date
Sat, 04 Oct 2014 17:58:34 +0300
changeset 40
f6512aacb114
parent 39
afd590258a93
child 41
aa214b9504de

- fine tuning, added .hg command

cobalt.py file | annotate | diff | comparison | revisions
--- a/cobalt.py	Sat Oct 04 17:52:41 2014 +0300
+++ b/cobalt.py	Sat Oct 04 17:58:34 2014 +0300
@@ -342,7 +342,8 @@
 				'{author|nonempty}\n{date(date, \'%A %d %B %Y %T\')}\n{diffstat|nonempty}').split('\n')
 
 			if len (moredata) != 3:
-				raise logical_exception ('malformed hg data')
+				chanlog ('error while processing %s: malformed hg data' % commit_node)
+				continue
 			#fi
 
 			commit_author = moredata[0]
@@ -354,7 +355,7 @@
 				ticket_data = suds_client.service.mc_issue_get (g_config['trackeruser'],
 					g_config['trackerpassword'], ticket_id)
 			except Exception as e:
-				raise logical_exception ('%s' % `e`)
+				chanlog ('error while processing %s: %s' % (commit_node, `e`))
 				continue
 			#tried
 
@@ -983,6 +984,26 @@
 				raise e
 			except Exception as e:
 				raise logical_exception ('Urban dictionary lookup failed: %s' % `e`)
+		elif command == 'hg':
+			check_admin (sender, ident, host, command)
+
+			if len(args) < 2:
+				raise logical_exception ('usage: %s <repo> <command...>' % command)
+
+			try:
+				repo = hgapi.Repo (args[0])
+				result = repo.hg_command (*args[1:])
+				self.privmsg (replyto, result)
+			except hgapi.hgapi.HgException as e:
+				try:
+					# Blah, hgapi, why must your error messages be so hard to decipher?
+					rawmsg = e.message.replace('\n', '').replace('" +','').replace('\t','')
+					errmsg = re.compile (r'.*\btErr: (.+)Out:').match (errmsg).group (1)
+					self.privmsg (replyto, 'error: %s' % errmsg)
+				except:
+					self.privmsg (replyto, 'error (unable to decipher error message)')
+				#tried
+			#tried
 #		else:
 #			raiee logical_exception ("unknown command `.%s`" % command)
 

mercurial