Переглянути джерело

Calculate client info only once

Oz N Tiram 8 роки тому
батько
коміт
c077006c42
2 змінених файлів з 9 додано та 3 видалено
  1. 7 3
      pwman/ui/cli.py
  2. 2 0
      pwman/util/config.py

+ 7 - 3
pwman/ui/cli.py

@@ -123,10 +123,14 @@ def main():
     xselpath, dbtype, config = get_conf_options(args, OSX)
     dburi = config.get_value('Database', 'dburi')
 
-    if config.get_value('Global',
+    if config.get_value('Updater',
                         'supress_version_check').lower() != 'yes':
-        _, latest = is_latest_version(version)
-        if not latest:
+        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)
             print("A newer version of Pwman3 was release, you should consider updating")  # noqa
 
     if not has_cryptography:

+ 2 - 0
pwman/util/config.py

@@ -40,6 +40,8 @@ default_config = {'Global': {'umask': '0100', 'colors': 'yes',
                   'Readline': {'history': os.path.join(config_dir,
                                                        'history')},
                   'Crypto': {'supress_warning': 'no'},
+
+                  'Updater': {'supress_version_check': 'no'}
                   }
 
 if 'win' in sys.platform: