mirror of
https://github.com/SpiceBot/SpiceBot.git
synced 2026-11-13 06:59:53 -05:00
request method
This commit is contained in:
parent
70d83d4dd8
commit
89a2b316e0
@ -7,8 +7,6 @@ This is the SpiceBot Update system.
|
|||||||
import sopel
|
import sopel
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
import json
|
|
||||||
from restkit import request
|
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
|
|
||||||
from .Config import config as botconfig
|
from .Config import config as botconfig
|
||||||
@ -54,19 +52,8 @@ class BotVersion():
|
|||||||
# get actual version number, and commit count, and assemble a version
|
# get actual version number, and commit count, and assemble a version
|
||||||
|
|
||||||
def count_repo_commits(self, _acc=0):
|
def count_repo_commits(self, _acc=0):
|
||||||
r = request("https://api.github.com/repos/SpiceBot/SpiceBot/commits/master")
|
info = requests.get(self.spicebot["version_url"], verify=botconfig.core.verify_ssl).json()
|
||||||
commits = json.loads(r.body_string())
|
return len(info)
|
||||||
n = len(commits)
|
|
||||||
if n == 0:
|
|
||||||
return _acc
|
|
||||||
link = r.headers.get('link')
|
|
||||||
if link is None:
|
|
||||||
return _acc + n
|
|
||||||
next_url = self.find_next(r.headers['link'])
|
|
||||||
if next_url is None:
|
|
||||||
return _acc + n
|
|
||||||
# try to be tail recursive, even when it doesn't matter in CPython
|
|
||||||
return self.count_repo_commits(next_url, _acc + n)
|
|
||||||
|
|
||||||
def find_next(self, link):
|
def find_next(self, link):
|
||||||
for l in link.split(','):
|
for l in link.split(','):
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user