Show More
The requested changes are too big and content was truncated. Show full diff
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file | ||
The requested commit or file is too big and content was truncated. Show full diff |
@@ -1,35 +1,47 b'' | |||||
1 | # -*- coding: utf-8 -*- |
|
1 | # -*- coding: utf-8 -*- | |
2 | """ Proxy module for accessing platform specific utility functions. |
|
2 | """ Proxy module for accessing platform specific utility functions. | |
3 |
|
3 | |||
4 | Importing this module should give you the implementations that are correct |
|
4 | Importing this module should give you the implementations that are correct | |
5 | for your operation system, from platutils_PLATFORMNAME module. |
|
5 | for your operation system, from platutils_PLATFORMNAME module. | |
6 |
|
||||
7 | $Id: ipstruct.py 1005 2006-01-12 08:39:26Z fperez $ |
|
|||
8 |
|
||||
9 |
|
||||
10 | """ |
|
6 | """ | |
11 |
|
7 | |||
12 |
|
||||
13 | #***************************************************************************** |
|
8 | #***************************************************************************** | |
14 | # Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu> |
|
9 | # Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu> | |
15 | # |
|
10 | # | |
16 | # Distributed under the terms of the BSD License. The full license is in |
|
11 | # Distributed under the terms of the BSD License. The full license is in | |
17 | # the file COPYING, distributed as part of this software. |
|
12 | # the file COPYING, distributed as part of this software. | |
18 | #***************************************************************************** |
|
13 | #***************************************************************************** | |
19 |
|
14 | |||
20 | from IPython import Release |
|
15 | from IPython import Release | |
21 | __author__ = '%s <%s>' % Release.authors['Ville'] |
|
16 | __author__ = '%s <%s>' % Release.authors['Ville'] | |
22 | __license__ = Release.license |
|
17 | __license__ = Release.license | |
23 |
|
18 | |||
24 |
import os |
|
19 | import os | |
|
20 | import sys | |||
25 |
|
21 | |||
|
22 | # Import the platform-specific implementations | |||
26 | if os.name == 'posix': |
|
23 | if os.name == 'posix': | |
27 |
|
|
24 | import platutils_posix as _platutils | |
28 | elif sys.platform == 'win32': |
|
25 | elif sys.platform == 'win32': | |
29 |
|
|
26 | import platutils_win32 as _platutils | |
30 | else: |
|
27 | else: | |
31 |
|
|
28 | import platutils_dummy as _platutils | |
32 | import warnings |
|
29 | import warnings | |
33 | warnings.warn("Platutils not available for platform '%s', some features may be missing" % |
|
30 | warnings.warn("Platutils not available for platform '%s', some features may be missing" % | |
34 | os.name) |
|
31 | os.name) | |
35 | del warnings |
|
32 | del warnings | |
|
33 | ||||
|
34 | ||||
|
35 | # Functionality that's logically common to all platforms goes here, each | |||
|
36 | # platform-specific module only provides the bits that are OS-dependent. | |||
|
37 | ||||
|
38 | def freeze_term_title(): | |||
|
39 | _platutils.ignore_termtitle = True | |||
|
40 | ||||
|
41 | ||||
|
42 | def set_term_title(title): | |||
|
43 | """Set terminal title using the necessary platform-dependent calls.""" | |||
|
44 | ||||
|
45 | if _platutils.ignore_termtitle: | |||
|
46 | return | |||
|
47 | _platutils.set_term_title(title) |
@@ -1,29 +1,24 b'' | |||||
1 | # -*- coding: utf-8 -*- |
|
1 | # -*- coding: utf-8 -*- | |
2 | """ Platform specific utility functions, dummy version |
|
2 | """ Platform specific utility functions, dummy version | |
3 |
|
3 | |||
4 | This has empty implementation of the platutils functions, used for |
|
4 | This has empty implementation of the platutils functions, used for | |
5 | unsupported operating systems. |
|
5 | unsupported operating systems. | |
6 |
|
||||
7 | $Id: ipstruct.py 1005 2006-01-12 08:39:26Z fperez $ |
|
|||
8 |
|
||||
9 |
|
||||
10 | """ |
|
6 | """ | |
11 |
|
7 | |||
12 |
|
||||
13 | #***************************************************************************** |
|
8 | #***************************************************************************** | |
14 | # Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu> |
|
9 | # Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu> | |
15 | # |
|
10 | # | |
16 | # Distributed under the terms of the BSD License. The full license is in |
|
11 | # Distributed under the terms of the BSD License. The full license is in | |
17 | # the file COPYING, distributed as part of this software. |
|
12 | # the file COPYING, distributed as part of this software. | |
18 | #***************************************************************************** |
|
13 | #***************************************************************************** | |
19 |
|
14 | |||
20 | from IPython import Release |
|
15 | from IPython import Release | |
21 | __author__ = '%s <%s>' % Release.authors['Ville'] |
|
16 | __author__ = '%s <%s>' % Release.authors['Ville'] | |
22 | __license__ = Release.license |
|
17 | __license__ = Release.license | |
23 |
|
18 | |||
|
19 | # This variable is part of the expected API of the module: | |||
|
20 | ignore_termtitle = True | |||
24 |
|
21 | |||
25 |
def |
|
22 | def set_term_title(*args,**kw): | |
|
23 | """Dummy no-op.""" | |||
26 | pass |
|
24 | pass | |
27 |
|
||||
28 | set_term_title = _dummy |
|
|||
29 |
|
@@ -1,47 +1,36 b'' | |||||
1 | # -*- coding: utf-8 -*- |
|
1 | # -*- coding: utf-8 -*- | |
2 | """ Platform specific utility functions, posix version |
|
2 | """ Platform specific utility functions, posix version | |
3 |
|
3 | |||
4 | Importing this module directly is not portable - rather, import platutils |
|
4 | Importing this module directly is not portable - rather, import platutils | |
5 | to use these functions in platform agnostic fashion. |
|
5 | to use these functions in platform agnostic fashion. | |
6 |
|
||||
7 | $Id: ipstruct.py 1005 2006-01-12 08:39:26Z fperez $ |
|
|||
8 |
|
||||
9 | """ |
|
6 | """ | |
10 |
|
7 | |||
11 |
|
||||
12 | #***************************************************************************** |
|
8 | #***************************************************************************** | |
13 | # Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu> |
|
9 | # Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu> | |
14 | # |
|
10 | # | |
15 | # Distributed under the terms of the BSD License. The full license is in |
|
11 | # Distributed under the terms of the BSD License. The full license is in | |
16 | # the file COPYING, distributed as part of this software. |
|
12 | # the file COPYING, distributed as part of this software. | |
17 | #***************************************************************************** |
|
13 | #***************************************************************************** | |
18 |
|
14 | |||
19 | from IPython import Release |
|
15 | from IPython import Release | |
20 | __author__ = '%s <%s>' % Release.authors['Ville'] |
|
16 | __author__ = '%s <%s>' % Release.authors['Ville'] | |
21 | __license__ = Release.license |
|
17 | __license__ = Release.license | |
22 |
|
18 | |||
23 | import sys |
|
19 | import sys | |
24 | import os |
|
20 | import os | |
25 |
|
21 | |||
26 | ignore_termtitle = False |
|
22 | ignore_termtitle = False | |
27 |
|
23 | |||
28 | def _dummy_op(*a, **b): |
|
24 | def _dummy_op(*a, **b): | |
29 | """ A no-op function """ |
|
25 | """ A no-op function """ | |
30 |
|
26 | |||
31 | def _set_term_title_xterm(title): |
|
27 | def _set_term_title_xterm(title): | |
32 | """ Change virtual terminal title in xterm-workalikes """ |
|
28 | """ Change virtual terminal title in xterm-workalikes """ | |
33 |
|
29 | |||
34 | if ignore_termtitle: |
|
|||
35 | return |
|
|||
36 |
|
||||
37 | sys.stdout.write('\033]%d;%s\007' % (0,title)) |
|
30 | sys.stdout.write('\033]%d;%s\007' % (0,title)) | |
38 |
|
31 | |||
39 |
|
32 | |||
40 | if os.environ.get('TERM','') == 'xterm': |
|
33 | if os.environ.get('TERM','') == 'xterm': | |
41 | set_term_title = _set_term_title_xterm |
|
34 | set_term_title = _set_term_title_xterm | |
42 | else: |
|
35 | else: | |
43 | set_term_title = _dummy_op |
|
36 | set_term_title = _dummy_op | |
44 |
|
||||
45 | def freeze_term_title(): |
|
|||
46 | global ignore_termtitle |
|
|||
47 | ignore_termtitle = True |
|
@@ -1,56 +1,47 b'' | |||||
1 | # -*- coding: utf-8 -*- |
|
1 | # -*- coding: utf-8 -*- | |
2 | """ Platform specific utility functions, win32 version |
|
2 | """ Platform specific utility functions, win32 version | |
3 |
|
3 | |||
4 | Importing this module directly is not portable - rather, import platutils |
|
4 | Importing this module directly is not portable - rather, import platutils | |
5 | to use these functions in platform agnostic fashion. |
|
5 | to use these functions in platform agnostic fashion. | |
6 |
|
||||
7 | $Id: ipstruct.py 1005 2006-01-12 08:39:26Z fperez $ |
|
|||
8 |
|
||||
9 | """ |
|
6 | """ | |
10 |
|
7 | |||
11 |
|
||||
12 | #***************************************************************************** |
|
8 | #***************************************************************************** | |
13 | # Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu> |
|
9 | # Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu> | |
14 | # |
|
10 | # | |
15 | # Distributed under the terms of the BSD License. The full license is in |
|
11 | # Distributed under the terms of the BSD License. The full license is in | |
16 | # the file COPYING, distributed as part of this software. |
|
12 | # the file COPYING, distributed as part of this software. | |
17 | #***************************************************************************** |
|
13 | #***************************************************************************** | |
18 |
|
14 | |||
19 | from IPython import Release |
|
15 | from IPython import Release | |
20 | __author__ = '%s <%s>' % Release.authors['Ville'] |
|
16 | __author__ = '%s <%s>' % Release.authors['Ville'] | |
21 | __license__ = Release.license |
|
17 | __license__ = Release.license | |
22 |
|
18 | |||
23 | import os |
|
19 | import os | |
24 |
|
20 | |||
25 |
ignore_termtitle = |
|
21 | ignore_termtitle = False | |
26 |
|
22 | |||
27 | try: |
|
23 | try: | |
28 | import ctypes |
|
24 | import ctypes | |
29 | SetConsoleTitleW=ctypes.windll.kernel32.SetConsoleTitleW |
|
25 | ||
30 | SetConsoleTitleW.argtypes=[ctypes.c_wchar_p] |
|
26 | SetConsoleTitleW = ctypes.windll.kernel32.SetConsoleTitleW | |
31 | def _set_term_title(title): |
|
27 | SetConsoleTitleW.argtypes = [ctypes.c_wchar_p] | |
32 | """ Set terminal title using the ctypes""" |
|
28 | ||
|
29 | def set_term_title(title): | |||
|
30 | """Set terminal title using ctypes to access the Win32 APIs.""" | |||
33 | SetConsoleTitleW(title) |
|
31 | SetConsoleTitleW(title) | |
34 |
|
32 | |||
35 | except ImportError: |
|
33 | except ImportError: | |
36 |
def |
|
34 | def set_term_title(title): | |
37 |
""" |
|
35 | """Set terminal title using the 'title' command.""" | |
38 | curr=os.getcwd() |
|
36 | global ignore_termtitle | |
39 | os.chdir("C:") #Cannot be on network share when issuing system commands |
|
37 | ||
40 | ret = os.system("title " + title) |
|
38 | try: | |
41 | os.chdir(curr) |
|
39 | # Cannot be on network share when issuing system commands | |
|
40 | curr = os.getcwd() | |||
|
41 | os.chdir("C:") | |||
|
42 | ret = os.system("title " + title) | |||
|
43 | finally: | |||
|
44 | os.chdir(curr) | |||
42 | if ret: |
|
45 | if ret: | |
43 | ignore_termtitle = 1 |
|
46 | # non-zero return code signals error, don't try again | |
44 |
|
47 | ignore_termtitle = True | ||
45 | def set_term_title(title): |
|
|||
46 | """ Set terminal title using the 'title' command """ |
|
|||
47 | global ignore_termtitle |
|
|||
48 |
|
||||
49 | if ignore_termtitle: |
|
|||
50 | return |
|
|||
51 | _set_term_title(title) |
|
|||
52 |
|
||||
53 | def freeze_term_title(): |
|
|||
54 | global ignore_termtitle |
|
|||
55 | ignore_termtitle = 1 |
|
|||
56 |
|
General Comments 0
You need to be logged in to leave comments.
Login now