def get_credentials(create=False): """ We use this to ask the user for his credentials in case we have no valid token. If create is true, the user is asked twice for the password, to make sure, that no typing error occurred. This is done three times after that a PasswordsDontMatchException is thrown. """ email = raw_input('Email : ') password = None for i in range(3): #noinspection PyArgumentEqualDefault password = recode_input(getpass('Password: '******'Password (again): ')) if password != password2: print messages['PasswordsDontMatch'] if i == 2: #noinspection PyExceptionInherit raise PasswordsDontMatchException() else: break else: break return email, password
def get_password(create=False): password = None for i in range(3): password = recode_input(getpass('Password: '******'Password (again): ')) if password != password2: print messages['PasswordsDontMatch'] if i == 2: raise PasswordsDontMatchException() else: break else: break return password
def get_password(create=False): password = None for i in range(3): password = recode_input(getpass('Password: '******'Password (again): ')) if password != password2: print >> sys.stderr, messages['PasswordsDontMatch'] if i == 2: raise PasswordsDontMatchException() else: break else: break return password
def if_file_get_content(value): """ if value is the path to a local file, read the content and return it otherwise just return value """ file_path = path.abspath(value) if path.isfile(file_path): try: f = open(file_path, 'rU') except IOError: pass else: content = f.read() f.close() return content if sys.platform == 'win32': # in windows, sys.argv is encoded in windows-1252 return value.decode('windows-1252').encode('UTF-8') else: # all others use the same encoding for stdin and argv return recode_input(value)