Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
ckanext-odsh
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
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Open-Data
ckanext-odsh
Commits
8546f4a5
Commit
8546f4a5
authored
5 years ago
by
anonymous
Browse files
Options
Downloads
Patches
Plain Diff
changed fallback-filepath
parent
59248287
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
ckanext/odsh/profiles.py
+13
-7
13 additions, 7 deletions
ckanext/odsh/profiles.py
with
13 additions
and
7 deletions
ckanext/odsh/profiles.py
+
13
−
7
View file @
8546f4a5
...
@@ -111,22 +111,28 @@ def resource_formats():
...
@@ -111,22 +111,28 @@ def resource_formats():
g
.
parse
(
urlresponse
)
g
.
parse
(
urlresponse
)
# At the moment, there are 143 different file types listed,
# At the moment, there are 143 different file types listed,
# if less than 120 are found, something went wrong.
# if less than 120 are found, something went wrong.
assert
len
(
set
([
s
for
s
in
g
.
subjects
()]))
>
120
if
len
(
set
([
s
for
s
in
g
.
subjects
()]))
>
120
:
raise
ValueError
(
"
Not enough subjects
"
)
# Save the content as backup
# Save the content as backup
if
sys
.
version_info
[
0
]
==
2
:
if
sys
.
version_info
[
0
]
==
2
:
urlresponse
=
urllib2
.
urlopen
(
urllib2
.
Request
(
format_european_url
))
urlresponse
=
urllib2
.
urlopen
(
urllib2
.
Request
(
format_european_url
))
elif
sys
.
version_info
[
0
]
==
3
:
# >=Python3.1
elif
sys
.
version_info
[
0
]
==
3
:
# >=Python3.1
urlresponse
=
urllib
.
request
.
urlopen
(
urllib
.
request
.
Request
(
format_european_url
))
urlresponse
=
urllib
.
request
.
urlopen
(
urllib
.
request
.
Request
(
format_european_url
))
err_msg
=
"
Could not write to /usr/lib/ckan/default/src/ckanext-odsh/ckanext/odsh/fileformats.rdf
"
fallback_filepath
=
config
.
get
(
'
ckan.odsh.resource_formats_fallback_filepath
'
)
f
=
open
(
'
/usr/lib/ckan/default/src/ckanext-odsh/ckanext/odsh/fileformats.rdf
'
,
'
w
'
)
if
not
fallback_filepath
:
log
.
warning
(
"
Could not find config setting:
'
ckan.odsh.resource_formats_fallback_filepath
'
, using fallback instead.
"
)
fallback_filepath
=
"
/tmp/fileformats.rdf
"
err_msg
=
"
Could not write to
"
+
fallback_filepath
f
=
open
(
fallback_filepath
,
'
w
'
)
f
.
write
(
urlresponse
.
read
())
f
.
write
(
urlresponse
.
read
())
f
.
close
()
f
.
close
()
except
:
except
:
log
.
exception
(
"
failed to process resource_formats
"
)
# Something went wrong with trying to get the file formats online, try to use backup instead
# Something went wrong with trying to get the file formats online, try to use backup instead
try
:
try
:
g
.
parse
(
'
/usr/lib/ckan/default/src/ckanext-odsh/ckanext/odsh/fileformats.rdf
'
)
g
.
parse
(
fallback_filepath
)
assert
len
(
set
([
s
for
s
in
g
.
subjects
()]))
>
120
assert
len
(
set
([
s
for
s
in
g
.
subjects
()]))
>
120
log
.
warning
(
"
Could not get file formats from
"
+
format_european_url
+
"
, using fallback instead.
"
)
log
.
info
(
"
Could not get file formats from
"
+
format_european_url
+
"
, using fallback instead.
"
)
except
:
except
:
raise
Exception
(
err_msg
)
raise
Exception
(
err_msg
)
file_types
=
[
subj
.
decode
()
for
subj
in
g
.
subjects
()]
file_types
=
[
subj
.
decode
()
for
subj
in
g
.
subjects
()]
...
...
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