Navigation Menu

Skip to content

Commit

Permalink
Move cache files to subdirectory 'datacache', fix report loading.gif
Browse files Browse the repository at this point in the history
  • Loading branch information
mgarabed committed Mar 26, 2013
1 parent fe89bab commit 1db36b1
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -4,6 +4,7 @@

widget_data*
*.db
*.data
log.txt

build
Expand Down
4 changes: 2 additions & 2 deletions apps/datasource/datasource/profiler.py
Expand Up @@ -16,7 +16,7 @@

from apps.datasource.models import TableColumn
from apps.datasource.devicemanager import DeviceManager

from project import settings

logger = logging.getLogger('datasource')
lock = threading.Lock()
Expand All @@ -35,7 +35,7 @@ def __init__(self, table, job):
self.job = job

def run(self):
cachefile = "table-%s.cache" % self.table.id
cachefile = os.path.join(settings.DATA_CACHE, "table-%s.cache" % self.table.id)
if os.path.exists(cachefile):
# XXXCJ This cachefile hack is temporary and is only good for testing to avoid actually
# having to run the report every single time.
Expand Down
4 changes: 2 additions & 2 deletions apps/datasource/datasource/shark.py
Expand Up @@ -20,7 +20,7 @@

from apps.datasource.models import TableColumn
from apps.datasource.devicemanager import DeviceManager

from project import settings

logger = logging.getLogger('datasource')
lock = threading.Lock()
Expand All @@ -38,7 +38,7 @@ def __init__(self, table, job):
self.job = job

def run(self):
cachefile = "table-%s.cache" % self.table.id
cachefile = os.path.join(settings.DATA_CACHE, "table-%s.cache" % self.table.id)
if os.path.exists(cachefile):
# XXXCJ This cachefile hack is temporary and is only good for testing to avoid actually
# having to run the report every single time.
Expand Down
5 changes: 4 additions & 1 deletion apps/datasource/models.py
Expand Up @@ -6,6 +6,7 @@
# This software is distributed "AS IS" as set forth in the License.


import os
import sys
import pickle
import logging
Expand All @@ -15,6 +16,8 @@
from django.db import models
from django.core.exceptions import ObjectDoesNotExist

from project import settings

from jsonfield import JSONField

logger = logging.getLogger('datasource')
Expand Down Expand Up @@ -154,7 +157,7 @@ def done(self):
return self.status == Job.COMPLETE or self.status == Job.ERROR

def datafile(self):
return self.handle + ".data"
return os.path.join(settings.DATA_CACHE, self.handle + ".data")

def data(self):
f = open(self.datafile(), "r")
Expand Down
10 changes: 10 additions & 0 deletions apps/report/templates/report.html
Expand Up @@ -42,6 +42,16 @@
});
}
</script>
<style>
.loading-indicator
{
height: 80px;
width: 80px;
background: url( '{{ STATIC_URL }}showLoading/images/loading.gif' );
background-repeat: no-repeat;
background-position: center center;
}
</style>
{% endblock %}

{% block content %}
Expand Down
4 changes: 4 additions & 0 deletions datacache/.gitignore
@@ -0,0 +1,4 @@
# ignore everything in this directory for git
*
# except this file
!.gitignore
1 change: 1 addition & 0 deletions project/settings.py
Expand Up @@ -14,6 +14,7 @@

PORTAL_ROOT = os.path.abspath(os.path.dirname(__file__))
PROJECT_ROOT = os.path.dirname(PORTAL_ROOT)
DATA_CACHE = os.path.join(PROJECT_ROOT, 'datacache')


ADMINS = (
Expand Down
1 change: 0 additions & 1 deletion templates/base.html
Expand Up @@ -71,7 +71,6 @@
</div>
</div>
{% block content %}{% endblock %}
{{ django_version }}
</body>
</html>

0 comments on commit 1db36b1

Please sign in to comment.