summary refs log tree commit diff stats
path: root/ranger
diff options
context:
space:
mode:
authornfnty <git@nfnty.se>2017-02-19 18:00:01 +0100
committernfnty <git@nfnty.se>2017-02-19 18:00:01 +0100
commit85c5bff9a565d11f93ee7801ac13a7d8c832158e (patch)
treeff66405b246220f4cadaef8dbf38b4df740ffded /ranger
parentd861ba27b25a32aacb845eb33b6c9ce95cb33356 (diff)
downloadranger-85c5bff9a565d11f93ee7801ac13a7d8c832158e.tar.gz
core.main: `--version`: Report Python version and locale
Makes issue reporting easier.

Fixes #812
Diffstat (limited to 'ranger')
-rw-r--r--ranger/core/main.py21
1 files changed, 11 insertions, 10 deletions
diff --git a/ranger/core/main.py b/ranger/core/main.py
index a1a13dbc..560b4c0f 100644
--- a/ranger/core/main.py
+++ b/ranger/core/main.py
@@ -5,23 +5,29 @@
 
 from __future__ import (absolute_import, division, print_function)
 
+from logging import getLogger
+import locale
 import os.path
 import sys
 import tempfile
-from logging import getLogger
 
 from ranger import VERSION
 
 
 LOG = getLogger(__name__)
 
+VERSION_MSG = [
+    'ranger version: {0}'.format(VERSION),
+    'Python version: {0}'.format(' '.join(line.strip() for line in sys.version.splitlines())),
+    'Locale: {0}'.format('.'.join(str(s) for s in locale.getlocale())),
+]
+
 
 def main(
         # pylint: disable=too-many-locals,too-many-return-statements
         # pylint: disable=too-many-branches,too-many-statements
 ):
     """initialize objects and run the filemanager"""
-    import locale
     import ranger.api
     from ranger.container.settings import Settings
     from ranger.core.shared import FileManagerAware, SettingsAware
@@ -33,12 +39,7 @@ def main(
     ranger.arg = OpenStruct(args.__dict__)  # COMPAT
     setup_logging(debug=args.debug, logfile=args.logfile)
 
-    info_msg = [
-        'ranger version: {0}'.format(VERSION),
-        'Python version: {0}'.format(' '.join(line.strip() for line in sys.version.splitlines())),
-        'Locale: {0}'.format('.'.join(str(s) for s in locale.getlocale())),
-    ]
-    for line in info_msg:
+    for line in VERSION_MSG:
         LOG.info(line)
     LOG.info('Process ID: %s', os.getpid())
 
@@ -170,7 +171,7 @@ def main(
     except Exception:  # pylint: disable=broad-except
         import traceback
         ex_traceback = traceback.format_exc()
-        exit_msg += '\n'.join(info_msg) + '\n'
+        exit_msg += '\n'.join(VERSION_MSG) + '\n'
         try:
             exit_msg += "Current file: {0}\n".format(repr(fm.thisfile.path))
         except Exception:  # pylint: disable=broad-except
@@ -219,7 +220,7 @@ def parse_arguments():
     from optparse import OptionParser  # pylint: disable=deprecated-module
     from ranger import CONFDIR, CACHEDIR, DATADIR, USAGE
 
-    parser = OptionParser(usage=USAGE, version=VERSION)
+    parser = OptionParser(usage=USAGE, version=('\n'.join(VERSION_MSG)))
 
     parser.add_option('-d', '--debug', action='store_true',
                       help="activate debug mode")