diff options
-rw-r--r-- | HACKING | 7 | ||||
-rwxr-xr-x | ranger.py | 5 | ||||
-rw-r--r-- | ranger/__main__.py | 30 |
3 files changed, 25 insertions, 17 deletions
diff --git a/HACKING b/HACKING index 3d35190e..9c114e89 100644 --- a/HACKING +++ b/HACKING @@ -90,7 +90,6 @@ Version Numbering X.Y.Z, where: -* X: Milestones -* Y: Stable versions -* Z: Experimental versions - +* X: Major version, milestone +* Y: Minor version, odd number => stable version +* Z: Revision diff --git a/ranger.py b/ranger.py index ccc9f0d6..f290d796 100755 --- a/ranger.py +++ b/ranger.py @@ -30,6 +30,8 @@ fi return 1 """ +import sys + # Redefine the docstring, since the previous one was hijacked to # embed a shellscript. __doc__ = """Ranger - file browser for the unix terminal""" @@ -40,7 +42,6 @@ __doc__ = """Ranger - file browser for the unix terminal""" try: from ranger.__main__ import main except ImportError: - import sys if '-d' not in sys.argv and '--debug' not in sys.argv: print("Can't import the main module.") print("To run an uninstalled copy of ranger,") @@ -48,4 +49,4 @@ except ImportError: else: raise else: - main() + sys.exit(main()) diff --git a/ranger/__main__.py b/ranger/__main__.py index a03509cf..ac6b2362 100644 --- a/ranger/__main__.py +++ b/ranger/__main__.py @@ -21,6 +21,7 @@ # (ImportError will imply that this module can't be found) # convenient exception handling in ranger.py (ImportError) +import locale import os import sys @@ -152,7 +153,18 @@ def main(): print(errormessage) print('ranger requires the python curses module. Aborting.') sys.exit(1) - import locale + + try: locale.setlocale(locale.LC_ALL, '') + except: print("Warning: Unable to set locale. Expect encoding problems.") + + if not 'SHELL' in os.environ: + os.environ['SHELL'] = 'bash' + + arg = parse_arguments() + if arg.clean: + sys.dont_write_bytecode = True + + # Need to decide whether to write bytecode or not before importing. import ranger from ranger.ext import curses_interrupt_handler from ranger.core.runner import Runner @@ -163,17 +175,9 @@ def main(): from ranger.shared import (EnvironmentAware, FileManagerAware, SettingsAware) - try: locale.setlocale(locale.LC_ALL, '') - except: print("Warning: Unable to set locale. Expect encoding problems.") - - if not 'SHELL' in os.environ: - os.environ['SHELL'] = 'bash' - - arg = parse_arguments() - ranger.arg = arg - - if not ranger.arg.debug: + if not arg.debug: curses_interrupt_handler.install_interrupt_handler() + ranger.arg = arg SettingsAware._setup() @@ -212,6 +216,8 @@ def main(): except Exception: import traceback crash_traceback = traceback.format_exc() + except SystemExit as error: + return error.args[0] finally: try: fm.ui.destroy() @@ -222,6 +228,8 @@ def main(): print("Ranger crashed. " \ "Please report this (including the traceback) at:") print("http://savannah.nongnu.org/bugs/?group=ranger&func=additem") + return 1 + return 0 if __name__ == '__main__': |