Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
inau
Manage
Activity
Members
Labels
Plan
Issues
5
Issue boards
Milestones
Wiki
Code
Merge requests
2
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cs
util
inau
Commits
6e597e85
Commit
6e597e85
authored
4 years ago
by
Alessio Igor Bogani
Browse files
Options
Downloads
Patches
Plain Diff
Use HTTPStatus' enum for HTTP status codes
parent
b9b362cc
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
inau-dispatcher.py
+6
-5
6 additions, 5 deletions
inau-dispatcher.py
with
6 additions
and
5 deletions
inau-dispatcher.py
+
6
−
5
View file @
6e597e85
#!/usr/bin/env python3
from
http.server
import
BaseHTTPRequestHandler
,
HTTPServer
from
http
import
HTTPStatus
from
sqlalchemy
import
create_engine
from
sqlalchemy.orm
import
sessionmaker
,
exc
from
multiprocessing
import
Process
,
Queue
...
...
@@ -291,7 +292,7 @@ class Server(BaseHTTPRequestHandler):
post_data
=
self
.
rfile
.
read
(
content_length
)
if
self
.
headers
[
'
Content-Type
'
]
!=
'
application/json
'
:
self
.
send_response
(
415
)
self
.
send_response
(
HTTPStatus
.
UNSUPPORTED_MEDIA_TYPE
.
value
)
self
.
end_headers
()
return
...
...
@@ -300,13 +301,13 @@ class Server(BaseHTTPRequestHandler):
# Tag deletion
if
post_json
[
'
after
'
]
==
'
0000000000000000000000000000000000000000
'
:
self
.
send_response
(
200
)
self
.
send_response
(
HTTPStatus
.
OK
.
value
)
self
.
end_headers
()
return
# Check if the tag is lightweight
if
post_json
[
'
after
'
]
==
post_json
[
'
commits
'
][
0
][
'
id
'
]:
self
.
send_response
(
200
)
self
.
send_response
(
HTTPStatus
.
OK
.
value
)
self
.
end_headers
()
return
...
...
@@ -328,14 +329,14 @@ class Server(BaseHTTPRequestHandler):
# req = requests.post('https://gitlab.elettra.eu/api/v4/projects/' + urllib.parse.quote(rn, safe='')
# + '/protected_tags?name=' + post_json['ref'] + '&create_access_level=40')
self
.
send_response
(
200
)
self
.
send_response
(
HTTPStatus
.
OK
.
value
)
self
.
end_headers
()
except
Exception
as
e
:
sendEmailAdmins
(
"
Receive new tag failed
"
,
str
(
e
))
logger
.
error
(
"
Receive new tag failed:
"
,
str
(
e
))
session
.
rollback
()
self
.
send_response
(
500
)
self
.
send_response
(
HTTPStatus
.
INTERNAL_SERVER_ERROR
.
value
)
self
.
end_headers
()
finally
:
session
.
close
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment