Merge remote-tracking branch 'origin/master'

This commit is contained in:
sregnery 2019-02-18 16:09:53 +01:00
commit 52892a2346
4 changed files with 123 additions and 70 deletions

View File

@ -1,11 +1,11 @@
{ {
arc_dps_buildtemplates: { "arc_dps": {
download_path: "https://www.deltaconnected.com/arcdps/x64/buildtemplates/d3d9_arcdps_buildtemplates.dll" "download_path": "https://www.deltaconnected.com/arcdps/x64/d3d9.dll",
}, "md5path": "https://www.deltaconnected.com/arcdps/x64/d3d9.dll.md5sum",
arc_dps: { "current_version": "13ebe41cf5592c7096a0c8d1b36ded35"
current_version: "2b1dc4e1436ed6ffa55cc15f9351239a", },
md5path: "https://www.deltaconnected.com/arcdps/x64/d3d9.dll.md5sum", "guildwars2_path": "C:\\Program Files\\Guild Wars 2",
download_path: "https://www.deltaconnected.com/arcdps/x64/d3d9.dll" "arc_dps_buildtemplates": {
}, "download_path": "https://www.deltaconnected.com/arcdps/x64/buildtemplates/d3d9_arcdps_buildtemplates.dll"
guildwars2_path: "F:\Games\Guild Wars 2" }
} }

View File

@ -1,61 +0,0 @@
import shutil
import json
import os
import requests
import urllib3
import urllib2
import ssl
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
with open("config.json", mode="r") as config_file:
config = json.load(config_file)
def get_md5sum(md5_url):
r = requests.get(md5_url, verify=False, stream=True)
return str(r.text.split(" ")[0])
def download_file(url):
ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
file_name = url.split('/')[-1]
u = urllib2.urlopen(url, context=ctx)
f = open(file_name, 'wb')
meta = u.info()
file_size = int(meta.getheaders("Content-Length")[0])
print "Downloading: %s Bytes: %s" % (file_name, file_size)
file_size_dl = 0
block_sz = 8192
while True:
file_buffer = u.read(block_sz)
if not file_buffer:
break
file_size_dl += len(file_buffer)
f.write(file_buffer)
status = r"%10d [%3.2f%%]" % (file_size_dl, file_size_dl * 100. / file_size)
status += chr(8) * (len(status) + 1)
print status,
f.close()
online_version = get_md5sum(config["arc_dps"]["md5path"])
arc_dps_url = config["arc_dps"]["download_path"]
buildtemplates_url = config["arc_dps_buildtemplates"]["download_path"]
if config["arc_dps"]["current_version"] != online_version:
arc_dps_file_name = arc_dps_url.rsplit('/', 1)[-1]
buildtemplates_file_name = buildtemplates_url.rsplit('/', 1)[-1]
download_file(arc_dps_url)
download_file(buildtemplates_url)
shutil.move(arc_dps_file_name, os.path.join(config["guildwars2_path"], "bin64", arc_dps_file_name))
shutil.move(buildtemplates_file_name, os.path.join(config["guildwars2_path"], "bin64", buildtemplates_file_name))
config["arc_dps"]["current_version"] = online_version
with open("config.json", mode="w") as config_file:
config_file = (json.dump(config, config_file, indent=2))

View File

@ -0,0 +1,65 @@
import shutil
import json
import os
import requests
import urllib3
from urllib import request
import ssl
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
with open("config.json", mode="r") as config_file:
config = json.load(config_file)
def get_md5sum(md5_url):
r = requests.get(md5_url, verify=False, stream=True)
return str(r.text.split(" ")[0])
def download_file(url):
ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
file_name = url.split('/')[-1]
u = request.urlopen(url)
f = open(file_name, 'wb')
file_size = int(u.getheader("Content-Length"))
print("Downloading: %s Bytes: %s" % (file_name, file_size))
file_size_dl = 0
block_sz = 8192
while True:
file_buffer = u.read(block_sz)
if not file_buffer:
break
file_size_dl += len(file_buffer)
f.write(file_buffer)
f.close()
def main():
global config_file
online_version = get_md5sum(config["arc_dps"]["md5path"])
arc_dps_url = config["arc_dps"]["download_path"]
buildtemplates_url = config["arc_dps_buildtemplates"]["download_path"]
if config["arc_dps"]["current_version"] != online_version:
arc_dps_file_name = arc_dps_url.rsplit('/', 1)[-1]
buildtemplates_file_name = buildtemplates_url.rsplit('/', 1)[-1]
download_file(arc_dps_url)
download_file(buildtemplates_url)
shutil.move(arc_dps_file_name, os.path.join(config["guildwars2_path"], "bin64", arc_dps_file_name))
shutil.move(buildtemplates_file_name,
os.path.join(config["guildwars2_path"], "bin64", buildtemplates_file_name))
config["arc_dps"]["current_version"] = online_version
with open("config.json", mode="w") as config_file:
config_file = (json.dump(config, config_file, indent=2))
if __name__ == "__main__":
main()

View File

@ -0,0 +1,49 @@
#!/usr/bin/env python
import textwrap
import requests
from flask import Flask, Response, request
app = Flask(__name__)
USER_TOKEN = ''
def get_uploads(user_token, page=1):
return requests.get("https://dps.report/getUploads?userToken={}&page={}".format(user_token, page)).json()
@app.route("/")
def fetch_and_display_my_reports():
if request.args.get('page', ''):
uploads = get_uploads(USER_TOKEN, request.args.get('page', ''))
else:
uploads = get_uploads(USER_TOKEN)
# print(uploads)
upload_links_html = ""
for upload in uploads['uploads']:
upload_links_html += ' <a href="{url}">{url}</a><br>\n'.format(url=upload['permalink'])
older_reports = "<br>Older reports: "
if uploads['pages'] > 1:
for i in range(uploads['pages']):
if request.args.get('page', '') == str(i+1):
older_reports += ' <a href="?page={page_number}"><b>{page_number}</b></a> '.format(page_number=i+1)
else:
older_reports += ' <a href="?page={page_number}">{page_number}</a> '.format(page_number=i+1)
else:
older_reports = ""
response_text = textwrap.dedent('''\
<!DOCTYPE html>
<html>
<head>
<title>lennys dps reports</title>
</head>
<body>
{upload_links}{older_reports}
</body>
</html>'''.format(upload_links=upload_links_html, older_reports=older_reports))
return Response(response_text, mimetype='text/html')
def start():
app = Flask(__name__)