|
@@ -14,7 +14,7 @@
|
|
|
# along with Pwman3; if not, write to the Free Software
|
|
|
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
# ============================================================================
|
|
|
-# Copyright (C) 2012-2016 Oz N Tiram <oz.tiram@gmail.com>
|
|
|
+# Copyright (C) 2012-2018 Oz N Tiram <oz.tiram@gmail.com>
|
|
|
# ============================================================================
|
|
|
# pylint: disable=I0011
|
|
|
|
|
@@ -22,10 +22,6 @@
|
|
|
import cmd
|
|
|
import sys
|
|
|
|
|
|
-
|
|
|
-if sys.version_info.major > 2:
|
|
|
- raw_input = input
|
|
|
-
|
|
|
try:
|
|
|
import readline
|
|
|
_readline_available = True
|
|
@@ -93,23 +89,24 @@ def get_ui_platform(platform): # pragma: no cover
|
|
|
return PwmanCli, OSX
|
|
|
|
|
|
|
|
|
+def check_version(version, client_info):
|
|
|
+ _, latest = is_latest_version(version, client_info)
|
|
|
+ if not latest:
|
|
|
+ print("A newer version of Pwman3 was release, you should consider updating") # noqa
|
|
|
+ return latest
|
|
|
+
|
|
|
+
|
|
|
def main():
|
|
|
args = parser_options().parse_args()
|
|
|
PwmanCli, OSX = get_ui_platform(sys.platform)
|
|
|
xselpath, dbtype, config = get_conf_options(args, OSX)
|
|
|
dburi = config.get_value('Database', 'dburi')
|
|
|
|
|
|
- if config.get_value('Updater',
|
|
|
- 'supress_version_check').lower() != 'yes':
|
|
|
- client_info = config.get_value('Updater', 'client_info')
|
|
|
- if not client_info:
|
|
|
- client_info = calculate_client_info()
|
|
|
- config.set_value('Updater', 'client_info', client_info)
|
|
|
-
|
|
|
- _, latest = is_latest_version(version, client_info)
|
|
|
+ client_info = config.get_value('Updater', 'client_info')
|
|
|
|
|
|
- if not latest:
|
|
|
- print("A newer version of Pwman3 was release, you should consider updating") # noqa
|
|
|
+ if not client_info:
|
|
|
+ client_info = calculate_client_info()
|
|
|
+ config.set_value('Updater', 'client_info', client_info)
|
|
|
|
|
|
if not has_cryptography:
|
|
|
import colorama
|
|
@@ -120,6 +117,15 @@ def main():
|
|
|
"pwman config file.{}".format(colorama.Fore.RED,
|
|
|
colorama.Style.RESET_ALL))
|
|
|
|
|
|
+ if args.cmd == "version":
|
|
|
+ latest = check_version(version, client_info)
|
|
|
+ print("version: %s is latest: %s" % (version, latest))
|
|
|
+ sys.exit(0)
|
|
|
+
|
|
|
+ elif config.get_value('Updater',
|
|
|
+ 'supress_version_check').lower() != 'yes':
|
|
|
+ check_version(version, client_info)
|
|
|
+
|
|
|
print(dburi)
|
|
|
dbver = get_db_version(config, args)
|
|
|
timeout = int(config.get_value('Global', 'lock_timeout'))
|
|
@@ -136,11 +142,11 @@ def main():
|
|
|
|
|
|
if args.cmd == "p":
|
|
|
cli.onecmd("pp %s" % args.node)
|
|
|
- sys.exit(1)
|
|
|
+ sys.exit(0)
|
|
|
|
|
|
if args.cmd == "cp":
|
|
|
cli.onecmd("cp %s" % args.node)
|
|
|
- sys.exit(1)
|
|
|
+ sys.exit(0)
|
|
|
|
|
|
try:
|
|
|
cli.cmdloop()
|