script/utils/export_twitter_alchemy.py
changeset 893 10a19dd4e1c9
parent 888 6fc6637d8403
child 957 e4d0094f097b
equal deleted inserted replaced
877:41ce1c341abe 893:10a19dd4e1c9
   364                         ts = tweet_ts
   364                         ts = tweet_ts
   365                     tweet_ts_rel = (tweet_ts-ts) * 1000
   365                     tweet_ts_rel = (tweet_ts-ts) * 1000
   366                     username = None
   366                     username = None
   367                     profile_url = ""
   367                     profile_url = ""
   368                     if tw.user is not None:
   368                     if tw.user is not None:
   369                         username = tw.user.name                    
   369                         username = tw.user.screen_name
   370                         profile_url = tw.user.profile_image_url if tw.user.profile_image_url is not None else ""
   370                         profile_url = tw.user.profile_image_url if tw.user.profile_image_url is not None else ""
   371                     if not username:
   371                     if not username:
   372                         username = "anon."
   372                         username = "anon."
   373                     
   373                     
   374                     element = etree.SubElement(elements, u"element" , {u"id":unicode(uuid.uuid4())+u"-"+unicode(tw.id), u"color":unicode(options.color), u"author":unicode(username), u"date":unicode(tweet_ts_dt.strftime("%Y/%m/%d")), u"begin": unicode(tweet_ts_rel), u"dur":u"0", u"src":unicode(profile_url)})
   374                     element = etree.SubElement(elements, u"element" , {u"id":unicode(uuid.uuid4())+u"-"+unicode(tw.id), u"color":unicode(options.color), u"author":unicode(username), u"date":unicode(tweet_ts_dt.strftime("%Y/%m/%d")), u"begin": unicode(tweet_ts_rel), u"dur":u"0", u"src":unicode(profile_url)})
   414                     get_logger().debug("write http " + content_file_write) #@UndefinedVariable
   414                     get_logger().debug("write http " + content_file_write) #@UndefinedVariable
   415                     get_logger().debug("write http " + repr(post_param)) #@UndefinedVariable
   415                     get_logger().debug("write http " + repr(post_param)) #@UndefinedVariable
   416                     get_logger().debug("write http " + repr(project)) #@UndefinedVariable
   416                     get_logger().debug("write http " + repr(project)) #@UndefinedVariable
   417                     r = requests.put(content_file_write, data=anyjson.dumps(project), headers={'content-type':'application/json'}, params=post_param);
   417                     r = requests.put(content_file_write, data=anyjson.dumps(project), headers={'content-type':'application/json'}, params=post_param);
   418                     get_logger().debug("write http " + repr(r) + " content " + r.text) #@UndefinedVariable
   418                     get_logger().debug("write http " + repr(r) + " content " + r.text) #@UndefinedVariable
   419                     if r.status_code != requests.codes.ok:
   419                     if r.status_code != requests.codes.ok:  # @UndefinedVariable
   420                         r.raise_for_status()
   420                         r.raise_for_status()
   421                 else:
   421                 else:
   422                     if content_file_write and os.path.exists(content_file_write):
   422                     if content_file_write and os.path.exists(content_file_write):
   423                         dest_file_name = content_file_write
   423                         dest_file_name = content_file_write
   424                     else:
   424                     else: