class Twitter(Input): def init(self): self.api = Api(self.atoken, self.atokensecret) def fetch(self): def handler(data): self.send(data) self.api.userstream(handler)
def twitterinitializer(account_number=0): if account_number == 0: global settings # settings - twitter内の辞書の数を数える twitter_setting = settings.get("MODULE_SETTINGS").get("twitter",[]) if isinstance(twitter_setting, dict): twitter_setting = [twitter_setting] account_number = len(twitter_setting) tokens = ['\n"twitter":['] api = Api() for i in range(account_number): print "\n\n---> Authorize %dth account." % (i + 1) tokens.append("\n%s," % str(api.initializer())) tokens.append('],') with open(os.path.dirname(os.path.abspath(__file__)) + "/settings.py", "a") as f: f.writelines(tokens) print tokens
def init(self): self.api = Api(self.atoken, self.atokensecret)