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/.
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.collaboraoffice.com/"
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 session
.post(upload_url
, headers
=headers
, files
=files
, data
=data
)
54 if __name__
== "__main__":
57 # vim: set shiftwidth=4 softtabstop=4 expandtab: