revert unittests to use plain text-based LibreOfficeKitCallback
[LibreOffice.git] / bin / upload_symbols.py
blob277508da712ef7e927742c05aab5a3dce8f41b78
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 requests, sys
10 import platform, configparser
12 def detect_platform():
13 return platform.system()
15 def main():
16 if len(sys.argv) < 4:
17 print(sys.argv)
18 print("Invalid number of parameters")
19 print("Usage: upload-symbols.py symbols.zip config.ini \"long explanation\" [--system]")
20 sys.exit(1)
22 base_url = "https://crashreport.libreoffice.org/"
23 upload_url = base_url + "upload/"
24 login_url = base_url + "accounts/login/"
26 config = configparser.ConfigParser()
27 config.read(sys.argv[2])
29 user = config["CrashReport"]["User"]
30 password = config["CrashReport"]["Password"]
32 platform = detect_platform()
33 files = {'symbols': open(sys.argv[1], 'rb')}
34 data = {'version': sys.argv[3], 'platform': platform}
36 if len(sys.argv) > 4 and sys.argv[4] == "--system":
37 data['system'] = True
39 session = requests.session()
40 session.get(login_url)
41 csrftoken = session.cookies['csrftoken']
43 login_data = { 'username': user,'password': password,
44 'csrfmiddlewaretoken': csrftoken }
45 headers = { "Referer": base_url }
46 r1 = session.post(login_url, headers=headers, data=login_data)
48 data['csrfmiddlewaretoken'] = csrftoken
50 r = session.post(upload_url, headers=headers, files=files, data=data)
52 if __name__ == "__main__":
53 main()
55 # vim: set shiftwidth=4 softtabstop=4 expandtab: