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 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":
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__":
53 # vim: set shiftwidth=4 softtabstop=4 expandtab: