Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
beat.web
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
beat
beat.web
Commits
885320af
Commit
885320af
authored
9 years ago
by
André Anjos
Browse files
Options
Downloads
Patches
Plain Diff
[utils] Remove outdated scheduler communication bridge
parent
f3a4582c
No related branches found
No related tags found
1 merge request
!194
Scheduler
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
beat/web/utils/scheduler.py
+0
-153
0 additions, 153 deletions
beat/web/utils/scheduler.py
with
0 additions
and
153 deletions
beat/web/utils/scheduler.py
deleted
100644 → 0
+
0
−
153
View file @
f3a4582c
#!/usr/bin/env python
# vim: set fileencoding=utf-8 :
###############################################################################
# #
# Copyright (c) 2016 Idiap Research Institute, http://www.idiap.ch/ #
# Contact: beat.support@idiap.ch #
# #
# This file is part of the beat.web module of the BEAT platform. #
# #
# Commercial License Usage #
# Licensees holding valid commercial BEAT licenses may use this file in #
# accordance with the terms contained in a written agreement between you #
# and Idiap. For further information contact tto@idiap.ch #
# #
# Alternatively, this file may be used under the terms of the GNU Affero #
# Public License version 3 as published by the Free Software and appearing #
# in the file LICENSE.AGPL included in the packaging of this file. #
# The BEAT platform is distributed in the hope that it will be useful, but #
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY #
# or FITNESS FOR A PARTICULAR PURPOSE. #
# #
# You should have received a copy of the GNU Affero Public License along #
# with the BEAT platform. If not, see http://www.gnu.org/licenses/. #
# #
###############################################################################
from
django.conf
import
settings
import
httplib
import
logging
import
traceback
import
urlparse
import
urllib
import
simplejson
as
json
logger
=
logging
.
getLogger
(
__name__
)
#----------------------------------------------------------
def
_connect
(
url
,
port
):
parsed_url
=
urlparse
.
urlparse
(
url
)
host_and_port
=
parsed_url
.
netloc
.
split
(
'
:
'
)
if
port
is
None
:
if
len
(
host_and_port
)
==
2
:
host
,
port
=
host_and_port
else
:
host
=
host_and_port
if
parsed_url
.
scheme
==
'
https
'
:
port
=
443
else
:
port
=
80
else
:
host
=
host_and_port
[
0
]
if
parsed_url
.
scheme
==
'
https
'
:
connection
=
httplib
.
HTTPSConnection
(
host
,
port
)
else
:
connection
=
httplib
.
HTTPConnection
(
host
,
port
)
try
:
connection
.
connect
()
except
:
logger
.
error
(
'
Failed to establish a connection with the scheduler API, reason: %s
'
%
traceback
.
format_exc
())
return
None
return
connection
#----------------------------------------------------------
def
_combine_url_parameters
(
url
,
params
):
"""
Combines the given URL with the parameter dictionary
"""
parsed_url
=
urlparse
.
urlparse
(
url
)
qs
=
[]
if
parsed_url
.
query
:
qs
.
extend
([
parsed_url
.
query
,
'
&
'
])
qs
.
append
(
urllib
.
urlencode
(
params
,
doseq
=
True
))
return
urlparse
.
urlunparse
((
parsed_url
[
0
],
parsed_url
[
1
],
parsed_url
[
2
],
parsed_url
[
3
],
''
.
join
(
qs
),
parsed_url
[
5
]
))
#----------------------------------------------------------
def
_sendMessage
(
url
,
params
=
None
,
data
=
None
,
msg_type
=
'
PUT
'
):
# Establish the connection
connection
=
_connect
(
settings
.
SCHEDULER_ADDRESS
,
settings
.
SCHEDULER_PORT
)
if
connection
is
None
:
return
None
# Send the request
headers
=
{}
if
data
is
not
None
:
data
=
json
.
dumps
(
data
)
headers
[
'
Content-Type
'
]
=
'
application/json
'
else
:
headers
[
'
Content-Length
'
]
=
0
try
:
if
params
:
full_url
=
_combine_url_parameters
(
url
,
params
)
else
:
full_url
=
url
connection
.
request
(
msg_type
,
full_url
,
data
,
headers
)
response
=
connection
.
getresponse
()
data
=
response
.
read
()
except
:
logger
.
error
(
'
Failed to use the Web API, reason: %s
'
%
traceback
.
format_exc
())
return
None
finally
:
connection
.
close
()
return
(
response
.
status
,
data
)
#----------------------------------------------------------
def
putMessage
(
url
,
params
=
None
,
data
=
None
):
return
_sendMessage
(
url
,
params
=
params
,
data
=
data
,
msg_type
=
'
PUT
'
)
#----------------------------------------------------------
def
postMessage
(
url
,
params
=
None
,
data
=
None
):
return
_sendMessage
(
url
,
params
=
params
,
data
=
data
,
msg_type
=
'
POST
'
)
#----------------------------------------------------------
def
getMessage
(
url
,
params
=
None
,
data
=
None
):
return
_sendMessage
(
url
,
params
=
params
,
data
=
data
,
msg_type
=
'
GET
'
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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