mirror of
https://github.com/sshuttle/sshuttle.git
synced 2025-08-13 09:47:08 +02:00
ui-macos/*: "a series of unfortunate events."
Just kidding. This is a squash of a whole bunch of unlabeled temporary commits that I produced over the last couple of weeks while writing a UI for MacOS while riding on airplanes and sitting in airports. So long, batch of useless commits!
This commit is contained in:
31
ui-macos/askpass.py
Executable file
31
ui-macos/askpass.py
Executable file
@ -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)
|
||||
|
Reference in New Issue
Block a user