Updated colorama and info level of file messages.

This commit is contained in:
Bastian Kleineidam 2012-12-12 22:00:17 +01:00
parent e5a04931d3
commit 8d92a8f334
2 changed files with 18 additions and 10 deletions

View file

@ -1,5 +1,5 @@
# These functions are part of the python-colorama module # These functions are part of the python-colorama module
# They have been adjusted slightly for Dosage # They have been adjusted slightly for dosage
# #
# Copyright: (C) 2010 Jonathan Hartley <tartley@tartley.com> # Copyright: (C) 2010 Jonathan Hartley <tartley@tartley.com>
# All rights reserved. # All rights reserved.
@ -32,7 +32,7 @@ STDOUT = -11
STDERR = -12 STDERR = -12
from ctypes import (windll, byref, Structure, c_char, c_short, c_uint32, from ctypes import (windll, byref, Structure, c_char, c_short, c_uint32,
c_ushort) c_ushort, ArgumentError, WinError)
handles = { handles = {
STDOUT: windll.kernel32.GetStdHandle(STDOUT), STDOUT: windll.kernel32.GetStdHandle(STDOUT),
@ -83,8 +83,10 @@ def GetConsoleScreenBufferInfo(stream_id=STDOUT):
"""Get console screen buffer info object.""" """Get console screen buffer info object."""
handle = handles[stream_id] handle = handles[stream_id]
csbi = CONSOLE_SCREEN_BUFFER_INFO() csbi = CONSOLE_SCREEN_BUFFER_INFO()
windll.kernel32.GetConsoleScreenBufferInfo( success = windll.kernel32.GetConsoleScreenBufferInfo(
handle, byref(csbi)) handle, byref(csbi))
if not success:
raise WinError()
return csbi return csbi
@ -116,7 +118,13 @@ _default_style = None
def init(): def init():
"""Initialize foreground and background attributes.""" """Initialize foreground and background attributes."""
global _default_foreground, _default_background, _default_style global _default_foreground, _default_background, _default_style
attrs = GetConsoleScreenBufferInfo(STDOUT).wAttributes try:
attrs = GetConsoleScreenBufferInfo().wAttributes
except ArgumentError:
_default_foreground = GREY
_default_background = BLACK
_default_style = NORMAL
else:
_default_foreground = attrs & 7 _default_foreground = attrs & 7
_default_background = (attrs >> 4) & 7 _default_background = (attrs >> 4) & 7
_default_style = attrs & BRIGHT _default_style = attrs & BRIGHT
@ -146,4 +154,4 @@ def reset_console(stream=STDOUT):
def get_console_size(): def get_console_size():
"""Get the console size.""" """Get the console size."""
return GetConsoleScreenBufferInfo(STDOUT).dwSize return GetConsoleScreenBufferInfo().dwSize

View file

@ -94,7 +94,7 @@ class ComicImage(object):
fn = os.path.join(comicDir, filename) fn = os.path.join(comicDir, filename)
if os.path.isfile(fn) and os.path.getsize(fn) >= comicSize: if os.path.isfile(fn) and os.path.getsize(fn) >= comicSize:
self.touch(fn) self.touch(fn)
out.info('Skipping existing file "%s".' % fn, 1) out.info('Skipping existing file "%s".' % fn)
return fn, False return fn, False
try: try:
@ -108,7 +108,7 @@ class ComicImage(object):
raise raise
else: else:
size = strsize(os.path.getsize(fn)) size = strsize(os.path.getsize(fn))
out.info("Saved %s (%s)." % (fn, size), 1) out.info("Saved %s (%s)." % (fn, size))
getHandler().comicDownloaded(self.name, fn) getHandler().comicDownloaded(self.name, fn)
return fn, True return fn, True