Showing
3 changed files
with
11 additions
and
11 deletions
... | @@ -63,7 +63,7 @@ class Context(object): | ... | @@ -63,7 +63,7 @@ class Context(object): |
63 | if os.path.isdir('.kappa'): | 63 | if os.path.isdir('.kappa'): |
64 | cache_file = os.path.join('.kappa', 'cache') | 64 | cache_file = os.path.join('.kappa', 'cache') |
65 | if os.path.isfile(cache_file): | 65 | if os.path.isfile(cache_file): |
66 | - with open(cache_file, 'rb') as fp: | 66 | + with open(cache_file, 'r') as fp: |
67 | self.cache = yaml.load(fp) | 67 | self.cache = yaml.load(fp) |
68 | 68 | ||
69 | def _delete_cache(self): | 69 | def _delete_cache(self): |
... | @@ -75,14 +75,14 @@ class Context(object): | ... | @@ -75,14 +75,14 @@ class Context(object): |
75 | if not os.path.isdir('.kappa'): | 75 | if not os.path.isdir('.kappa'): |
76 | os.mkdir('.kappa') | 76 | os.mkdir('.kappa') |
77 | cache_file = os.path.join('.kappa', 'cache') | 77 | cache_file = os.path.join('.kappa', 'cache') |
78 | - with open(cache_file, 'wb') as fp: | 78 | + with open(cache_file, 'w') as fp: |
79 | yaml.dump(self.cache, fp) | 79 | yaml.dump(self.cache, fp) |
80 | 80 | ||
81 | def get_cache_value(self, key): | 81 | def get_cache_value(self, key): |
82 | return self.cache.setdefault(self.environment, dict()).get(key) | 82 | return self.cache.setdefault(self.environment, dict()).get(key) |
83 | 83 | ||
84 | def set_cache_value(self, key, value): | 84 | def set_cache_value(self, key, value): |
85 | - self.cache.setdefault(self.environment, dict())[key] = value | 85 | + self.cache.setdefault(self.environment, dict())[key] = value.encode('utf-8') |
86 | self._save_cache() | 86 | self._save_cache() |
87 | 87 | ||
88 | @property | 88 | @property | ... | ... |
... | @@ -137,7 +137,7 @@ class Function(object): | ... | @@ -137,7 +137,7 @@ class Function(object): |
137 | m = hashlib.md5() | 137 | m = hashlib.md5() |
138 | with open(self.zipfile_name, 'rb') as fp: | 138 | with open(self.zipfile_name, 'rb') as fp: |
139 | m.update(fp.read()) | 139 | m.update(fp.read()) |
140 | - zip_md5 = m.hexdigest().encode('utf-8') | 140 | + zip_md5 = m.hexdigest() |
141 | cached_md5 = self._context.get_cache_value('zip_md5') | 141 | cached_md5 = self._context.get_cache_value('zip_md5') |
142 | LOG.debug('zip_md5: %s', zip_md5) | 142 | LOG.debug('zip_md5: %s', zip_md5) |
143 | LOG.debug('cached md5: %s', cached_md5) | 143 | LOG.debug('cached md5: %s', cached_md5) |
... | @@ -153,12 +153,12 @@ class Function(object): | ... | @@ -153,12 +153,12 @@ class Function(object): |
153 | # If the MD5 does not match the cached MD5, the configuration has | 153 | # If the MD5 does not match the cached MD5, the configuration has |
154 | # changed and needs to be updated so return True. | 154 | # changed and needs to be updated so return True. |
155 | m = hashlib.md5() | 155 | m = hashlib.md5() |
156 | - m.update(self.description) | 156 | + m.update(self.description.encode('utf-8')) |
157 | - m.update(self.handler) | 157 | + m.update(self.handler.encode('utf-8')) |
158 | - m.update(str(self.memory_size)) | 158 | + m.update(str(self.memory_size).encode('utf-8')) |
159 | - m.update(self._context.exec_role_arn) | 159 | + m.update(self._context.exec_role_arn.encode('utf-8')) |
160 | - m.update(str(self.timeout)) | 160 | + m.update(str(self.timeout).encode('utf-8')) |
161 | - config_md5 = m.hexdigest().encode('utf-8') | 161 | + config_md5 = m.hexdigest() |
162 | cached_md5 = self._context.get_cache_value('config_md5') | 162 | cached_md5 = self._context.get_cache_value('config_md5') |
163 | LOG.debug('config_md5: %s', config_md5) | 163 | LOG.debug('config_md5: %s', config_md5) |
164 | LOG.debug('cached_md5: %s', cached_md5) | 164 | LOG.debug('cached_md5: %s', cached_md5) | ... | ... |
... | @@ -125,7 +125,7 @@ class Policy(object): | ... | @@ -125,7 +125,7 @@ class Policy(object): |
125 | def _check_md5(self, document): | 125 | def _check_md5(self, document): |
126 | m = hashlib.md5() | 126 | m = hashlib.md5() |
127 | m.update(document.encode('utf-8')) | 127 | m.update(document.encode('utf-8')) |
128 | - policy_md5 = m.hexdigest().encode('utf-8') | 128 | + policy_md5 = m.hexdigest() |
129 | cached_md5 = self._context.get_cache_value('policy_md5') | 129 | cached_md5 = self._context.get_cache_value('policy_md5') |
130 | LOG.debug('policy_md5: %s', policy_md5) | 130 | LOG.debug('policy_md5: %s', policy_md5) |
131 | LOG.debug('cached md5: %s', cached_md5) | 131 | LOG.debug('cached md5: %s', cached_md5) | ... | ... |
-
Please register or login to post a comment