Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Crans Passwords
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
5
Issues
5
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nounous
Crans Passwords
Commits
10ee8be9
Commit
10ee8be9
authored
Jul 02, 2014
by
Daniel STAN
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
draft de mode interactif
parent
81f095d8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
0 deletions
+41
-0
client.py
client.py
+41
-0
No files found.
client.py
View file @
10ee8be9
...
...
@@ -27,6 +27,7 @@ import copy
import
glob
import
ConfigParser
import
shlex
import
cmd
# Import de la config
def
get_config_path
():
...
...
@@ -934,6 +935,42 @@ def parse_roles(options, cast=False):
ret
.
add
(
role
)
return
list
(
ret
)
class
CpasswordClient
(
cmd
.
Cmd
,
object
):
_cached_list
=
None
def
__init__
(
self
,
options
):
super
(
CpasswordClient
,
self
).
__init__
()
self
.
options
=
options
def
do_EOF
(
self
,
line
):
return
True
def
do_view
(
self
,
line
):
options
.
fname
=
line
show_file
(
self
.
options
)
def
_list
(
self
):
if
self
.
_cached_list
is
not
None
:
return
self
.
_cached_list
self
.
_cached_list
=
[]
my_roles
,
_
=
get_my_roles
(
self
.
options
)
files
=
all_files
(
self
.
options
)
keys
=
files
.
keys
()
for
fname
in
keys
:
froles
=
files
[
fname
]
access
=
set
(
my_roles
).
intersection
(
froles
)
!=
set
([])
if
access
:
self
.
_cached_list
.
append
(
fname
)
def
complete_view
(
self
,
text
,
line
,
begidx
,
endidx
):
return
[
s
for
s
in
self
.
_list
()
if
s
.
startswith
(
text
)]
def
interactive
(
options
):
CpasswordClient
(
options
).
cmdloop
()
def
insult_on_nofilename
(
options
,
parser
):
"""Insulte (si non quiet) et quitte si aucun nom de fichier n'a été fourni en commandline."""
if
options
.
fname
==
None
:
...
...
@@ -987,6 +1024,9 @@ if __name__ == "__main__":
action_grp
.
add_argument
(
'--list-servers'
,
action
=
'store_const'
,
dest
=
'action'
,
default
=
show_file
,
const
=
show_servers
,
help
=
"Lister les serveurs"
)
action_grp
.
add_argument
(
'-i'
,
'--interactive'
,
action
=
'store_const'
,
dest
=
'action'
,
default
=
show_file
,
const
=
interactive
,
help
=
"Mode interactif"
)
action_grp
.
add_argument
(
'--recrypt-files'
,
action
=
'store_const'
,
dest
=
'action'
,
default
=
show_file
,
const
=
recrypt_files
,
help
=
"""Rechiffrer les mots de passe.
...
...
@@ -1046,3 +1086,4 @@ if __name__ == "__main__":
# On exécute l'action demandée
options
.
action
(
options
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment