Show More
@@ -28,8 +28,9 import subprocess | |||
|
28 | 28 | import time |
|
29 | 29 | |
|
30 | 30 | from .iptest import have, test_group_names, test_sections |
|
31 | from IPython.utils.path import compress_user | |
|
31 | 32 | from IPython.utils.py3compat import bytes_to_str |
|
32 |
from IPython.utils.sysinfo import |
|
|
33 | from IPython.utils.sysinfo import get_sys_info | |
|
33 | 34 | from IPython.utils.tempdir import TemporaryDirectory |
|
34 | 35 | |
|
35 | 36 | |
@@ -205,8 +206,20 def do_run(controller): | |||
|
205 | 206 | |
|
206 | 207 | def report(): |
|
207 | 208 | """Return a string with a summary report of test-related variables.""" |
|
208 | ||
|
209 | out = [ brief_sys_info(), '\n'] | |
|
209 | inf = get_sys_info() | |
|
210 | out = [] | |
|
211 | def _add(name, value): | |
|
212 | out.append((name, value)) | |
|
213 | ||
|
214 | _add('IPython version', inf['ipython_version']) | |
|
215 | _add('IPython commit', "{} ({})".format(inf['commit_hash'], inf['commit_source'])) | |
|
216 | _add('IPython package', compress_user(inf['ipython_path'])) | |
|
217 | _add('Python version', inf['sys_version'].replace('\n','')) | |
|
218 | _add('sys.executable', compress_user(inf['sys_executable'])) | |
|
219 | _add('Platform', inf['platform']) | |
|
220 | ||
|
221 | width = max(len(n) for (n,v) in out) | |
|
222 | out = ["{:<{width}}: {}\n".format(n, v, width=width) for (n,v) in out] | |
|
210 | 223 | |
|
211 | 224 | avail = [] |
|
212 | 225 | not_avail = [] |
@@ -88,6 +88,13 def unquote_filename(name, win32=(sys.platform=='win32')): | |||
|
88 | 88 | name = name[1:-1] |
|
89 | 89 | return name |
|
90 | 90 | |
|
91 | def compress_user(path): | |
|
92 | """Reverse of :func:`os.path.expanduser` | |
|
93 | """ | |
|
94 | home = os.path.expanduser('~') | |
|
95 | if path.startswith(home): | |
|
96 | path = "~" + path[len(home):] | |
|
97 | return path | |
|
91 | 98 | |
|
92 | 99 | def get_py_filename(name, force_win32=None): |
|
93 | 100 | """Return a valid python filename in the current directory. |
@@ -93,6 +93,11 def pkg_info(pkg_path): | |||
|
93 | 93 | default_encoding=encoding.DEFAULT_ENCODING, |
|
94 | 94 | ) |
|
95 | 95 | |
|
96 | def get_sys_info(): | |
|
97 | """Return useful information about IPython and the system, as a dict.""" | |
|
98 | p = os.path | |
|
99 | path = p.dirname(p.abspath(p.join(__file__, '..'))) | |
|
100 | return pkg_info(path) | |
|
96 | 101 | |
|
97 | 102 | @py3compat.doctest_refactor_print |
|
98 | 103 | def sys_info(): |
@@ -112,39 +117,8 def sys_info(): | |||
|
112 | 117 | 'sys_executable': '/usr/bin/python', |
|
113 | 118 | 'sys_platform': 'linux2', |
|
114 | 119 | 'sys_version': '2.6.6 (r266:84292, Sep 15 2010, 15:52:39) \\n[GCC 4.4.5]'} |
|
115 | """ | |
|
116 | p = os.path | |
|
117 | path = p.dirname(p.abspath(p.join(__file__, '..'))) | |
|
118 | return pprint.pformat(pkg_info(path)) | |
|
119 | ||
|
120 | def _compress_user(path): | |
|
121 | """Reverse of :func:`os.path.expanduser` | |
|
122 | 120 | """ |
|
123 | home = os.path.expanduser('~') | |
|
124 | if path.startswith(home): | |
|
125 | path = "~" + path[len(home):] | |
|
126 | return path | |
|
127 | ||
|
128 | def brief_sys_info(): | |
|
129 | """Return summary information about IPython and the system, as a string. | |
|
130 | """ | |
|
131 | p = os.path | |
|
132 | path = p.dirname(p.abspath(p.join(__file__, '..'))) | |
|
133 | inf = pkg_info(path) | |
|
134 | out = [] | |
|
135 | def _add(name, value): | |
|
136 | out.append((name, value)) | |
|
137 | ||
|
138 | _add('IPython version', inf['ipython_version']) | |
|
139 | _add('IPython commit', "{} ({})".format(inf['commit_hash'], inf['commit_source'])) | |
|
140 | _add('IPython package', _compress_user(inf['ipython_path'])) | |
|
141 | _add('Python version', inf['sys_version'].replace('\n','')) | |
|
142 | _add('sys.executable', _compress_user(inf['sys_executable'])) | |
|
143 | _add('Platform', inf['platform']) | |
|
144 | ||
|
145 | width = max(len(n) for (n,v) in out) | |
|
146 | return '\n'.join("{:<{width}}: {}".format(n, v, width=width) for (n,v) in out) | |
|
147 | ||
|
121 | return pprint.pformat(get_sys_info()) | |
|
148 | 122 | |
|
149 | 123 | def _num_cpus_unix(): |
|
150 | 124 | """Return the number of active CPUs on a Unix system.""" |
General Comments 0
You need to be logged in to leave comments.
Login now