diff --git a/cabot/cabotapp/tasks.py b/cabot/cabotapp/tasks.py index f24bbd79b..e748699e6 100644 --- a/cabot/cabotapp/tasks.py +++ b/cabot/cabotapp/tasks.py @@ -99,9 +99,7 @@ def clean_db(days_to_retain=7, batch_size=10000): InstanceStatusSnapshot.objects.filter(id__in=instance_snapshot_ids).delete() # If we reached the batch size on either we need to re-queue to continue cleaning up. - if ( - result_count == batch_size or service_snapshot_count == batch_size or instance_snapshot_count == batch_size - ): + if result_count == batch_size or service_snapshot_count == batch_size or instance_snapshot_count == batch_size: clean_db.apply_async(kwargs={ 'days_to_retain': days_to_retain, 'batch_size': batch_size}, diff --git a/cabot/cabotapp/views.py b/cabot/cabotapp/views.py index 1b8c16113..f847c87ce 100644 --- a/cabot/cabotapp/views.py +++ b/cabot/cabotapp/views.py @@ -264,7 +264,7 @@ class Meta: }), 'text_match': forms.TextInput(attrs={ 'style': 'width: 100%', - 'placeholder': '[Aa]rachnys\s+[Rr]ules', + 'placeholder': r'[Aa]rachnys\s+[Rr]ules', }), 'status_code': forms.TextInput(attrs={ 'style': 'width: 20%', diff --git a/cabot/celery.py b/cabot/celery.py index 6e270ebff..d53a056a5 100644 --- a/cabot/celery.py +++ b/cabot/celery.py @@ -23,6 +23,9 @@ }, 'clean-db': { 'task': 'cabot.cabotapp.tasks.clean_db', + 'kwargs': { + 'days_to_retain': os.environ.get('CABOT_RESULTS_RETENTION_DAYS', 7) + }, 'schedule': timedelta(seconds=60 * 60 * 24), }, } diff --git a/cabot/settings.py b/cabot/settings.py index 187860113..7699138a3 100644 --- a/cabot/settings.py +++ b/cabot/settings.py @@ -164,7 +164,7 @@ COMPRESS_PRECOMPILERS = ( ('text/coffeescript', 'coffee --compile --stdio'), ('text/eco', - 'eco -i TEMPLATES {infile} && cat "$(echo "{infile}" | sed -e "s/\.eco$/.js/g")"'), + r'eco -i TEMPLATES {infile} && cat "$(echo "{infile}" | sed -e "s/\.eco$/.js/g")"'), ('text/less', 'lessc {infile} > {outfile}'), ) diff --git a/conf/default.env b/conf/default.env index fd289b60d..897a7ee25 100644 --- a/conf/default.env +++ b/conf/default.env @@ -7,6 +7,8 @@ DJANGO_SETTINGS_MODULE=cabot.settings LOG_FILE=/dev/null PORT=5001 +CABOT_RESULTS_RETENTION_DAYS=7 + # You shouldn't need to change anything above this line # Base path to include before generated URLs. If not defined, uses `/` diff --git a/conf/development.env.example b/conf/development.env.example index 8a823bd09..77ef2366e 100644 --- a/conf/development.env.example +++ b/conf/development.env.example @@ -7,6 +7,8 @@ DJANGO_SETTINGS_MODULE=cabot.settings LOG_FILE=/dev/null PORT=5001 +CABOT_RESULTS_RETENTION_DAYS=7 + # You shouldn't need to change anything above this line # Base path to include before generated URLs. If not defined, uses `/` diff --git a/conf/production.env.example b/conf/production.env.example index a092faa84..5e14d4cca 100644 --- a/conf/production.env.example +++ b/conf/production.env.example @@ -11,6 +11,9 @@ WWW_SCHEME=http # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name TIME_ZONE=Etc/UTC +## How long to keep test results for +CABOT_RESULTS_RETENTION_DAYS=60 + ## URL of calendar to synchronise rota with CALENDAR_ICAL_URL=http://www.google.com/calendar/ical/example.ics diff --git a/setup.py b/setup.py index 5df0466b6..77e7c0b35 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,10 @@ from os import environ as env import subprocess -from pip.req import parse_requirements +try: # for pip >= 10 + from pip._internal.req import parse_requirements +except ImportError: # for pip <= 9.0.3 + from pip.req import parse_requirements requirements = [str(req.req) for req in parse_requirements('requirements.txt', session=False)] requirements_plugins = [str(req.req) for req in parse_requirements('requirements-plugins.txt', session=False)]