Fix typelib_TypeDescriptionReference -> typelib_TypeDescription conversion
[LibreOffice.git] / bin / upload_symbols.py
blobf0ae2dcf3ca35b5800757b3944291e201d37197c
1 #!/usr/bin/env python3
2 # -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
4 # This Source Code Form is subject to the terms of the Mozilla Public
5 # License, v. 2.0. If a copy of the MPL was not distributed with this
6 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 import configparser
10 import platform
11 import argparse
12 import requests
15 def main():
16 parser = argparse.ArgumentParser()
17 parser.add_argument('symbols_zip_file')
18 parser.add_argument('credentials_file')
19 parser.add_argument('version')
20 group = parser.add_mutually_exclusive_group()
21 group.add_argument('--system', action='store_true')
22 group.add_argument('--platform', choices=('Windows', 'Linux'))
23 args = parser.parse_args()
25 base_url = "https://crashreport.libreoffice.org/"
26 upload_url = base_url + "upload/"
27 login_url = base_url + "accounts/login/"
29 config = configparser.ConfigParser()
30 config.read(args.credentials_file)
32 user = config["CrashReport"]["User"]
33 password = config["CrashReport"]["Password"]
35 files = {'symbols': open(args.symbols_zip_file, 'rb')}
36 data = {'version': args.version,
37 'system': args.system,
38 'platform': platform.system() if args.platform is None else args.platform}
40 session = requests.session()
41 session.get(login_url)
42 csrftoken = session.cookies['csrftoken']
44 login_data = {'username': user, 'password': password,
45 'csrfmiddlewaretoken': csrftoken}
46 headers = {"Referer": base_url}
47 session.post(login_url, headers=headers, data=login_data)
49 data['csrfmiddlewaretoken'] = csrftoken
51 response = session.post(upload_url, headers=headers, files=files, data=data)
52 if response.ok:
53 print("Symbols uploaded successfully")
54 else:
55 print(response.text)
58 if __name__ == "__main__":
59 main()
61 # vim: set shiftwidth=4 softtabstop=4 expandtab: