Server IP : 172.24.0.40 / Your IP : 216.73.216.10 Web Server : Apache System : Linux dbweb26.ust.edu.ph 4.18.0-513.5.1.el8_9.x86_64 #1 SMP Fri Sep 29 05:21:10 EDT 2023 x86_64 User : apache ( 48) PHP Version : 8.2.18 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /usr/lib64/python3.6/site-packages/subscription_manager/ |
Upload File : |
from __future__ import print_function, division, absolute_import import logging from subscription_manager import injection as inj log = logging.getLogger(__name__) class Locker(object): def __init__(self): self.lock = self._get_lock() def run(self, action): self.lock.acquire() try: return action() finally: self.lock.release() def _get_lock(self): return inj.require(inj.ACTION_LOCK) class BaseActionInvoker(object): def __init__(self, locker=None): self.locker = locker or Locker() self.report = None def update(self): self.report = self.locker.run(self._do_update) return self.report def _do_update(self): """Thing the "lib" needs to do""" return class ActionReport(object): """Base class for cert lib and action reports""" name = "Report" def __init__(self): self._status = None self._exceptions = [] self._updates = [] def log_entry(self): """log report entries""" # assuming a useful repr log.debug(self) def format_exceptions(self): buf = '' for e in self._exceptions: buf += str(e).split('-', maxsplit=1)[-1].strip() buf += '\n' return buf def print_exceptions(self): if self._exceptions: print(self.format_exceptions()) def __str__(self): template = """%(report_name)s status: %(status)s updates: %(updates)s exceptions: %(exceptions)s """ return template % {'report_name': self.name, 'status': self._status, 'updates': self._updates, 'exceptions': self.format_exceptions()}