mirror of
https://github.com/munki/munki.git
synced 2026-04-23 21:40:25 -05:00
Remove hack that allowed in-place editing of suggested/default values for prompts; does not work properly on remote sessions.
This commit is contained in:
+7
-37
@@ -30,8 +30,6 @@ import subprocess
|
||||
import time
|
||||
from optparse import OptionParser, BadOptionError, AmbiguousOptionError
|
||||
|
||||
from Quartz import CGEventCreateKeyboardEvent, CGEventPost, kCGHIDEventTap
|
||||
|
||||
from munkilib import munkicommon
|
||||
from munkilib import FoundationPlist
|
||||
|
||||
@@ -58,42 +56,14 @@ class PassThroughOptionParser(OptionParser):
|
||||
|
||||
|
||||
def raw_input_with_default(prompt='', default=''):
|
||||
'''Uses readline and some hacking under OS X to provide
|
||||
an editable default value for input.'''
|
||||
|
||||
def readline_pre_input_hook():
|
||||
'''Inserts default into the input stream. This doesn't work with
|
||||
the system Python on OS X because it's linked to BSD libedit instead
|
||||
of GNU readline'''
|
||||
readline.insert_text(default)
|
||||
readline.redisplay()
|
||||
|
||||
def insertUpArrowKeyboardEvent():
|
||||
'''Inserts an up-arrow keypress into the OS X event queue'''
|
||||
UP_ARROW = 126
|
||||
myevent = CGEventCreateKeyboardEvent(None, UP_ARROW, True)
|
||||
CGEventPost(kCGHIDEventTap, myevent)
|
||||
myevent = CGEventCreateKeyboardEvent(None, UP_ARROW, False)
|
||||
CGEventPost(kCGHIDEventTap, myevent)
|
||||
'''Get input from user with a prompt and a suggested default value'''
|
||||
|
||||
if default:
|
||||
if sys.platform == 'darwin':
|
||||
# append our default value to history
|
||||
readline.add_history(default)
|
||||
# fake an up-arrow to cause last history
|
||||
# item to be displayed
|
||||
insertUpArrowKeyboardEvent()
|
||||
return raw_input(prompt)
|
||||
else:
|
||||
# set up out pre input hook
|
||||
readline.set_pre_input_hook(readline_pre_input_hook)
|
||||
response = raw_input(prompt)
|
||||
# remove our pre input hook
|
||||
readline.set_pre_input_hook()
|
||||
return response
|
||||
prompt = '%s [%s]: ' % (prompt, default)
|
||||
return raw_input(prompt) or default
|
||||
else:
|
||||
# no default value, just call raw_input
|
||||
return raw_input(prompt)
|
||||
return raw_input(prompt + ": ")
|
||||
|
||||
|
||||
def makeDMG(pkgpath):
|
||||
@@ -572,7 +542,7 @@ def configure():
|
||||
('editor', 'pkginfo editor (examples: /usr/bin/vi or TextMate.app)'),
|
||||
('default_catalog', 'Default catalog to use (example: testing)')]:
|
||||
|
||||
_prefs[key] = raw_input_with_default('%15s: ' % prompt, pref(key))
|
||||
_prefs[key] = raw_input_with_default('%15s' % prompt, pref(key))
|
||||
|
||||
try:
|
||||
FoundationPlist.writePlist(_prefs, PREFSPATH)
|
||||
@@ -764,12 +734,12 @@ def main():
|
||||
('Description', 'description'),
|
||||
('Version', 'version'))
|
||||
for (name, key) in editfields:
|
||||
prompt = '%15s: ' % name
|
||||
prompt = '%15s' % name
|
||||
default = pkginfo.get(key,'').encode('UTF-8')
|
||||
pkginfo[key] = raw_input_with_default(prompt, default)
|
||||
|
||||
# special handling for catalogs array
|
||||
prompt = '%15s: ' % 'Catalogs'
|
||||
prompt = '%15s' % 'Catalogs'
|
||||
default = ', '.join(pkginfo['catalogs'])
|
||||
newvalue = raw_input_with_default(prompt, default)
|
||||
pkginfo['catalogs'] = [item.strip()
|
||||
|
||||
Reference in New Issue
Block a user