def __init__(self, path, options, norecreate, nodeps, running, filelog=None): global log if "log" not in globals(): if filelog is not None: log = logging.getLogger(__name__) log.addHandler(logger.FileHandler(filelog)) log.setLevel(logging.DEBUG) else: log = logging.getLogger(__name__) log.addHandler(logger.StreamHandler()) log.setLevel(logging.DEBUG) self.path = path self.options = options self.norecreate = norecreate self.nodeps = nodeps self.running = running try: self.project = command.project_from_options( self.path, self.options) except ConfigurationError: log.error("Can't create a monitor unit\n{}".format( traceback.format_exc())) raise SystemExit
def __init__(self, resources, timeout=None, untagged=False, force=[], version="auto", oldest=0, images_include=[], volumes_include=[], images_exclude=[], volumes_exclude=[], prune=[], loglevel=None, filelog=None): global log if "log" not in globals(): if filelog is not None: log = logging.getLogger(__name__) log.addHandler(logger.FileHandler(filelog)) log.setLevel(getattr(logging, loglevel)) else: log = logging.getLogger(__name__) log.addHandler(logger.StreamHandler()) log.setLevel(getattr(logging, loglevel)) self.docker_client = docker.DockerClient(version=version) self.resources = resources self.i_force = True if "images" in force or "all" in force else False self.v_force = True if "volumes" in force or "all" in force else False self.timeout = int(timeout) if timeout is not None else None self.untagged = untagged self.oldest = int(oldest) self.images_include = images_include self.volumes_include = volumes_include self.images_exclude = images_exclude self.volumes_exclude = volumes_exclude self.prune = prune
def __init__(self, redirect_url, client_id, client_secret, push_secret, scope=["operation-details"], base_url="https://sp-money.yandex.ru/oauth", loglevel="INFO", logfile=None): self.base_url = base_url self.redirect_url = redirect_url self.client_id = client_id self.client_secret = client_secret self.push_secret = push_secret self.scope = scope self.loglevel = loglevel self.logfile = logfile global log if "log" not in globals(): if logfile is not None: log = logging.getLogger(__name__) log.addHandler(logger.FileHandler(logfile)) log.setLevel(getattr(logging, loglevel)) else: log = logging.getLogger(__name__) log.addHandler(logger.StreamHandler()) log.setLevel(getattr(logging, loglevel))
def __init__(self, host, port, user, password, db, loglevel="INFO", logfile=None): self.host = host self.port = port self.user = user self.password = password self.db = db self.connection = None self.loglevel = loglevel self.logfile = logfile global log if "log" not in globals(): if logfile is not None: log = logging.getLogger(__name__) log.addHandler(logger.FileHandler(logfile)) log.setLevel(getattr(logging, loglevel)) else: log = logging.getLogger(__name__) log.addHandler(logger.StreamHandler()) log.setLevel(getattr(logging, loglevel))
def __init__(self, message, loglevel="INFO", logfile=None): self.message = message self._parsed = {} self._verified = None self.loglevel = loglevel self.logfile = logfile global log if "log" not in globals(): if logfile is not None: log = logging.getLogger(__name__) log.addHandler(logger.FileHandler(logfile)) log.setLevel(getattr(logging, loglevel)) else: log = logging.getLogger(__name__) log.addHandler(logger.StreamHandler()) log.setLevel(getattr(logging, loglevel))
def main(): try: parser = argparse.ArgumentParser() parser.add_argument("resources", type=str, default=[], nargs='+', choices=["images", "volumes", "all"], help="Types of resources for removing") parser.add_argument("-f", "--force", dest="force", default=[], nargs='+', choices=["images", "volumes", "all"], help="Force removing") parser.add_argument("-v", "--client-version", dest="version", default="auto", help="Version of docker client to use") parser.add_argument( "-o", "--older", dest="older", default=0, help="Clear resources that older amount of time (in minutes)") parser.add_argument( "--images-include", dest="images_include", nargs='+', default=[""], help="Filter images that only contains any of that names") parser.add_argument( "--volumes-include", dest="volumes_include", nargs='+', default=[""], help="Filter volumes that only contains any of that name") parser.add_argument( "--images-exclude", dest="images_exclude", nargs='+', default=[], help="Exclude images that contains any of that names") parser.add_argument( "--volumes-exclude", dest="volumes_exclude", nargs='+', default=[], help="Exclude volumes that contains any of that name") parser.add_argument("-p", "--prune", dest="prune", nargs='+', choices=["images", "volumes", "containers", "all"], default=[], help="Prune specified resources") parser.add_argument("-u", "--untagged", dest="untagged", action="store_true", help="Clear untagged images") parser.add_argument("-t", "--timeout", dest="timeout", default=None, help="Timeout of cleaning. " "Live it empty in case of using cron job.") parser.add_argument("--loglevel", dest="loglevel", default="INFO", choices=[ "CRITICAL", "ERROR", "WARNING", "INFO", "DEBUG", "NOTSET" ], help="Logging level") parser.add_argument("-l", "--log", dest="log", help="Redirect logging to file") args = parser.parse_args() global log if args.log is not None: log = logging.getLogger(__name__) log.addHandler(logger.FileHandler(args.log)) log.setLevel(getattr(logging, args.loglevel)) else: log = logging.getLogger(__name__) log.addHandler(logger.StreamHandler()) log.setLevel(getattr(logging, args.loglevel)) ac = AutoCleaner(resources=args.resources, timeout=args.timeout, untagged=args.untagged, force=args.force, version=args.version, oldest=args.older, images_include=args.images_include, volumes_include=args.volumes_include, images_exclude=args.images_exclude, volumes_exclude=args.volumes_exclude, prune=args.prune, loglevel=args.loglevel, filelog=args.log) ac.clean() except KeyboardInterrupt: print('\nThe process was interrupted by the user') raise SystemExit
help="Don't recreate, only pull") parser.add_argument("--no-deps", dest="nodeps", action="store_true", help="Don't restart services dependencies") parser.add_argument( "--affect-only-running", dest="running", action="store_true", help="Restart only running services and don't touch stopped") parser.add_argument("-l", "--log", dest="log", help="Redirect logging to file") args = parser.parse_args() if args.log is not None: log = logging.getLogger(__name__) log.addHandler(logger.FileHandler(args.log)) log.setLevel(logging.DEBUG) else: log = logging.getLogger(__name__) log.addHandler(logger.StreamHandler()) log.setLevel(logging.DEBUG) def main(): try: if args.options is None: monitor = Monitor(args.path, dict(), args.norecreate, args.nodeps, args.running, args.log) else: monitor = Monitor( args.path,