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
6fc26a35
Commit
6fc26a35
authored
Apr 14, 2020
by
Thomas Gambier
🚴🏼
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve log message and use lazy logging
parent
1ae8107b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
8 deletions
+10
-8
slapcache/signature.py
slapcache/signature.py
+10
-8
No files found.
slapcache/signature.py
View file @
6fc26a35
...
...
@@ -157,9 +157,11 @@ class Signature:
self
.
config
=
config
self
.
logger
=
logger
def
log
(
self
,
message
):
def
log
(
self
,
message
,
*
args
):
if
self
.
logger
is
not
None
:
self
.
logger
.
debug
(
message
)
self
.
logger
.
debug
(
message
,
*
args
)
elif
args
:
print
(
message
%
args
)
else
:
print
(
message
)
...
...
@@ -189,11 +191,11 @@ class Signature:
required_key_list
=
[
'timestamp'
],
strategy
=
strategy
)
if
download_metadata_dict
:
self
.
log
(
'File downloaded
on temp %s'
%
path
)
self
.
log
(
'File downloaded
in %s'
,
path
)
current_sha256
=
self
.
get_file_hash
(
path
)
if
shacache
.
download
(
path
=
sha256path
,
required_key_list
=
[
'timestamp'
],
strategy
=
strategy
,
is_sha256file
=
True
):
self
.
log
(
'
File downloaded on temp. %s'
%
sha256path
)
self
.
log
(
'
sha 256 downloaded in %s'
,
sha256path
)
with
open
(
sha256path
,
'rb'
)
as
f
:
expected_sha256
=
f
.
read
()
...
...
@@ -230,16 +232,16 @@ class Signature:
try
:
if
shacache
.
upload
(
path
=
path
,
metadata_dict
=
metadata_dict
):
self
.
log
(
'Uploaded
upload file to cache.'
)
self
.
log
(
'Uploaded
%s to cache (using %s key).'
,
path
,
shacache
.
directory_key
)
if
shacache
.
upload
(
path
=
sha256path
,
metadata_dict
=
metadata_dict
,
is_sha256file
=
True
):
self
.
log
(
'Uploaded
sha256file file to cache.'
)
self
.
log
(
'Uploaded
%s to cache (using %s key).'
,
sha256path
,
shacache
.
directory_key
)
else
:
self
.
log
(
'Fail to upload sha256file file to cache.'
)
else
:
self
.
log
(
'Fail to upload
file to cache.'
)
self
.
log
(
'Fail to upload
%s to cache.'
,
path
)
except
Exception
:
self
.
log
(
'Unable to upload to cache:
\
n
%s.'
%
traceback
.
format_exc
())
self
.
log
(
'Unable to upload to cache:
\
n
%s.'
,
traceback
.
format_exc
())
return
def
upload
(
self
):
...
...
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