equal
deleted
inserted
replaced
15 # |
15 # |
16 # You should have received a copy of the GNU Lesser General Public License along |
16 # You should have received a copy of the GNU Lesser General Public License along |
17 # with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
17 # with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
18 """utilities for instances migration""" |
18 """utilities for instances migration""" |
19 from __future__ import print_function |
19 from __future__ import print_function |
20 |
|
21 |
|
22 |
20 |
23 import sys |
21 import sys |
24 import os |
22 import os |
25 import logging |
23 import logging |
26 import tempfile |
24 import tempfile |
266 pass |
264 pass |
267 from code import interact |
265 from code import interact |
268 banner = """entering the migration python shell |
266 banner = """entering the migration python shell |
269 just type migration commands or arbitrary python code and type ENTER to execute it |
267 just type migration commands or arbitrary python code and type ENTER to execute it |
270 type "exit" or Ctrl-D to quit the shell and resume operation""" |
268 type "exit" or Ctrl-D to quit the shell and resume operation""" |
271 interact(banner, local=local_ctx) |
269 |
|
270 # use ipython if available |
272 try: |
271 try: |
273 readline.write_history_file(histfile) |
272 from IPython import start_ipython |
274 except IOError: |
273 print(banner) |
275 pass |
274 start_ipython(argv=[], user_ns=local_ctx) |
|
275 except ImportError: |
|
276 interact(banner, local=local_ctx) |
|
277 |
|
278 try: |
|
279 readline.write_history_file(histfile) |
|
280 except IOError: |
|
281 pass |
|
282 |
276 # delete instance's confirm attribute to avoid questions |
283 # delete instance's confirm attribute to avoid questions |
277 del self.confirm |
284 del self.confirm |
278 self.need_wrap = True |
285 self.need_wrap = True |
279 |
286 |
280 @cached |
287 @cached |