Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapcache
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
slapcache
Commits
d60cf318
Commit
d60cf318
authored
Jul 15, 2019
by
Thomas Gambier
🚴🏼
Committed by
Rafael Monnerat
Jul 15, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for Python 3
parent
169a3705
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
16 additions
and
15 deletions
+16
-15
setup.py
setup.py
+1
-0
slapcache/conf.py
slapcache/conf.py
+3
-3
slapcache/download.py
slapcache/download.py
+2
-2
slapcache/signature.py
slapcache/signature.py
+8
-8
slapcache/upload.py
slapcache/upload.py
+2
-2
No files found.
setup.py
View file @
d60cf318
...
...
@@ -22,6 +22,7 @@ setup(name=name,
install_requires
=
[
'slapos.libnetworkcache>=0.14.1'
,
'iniparse'
,
'six'
,
],
zip_safe
=
False
,
entry_points
=
{
...
...
slapcache/conf.py
View file @
d60cf318
...
...
@@ -34,7 +34,7 @@ import logging
from
optparse
import
OptionParser
,
Option
from
time
import
time
import
sys
from
signature
import
Config
from
s
lapcache.s
ignature
import
Config
import
os
class
Parser
(
OptionParser
):
...
...
@@ -82,10 +82,10 @@ def mkdir_p(path):
if
not
os
.
path
.
exists
(
path
):
os
.
makedirs
(
path
)
def
create
(
path
,
text
=
None
,
mode
=
0666
):
def
create
(
path
,
text
=
None
,
mode
=
0
o
666
):
fd
=
os
.
open
(
path
,
os
.
O_CREAT
|
os
.
O_WRONLY
|
os
.
O_TRUNC
,
mode
)
try
:
os
.
write
(
fd
,
text
)
os
.
write
(
fd
,
text
.
encode
(
'utf-8'
)
)
finally
:
os
.
close
(
fd
)
...
...
slapcache/download.py
View file @
d60cf318
...
...
@@ -28,12 +28,12 @@
#
##############################################################################
import
ConfigP
arser
from
six.moves
import
configp
arser
import
datetime
from
optparse
import
OptionParser
,
Option
import
sys
from
signature
import
Signature
,
Config
from
s
lapcache.s
ignature
import
Signature
,
Config
class
Parser
(
OptionParser
):
"""
...
...
slapcache/signature.py
View file @
d60cf318
...
...
@@ -27,7 +27,7 @@
#
##############################################################################
import
ConfigP
arser
from
six.moves
import
configp
arser
import
os
import
time
import
traceback
...
...
@@ -39,8 +39,8 @@ import base64
from
random
import
choice
from
string
import
ascii_lowercase
from
slapos.
networkcachehelper
import
NetworkcacheClient
,
\
helper_download_network_cached
from
slapos.
libnetworkcache
import
NetworkcacheClient
from
slapos.networkcachehelper
import
helper_download_network_cached
class
NetworkCache
:
...
...
@@ -51,7 +51,7 @@ class NetworkCache:
self
.
_load
()
def
_load
(
self
):
network_cache_info
=
ConfigP
arser
.
RawConfigParser
()
network_cache_info
=
configp
arser
.
RawConfigParser
()
network_cache_info
.
read
(
self
.
configuration
)
network_cache_info_dict
=
dict
(
network_cache_info
.
items
(
'networkcache'
))
def
get_
(
name
):
...
...
@@ -161,10 +161,10 @@ class Signature:
if
self
.
logger
is
not
None
:
self
.
logger
.
debug
(
message
)
else
:
print
message
print
(
message
)
def
get_file_hash
(
self
,
path
):
with
open
(
path
)
as
f
:
with
open
(
path
,
'rb'
)
as
f
:
h
=
hashlib
.
sha256
()
h
.
update
(
f
.
read
())
base
=
base64
.
b64encode
(
h
.
digest
())
...
...
@@ -172,7 +172,7 @@ class Signature:
def
save_file_hash
(
self
,
path
,
destination
):
base
=
self
.
get_file_hash
(
path
)
with
open
(
destination
,
"w"
)
as
f
:
with
open
(
destination
,
"w
b
"
)
as
f
:
f
.
write
(
base
)
def
_download
(
self
,
path
):
...
...
@@ -194,7 +194,7 @@ class Signature:
if
shacache
.
download
(
path
=
sha256path
,
required_key_list
=
[
'timestamp'
],
strategy
=
strategy
,
is_sha256file
=
True
):
self
.
log
(
'File downloaded on temp. %s'
%
sha256path
)
with
open
(
sha256path
)
as
f
:
with
open
(
sha256path
,
'rb'
)
as
f
:
expected_sha256
=
f
.
read
()
if
current_sha256
==
expected_sha256
:
...
...
slapcache/upload.py
View file @
d60cf318
...
...
@@ -28,12 +28,12 @@
#
##############################################################################
import
ConfigP
arser
from
six.moves
import
configp
arser
import
datetime
from
optparse
import
OptionParser
,
Option
import
sys
from
signature
import
Signature
,
Config
from
s
lapcache.s
ignature
import
Signature
,
Config
class
Parser
(
OptionParser
):
"""
...
...
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