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/.
10 import platform
, configparser
12 def detect_platform():
13 return platform
.system()
18 print("Invalid number of parameters")
19 print("Usage: upload-symbols.py symbols.zip config.ini \"long explanation\" [--system]")
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":
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__":
55 # vim: set shiftwidth=4 softtabstop=4 expandtab: