Toggle navigation
Toggle navigation
This project
Loading...
Sign in
서승완
/
kappa
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Authored by
Mitch Garnaat
2015-12-14 08:23:33 -0500
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
672626db3131d405bd02bda7d2be823754fc85cc
672626db
1 parent
fcdc6f5d
Another run at fixing the Py3 encoding problems.
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
11 deletions
kappa/context.py
kappa/function.py
kappa/policy.py
kappa/context.py
View file @
672626d
...
...
@@ -63,7 +63,7 @@ class Context(object):
if
os
.
path
.
isdir
(
'.kappa'
):
cache_file
=
os
.
path
.
join
(
'.kappa'
,
'cache'
)
if
os
.
path
.
isfile
(
cache_file
):
with
open
(
cache_file
,
'r
b
'
)
as
fp
:
with
open
(
cache_file
,
'r'
)
as
fp
:
self
.
cache
=
yaml
.
load
(
fp
)
def
_delete_cache
(
self
):
...
...
@@ -75,14 +75,14 @@ class Context(object):
if
not
os
.
path
.
isdir
(
'.kappa'
):
os
.
mkdir
(
'.kappa'
)
cache_file
=
os
.
path
.
join
(
'.kappa'
,
'cache'
)
with
open
(
cache_file
,
'w
b
'
)
as
fp
:
with
open
(
cache_file
,
'w'
)
as
fp
:
yaml
.
dump
(
self
.
cache
,
fp
)
def
get_cache_value
(
self
,
key
):
return
self
.
cache
.
setdefault
(
self
.
environment
,
dict
())
.
get
(
key
)
def
set_cache_value
(
self
,
key
,
value
):
self
.
cache
.
setdefault
(
self
.
environment
,
dict
())[
key
]
=
value
self
.
cache
.
setdefault
(
self
.
environment
,
dict
())[
key
]
=
value
.
encode
(
'utf-8'
)
self
.
_save_cache
()
@property
...
...
kappa/function.py
View file @
672626d
...
...
@@ -137,7 +137,7 @@ class Function(object):
m
=
hashlib
.
md5
()
with
open
(
self
.
zipfile_name
,
'rb'
)
as
fp
:
m
.
update
(
fp
.
read
())
zip_md5
=
m
.
hexdigest
()
.
encode
(
'utf-8'
)
zip_md5
=
m
.
hexdigest
()
cached_md5
=
self
.
_context
.
get_cache_value
(
'zip_md5'
)
LOG
.
debug
(
'zip_md5:
%
s'
,
zip_md5
)
LOG
.
debug
(
'cached md5:
%
s'
,
cached_md5
)
...
...
@@ -153,12 +153,12 @@ class Function(object):
# If the MD5 does not match the cached MD5, the configuration has
# changed and needs to be updated so return True.
m
=
hashlib
.
md5
()
m
.
update
(
self
.
description
)
m
.
update
(
self
.
handler
)
m
.
update
(
str
(
self
.
memory_size
))
m
.
update
(
self
.
_context
.
exec_role_arn
)
m
.
update
(
str
(
self
.
timeout
))
config_md5
=
m
.
hexdigest
()
.
encode
(
'utf-8'
)
m
.
update
(
self
.
description
.
encode
(
'utf-8'
)
)
m
.
update
(
self
.
handler
.
encode
(
'utf-8'
)
)
m
.
update
(
str
(
self
.
memory_size
)
.
encode
(
'utf-8'
)
)
m
.
update
(
self
.
_context
.
exec_role_arn
.
encode
(
'utf-8'
)
)
m
.
update
(
str
(
self
.
timeout
)
.
encode
(
'utf-8'
)
)
config_md5
=
m
.
hexdigest
()
cached_md5
=
self
.
_context
.
get_cache_value
(
'config_md5'
)
LOG
.
debug
(
'config_md5:
%
s'
,
config_md5
)
LOG
.
debug
(
'cached_md5:
%
s'
,
cached_md5
)
...
...
kappa/policy.py
View file @
672626d
...
...
@@ -125,7 +125,7 @@ class Policy(object):
def
_check_md5
(
self
,
document
):
m
=
hashlib
.
md5
()
m
.
update
(
document
.
encode
(
'utf-8'
))
policy_md5
=
m
.
hexdigest
()
.
encode
(
'utf-8'
)
policy_md5
=
m
.
hexdigest
()
cached_md5
=
self
.
_context
.
get_cache_value
(
'policy_md5'
)
LOG
.
debug
(
'policy_md5:
%
s'
,
policy_md5
)
LOG
.
debug
(
'cached md5:
%
s'
,
cached_md5
)
...
...
Please
register
or
login
to post a comment