Skip to content
This repository has been archived by the owner on Oct 5, 2020. It is now read-only.

fix timezone info UnicodeDecodeError #227

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions cloudify/logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import logging
import json
import datetime
import locale
from functools import wraps

from cloudify import amqp_client
Expand Down Expand Up @@ -286,6 +287,10 @@ def _send_event(ctx, context_type, event_type,

def populate_base_item(item, message_type):
timezone = time.strftime("%z", time.gmtime())
codeset = locale.getlocale()[1]
if codeset:
# decode with correct codeset, and encode as utf-8
timezone = timezone.decode(codeset).encode('utf_8', 'ignore')
timestamp = str(datetime.datetime.now())[0:-3] + timezone
item['timestamp'] = timestamp
item['message_code'] = None
Expand Down