diff --git a/build.py b/build.py index ab1194d627b4dd308ea7dfc4b7826baf512600c9..2edb7dba3ed48f5e645c6835a951b460cb6e9a67 100755 --- a/build.py +++ b/build.py @@ -3,20 +3,38 @@ import os import sys import requests -os.system('hugo --enableGitInfo --cleanDestinationDir') +def checkAtom(file): -exit = 0 -url = 'https://validator.w3.org/feed/check.cgi' -payload = {'url': 'https://briarproject.org/index.xml'} + url = 'https://validator.w3.org/feed/check.cgi' -r = requests.get(url, params=payload) + with open(file,'r') as index_file: + index_lines = index_file.read().replace('\n','') -if "This is a valid Atom 1.0 feed" not in r.content: - print "ATOM feed is not valid." - exit = 1 -else: - print "-- This is a valid Atom 1.0 feed -- %s" % payload.get('url') + payload = { 'rawdata': index_lines } -#print r.content + r = requests.post(url, data=payload) -sys.exit(exit) + if "This is a valid Atom 1.0 feed" in r.content: + return "checkAtom: " + file + " is valid" + else: + return "checkAtom: " + file + " is NOT valid" + +def checkHtml(file): + + url = 'https://validator.w3.org/nu/' + + files = {'file': open(file,'rb')} + + r = requests.post(url, files=files) + + if "The document validates" in r.content: + return "checkHtml: " + file + " is valid" + else: + return "checkHtml: " + file + " is NOT valid" + +if __name__ == "__main__": + os.system('hugo --enableGitInfo --cleanDestinationDir') + atom = checkAtom('public/index.xml') + print atom + html = checkHtml('public/index.html') + print html