コード例 #1
0
    def init(self, configurationAttributes):
        print "Toopher. Initialization"
        toopher_creds_file = configurationAttributes.get(
            "toopher_creds_file").getValue2()

        # Load credentials from file
        f = open(toopher_creds_file, 'r')
        try:
            creds = json.loads(f.read())
        except:
            return False
        finally:
            f.close()

        consumer_key = creds["CONSUMER_KEY"]
        consumer_secret = creds["CONSUMER_SECRET"]
        try:
            stringEncrypter = StringEncrypter.defaultInstance()
            consumer_secret = stringEncrypter.decrypt(consumer_secret)
        except:
            return False

        self.tapi = ToopherAPI(consumer_key, consumer_secret)
        print "Toopher. Initialized successfully"

        return True