Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6ce495fcd3 | ||
|
|
776a3eff2a | ||
|
|
04e8ae5bdd | ||
|
|
18b9fb3876 | ||
|
|
1da86f27a7 |
@@ -99,11 +99,19 @@ def parseTitle(title):
|
|||||||
def getLinksFromModSearch():
|
def getLinksFromModSearch():
|
||||||
links = {}
|
links = {}
|
||||||
|
|
||||||
contents = urllib.request.urlopen("https://krock-works.uk.to/minetest/modList.php").read().decode("utf-8")
|
try:
|
||||||
for x in json.loads(contents):
|
contents = urllib.request.urlopen("https://krock-works.uk.to/minetest/modList.php").read().decode("utf-8")
|
||||||
link = x.get("link")
|
for x in json.loads(contents):
|
||||||
if link is not None:
|
try:
|
||||||
links[int(x["topicId"])] = link
|
link = x.get("link")
|
||||||
|
if link is not None:
|
||||||
|
links[int(x["topicId"])] = link
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
except urllib.error.URLError:
|
||||||
|
print("Unable to open krocks mod search!")
|
||||||
|
return links
|
||||||
|
|
||||||
return links
|
return links
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,10 @@ from app.utils import randomString
|
|||||||
|
|
||||||
class GithubURLMaker:
|
class GithubURLMaker:
|
||||||
def __init__(self, url):
|
def __init__(self, url):
|
||||||
|
self.baseUrl = None
|
||||||
|
self.user = None
|
||||||
|
self.repo = None
|
||||||
|
|
||||||
# Rewrite path
|
# Rewrite path
|
||||||
import re
|
import re
|
||||||
m = re.search("^\/([^\/]+)\/([^\/]+)\/?$", url.path)
|
m = re.search("^\/([^\/]+)\/([^\/]+)\/?$", url.path)
|
||||||
@@ -51,6 +55,9 @@ class GithubURLMaker:
|
|||||||
def getScreenshotURL(self):
|
def getScreenshotURL(self):
|
||||||
return self.baseUrl + "/screenshot.png"
|
return self.baseUrl + "/screenshot.png"
|
||||||
|
|
||||||
|
def getModConfURL(self):
|
||||||
|
return self.baseUrl + "/mod.conf"
|
||||||
|
|
||||||
def getCommitsURL(self, branch):
|
def getCommitsURL(self, branch):
|
||||||
return "https://api.github.com/repos/{}/{}/commits?sha={}" \
|
return "https://api.github.com/repos/{}/{}/commits?sha={}" \
|
||||||
.format(self.user, self.repo, urllib.parse.quote_plus(branch))
|
.format(self.user, self.repo, urllib.parse.quote_plus(branch))
|
||||||
@@ -339,8 +346,11 @@ def makeVCSReleaseFromGithub(id, branch, release, url):
|
|||||||
raise TaskError("Invalid github repo URL")
|
raise TaskError("Invalid github repo URL")
|
||||||
|
|
||||||
commitsURL = urlmaker.getCommitsURL(branch)
|
commitsURL = urlmaker.getCommitsURL(branch)
|
||||||
contents = urllib.request.urlopen(commitsURL).read().decode("utf-8")
|
try:
|
||||||
commits = json.loads(contents)
|
contents = urllib.request.urlopen(commitsURL).read().decode("utf-8")
|
||||||
|
commits = json.loads(contents)
|
||||||
|
except HTTPError:
|
||||||
|
raise TaskError("Unable to get commits for Github repository. Either the repository or reference doesn't exist.")
|
||||||
|
|
||||||
if len(commits) == 0 or not "sha" in commits[0]:
|
if len(commits) == 0 or not "sha" in commits[0]:
|
||||||
raise TaskError("No commits found")
|
raise TaskError("No commits found")
|
||||||
@@ -349,7 +359,6 @@ def makeVCSReleaseFromGithub(id, branch, release, url):
|
|||||||
release.task_id = None
|
release.task_id = None
|
||||||
release.commit_hash = commits[0]["sha"]
|
release.commit_hash = commits[0]["sha"]
|
||||||
release.approve(release.package.author)
|
release.approve(release.package.author)
|
||||||
print(release.url)
|
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
return release.url
|
return release.url
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ def doFileUpload(file, fileType, fileTypeDesc):
|
|||||||
if fileType == "image":
|
if fileType == "image":
|
||||||
allowedExtensions = ["jpg", "jpeg", "png"]
|
allowedExtensions = ["jpg", "jpeg", "png"]
|
||||||
isImage = True
|
isImage = True
|
||||||
elif filetype == "zip":
|
elif fileType == "zip":
|
||||||
allowedExtensions = ["zip"]
|
allowedExtensions = ["zip"]
|
||||||
else:
|
else:
|
||||||
raise Exception("Invalid fileType")
|
raise Exception("Invalid fileType")
|
||||||
|
|||||||
@@ -12,7 +12,8 @@ GitHub-Flask~=3.2
|
|||||||
SQLAlchemy-Searchable==1.0.3
|
SQLAlchemy-Searchable==1.0.3
|
||||||
|
|
||||||
beautifulsoup4~=4.6
|
beautifulsoup4~=4.6
|
||||||
celery~=4.2
|
celery==4.1.1
|
||||||
|
kombu==4.2.0
|
||||||
GitPython~=2.1
|
GitPython~=2.1
|
||||||
lxml~=4.2
|
lxml~=4.2
|
||||||
pillow~=5.3
|
pillow~=5.3
|
||||||
|
|||||||
Reference in New Issue
Block a user