Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
VILLAScontroller
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container registry
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ACS
Public
VILLASframework
VILLAScontroller
Commits
fc401a9c
Commit
fc401a9c
authored
6 years ago
by
Steffen Vogel
Browse files
Options
Downloads
Patches
Plain Diff
fix handling of broker setting in user config
parent
2f4caf87
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bin/villas-ctl
+21
-4
21 additions, 4 deletions
bin/villas-ctl
with
21 additions
and
4 deletions
bin/villas-ctl
+
21
−
4
View file @
fc401a9c
...
...
@@ -3,6 +3,7 @@
import
logging
import
argparse
import
kombu
import
socket
from
villas.controller.config
import
Config
,
ConfigType
from
villas.controller.command
import
Command
...
...
@@ -46,8 +47,7 @@ def setup_argparse():
)
parser
.
add_argument
(
'
-b
'
,
'
--broker
'
,
help
=
'
URL of AMQP broker
'
,
default
=
"
amqp://guest:guest@localhost/%2F
"
help
=
'
URL of AMQP broker
'
)
parser
.
add_argument
(
'
-c
'
,
'
--config
'
,
...
...
@@ -56,7 +56,7 @@ def setup_argparse():
default
=
Config
()
)
parser
.
add_argument
(
'
--log-level
'
,
parser
.
add_argument
(
'
-d
'
,
'
--log-level
'
,
default
=
'
INFO
'
,
dest
=
'
log_level
'
,
type
=
_log_level_string_to_int
,
...
...
@@ -75,8 +75,25 @@ if __name__ == '__main__':
setup_logging
(
args
)
with
kombu
.
Connection
(
args
.
broker
)
as
c
:
if
args
.
broker
is
not
None
:
broker
=
args
.
broker
elif
'
broker
'
in
args
.
config
.
json
and
'
url
'
in
args
.
config
.
json
[
'
broker
'
]:
broker
=
args
.
config
.
json
[
'
broker
'
][
'
url
'
]
else
:
broker
=
'
amqp://guest:guest@localhost/%2F
'
LOGGER
.
info
(
'
Connecting to: %s
'
%
broker
)
with
kombu
.
Connection
(
broker
,
connect_timeout
=
3
)
as
c
:
try
:
c
.
connect
()
if
c
.
connected
:
LOGGER
.
info
(
'
Connection established!
'
)
args
.
func
(
c
,
args
)
except
ConnectionRefusedError
:
LOGGER
.
error
(
"
Connection refused!
"
)
except
socket
.
timeout
:
LOGGER
.
error
(
"
Connection timeout!
"
)
except
KeyboardInterrupt
:
LOGGER
.
info
(
"
Ctrl-C... Abort
"
)
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