##// END OF EJS Templates
IPython/utils/_process_emscripten.py: New
Hood Chatham -
Show More
@@ -0,0 +1,12 b''
1 def system(cmd):
2 raise OSError("Not available")
3
4 def getoutput(cmd):
5 raise OSError("Not available")
6
7 def check_pid(cmd):
8 raise OSError("Not available")
9
10 def arg_split(s, posix=False, strict=True):
11 """This one could be made to work but it's not clear if it would be useful..."""
12 raise OSError("Not available")
@@ -1,69 +1,71 b''
1 1 # encoding: utf-8
2 2 """
3 3 Utilities for working with external processes.
4 4 """
5 5
6 6 # Copyright (c) IPython Development Team.
7 7 # Distributed under the terms of the Modified BSD License.
8 8
9 9
10 10 import os
11 11 import shutil
12 12 import sys
13 13
14 14 if sys.platform == 'win32':
15 15 from ._process_win32 import system, getoutput, arg_split, check_pid
16 16 elif sys.platform == 'cli':
17 17 from ._process_cli import system, getoutput, arg_split, check_pid
18 elif sys.platform == "emscripten":
19 from ._process_emscripten import system, getoutput, arg_split, check_pid
18 20 else:
19 21 from ._process_posix import system, getoutput, arg_split, check_pid
20 22
21 23 from ._process_common import getoutputerror, get_output_error_code, process_handler
22 24
23 25
24 26 class FindCmdError(Exception):
25 27 pass
26 28
27 29
28 30 def find_cmd(cmd):
29 31 """Find absolute path to executable cmd in a cross platform manner.
30 32
31 33 This function tries to determine the full path to a command line program
32 34 using `which` on Unix/Linux/OS X and `win32api` on Windows. Most of the
33 35 time it will use the version that is first on the users `PATH`.
34 36
35 37 Warning, don't use this to find IPython command line programs as there
36 38 is a risk you will find the wrong one. Instead find those using the
37 39 following code and looking for the application itself::
38 40
39 41 import sys
40 42 argv = [sys.executable, '-m', 'IPython']
41 43
42 44 Parameters
43 45 ----------
44 46 cmd : str
45 47 The command line program to look for.
46 48 """
47 49 path = shutil.which(cmd)
48 50 if path is None:
49 51 raise FindCmdError('command could not be found: %s' % cmd)
50 52 return path
51 53
52 54
53 55 def abbrev_cwd():
54 56 """ Return abbreviated version of cwd, e.g. d:mydir """
55 57 cwd = os.getcwd().replace('\\','/')
56 58 drivepart = ''
57 59 tail = cwd
58 60 if sys.platform == 'win32':
59 61 if len(cwd) < 4:
60 62 return cwd
61 63 drivepart,tail = os.path.splitdrive(cwd)
62 64
63 65
64 66 parts = tail.split('/')
65 67 if len(parts) > 2:
66 68 tail = '/'.join(parts[-2:])
67 69
68 70 return (drivepart + (
69 71 cwd == '/' and '/' or tail))
General Comments 0
You need to be logged in to leave comments. Login now