Skip to content
This repository has been archived by the owner on Aug 31, 2020. It is now read-only.

Commit

Permalink
#40 move and store data to one directory - use for custom storage
Browse files Browse the repository at this point in the history
  • Loading branch information
Pajinek committed Nov 19, 2015
1 parent 86417f6 commit 571115a
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 21 deletions.
2 changes: 1 addition & 1 deletion apps/core/management/commands/beaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from apps.core.utils.beaker import Beaker
from apps.taskomatic.models import TaskPeriod, TaskPeriodSchedule

logger = logging.getLogger(__name__)
logger = logging.getLogger("main")


class Command(AdvancedCommand):
Expand Down
2 changes: 1 addition & 1 deletion apps/core/management/commands/check_beaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from apps.core.utils.beaker import Beaker
from apps.core.utils.date_helpers import currentDate

logger = logging.getLogger(__name__)
logger = logging.getLogger("main")


class Command(BaseCommand):
Expand Down
6 changes: 5 additions & 1 deletion apps/core/management/commands/checkrepo.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@
# Date: 20.07.2014

import logging
import os

from django.conf import settings
from django.core.management.base import BaseCommand

from apps.core.models import Git

logger = logging.getLogger(__name__)
logger = logging.getLogger("main")


class Command(BaseCommand):
Expand All @@ -38,6 +39,9 @@ def handle(self, *args, **kwargs):
for repo in settings.REPOSITORIES_GIT[path]:
if len(repos) > 0 and repo not in repos:
continue
if not os.path.exists("%s%s" % (path, repo)):
logger.error("repo %s doesn't exists in %s" % (repo, path))
continue
git = Git.getGitFromFolder("%s%s" % (path, repo))
git.log = logger
if git:
Expand Down
2 changes: 1 addition & 1 deletion apps/core/management/commands/schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from apps.core.utils.beaker import Beaker
from apps.taskomatic.models import TaskPeriodSchedule

logger = logging.getLogger(__name__)
logger = logging.getLogger("main")


class Command(BaseCommand):
Expand Down
9 changes: 5 additions & 4 deletions apps/core/utils/beaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def generateXmlFile(self, jobT, filename, reserve=False):
if filename.startswith('/'):
tmp_path = filename
else:
tmp_path = "%s/data/xmls/%s" % (settings.ROOT_PATH, filename)
tmp_path = "%s/xmls/%s" % (settings.STORAGE_ROOT, filename)
tmp_path = re.sub(r'//+', '/', tmp_path)
tmp_dir = os.path.dirname(tmp_path)
if not os.path.exists(tmp_dir):
Expand Down Expand Up @@ -225,19 +225,20 @@ def parse_job(self, jobid, running=True, date_created=None):

def listLogs(self, recipe):
#client = self._getXMLRPCClient()
#return client.recipes.files(int(recipe))
# return client.recipes.files(int(recipe))
raw, status = self.execute("job-logs", recipe)
return raw.split()

def downloadLog(self, logurl):
logparse = urlparse(logurl)
logpath = os.path.join(settings.MEDIA_ROOT, *(urlparse(logurl).path.split("/")))
logpath = os.path.join(
settings.STORAGE_ROOT, *(urlparse(logurl).path.split("/")))
logdir = os.path.dirname(logpath)
if not os.path.exists(logdir):
os.makedirs(logdir)
rawfile = urllib2.urlopen(logurl)
logger.debug("download logfile: %s" % logurl)
of = open(logpath,'wb')
of = open(logpath, 'wb')
of.write(rawfile.read())
of.close()

Expand Down
10 changes: 3 additions & 7 deletions apps/core/views/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import hashlib
import logging
import sys
from copy import copy
from datetime import datetime, timedelta

Expand All @@ -16,16 +15,13 @@

from apps.core.forms import FilterForm
from apps.core.models import (RESULT_CHOICES, Author, CheckProgress, Event,
JobTemplate, Recipe, RecipeTemplate, render_label)
JobTemplate, Recipe, render_label)
from apps.taskomatic.models import TaskPeriodSchedule
from apps.waiver.forms import WaiverForm
from apps.waiver.models import Comment
from base import create_matrix

if sys.version_info < (2, 7):
from ordereddict import OrderedDict
else:
from collections import OrderedDict
from collections import OrderedDict

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -233,7 +229,7 @@ def render_to_response(self, context, **response_kwargs):
context, **response_kwargs)

def prepare_matrix(self, jobs, recipes, label=None):
data, reschedule = OrderedDict(), 0
data = OrderedDict()
if not label:
label = create_matrix(settings.PREVIOUS_DAYS)
for job in jobs:
Expand Down
2 changes: 1 addition & 1 deletion apps/taskomatic/management/commands/pickup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

class Command(BaseCommand):
help = ('Automatization for running task')
requires_model_validation = True
requires_system_checks = True
can_import_settings = True

def handle(self, *args, **kwargs):
Expand Down
4 changes: 2 additions & 2 deletions apps/taskomatic/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ def __unicode__(self):
return "[%d] %s" % (self.counter, self.title)

def recount(self):
it.counter = TaskPeriodSchedule.object.filter(
self.counter = TaskPeriodSchedule.object.filter(
period=self.period).count()
it.save()
self.save()


class TaskPeriod(models.Model):
Expand Down
22 changes: 19 additions & 3 deletions tttt/settings/basic.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Django settings for tttt project.

import os

from django.conf import global_settings

ROOT_PATH = os.path.abspath("%s/%s/" %
Expand Down Expand Up @@ -80,6 +79,8 @@
# Example: "/home/media/media.lawrence.com/static/"
STATIC_ROOT = "%s/tttt/%s/" % (ROOT_PATH, 'static')

STORAGE_ROOT = "%s/%s/" % (ROOT_PATH, 'storage')

# URL prefix for static files.
# Example: "http://media.lawrence.com/static/"
STATIC_URL = '/static/'
Expand Down Expand Up @@ -210,19 +211,34 @@
'()': 'django.utils.log.RequireDebugFalse'
}
},
'formatters': {
'simple': {
'format': '%(levelname)s %(message)s'
},
},
'handlers': {
'mail_admins': {
'level': 'ERROR',
'filters': ['require_debug_false'],
'class': 'django.utils.log.AdminEmailHandler'
}
},
'log_to_stdout': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'formatter': 'simple',
},
},
'loggers': {
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True,
},
'main': {
'handlers': ['log_to_stdout'],
'level': 'DEBUG',
'propagate': True,
}
}
}

Expand Down Expand Up @@ -269,7 +285,7 @@
# If you want to change directory with repositories,
# don't forget changed it in /var/www/gitweb/gitweb_config.perl
REPOSITORIES_GIT = {
"~":
"%s/git" % STORAGE_ROOT:
("/tests",),
}

Expand Down

0 comments on commit 571115a

Please sign in to comment.