[cig-commits] r13958 - in cs/portal/trunk/magportal: . MagWebPortal MagWebPortal/static MagWebPortal/templates MagWebPortal/templates/MagWebPortal
leif at geodynamics.org
leif at geodynamics.org
Mon Jan 26 18:40:34 PST 2009
Author: leif
Date: 2009-01-26 18:40:33 -0800 (Mon, 26 Jan 2009)
New Revision: 13958
Added:
cs/portal/trunk/magportal/MANIFEST.in
cs/portal/trunk/magportal/MagWebPortal/templates/MagWebPortal/simulation_list.py.tmpl
cs/portal/trunk/magportal/debug-setup.sh
Removed:
cs/portal/trunk/magportal/MagWebPortal/models.py.old
cs/portal/trunk/magportal/MagWebPortal/static/html/
cs/portal/trunk/magportal/MagWebPortal/templates/MagWebPortal/inputparam_detail_gearth.kml
cs/portal/trunk/magportal/MagWebPortal/templates/MagWebPortal/simulation_list.py
cs/portal/trunk/magportal/MagWebPortal/templates/cig-logo_small-initials.ico
cs/portal/trunk/magportal/ez_setup.py
Modified:
cs/portal/trunk/magportal/MagWebPortal/urls.py
cs/portal/trunk/magportal/setup.py
Log:
Wrote working 'setup.py' script. Added shell script which documents
how to debug the portal. Removed some junk.
Added: cs/portal/trunk/magportal/MANIFEST.in
===================================================================
--- cs/portal/trunk/magportal/MANIFEST.in (rev 0)
+++ cs/portal/trunk/magportal/MANIFEST.in 2009-01-27 02:40:33 UTC (rev 13958)
@@ -0,0 +1,20 @@
+include MANIFEST.in
+include debug-setup.sh
+include runserver.sh
+include daemon.py
+include MagWebPortal/static/*.pdf
+include MagWebPortal/static/*.ico
+include MagWebPortal/static/*.txt
+include MagWebPortal/static/css/*.css
+include MagWebPortal/static/doc/*.pdf
+include MagWebPortal/static/images/*.gif
+include MagWebPortal/static/images/*.jpg
+include MagWebPortal/static/images/*.ico
+include MagWebPortal/static/jss/*.js
+include MagWebPortal/static/samples/*
+include MagWebPortal/templates/MagWebPortal/*.html
+include MagWebPortal/templates/MagWebPortal/*.txt
+include MagWebPortal/templates/MagWebPortal/*.tmpl
+include MagWebPortal/templates/registration/*.html
+include MagWebPortal/templates/registration/*.txt
+include MagWebPortal/templates/*.html
Deleted: cs/portal/trunk/magportal/MagWebPortal/models.py.old
===================================================================
--- cs/portal/trunk/magportal/MagWebPortal/models.py.old 2009-01-26 19:43:49 UTC (rev 13957)
+++ cs/portal/trunk/magportal/MagWebPortal/models.py.old 2009-01-27 02:40:33 UTC (rev 13958)
@@ -1,412 +0,0 @@
-
-from django.db import models
-from django.contrib.auth.models import User
-from django.core import validators
-
-from managers import CurrentUser, CurrentUserManager
-from middleware import get_current_user
-
-# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-# Inputdatafiles
-# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-# Set the init condition
-INIT_STATUS = (
- (0, 'has restart file'),
- (1, 'start from scratch'),
-)
-
-class InputdataFile(models.Model):
-
- # each user has a list of their own inputdatafiles
- user = models.ForeignKey(User)
-
- name = models.CharField(maxlength=100)
-
- # managers
- objects = models.Manager()
- user_objects = CurrentUserManager()
-
- def __str__(self): return self.name
-
- def copy(self, objMap):
- from copy import copy
- obj = copy(self)
- obj.id = None
- obj.user = objMap[User][self.user.id]
- super(InputdataFile, obj).save()
- for inputdata in self.inputdata_set.all():
- inputdataCopy = copy(inputdata)
- inputdataCopy.id = None
- inputdataCopy.inputdataFile = obj
- inputdataCopy.save()
- return obj
-
- def delete(self):
- self.inputdata_set.all().delete()
- super(InputdataFile, self).delete()
-
-
-class Inputdata(models.Model):
-
- # each user has own inputdatas
- inputdatafile= models.ForeignKey(InputdataFile)
-
- #input, output, stepping control, initialization of the run
- outfile = models.CharField(maxlength=10) # 3-4 chars currently
- runid = models.CharField(maxlength=100)
- init = models.IntegerField(choices=INIT_STATUS, default=1)
- treset = models.BooleanField(core=True)
- samp = models.FloatField(max_digits=10, decimal_places=10,default=0.1000)
- nstep = models.IntegerField(default=200)
- nprnt = models.IntegerField(default=8)
- nstor = models.IntegerField(default=04)
- nplog = models.IntegerField(default=0)
- nlogstep = models.IntegerField(default=100)
- ngform = models.IntegerField(default=1)
- ngrad = models.IntegerField(default=01)
- ngcolat = models.IntegerField(default=1)
- nglon = models.IntegerField(default=1)
- #ifbfrz=.true.,
-
- # time setp control
- #dtmax=1.5E-4,
- #courfac=5.0,
- #alffac=0.1,
- #icour = 4
-
- # Physical control parameters
- #radratio=0.35,
- #ra=1.0E5,
- #ek=1.00E-3,
- #pr=1.0,
- #prmag=1.0,
- #bpeak=0.0,
- #epsc0=-0.0,
-
- # boundary conditions at inner and outer radii
- #imagcon=0,
- #ktops=1,
- #kbots=1,
- #ktopv=2,
- #kbotv=2,
-
- # hyperdiffusivites
- #difamp=0,
-
- # parameters for generationg movie files
- #imovopt=000,
- #tmovstart=0.0,
- #tmovstep=0.E-3,
- #iframes=00,
-
-
- def __str__(self): return self.inputdatafile
-
-
- def _getMrrStr2f(self): return "%.2f" % (self.Mrr * 1.0e-26)
-
- mrr = property(_getMrrStr2f)
-
- def saveInputdata(cls, inputdatafile):
-
- inputdata = Inputdata(
- outfile = outfile,
- runid = runid,
- init = init,
- treset = treset,
- samp = samp,
- nstep = nstep,
- nprnt = nprnt,
- nstor = nstor,
- nplog = nplog,
- nlogstep = nlogstep,
- ngform = ngform,
- ngrad = ngrad,
- ngcolat = ngcolat,
- nglon = nglon,
- )
-
- inputdata.save()
- return
-
- saveInputdata = classmethod(saveInputdata)
-
-
-# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-# Input Parameter file
-# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-# Set the init condition
-INIT_STATUS = (
- (0, 'has restart file'),
- (1, 'start from scratch'),
-)
-
-class InputparamFile(models.Model):
-
- # each user has own inputparam lists
- user = models.ForeignKey(User)
-
- name = models.CharField(maxlength=100)
-
- # managers
- objects = models.Manager()
- user_objects = CurrentUserManager()
-
- def __str__(self): return self.name
-
- def copy(self, objMap):
- from copy import copy
- obj = copy(self)
- obj.id = None
- obj.user = objMap[User][self.user.id]
- super(InputparamFile, obj).save()
- for inputparam in self.inputparam_set.all():
- inputparamCopy = copy(inputparam)
- inputparamCopy.id = None
- inputparamCopy.inputparamFile = obj
- inputparamCopy.save()
- return obj
-
- def delete(self):
- self.inputparam_set.all().delete()
- super(InputparamFile, self).delete()
-
- class Admin:
- pass
-
-
-class Inputparam(models.Model):
-
- # each user has own inputparams
- inputparamFile = models.ForeignKey(InputparamFile, null=True)
-
- #input, output, stepping control, initialization of the run
- outfile = models.CharField(maxlength=10) # 3-4 chars currently
- runid = models.CharField(maxlength=100)
- init = models.IntegerField(choices=INIT_STATUS, default=1)
- treset = models.BooleanField(core=True)
- samp = models.FloatField(max_digits=19, decimal_places=10)
- nstep = models.FloatField(max_digits=19, decimal_places=10)
- nprnt = models.FloatField(max_digits=19, decimal_places=10)
- nstor = models.FloatField(max_digits=19, decimal_places=10, default=0.0)
- nplog = models.IntegerField(default=0)
- nlogstep = models.IntegerField(default=100)
- ngform = models.IntegerField(default=1)
- ngrad = models.IntegerField(default=01)
- ngcolat = models.IntegerField(default=1)
- nglon = models.IntegerField(default=1)
- #ifbfrz=.true.,
-
- # time setp control
- #dtmax=1.5E-4,
- #courfac=5.0,
- #alffac=0.1,
- #icour = 4
-
- # Physical control parameters
- #radratio=0.35,
- #ra=1.0E5,
- #ek=1.00E-3,
- #pr=1.0,
- #prmag=1.0,
- #bpeak=0.0,
- #epsc0=-0.0,
-
- # boundary conditions at inner and outer radii
- #imagcon=0,
- #ktops=1,
- #kbots=1,
- #ktopv=2,
- #kbotv=2,
-
- # hyperdiffusivites
- #difamp=0,
-
- # parameters for generationg movie files
- #imovopt=000,
- #tmovstart=0.0,
- #tmovstep=0.E-3,
- #iframes=00,
-
-
-
-# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-# Simulations
-# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-
-NLOGISYM_CHOICES = (
- (1, 'no global symmetry'),
- (4, '4-fold global symmetry'),
- (6, '6-fold global symmetry'),
-)
-
-NTRUNCORDER_CHOICES = (
- (32, '32'),
- (48, '48'),
- (96, '96'),
-)
-
-class Simulation(models.Model):
- #
- # general information about the simulation
- #
- user = models.ForeignKey(User)
- name = models.CharField(maxlength=100, core=True)
- created = models.DateTimeField(auto_now_add=True, editable=False)
- modified = models.DateTimeField(auto_now=True, editable=False)
-
- #
- # specific information starts here
- #
- logisym = models.IntegerField(core=True, choices=NLOGISYM_CHOICES, default=4)
- truncorder = models.IntegerField(core=True, choices=NTRUNCORDER_CHOICES, default=32)
-
- # PARAMFILE
- InputparamFile = models.ForeignKey(InputparamFile, limit_choices_to = {'user__exact': CurrentUser()})
- # managers
-
- objects = models.Manager()
- user_objects = CurrentUserManager()
-
- def __str__(self): return self.name
-
- def save(self):
- self.user = get_current_user()
- super(Simulation, self).save()
- return
-
- def copy(self, objMap):
- from copy import copy
- obj = copy(self)
- obj.id = None
- obj.user = objMap[User][self.user.id]
- obj.inputparams = objMap[Inputparam][self.inputparams.id]
- super(Simulation, obj).save()
- return obj
-
- def run(self):
- r = Run()
- r.simulation = self
- r.save()
- return r
-
- def _getStatus(self):
- if not hasattr(self, '_status'):
- self._status = "new"
- for run in self.run_set.all():
- self._status = run.status
- return self._status
- status = property(_getStatus)
-
- class Admin:
- pass
-
-
-# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-# Runs, Jobs
-# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-
-class Run(models.Model):
- # each simulation may have multiple runs
- simulation = models.ForeignKey(Simulation)
-
- status = models.CharField(maxlength=100)
- started = models.DateTimeField(auto_now_add=True, editable=False)
- finished = models.DateTimeField(null=True, blank=True)
-
- class Admin:
- list_display = ('simulation', 'status', 'started', 'finished')
-
- def __str__(self):
- return "%s r%d" % (self.simulation.name, self.id)
-
-
-class Job(models.Model):
- # each run may correspond to multiple jobs
- run = models.ForeignKey(Run)
-
- task = models.CharField(maxlength=100)
- status = models.CharField(maxlength=100)
- created = models.DateTimeField(auto_now_add=True, editable=False)
- started = models.DateTimeField(null=True, blank=True)
- finished = models.DateTimeField(null=True, blank=True)
-
- # base URL for input/output files
- url = models.URLField(verify_exists=False)
-
- class Admin:
- list_display = ('id', 'run', 'task', 'status', 'started', 'finished', 'url')
-
- def wait(self): return 0 # NYI
- def duration(self): return "-" # NYI
-
-
-class OutputFile(models.Model):
- job = models.ForeignKey(Job)
-
- name = models.CharField(maxlength=100)
-
- def url(self): return self.job.url + self.name
-
-
-# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-# Registration
-# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-
-class Invite(models.Model):
- code = models.CharField(maxlength=100, unique=True, db_index=True)
- name = models.CharField(maxlength=100)
- description = models.TextField(blank=True)
- created = models.DateTimeField(auto_now_add=True, editable=False)
- modified = models.DateTimeField(auto_now=True, editable=False)
- expires = models.DateTimeField(null=True, blank=True)
-
- def __str__(self): return self.name
-
- def hasExpired(self):
- import datetime
- if self.expires is None:
- return False
- now = datetime.datetime.now()
- return self.expires < now
-
- class Admin:
- list_display = ('name', 'code', 'expires', 'hasExpired')
-
-
-class UserInfo(models.Model):
- user = models.OneToOneField(User)
- institution = models.CharField(maxlength=100, core=True)
- address1 = models.CharField(maxlength=100, null=True, blank=True)
- address2 = models.CharField(maxlength=100, null=True, blank=True)
- address3 = models.CharField(maxlength=100, null=True, blank=True)
- phone = models.PhoneNumberField(null=True, blank=True)
-
- # the invitation used, if any
- invite = models.ForeignKey(Invite, null=True, blank=True)
-
- # 'True' if this user can run simulations. Users who enter a
- # valid invitation code are automatically approved.
- approved = models.BooleanField(default=False)
- help_visible = models.BooleanField(default=True)
-
- def __str__(self): return self.user.username
-
- # forward to User
- def username(self): return self.user.username
- def first_name(self): return self.user.first_name
- def last_name(self): return self.user.last_name
-
- class Admin:
- # This is an admittedly crude way to allow admins to scan for
- # unapproved users in the 'admin' interface.
- list_display = ('username', 'first_name', 'last_name', 'invite', 'approved')
- list_filter = ('approved',)
-
-
-# end of file
Deleted: cs/portal/trunk/magportal/MagWebPortal/templates/MagWebPortal/inputparam_detail_gearth.kml
===================================================================
--- cs/portal/trunk/magportal/MagWebPortal/templates/MagWebPortal/inputparam_detail_gearth.kml 2009-01-26 19:43:49 UTC (rev 13957)
+++ cs/portal/trunk/magportal/MagWebPortal/templates/MagWebPortal/inputparam_detail_gearth.kml 2009-01-27 02:40:33 UTC (rev 13958)
@@ -1,10 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<kml xmlns="http://earth.google.com/kml/2.0">
- <Placemark>
- <name>{{object.code}} {{object.name}}</name>
- <styleUrl>root://styleMaps#default+nicon=0x304+hicon=0x314</styleUrl>
- <Point>
- <coordinates>{{object.longitude}},{{object.latitude}},{{object.elevation}}</coordinates>
- </Point>
- </Placemark>
-</kml>
Deleted: cs/portal/trunk/magportal/MagWebPortal/templates/MagWebPortal/simulation_list.py
===================================================================
--- cs/portal/trunk/magportal/MagWebPortal/templates/MagWebPortal/simulation_list.py 2009-01-26 19:43:49 UTC (rev 13957)
+++ cs/portal/trunk/magportal/MagWebPortal/templates/MagWebPortal/simulation_list.py 2009-01-27 02:40:33 UTC (rev 13958)
@@ -1,5 +0,0 @@
-(
- {% for object in object_list %}
- { 'id': {{ object.id }}, 'status': '{{ object.status }}' },
- {% endfor %}
-)
Copied: cs/portal/trunk/magportal/MagWebPortal/templates/MagWebPortal/simulation_list.py.tmpl (from rev 13957, cs/portal/trunk/magportal/MagWebPortal/templates/MagWebPortal/simulation_list.py)
===================================================================
--- cs/portal/trunk/magportal/MagWebPortal/templates/MagWebPortal/simulation_list.py.tmpl (rev 0)
+++ cs/portal/trunk/magportal/MagWebPortal/templates/MagWebPortal/simulation_list.py.tmpl 2009-01-27 02:40:33 UTC (rev 13958)
@@ -0,0 +1,5 @@
+(
+ {% for object in object_list %}
+ { 'id': {{ object.id }}, 'status': '{{ object.status }}' },
+ {% endfor %}
+)
Deleted: cs/portal/trunk/magportal/MagWebPortal/templates/cig-logo_small-initials.ico
===================================================================
(Binary files differ)
Modified: cs/portal/trunk/magportal/MagWebPortal/urls.py
===================================================================
--- cs/portal/trunk/magportal/MagWebPortal/urls.py 2009-01-26 19:43:49 UTC (rev 13957)
+++ cs/portal/trunk/magportal/MagWebPortal/urls.py 2009-01-27 02:40:33 UTC (rev 13958)
@@ -164,7 +164,7 @@
(r'^simulations/list.py$', 'django.views.generic.list_detail.object_list', dict(queryset = models.Simulation.objects.all(),
allow_empty = True,
- template_name = APP_LABEL + '/simulation_list.py',
+ template_name = APP_LABEL + '/simulation_list.py.tmpl',
mimetype = 'text/plain')),
(r'^simulations/list.txt$', 'django.views.generic.list_detail.object_list', dict(queryset = models.Simulation.objects.all(),
Added: cs/portal/trunk/magportal/debug-setup.sh
===================================================================
--- cs/portal/trunk/magportal/debug-setup.sh (rev 0)
+++ cs/portal/trunk/magportal/debug-setup.sh 2009-01-27 02:40:33 UTC (rev 13958)
@@ -0,0 +1,16 @@
+# To debug the portal, perform the following:
+#
+# . debug-setup.sh
+# django-admin.py syncdb
+# django-admin.py runserver
+# firefox http://127.0.0.1:8000/magwebportal/
+#
+
+export DJANGO_SETTINGS_MODULE=MagWebPortal.site.settings
+export WEBPORTAL_MEDIA_ROOT=`python -c "from os.path import dirname; import MagWebPortal; print dirname(MagWebPortal.__file__)"`
+export WEBPORTAL_DATABASE_NAME=`pwd`/database
+export WEBPORTAL_SECRET_KEY='$2k0qi00^76%1i9r5z at i#l at l($2&-r3&!37z00-vll&9#&(skg'
+
+mkdir -p $WEBPORTAL_MEDIA_ROOT
+
+export WEBPORTAL_DEBUG=1
Deleted: cs/portal/trunk/magportal/ez_setup.py
===================================================================
--- cs/portal/trunk/magportal/ez_setup.py 2009-01-26 19:43:49 UTC (rev 13957)
+++ cs/portal/trunk/magportal/ez_setup.py 2009-01-27 02:40:33 UTC (rev 13958)
@@ -1,222 +0,0 @@
-#!python
-"""Bootstrap setuptools installation
-
-If you want to use setuptools in your package's setup.py, just include this
-file in the same directory with it, and add this to the top of your setup.py::
-
- from ez_setup import use_setuptools
- use_setuptools()
-
-If you want to require a specific version of setuptools, set a download
-mirror, or use an alternate download directory, you can do so by supplying
-the appropriate options to ``use_setuptools()``.
-
-This file can also be run as a script to install or upgrade setuptools.
-"""
-import sys
-DEFAULT_VERSION = "0.6c3"
-DEFAULT_URL = "http://cheeseshop.python.org/packages/%s/s/setuptools/" % sys.version[:3]
-
-md5_data = {
- 'setuptools-0.6b1-py2.3.egg': '8822caf901250d848b996b7f25c6e6ca',
- 'setuptools-0.6b1-py2.4.egg': 'b79a8a403e4502fbb85ee3f1941735cb',
- 'setuptools-0.6b2-py2.3.egg': '5657759d8a6d8fc44070a9d07272d99b',
- 'setuptools-0.6b2-py2.4.egg': '4996a8d169d2be661fa32a6e52e4f82a',
- 'setuptools-0.6b3-py2.3.egg': 'bb31c0fc7399a63579975cad9f5a0618',
- 'setuptools-0.6b3-py2.4.egg': '38a8c6b3d6ecd22247f179f7da669fac',
- 'setuptools-0.6b4-py2.3.egg': '62045a24ed4e1ebc77fe039aa4e6f7e5',
- 'setuptools-0.6b4-py2.4.egg': '4cb2a185d228dacffb2d17f103b3b1c4',
- 'setuptools-0.6c1-py2.3.egg': 'b3f2b5539d65cb7f74ad79127f1a908c',
- 'setuptools-0.6c1-py2.4.egg': 'b45adeda0667d2d2ffe14009364f2a4b',
- 'setuptools-0.6c2-py2.3.egg': 'f0064bf6aa2b7d0f3ba0b43f20817c27',
- 'setuptools-0.6c2-py2.4.egg': '616192eec35f47e8ea16cd6a122b7277',
- 'setuptools-0.6c3-py2.3.egg': 'f181fa125dfe85a259c9cd6f1d7b78fa',
- 'setuptools-0.6c3-py2.4.egg': 'e0ed74682c998bfb73bf803a50e7b71e',
- 'setuptools-0.6c3-py2.5.egg': 'abef16fdd61955514841c7c6bd98965e',
-}
-
-import sys, os
-
-def _validate_md5(egg_name, data):
- if egg_name in md5_data:
- from md5 import md5
- digest = md5(data).hexdigest()
- if digest != md5_data[egg_name]:
- print >>sys.stderr, (
- "md5 validation of %s failed! (Possible download problem?)"
- % egg_name
- )
- sys.exit(2)
- return data
-
-
-def use_setuptools(
- version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir,
- download_delay=15
-):
- """Automatically find/download setuptools and make it available on sys.path
-
- `version` should be a valid setuptools version number that is available
- as an egg for download under the `download_base` URL (which should end with
- a '/'). `to_dir` is the directory where setuptools will be downloaded, if
- it is not already available. If `download_delay` is specified, it should
- be the number of seconds that will be paused before initiating a download,
- should one be required. If an older version of setuptools is installed,
- this routine will print a message to ``sys.stderr`` and raise SystemExit in
- an attempt to abort the calling script.
- """
- try:
- import setuptools
- if setuptools.__version__ == '0.0.1':
- print >>sys.stderr, (
- "You have an obsolete version of setuptools installed. Please\n"
- "remove it from your system entirely before rerunning this script."
- )
- sys.exit(2)
- except ImportError:
- egg = download_setuptools(version, download_base, to_dir, download_delay)
- sys.path.insert(0, egg)
- import setuptools; setuptools.bootstrap_install_from = egg
-
- import pkg_resources
- try:
- pkg_resources.require("setuptools>="+version)
-
- except pkg_resources.VersionConflict, e:
- # XXX could we install in a subprocess here?
- print >>sys.stderr, (
- "The required version of setuptools (>=%s) is not available, and\n"
- "can't be installed while this script is running. Please install\n"
- " a more recent version first.\n\n(Currently using %r)"
- ) % (version, e.args[0])
- sys.exit(2)
-
-def download_setuptools(
- version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir,
- delay = 15
-):
- """Download setuptools from a specified location and return its filename
-
- `version` should be a valid setuptools version number that is available
- as an egg for download under the `download_base` URL (which should end
- with a '/'). `to_dir` is the directory where the egg will be downloaded.
- `delay` is the number of seconds to pause before an actual download attempt.
- """
- import urllib2, shutil
- egg_name = "setuptools-%s-py%s.egg" % (version,sys.version[:3])
- url = download_base + egg_name
- saveto = os.path.join(to_dir, egg_name)
- src = dst = None
- if not os.path.exists(saveto): # Avoid repeated downloads
- try:
- from distutils import log
- if delay:
- log.warn("""
----------------------------------------------------------------------------
-This script requires setuptools version %s to run (even to display
-help). I will attempt to download it for you (from
-%s), but
-you may need to enable firewall access for this script first.
-I will start the download in %d seconds.
-
-(Note: if this machine does not have network access, please obtain the file
-
- %s
-
-and place it in this directory before rerunning this script.)
----------------------------------------------------------------------------""",
- version, download_base, delay, url
- ); from time import sleep; sleep(delay)
- log.warn("Downloading %s", url)
- src = urllib2.urlopen(url)
- # Read/write all in one block, so we don't create a corrupt file
- # if the download is interrupted.
- data = _validate_md5(egg_name, src.read())
- dst = open(saveto,"wb"); dst.write(data)
- finally:
- if src: src.close()
- if dst: dst.close()
- return os.path.realpath(saveto)
-
-def main(argv, version=DEFAULT_VERSION):
- """Install or upgrade setuptools and EasyInstall"""
-
- try:
- import setuptools
- except ImportError:
- egg = None
- try:
- egg = download_setuptools(version, delay=0)
- sys.path.insert(0,egg)
- from setuptools.command.easy_install import main
- return main(list(argv)+[egg]) # we're done here
- finally:
- if egg and os.path.exists(egg):
- os.unlink(egg)
- else:
- if setuptools.__version__ == '0.0.1':
- # tell the user to uninstall obsolete version
- use_setuptools(version)
-
- req = "setuptools>="+version
- import pkg_resources
- try:
- pkg_resources.require(req)
- except pkg_resources.VersionConflict:
- try:
- from setuptools.command.easy_install import main
- except ImportError:
- from easy_install import main
- main(list(argv)+[download_setuptools(delay=0)])
- sys.exit(0) # try to force an exit
- else:
- if argv:
- from setuptools.command.easy_install import main
- main(argv)
- else:
- print "Setuptools version",version,"or greater has been installed."
- print '(Run "ez_setup.py -U setuptools" to reinstall or upgrade.)'
-
-
-
-def update_md5(filenames):
- """Update our built-in md5 registry"""
-
- import re
- from md5 import md5
-
- for name in filenames:
- base = os.path.basename(name)
- f = open(name,'rb')
- md5_data[base] = md5(f.read()).hexdigest()
- f.close()
-
- data = [" %r: %r,\n" % it for it in md5_data.items()]
- data.sort()
- repl = "".join(data)
-
- import inspect
- srcfile = inspect.getsourcefile(sys.modules[__name__])
- f = open(srcfile, 'rb'); src = f.read(); f.close()
-
- match = re.search("\nmd5_data = {\n([^}]+)}", src)
- if not match:
- print >>sys.stderr, "Internal error!"
- sys.exit(2)
-
- src = src[:match.start(1)] + repl + src[match.end(1):]
- f = open(srcfile,'w')
- f.write(src)
- f.close()
-
-
-if __name__=='__main__':
- if len(sys.argv)>2 and sys.argv[1]=='--md5update':
- update_md5(sys.argv[2:])
- else:
- main(sys.argv[1:])
-
-
-
-
-
Modified: cs/portal/trunk/magportal/setup.py
===================================================================
--- cs/portal/trunk/magportal/setup.py 2009-01-26 19:43:49 UTC (rev 13957)
+++ cs/portal/trunk/magportal/setup.py 2009-01-27 02:40:33 UTC (rev 13958)
@@ -1,30 +1,28 @@
-try:
- # If setuptools 0.6b1 or later is installed, run with it.
- from pkg_resources import require
- require("setuptools>=0.6b1")
-except:
- from ez_setup import use_setuptools
- use_setuptools()
+from distutils.core import setup
-from setuptools import setup
-
setup(
name = 'MagWebPortal',
version = '1.0',
url = 'http://www.geodynamics.org/',
- author = 'Wei Mi',
- author_email = 'wei at geodynamics.org',
- packages = [ 'MagWebPortal' ],
-
- install_requires = [
- 'Django >= 0.95',
- #'pysqlite >= 2.0.3',
- ],
-
- dependency_links = [
- 'http://www.djangoproject.com/download/0.95/tarball/#egg=Django-0.95',
- 'http://initd.org/tracker/pysqlite',
- ],
-
-)
+ author = 'Leif Strand',
+ author_email = 'leif at geodynamics.org',
+ packages = ['MagWebPortal', 'MagWebPortal.site'],
+ package_data = {'MagWebPortal': ['static/*.pdf',
+ 'static/*.ico',
+ 'static/*.txt',
+ 'static/css/*.css',
+ 'static/doc/*.pdf',
+ 'static/images/*.gif',
+ 'static/images/*.jpg',
+ 'static/images/*.ico',
+ 'static/jss/*.js',
+ 'static/samples/*',
+ 'templates/MagWebPortal/*.html',
+ 'templates/MagWebPortal/*.txt',
+ 'templates/MagWebPortal/*.tmpl',
+ 'templates/registration/*.html',
+ 'templates/registration/*.txt',
+ 'templates/*.html',
+ ]},
+ )
More information about the CIG-COMMITS
mailing list