#4 Always try to serialize the dates but be more careful when doing it
Closed 4 years ago by pingou. Opened 4 years ago by pingou.
pingou/koji-fedmsg-plugin fix_datetime_serialization  into  master

file modified
+5 -4
@@ -29,11 +29,11 @@ 

      return re.sub('([a-z0-9])([A-Z])', r'\1.\2', s1).lower()

  

  

- def serialize_datetime_in_task(task):

+ def serialize_datetime(msg):

      for date_key in ("completion_time", "create_time", "start_time"):

-         if task[date_key] is None:

+         if msg.get(date_key) is None:

              continue

-         task[date_key] = time.mktime(task[date_key].timetuple())

+         msg[date_key] = time.mktime(msg[date_key].timetuple())

  

  

  def get_message_body(topic, *args, **kws):
@@ -53,7 +53,6 @@ 

          msg['update'] = kws.get('update', None)

      elif topic == 'task.state.change':

          info = kws['info']

-         serialize_datetime_in_task(info)

  

          # Stuff in information about descendant tasks

          task = kojihub.Task(info['id'])
@@ -149,6 +148,8 @@ 

              msg['build'] = kws['build']

              msg['rpm'] = kws['rpm']

  

+     serialize_datetime(msg)

+ 

      return msg

  

  

Basically, we should check for every message we are trying to send
if they contain dates and if they do serialize them.
But since we're not sure if they do, we need to be more careful when
checking it.

Signed-off-by: Pierre-Yves Chibon pingou@pingoured.fr

rebased onto b584d34

4 years ago

Not going to work, closing :(

Pull-Request has been closed by pingou

4 years ago
Metadata