def __init__(self, config, name): RefreshableAccessToken.__init__(self, config, name) self._kinit_exec = resolve_install_path('kinit') self._klist_exec = resolve_install_path('klist') self._cache = None self._map_auth_name2fn = dict( imap(lambda name: (name, config.get_work_path('proxy.%s' % name)), ['KRB5CCNAME', 'KRBTKFILE'])) with_lock(AFSAccessToken.env_lock, self._backup_tickets, config) self._tickets = config.get_list('tickets', [], on_change=None)
def execute(self, wms_id_list, wms_name): # yields list of purged (wms_id,) activity = Activity('waiting for jobs to finish') time.sleep(5) for wms_id in wms_id_list: path = self._sandbox_helper.get_sandbox('WMSID.%s.%s' % (wms_name, wms_id)) if path is None: self._log.warning('Sandbox for job %r could not be found', wms_id) continue with_lock(LocalPurgeJobs.purge_lock, _purge_directory, self._log, path, wms_id) yield (wms_id,) activity.finish()
def _redraw(self): try: while not self._redraw_shutdown: self._redraw_event.wait(timeout=self._redraw_interval) self._immediate_redraw_event.wait(timeout=self._redraw_delay) with_lock(self._console_lock, self._element.redraw) self._immediate_redraw_event.clear() self._redraw_event.clear() except Exception: self._exc.collect() abort(True)
def execute(self, wms_id_list, wms_name): # yields list of purged (wms_id,) activity = Activity('waiting for jobs to finish') time.sleep(5) for wms_id in wms_id_list: path = self._sandbox_helper.get_sandbox('WMSID.%s.%s' % (wms_name, wms_id)) if path is None: self._log.warning('Sandbox for job %r could not be found', wms_id) continue with_lock(LocalPurgeJobs.purge_lock, _purge_directory, self._log, path, wms_id) yield (wms_id, ) activity.finish()
def __init__(self, msg=None, level=logging.INFO, name=None, parent=None, fmt='%(msg)s...', log=False, logger=None): # log == None - only at start/finish; log == True - always (self._level, self._msg_dict, self._fmt) = (level, {'msg': ''}, fmt) (self.name, self._parent, self._children) = (name, None, []) (self._log, self._logger) = (log, logger or logging.getLogger()) if (self._log is not False) and msg: self._logger.log(level, msg) self._current_thread_name = get_thread_name() with_lock(Activity.lock, self._add_activity, parent) self.depth = len(list(self.get_parents())) if self._parent: self._parent.add_child(self) self.update(msg)
def _finish_drawing(self): def _final_draw(): try: self._element.make_dirty() finally: self._redraw_shutdown = True # stop redraw thread self._redraw_event.set() try: try: with_lock(self._console_lock, _final_draw) # last redraw finally: if self._redraw_thread: self._redraw_thread.join(5 + self._redraw_interval) finally: with_lock(self._console_lock, self._element.draw_finish) # draw finish
def __init__(self, msg=None, level=logging.INFO, name=None, parent=None, fmt='%(msg)s...', log=False, logger=None ): # log == None - only at start/finish; log == True - always (self._level, self._msg_dict, self._fmt) = (level, {'msg': ''}, fmt) (self.name, self._parent, self._children) = (name, None, []) (self._log, self._logger) = (log, logger or logging.getLogger()) if (self._log is not False) and msg: self._logger.log(level, msg) self._current_thread_name = get_thread_name() with_lock(Activity.lock, self._add_activity, parent) self.depth = len(list(self.get_parents())) if self._parent: self._parent.add_child(self) self.update(msg)
def write(self, value=''): with_lock(MultiActivityMonitor.global_lock, self._write, value)
def get_partition_checked(self, partition_num): if partition_num >= self._partition_len: raise PartitionError('%s is out of range for available partitions' % repr(partition_num)) return with_lock(self._lock, self.get_partition_unchecked, partition_num)
def emit(self, record): if record.pathname == '<process>': with_lock(self._lock, self._write_process_log, record) self._log.warning('All logfiles were moved to %s', self._fn)
def handle(self, record): filter_result = self.filter(record) if filter_result: with_lock(self.global_lock or self.lock, self.emit, record) return filter_result
def start_interface(self): GCStreamHandler.set_global_lock(self._console_lock) with_lock(self._console_lock, self._element.draw_startup) self._redraw_shutdown = False # start redraw thread self._redraw_thread = start_daemon('GUI draw thread', self._redraw)