Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
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
Léo-Paul Géneau
slapos.core
Commits
7ff4154e
Commit
7ff4154e
authored
May 15, 2014
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[slapos.collect] Introduce getTableList on database
parent
1d291528
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
10 deletions
+17
-10
slapos/collect/db.py
slapos/collect/db.py
+7
-1
slapos/collect/reporter.py
slapos/collect/reporter.py
+8
-5
slapos/tests/collect.py
slapos/tests/collect.py
+2
-4
No files found.
slapos/collect/db.py
View file @
7ff4154e
...
...
@@ -144,7 +144,13 @@ class Database:
self
.
_execute
(
insertion_sql
)
return
insertion_sql
def
getDataScopeList
(
self
,
ignore_date
=
None
,
reported
=
0
):
def
getTableList
(
self
):
""" Get the list of tables from the database
"""
return
[
i
[
0
]
for
i
in
self
.
_execute
(
"SELECT name FROM sqlite_master WHERE type='table'"
)]
def
getDateScopeList
(
self
,
ignore_date
=
None
,
reported
=
0
):
""" Get from the present unique dates from the system
Use a smaller table to sabe time.
"""
...
...
slapos/collect/reporter.py
View file @
7ff4154e
...
...
@@ -53,11 +53,14 @@ class RawDumper(Dumper):
def
dump
(
self
,
folder
):
date
=
strftime
(
"%Y-%m-%d"
)
self
.
db
.
connect
()
for
date_scope
,
amount
in
self
.
db
.
getDataScopeList
(
ignore_date
=
date
):
self
.
writeFile
(
"system"
,
folder
,
date_scope
,
self
.
db
.
select
(
"system"
,
date_scope
))
self
.
writeFile
(
"user"
,
folder
,
date_scope
,
self
.
db
.
select
(
"user"
,
date_scope
))
self
.
writeFile
(
"disk"
,
folder
,
date_scope
,
self
.
db
.
select
(
"disk"
,
date_scope
))
self
.
db
.
markDayAsReported
(
date_scope
,
table_list
=
[
"system"
,
"user"
,
"disk"
])
table_list
=
self
.
db
.
getTableList
()
for
date_scope
,
amount
in
self
.
db
.
getDateScopeList
(
ignore_date
=
date
):
for
table
in
table_list
:
self
.
writeFile
(
table
,
folder
,
date_scope
,
self
.
db
.
select
(
table
,
date_scope
))
self
.
db
.
markDayAsReported
(
date_scope
,
table_list
=
table_list
)
self
.
db
.
commit
()
self
.
db
.
close
()
...
...
slapos/tests/collect.py
View file @
7ff4154e
...
...
@@ -79,11 +79,9 @@ class TestCollectDatabase(unittest.TestCase):
database
=
db
.
Database
(
self
.
instance_root
)
database
.
connect
()
try
:
table_list
=
database
.
_execute
(
"SELECT name FROM sqlite_master WHERE type='table'"
)
self
.
assertEquals
(
[
(
u'user'
,),
(
u'computer'
,),
(
u'system'
,),
(
u'disk'
,)
],
[
i
for
i
in
table_list
]
)
[
u'user'
,
u'computer'
,
u'system'
,
u'disk'
],
database
.
getTableList
()
)
finally
:
database
.
close
()
...
...
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