Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
archlinux
archversion
Commits
aceddd98
Commit
aceddd98
authored
May 17, 2015
by
Seblu
Browse files
Fix failure when no timeout is defined
parent
17bb70ab
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/lib/archversion/version.py
View file @
aceddd98
...
...
@@ -89,14 +89,14 @@ class VersionController(object):
value
.
get
(
"regex_ext"
,
"\.(?:tar(?:\.gz|\.bz2|\.xz)?|tgz|tbz2|zip)"
)))
# retrieve config timeout
timeout
=
float
(
value
.
get
(
"timeout"
,
None
))
timeout
=
float
(
value
[
"timeout"
])
if
"timeout"
in
value
else
None
# do it retry time + 1
ntry
=
int
(
value
.
get
(
"retry"
,
0
))
+
1
# do the job
for
n
in
range
(
1
,
ntry
+
1
):
try
:
logging
.
debug
(
"Requesting url: %s (try %d/%d)"
%
(
url
,
n
,
ntry
))
logging
.
debug
(
"Timeout is %
f
"
%
timeout
)
logging
.
debug
(
"Timeout is %
s
"
%
timeout
)
url_req
=
Request
(
url
,
headers
=
{
"User-Agent"
:
USER_AGENT
})
url_fd
=
urlopen
(
url_req
,
timeout
=
timeout
)
logging
.
debug
(
"Version regex: %s"
%
regex
)
...
...
@@ -159,14 +159,14 @@ class VersionController(object):
"community-testing,community,testing,extra,core"
).
split
(
","
)
# retrieve config timeout
timeout
=
float
(
value
.
get
(
"timeout"
,
None
))
timeout
=
float
(
value
[
"timeout"
])
if
"timeout"
in
value
else
None
for
arch
in
archs
:
for
repo
in
repos
:
url
=
"http://www.archlinux.org/packages/%s/%s/%s/json"
%
(
repo
,
arch
,
name
)
url_req
=
Request
(
url
,
headers
=
{
"User-Agent"
:
USER_AGENT
})
logging
.
debug
(
"Requesting url: %s"
%
url
)
logging
.
debug
(
"Timeout is %
f
"
%
timeout
)
logging
.
debug
(
"Timeout is %
s
"
%
timeout
)
try
:
url_fd
=
urlopen
(
url_req
,
timeout
=
timeout
)
d
=
json
.
loads
(
url_fd
.
read
().
decode
(
"utf-8"
))
...
...
@@ -183,11 +183,11 @@ class VersionController(object):
logging
.
debug
(
"Get AUR version"
)
try
:
# retrieve config timeout
timeout
=
float
(
value
.
get
(
"timeout"
,
None
))
timeout
=
float
(
value
[
"timeout"
])
if
"timeout"
in
value
else
None
url
=
"http://aur.archlinux.org/rpc.php?type=info&arg=%s"
%
name
url_req
=
Request
(
url
,
headers
=
{
"User-Agent"
:
USER_AGENT
})
logging
.
debug
(
"Requesting url: %s"
%
url
)
logging
.
debug
(
"Timeout is %
f
"
%
timeout
)
logging
.
debug
(
"Timeout is %
s
"
%
timeout
)
url_fd
=
urlopen
(
url_req
,
timeout
=
timeout
)
d
=
json
.
loads
(
url_fd
.
read
().
decode
(
"utf-8"
))
if
"version"
not
in
d
or
d
[
"version"
]
!=
1
:
...
...
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