Example #1
0
 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()
Example #2
0
 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()
Example #3
0
 def __init__(self):
     sess = KuaipanSession(self._consumer_key, self._consumer_secret,
                           "app_folder")
     self.api = KuaipanAPI(sess)
     url = self.api.requestToken()
     print url
     webbrowser.open(url)
     raw_input()
     #time.sleep(30) # sleep  授权
     self.api.accessToken()
Example #4
0
 def setUp(self):
    sess = KuaipanSession("", "", "app_folder")
    sess.set_access_token("", "")
    self.api = KuaipanAPI(sess)
Example #5
0
 def setUp(self):
     sess = KuaipanSession("", "", "app_folder")
     sess.set_access_token("", "")
     self.api = KuaipanAPI(sess)