def signal_handler(signal, frame): print(Fore.RED + 'Ctrl-C caught: exiting...' + Style.RESET_ALL) if _follower: _follower.close() sys.stderr = DevNull() print(Fore.MAGENTA + 'exit.' + Style.RESET_ALL) sys.exit(0)
def signal_handler(signal, frame): print(Fore.YELLOW + 'signal handler caught Ctrl-C; exiting...') if _blinka: _blinka.disable() sys.stderr = DevNull() print('exit.') sys.exit(0)
def signal_handler(signal, frame): print(Fore.RED + 'Ctrl-C caught: exiting...' + Style.RESET_ALL) if _infrareds is not None: _infrareds.close() sys.stderr = DevNull() print(Fore.MAGENTA + 'exit.' + Style.RESET_ALL) sys.exit(0)
def close(self): super().close() if not self._closing: self._closing = True self._active = False self._enabled = False self._log.critical('closing ' + self.task_name + '...') _n = 0 while self.is_alive(): _n = _n + 1 self._log.info('joining thread of ' + self.task_name + '.') self.join(timeout=2.0) if self.task_name is 'os' and _n >= 3: self._log.error(Fore.RED + Style.BRIGHT + 'waited too long: forced termination...') sys.stderr = DevNull() sys.exit() self._log.info('waiting ({:d}) for {} to terminate...'.format( _n, self.task_name)) time.sleep(0.25) # self._gpio.cleanup() self._log.critical('closed ' + self.task_name + '.') # pass else: self._log.error('already closing ' + self.task_name + '.')
def signal_handler(signal, frame): print(Fore.RED + 'Ctrl-C caught: exiting...' + Style.RESET_ALL) # _motors.halt() # Motors.cancel() sys.stderr = DevNull() print(Fore.MAGENTA + 'exit.' + Style.RESET_ALL) sys.exit(0)
def signal_handler(signal, frame): print('\nsignal handler :' + Fore.MAGENTA + Style.BRIGHT + ' INFO : Ctrl-C caught: exiting...' + Style.RESET_ALL) _ros.close() print(Fore.MAGENTA + 'exit.' + Style.RESET_ALL) sys.stderr = DevNull() # sys.exit() sys.exit(0)
def quit(): if _port_motor: _port_motor.halt() if _stbd_motor: _stbd_motor.halt() Motor.cancel() sys.stderr = DevNull() print('exit.') sys.exit(0)
def close(self): ''' This sets the ROS back to normal following a session. ''' if self._closing: # this also gets called by the arbitrator so we ignore that self._log.info('already closing.') return else: self._active = False self._closing = True self._log.info(Style.BRIGHT + 'closing...') if self._gamepad: self._gamepad.close() if self._motors: self._motors.close() if self._ifs: self._ifs.close() # close features for feature in self._features: self._log.info('closing feature {}...'.format(feature.name())) feature.close() self._log.info('finished closing features.') if self._arbitrator: self._arbitrator.disable() self._arbitrator.close() # self._arbitrator.join(timeout=1.0) if self._controller: self._controller.disable() # if self._flask_wrapper is not None: # self._flask_wrapper.close() super().close() # self._info.close() # self._rgbmatrix.close() # if self._switch: # self._switch.close() # super(AbstractTask, self).close() if self._disable_leds: # restore LEDs self._set_pi_leds(True) # GPIO.cleanup() # self._log.info('joining main thread...') # self.join(timeout=0.5) self._log.info('os closed.') sys.stderr = DevNull() sys.exit(0)
def signal_handler(signal, frame): print(Fore.RED + 'Ctrl-C caught: exiting...' + Style.RESET_ALL) sys.stderr = DevNull() print(Fore.CYAN + 'exit.' + Style.RESET_ALL) sys.exit(0)
def signal_handler(signal, frame): print('Ctrl-C caught: exiting...') Motor.cancel() sys.stderr = DevNull() print('exit.') sys.exit(0)
init() from lib.devnull import DevNull from lib.logger import Logger, Level # configuration ................................................................ # path to the sound directory SOUND_DIR = 'sound' # play volume 0.0 - 1.0 PLAY_VOLUME = 1.0 # suppress pygame and config console output .................................... temp_stdout = sys.stdout sys.stdout = DevNull() import pygame sys.stdout = temp_stdout # configuration ................................................................ class Sound(Enum): ''' An enumerated set of available sounds. ''' BEEP = ( 1, "Beep.mp3" ) # from an answering machine, probably 440 Hz tone HONK = ( 2, "HornHonk.mp3" ) # single honk, more modern car HONK2 = ( 3, "HornHonk2.mp3" ) # short car horn BUZZ = ( 4, "Buzz.mp3" ) # rather audible buzzz DOOR_BUZZ = ( 5, "DoorBuzzer.mp3" ) # sounds like it's at a distance ALARM = ( 6, "AnalogWatchAlarm.mp3" ) # high pitch beep-beep (actually audible) CHIRP = ( 7, "RadioInterruption.mp3" ) # electronic chirp
def quit(): Motor.cancel() sys.stderr = DevNull() print('exit.') sys.exit(0)