summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlessio Sergi <al3hex@gmail.com>2016-12-26 18:49:04 +0100
committerAlessio Sergi <al3hex@gmail.com>2016-12-26 18:49:04 +0100
commitcefa8b06cefbe3ab3a62bdaa58b2d4ca94a85ddb (patch)
tree6c5b5a4d946b41be61cb0311177fba507f5162df
parent01ff8aa7d507993ca420d5c2bc4aea02cb266f2a (diff)
Console mode on Windows is no more
-rw-r--r--NEWS6
-rw-r--r--glances/outputs/glances_colorconsole.py174
-rw-r--r--glances/outputs/glances_curses.py5
3 files changed, 3 insertions, 182 deletions
diff --git a/NEWS b/NEWS
index f33def1d..b1d9719d 100644
--- a/NEWS
+++ b/NEWS
@@ -5,12 +5,10 @@ Glances Version 2
Version 2.8
===========
-Deprecated:
-
- * Deprecate Windows Curse UI: automaticaly open Web Browser for the standalone mode (issue #946)
-
Changes:
+ * The curses interface on Windows is no more. The web-based interface is now
+ the default. (issue #946)
* IRQ plugin off by default. '--disable-irq' option replaced by '--enable-irq'.
Enhancements and new features:
diff --git a/glances/outputs/glances_colorconsole.py b/glances/outputs/glances_colorconsole.py
deleted file mode 100644
index cf785112..00000000
--- a/glances/outputs/glances_colorconsole.py
+++ /dev/null
@@ -1,174 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# This file is part of Glances.
-#
-# Copyright (C) 2015 Nicolargo <nicolas@nicolargo.com>
-#
-# Glances is free software; you can redistribute it and/or modify
-# it under the terms of the GNU Lesser General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# Glances 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 Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-import sys
-import threading
-import time
-
-import msvcrt
-
-from glances.compat import queue
-from glances.logger import logger
-
-try:
- import colorconsole
- import colorconsole.terminal
-except ImportError:
- logger.critical("Colorconsole module not found. Glances cannot start in standalone mode.")
- sys.exit(1)
-
-
-class ListenGetch(threading.Thread):
-
- def __init__(self, nom=''):
- super(ListenGetch, self).__init__()
- self.Terminated = False
- self.q = queue.Queue()
-
- def run(self):
- while not self.Terminated:
- char = msvcrt.getch()
- self.q.put(char)
-
- def stop(self):
- self.Terminated = True
- while not self.q.empty():
- self.q.get()
-
- def get(self, default=None):
- try:
- return ord(self.q.get_nowait())
- except Exception:
- return default
-
-
-class Screen(object):
-
- COLOR_DEFAULT_WIN = '0F' # 07'#'0F'
- COLOR_BK_DEFAULT = colorconsole.terminal.colors["BLACK"]
- COLOR_FG_DEFAULT = colorconsole.terminal.colors["WHITE"]
-
- def __init__(self, nc):
- self.nc = nc
- self.term = colorconsole.terminal.get_terminal()
- # os.system('color %s' % self.COLOR_DEFAULT_WIN)
- self.listen = ListenGetch()
- self.listen.start()
-
- self.term.clear()
-
- def subwin(self, x, y):
- return self
-
- def keypad(self, screen_id):
- return None
-
- def nodelay(self, screen_id):
- return None
-
- def getch(self):
- return self.listen.get(27)
-
- def erase(self):
- self.reset()
- return None
-
- def addnstr(self, y, x, msg, ln, typo=0):
- try:
- fgs, bks = self.nc.colors[typo]
- except Exception:
- fgs, bks = self.COLOR_FG_DEFAULT, self.COLOR_BK_DEFAULT
- self.term.set_color(fg=fgs, bk=bks)
- self.term.print_at(x, y, msg.ljust(ln))
- self.term.set_color(fg=self.COLOR_FG_DEFAULT, bk=self.COLOR_BK_DEFAULT)
-
- def getmaxyx(self):
- x = (self.term._Terminal__get_console_info().srWindow.Right -
- self.term._Terminal__get_console_info().srWindow.Left + 1)
- y = (self.term._Terminal__get_console_info().srWindow.Bottom -
- self.term._Terminal__get_console_info().srWindow.Top + 1)
- return [y, x]
-
- def reset(self):
- self.term.clear()
- self.term.reset()
- return None
-
- def restore_buffered_mode(self):
- self.term.restore_buffered_mode()
- return None
-
-
-class WCurseLight(object):
-
- COLOR_WHITE = colorconsole.terminal.colors["WHITE"]
- COLOR_RED = colorconsole.terminal.colors["RED"]
- COLOR_GREEN = colorconsole.terminal.colors["GREEN"]
- COLOR_BLUE = colorconsole.terminal.colors["LBLUE"]
- COLOR_MAGENTA = colorconsole.terminal.colors["LPURPLE"]
- COLOR_BLACK = colorconsole.terminal.colors["BLACK"]
- A_UNDERLINE = 0
- A_BOLD = 0
- A_PROTECT = 0
- COLOR_PAIRS = 9
- colors = {}
-
- def __init__(self):
- self.term = Screen(self)
-
- def initscr(self):
- return self.term
-
- def start_color(self):
- return None
-
- def use_default_colors(self):
- return None
-
- def noecho(self):
- return None
-
- def cbreak(self):
- return None
-
- def curs_set(self, y):
- return None
-
- def has_colors(self):
- return True
-
- def echo(self):
- return None
-
- def nocbreak(self):
- return None
-
- def endwin(self):
- self.term.reset()
- self.term.restore_buffered_mode()
- self.term.listen.stop()
-
- def napms(self, t):
- time.sleep(t / 1000 if t > 1000 else 1)
-
- def init_pair(self, color_id, fg, bk):
- self.colors[color_id] = [max(fg, 0), max(bk, 0)]
-
- def color_pair(self, color_id):
- return color_id
diff --git a/glances/outputs/glances_curses.py b/glances/outputs/glances_curses.py
index 2030b531..ebe126cd 100644
--- a/glances/outputs/glances_curses.py
+++ b/glances/outputs/glances_curses.py
@@ -29,7 +29,7 @@ from glances.logs import glances_logs
from glances.processes import glances_processes
from glances.timer import Timer
-# Import curses lib for "normal" operating system and consolelog for Windows
+# Import curses library for "normal" operating system
if not WINDOWS:
try:
import curses
@@ -38,9 +38,6 @@ if not WINDOWS:
except ImportError:
logger.critical("Curses module not found. Glances cannot start in standalone mode.")
sys.exit(1)
-else:
- from glances.outputs.glances_colorconsole import WCurseLight
- curses = WCurseLight()
class _GlancesCurses(object):