about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2009-12-24 21:00:43 +0100
committerhut <hut@lavabit.com>2009-12-24 21:00:43 +0100
commit356592fa1fa165e38d8ec893bc191a2bbe5ce961 (patch)
tree21ddc13911501a2dd84c16259761d36ffce39d99
parentf5426c6c6788ffd4b7ee6ecfc03ad7430b6f10d8 (diff)
downloadranger-356592fa1fa165e38d8ec893bc191a2bbe5ce961.tar.gz
random fixes/upgrades
-rw-r--r--ranger/actions.py14
-rw-r--r--ranger/applications.py3
-rw-r--r--ranger/commands.py6
-rw-r--r--ranger/defaults/keys.py4
-rw-r--r--ranger/fsobject/__init__.py2
-rw-r--r--ranger/fsobject/directory.py20
6 files changed, 31 insertions, 18 deletions
diff --git a/ranger/actions.py b/ranger/actions.py
index 29d92ae5..681751e3 100644
--- a/ranger/actions.py
+++ b/ranger/actions.py
@@ -59,9 +59,13 @@ class Actions(EnvironmentAware, SettingsAware):
 		"""Delete the bookmark with the name <key>"""
 		self.bookmarks.delete(key)
 
-	def move_left(self):
+	def move_left(self, n=1):
 		"""Enter the parent directory"""
-		self.env.enter_dir('..')
+		try:
+			directory = os.path.join(*(['..'] * n))
+		except:
+			return
+		self.env.enter_dir(directory)
 	
 	def move_right(self, mode=0):
 		"""Enter the current directory or execute the current file"""
@@ -193,7 +197,7 @@ class Actions(EnvironmentAware, SettingsAware):
 			for f in self.env.copy:
 				try:
 					shutil.move(f.path, self.env.pwd.path)
-				except (shutil.Error, IOError) as x:
+				except (shutil.Error, IOError, OSError) as x:
 					self.notify(str(x), bad=True)
 			self.env.copy.clear()
 			self.env.cut = False
@@ -204,12 +208,12 @@ class Actions(EnvironmentAware, SettingsAware):
 				if isdir(f.path):
 					try:
 						shutil.copytree(f.path, join(self.env.pwd.path, f.basename))
-					except (shutil.Error, IOError) as x:
+					except (shutil.Error, IOError, OSError) as x:
 						self.notify(str(x), bad=True)
 				else:
 					try:
 						shutil.copy(f.path, self.env.pwd.path)
-					except (shutil.Error, IOError) as x:
+					except (shutil.Error, IOError, OSError) as x:
 						self.notify(str(x), bad=True)
 		msg.delete()
 
diff --git a/ranger/applications.py b/ranger/applications.py
index 3acf6da5..a046a839 100644
--- a/ranger/applications.py
+++ b/ranger/applications.py
@@ -16,7 +16,7 @@ class Applications(object):
 		"""Returns a list with all application functions"""
 		return [x for x in self.__dict__ if x.startswith('app_')]
 
-import os
+import os, sys
 null = open(os.devnull, 'a')
 
 def run(*args, **kw):
@@ -33,6 +33,7 @@ def run(*args, **kw):
 
 	args = map(str, args)
 	popen_kw = {}
+	popen_kw['stdout'] = sys.stderr
 
 	if kw['stdin'] is not None:
 		popen_kw['stdin'] = kw['stdin']
diff --git a/ranger/commands.py b/ranger/commands.py
index 009de586..0ddd5d01 100644
--- a/ranger/commands.py
+++ b/ranger/commands.py
@@ -46,7 +46,8 @@ class Command(FileManagerAware):
 # -------------------------------- definitions
 
 class cd(Command):
-	"""The cd command changes the directory. The command 'cd -' is
+	"""
+	The cd command changes the directory. The command 'cd -' is
 	equivalent to typing ``. In the quick console, the directory
 	will be entered without the need to press enter, as soon as there
 	is one unambiguous match.
@@ -117,7 +118,8 @@ class cd(Command):
 		return rel_dest != '.' and isdir(abs_dest)
 
 class find(Command):
-	"""The find command will attempt to find a partial, case insensitive
+	"""
+	The find command will attempt to find a partial, case insensitive
 	match in the filenames of the current directory. In the quick command
 	console, once there is one unambiguous match, the file will be run
 	automatically.
diff --git a/ranger/defaults/keys.py b/ranger/defaults/keys.py
index ebcca70b..9129541e 100644
--- a/ranger/defaults/keys.py
+++ b/ranger/defaults/keys.py
@@ -25,7 +25,6 @@ def initialize_commands(command_list):
 	def bind(*args):
 		command_list.bind(args[-1], *args[:-1])
 
-	bind('h', KEY_LEFT, KEY_BACKSPACE, DEL, do('move_left'))
 	bind('l', KEY_RIGHT, do('move_right'))
 	bind(KEY_ENTER, ctrl('j'), do('move_right', mode=1))
 	bind('H', do('history_go', -1))
@@ -135,6 +134,9 @@ def initialize_commands(command_list):
 	bind('j', KEY_DOWN, jk(1))
 	bind('k', KEY_UP, jk(-1))
 
+	bind('h', KEY_LEFT, KEY_BACKSPACE, DEL, lambda fm, n: \
+			fm.move_left(n))
+
 	command_list.rebuild_paths()
 
 
diff --git a/ranger/fsobject/__init__.py b/ranger/fsobject/__init__.py
index 79645c5e..736175cd 100644
--- a/ranger/fsobject/__init__.py
+++ b/ranger/fsobject/__init__.py
@@ -11,7 +11,7 @@ BAD_INFO = None
 class NotLoadedYet(Exception):
 	pass
 
+from .fsobject import FileSystemObject
 from .file import File
 from .directory import Directory, NoDirectoryGiven
-from .fsobject import FileSystemObject
 from .loader import Loader
diff --git a/ranger/fsobject/directory.py b/ranger/fsobject/directory.py
index 461915db..8fb4d0ac 100644
--- a/ranger/fsobject/directory.py
+++ b/ranger/fsobject/directory.py
@@ -1,6 +1,4 @@
-from . import BAD_INFO
-from .file import File
-from .fsobject import FileSystemObject as SuperClass
+from ranger.fsobject import BAD_INFO, File, FileSystemObject
 from ranger.shared import SettingsAware
 from ranger import log
 import ranger.fsobject
@@ -16,7 +14,7 @@ def sort_by_directory(path):
 class NoDirectoryGiven(Exception):
 	pass
 
-class Directory(SuperClass, SettingsAware):
+class Directory(FileSystemObject, SettingsAware):
 	enterable = False
 	load_generator = None
 	loading = False
@@ -48,7 +46,7 @@ class Directory(SuperClass, SettingsAware):
 		if isfile(path):
 			raise NoDirectoryGiven()
 
-		SuperClass.__init__(self, path)
+		FileSystemObject.__init__(self, path)
 
 		self.marked_items = set()
 
@@ -313,8 +311,11 @@ class Directory(SuperClass, SettingsAware):
 			self.pointed_index = i
 			self.pointed_file = self[i]
 
-		if self == self.fm.env.pwd:
-			self.fm.env.cf = self.pointed_file
+		try:
+			if self == self.fm.env.pwd:
+				self.fm.env.cf = self.pointed_file
+		except:
+			pass
 		
 	def load_content_once(self, *a, **k):
 		"""Load the contents of the directory if not done yet"""
@@ -340,7 +341,10 @@ class Directory(SuperClass, SettingsAware):
 			real_mtime = os.lstat(self.path).st_mtime
 		except OSError:
 			real_mtime = None
-		cached_mtime = self.stat.st_mtime
+		if self.stat:
+			cached_mtime = self.stat.st_mtime
+		else:
+			cached_mtime = 0
 
 		if real_mtime != cached_mtime:
 			self.load_content()