yapf format

This commit is contained in:
Joseph Schorr 2017-06-29 09:40:39 +03:00
parent 76c9339453
commit 138881dab8
4 changed files with 9 additions and 2 deletions

View file

@ -3,6 +3,7 @@ from data.database import UseThenDisconnect
from workers.gc.models_pre_oci import pre_oci_model as model from workers.gc.models_pre_oci import pre_oci_model as model
from workers.worker import Worker from workers.worker import Worker
class GarbageCollectionWorker(Worker): class GarbageCollectionWorker(Worker):
def __init__(self): def __init__(self):
super(GarbageCollectionWorker, self).__init__() super(GarbageCollectionWorker, self).__init__()
@ -14,6 +15,7 @@ class GarbageCollectionWorker(Worker):
with UseThenDisconnect(app.config): with UseThenDisconnect(app.config):
model.perform_garbage_collection() model.perform_garbage_collection()
if __name__ == "__main__": if __name__ == "__main__":
worker = GarbageCollectionWorker() worker = GarbageCollectionWorker()
worker.start() worker.start()

View file

@ -2,11 +2,13 @@ from abc import ABCMeta, abstractmethod
from six import add_metaclass from six import add_metaclass
@add_metaclass(ABCMeta) @add_metaclass(ABCMeta)
class GCWorkerDataInterface(object): class GCWorkerDataInterface(object):
""" """
Interface that represents all data store interactions required by the GC worker. Interface that represents all data store interactions required by the GC worker.
""" """
@abstractmethod @abstractmethod
def perform_garbage_collection(self): def perform_garbage_collection(self):
""" Performs garbage collection on a single repository, if any can be found with garbage. """ """ Performs garbage collection on a single repository, if any can be found with garbage. """

View file

@ -1,12 +1,13 @@
import logging import logging
from data.model.repository import (find_repository_with_garbage, garbage_collect_repo, from data.model.repository import (
get_random_gc_policy) find_repository_with_garbage, garbage_collect_repo, get_random_gc_policy)
from workers.gc.models_interface import GCWorkerDataInterface from workers.gc.models_interface import GCWorkerDataInterface
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
class PreOCIModel(GCWorkerDataInterface): class PreOCIModel(GCWorkerDataInterface):
def perform_garbage_collection(self): def perform_garbage_collection(self):
repository = find_repository_with_garbage(get_random_gc_policy()) repository = find_repository_with_garbage(get_random_gc_policy())
@ -18,4 +19,5 @@ class PreOCIModel(GCWorkerDataInterface):
garbage_collect_repo(repository) garbage_collect_repo(repository)
logger.debug('Finished GC of repository #%s (%s)', repository.id, repository.name) logger.debug('Finished GC of repository #%s (%s)', repository.id, repository.name)
pre_oci_model = PreOCIModel() pre_oci_model = PreOCIModel()

View file

@ -2,6 +2,7 @@ from workers.gc.gcworker import GarbageCollectionWorker
from test.fixtures import * from test.fixtures import *
def test_gc(initialized_db): def test_gc(initialized_db):
worker = GarbageCollectionWorker() worker = GarbageCollectionWorker()
worker._garbage_collection_repos() worker._garbage_collection_repos()