loplugin:constmethod in editeng
[LibreOffice.git] / bin / upload_symbols.py
blob72a03b6e56db166059c080599a6ad2bf181c1e38
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 upload_url = "http://crashreport.libreoffice.org/upload/"
23 login_url = "http://crashreport.libreoffice.org/accounts/login/"
25 config = configparser.ConfigParser()
26 config.read(sys.argv[2])
28 user = config["CrashReport"]["User"]
29 password = config["CrashReport"]["Password"]
31 platform = detect_platform()
32 files = {'symbols': open(sys.argv[1], 'rb')}
33 data = {'version': sys.argv[3], 'platform': platform}
35 if len(sys.argv) > 4 and sys.argv[4] == "--system":
36 data['system'] = True
38 session = requests.session()
39 session.get(login_url)
40 csrftoken = session.cookies['csrftoken']
42 login_data = { 'username': user,'password': password,
43 'csrfmiddlewaretoken': csrftoken }
44 r1 = session.post(login_url,data=login_data)
46 data['csrfmiddlewaretoken'] = csrftoken
48 r = session.post(upload_url, files = files, data = data)
50 if __name__ == "__main__":
51 main()
53 # vim: set shiftwidth=4 softtabstop=4 expandtab: