diff options
author | hut <hut@lavabit.com> | 2010-06-22 00:50:58 +0200 |
---|---|---|
committer | hut <hut@lavabit.com> | 2010-06-22 00:50:58 +0200 |
commit | b290073bce2ed945a363132b45db34b934c31276 (patch) | |
tree | b4d473899debf10e9cc45ee38de9f490ba1c228e /ranger | |
parent | 6613bf4181f3d6d4b612e98e865192b73ebbe90c (diff) | |
parent | 3817c8b47e85d3644383182c2b3909a2dbdd0b3b (diff) | |
download | ranger-b290073bce2ed945a363132b45db34b934c31276.tar.gz |
Merge branch 'master' into preview
Diffstat (limited to 'ranger')
-rw-r--r-- | ranger/__init__.py | 2 | ||||
-rw-r--r-- | ranger/__main__.py | 30 | ||||
-rw-r--r-- | ranger/core/actions.py | 8 | ||||
-rw-r--r-- | ranger/core/runner.py | 19 | ||||
-rw-r--r-- | ranger/help/starting.py | 1 |
5 files changed, 44 insertions, 16 deletions
diff --git a/ranger/__init__.py b/ranger/__init__.py index 2f8b2572..4fcc2ecf 100644 --- a/ranger/__init__.py +++ b/ranger/__init__.py @@ -20,7 +20,7 @@ import sys from ranger.ext.openstruct import OpenStruct __license__ = 'GPL3' -__version__ = '1.1.0' +__version__ = '1.1.1' __credits__ = 'Roman Zimbelmann' __author__ = 'Roman Zimbelmann' __maintainer__ = 'Roman Zimbelmann' 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__': diff --git a/ranger/core/actions.py b/ranger/core/actions.py index 2db749cd..743d82c5 100644 --- a/ranger/core/actions.py +++ b/ranger/core/actions.py @@ -139,9 +139,11 @@ class Actions(FileManagerAware, EnvironmentAware, SettingsAware): cwd.move(to=newpos) def move_parent(self, n): - self.enter_dir('..') - self.move(down=n) - self.move(right=0) + parent = self.env.at_level(-1) + try: + self.env.enter_dir(parent.files[parent.pointer+n]) + except IndexError: + pass def history_go(self, relative): """Move back and forth in the history""" diff --git a/ranger/core/runner.py b/ranger/core/runner.py index 26424881..f35f99b7 100644 --- a/ranger/core/runner.py +++ b/ranger/core/runner.py @@ -37,10 +37,21 @@ from subprocess import Popen, PIPE from ranger.ext.waitpid_no_intr import waitpid_no_intr -ALLOWED_FLAGS = 'sdpSDP' +ALLOWED_FLAGS = 'sdpwSDPW' devnull = open(os.devnull, 'a') +def press_enter(): + """Wait for an ENTER-press""" + sys.stdout.write("Press ENTER to continue") + try: + waitfnc = raw_input + except NameError: + # "raw_input" not available in python3 + waitfnc = input + waitfnc() + + class Context(object): """ A context object contains data on how to run a process. @@ -144,6 +155,7 @@ class Runner(object): toggle_ui = True pipe_output = False + wait_for_enter = False popen_kws['args'] = action if 'shell' not in popen_kws: @@ -168,6 +180,9 @@ class Runner(object): if 'd' in context.flags: toggle_ui = False context.wait = False + if 'w' in context.flags: + if not pipe_output and context.wait: # <-- sanity check + wait_for_enter = True # Finally, run it @@ -182,6 +197,8 @@ class Runner(object): else: if context.wait: waitpid_no_intr(process.pid) + if wait_for_enter: + press_enter() finally: if toggle_ui: self._activate_ui(True) diff --git a/ranger/help/starting.py b/ranger/help/starting.py index 069d6a04..99cfc45e 100644 --- a/ranger/help/starting.py +++ b/ranger/help/starting.py @@ -95,6 +95,7 @@ Flags give you a way to modify the behaviour of the spawned process. s Silent mode. Output will be discarded. d Detach the process. (Run in background) p Redirect output to the pager + w Wait for an enter-press when the process is done For example, "open with: p" will pipe the output of that process into the pager. |