Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
1a1272df
Commit
1a1272df
authored
Sep 08, 2014
by
Will Thames
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
get_url module: Add timeout parameter
parent
8604f6dc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
3 deletions
+11
-3
library/network/get_url
+11
-3
No files found.
library/network/get_url
View file @
1a1272df
...
@@ -90,6 +90,12 @@ options:
...
@@ -90,6 +90,12 @@ options:
required: false
required: false
default: 'yes'
default: 'yes'
choices: ['yes', 'no']
choices: ['yes', 'no']
timeout:
description:
- Timeout for URL request
required: false
default: 10
version_added: '1.8'
url_username:
url_username:
description:
description:
- The username for use in HTTP basic authentication. This parameter can be used
- The username for use in HTTP basic authentication. This parameter can be used
...
@@ -136,14 +142,14 @@ def url_filename(url):
...
@@ -136,14 +142,14 @@ def url_filename(url):
return
'index.html'
return
'index.html'
return
fn
return
fn
def
url_get
(
module
,
url
,
dest
,
use_proxy
,
last_mod_time
,
force
):
def
url_get
(
module
,
url
,
dest
,
use_proxy
,
last_mod_time
,
force
,
timeout
=
10
):
"""
"""
Download data from the url and store in a temporary file.
Download data from the url and store in a temporary file.
Return (tempfile, info about the request)
Return (tempfile, info about the request)
"""
"""
rsp
,
info
=
fetch_url
(
module
,
url
,
use_proxy
=
use_proxy
,
force
=
force
,
last_mod_time
=
last_mod_time
)
rsp
,
info
=
fetch_url
(
module
,
url
,
use_proxy
=
use_proxy
,
force
=
force
,
last_mod_time
=
last_mod_time
,
timeout
=
timeout
)
if
info
[
'status'
]
==
304
:
if
info
[
'status'
]
==
304
:
module
.
exit_json
(
url
=
url
,
dest
=
dest
,
changed
=
False
,
msg
=
info
.
get
(
'msg'
,
''
))
module
.
exit_json
(
url
=
url
,
dest
=
dest
,
changed
=
False
,
msg
=
info
.
get
(
'msg'
,
''
))
...
@@ -192,6 +198,7 @@ def main():
...
@@ -192,6 +198,7 @@ def main():
url
=
dict
(
required
=
True
),
url
=
dict
(
required
=
True
),
dest
=
dict
(
required
=
True
),
dest
=
dict
(
required
=
True
),
sha256sum
=
dict
(
default
=
''
),
sha256sum
=
dict
(
default
=
''
),
timeout
=
dict
(
required
=
False
,
type
=
'int'
,
default
=
10
),
)
)
module
=
AnsibleModule
(
module
=
AnsibleModule
(
...
@@ -205,6 +212,7 @@ def main():
...
@@ -205,6 +212,7 @@ def main():
force
=
module
.
params
[
'force'
]
force
=
module
.
params
[
'force'
]
sha256sum
=
module
.
params
[
'sha256sum'
]
sha256sum
=
module
.
params
[
'sha256sum'
]
use_proxy
=
module
.
params
[
'use_proxy'
]
use_proxy
=
module
.
params
[
'use_proxy'
]
timeout
=
module
.
params
[
'timeout'
]
dest_is_dir
=
os
.
path
.
isdir
(
dest
)
dest_is_dir
=
os
.
path
.
isdir
(
dest
)
last_mod_time
=
None
last_mod_time
=
None
...
@@ -219,7 +227,7 @@ def main():
...
@@ -219,7 +227,7 @@ def main():
last_mod_time
=
datetime
.
datetime
.
utcfromtimestamp
(
mtime
)
last_mod_time
=
datetime
.
datetime
.
utcfromtimestamp
(
mtime
)
# download to tmpsrc
# download to tmpsrc
tmpsrc
,
info
=
url_get
(
module
,
url
,
dest
,
use_proxy
,
last_mod_time
,
force
)
tmpsrc
,
info
=
url_get
(
module
,
url
,
dest
,
use_proxy
,
last_mod_time
,
force
,
timeout
)
# Now the request has completed, we can finally generate the final
# Now the request has completed, we can finally generate the final
# destination file name from the info dict.
# destination file name from the info dict.
...
...
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