Commits

pval...@lookindustry  committed fd48396

Mudanças na correria

  • Participants
  • Parent commits 58532b2

Comments (0)

Files changed (4)

File comofas_answers.py

-#! /usr/bin/env python
 # -*- coding: utf-8 -*-
 
 # Comofas - everyone deserves an answer from Yahoo!Answers and Twitter
 import simplejson
 import sys
 import logging
-import pickle
+import cPickle as pickle
 import os
 import traceback
 

File comofas_questions.py

-#! /usr/bin/env python
 # -*- coding: utf-8 -*-
 
 # Comofas - everyone deserves an answer from Yahoo!Answers and Twitter
 import simplejson
 import sys
 import logging
-import pickle
+import cPickle as pickle
 import os
 import traceback
 
         #descobre as não gravadas, ou seja, as novas
         question_ids = []        
         for q in questions:
-            question_ids.append(q['id'])
+             question_ids.append(q['id'])
         
         persisted_ids = []
+           
+        
         for p in self.persisted_questions:
             persisted_ids.append(p['id'])
         

File comofas_settings.py

 # questions posted @ Twitter
 
 REGION='br'
-KEYWORD=''
+KEYWORD='comofas'
 
 LOG_FILENAME='logging.out'
 
 # usado para fazer follow de novos usuarios
 LAST_USERS_SIZE=5
 
+NUMBER_OF_TWEETS = 10
+
 DEBUG = True

File comofas_twitterer.py

-#! /usr/bin/env python
 # -*- coding: utf-8 -*-
 
 # Comofas - everyone deserves an answer from Yahoo!Answers and Twitter
 import simplejson
 import sys
 import logging
-import pickle
+import cPickle as pickle
 import os
 import traceback
 
             self.picklefd =open(PICKLE_FILENAME,'wb')
             self.persisted_questions = pickle.load(self.picklefd)
             self.picklefd.close()
+        
+        
 
     def persist_questions(self):
         self.picklefd =open(PICKLE_FILENAME,"wb")
                 # Beleza, temos uma pergunta respondida e não tuitada.
                 # Vamos em frente
                 
-                if contador_de_posts <= 2:
+                if contador_de_posts <= (NUMBER_OF_TWEETS - 1):
                     
                     to_user = question['from_user']
                     raw_answer = question['answer']['ChosenAnswer']
                     # Se tiver mandado, aborta o post e atualiza a persistencia
 
                     if not update in fasassim_updates:
-                        status = self.twitter_connection.PostUpdate(update)
-                    question['twittered'] = True
+                        if not DEBUG:
+                            status = self.twitter_connection.PostUpdate(update)
+                    if not DEBUG: question['twittered'] = True
                     question['posted_tweet'] = update                    
                     contador_de_posts = contador_de_posts + 1