Permalink
Browse files

Added check to temp user data

  • Loading branch information...
1 parent 8ac8fa6 commit 506e8130c006bdee246d5691a97ef9c4e80da9a2 @karpitsky committed May 13, 2011
Showing with 17 additions and 3 deletions.
  1. +15 −3 clclt.py
  2. +2 −0 data/.gitignore
View
@@ -50,6 +50,7 @@ def UsersLookup(self, user_id):
uids.extend(user_id)
parameters['user_id'] = ','.join(["%s" % u for u in uids])
_json = self._FetchUrl(url, parameters=parameters)
+ print _json
data = json.loads(_json)
error = self._ParseError(data)
if error is not None:
@@ -74,6 +75,8 @@ def PostDirectMessage(self, user, text):
url = 'https://api.twitter.com/1/direct_messages/new.json'
data = {'text': text, 'user': user}
_json = self._FetchUrl(url, post_data=data)
+ print data
+ print _json
return _json
def PostUpdate(self, status):
@@ -147,11 +150,19 @@ def _UnGzip(self, response):
return url_data
class FilesHandler:
- def get_json_from_file(self, file):
+ def get_json_from_file(self, file, user_file=0):
try:
json_data = open(file)
try:
data = json.load(json_data)
+ if user_file == 1:
+ data['sub'] = data.get("sub", "follow")
+ data['dm'] = data.get("dm", "public")
+ for i in ["y", "f", "s"]:
+ if i in data:
+ pass
+ else:
+ data[i] = 0
except:
data = {}
data['sub'] = "follow"
@@ -161,14 +172,15 @@ def get_json_from_file(self, file):
data['f'] = 0
json_data.close()
except:
+ print "get_json_from_file error"
exit()
return data
def get_user_info(self, user_id):
user_file = ROOT_PATH + '/data/' + str(user_id) + ".json"
if not os.path.exists(user_file):
open(user_file, 'w').close()
- return self.get_json_from_file(user_file)
+ return self.get_json_from_file(user_file, 1)
def save_info_to_file(self, user_id, user_data):
user_file = ROOT_PATH + '/data/' + str(user_id) + ".json"
@@ -227,7 +239,7 @@ def do_calculate(self):
req_count = ceil(users_count/100.0)
i = 0
while i < req_count:
- mod_req = self.requests % 350
+ mod_req = self.requests % 200
if mod_req == 0:
self.bot += 1
self.th = TwitterHandler(self.bot)
View
@@ -0,0 +1,2 @@
+*
+!.gitignore

0 comments on commit 506e813

Please sign in to comment.