munkiimport: Only offer to unmount the repo if we mounted it in the first place.

git-svn-id: http://munki.googlecode.com/svn/trunk@1028 a4e17f2e-e282-11dd-95e1-755cbddbdd66
This commit is contained in:
Greg Neagle
2011-02-11 18:28:05 +00:00
parent 72c8b0ac50
commit 1002eb7a26
+12 -3
View File
@@ -100,6 +100,7 @@ def mountRepoGUI():
def mountRepoCLI():
"""Attempts to connect to the repo fileshare"""
global WE_MOUNTED_THE_REPO
repo_path = pref('repo_path')
repo_url = pref('repo_url')
if os.path.exists(repo_path):
@@ -110,6 +111,8 @@ def mountRepoCLI():
retcode = subprocess.call(cmd)
if retcode:
os.rmdir(repo_path)
else:
WE_MOUNTED_THE_REPO = True
def unmountRepoCLI():
@@ -442,12 +445,17 @@ def makeCatalogs():
def cleanupAndExit(exitcode):
if not NOINTERACTIVE:
answer = raw_input('Unmount the repo fileshare? [y/n] ')
if answer.lower().startswith('y'):
result = 0
if WE_MOUNTED_THE_REPO:
if not NOINTERACTIVE:
answer = raw_input('Unmount the repo fileshare? [y/n] ')
if answer.lower().startswith('y'):
result = unmountRepoCLI()
else:
result = unmountRepoCLI()
exit(exitcode or result)
def pref(prefname):
"""Returns a preference for prefname"""
try:
@@ -483,6 +491,7 @@ PREFSNAME = 'com.googlecode.munki.munkiimport.plist'
PREFSPATH = os.path.expanduser(os.path.join('~/Library/Preferences',
PREFSNAME))
NOINTERACTIVE = False
WE_MOUNTED_THE_REPO = False
def main():
"""Main routine"""