diff options
Diffstat (limited to 'ui-macos/askpass.py')
-rwxr-xr-x | ui-macos/askpass.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/ui-macos/askpass.py b/ui-macos/askpass.py new file mode 100755 index 0000000..55e98ee --- /dev/null +++ b/ui-macos/askpass.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python +import sys, os, re, subprocess + +prompt = ' '.join(sys.argv[1:2]).replace('"', "'") + +if 'yes/no' in prompt: + print "yes" + sys.exit(0) + +script=""" + tell application "Finder" + activate + display dialog "%s" \ + with title "Sshuttle SSH Connection" \ + default answer "" \ + with icon caution \ + with hidden answer + end tell +""" % prompt + +p = subprocess.Popen(['osascript', '-e', script], stdout=subprocess.PIPE) +out = p.stdout.read() +rv = p.wait() +if rv: + # if they press the cancel button, it returns nonzero + sys.exit(1) +g = re.match("text returned:(.*), button returned:.*", out) +if not g: + sys.exit(2) +print g.group(1) + |