summary refs log tree commit diff stats
path: root/ranger
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2010-06-09 14:10:06 +0200
committerhut <hut@lavabit.com>2010-06-09 14:10:06 +0200
commita4c9208bb69b09207c017ae88c810ef0ee83a780 (patch)
tree1666c23d6d69481587d26669c790b278123b1f0a /ranger
parent1d895690f81f2cb3a308416c29b280e91e681e36 (diff)
parente74222ee48435895a636812f908c862f3fb7acb6 (diff)
downloadranger-a4c9208bb69b09207c017ae88c810ef0ee83a780.tar.gz
Merge branch 'master' into preview
Conflicts:
	ranger/fsobject/file.py
Diffstat (limited to 'ranger')
-rw-r--r--ranger/__init__.py2
-rw-r--r--ranger/__main__.py37
-rw-r--r--ranger/core/environment.py4
-rw-r--r--ranger/ext/shell_escape.py2
-rw-r--r--ranger/fsobject/file.py2
-rw-r--r--ranger/fsobject/fsobject.py5
-rw-r--r--ranger/gui/widgets/console.py6
-rw-r--r--ranger/gui/widgets/taskview.py3
-rw-r--r--ranger/help/index.py4
-rw-r--r--ranger/help/invocation.py9
10 files changed, 42 insertions, 32 deletions
diff --git a/ranger/__init__.py b/ranger/__init__.py
index f46a1e76..2f8b2572 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.0.4'
+__version__ = '1.1.0'
 __credits__ = 'Roman Zimbelmann'
 __author__ = 'Roman Zimbelmann'
 __maintainer__ = 'Roman Zimbelmann'
diff --git a/ranger/__main__.py b/ranger/__main__.py
index 5f525582..a03509cf 100644
--- a/ranger/__main__.py
+++ b/ranger/__main__.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python
 # coding=utf-8
 #
 # Copyright (C) 2009, 2010  Roman Zimbelmann <romanz@lavabit.com>
@@ -26,7 +26,7 @@ import sys
 
 def parse_arguments():
 	"""Parse the program arguments"""
-	from optparse import OptionParser
+	from optparse import OptionParser, SUPPRESS_HELP
 	from ranger import __version__, USAGE, DEFAULT_CONFDIR
 	from ranger.ext.openstruct import OpenStruct
 	parser = OptionParser(usage=USAGE, version='ranger ' + __version__)
@@ -35,7 +35,9 @@ def parse_arguments():
 			help="activate debug mode")
 	parser.add_option('-c', '--clean', action='store_true',
 			help="don't touch/require any config files. ")
-	parser.add_option('--fail-if-run', action='store_true',
+	parser.add_option('--fail-if-run', action='store_true', # COMPAT
+			help=SUPPRESS_HELP)
+	parser.add_option('--fail-unless-cd', action='store_true',
 			help="experimental: return the exit code 1 if ranger is" \
 					"used to run a file (with `ranger filename`)")
 	parser.add_option('-r', '--confdir', type='string',
@@ -50,6 +52,9 @@ def parse_arguments():
 	options, positional = parser.parse_args()
 	arg = OpenStruct(options.__dict__, targets=positional)
 	arg.confdir = os.path.expanduser(arg.confdir)
+	if arg.fail_if_run:
+		arg.fail_unless_cd = arg.fail_if_run
+		del arg['fail_if_run']
 
 	return arg
 
@@ -185,13 +190,13 @@ def main():
 			runner = Runner(logfunc=print_function)
 			load_apps(runner, ranger.arg.clean)
 			runner(files=[File(target)], mode=arg.mode, flags=arg.flags)
-			sys.exit(1 if arg.fail_if_run else 0)
+			sys.exit(1 if arg.fail_unless_cd else 0)
 		else:
 			path = target
 	else:
 		path = '.'
 
-	crash_exception = None
+	crash_traceback = None
 	try:
 		# Initialize objects
 		EnvironmentAware._assign(Environment(path))
@@ -204,25 +209,19 @@ def main():
 		fm.initialize()
 		fm.ui.initialize()
 		fm.loop()
-	except Exception as e:
-		crash_exception = e
-		if not (arg.debug or arg.clean):
-			import traceback
-			dumpname = ranger.relpath_conf('traceback')
-			traceback.print_exc(file=open(dumpname, 'w'))
+	except Exception:
+		import traceback
+		crash_traceback = traceback.format_exc()
 	finally:
-		# Finish, clean up
 		try:
 			fm.ui.destroy()
 		except (AttributeError, NameError):
 			pass
-		if crash_exception:
-			print("Fatal: " + str(crash_exception))
-			if arg.debug or arg.clean:
-				raise crash_exception
-			else:
-				print("A traceback has been saved to " + dumpname)
-				print("Please include it in a bugreport.")
+		if crash_traceback:
+			print(crash_traceback)
+			print("Ranger crashed.  " \
+					"Please report this (including the traceback) at:")
+			print("http://savannah.nongnu.org/bugs/?group=ranger&func=additem")
 
 
 if __name__ == '__main__':
diff --git a/ranger/core/environment.py b/ranger/core/environment.py
index bb6abb36..fca2168b 100644
--- a/ranger/core/environment.py
+++ b/ranger/core/environment.py
@@ -28,8 +28,8 @@ ALLOWED_CONTEXTS = ('browser', 'pager', 'embedded_pager', 'taskview',
 		'console')
 
 class Environment(SettingsAware, SignalDispatcher):
-	"""A collection of data which is relevant for more than
-	one class.
+	"""
+	A collection of data which is relevant for more than one class.
 	"""
 
 	cwd = None  # current directory
diff --git a/ranger/ext/shell_escape.py b/ranger/ext/shell_escape.py
index f8393f2a..ec9e4b12 100644
--- a/ranger/ext/shell_escape.py
+++ b/ranger/ext/shell_escape.py
@@ -14,7 +14,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 """
-A function to escape metacharacters of arguments for shell commands.
+Functions to escape metacharacters of arguments for shell commands.
 """
 
 META_CHARS = (' ', "'", '"', '`', '&', '|', ';',
diff --git a/ranger/fsobject/file.py b/ranger/fsobject/file.py
index cd5b37ff..216b4754 100644
--- a/ranger/fsobject/file.py
+++ b/ranger/fsobject/file.py
@@ -87,6 +87,8 @@ class File(FileSystemObject):
 			return True
 		if PREVIEW_BLACKLIST.search(self.basename):
 			return False
+		if self.path == '/dev/core' or self.path == '/proc/kcore':
+			return False
 		if self.is_binary():
 			return False
 		return True
diff --git a/ranger/fsobject/fsobject.py b/ranger/fsobject/fsobject.py
index 865698b3..4ca5a6c8 100644
--- a/ranger/fsobject/fsobject.py
+++ b/ranger/fsobject/fsobject.py
@@ -107,7 +107,10 @@ class FileSystemObject(MimeTypeAware, FileManagerAware):
 
 	def set_mimetype(self):
 		"""assign attributes such as self.video according to the mimetype"""
-		self._mimetype = self.mimetypes.guess_type(self.basename, False)[0]
+		basename = self.basename
+		if self.extension == 'part':
+			basename = basename[0:-5]
+		self._mimetype = self.mimetypes.guess_type(basename, False)[0]
 		if self._mimetype is None:
 			self._mimetype = ''
 
diff --git a/ranger/gui/widgets/console.py b/ranger/gui/widgets/console.py
index 3bb41482..1ee7ebc0 100644
--- a/ranger/gui/widgets/console.py
+++ b/ranger/gui/widgets/console.py
@@ -66,7 +66,11 @@ class Console(Widget):
 		self.clear()
 		self.histories = []
 		# load histories from files
-		if not ranger.arg.clean:
+		if ranger.arg.clean:
+			for i in range(4):
+				self.histories.append(
+						History(self.settings.max_console_history_size))
+		else:
 			self.historypaths = [relpath_conf(x) for x in \
 				('history', 'history_search', 'history_qopen', 'history_open')]
 			for i, path in enumerate(self.historypaths):
diff --git a/ranger/gui/widgets/taskview.py b/ranger/gui/widgets/taskview.py
index 475b903c..e988b08c 100644
--- a/ranger/gui/widgets/taskview.py
+++ b/ranger/gui/widgets/taskview.py
@@ -86,7 +86,8 @@ class TaskView(Widget, Accumulator):
 		if i is None:
 			i = self.pointer
 
-		self.fm.loader.remove(index=i)
+		if self.fm.loader.queue:
+			self.fm.loader.remove(index=i)
 
 	def task_move(self, to, i=None):
 		if i is None:
diff --git a/ranger/help/index.py b/ranger/help/index.py
index 316e975f..1245da64 100644
--- a/ranger/help/index.py
+++ b/ranger/help/index.py
@@ -18,8 +18,8 @@
                                                                      k
     Move around:  Use the cursor keys, or "h" to go left,          h   l
                   "j" to go down, "k" to go up, "l" to go right.     j
-   Close Ranger:  Use ":q<Enter>" or "Q".
-  Specific help:  Type the help key "?" prepended with a number:
+   Close Ranger:  Type "Q"
+  Specific help:  Type "?", prepended with a number:
 
 	|0?|	This index
 	|1?|	Basic movement and browsing
diff --git a/ranger/help/invocation.py b/ranger/help/invocation.py
index 3de574cc..26cffd4a 100644
--- a/ranger/help/invocation.py
+++ b/ranger/help/invocation.py
@@ -43,9 +43,10 @@ command line.
       This is useful when your configuration is broken, when you want
       to avoid clutter, etc.
 
---fail-if-run
+--fail-unless-cd
       Return the exit code 1 if ranger is used to run a file, for example
-      with `ranger --fail-if-run filename`.  This can be useful for scripts.
+      with `ranger --fail-unless-cd filename`.  This can be useful for scripts.
+      (This option used to be called --fail-if-run)
 
 -r <dir>, --confdir=<dir>
       Define a different configuration directory.  The default is
@@ -69,7 +70,7 @@ command line.
 Examples:
       ranger episode1.avi
       ranger --debug /usr/bin
-      ranger --confdir=~/.config/ranger --fail-if-run
+      ranger --confdir=~/.config/ranger --fail-unless-cd
 
 
 ==============================================================================
@@ -95,7 +96,7 @@ docstrings.  Use this option if you don't need the documentation.
 Examples:
       PYTHONOPTIMIZE=1 ranger episode1.avi
       PYTHONOPTIMIZE=2 ranger --debug /usr/bin
-      python -OO `which ranger` --confdir=~/.config/ranger --fail-if-run
+      python -OO `which ranger` --confdir=~/.config/ranger --fail-unless-cd
 
 Note: The author expected "-OO" to reduce the memory usage, but that
 doesn't seem to happen.