Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
installsystems
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
Seblu
installsystems
Commits
38d6770b
Commit
38d6770b
authored
13 years ago
by
Seblu
Browse files
Options
Downloads
Patches
Plain Diff
add timeout to uopen
parent
bdb3b4af
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
installsystems/repository.py
+3
-2
3 additions, 2 deletions
installsystems/repository.py
installsystems/tools.py
+2
-2
2 additions, 2 deletions
installsystems/tools.py
with
5 additions
and
4 deletions
installsystems/repository.py
+
3
−
2
View file @
38d6770b
...
...
@@ -104,7 +104,7 @@ class Repository(object):
'''
try
:
last_path
=
os
.
path
.
join
(
config
.
path
,
config
.
lastname
)
return
int
(
istools
.
u
open
(
last_path
,
"
r
"
).
read
().
rstrip
())
return
int
(
open
(
last_path
,
"
r
"
).
read
().
rstrip
())
except
Exception
as
e
:
raise
Exception
(
"
Read last file failed: %s
"
%
e
)
return
0
...
...
@@ -425,7 +425,8 @@ class RepositoryManager(object):
open
(
filedest
,
"
wb
"
)
# get remote last value
try
:
rlast
=
int
(
istools
.
uopen
(
config
.
lastpath
).
read
().
strip
())
rlast
=
int
(
istools
.
uopen
(
config
.
lastpath
,
timeout
=
self
.
timeout
).
read
().
strip
())
# get local last value
llast
=
int
(
os
.
stat
(
filedest
).
st_mtime
)
# if repo is out of date, download it
...
...
This diff is collapsed.
Click to expand it.
installsystems/tools.py
+
2
−
2
View file @
38d6770b
...
...
@@ -130,7 +130,7 @@ def abspath(path):
else
:
return
None
def
uopen
(
path
,
mode
=
"
rb
"
):
def
uopen
(
path
,
mode
=
"
rb
"
,
timeout
=
3
):
'''
Universal Open
Create a file-like object to a file which can be remote
...
...
@@ -139,7 +139,7 @@ def uopen(path, mode="rb"):
if
ftype
==
"
file
"
:
return
open
(
path
,
mode
)
elif
ftype
==
"
http
"
or
ftype
==
"
ftp
"
:
return
urllib2
.
urlopen
(
path
)
return
urllib2
.
urlopen
(
path
,
timeout
=
timeout
)
else
:
raise
NotImplementedError
...
...
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