diff options
author | Zac Medico <zmedico@gentoo.org> | 2010-10-23 15:55:36 -0700 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2010-10-27 07:35:25 -0700 |
commit | 10c63440bba359bf91d69c2b9ce7a4e9e92e6c22 (patch) | |
tree | 8bdd0d5877fcb98152da49649ba6f22d77c1c108 | |
parent | c38f5518b6f0f1ac02c9a1931d09fa88136a0a04 (diff) | |
download | portage-10c63440bba359bf91d69c2b9ce7a4e9e92e6c22.tar.gz portage-10c63440bba359bf91d69c2b9ce7a4e9e92e6c22.tar.bz2 portage-10c63440bba359bf91d69c2b9ce7a4e9e92e6c22.zip |
JobStatusDisplay: add a _set_width() method
-rw-r--r-- | pym/_emerge/JobStatusDisplay.py | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/pym/_emerge/JobStatusDisplay.py b/pym/_emerge/JobStatusDisplay.py index 200e196b5..d3d330d30 100644 --- a/pym/_emerge/JobStatusDisplay.py +++ b/pym/_emerge/JobStatusDisplay.py @@ -47,11 +47,6 @@ class JobStatusDisplay(object): object.__setattr__(self, "_displayed", False) object.__setattr__(self, "_last_display_time", 0) - width = portage.output.get_term_size()[1] - if width <= 0 or width > 80: - width = 80 - object.__setattr__(self, "width", width) - object.__setattr__(self, "_jobs_column_width", width - 32) self.reset() isatty = os.environ.get('TERM') != 'dumb' and \ @@ -68,6 +63,20 @@ class JobStatusDisplay(object): if not isinstance(v, basestring): self._term_codes[k] = v.decode(encoding, 'replace') + if self._isatty: + width = portage.output.get_term_size()[1] + else: + width = 80 + self._set_width(width) + + def _set_width(self, width): + if width == getattr(self, 'width', None): + return + if width <= 0 or width > 80: + width = 80 + object.__setattr__(self, "width", width) + object.__setattr__(self, "_jobs_column_width", width - 32) + @property def out(self): """Use a lazy reference to sys.stdout, in case the API consumer has |