Show More
@@ -1,18 +1,10 | |||
|
1 | 1 | """ History related magics and functionality """ |
|
2 | #----------------------------------------------------------------------------- | |
|
3 | # Copyright (C) 2010-2011 The IPython Development Team. | |
|
4 | # | |
|
5 | # Distributed under the terms of the BSD License. | |
|
6 | # | |
|
7 | # The full license is in the file COPYING.txt, distributed with this software. | |
|
8 | #----------------------------------------------------------------------------- | |
|
9 | 2 | |
|
10 | #----------------------------------------------------------------------------- | |
|
11 | # Imports | |
|
12 | #----------------------------------------------------------------------------- | |
|
3 | # Copyright (c) IPython Development Team. | |
|
4 | # Distributed under the terms of the Modified BSD License. | |
|
5 | ||
|
13 | 6 | from __future__ import print_function |
|
14 | 7 | |
|
15 | # Stdlib imports | |
|
16 | 8 | import atexit |
|
17 | 9 | import datetime |
|
18 | 10 | import os |
@@ -24,9 +16,9 except ImportError: | |||
|
24 | 16 | from pysqlite2 import dbapi2 as sqlite3 |
|
25 | 17 | except ImportError: |
|
26 | 18 | sqlite3 = None |
|
19 | import sys | |
|
27 | 20 | import threading |
|
28 | 21 | |
|
29 | # Our own packages | |
|
30 | 22 | from traitlets.config.configurable import LoggingConfigurable |
|
31 | 23 | from decorator import decorator |
|
32 | 24 | from IPython.utils.decorators import undoc |
@@ -88,15 +80,15 def catch_corrupt_db(f, self, *a, **kw): | |||
|
88 | 80 | """ |
|
89 | 81 | try: |
|
90 | 82 | return f(self, *a, **kw) |
|
91 | except (DatabaseError, OperationalError): | |
|
83 | except (DatabaseError, OperationalError) as e: | |
|
92 | 84 | if os.path.isfile(self.hist_file): |
|
93 | 85 | # Try to move the file out of the way |
|
94 | 86 | base,ext = os.path.splitext(self.hist_file) |
|
95 | 87 | newpath = base + '-corrupt' + ext |
|
96 | 88 | os.rename(self.hist_file, newpath) |
|
89 | print("ERROR! History file wasn't a valid SQLite database (%s)." % e, | |
|
90 | "It was moved to %s" % newpath, "and a new file created.", file=sys.stderr) | |
|
97 | 91 | self.init_db() |
|
98 | print("ERROR! History file wasn't a valid SQLite database.", | |
|
99 | "It was moved to %s" % newpath, "and a new file created.") | |
|
100 | 92 | return [] |
|
101 | 93 | |
|
102 | 94 | else: |
General Comments 0
You need to be logged in to leave comments.
Login now