Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Kirill Smelkov
neo
Commits
9bd31803
Commit
9bd31803
authored
Dec 05, 2014
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
neolog: add support for gzip/bz2 compressed logs
They're decompressed automatically to temporary files.
parent
1b1a9bcd
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
6 deletions
+18
-6
neo/scripts/neolog.py
neo/scripts/neolog.py
+18
-6
No files found.
neo/scripts/neolog.py
View file @
9bd31803
...
...
@@ -17,10 +17,11 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import
bz2
,
optparse
,
os
,
signal
,
sqlite3
,
time
import
bz2
,
gzip
,
optparse
,
os
,
signal
,
sqlite3
,
time
from
bisect
import
insort
from
logging
import
getLevelName
comp_dict
=
dict
(
bz2
=
bz2
.
BZ2File
,
gz
=
gzip
.
GzipFile
)
class
Log
(
object
):
...
...
@@ -31,12 +32,23 @@ class Log(object):
filter_from
=
None
):
self
.
_date_format
=
'%F %T'
if
date_format
is
None
else
date_format
self
.
_decode_all
=
decode_all
self
.
_default_name
=
os
.
path
.
splitext
(
os
.
path
.
basename
(
db_path
))[
0
]
# WKRD: Python does not support URI so we can't open in read-only mode
# See http://bugs.python.org/issue13773
self
.
_filter_from
=
filter_from
name
=
os
.
path
.
basename
(
db_path
)
try
:
name
,
ext
=
name
.
rsplit
(
os
.
extsep
,
1
)
ZipFile
=
comp_dict
[
ext
]
except
(
KeyError
,
ValueError
):
# WKRD: Python does not support URI so we can't open in read-only
# mode. See http://bugs.python.org/issue13773
os
.
stat
(
db_path
)
# do not create empty DB if file is missing
self
.
_db
=
sqlite3
.
connect
(
db_path
)
self
.
_filter_from
=
filter_from
else
:
import
shutil
,
tempfile
with
tempfile
.
NamedTemporaryFile
()
as
f
:
shutil
.
copyfileobj
(
ZipFile
(
db_path
),
f
)
self
.
_db
=
sqlite3
.
connect
(
f
.
name
)
name
=
name
.
rsplit
(
os
.
extsep
,
1
)[
0
]
self
.
_default_name
=
name
def
__iter__
(
self
):
db
=
self
.
_db
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment