def setup(): logging.info("Celery user: %s" % getpass.getuser()) logging.info("DJANGO_SETTINGS_MODULE: %s" % os.environ.get('DJANGO_SETTINGS_MODULE', 'NOT-SET')) # Show a debugging info on console logging.debug("__file__ = %s", __file__) logging.debug("sys.version = %s", sys.version) logging.debug("os.getpid() = %s", os.getpid()) logging.debug("os.getcwd() = %s", os.getcwd()) logging.debug("os.curdir = %s", os.curdir) logging.debug("sys.path:\n\t%s", "\n\t".join(sys.path)) logging.debug("PYTHONPATH:\n\t%s", "\n\t".join(os.environ.get('PYTHONPATH', "").split(';'))) logging.debug("sys.modules.keys() = %s", repr(sys.modules.keys())) logging.debug("sys.modules.has_key('website') = %s", 'website' in sys.modules) if 'website' in sys.modules: logging.debug("sys.modules['website'].__name__ = %s", sys.modules['website'].__name__) logging.debug("sys.modules['website'].__file__ = %s", sys.modules['website'].__file__) from django.conf import settings # noqa F402 F403 isort:skip import django # noqa F402 F403 isort:skip django.setup() logging.debug("settings.__dir__: %s", settings.__dir__()) logging.debug("settings.DEBUG: %s", settings.DEBUG)
def invited(request, invitation_key=None): if 'INVITE_MODE' in settings.__dir__() and settings.INVITE_MODE: if invitation_key and is_key_valid(invitation_key): return HttpResponseRedirect(reverse('registration_register')) #template = 'registration/registration_form.html' #return direct_to_template(request, template, {'backend': 'registration.backends.credis.DefaultBackend', 'form_class':main.forms.CredisRegistrationForm}) else: template = 'invitation/wrong_invitation_key.html' return direct_to_template(request, template, {'invitation_key': invitation_key,'expiration_days':settings.ACCOUNT_INVITATION_DAYS}) else: template = 'invitation/invitation_closed.html' return direct_to_template(request, template)
def run(): # pragma: no cover assert 'DJANGO_SETTINGS_MODULE' in os.environ, "DJANGO_SETTINGS_MODULE is missing from environment, you must set if before running this worker" logging.info("os.environ['DJANGO_SETTINGS_MODULE']: %s" % os.environ['DJANGO_SETTINGS_MODULE']) cwd = os.getcwd() if cwd not in sys.path: # pragma: no cover sys.path.append(cwd) # Show a debugging info on console logging.debug("__file__ = %s", __file__) logging.debug("sys.version = %s", sys.version) logging.debug("os.getpid() = %s", os.getpid()) logging.debug("os.getcwd() = %s", cwd) logging.debug("os.curdir = %s", os.curdir) logging.debug("sys.path:\n\t%s", "\n\t".join(sys.path)) logging.debug("PYTHONPATH:\n\t%s", "\n\t".join(os.environ.get('PYTHONPATH', "").split(';'))) logging.debug("sys.modules.keys() = %s", repr(sys.modules.keys())) logging.debug("sys.modules.has_key('website') = %s", 'website' in sys.modules) from django.conf import settings import django django.setup() logging.debug("settings.__dir__: %s", settings.__dir__()) logging.debug("settings.DEBUG: %s", settings.DEBUG) from django_multiinfo.models import SmsMessage while True: more = SmsMessage.send_queued(10) seconds = settings.EMAIL_QUEUE_SLEEP_TIME logging.debug("Will sleep for %s seconds", seconds) if not more: sleep(seconds)
if cwd not in sys.path: # pragma: no cover sys.path.append(cwd) # Show a debugging info on console log.debug("__file__ = %s", __file__) log.debug("sys.version = %s", sys.version) log.debug("os.getpid() = %s", os.getpid()) log.debug("os.getcwd() = %s", cwd) log.debug("os.curdir = %s", os.curdir) log.debug("sys.path:\n\t%s", "\n\t".join(sys.path)) log.debug("PYTHONPATH:\n\t%s", "\n\t".join(os.environ.get('PYTHONPATH', "").split(';'))) log.debug("sys.modules.keys() = %s", repr(sys.modules.keys())) log.debug("sys.modules.has_key('website') = %s", 'website' in sys.modules) from django.conf import settings import django django.setup() log.debug("settings.__dir__: %s", settings.__dir__()) log.debug("settings.DEBUG: %s", settings.DEBUG) def main(argv=sys.argv[1:]): # pragma: no cover from .models import TaskWorker TaskWorker.run_queues(argv) if __name__ == '__main__': # pragma: no cover main()
logging.debug("os.getpid() = %s", os.getpid()) logging.debug("os.getcwd() = %s", os.getcwd()) logging.debug("os.curdir = %s", os.curdir) logging.debug("sys.path:\n\t%s", "\n\t".join(sys.path)) logging.debug("PYTHONPATH:\n\t%s", "\n\t".join(os.environ.get('PYTHONPATH', "").split(';'))) logging.debug("sys.modules.keys() = %s", repr(sys.modules.keys())) logging.debug("sys.modules.has_key('website') = %s", 'website' in sys.modules) if 'website' in sys.modules: logging.debug("sys.modules['website'].__name__ = %s", sys.modules['website'].__name__) logging.debug("sys.modules['website'].__file__ = %s", sys.modules['website'].__file__) logging.debug("os.environ['DJANGO_SETTINGS_MODULE']= %s", os.environ.get('DJANGO_SETTINGS_MODULE', None)) from django.conf import settings settings._setup() logging.debug("settings.__dir__: %s", settings.__dir__()) logging.debug("settings.DEBUG: %s", settings.DEBUG) # Using Celery with Django # http://docs.celeryproject.org/en/latest/django/first-steps-with-django.html#using-celery-with-django # set the default Django settings module for the 'celery' program. app = Celery('website.celery') # Using a string here means the worker will not have to # pickle the object when using Windows. app.config_from_object('django.conf:settings') app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)
(r'^reports/(\d+)/flags/thanks', 'thanks'), (r'^reports/(\d+)/flags', 'new'), ) urlpatterns += patterns('mainapp.views.reports.main', (r'^reports/(\d+)$', 'show'), (r'^reports/', 'new'), ) urlpatterns += patterns('mainapp.views.contact', (r'^contact/thanks', 'thanks'), (r'^contact', 'new', {}, 'contact_url_name'), ) urlpatterns += patterns('mainapp.views.ajax', (r'^ajax/categories/(\d+)', 'category_desc'), ) if settings.DEBUG and 'TESTVIEW' in settings.__dir__(): urlpatterns += patterns ('', (r'^testview',include('django_testview.urls'))) #The following is used to serve up local media files like images if settings.LOCAL_DEV: baseurlregex = r'^media/(?P<path>.*)$' urlpatterns += patterns('', (baseurlregex, 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}), )