fix
This commit is contained in:
parent
52892a2346
commit
e22941d335
|
|
@ -26,7 +26,8 @@ def download_file(url):
|
|||
file_name = url.split('/')[-1]
|
||||
u = request.urlopen(url)
|
||||
f = open(file_name, 'wb')
|
||||
file_size = int(u.getheader("Content-Length"))
|
||||
file_size = u.getheader("Content-Length")
|
||||
print(file_size)
|
||||
print("Downloading: %s Bytes: %s" % (file_name, file_size))
|
||||
|
||||
file_size_dl = 0
|
||||
|
|
@ -46,15 +47,10 @@ 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:
|
||||
|
|
|
|||
|
|
@ -1,13 +1,17 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
import time
|
||||
import requests
|
||||
import argparse
|
||||
|
||||
from pathlib import Path
|
||||
from oslo_concurrency import lockutils
|
||||
from watchdog.observers import Observer
|
||||
from watchdog.events import PatternMatchingEventHandler
|
||||
|
||||
lockutils.set_defaults(os.path.abspath(os.path.dirname(__file__)))
|
||||
|
||||
|
||||
class FileWatchdog(PatternMatchingEventHandler):
|
||||
def __init__(self, file_pattern, user_token):
|
||||
|
|
@ -25,7 +29,9 @@ class FileWatchdog(PatternMatchingEventHandler):
|
|||
print(a.json())
|
||||
|
||||
|
||||
@lockutils.synchronized('dps.report_uploader', external=True)
|
||||
def main():
|
||||
print('start initiated')
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('user_token', action='store')
|
||||
args = parser.parse_args()
|
||||
|
|
@ -37,7 +43,7 @@ def main():
|
|||
observer = Observer()
|
||||
observer.schedule(FileWatchdog(file_pattern, args.user_token), watch_path, recursive=True)
|
||||
observer.start()
|
||||
|
||||
print('started observing')
|
||||
while True:
|
||||
time.sleep(1)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user