Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Xavier Thompson
neoppod
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
Hide 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 @@
...
@@ -17,10 +17,11 @@
# You should have received a copy of the GNU General Public License
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# 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
bisect
import
insort
from
logging
import
getLevelName
from
logging
import
getLevelName
comp_dict
=
dict
(
bz2
=
bz2
.
BZ2File
,
gz
=
gzip
.
GzipFile
)
class
Log
(
object
):
class
Log
(
object
):
...
@@ -31,12 +32,23 @@ class Log(object):
...
@@ -31,12 +32,23 @@ class Log(object):
filter_from
=
None
):
filter_from
=
None
):
self
.
_date_format
=
'%F %T'
if
date_format
is
None
else
date_format
self
.
_date_format
=
'%F %T'
if
date_format
is
None
else
date_format
self
.
_decode_all
=
decode_all
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
os
.
stat
(
db_path
)
# do not create empty DB if file is missing
self
.
_db
=
sqlite3
.
connect
(
db_path
)
self
.
_filter_from
=
filter_from
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
)
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
):
def
__iter__
(
self
):
db
=
self
.
_db
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