def checkexit(self, status, output=''): if status: if output: self.ui.warn(_('%s error:\n') % self.command) self.ui.warn(output) msg = util.explainexit(status)[0] raise error.Abort('%s %s' % (self.command, msg))
def notify(self, bugs, committer): '''tell bugzilla to send mail.''' self.ui.status(_('telling bugzilla to send mail:\n')) (user, userid) = self.get_bugzilla_user(committer) for id in bugs.keys(): self.ui.status(_(' bug %s\n') % id) cmdfmt = self.ui.config('bugzilla', 'notify', self.default_notify) bzdir = self.ui.config('bugzilla', 'bzdir', '/var/www/html/bugzilla') try: # Backwards-compatible with old notify string, which # took one string. This will throw with a new format # string. cmd = cmdfmt % id except TypeError: cmd = cmdfmt % {'bzdir': bzdir, 'id': id, 'user': user} self.ui.note(_('running notify command %s\n') % cmd) fp = util.popen('(%s) 2>&1' % cmd) out = fp.read() ret = fp.close() if ret: self.ui.warn(out) raise util.Abort(_('bugzilla notify command %s') % util.explainexit(ret)[0]) self.ui.status(_('done\n'))
def system(self, cmd, environ=None, cwd=None, onerr=None, errprefix=None): # fallback to the original system method if the output needs to be # captured (to self._buffers), or the output stream is not stdout # (e.g. stderr, cStringIO), because the chg client is not aware of # these situations and will behave differently (write to stdout). if (any(s[1] for s in self._bufferstates) or not util.safehasattr(self.fout, 'fileno') or self.fout.fileno() != sys.stdout.fileno()): return super(chgui, self).system(cmd, environ, cwd, onerr, errprefix) # copied from mercurial/util.py:system() self.flush() def py2shell(val): if val is None or val is False: return '0' if val is True: return '1' return str(val) env = os.environ.copy() if environ: env.update((k, py2shell(v)) for k, v in environ.iteritems()) env['HG'] = util.hgexecutable() rc = self._csystem(cmd, env, cwd) if rc and onerr: errmsg = '%s %s' % (os.path.basename(cmd.split(None, 1)[0]), util.explainexit(rc)[0]) if errprefix: errmsg = '%s: %s' % (errprefix, errmsg) raise onerr(errmsg) return rc
def notify(self, bugs, committer): '''tell bugzilla to send mail.''' self.ui.status(_('telling bugzilla to send mail:\n')) (user, userid) = self.get_bugzilla_user(committer) for id in bugs.keys(): self.ui.status(_(' bug %s\n') % id) cmdfmt = self.ui.config('bugzilla', 'notify', self.default_notify) bzdir = self.ui.config('bugzilla', 'bzdir', '/var/www/html/bugzilla') try: # Backwards-compatible with old notify string, which # took one string. This will throw with a new format # string. cmd = cmdfmt % id except TypeError: cmd = cmdfmt % {'bzdir': bzdir, 'id': id, 'user': user} self.ui.note(_('running notify command %s\n') % cmd) fp = util.popen('(%s) 2>&1' % cmd) out = fp.read() ret = fp.close() if ret: self.ui.warn(out) raise util.Abort( _('bugzilla notify command %s') % util.explainexit(ret)[0]) self.ui.status(_('done\n'))
def system(self, cmd, environ=None, cwd=None, onerr=None, errprefix=None): # copied from mercurial/util.py:system() self.flush() def py2shell(val): if val is None or val is False: return '0' if val is True: return '1' return str(val) env = os.environ.copy() if environ: env.update((k, py2shell(v)) for k, v in environ.iteritems()) env['HG'] = util.hgexecutable() rc = self._csystem(cmd, env, cwd) if rc and onerr: errmsg = '%s %s' % (os.path.basename(cmd.split( None, 1)[0]), util.explainexit(rc)[0]) if errprefix: errmsg = '%s: %s' % (errprefix, errmsg) raise onerr(errmsg) return rc
def checkexit(self, status, output=""): if status: if output: self.ui.warn(_("%s error:\n") % self.command) self.ui.warn(output) msg = util.explainexit(status)[0] raise util.Abort("%s %s" % (self.command, msg))