Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
agkyra
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
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
itminedu
agkyra
Commits
c834374e
Commit
c834374e
authored
9 years ago
by
Stavros Sachtouris
Committed by
Giorgos Korfiatis
9 years ago
Browse files
Options
Downloads
Patches
Plain Diff
CLI: Warn users when settings updates need restart
parent
20d65323
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
agkyra/cli.py
+35
-15
35 additions, 15 deletions
agkyra/cli.py
with
35 additions
and
15 deletions
agkyra/cli.py
+
35
−
15
View file @
c834374e
...
@@ -105,11 +105,13 @@ class ConfigCommands(object):
...
@@ -105,11 +105,13 @@ class ConfigCommands(object):
assert
section
==
'
global
'
,
'
section %s should be global
"'
%
section
assert
section
==
'
global
'
,
'
section %s should be global
"'
%
section
self
.
cnf
.
set
(
section
,
option
,
value
)
self
.
cnf
.
set
(
section
,
option
,
value
)
self
.
cnf
.
write
()
self
.
cnf
.
write
()
return
True
def
set_setting
(
self
,
section
,
name
,
option
,
value
):
def
set_setting
(
self
,
section
,
name
,
option
,
value
):
self
.
_validate_section
(
section
)
self
.
_validate_section
(
section
)
self
.
cnf
.
set
(
'
%s.%s
'
%
(
section
,
name
),
option
,
value
)
self
.
cnf
.
set
(
'
%s.%s
'
%
(
section
,
name
),
option
,
value
)
self
.
cnf
.
write
()
self
.
cnf
.
write
()
return
True
def
delete_global_option
(
self
,
section
,
option
,
yes
=
False
):
def
delete_global_option
(
self
,
section
,
option
,
yes
=
False
):
"""
Delete global option
"""
"""
Delete global option
"""
...
@@ -119,9 +121,10 @@ class ConfigCommands(object):
...
@@ -119,9 +121,10 @@ class ConfigCommands(object):
if
(
not
yes
and
'
y
'
!=
raw_input
(
if
(
not
yes
and
'
y
'
!=
raw_input
(
'
Delete %s option %s? [y|N]:
'
%
(
section
,
option
))):
'
Delete %s option %s? [y|N]:
'
%
(
section
,
option
))):
sys
.
stderr
.
write
(
'
Aborted
\n
'
)
sys
.
stderr
.
write
(
'
Aborted
\n
'
)
else
:
return
False
self
.
cnf
.
remove_option
(
section
,
option
)
self
.
cnf
.
remove_option
(
section
,
option
)
self
.
cnf
.
write
()
self
.
cnf
.
write
()
return
True
def
delete_section_option
(
self
,
section
,
name
,
option
,
yes
=
False
):
def
delete_section_option
(
self
,
section
,
name
,
option
,
yes
=
False
):
"""
Delete a section (sync or cloud) option
"""
"""
Delete a section (sync or cloud) option
"""
...
@@ -131,14 +134,15 @@ class ConfigCommands(object):
...
@@ -131,14 +134,15 @@ class ConfigCommands(object):
if
(
not
yes
and
'
y
'
!=
raw_input
(
if
(
not
yes
and
'
y
'
!=
raw_input
(
'
Delete %s of %s
"
%s
"
? [y|N]:
'
%
(
option
,
section
,
name
))):
'
Delete %s of %s
"
%s
"
? [y|N]:
'
%
(
option
,
section
,
name
))):
sys
.
stderr
.
write
(
'
Aborted
\n
'
)
sys
.
stderr
.
write
(
'
Aborted
\n
'
)
return
False
if
section
==
config
.
CLOUD_PREFIX
:
self
.
cnf
.
remove_from_cloud
(
name
,
option
)
elif
section
==
config
.
SYNC_PREFIX
:
self
.
cnf
.
remove_from_sync
(
name
,
option
)
else
:
else
:
if
section
==
config
.
CLOUD_PREFIX
:
self
.
cnf
.
remove_option
(
'
%s.%s
'
%
(
section
,
name
),
option
)
self
.
cnf
.
remove_from_cloud
(
name
,
option
)
self
.
cnf
.
write
()
elif
section
==
config
.
SYNC_PREFIX
:
return
True
self
.
cnf
.
remove_from_sync
(
name
,
option
)
else
:
self
.
cnf
.
remove_option
(
'
%s.%s
'
%
(
section
,
name
),
option
)
self
.
cnf
.
write
()
def
delete_section
(
self
,
section
,
name
,
yes
=
False
):
def
delete_section
(
self
,
section
,
name
,
yes
=
False
):
"""
Delete a section (sync or cloud)
"""
"""
Delete a section (sync or cloud)
"""
...
@@ -147,9 +151,10 @@ class ConfigCommands(object):
...
@@ -147,9 +151,10 @@ class ConfigCommands(object):
if
(
not
yes
and
'
y
'
!=
raw_input
(
if
(
not
yes
and
'
y
'
!=
raw_input
(
'
Delete %s
"
%s
"
? [y|N]:
'
%
(
section
,
name
))):
'
Delete %s
"
%s
"
? [y|N]:
'
%
(
section
,
name
))):
sys
.
stderr
.
write
(
'
Aborted
\n
'
)
sys
.
stderr
.
write
(
'
Aborted
\n
'
)
else
:
return
False
self
.
cnf
.
remove_option
(
section
,
name
)
self
.
cnf
.
remove_option
(
section
,
name
)
self
.
cnf
.
write
()
self
.
cnf
.
write
()
return
True
from
functools
import
wraps
from
functools
import
wraps
...
@@ -281,6 +286,15 @@ class AgkyraCLI(cmd.Cmd):
...
@@ -281,6 +286,15 @@ class AgkyraCLI(cmd.Cmd):
raise
raise
sys
.
stderr
.
write
(
self
.
config_list
.
__doc__
+
'
\n
'
)
sys
.
stderr
.
write
(
self
.
config_list
.
__doc__
+
'
\n
'
)
def
_warn_user_about_setting_updates
(
self
):
if
self
.
helper
.
load_active_session
():
sys
.
stderr
.
write
(
'
Done
\n
'
'
WARNING: Setting updates will take effect after agkyra is
'
'
shutdown and started again. To do this:
\n
'
'
\t
$ agkyra shutdown
\n\t
$ agkyra start
\n
'
);
sys
.
stderr
.
flush
()
def
config_set
(
self
,
args
):
def
config_set
(
self
,
args
):
"""
Set an option
"""
Set an option
set global OPTION VALUE Set a global option
set global OPTION VALUE Set a global option
...
@@ -288,8 +302,9 @@ class AgkyraCLI(cmd.Cmd):
...
@@ -288,8 +302,9 @@ class AgkyraCLI(cmd.Cmd):
Creates a sync or cloud, if it
Creates a sync or cloud, if it
does not exist
does not exist
"""
"""
r
=
False
try
:
try
:
{
r
=
{
3
:
self
.
cnf_cmds
.
set_global_setting
,
3
:
self
.
cnf_cmds
.
set_global_setting
,
4
:
self
.
cnf_cmds
.
set_setting
4
:
self
.
cnf_cmds
.
set_setting
}[
len
(
args
)](
*
args
)
}[
len
(
args
)](
*
args
)
...
@@ -298,6 +313,8 @@ class AgkyraCLI(cmd.Cmd):
...
@@ -298,6 +313,8 @@ class AgkyraCLI(cmd.Cmd):
if
isinstance
(
e
,
ConfigError
):
if
isinstance
(
e
,
ConfigError
):
raise
raise
sys
.
stderr
.
write
(
self
.
config_set
.
__doc__
+
'
\n
'
)
sys
.
stderr
.
write
(
self
.
config_set
.
__doc__
+
'
\n
'
)
if
r
:
self
.
_warn_user_about_setting_updates
()
def
config_delete
(
self
,
args
):
def
config_delete
(
self
,
args
):
"""
Delete an option
"""
Delete an option
...
@@ -306,8 +323,9 @@ class AgkyraCLI(cmd.Cmd):
...
@@ -306,8 +323,9 @@ class AgkyraCLI(cmd.Cmd):
delete <cloud |sync> NAME OPTION [-y] Delete a sync or cloud option
delete <cloud |sync> NAME OPTION [-y] Delete a sync or cloud option
"""
"""
args
.
append
(
self
.
args
.
yes
)
args
.
append
(
self
.
args
.
yes
)
r
=
False
try
:
try
:
{
r
=
{
3
:
self
.
cnf_cmds
.
delete_global_option
if
(
3
:
self
.
cnf_cmds
.
delete_global_option
if
(
args
[
0
]
==
'
global
'
)
else
self
.
cnf_cmds
.
delete_section
,
args
[
0
]
==
'
global
'
)
else
self
.
cnf_cmds
.
delete_section
,
4
:
self
.
cnf_cmds
.
delete_section_option
4
:
self
.
cnf_cmds
.
delete_section_option
...
@@ -317,6 +335,8 @@ class AgkyraCLI(cmd.Cmd):
...
@@ -317,6 +335,8 @@ class AgkyraCLI(cmd.Cmd):
if
isinstance
(
e
,
ConfigError
):
if
isinstance
(
e
,
ConfigError
):
raise
raise
sys
.
stderr
.
write
(
self
.
config_delete
.
__doc__
+
'
\n
'
)
sys
.
stderr
.
write
(
self
.
config_delete
.
__doc__
+
'
\n
'
)
if
r
:
self
.
_warn_user_about_setting_updates
()
def
do_config
(
self
,
line
):
def
do_config
(
self
,
line
):
"""
Commands for managing the agkyra settings
"""
Commands for managing the agkyra settings
...
...
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