Skip to content
Commits on Source (2)
......@@ -69,6 +69,7 @@ from daklib.dak_exceptions import CantOpenError, AlreadyLockedError, CantGetLock
from daklib.summarystats import SummaryStats
from daklib.config import Config
from daklib.policy import UploadCopy, PolicyQueueUploadHandler
from daklib.termcolor import colorize as Color
# Globals
Options = None
......@@ -162,7 +163,7 @@ def print_new(upload, missing, indexed, session, file=sys.stdout):
section = m['section']
priority = m['priority']
if m["type"] == 'deb' and priority != 'optional':
priority = '\033[31m' + priority + '\033[0m'
priority = Color(priority, "red")
included = "" if m['included'] else "NOT UPLOADED"
if indexed:
line = "(%s): %-20s %-20s %-20s %s" % (index, package, priority, section, included)
......@@ -179,8 +180,12 @@ def print_new(upload, missing, indexed, session, file=sys.stdout):
print('%s: %s' % (t[0], t[1]))
notes = get_new_comments(upload.policy_queue, upload.changes.source)
for note in notes:
print("\nAuthor: %s\nVersion: %s\nTimestamp: %s\n\n%s"
% (note.author, note.version, note.notedate, note.comment))
print("\n")
print(Color("Author:", "yellow"), "%s" % note.author)
print(Color("Version:", "yellow"), "%s" % note.version)
print(Color("Timestamp:", "yellow"), "%s" % note.timestamp)
print("\n\n")
print(note.comment)
print("-" * 72)
return len(notes) > 0
......
#!/usr/bin/env python
# vim:set et sw=4:
"""
TermColor utils for dak
@contact: Debian FTP Master <ftpmaster@debian.org>
@copyright: 2019 Mo Zhou <lumin@debian.org>
@license: GNU General Public License version 2 or later
"""
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
###############################################################################
import sys
###############################################################################
__all__ = []
###############################################################################
_COLORS_ = ('red', 'green', 'yellow', 'blue', 'violet', 'cyan', 'white')
_COLOR_CODES_ = {k: 31 + _COLORS_.index(k) for k in _COLORS_}
def colorize(s, fg, bg=None, bold=False, ul=False):
'''
s: str -- string to be colorized
fg: str/int -- foreground color. See _COLORS_ for choices
bg: str/int -- background color. See _COLORS_ for choices
bold: bool -- bold font?
ul: bool -- underline?
'''
if fg not in _COLORS_:
raise ValueError("Unsupported foreground Color!")
if (bg is not None) or any((bold, ul)):
raise NotImplementedError
return "\x1b[{}m{}\x1b[0;m".format(_COLOR_CODES_[fg], s)