Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
938b4f81
Commit
938b4f81
authored
Aug 08, 2014
by
David Baumgold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle Validation Failed for release script
parent
2a9c9ee7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
1 deletions
+49
-1
scripts/release.py
+49
-1
No files found.
scripts/release.py
View file @
938b4f81
...
...
@@ -149,10 +149,58 @@ def create_github_creds():
headers
=
headers
,
data
=
json
.
dumps
(
payload
),
)
if
not
response
.
ok
:
raise
requests
.
exceptions
.
RequestException
(
response
.
json
()[
"message"
])
message
=
response
.
json
()[
"message"
]
if
message
!=
"Validation Failed"
:
raise
requests
.
exceptions
.
RequestException
(
message
)
else
:
# A token called "edx-release" already exists on Github.
# Delete it, and try again.
token_id
=
get_github_auth_id
(
username
,
password
,
"edx-release"
)
if
token_id
:
delete_github_auth_token
(
username
,
password
,
token_id
)
response
=
requests
.
post
(
"https://api.github.com/authorizations"
,
auth
=
(
username
,
password
),
headers
=
headers
,
data
=
json
.
dumps
(
payload
),
)
if
not
response
.
ok
:
message
=
response
.
json
()[
"message"
]
raise
requests
.
exceptions
.
RequestException
(
message
)
return
(
username
,
response
.
json
()[
"token"
])
def
get_github_auth_id
(
username
,
password
,
note
):
"""
Return the ID associated with the Github auth token with the given note.
If no such auth token exists, return None.
"""
response
=
requests
.
get
(
"https://api.github.com/authorizations"
,
auth
=
(
username
,
password
),
headers
=
{
"User-Agent"
:
"edx-release"
},
)
if
not
response
.
ok
:
message
=
response
.
json
()[
"message"
]
raise
requests
.
exceptions
.
RequestException
(
message
)
for
auth_token
in
response
.
json
():
if
auth_token
[
"note"
]
==
"edx-release"
:
return
auth_token
[
"id"
]
return
None
def
delete_github_auth_token
(
username
,
password
,
token_id
):
response
=
requests
.
delete
(
"https://api.github.com/authorizations/{id}"
.
format
(
id
=
token_id
),
auth
=
(
username
,
password
),
headers
=
{
"User-Agent"
:
"edx-release"
},
)
if
not
response
.
ok
:
message
=
response
.
json
()[
"message"
]
raise
requests
.
exceptions
.
RequestException
(
message
)
def
ensure_github_creds
(
attempts
=
3
):
"""
Make sure that we have Github OAuth credentials. This will check the user's
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment