fix for Bug #183 (--threads dot output)

This commit is contained in:
Miroslav Stampar 2010-04-16 13:40:02 +00:00
parent 1aeaa5db47
commit 938a3ab0b9
2 changed files with 28 additions and 2 deletions

View File

@ -32,6 +32,7 @@ import time
import urlparse import urlparse
import ntpath import ntpath
import posixpath import posixpath
import subprocess
from tempfile import NamedTemporaryFile from tempfile import NamedTemporaryFile
from tempfile import mkstemp from tempfile import mkstemp
@ -1062,3 +1063,25 @@ def isBase64EncodedString(subject):
def isHexEncodedString(subject): def isHexEncodedString(subject):
return re.match(r"\A[0-9a-fA-F]+\Z", subject) is not None return re.match(r"\A[0-9a-fA-F]+\Z", subject) is not None
def getConsoleWidth(default=80):
width = None
if 'COLUMNS' in os.environ and os.environ['COLUMNS'].isdigit():
width = int(os.environ['COLUMNS'])
else:
output=subprocess.Popen('stty size', shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).stdout.read()
items = output.split()
if len(items) == 2 and items[1].isdigit():
width = int(items[1])
if width is None:
try:
import curses
stdscr = curses.initscr()
_, width = stdscr.getmaxyx()
curses.endwin()
except:
pass
return width if width else default

View File

@ -34,6 +34,7 @@ import urlparse
from ConfigParser import ConfigParser from ConfigParser import ConfigParser
from lib.core.common import getConsoleWidth
from lib.core.common import getFileType from lib.core.common import getFileType
from lib.core.common import normalizePath from lib.core.common import normalizePath
from lib.core.common import ntToPosixSlashes from lib.core.common import ntToPosixSlashes
@ -904,10 +905,12 @@ def __setConfAttributes():
conf.threadException = False conf.threadException = False
conf.wFileType = None conf.wFileType = None
width = getConsoleWidth()
if conf.eta: if conf.eta:
conf.progressWidth = 54 conf.progressWidth = width-26
else: else:
conf.progressWidth = 34 conf.progressWidth = width-46
def __setKnowledgeBaseAttributes(): def __setKnowledgeBaseAttributes():
""" """