Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.buildout
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Rafael Monnerat
slapos.buildout
Commits
403c0999
Commit
403c0999
authored
May 06, 2011
by
Lucas Carvalho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed useless import and improved code style.
parent
ca0599e3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
3 deletions
+6
-3
src/zc/buildout/networkcache.py
src/zc/buildout/networkcache.py
+6
-3
No files found.
src/zc/buildout/networkcache.py
View file @
403c0999
...
@@ -15,7 +15,6 @@
...
@@ -15,7 +15,6 @@
import
os
import
os
import
urllib
import
urllib
import
re
import
posixpath
import
posixpath
import
base64
import
base64
import
hashlib
import
hashlib
...
@@ -46,11 +45,13 @@ def _get_sha256_from_file(path):
...
@@ -46,11 +45,13 @@ def _get_sha256_from_file(path):
' The path is not a file: %s '
%
path
' The path is not a file: %s '
%
path
return
_get_hash_from_file
(
path
,
hashlib
.
sha256
())
return
_get_hash_from_file
(
path
,
hashlib
.
sha256
())
def
check_sha256sum
(
path
,
sha256sum
):
def
check_sha256sum
(
path
,
sha256sum
):
"""Tell whether the SHA256sum checksum of the file at path matches
"""Tell whether the SHA256sum checksum of the file at path matches
"""
"""
return
sha256sum
==
_get_hash_from_file
(
path
,
hashlib
.
sha256
())
return
sha256sum
==
_get_hash_from_file
(
path
,
hashlib
.
sha256
())
def
_update_network_cached_map
(
network_cache
,
sha256sum
,
url
,
logger
):
def
_update_network_cached_map
(
network_cache
,
sha256sum
,
url
,
logger
):
"""
"""
If the url is not into the map file, it must be updated.
If the url is not into the map file, it must be updated.
...
@@ -134,6 +135,7 @@ def download_network_cached(network_cache, path, url, logger):
...
@@ -134,6 +135,7 @@ def download_network_cached(network_cache, path, url, logger):
return
True
return
True
def
upload_network_cached
(
network_cache
,
external_url
,
path
,
logger
):
def
upload_network_cached
(
network_cache
,
external_url
,
path
,
logger
):
"""Upload file to a network cache server"""
"""Upload file to a network cache server"""
if
network_cache
in
[
None
,
''
]:
if
network_cache
in
[
None
,
''
]:
...
@@ -148,14 +150,15 @@ def upload_network_cached(network_cache, external_url, path, logger):
...
@@ -148,14 +150,15 @@ def upload_network_cached(network_cache, external_url, path, logger):
url
=
os
.
path
.
join
(
network_cache
,
sha256sum
)
url
=
os
.
path
.
join
(
network_cache
,
sha256sum
)
try
:
try
:
result
=
urllib
.
urlopen
(
url
,
urllib
.
urlencode
({
result
=
urllib
.
urlopen
(
url
,
urllib
.
urlencode
({
"data"
:
base64
.
encodestring
(
data
)}))
"data"
:
base64
.
encodestring
(
data
)}))
if
result
.
code
==
200
and
\
if
result
.
code
==
200
and
\
json
.
loads
(
result
.
read
()).
get
(
'sha'
)
==
sha256sum
:
json
.
loads
(
result
.
read
()).
get
(
'sha'
)
==
sha256sum
:
_update_network_cached_map
(
network_cache
,
sha256sum
,
_update_network_cached_map
(
network_cache
,
sha256sum
,
external_url
,
logger
)
external_url
,
logger
)
except
(
IOError
,
EOFError
),
e
:
except
(
IOError
,
EOFError
),
e
:
logger
.
info
(
'Fail to upload cache on %s. %s'
%
(
external_url
,
str
(
e
)))
logger
.
info
(
'Fail to upload cache on %s. %s'
%
\
(
external_url
,
str
(
e
)))
finally
:
finally
:
f
.
close
()
f
.
close
()
return
True
return
True
...
...
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