From b0dd20018fffcbccd67ec565477f4fd56caf623e Mon Sep 17 00:00:00 2001 From: Greg Neagle Date: Thu, 15 Dec 2016 13:43:11 -0800 Subject: [PATCH] Move the last function out of munkicommon/__init__.py --- code/client/munkilib/munkicommon/__init__.py | 31 ------------------- code/client/munkilib/munkicommon/processes.py | 25 +++++++++++++++ 2 files changed, 25 insertions(+), 31 deletions(-) diff --git a/code/client/munkilib/munkicommon/__init__.py b/code/client/munkilib/munkicommon/__init__.py index 1ef41a54..59bb4cec 100755 --- a/code/client/munkilib/munkicommon/__init__.py +++ b/code/client/munkilib/munkicommon/__init__.py @@ -21,9 +21,6 @@ Created by Greg Neagle on 2008-11-18. Common functions used by the munki tools. """ - -import os - # We wildcard-import from submodules for backwards compatibility; functions # that were previously available from this module # pylint: disable=wildcard-import @@ -42,33 +39,5 @@ from .reports import * from .scriptutils import * # pylint: enable=wildcard-import -# we use camelCase-style names. Deal with it. -# pylint: disable=C0103 - - -# misc functions - -_stop_requested = False -def stopRequested(): - """Allows user to cancel operations when GUI status is being used""" - global _stop_requested - if _stop_requested: - return True - stop_request_flag = ( - '/private/tmp/' - 'com.googlecode.munki.managedsoftwareupdate.stop_requested') - if os.path.exists(stop_request_flag): - # store this so it's persistent until this session is over - _stop_requested = True - display_info('### User stopped session ###') - try: - os.unlink(stop_request_flag) - except OSError, err: - display_error( - 'Could not remove %s: %s', stop_request_flag, err) - return True - return False - - if __name__ == '__main__': print 'This is a library of support tools for the Munki Suite.' diff --git a/code/client/munkilib/munkicommon/processes.py b/code/client/munkilib/munkicommon/processes.py index bee11a15..4a698828 100755 --- a/code/client/munkilib/munkicommon/processes.py +++ b/code/client/munkilib/munkicommon/processes.py @@ -197,5 +197,30 @@ def forceLogoutNow(): display.display_error('Exception in forceLogoutNow(): %s' % str(err)) +# this function is maybe an odd fit for this module, but it's a way for the +# Managed Software Center.app and MunkiStatus.app processes to tell the +# managedsoftwareupdate process to stop/cancel, so here it is! +_stop_requested = False +def stopRequested(): + """Allows user to cancel operations when GUI status is being used""" + global _stop_requested + if _stop_requested: + return True + stop_request_flag = ( + '/private/tmp/' + 'com.googlecode.munki.managedsoftwareupdate.stop_requested') + if os.path.exists(stop_request_flag): + # store this so it's persistent until this session is over + _stop_requested = True + display_info('### User stopped session ###') + try: + os.unlink(stop_request_flag) + except OSError, err: + display_error( + 'Could not remove %s: %s', stop_request_flag, err) + return True + return False + + if __name__ == '__main__': print 'This is a library of support tools for the Munki Suite.'