webssh

Web based ssh client https://github.com/huashengdun/webssh webssh.huashengdun.org/
git clone http://git.hanabi.in/repos/webssh.git
Log | Files | Refs | README | LICENSE

commit 72df3b9ee91f707e549803fc0bfe4ac6256fedd2
parent 934d6dfcb6c194b33a6e9188f6c9f5812a4767ae
Author: Sheng <webmaster0115@gmail.com>
Date:   Sun,  6 May 2018 18:32:31 +0800

Added print_version

Diffstat:
Mtests/test_settings.py | 8+++++++-
Mwebssh/settings.py | 10++++++++++
2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/tests/test_settings.py b/tests/test_settings.py @@ -4,13 +4,19 @@ import paramiko import tornado.options as options from webssh.settings import ( - get_host_keys_settings, get_policy_setting, base_dir + get_host_keys_settings, get_policy_setting, base_dir, print_version ) from webssh.policy import load_host_keys +from webssh._version import __version__ class TestSettings(unittest.TestCase): + def test_print_version(self): + self.assertNotEqual(print_version(False), 2, msg=__version__) + with self.assertRaises(SystemExit): + self.assertEqual(print_version(True), 2, msg=__version__) + def test_get_host_keys_settings(self): options.hostFile = '' options.sysHostFile = '' diff --git a/webssh/settings.py b/webssh/settings.py @@ -1,11 +1,19 @@ import logging import os.path +import sys import uuid from tornado.options import define from webssh.policy import ( load_host_keys, get_policy_class, check_policy_setting ) +from webssh._version import __version__ + + +def print_version(flag): + if flag: + print(__version__) + sys.exit(0) define('address', default='127.0.0.1', help='listen address') @@ -15,6 +23,8 @@ define('policy', default='warning', help='missing host key policy, reject|autoadd|warning') define('hostFile', default='', help='User defined host keys file') define('sysHostFile', default='', help='System wide host keys file') +define('version', type=bool, help='show version information', + callback=print_version) base_dir = os.path.dirname(__file__)