diff --git a/freezer_ui/api/api.py b/freezer_ui/api/api.py index 6c05eaf..85d7e02 100644 --- a/freezer_ui/api/api.py +++ b/freezer_ui/api/api.py @@ -14,10 +14,9 @@ # from horizon. -import warnings +import logging from django.conf import settings -from django.utils.translation import ugettext_lazy as _ from horizon.utils import functions as utils from horizon.utils.memoized import memoized # noqa @@ -35,15 +34,18 @@ from freezer_ui.utils import create_dummy_id from freezer_ui.utils import assign_value_from_source +LOG = logging.getLogger(__name__) + + @memoized def get_hardcoded_url(): """Get FREEZER_API_URL from local_settings.py""" try: - warnings.warn(_('Using hardcoded FREEZER_API_URL at {0}') - .format(settings.FREEZER_API_URL)) + LOG.warn('Using hardcoded FREEZER_API_URL at {0}' + .format(settings.FREEZER_API_URL)) return getattr(settings, 'FREEZER_API_URL', None) except (AttributeError, TypeError): - warnings.warn(_('No FREEZER_API_URL was found in local_settings.py')) + LOG.warn('No FREEZER_API_URL was found in local_settings.py') raise diff --git a/freezer_ui/backups/tables.py b/freezer_ui/backups/tables.py index 620b079..074ef88 100644 --- a/freezer_ui/backups/tables.py +++ b/freezer_ui/backups/tables.py @@ -10,6 +10,7 @@ # License for the specific language governing permissions and limitations # under the License. +import logging from django.core.urlresolvers import reverse from django.utils import safestring @@ -19,6 +20,9 @@ from horizon import tables from freezer_ui.utils import timestamp_to_string +LOG = logging.getLogger(__name__) + + class Restore(tables.LinkAction): name = "restore" verbose_name = _("Restore") diff --git a/freezer_ui/backups/views.py b/freezer_ui/backups/views.py index 159431c..28ace53 100644 --- a/freezer_ui/backups/views.py +++ b/freezer_ui/backups/views.py @@ -10,6 +10,7 @@ # License for the specific language governing permissions and limitations # under the License. +import logging import datetime import pprint @@ -27,6 +28,9 @@ from freezer_ui.backups.workflows import restore as restore_workflow import freezer_ui.api.api as freezer_api +LOG = logging.getLogger(__name__) + + class IndexView(tables.DataTableView): name = _("Backups") slug = "backups" @@ -42,7 +46,6 @@ class DetailView(generic.TemplateView): template_name = 'freezer_ui/backups/detail.html' def get_context_data(self, **kwargs): - backup = freezer_api.backup_get(self.request, kwargs['backup_id']) return {'data': pprint.pformat(backup.data_dict)} diff --git a/freezer_ui/backups/workflows/restore.py b/freezer_ui/backups/workflows/restore.py index c84a387..b29028f 100644 --- a/freezer_ui/backups/workflows/restore.py +++ b/freezer_ui/backups/workflows/restore.py @@ -11,6 +11,8 @@ # under the License. +import logging + from django.core.exceptions import ValidationError from django.utils.translation import ugettext_lazy as _ @@ -21,6 +23,9 @@ from horizon import workflows import freezer_ui.api.api as freezer_api +LOG = logging.getLogger(__name__) + + class DestinationAction(workflows.MembershipAction): path = forms.CharField(label=_("Destination Path"), help_text=_("The path in which the backup should be" diff --git a/freezer_ui/jobs/tables.py b/freezer_ui/jobs/tables.py index 3d2e995..06418eb 100644 --- a/freezer_ui/jobs/tables.py +++ b/freezer_ui/jobs/tables.py @@ -10,6 +10,7 @@ # License for the specific language governing permissions and limitations # under the License. +import logging import datetime from django import shortcuts from django.utils import safestring @@ -24,6 +25,9 @@ import freezer_ui.api.api as freezer_api from freezer_ui.utils import timestamp_to_string +LOG = logging.getLogger(__name__) + + def format_last_backup(last_backup): last_backup_ts = datetime.datetime.fromtimestamp(last_backup) ten_days_later = last_backup_ts + datetime.timedelta(days=10) diff --git a/freezer_ui/jobs/views.py b/freezer_ui/jobs/views.py index e8fe73d..fb0022c 100644 --- a/freezer_ui/jobs/views.py +++ b/freezer_ui/jobs/views.py @@ -10,6 +10,8 @@ # License for the specific language governing permissions and limitations # under the License. +import logging + from django.core.urlresolvers import reverse from django.utils.translation import ugettext_lazy as _ from django.core.urlresolvers import reverse_lazy @@ -26,6 +28,9 @@ import workflows.configure as configure_workflow import workflows.action as action_workflow +LOG = logging.getLogger(__name__) + + class JobWorkflowView(workflows.WorkflowView): workflow_class = configure_workflow.ConfigureJob diff --git a/freezer_ui/jobs/workflows/action.py b/freezer_ui/jobs/workflows/action.py index 74797ac..8e131d6 100644 --- a/freezer_ui/jobs/workflows/action.py +++ b/freezer_ui/jobs/workflows/action.py @@ -10,6 +10,8 @@ # License for the specific language governing permissions and limitations # under the License. +import logging + from django.utils.translation import ugettext_lazy as _ from horizon import workflows from horizon import exceptions @@ -17,6 +19,9 @@ from horizon import forms import freezer_ui.api.api as freezer_api +LOG = logging.getLogger(__name__) + + class ActionConfigurationAction(workflows.Action): action = forms.ChoiceField( help_text=_("Set the action to be taken"), diff --git a/freezer_ui/jobs/workflows/configure.py b/freezer_ui/jobs/workflows/configure.py index 34c6f14..d9542aa 100644 --- a/freezer_ui/jobs/workflows/configure.py +++ b/freezer_ui/jobs/workflows/configure.py @@ -10,6 +10,8 @@ # License for the specific language governing permissions and limitations # under the License. +import logging + from collections import namedtuple import datetime @@ -24,6 +26,9 @@ import freezer_ui.api.api as freezer_api from freezer_ui.utils import actions_in_job +LOG = logging.getLogger(__name__) + + class ActionsConfigurationAction(workflows.Action): pass diff --git a/freezer_ui/sessions/tables.py b/freezer_ui/sessions/tables.py index 0032c10..69e8878 100644 --- a/freezer_ui/sessions/tables.py +++ b/freezer_ui/sessions/tables.py @@ -10,6 +10,7 @@ # License for the specific language governing permissions and limitations # under the License. +import logging from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ungettext_lazy @@ -20,6 +21,9 @@ from horizon.utils.urlresolvers import reverse import freezer_ui.api.api as freezer_api +LOG = logging.getLogger(__name__) + + def get_link(session): return reverse('horizon:freezer_ui:sessions:index', kwargs={'session_id': session.session_id}) diff --git a/freezer_ui/sessions/views.py b/freezer_ui/sessions/views.py index 7771add..7c18efa 100644 --- a/freezer_ui/sessions/views.py +++ b/freezer_ui/sessions/views.py @@ -10,6 +10,7 @@ # License for the specific language governing permissions and limitations # under the License. +import logging from django.core.urlresolvers import reverse from django.utils.translation import ugettext_lazy as _ @@ -25,6 +26,9 @@ import freezer_ui.api.api as freezer_api from freezer_ui.utils import SessionJob +LOG = logging.getLogger(__name__) + + class AttachToSessionWorkflow(workflows.WorkflowView): workflow_class = attach.AttachJobToSession diff --git a/freezer_ui/sessions/workflows/attach.py b/freezer_ui/sessions/workflows/attach.py index 04fbf97..56ff2f1 100644 --- a/freezer_ui/sessions/workflows/attach.py +++ b/freezer_ui/sessions/workflows/attach.py @@ -10,6 +10,8 @@ # License for the specific language governing permissions and limitations # under the License. +import logging + from django.utils.translation import ugettext_lazy as _ from horizon import exceptions @@ -19,6 +21,9 @@ from horizon import workflows import freezer_ui.api.api as freezer_api +LOG = logging.getLogger(__name__) + + class SessionConfigurationAction(workflows.Action): session_id = forms.ChoiceField( help_text=_("Set a session to attach this job"), diff --git a/freezer_ui/sessions/workflows/create_session.py b/freezer_ui/sessions/workflows/create_session.py index 20f611f..7036af8 100644 --- a/freezer_ui/sessions/workflows/create_session.py +++ b/freezer_ui/sessions/workflows/create_session.py @@ -10,6 +10,7 @@ # License for the specific language governing permissions and limitations # under the License. +import logging import datetime from django.utils.translation import ugettext_lazy as _ @@ -21,6 +22,9 @@ from horizon import workflows import freezer_ui.api.api as freezer_api +LOG = logging.getLogger(__name__) + + class SessionConfigurationAction(workflows.Action): description = forms.CharField( label=_("Session Name"),