Commit 9882453c authored by ale's avatar ale

only ask for OTP if stdin is a tty

parent 49095906
import cookielib
import getpass
import os
import urllib2
import urllib
import re
import sys
class SSOProcessor(urllib2.BaseHandler):
......@@ -40,6 +42,9 @@ class SSOProcessor(urllib2.BaseHandler):
self._username, form_data['s'].rstrip('/')))
form_data['password'] = self._password
if self._otp_pattern.search(response_data):
# Only ask for an OTP when the standard input is a tty,
# otherwise simply don't send any OTP.
if os.isatty(sys.stdin):
form_data['otp'] = raw_input('OTP for %s@%s: ' % (
self._username, form_data['s'].rstrip('/')))
newreq = urllib2.Request(request_baseurl,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment