def __init__(self, app_type="kuaipan"): sess = KuaipanSession(self._consumer_key, self._consumer_secret, app_type) self.api = KuaipanAPI(sess) if os.path.exists('.token'): fp = open('.token', 'rb') key = fp.readline() secret = fp.readline() fp.close() sess.token = oauth.oauth.OAuthToken(key[:-1], secret[:-1]) ret = self.account_info() if ret != False: print(u"%s 登陆成功..\n" % ret['user_name']) print(u"\t用户总空间:%dM" % (ret['quota_total']/1024/1024)) print(u"\t已使用空间:%dM" % (ret['quota_used']/1024/1024)) print(u"\t允许上传最大文件:%dM" % (ret['max_file_size']/1024/1024)) print("--------------------------------------\n") return url = self.api.requestToken() print(u"如果没有自动访问的话,请将下面链接复制到浏览器中。\n%s" % url) webbrowser.open(url) print(u"使用上面链接登陆成功后按回车键继续..") raw_input() self.api.accessToken() fp = open('.token', 'wb') fp.write(sess.token.key + '\n') fp.write(sess.token.secret + '\n') fp.close()
def __init__(self, app_type="kuaipan"): sess = KuaipanSession(self._consumer_key, self._consumer_secret, app_type) self.api = KuaipanAPI(sess) if os.path.exists('.token'): fp = open('.token', 'rb') key = fp.readline() secret = fp.readline() fp.close() sess.token = oauth.oauth.OAuthToken(key[:-1], secret[:-1]) ret = self.account_info() if ret != False: print(u"%s 登陆成功..\n" % ret['user_name']) print(u"\t用户总空间:%dM" % (ret['quota_total'] / 1024 / 1024)) print(u"\t已使用空间:%dM" % (ret['quota_used'] / 1024 / 1024)) print(u"\t允许上传最大文件:%dM" % (ret['max_file_size'] / 1024 / 1024)) print("--------------------------------------\n") return url = self.api.requestToken() print(u"如果没有自动访问的话,请将下面链接复制到浏览器中。\n%s" % url) webbrowser.open(url) print(u"使用上面链接登陆成功后按回车键继续..") raw_input() self.api.accessToken() fp = open('.token', 'wb') fp.write(sess.token.key + '\n') fp.write(sess.token.secret + '\n') fp.close()