diff --git a/misc/madupload.py b/misc/madupload.py index 8c4b4c64..d68a6cd6 100755 --- a/misc/madupload.py +++ b/misc/madupload.py @@ -38,7 +38,7 @@ raise SystemExit( "Usage: {} \n" "Uploads 'filename' to Maddavo's site, where filename should be " - "a .prices or Station.csv file.\n" + "a .prices, Station.csv or ShipVendor.csv file.\n" "\n" "NOTE to OCR USERS:\n" "Please upload the .prices file from your OCR DIRECTLY before " @@ -46,22 +46,24 @@ ) upfile = sys.argv[1] +uppath = pathlib.Path(upfile) ############################################################################ - -if not pathlib.Path(upfile).is_file(): - raise SystemExit("ERROR: File not found: {}".format(upfile)) +if not uppath.exists(): + raise SystemExit("ERROR: {}: File not found".format(upfile)) +if not uppath.is_file(): + raise SystemExit("ERROR: {}: Not a file".format(upfile)) r = requests.post( upload_url, files={ 'Filename': ( - upfile, - open(upfile, 'rb'), + uppath.name, + uppath.open("rb"), 'text/plain', { - "Expires": '300', + "Expires": '90', } ), } @@ -76,5 +78,7 @@ if resultCode.startswith("SUCCESS"): raise SystemExit("Upload complete") -print("Upload failed: {}".format(resultCode)) - +print("Error response from Maddavo's site: {}".format(resultCode)) +with open("tmp/maderror.txt", "w") as out: + print(r.text, file=out) + print("See tmp/maderror.txt for full response.") \ No newline at end of file