From 038d7febb7224b9088ef628bee16b3c54ebf98ed Mon Sep 17 00:00:00 2001 From: Diane Trout Date: Wed, 6 Apr 2011 13:49:26 -0700 Subject: [PATCH] django-nose didn't work with django 1.1, so I went back to the nose plugin NoseDjango I needed to move the settings file around a bit so the default build of nosedjango will find it (instead of my previously hacked copy). I got tired of modifying the location of the settings files and discovered that django has a standardized way of grabbign the config file. with "from django.conf import settings", though that will only show uppercased config entries. --- extra/fix_ob3.py | 2 +- htsworkflow/frontend/analysis/main.py | 9 ++++++--- htsworkflow/frontend/analysis/models.py | 2 +- htsworkflow/frontend/auth.py | 3 +-- htsworkflow/frontend/bcmagic/utils.py | 4 ++-- htsworkflow/frontend/eland_config/views.py | 2 +- htsworkflow/frontend/experiments/experiments.py | 2 +- htsworkflow/frontend/experiments/models.py | 5 +++-- htsworkflow/frontend/experiments/tests.py | 2 ++ htsworkflow/frontend/inventory/views.py | 5 ++--- htsworkflow/frontend/reports/libinfopar.py | 2 +- htsworkflow/frontend/samples/models.py | 1 - htsworkflow/frontend/samples/results.py | 2 +- htsworkflow/frontend/samples/views.py | 2 +- htsworkflow/frontend/urls.py | 2 +- scripts/htsw-record-runfolder | 7 ++++--- htsworkflow/settings.py => settings.py | 6 +++--- 17 files changed, 31 insertions(+), 27 deletions(-) rename htsworkflow/settings.py => settings.py (97%) diff --git a/extra/fix_ob3.py b/extra/fix_ob3.py index 1278901..9955f69 100644 --- a/extra/fix_ob3.py +++ b/extra/fix_ob3.py @@ -7,7 +7,7 @@ import re import sys from django.core.management import setup_environ -from htsworkflow.frontend import settings +from django.conf import settings setup_environ(settings) import htsworkflow.frontend.samples.models as samples diff --git a/htsworkflow/frontend/analysis/main.py b/htsworkflow/frontend/analysis/main.py index b57ad20..ba2a739 100644 --- a/htsworkflow/frontend/analysis/main.py +++ b/htsworkflow/frontend/analysis/main.py @@ -1,11 +1,14 @@ # some core functions of analysis manager module -from django.http import HttpResponse + from datetime import datetime from string import * import re -from htsworkflow.frontend import settings -from htsworkflow.frontend.analysis.models import Task, Project + +from django.conf import settings from django.core.exceptions import ObjectDoesNotExist +from django.http import HttpResponse + +from htsworkflow.frontend.analysis.models import Task, Project def updStatus(request): ClIP = request.META['REMOTE_ADDR'] diff --git a/htsworkflow/frontend/analysis/models.py b/htsworkflow/frontend/analysis/models.py index 41ecf42..5a580e0 100644 --- a/htsworkflow/frontend/analysis/models.py +++ b/htsworkflow/frontend/analysis/models.py @@ -1,6 +1,6 @@ from django.db import models +from django.conf import settings from datetime import datetime -from htsworkflow.frontend import settings from htsworkflow.frontend.samples.models import Library from string import * diff --git a/htsworkflow/frontend/auth.py b/htsworkflow/frontend/auth.py index 4df771b..31650a6 100644 --- a/htsworkflow/frontend/auth.py +++ b/htsworkflow/frontend/auth.py @@ -2,8 +2,7 @@ Define some alternate authentication methods """ from django.core.exceptions import PermissionDenied - -from htsworkflow.frontend import settings +from django.conf import settings apidata = {'apiid': u'0', 'apikey': settings.DEFAULT_API_KEY} diff --git a/htsworkflow/frontend/bcmagic/utils.py b/htsworkflow/frontend/bcmagic/utils.py index e7d89d3..78919b0 100644 --- a/htsworkflow/frontend/bcmagic/utils.py +++ b/htsworkflow/frontend/bcmagic/utils.py @@ -1,4 +1,4 @@ -from htsworkflow.frontend import settings +from django.conf import settings import ftplib import socket @@ -53,4 +53,4 @@ def autofill(field, value): Return a bcm dictionary with a command to automatically fill the corresponding "field" with "value" """ - return {'mode': 'autofill', 'field': field, 'value': value} \ No newline at end of file + return {'mode': 'autofill', 'field': field, 'value': value} diff --git a/htsworkflow/frontend/eland_config/views.py b/htsworkflow/frontend/eland_config/views.py index 6169f8a..d21f86b 100644 --- a/htsworkflow/frontend/eland_config/views.py +++ b/htsworkflow/frontend/eland_config/views.py @@ -1,9 +1,9 @@ +from django.conf import settings from django.http import HttpResponse from django.shortcuts import render_to_response from django.core.exceptions import ObjectDoesNotExist from htsworkflow.frontend.eland_config import forms -from htsworkflow.frontend import settings from htsworkflow.frontend.experiments import models import os diff --git a/htsworkflow/frontend/experiments/experiments.py b/htsworkflow/frontend/experiments/experiments.py index 882ea89..5dec8cf 100755 --- a/htsworkflow/frontend/experiments/experiments.py +++ b/htsworkflow/frontend/experiments/experiments.py @@ -12,9 +12,9 @@ from django.contrib.auth.decorators import login_required from django.core.exceptions import ObjectDoesNotExist from django.core.mail import send_mail, mail_admins from django.http import HttpResponse, Http404 +from django.conf import settings from htsworkflow.frontend.auth import require_api_key -from htsworkflow.frontend import settings from htsworkflow.frontend.experiments.models import \ FlowCell, \ DataRun, \ diff --git a/htsworkflow/frontend/experiments/models.py b/htsworkflow/frontend/experiments/models.py index 10599e2..8a71e25 100755 --- a/htsworkflow/frontend/experiments/models.py +++ b/htsworkflow/frontend/experiments/models.py @@ -5,7 +5,8 @@ from django.core import urlresolvers from django.db import models from htsworkflow.frontend.samples.models import * -from htsworkflow.frontend.settings import options +#from htsworkflow.frontend.settings import options +from django.conf import settings class ClusterStation(models.Model): name = models.CharField(max_length=50, unique=True) @@ -21,7 +22,7 @@ class Sequencer(models.Model): default_pM = 5 try: - default_pM = int(options.get('frontend', 'default_pm')) + default_pM = int(settings.DEFAULT_PM) except ValueError,e: logging.error("invalid value for frontend.default_pm") diff --git a/htsworkflow/frontend/experiments/tests.py b/htsworkflow/frontend/experiments/tests.py index 9088b46..7bfebfe 100644 --- a/htsworkflow/frontend/experiments/tests.py +++ b/htsworkflow/frontend/experiments/tests.py @@ -4,6 +4,7 @@ try: import json except ImportError, e: import simplejson as json +import os import sys from django.core import mail @@ -206,3 +207,4 @@ class TestEmailNotify(TestCase): # require that navigation back to the admin page exists self.failUnless(re.search('[^<]+', response.content)) + diff --git a/htsworkflow/frontend/inventory/views.py b/htsworkflow/frontend/inventory/views.py index dfb92a9..69848cc 100644 --- a/htsworkflow/frontend/inventory/views.py +++ b/htsworkflow/frontend/inventory/views.py @@ -5,15 +5,14 @@ from htsworkflow.frontend.bcmagic.plugin import register_search_plugin from htsworkflow.frontend.experiments.models import FlowCell from htsworkflow.frontend.bcmagic.forms import BarcodeMagicForm from htsworkflow.frontend.bcmagic.utils import print_zpl_socket -from htsworkflow.frontend import settings -#from htsworkflow.util.jsonutil import encode_json +from django.conf import settings +from django.contrib.auth.decorators import login_required from django.core.exceptions import ObjectDoesNotExist from django.http import HttpResponse, HttpResponseRedirect from django.shortcuts import render_to_response from django.template import RequestContext, Template from django.template.loader import get_template -from django.contrib.auth.decorators import login_required register_search_plugin('Inventory Item', item_search) diff --git a/htsworkflow/frontend/reports/libinfopar.py b/htsworkflow/frontend/reports/libinfopar.py index 954fce6..73072af 100644 --- a/htsworkflow/frontend/reports/libinfopar.py +++ b/htsworkflow/frontend/reports/libinfopar.py @@ -1,4 +1,4 @@ -from htsworkflow.frontend import settings +from django.conf import settings from django.http import HttpResponse from datetime import datetime from string import * diff --git a/htsworkflow/frontend/samples/models.py b/htsworkflow/frontend/samples/models.py index a8201c9..aac0ff6 100644 --- a/htsworkflow/frontend/samples/models.py +++ b/htsworkflow/frontend/samples/models.py @@ -4,7 +4,6 @@ from django.db import models from django.contrib.auth.models import User, UserManager from django.db.models.signals import pre_save, post_save from django.db import connection -from htsworkflow.frontend import settings from htsworkflow.frontend.reports.libinfopar import * diff --git a/htsworkflow/frontend/samples/results.py b/htsworkflow/frontend/samples/results.py index 39797b1..3c6543a 100644 --- a/htsworkflow/frontend/samples/results.py +++ b/htsworkflow/frontend/samples/results.py @@ -1,4 +1,4 @@ -from htsworkflow.frontend import settings +from django.conf import settings import glob import os diff --git a/htsworkflow/frontend/samples/views.py b/htsworkflow/frontend/samples/views.py index c96b718..2bbcc89 100644 --- a/htsworkflow/frontend/samples/views.py +++ b/htsworkflow/frontend/samples/views.py @@ -18,7 +18,6 @@ from htsworkflow.frontend.bcmagic.forms import BarcodeMagicForm from htsworkflow.pipelines.runfolder import load_pipeline_run_xml from htsworkflow.pipelines import runfolder from htsworkflow.pipelines.eland import ResultLane -from htsworkflow.frontend import settings from htsworkflow.util.conversion import unicode_or_none from htsworkflow.util import makebed from htsworkflow.util import opener @@ -30,6 +29,7 @@ from django.shortcuts import render_to_response, get_object_or_404 from django.template import RequestContext from django.template.loader import get_template from django.contrib.auth.decorators import login_required +from django.conf import settings LANE_LIST = [1,2,3,4,5,6,7,8] SAMPLES_CONTEXT_DEFAULTS = { diff --git a/htsworkflow/frontend/urls.py b/htsworkflow/frontend/urls.py index c9ce79b..8cdb82c 100644 --- a/htsworkflow/frontend/urls.py +++ b/htsworkflow/frontend/urls.py @@ -9,7 +9,7 @@ admin.autodiscover() #databrowse.site.register(Library) #databrowse.site.register(FlowCell) -from htsworkflow.frontend import settings +from django.conf import settings urlpatterns = patterns('', diff --git a/scripts/htsw-record-runfolder b/scripts/htsw-record-runfolder index 288ec1a..42bb614 100755 --- a/scripts/htsw-record-runfolder +++ b/scripts/htsw-record-runfolder @@ -1,8 +1,5 @@ #!/usr/bin/env python -from htsworkflow.util.hdquery import get_hd_serial_num -from htsworkflow.frontend import settings - from optparse import OptionParser import os import re @@ -10,6 +7,10 @@ import sys import urllib2 import urlparse +from django.conf import settings + +from htsworkflow.util.hdquery import get_hd_serial_num + runfolder_pattern = re.compile(r'[0-9]{6}_[-A-Za-z\d]+_\d+_(?P[A-Z\d]+)\.tgz') def extract_flowcell(runfolder_name): diff --git a/htsworkflow/settings.py b/settings.py similarity index 97% rename from htsworkflow/settings.py rename to settings.py index 9569d3e..0f2d4da 100644 --- a/htsworkflow/settings.py +++ b/settings.py @@ -169,7 +169,8 @@ TEMPLATE_DIRS = ( # Don't forget to use absolute paths, not relative paths. '/usr/share/python-support/python-django/django/contrib/admin/templates', #'/usr/lib/pymodules/python2.6/django/contrib/admin/templates/', - os.path.join(os.path.split(__file__)[0], 'frontend','templates'), + os.path.join(os.path.split(__file__)[0], + 'htsworkflow', 'frontend','templates'), ) INSTALLED_APPS = ( @@ -179,7 +180,6 @@ INSTALLED_APPS = ( 'django.contrib.humanize', 'django.contrib.sessions', 'django.contrib.sites', - 'django_nose', 'htsworkflow.frontend.eland_config', 'htsworkflow.frontend.samples', # modules from htsworkflow branch @@ -216,4 +216,4 @@ BCPRINTER_PRINTER1_PORT = int(options.get('bcprinter', 'printer1_port')) BCPRINTER_PRINTER2_HOST = options.get('bcprinter', 'printer2_host') BCPRINTER_PRINTER2_PORT = int(options.get('bcprinter', 'printer2_port')) -TEST_RUNNER='django_nose.NoseTestSuiteRunner' +DEFAULT_PM=int(options.get('frontend', 'default_pm')) -- 2.30.2