1 #! /usr/bin/env python3
8 dir_path
= os
.path
.dirname(os
.path
.realpath(__file__
))
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"
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
)
38 if r
.status_code
!= 200:
41 if __name__
== "__main__":