コード例 #1
0
ファイル: test_json.py プロジェクト: Thisisdotme/thisis.me
  def test_json(self):
    obj = json_serializer.load_string(self.string)
    self.assertEqual(obj['hello'], 'world')
    self.assertEqual(obj['int'], 1234)

    result = json_serializer.dump_string(obj)
    self.assertEqual(self.string, result)
コード例 #2
0
ファイル: Event.py プロジェクト: Thisisdotme/thisis.me
 def getAuxillaryContent(self):
   auxData = {}
   if 'location' in self.raw_json:
     auxData['location'] = self.raw_json['location']
   if 'images' in self.raw_json:
     auxData['images'] = self.raw_json['images']
   return json_serializer.dump_string(auxData)
コード例 #3
0
ファイル: driver.py プロジェクト: Thisisdotme/thisis.me
 def _send_message(self, message):
   routing_key = message['header']['type']
   body = json_serializer.dump_string(message)
   self.factory.amqp.send_message(
       exchange=self.factory.amqp_exchange,
       routing_key=routing_key,
       msg=body)
コード例 #4
0
ファイル: driver.py プロジェクト: Thisisdotme/thisis.me
 def notify_event_collector(self, asm):
   notification = messages.create_notification_message('twitter', asm.service_author_id)
   routing_key = notification['header']['type']
   body = json_serializer.dump_string(notification)
   self.amqp.send_message(
       exchange=self.amqp_exchange,
       routing_key=routing_key,
       msg=body)
コード例 #5
0
ファイル: Event.py プロジェクト: Thisisdotme/thisis.me
  def getAuxillaryContent(self):
    auxData = {}

    venueURL = self.raw_json['venue'].get('url')
    auxData['venue_url'] = venueURL

    photoSizes = self.raw_json['photos']['items'][0]['sizes'] if int(self.raw_json['photos']['count']) > 0 else None
    if photoSizes:
      auxData['photo_sizes'] = photoSizes

    return json_serializer.dump_string(auxData) if venueURL else None
コード例 #6
0
def correlate_and_update_event(url, correlation_id, author_id, me_service_id):
  if correlation_id:
    # Get the ASM for this user
    asm = author_service_map.query_asm_by_author_and_service(author_id, me_service_id)

    # We have a correlation
    correlation_event = service_event.query_correlation_event(
        me_service_id,
        correlation_id,
        author_id)

    correlated_events = service_event.query_correlated_events(author_id, correlation_id)

    (correlation_json,
     source_event,
     created_time,
     modified_time) = _analyze_correlated_events(url, correlated_events)

    json_string = json_serializer.dump_string(correlation_json)

    if correlation_event:
      correlation_event.modify_time = modified_time
      correlation_event.create_time = created_time
      correlation_event.headline = source_event.headline
      correlation_event.caption = source_event.caption
      correlation_event.tagline = source_event.tagline
      correlation_event.content = source_event.content
      correlation_event.photo_url = source_event.photo_url
      correlation_event.json = json_string
    else:
      # create a new row with this id
      correlation_event = models.ServiceEvent(
          asm.id,
          models.ServiceObjectType.CORRELATION_TYPE,
          author_id,
          me_service_id,
          correlation_id,
          created_time,
          modify_time=modified_time,
          headline=source_event.headline,
          caption=source_event.caption,
          tagline=source_event.tagline,
          content=source_event.content,
          photo_url=source_event.photo_url,
          json=json_string)
      db.Session().add(correlation_event)
    db.Session().flush()
コード例 #7
0
ファイル: Event.py プロジェクト: Thisisdotme/thisis.me
 def toJSON(self):
   return json_serializer.dump_string(self.toNormalizedObj())