Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
LOFAR
Manage
Activity
Members
Labels
Plan
Issues
Wiki
Jira issues
Open Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
RadioObservatory
LOFAR
Commits
ba1529d0
Commit
ba1529d0
authored
9 years ago
by
Jorrit Schaap
Browse files
Options
Downloads
Patches
Plain Diff
Task #8721: give optional database path on CLI. supply highcharts with unix timstamps
parent
bbe4b107
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
LTA/ltastorageoverview/lib/webservice/webservice.py
+17
-5
17 additions, 5 deletions
LTA/ltastorageoverview/lib/webservice/webservice.py
with
17 additions
and
5 deletions
LTA/ltastorageoverview/lib/webservice/webservice.py
+
17
−
5
View file @
ba1529d0
...
@@ -36,7 +36,7 @@ from ltastorageoverview.utils import monthRanges
...
@@ -36,7 +36,7 @@ from ltastorageoverview.utils import monthRanges
app
=
Flask
(
'
LTA storage overview
'
)
app
=
Flask
(
'
LTA storage overview
'
)
app
.
config
.
root_path
=
os
.
path
.
dirname
(
__file__
)
app
.
config
.
root_path
=
os
.
path
.
dirname
(
__file__
)
db
=
store
.
LTAStorageDb
(
'
../ltastorageoverview.sqlite
'
)
db
=
None
@app.route
(
'
/
'
)
@app.route
(
'
/
'
)
@app.route
(
'
/index.html
'
)
@app.route
(
'
/index.html
'
)
...
@@ -62,8 +62,9 @@ def index():
...
@@ -62,8 +62,9 @@ def index():
min_date
=
datetime
(
2012
,
1
,
1
)
min_date
=
datetime
(
2012
,
1
,
1
)
month_ranges
=
monthRanges
(
min_date
,
max_date
)
month_ranges
=
monthRanges
(
min_date
,
max_date
)
format
=
'
%Y,%m,%d,%H,%M,%S
'
# convert end-of-month timestamps to milliseconds since epoch
datestamps
=
[
'
Date.UTC(%s)
'
%
datetime
.
strftime
(
x
[
1
],
format
)
for
x
in
month_ranges
]
epoch
=
datetime
.
utcfromtimestamp
(
0
)
datestamps
=
[(
'
%d
'
%
((
x
[
1
]
-
epoch
).
total_seconds
()
*
1000
,))
for
x
in
month_ranges
]
usage_per_month_series
=
'
[
'
usage_per_month_series
=
'
[
'
deltas_per_month_series
=
'
[
'
deltas_per_month_series
=
'
[
'
...
@@ -92,7 +93,7 @@ def index():
...
@@ -92,7 +93,7 @@ def index():
storagesitedata
=
storagesitedata
,
storagesitedata
=
storagesitedata
,
usage_per_month_series
=
usage_per_month_series
,
usage_per_month_series
=
usage_per_month_series
,
deltas_per_month_series
=
deltas_per_month_series
,
deltas_per_month_series
=
deltas_per_month_series
,
data_gathered_timestamp
=
str
(
db
.
mostRecentVisitDate
()))
data_gathered_timestamp
=
db
.
mostRecentVisitDate
()
.
strftime
(
'
%Y/%m/%d %H:%M:%S
'
))
@app.route
(
'
/rest/sites/
'
)
@app.route
(
'
/rest/sites/
'
)
def
get_sites
():
def
get_sites
():
...
@@ -139,7 +140,18 @@ def get_filesInDirectory(dir_id):
...
@@ -139,7 +140,18 @@ def get_filesInDirectory(dir_id):
def
main
(
argv
):
def
main
(
argv
):
app
.
run
(
debug
=
False
,
host
=
'
0.0.0.0
'
)
dbpath
=
argv
[
0
]
if
argv
else
'
ltastorageoverview.sqlite
'
if
not
os
.
path
.
exists
(
dbpath
):
print
'
No database file found at
\'
%s
\'
'
%
(
dbpath
,)
sys
.
exit
(
-
1
)
print
'
Using database at
\'
%s
\'
'
%
(
dbpath
,)
global
db
db
=
store
.
LTAStorageDb
(
dbpath
)
app
.
run
(
debug
=
True
,
host
=
'
0.0.0.0
'
)
if
__name__
==
'
__main__
'
:
if
__name__
==
'
__main__
'
:
main
(
sys
.
argv
[
1
:])
main
(
sys
.
argv
[
1
:])
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment