about summary refs log tree commit diff stats
path: root/ranger/core/actions.py
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2010-04-20 15:45:10 +0200
committerhut <hut@lavabit.com>2010-04-20 18:58:29 +0200
commit996d96d15f58fc796b60bd4be701973f757ca164 (patch)
tree2021d0e99cd7fa222ef286dab60ca0fc60666eed /ranger/core/actions.py
parent456e2e5353de6e6defb8379b6d105eef5b5f65cc (diff)
downloadranger-996d96d15f58fc796b60bd4be701973f757ca164.tar.gz
core.loader: added CommandLoader
Diffstat (limited to 'ranger/core/actions.py')
-rw-r--r--ranger/core/actions.py44
1 files changed, 13 insertions, 31 deletions
diff --git a/ranger/core/actions.py b/ranger/core/actions.py
index 47b15fa6..083f0c80 100644
--- a/ranger/core/actions.py
+++ b/ranger/core/actions.py
@@ -30,7 +30,7 @@ from ranger.shared import FileManagerAware, EnvironmentAware, SettingsAware
 from ranger.gui.widgets import console_mode as cmode
 from ranger.fsobject import File
 from ranger.ext import shutil_generatorized as shutil_g
-from ranger.core.loader import LoadableObject
+from ranger.core.loader import CommandLoader
 
 class Actions(FileManagerAware, EnvironmentAware, SettingsAware):
 	search_method = 'ctime'
@@ -567,6 +567,10 @@ class Actions(FileManagerAware, EnvironmentAware, SettingsAware):
 		if not copied_files:
 			return
 
+		def refresh(_):
+			cwd = self.env.get_directory(original_path)
+			cwd.load_content()
+
 		original_path = self.env.cwd.path
 		try:
 			one_file = copied_files[0]
@@ -580,41 +584,19 @@ class Actions(FileManagerAware, EnvironmentAware, SettingsAware):
 				descr = "moving: " + one_file.path
 			else:
 				descr = "moving files from: " + one_file.dirname
-			def generate():
-				null = open(os.devnull, 'w')
-				process = Popen(['mv', '--backup=existing',
-					'-t', self.env.cwd.path] + \
-							[f.path for f in copied_files],
-					stdout=null, stderr=PIPE)
-				while process.poll() is None:
-					rd, _, __ = select.select(
-							[process.stderr], [], [], 0.05)
-					if rd:
-						self.notify(process.stderr.readline(), bad=True)
-					yield
-				cwd = self.env.get_directory(original_path)
-				cwd.load_content()
+			obj = CommandLoader(args=['mv', '--backup=existing',
+					'-t', self.env.cwd.path] + [f.path for f in copied_files],
+					descr=descr, end_hook=refresh)
 		else:
 			if len(copied_files) == 1:
 				descr = "copying: " + one_file.path
 			else:
 				descr = "copying files from: " + one_file.dirname
-			def generate():
-				null = open(os.devnull, 'w')
-				process = Popen(['cp', '--backup=existing', '--archive',
-					'-t', self.env.cwd.path] + \
-							[f.path for f in self.env.copy],
-					stdout=null, stderr=PIPE)
-				while process.poll() is None:
-					rd, _, __ = select.select(
-							[process.stderr], [], [], 0.05)
-					if rd:
-						self.notify(process.stderr.readline(), bad=True)
-					yield
-				cwd = self.env.get_directory(original_path)
-				cwd.load_content()
-
-		self.loader.add(LoadableObject(generate(), descr))
+			obj = CommandLoader(args=['cp', '--backup=existing', '--archive',
+					'-t', self.env.cwd.path] + [f.path for f in self.env.copy],
+					descr=descr, end_hook=refresh)
+
+		self.loader.add(obj)
 
 	def delete(self):
 		self.notify("Deleting!", duration=1)