Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
flask-covid19
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
Thomas Wöhlke
flask-covid19
Commits
45b5246a
Commit
45b5246a
authored
3 years ago
by
thomaswoehlke
Browse files
Options
Downloads
Patches
Plain Diff
update data
parent
6f1808f7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
data/ecdc/ecdc_europa_data.csv
+61901
-0
61901 additions, 0 deletions
data/ecdc/ecdc_europa_data.csv
src/covid19/blueprints/application/application_service_download.py
+27
-22
27 additions, 22 deletions
...19/blueprints/application/application_service_download.py
with
61928 additions
and
22 deletions
data/ecdc/ecdc_europa_data.csv
0 → 100644
+
61901
−
0
View file @
45b5246a
This diff is collapsed.
Click to expand it.
src/covid19/blueprints/application/application_service_download.py
+
27
−
22
View file @
45b5246a
import
os
import
wget
import
subprocess
from
flask
import
flash
#
from flask import flash
from
database
import
app
from
covid19.blueprints.application.application_service_config
import
ApplicationServiceConfig
...
...
@@ -16,20 +16,20 @@ class ApplicationServiceDownload:
app
.
logger
.
debug
(
"
------------------------------------------------------------
"
)
app
.
logger
.
debug
(
"
ApplicationServiceDownload [ready]
"
)
def
__log_error
(
self
,
error_msg
:
str
,
error_obj
):
log_msg
=
self
.
cfg
.
slug
[
0
]
+
"
"
+
self
.
cfg
.
msg_error
()
+
"
"
+
error_msg
+
"
"
app
.
logger
.
error
(
log_msg
)
flash
(
message
=
log_msg
,
category
=
'
error
'
)
return
self
def
__log_success
(
self
,
data_file
):
slug
=
self
.
cfg
.
slug
[
0
]
log_msg1
=
"
"
+
slug
+
"
| download success:
"
+
data_file
+
"
"
log_msg2
=
"
"
+
slug
+
"
|
"
+
self
.
cfg
.
msg_ok
app
.
logger
.
info
(
log_msg1
)
app
.
logger
.
info
(
log_msg2
)
flash
(
log_msg1
)
return
self
#
def __log_error(self, error_msg: str, error_obj):
#
log_msg = self.cfg.slug[0] + " " + self.cfg.msg_error() + " " + error_msg + " "
#
app.logger.error(log_msg)
#
flash(message=log_msg, category='error')
#
return self
#
#
def __log_success(self, data_file):
#
slug = self.cfg.slug[0]
#
log_msg1 = " " + slug + " | download success: " + data_file + " "
#
log_msg2 = " " + slug + " | " + self.cfg.msg_ok
#
app.logger.info(log_msg1)
#
app.logger.info(log_msg2)
#
flash(log_msg1)
#
return self
def
__prepare_download
(
self
):
os
.
makedirs
(
self
.
cfg
.
data_path
,
exist_ok
=
True
)
...
...
@@ -39,17 +39,18 @@ class ApplicationServiceDownload:
def
__download_with_wget
(
self
):
data_file
=
wget
.
download
(
self
.
cfg
.
url_src
,
self
.
cfg
.
cvsfile_path
)
self
.
__log_success
(
data_file
)
app
.
logger
.
info
(
data_file
)
return
self
def
__download_with_subprocess_and_os_native_wget
(
self
):
orig_workdir
=
os
.
getcwd
()
os
.
chdir
(
self
.
cfg
.
data_path
)
my_cmd
=
[
'
wget
'
+
self
.
cfg
.
url_src
]
#subprocess.Popen(my_cmd, shell=True)
#
subprocess.Popen(my_cmd, shell=True)
retcode
=
subprocess
.
call
(
my_cmd
,
shell
=
True
)
app
.
logger
.
info
(
retcode
)
os
.
chdir
(
orig_workdir
)
self
.
__log_success
(
my_cmd
[
0
])
app
.
logger
.
info
(
my_cmd
[
0
])
return
self
def
download_file
(
self
):
...
...
@@ -64,13 +65,17 @@ class ApplicationServiceDownload:
else
:
self
.
__download_with_wget
()
except
RuntimeError
as
runtimeError
:
self
.
__log_error
(
"
RuntimeError:
"
,
runtimeError
)
app
.
logger
.
error
(
"
RuntimeError:
"
)
app
.
logger
.
error
(
runtimeError
)
except
OSError
as
osError
:
self
.
__log_error
(
"
OSError:
"
,
osError
)
app
.
logger
.
error
(
"
OSError:
"
)
app
.
logger
.
error
(
osError
)
except
AttributeError
as
attributeError
:
self
.
__log_error
(
"
AttributeError:
"
,
attributeError
)
app
.
logger
.
error
(
"
AttributeError:
"
)
app
.
logger
.
error
(
attributeError
)
except
Exception
as
exception
:
self
.
__log_error
(
"
Exception:
"
,
exception
)
app
.
logger
.
error
(
"
Exception:
"
)
app
.
logger
.
error
(
exception
)
finally
:
app
.
logger
.
info
(
"
------------------------------------------------------------
"
)
app
.
logger
.
info
(
"
download_file - [done]
"
)
...
...
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