Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
30b2757257 |
0
bunker/cli/__init__.py
Normal file
0
bunker/cli/__init__.py
Normal file
17
bunker/cli/io.py
Normal file
17
bunker/cli/io.py
Normal file
|
@ -0,0 +1,17 @@
|
|||
import os
|
||||
from getpass import getpass
|
||||
|
||||
from ..bunker import Bunker
|
||||
|
||||
def open(file_name, create):
|
||||
if(not os.path.exists(file_name)):
|
||||
if(not create):
|
||||
raise IOError("file '{}' does not exist".format(file_name))
|
||||
else:
|
||||
if(not os.path.isfile(file_name)):
|
||||
raise IOError("'{}' is not a file".format(file_name))
|
||||
|
||||
return Bunker.open(file_name)
|
||||
|
||||
def read_password():
|
||||
getpass()
|
22
bunker/cli/methods.py
Normal file
22
bunker/cli/methods.py
Normal file
|
@ -0,0 +1,22 @@
|
|||
from .io import read_password
|
||||
from ..backends.directory_store import DirectoryStore
|
||||
from ..backends.kvs import KeyValueStore
|
||||
|
||||
def add_kvs(bunker, name, password):
|
||||
if(password is None):
|
||||
password = read_password()
|
||||
|
||||
bunker.add_component(KeyValueStore.component_type, name, password)
|
||||
|
||||
def add_ds(bunker, name, password):
|
||||
if(password is None):
|
||||
password = read_password()
|
||||
|
||||
bunker.add_component(DirectoryStore.component_type, name, password)
|
||||
|
||||
def list_components(bunker, password):
|
||||
if(password is None):
|
||||
password = read_password()
|
||||
|
||||
for row in bunker._components:
|
||||
print(row["type"], ",\t", row["component"])
|
Loading…
Reference in New Issue
Block a user