Permalink
Browse files

Removing old apps and legacy code

  • Loading branch information...
1 parent 161a276 commit adadf37892a63ae397be0fcae6f1772b02e7417a @rosarior committed Mar 10, 2011
View
@@ -1,7 +0,0 @@
-# django.wsgi
-import os, sys
-import django.core.handlers.wsgi
-
-sys.path.append(os.path.join(os.path.realpath(os.path.dirname(__file__)), '..'))
-os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
-application = django.core.handlers.wsgi.WSGIHandler()
No changes.
No changes.
@@ -1,70 +0,0 @@
-from django.core.management.base import BaseCommand, CommandError
-from optparse import make_option
-import os
-import sys
-
-class Command(BaseCommand):
- option_list = BaseCommand.option_list + (
- make_option('--dontservestatic',
- action='store_false',
- dest='serve_static',
- default=True,
- help='Do not serve static content. Otherwise static content will be served on http://<same ip>:<port + 1>/static/'),
- )
- help = "Starts a Tornado Web."
- args = '[optional port number, or ipaddr:port]'
-
- sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0)
- sys.stderr = os.fdopen(sys.stderr.fileno(), 'w', 0)
-
- def handle(self, addrport='', *args, **options):
- from django.core.handlers.wsgi import WSGIHandler
- from tornado import httpserver, wsgi, ioloop, web
-
- import django
-
- if args:
- raise CommandError('Usage: runtornado %s' % self.args)
- if not addrport:
- addr = ''
- port = '8000'
- else:
- try:
- addr, port = addrport.split(':')
- except ValueError:
- addr, port = '', addrport
- if not addr:
- addr = '127.0.0.1'
-
- if not port.isdigit():
- raise CommandError("%r is not a valid port number." % port)
-
- quit_command = (sys.platform == 'win32') and 'CTRL-BREAK' or 'CONTROL-C'
-
- def inner_run(serve_static = options['serve_static']):
- from django.conf import settings
-
- print "Validating models..."
- self.validate(display_num_errors=True)
- print "\nDjango version %s, using settings %r" % (django.get_version(), settings.SETTINGS_MODULE)
- print "Server is running at http://%s:%s/" % (addr, port)
- print "Quit the server with %s." % quit_command
- django_application = WSGIHandler()
- django_container = wsgi.WSGIContainer(django_application)
- django_server = httpserver.HTTPServer(django_container)
- django_server.listen(int(port), address=addr)
-
- if serve_static:
- static_address=addr
- static_port=int(port)+1
- settings.SERVE_STATIC_CONTENT=False
- settings.MEDIA_URL = 'http://%s:%s/static/' % (static_address, static_port)
- settings.ADMIN_MEDIA_PREFIX = settings.MEDIA_URL + 'admin_media/'
- static_application = web.Application([], static_path=settings.MEDIA_ROOT)
- static_server = httpserver.HTTPServer(static_application)
- static_server.listen(static_port, address=addr)
-
- ioloop.IOLoop.instance().start()
-
- inner_run()
-
View
@@ -1,18 +0,0 @@
-#
-# Copyright (C) 2010 Roberto Rosario
-# This file is part of descartes-bi.
-#
-# descartes-bi is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# descartes-bi is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with descartes-bi. If not, see <http://www.gnu.org/licenses/>.
-#
-
@@ -1,18 +0,0 @@
-#
-# Copyright (C) 2010 Roberto Rosario
-# This file is part of descartes-bi.
-#
-# descartes-bi is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# descartes-bi is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with descartes-bi. If not, see <http://www.gnu.org/licenses/>.
-#
-
@@ -1,18 +0,0 @@
-#
-# Copyright (C) 2010 Roberto Rosario
-# This file is part of descartes-bi.
-#
-# descartes-bi is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# descartes-bi is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with descartes-bi. If not, see <http://www.gnu.org/licenses/>.
-#
-
@@ -1,117 +0,0 @@
-#
-# Copyright (C) 2010 Roberto Rosario
-# This file is part of descartes-bi.
-#
-# descartes-bi is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# descartes-bi is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with descartes-bi. If not, see <http://www.gnu.org/licenses/>.
-#
-
-import os
-import signal
-
-from optparse import OptionParser, make_option
-from django.core.management.base import BaseCommand
-from django.core.handlers.wsgi import WSGIHandler
-from django.conf import settings
-
-try:
- from cherrypy.wsgiserver import CherryPyWSGIServer
-except ImportError:
- from wsgiserver import CherryPyWSGIServer
-
-DEFAULT_HOST = getattr(settings, "WSGI_HOST", "127.0.0.1")
-DEFAULT_PORT = getattr(settings, "WSGI_PORT", 8000)
-
-class Command(BaseCommand):
- option_list = BaseCommand.option_list + (
- make_option("-h", "--host", dest="host", default="127.0.0.1"),
- make_option("-p", "--port", dest="port", default=8000),
- make_option("-d", "--daemon", dest="daemonize", action="store_true"),
- make_option("-u", "--upgrade", dest="upgrade", action="store_true"),
- )
- requires_model_validation = False
-
- def handle(self, *args, **options):
- self.server = CherryPyWSGIServer((options["host"], options["port"]), WSGIHandler())
- self.pidfile = os.path.join(settings.PROJECT_ROOT, "logs/wsgi.pid")
- try:
- action = args[0]
- except IndexError:
- print "You must provide an action. Possible actions are start, stop and restart."
- raise SystemExit
- if options["daemonize"]:
- daemonize()
- if options["upgrade"]:
- self.server = CherryPyWSGIServer((options["host"], options["port"]), self.upgrade_in_progress)
- if action == "start":
- self.start()
- elif action == "stop":
- pid = open(self.pidfile, "r").read()
- self.stop(pid)
- elif action == "restart":
- pid = open(self.pidfile, "r").read()
- self.restart(pid)
-
- def start(self):
- writepid(self.pidfile)
- try:
- self.server.start()
- except KeyboardInterrupt:
- # likely not a daemon so make sure to shutdown properly.
- self.server.stop()
-
- def stop(self, pid):
- os.kill(int(pid), signal.SIGHUP)
-
- def restart(self, pid):
- self.stop(pid)
- self.start()
-
- def create_parser(self, prog_name, subcommand):
- """
- Create and return the ``OptionParser`` which will be used to
- parse the arguments to this command.
- """
- return OptionParser(prog=prog_name, usage=self.usage(subcommand),
- version = self.get_version(),
- option_list = self.option_list,
- conflict_handler = "resolve")
-
-def writepid(pid_file):
- """
- Write the process ID to disk.
- """
- fp = open(pid_file, "w")
- fp.write(str(os.getpid()))
- fp.close()
-
-def daemonize():
- """
- Detach from the terminal and continue as a daemon.
- """
- # swiped from twisted/scripts/twistd.py
- # See http://www.erlenstar.demon.co.uk/unix/faq_toc.html#TOC16
- if os.fork(): # launch child and...
- os._exit(0) # kill off parent
- os.setsid()
- if os.fork(): # launch child and...
- os._exit(0) # kill off parent again.
- os.umask(077)
- null = os.open("/dev/null", os.O_RDWR)
- for i in range(3):
- try:
- os.dup2(null, i)
- except OSError, e:
- if e.errno != errno.EBADF:
- raise
- os.close(null)

0 comments on commit adadf37

Please sign in to comment.