diff options
author | Anton Yuzhaninov <citrin+git@citrin.ru> | 2018-10-22 22:19:29 -0400 |
---|---|---|
committer | Anton Yuzhaninov <citrin+git@citrin.ru> | 2018-10-22 22:56:05 -0400 |
commit | b3826709eca5a7cda0a61e4ae87c34cd2f3fb8d4 (patch) | |
tree | be6bc169d67c56c44223fdaa351271e1c3795a93 /test | |
parent | a9ea9d8bcd0092abafb3b967951fef5c493c0d7d (diff) | |
download | rspamd-b3826709eca5a7cda0a61e4ae87c34cd2f3fb8d4.tar.gz rspamd-b3826709eca5a7cda0a61e4ae87c34cd2f3fb8d4.zip |
Share robot log and report on https://ci.rspamd.com/testlogs/
Sending functional test log (about 5Mb) in a email attachmend was temporary
solution.
Upload them to https://ci.rspamd.com/testlogs/ instead.
Link to log/report will be printed in build log.
Diffstat (limited to 'test')
-rwxr-xr-x | test/tools/http_put.py | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/test/tools/http_put.py b/test/tools/http_put.py new file mode 100755 index 000000000..dab9a2150 --- /dev/null +++ b/test/tools/http_put.py @@ -0,0 +1,51 @@ +#!/usr/bin/env python3 +""" +Small script to upload file using HTTP PUT +""" + +import argparse +import os +import sys + +import requests + + +def main(): + parser = argparse.ArgumentParser( + description='Upload a file usgin HTTP PUT method', + epilog=( + "To use HTTP Auth set HTTP_PUT_AUTH environment variable to user:password\n" + "Example: %(prog)s file1 file2 https://example.com/dir/")) + parser.add_argument( + "file", type=argparse.FileType('rb'), nargs='+', help="File to upload") + parser.add_argument( + "dir_url", help="Remote URL (path to a directory, must ends with /)") + args = parser.parse_args() + + if not args.dir_url.endswith('/'): + parser.error("URL must ends with /") + + http_auth = os.getenv('HTTP_PUT_AUTH') + if http_auth: + user, password = http_auth.split(':') + auth = (user, password) + else: + auth = None + + exit_code = 0 + + for fh in args.file: + try: + r = requests.put(args.dir_url + fh.name, data=fh, auth=auth, timeout=(45, 90)) + r.raise_for_status() + print("{} uploaded to {}".format(fh.name, r.url)) + except (requests.exceptions.ConnectionError, + requests.exceptions.HTTPError) as err: + print(err, file=sys.stderr) + exit_code = 1 + + return exit_code + + +if __name__ == '__main__': + sys.exit(main()) |