def notify(self, msg): """Show a desktop notification with the supplied message On Linux and Mac, this will show a desktop notification with the message, but on Windows we can only flash the screen. """ moz_nospam = os.environ.get('MOZ_NOSPAM') if moz_nospam: return try: if sys.platform.startswith('darwin'): try: notifier = which.which('terminal-notifier') except which.WhichError: raise Exception('Install terminal-notifier to get ' 'a notification when the build finishes.') self.run_process([notifier, '-title', 'Mozilla Build System', '-group', 'mozbuild', '-message', msg], ensure_exit_code=False) elif sys.platform.startswith('win'): from ctypes import Structure, windll, POINTER, sizeof from ctypes.wintypes import DWORD, HANDLE, WINFUNCTYPE, BOOL, UINT class FLASHWINDOW(Structure): _fields_ = [("cbSize", UINT), ("hwnd", HANDLE), ("dwFlags", DWORD), ("uCount", UINT), ("dwTimeout", DWORD)] FlashWindowExProto = WINFUNCTYPE(BOOL, POINTER(FLASHWINDOW)) FlashWindowEx = FlashWindowExProto(("FlashWindowEx", windll.user32)) FLASHW_CAPTION = 0x01 FLASHW_TRAY = 0x02 FLASHW_TIMERNOFG = 0x0C # GetConsoleWindows returns NULL if no console is attached. We # can't flash nothing. console = windll.kernel32.GetConsoleWindow() if not console: return params = FLASHWINDOW(sizeof(FLASHWINDOW), console, FLASHW_CAPTION | FLASHW_TRAY | FLASHW_TIMERNOFG, 3, 0) FlashWindowEx(params) else: try: notifier = which.which('notify-send') except which.WhichError: raise Exception('Install notify-send (usually part of ' 'the libnotify package) to get a notification when ' 'the build finishes.') self.run_process([notifier, '--app-name=Mozilla Build System', 'Mozilla Build System', msg], ensure_exit_code=False) except Exception as e: self.log(logging.WARNING, 'notifier-failed', {'error': e.message}, 'Notification center failed: {error}')
def _make_path(self): baseconfig = os.path.join(self.topsrcdir, 'config', 'baseconfig.mk') def is_xcode_lisense_error(output): return self._is_osx() and b'Agreeing to the Xcode' in output def validate_make(make): if os.path.exists(baseconfig) and os.path.exists(make): cmd = [make, '-f', baseconfig] if self._is_windows(): cmd.append('HOST_OS_ARCH=WINNT') try: subprocess.check_output(cmd, stderr=subprocess.STDOUT) except subprocess.CalledProcessError as e: return False, is_xcode_lisense_error(e.output) return True, False return False, False xcode_lisense_error = False possible_makes = [ 'gmake', 'make', 'mozmake', 'gnumake', 'mingw32-make' ] if 'MAKE' in os.environ: make = os.environ['MAKE'] possible_makes.insert(0, make) for test in possible_makes: if os.path.isabs(test): make = test else: try: make = which.which(test) except which.WhichError: continue result, xcode_lisense_error_tmp = validate_make(make) if result: return [make] if xcode_lisense_error_tmp: xcode_lisense_error = True if xcode_lisense_error: raise Exception( 'Xcode requires accepting to the license agreement.\n' 'Please run Xcode and accept the license agreement.') if self._is_windows(): raise Exception('Could not find a suitable make implementation.\n' 'Please use MozillaBuild 1.9 or newer') else: raise Exception('Could not find a suitable make implementation.')