Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
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
Transparenzportal
ckanext-odsh
Commits
45cb3ada
Commit
45cb3ada
authored
5 years ago
by
Benjamin Becker
Browse files
Options
Downloads
Patches
Plain Diff
clears proxy after download
parent
db8f2959
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
ckanext/odsh/logic/action.py
+3
-2
3 additions, 2 deletions
ckanext/odsh/logic/action.py
ckanext/odsh/setup_proxy.py
+6
-1
6 additions, 1 deletion
ckanext/odsh/setup_proxy.py
with
9 additions
and
3 deletions
ckanext/odsh/logic/action.py
+
3
−
2
View file @
45cb3ada
...
@@ -14,8 +14,7 @@ import urllib2
...
@@ -14,8 +14,7 @@ import urllib2
import
logging
import
logging
log
=
logging
.
getLogger
(
__name__
)
log
=
logging
.
getLogger
(
__name__
)
from
ckanext.odsh.setup_proxy
import
setup_proxy
from
ckanext.odsh.setup_proxy
import
setup_proxy
,
clear_proxy
setup_proxy
()
def
odsh_package_create
(
context
,
data_dict
):
def
odsh_package_create
(
context
,
data_dict
):
...
@@ -119,7 +118,9 @@ TMP_FILE_PATH = '/tmp/temp_file_upload'
...
@@ -119,7 +118,9 @@ TMP_FILE_PATH = '/tmp/temp_file_upload'
def
_download_linked_resource_to_tmp
(
url
):
def
_download_linked_resource_to_tmp
(
url
):
log
.
debug
(
'
Downloading linked resource from {}.
'
.
format
(
url
))
log
.
debug
(
'
Downloading linked resource from {}.
'
.
format
(
url
))
setup_proxy
()
test_file
=
urllib2
.
urlopen
(
url
).
read
()
test_file
=
urllib2
.
urlopen
(
url
).
read
()
clear_proxy
()
with
open
(
TMP_FILE_PATH
,
'
wb
'
)
as
temporary_file
:
with
open
(
TMP_FILE_PATH
,
'
wb
'
)
as
temporary_file
:
temporary_file
.
write
(
test_file
)
temporary_file
.
write
(
test_file
)
...
...
This diff is collapsed.
Click to expand it.
ckanext/odsh/setup_proxy.py
+
6
−
1
View file @
45cb3ada
...
@@ -17,3 +17,8 @@ def setup_proxy():
...
@@ -17,3 +17,8 @@ def setup_proxy():
proxy
=
urllib2
.
ProxyHandler
({
'
http
'
:
proxy_url
,
'
https
'
:
proxy_url
})
proxy
=
urllib2
.
ProxyHandler
({
'
http
'
:
proxy_url
,
'
https
'
:
proxy_url
})
opener
=
urllib2
.
build_opener
(
proxy
)
opener
=
urllib2
.
build_opener
(
proxy
)
urllib2
.
install_opener
(
opener
)
urllib2
.
install_opener
(
opener
)
def
clear_proxy
():
proxy
=
urllib2
.
ProxyHandler
({})
opener
=
urllib2
.
build_opener
(
proxy
)
urllib2
.
install_opener
(
opener
)
\ No newline at end of file
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