about summary refs log tree commit diff stats
path: root/subx_debugging.md
diff options
context:
space:
mode:
Diffstat (limited to 'subx_debugging.md')
0 files changed, 0 insertions, 0 deletions
hut@lavabit.com> 2009-12-13 00:45:03 +0100 added docstrings everywhere' href='/akspecs/ranger/commit/ranger/applications.py?h=v1.2.1&id=728fb8385d3a4dca994ae652ca44b9ffe72a029d'>728fb838 ^
cc952d63 ^


728fb838 ^
cc952d63 ^

871c502d ^



728fb838 ^
871c502d ^

3de15ddd ^
871c502d ^























0c0b9489 ^
871c502d ^


0c0b9489 ^
871c502d ^
4c05e43d ^
871c502d ^

d88232a3 ^
871c502d ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61



                           
                                                                                       





                                                          
                                                               


                                                  
                                                                   

                                                                         



                            
                                                     

                                    
                                                              























                                                                                  
 


                                                 
 
             
                                         

                                           
                                            
                        
ALLOWED_FLAGS = 'sdpSDP'

class Applications(object):
	def get(self, app):
		"""Looks for an application, returns app_default if it doesn't exist"""
		try:
			return getattr(self, 'app_' + app)
		except AttributeError:
			return self.app_default

	def has(self, app):
		"""Returns whether an application is defined"""
		return hasattr(self, 'app_' + app)

	def all(self):
		"""Returns a list with all application functions"""
		return [x for x in self.__dict__ if x.startswith('app_')]

import os
null = open(os.devnull, 'a')

def run(*args, **kw):
	"""Run files with the specified parameters"""
	from subprocess import Popen
	from subprocess import PIPE
	from ranger.ext.waitpid_no_intr import waitpid_no_intr

	flags, fm = kw['flags'], kw['fm']
	for flag in flags:
		if ord(flag) <= 90:
			bad = flag + flag.lower()
			flags = ''.join(c for c in flags if c not in bad)

	args = map(str, args)
	popen_kw = {}

	if kw['stdin'] is not None:
		popen_kw['stdin'] = kw['stdin']

	if 's' in flags or 'd' in flags:
		popen_kw['stdout'] = popen_kw['stderr'] = popen_kw['stdin'] = null
	
	if 'p' in flags:
		popen_kw['stdout'] = PIPE
		process1 = Popen(args, **popen_kw)
		kw['stdin'] = process1.stdout
		kw['files'] = ()
		kw['flags'] = ''.join(f for f in kw['flags'] if f in 'd')
		process2 = kw['apps'].app_pager(**kw)
		return process2

	if 'd' in flags:
		process = Popen(args, **popen_kw)
		return process

	else:
		if fm.ui: fm.ui.suspend()
		p = Popen(args, **popen_kw)
		waitpid_no_intr(p.pid)
		if fm.ui: fm.ui.initialize()
		return p