Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
mio
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Anders Blomdell
mio
Commits
6a73c286
Commit
6a73c286
authored
May 6, 2014
by
Anders Blomdell
Browse files
Options
Downloads
Patches
Plain Diff
Version 2014-05-06 19:07
parent
dea6a7ba
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/mio/filecache.py
+8
-3
8 additions, 3 deletions
src/mio/filecache.py
src/mio/urlgrabber_compat.py
+53
-0
53 additions, 0 deletions
src/mio/urlgrabber_compat.py
with
61 additions
and
3 deletions
src/mio/filecache.py
+
8
−
3
View file @
6a73c286
...
...
@@ -6,13 +6,18 @@ import re
import
sys
import
tempfile
import
time
import
urlgrabber
import
urlgrabber.mirror
import
urlparse
import
urllib
import
mio.exception
import
socket
try
:
import
urlgrabber
import
urlgrabber.mirror
import
pycurl
except
ImportError
:
import
mio.urlgrabber_compat
as
urlgrabber
import
mio.urlgrabber_compat
as
pycurl
pass
temp
=
[]
cache
=
{}
...
...
...
...
This diff is collapsed.
Click to expand it.
src/mio/urlgrabber_compat.py
0 → 100755
+
53
−
0
View file @
6a73c286
#
# Hackish compat library when urlgrabber is missing (MacOS)
#
import
urllib2
import
calendar
import
time
INFO_FILETIME
=
object
()
class
CurlWrapper
:
def
__init__
(
self
,
url
):
self
.
url
=
url
self
.
curl_obj
=
self
self
.
scheme
=
self
.
url
.
geturl
().
split
(
'
:
'
,
1
)[
0
]
def
getinfo
(
self
,
what
):
if
what
==
INFO_FILETIME
:
modified
=
self
.
url
.
info
()[
"
Last-Modified
"
]
mtime
=
calendar
.
timegm
(
time
.
strptime
(
modified
,
"
%a, %d %b %Y %H:%M:%S %Z
"
))
return
mtime
raise
Exception
(
'
Unknown getifo %s
'
,
what
)
def
__getattr__
(
self
,
what
):
return
getattr
(
self
.
url
,
what
)
pass
class
Compat
:
URLGrabError
=
Exception
()
def
URLGrabber
(
self
):
pass
class
MirrorGroup
:
def
__init__
(
self
,
grabber
,
urls
):
self
.
urls
=
urls
def
urlopen
(
self
,
path
):
for
u
in
self
.
urls
:
url
=
"
%s/%s
"
%
(
u
,
path
)
try
:
return
CurlWrapper
(
urllib2
.
urlopen
(
url
))
except
IOError
,
e
:
pass
raise
IOError
(
"
Failed to get
'
%s
'
(%s)
"
%
(
path
,
e
))
pass
compat
=
Compat
()
grabber
=
compat
mirror
=
grabber
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