Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
sjrpc
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor 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
Mirror
sjrpc
Commits
242f1f5f
Commit
242f1f5f
authored
14 years ago
by
Seblu
Browse files
Options
Downloads
Patches
Plain Diff
command passwd use now TqlCommand
parent
05fb5e1a
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
cccli/command/account.py
+29
-22
29 additions, 22 deletions
cccli/command/account.py
cccli/printer.py
+3
-0
3 additions, 0 deletions
cccli/printer.py
with
32 additions
and
22 deletions
cccli/command/account.py
+
29
−
22
View file @
242f1f5f
...
@@ -8,7 +8,7 @@ CloudControl accounts related commands
...
@@ -8,7 +8,7 @@ CloudControl accounts related commands
from
cccli.exception
import
*
from
cccli.exception
import
*
from
sjrpc.core.exceptions
import
*
from
sjrpc.core.exceptions
import
*
from
cccli.printer
import
Printer
,
color
from
cccli.printer
import
Printer
,
color
from
cccli.command.command
import
Command
,
OptionCommand
,
TqlCommand
from
cccli.command.command
import
OptionCommand
,
TqlCommand
class
Command_addaccount
(
OptionCommand
):
class
Command_addaccount
(
OptionCommand
):
'''
Create an account
'''
'''
Create an account
'''
...
@@ -56,29 +56,36 @@ class Command_declose(TqlCommand):
...
@@ -56,29 +56,36 @@ class Command_declose(TqlCommand):
self
.
rpccall
(
"
declose
"
,
self
.
args
[
0
])
self
.
rpccall
(
"
declose
"
,
self
.
args
[
0
])
class
Command_passwd
(
Command
):
class
Command_passwd
(
Tql
Command
):
'''
Change account password
'''
'''
Change account password
'''
def
__init__
(
self
,
cli
,
argv0
):
TqlCommand
.
__init__
(
self
,
cli
,
argv0
)
self
.
set_usage
(
"
%prog [options] [tql] [password]
"
)
def
__call__
(
self
,
argv
):
def
__call__
(
self
,
argv
):
if
len
(
argv
)
==
1
:
# parse args
argv
.
append
(
"
a=%s
"
%
self
.
cli
.
settings
[
"
login
"
])
self
.
parse_args
(
argv
)
if
len
(
argv
)
==
2
:
_tql
=
None
a
=
self
.
printer
.
getpass
(
"
Password:
"
)
_pass
=
None
b
=
self
.
printer
.
getpass
(
"
Again:
"
)
if
len
(
self
.
args
)
==
0
:
if
a
!=
b
:
_tql
=
"
a=%s
"
%
self
.
cli
.
settings
[
"
login
"
]
raise
cmdError
(
"
You don
'
t type twice the same password. Aborted
"
)
elif
len
(
self
.
args
)
==
1
:
argv
.
append
(
a
)
_tql
=
self
.
args
[
0
]
elif
len
(
argv
)
==
3
:
elif
len
(
self
.
args
)
==
2
:
if
self
.
cli
.
interactive
:
_tql
=
self
.
args
[
0
]
s
=
"
You cannot set password with clear argument in interactive mode.
\n
"
_pass
=
self
.
args
[
1
]
s
+=
"
*** Think to clean your history! ***
"
_check
=
self
.
args
[
1
]
raise
cmdError
(
s
)
if
self
.
printer
.
isinteractive
():
self
.
printer
.
warn
(
"
Removing last line from history
"
)
self
.
printer
.
history
.
removelast
()
else
:
else
:
raise
cmdBadArgument
()
raise
cmdBadArgument
()
try
:
# get password
self
.
cli
.
rpc
.
call
(
"
passwd
"
,
argv
[
1
],
argv
[
2
])
if
_pass
is
None
:
except
RpcError
as
e
:
_pass
=
self
.
printer
.
getpass
(
"
Password:
"
)
raise
cmdError
(
"
RPCError: %s
"
%
str
(
e
))
_check
=
self
.
printer
.
getpass
(
"
Again:
"
)
if
_pass
!=
_check
:
def
usage
(
self
):
raise
cmdError
(
"
You don
'
t type twice the same password. Aborted
"
)
return
"
Usage: passwd [tql] [password]
"
# execute command
self
.
rpccall
(
"
passwd
"
,
_tql
,
_pass
)
This diff is collapsed.
Click to expand it.
cccli/printer.py
+
3
−
0
View file @
242f1f5f
...
@@ -100,6 +100,9 @@ class Printer(object):
...
@@ -100,6 +100,9 @@ class Printer(object):
if
cccli
.
debug
:
if
cccli
.
debug
:
self
.
out
(
"
%s%s%s
"
%
(
color
[
"
lgrey
"
],
message
,
color
[
"
reset
"
]),
fd
,
nl
)
self
.
out
(
"
%s%s%s
"
%
(
color
[
"
lgrey
"
],
message
,
color
[
"
reset
"
]),
fd
,
nl
)
def
isinteractive
(
self
):
return
self
.
readline
is
not
None
def
interactive
(
self
,
message
,
fd
=
sys
.
stderr
,
nl
=
os
.
linesep
):
def
interactive
(
self
,
message
,
fd
=
sys
.
stderr
,
nl
=
os
.
linesep
):
'''
Print only in interactive mode
'''
'''
Print only in interactive mode
'''
if
self
.
readline
is
not
None
:
if
self
.
readline
is
not
None
:
...
...
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