~ubuntu-branches/ubuntu/trusty/python-keystoneclient/trusty-proposed

« back to all changes in this revision

Viewing changes to keystoneclient/utils.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2013-05-29 13:07:56 UTC
  • mfrom: (1.1.19)
  • Revision ID: package-import@ubuntu.com-20130529130756-3h7dh05a39n9uvq5
Tags: 1:0.2.4-0ubuntu1
* New upstream release. 
* debian/control: Add python-d2to1 and python-pbr
* debian/control: Add testrepository, dropped python-nose
* debian/control: Add python-six

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import getpass
 
2
import hashlib
 
3
import sys
1
4
import uuid
2
 
import hashlib
3
5
 
4
6
import prettytable
5
7
 
21
23
 
22
24
 
23
25
def print_list(objs, fields, formatters={}, order_by=None):
24
 
    pt = prettytable.PrettyTable([f for f in fields], caching=False)
 
26
    pt = prettytable.PrettyTable([f for f in fields],
 
27
                                 caching=False, print_empty=False)
25
28
    pt.aligns = ['l' for f in fields]
26
29
 
27
30
    for o in objs:
55
58
 
56
59
    Wrap values to max_length wrap if wrap>0
57
60
    """
58
 
    pt = prettytable.PrettyTable(['Property', 'Value'], caching=False)
 
61
    pt = prettytable.PrettyTable(['Property', 'Value'],
 
62
                                 caching=False, print_empty=False)
59
63
    pt.aligns = ['l', 'l']
60
64
    for (prop, value) in d.iteritems():
61
65
        if value is None:
128
132
    hash_ = hashlib.md5()
129
133
    hash_.update(signed_text)
130
134
    return hash_.hexdigest()
 
135
 
 
136
 
 
137
def prompt_for_password():
 
138
    """
 
139
     Prompt user for password if not provided so the password
 
140
     doesn't show up in the bash history.
 
141
    """
 
142
    if not (hasattr(sys.stdin, 'isatty') and sys.stdin.isatty()):
 
143
        # nothing to do
 
144
        return
 
145
 
 
146
    while True:
 
147
        try:
 
148
            new_passwd = getpass.getpass('New Password: ')
 
149
            rep_passwd = getpass.getpass('Repeat New Password: ')
 
150
            if new_passwd == rep_passwd:
 
151
                return new_passwd
 
152
        except EOFError:
 
153
            return