mirror of
https://github.com/nishiki/manage-password.git
synced 2025-03-19 21:04:35 +00:00
manage-password.py: clear code
This commit is contained in:
parent
25378c91b5
commit
e5935e38ae
1 changed files with 24 additions and 26 deletions
|
@ -137,40 +137,38 @@ class ManagePasswd:
|
||||||
# @args: search ->
|
# @args: search ->
|
||||||
def ssh(self, search):
|
def ssh(self, search):
|
||||||
result = self.search(search, 'ssh')
|
result = self.search(search, 'ssh')
|
||||||
num = len(result)
|
for r in result:
|
||||||
if num > 0:
|
server = r[self.SERVER]
|
||||||
for i in range(num):
|
login = r[self.LOGIN]
|
||||||
server = result[i][self.SERVER]
|
port = r[self.PORT]
|
||||||
login = result[i][self.LOGIN]
|
passwd = r[self.PASSWD]
|
||||||
port = result[i][self.PORT]
|
|
||||||
passwd = result[i][self.PASSWD]
|
|
||||||
|
|
||||||
if not port:
|
if not port:
|
||||||
port = 22
|
port = 22
|
||||||
|
|
||||||
if passwd:
|
if passwd:
|
||||||
os.system('sshpass -p ' + passwd + ' ssh ' + login + '@' + server + ' -p ' + str(port))
|
os.system('sshpass -p ' + passwd + ' ssh ' + login + '@' + server + ' -p ' + str(port))
|
||||||
else:
|
else:
|
||||||
os.system('ssh ' + login + '@' + server + ' -p ' + str(port))
|
os.system('ssh ' + login + '@' + server + ' -p ' + str(port))
|
||||||
else:
|
|
||||||
|
if len(result) == 0:
|
||||||
print 'No result!'
|
print 'No result!'
|
||||||
|
|
||||||
|
|
||||||
# Display the connections informations for a server
|
# Display the connections informations for a server
|
||||||
def display(self, search, type=''):
|
def display(self, search, type=''):
|
||||||
result = self.search(search, type)
|
result = self.search(search, type)
|
||||||
num = len(result)
|
for r in result:
|
||||||
if num > 0:
|
print '# --------------------'
|
||||||
for i in range(num):
|
print '# Id: ' + r[self.ID]
|
||||||
print '# --------------------'
|
print '# Server: ' + r[self.SERVER]
|
||||||
print '# Id: ' + result[i][self.ID]
|
print '# Type: ' + r[self.TYPE]
|
||||||
print '# Server: ' + result[i][self.SERVER]
|
print '# Login: ' + r[self.LOGIN]
|
||||||
print '# Type: ' + result[i][self.TYPE]
|
print '# Password: ' + r[self.PASSWD]
|
||||||
print '# Login: ' + result[i][self.LOGIN]
|
print '# Port: ' + r[self.PORT]
|
||||||
print '# Password: ' + result[i][self.PASSWD]
|
print '# Comment: ' + r[self.COMMENT]
|
||||||
print '# Port: ' + result[i][self.PORT]
|
|
||||||
print '# Comment: ' + result[i][self.COMMENT]
|
if len(result) == 0:
|
||||||
else:
|
|
||||||
print 'No result!'
|
print 'No result!'
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue