Version 6.1.4.1, tag libreoffice-6.1.4.1
[LibreOffice.git] / bin / update / upload_build_config.py
blob9a87661eee731aca52959f3b63c2b875e966f97c
1 #! /usr/bin/env python3
3 import sys
4 import os
5 import configparser
6 import requests
8 dir_path = os.path.dirname(os.path.realpath(__file__))
10 def main(argv):
12 updater_config = sys.argv[2]
14 config = configparser.ConfigParser()
15 config.read(os.path.expanduser(updater_config))
17 user = config["Updater"]["User"]
18 password = config["Updater"]["Password"]
19 base_address = config["Updater"]["ServerURL"]
21 login_url = base_address + "accounts/login/"
23 session = requests.session()
24 r1 = session.get(login_url)
25 csrftoken = session.cookies['csrftoken']
27 login_data = { 'username': user,'password': password,
28 'csrfmiddlewaretoken': csrftoken }
29 r1 = session.post(login_url, data=login_data, headers={"Referer": login_url})
31 url = base_address + "update/upload/release"
32 data = {}
33 data['csrfmiddlewaretoken'] = csrftoken
35 build_config = os.path.join(sys.argv[1], "build_config.json")
36 r = session.post(url, files={'release_config': open(build_config, "r")}, data=data)
37 print(r.content)
38 if r.status_code != 200:
39 sys.exit(1)
41 if __name__ == "__main__":
42 main(sys.argv)