aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek.chauhan@gmail.com>2008-08-15 22:30:42 +0530
committerNirbheek Chauhan <nirbheek.chauhan@gmail.com>2008-08-15 22:30:42 +0530
commit9d9080b5b905f9351b38b9ebb52937baa7839212 (patch)
treeb611f91396319cb5ed36fcbcd79a6db08ce4c335
parentReorder slave/autotua/const.py (diff)
downloadautotua-9d9080b5b905f9351b38b9ebb52937baa7839212.tar.gz
autotua-9d9080b5b905f9351b38b9ebb52937baa7839212.tar.bz2
autotua-9d9080b5b905f9351b38b9ebb52937baa7839212.zip
Initial autotua-master import.
Run setup-master.py to setup the django webapp
-rw-r--r--master/autotua/__init__.py0
-rw-r--r--master/autotua/media/css/default.css48
-rw-r--r--master/autotua/media/images/404.pngbin0 -> 12953 bytes
-rw-r--r--master/autotua/media/images/topcorners.gifbin0 -> 234 bytes
-rw-r--r--master/autotua/models.py32
-rw-r--r--master/autotua/process/__init__.py33
-rw-r--r--master/autotua/process/const.py40
-rw-r--r--master/autotua/process/validate.py35
-rw-r--r--master/autotua/templates/basic.html31
-rw-r--r--master/autotua/templates/content.html9
-rw-r--r--master/autotua/templates/data.html8
-rw-r--r--master/autotua/urls.py22
-rw-r--r--master/autotua/views.py19
-rw-r--r--master/custom/autotua_settings.py9
-rw-r--r--master/custom/urls.py17
-rwxr-xr-xmaster/setup-master.py68
16 files changed, 371 insertions, 0 deletions
diff --git a/master/autotua/__init__.py b/master/autotua/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/master/autotua/__init__.py
diff --git a/master/autotua/media/css/default.css b/master/autotua/media/css/default.css
new file mode 100644
index 0000000..a7ad6d4
--- /dev/null
+++ b/master/autotua/media/css/default.css
@@ -0,0 +1,48 @@
+/* vim: set sw=4 sts=4 et :
+ * Copyright: 2008 Gentoo Foundation
+ * Author(s): Nirbheek Chauhan <nirbheek.chauhan@gmail.com>
+ * License: GPL-2
+ *
+ * Immortal lh!
+ */
+
+body {
+ color: black;
+ background-color: #ffffff;
+ float: left;
+ margin: 1.5%;
+ width: 98%;
+}
+
+a:link {
+ color: #4d4d4d;
+}
+
+a:visited, a:hover {
+ color: black;
+}
+
+#topcurves img {
+ width: 99%;
+ float: left;
+}
+
+#header {
+ width: 96%;
+ text-align: center;
+ font-size: 2em;
+ background-color: #e6e6e6;
+ padding: 1.5%;
+ padding-top: 0%;
+ float: left;
+}
+
+#content {
+ width: 100%
+ float: left;
+}
+
+#footer {
+ width: 100%;
+ float: left;
+}
diff --git a/master/autotua/media/images/404.png b/master/autotua/media/images/404.png
new file mode 100644
index 0000000..f54fa84
--- /dev/null
+++ b/master/autotua/media/images/404.png
Binary files differ
diff --git a/master/autotua/media/images/topcorners.gif b/master/autotua/media/images/topcorners.gif
new file mode 100644
index 0000000..a0fa668
--- /dev/null
+++ b/master/autotua/media/images/topcorners.gif
Binary files differ
diff --git a/master/autotua/models.py b/master/autotua/models.py
new file mode 100644
index 0000000..958bb3e
--- /dev/null
+++ b/master/autotua/models.py
@@ -0,0 +1,32 @@
+# vim: set sw=4 sts=4 et :
+# Copyright: 2008 Gentoo Foundation
+# Author(s): Nirbheek Chauhan <nirbheek.chauhan@gmail.com>
+# License: GPL-2
+#
+# Immortal lh!
+#
+
+from django.db import models
+from django.contrib.auth.models import User
+
+# Create your models here.
+class Job(models.Model):
+ # Identifier for the job
+ name = models.CharField(max_length=30, unique=True)
+ # Name of maintainer
+ maintainer = models.ForeignKey(User)
+ # gentoo://stage{1..4} or URL
+ # Using a URL => stage, arch, type, release ignored
+ stage = models.CharField(max_length=25)
+ # i686, amd64, g4, etc.
+ arch = models.CharField(max_length=25) # choices; const.archs['all']
+ # Type of stage; hardened, uclibc, etc
+ #type = CharField(maxlength=25) # const.stage_types
+ # List of releases?
+ release = models.CharField(max_length=25)
+ # Revision of jobtage tree to use (auto generated)
+ jobtagerev = models.CharField(max_length=50)
+ # Space-separated list of atoms
+ atoms = models.TextField()
+ class Meta:
+ unique_together = [("name", "maintainer")]
diff --git a/master/autotua/process/__init__.py b/master/autotua/process/__init__.py
new file mode 100644
index 0000000..6eb934c
--- /dev/null
+++ b/master/autotua/process/__init__.py
@@ -0,0 +1,33 @@
+# vim: set sw=4 sts=4 et :
+# Copyright: 2008 Gentoo Foundation
+# Author(s): Nirbheek Chauhan <nirbheek.chauhan@gmail.com>
+# License: GPL-2
+#
+# Immortal lh!
+#
+
+import random
+from django.core.validators import ValidationError
+import const, validate
+
+schemes = ['http', 'https', 'ftp']
+
+def generate_stage_url(**kwargs):
+ scheme = kwargs['stage'].split('://', 1)[0]
+ if scheme in schemes:
+ return kwargs['stage']
+ kwargs['gen_arch'] = _get_arch_dir(kwargs['arch'])
+ kwargs['mirror'] = random.choice(const.MIRRORS[scheme])
+ url = const.STAGE_URI % kwargs
+ return url
+
+def _get_arch_dir(arch):
+ """
+ Convert specific archs to generic archs
+ i686 -> x86
+ mips4 -> mips
+ """
+ for i in const.ARCHS:
+ if arch in const.ARCHSs[i]:
+ return i
+ raise ValidationError(const.VERRORS['invalid_arch'] % i)
diff --git a/master/autotua/process/const.py b/master/autotua/process/const.py
new file mode 100644
index 0000000..d88e2a0
--- /dev/null
+++ b/master/autotua/process/const.py
@@ -0,0 +1,40 @@
+# vim: set sw=4 sts=4 et :
+# Copyright: 2008 Gentoo Foundation
+# Author(s): Nirbheek Chauhan <nirbheek.chauhan@gmail.com>
+# License: GPL-2
+#
+# Immortal lh!
+#
+
+# No 'arm' in here because the dir structure is weird
+# and it hasn't been updated in forever anyway.
+# Use a custom stage url if you want to use arm
+#
+# 'Mirror dir': (<archs that reside there>)
+ARCHS = { 'x86': ('i686', 'x86',),
+ 'amd64': ('amd64',),
+ 'ppc': ('970-32ul', '970-64ul', 'g4', 'power5', 'ppc', 'ppc64',),
+ 'sparc': ('sparc64',)
+ 'alpha': ('alpha',),
+ 'ia64': ('ia64',),
+ 'hppa': ('hppa1.1', 'hppa2.0',),
+ 'mips': ('cobalt', 'mips3', 'mips4', 'n32',),
+ 'sh': ('sh4',),
+ 's390': ('s390', 's390x',) }
+
+# How do we get this list? Keep updating it regularly?
+# Do we associate mirrors with the slave's geo location?
+MIRRORS = { 'gentoo': ('http://gentoo.osuosl.org',) }
+# Example:
+# http://gentoo.osuosl.org/releases/hppa/2008.0/stages/stage3-hppa2.0-2008.0.tar.bz2
+STAGES = ('stage1', 'stage2', 'stage3', 'stage4',)
+STAGE_URI = '%(mirror)/releases/%(gen_arch)s/%(release)s/stages/%(stage)s-%(arch)s-%(release)s.tar.bz2'
+#stage_types = ('', 'hardened', 'hardened+nomultilib')
+
+VERRORS = { 'invalid_stage': 'Invalid stage: %s',
+ 'invalid_arch': 'Invalid arch: %s',
+ 'invalid_type': 'Invalid type: %s',
+ 'invalid_release': 'Invalid release: %s' }
+
+for arch in ARCHS.values()[:]:
+ ARCHS['all'] = ARCHS['all'].__add__(arch)
diff --git a/master/autotua/process/validate.py b/master/autotua/process/validate.py
new file mode 100644
index 0000000..9a84537
--- /dev/null
+++ b/master/autotua/process/validate.py
@@ -0,0 +1,35 @@
+# vim: set sw=4 sts=4 et :
+# Copyright: 2008 Gentoo Foundation
+# Author(s): Nirbheek Chauhan <nirbheek.chauhan@gmail.com>
+# License: GPL-2
+#
+# Immortal lh!
+#
+
+from datetime import datetime
+from django.core.validators import ValidationError
+import const
+
+def is_stage(stage):
+ if stage not in const.STAGES:
+ raise ValidationError(const.VERRORS['invalid_stage'] % stage)
+ return True
+
+def is_arch(arch):
+ if arch not in const.ARCHS['all']:
+ raise ValidationError(const.VERRORS['invalid_arch'] % i)
+ return True
+
+def is_type(type):
+ if type not in const.STAGE_TYPE:
+ raise ValidationError(const.VERRORS['invalid_type'] % type)
+ return True
+
+def is_release(release):
+ year, state = release.split('_', 1)
+ try:
+ if int(year.split('.', 1)[0]) > datetime.now().year:
+ raise ValidationError(const.VERRORS['invalid_release'] % release)
+ except:
+ raise ValidationError(const.VERRORS['invalid_release'] % release)
+ return True
diff --git a/master/autotua/templates/basic.html b/master/autotua/templates/basic.html
new file mode 100644
index 0000000..0147cfa
--- /dev/null
+++ b/master/autotua/templates/basic.html
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+{# vim: set sw=4 sts=4 et filetype=htmldjango : #}
+{# Copyright: 2008 Gentoo Foundation #}
+{# Author(s): Nirbheek Chauhan <nirbheek.chauhan@gmail.com> #}
+{# License: GPL-2 #}
+{# #}
+{# Immortal lh! #}
+{# #}
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <title>{% block title %}AutotuA{% endblock %}</title>
+ <link rel="stylesheet" href="{{ media_prefix }}css/default.css" type="text/css"/>
+ {#<script src="{{ media_prefix }}js/default.js" type="text/javascript"></script>#}
+ {% block head %}{% endblock %}
+</head>
+<body>
+ <div id="topcurves">
+ <img src="{{ media_prefix }}images/topcorners.gif"/>
+ </div>
+ <div id="header">
+ Zomg, AutotuA.
+ </div>
+ <div id="content">
+ {% block content %}{% endblock %}
+ </div>
+ <div id="footer">
+ {{ ddate }}
+ </div>
+</body>
+</html>
diff --git a/master/autotua/templates/content.html b/master/autotua/templates/content.html
new file mode 100644
index 0000000..6f68c97
--- /dev/null
+++ b/master/autotua/templates/content.html
@@ -0,0 +1,9 @@
+{# vim: set sw=4 sts=4 et filetype=htmldjango : #}
+{# Copyright: 2008 Gentoo Foundation #}
+{# Author(s): Nirbheek Chauhan <nirbheek.chauhan@gmail.com> #}
+{# License: GPL-2 #}
+{# #}
+{# Immortal lh! #}
+{# #}
+{% extends "basic.html" %}
+{% block content %}{{ first_name }} {{ last_name }} &lt;{{ email }}&gt;{% endblock %}
diff --git a/master/autotua/templates/data.html b/master/autotua/templates/data.html
new file mode 100644
index 0000000..bc448fb
--- /dev/null
+++ b/master/autotua/templates/data.html
@@ -0,0 +1,8 @@
+{# vim: set sw=4 sts=4 et filetype=htmldjango : #}
+{# Copyright: 2008 Gentoo Foundation #}
+{# Author(s): Nirbheek Chauhan <nirbheek.chauhan@gmail.com> #}
+{# License: GPL-2 #}
+{# #}
+{# Immortal lh! #}
+{# #}
+{{ data }}
diff --git a/master/autotua/urls.py b/master/autotua/urls.py
new file mode 100644
index 0000000..c5ffc08
--- /dev/null
+++ b/master/autotua/urls.py
@@ -0,0 +1,22 @@
+# vim: set sw=4 sts=4 et :
+# Copyright: 2008 Gentoo Foundation
+# Author(s): Nirbheek Chauhan <nirbheek.chauhan@gmail.com>
+# License: GPL-2
+#
+# Immortal lh!
+#
+
+from django.conf.urls.defaults import *
+from django.conf import settings
+from views import *
+
+urlpatterns = patterns('',
+ (r'^~([a-zA-Z0-9_]+)/$', user_page),
+)
+
+# Static media serving for development purposes
+if settings.DEBUG:
+ urlpatterns += patterns('',
+ # [1:] to remove prefixed slash
+ (r'^%s(?P<path>.*)$' % settings.MEDIA_PREFIX[1:], 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}),
+ )
diff --git a/master/autotua/views.py b/master/autotua/views.py
new file mode 100644
index 0000000..5b86b16
--- /dev/null
+++ b/master/autotua/views.py
@@ -0,0 +1,19 @@
+# vim: set sw=4 sts=4 et :
+# Copyright: 2008 Gentoo Foundation
+# Author(s): Nirbheek Chauhan <nirbheek.chauhan@gmail.com>
+# License: GPL-2
+#
+# Immortal lh!
+#
+
+from django.http import HttpResponse
+from django.shortcuts import get_object_or_404, render_to_response
+from master.models import User
+from django.conf import settings
+
+def user_page(request, username):
+ user = get_object_or_404(User, username=username)
+ details = {'media_prefix': settings.MEDIA_PREFIX}
+ for i in ('first_name', 'last_name', 'email',):
+ details[i] = getattr(user, i)
+ return render_to_response('content.html', details)
diff --git a/master/custom/autotua_settings.py b/master/custom/autotua_settings.py
new file mode 100644
index 0000000..b038853
--- /dev/null
+++ b/master/custom/autotua_settings.py
@@ -0,0 +1,9 @@
+import os
+from settings import *
+
+_cwd = os.path.dirname(__file__)
+
+MEDIA_PREFIX = '/site_media/'
+TEMPLATE_DIRS += os.path.join(_cwd, 'master', 'templates').replace('\\', '/'),
+INSTALLED_APPS += ('master',)
+MEDIA_ROOT = os.path.join(_cwd, 'master', 'media').replace('\\', '/')
diff --git a/master/custom/urls.py b/master/custom/urls.py
new file mode 100644
index 0000000..c6ce8da
--- /dev/null
+++ b/master/custom/urls.py
@@ -0,0 +1,17 @@
+from django.conf.urls.defaults import *
+
+# Uncomment the next two lines to enable the admin:
+# from django.contrib import admin
+# admin.autodiscover()
+
+urlpatterns = patterns('',
+ (r'^', include('master.urls')),
+ # Example:
+ # (r'^master/', include('master.foo.urls')),
+
+ # Uncomment the next line to enable admin documentation:
+ # (r'^admin/doc/', include('django.contrib.admindocs.urls')),
+
+ # Uncomment the next line for to enable the admin:
+ # (r'^admin/(.*)', admin.site.root),
+)
diff --git a/master/setup-master.py b/master/setup-master.py
new file mode 100755
index 0000000..448933d
--- /dev/null
+++ b/master/setup-master.py
@@ -0,0 +1,68 @@
+#!/usr/bin/python
+# vim: set sw=4 sts=4 et :
+# Copyright: 2008 Gentoo Foundation
+# Author(s): Nirbheek Chauhan <nirbheek.chauhan@gmail.com>
+# License: GPL-2
+#
+# Immortal lh!
+#
+
+import sys, os, shutil
+
+DESTDIR = 'autotua_master'
+SYMLINKS = True
+
+def print_help():
+ print \
+ """\
+%(file)s: Setup the django webapp for autotua
+Usage:
+ %(file)s <where>
+
+Example:
+ %(file)s /home/me/projects/
+will create `/home/me/projects/autotua` with all the necessary files.
+
+By default, the directory will have the files copied.
+Toggle `SYMLINKS` to symlink the files instead.
+ """ % {'file': sys.argv[0]}
+
+if len(sys.argv) == 1:
+ print_help()
+ sys.exit(1)
+
+os.chdir(os.path.dirname(sys.argv[0]))
+cwd = os.getcwd()
+if not os.path.isdir(sys.argv[1]):
+ os.makedirs(sys.argv[1])
+os.chdir(sys.argv[1])
+
+try:
+ from django.core import management
+except ImportError:
+ print "You need to install django-1.0 first."
+ sys.exit(1)
+
+if management.get_version() < '0.99':
+ print "You need django-1.0 to use this."
+ sys.exit(1)
+
+management.call_command('startproject', DESTDIR)
+
+if SYMLINKS:
+ os.symlink(cwd+'/autotua', DESTDIR+'/master')
+ for file in ['autotua_settings.py', 'urls.py']:
+ dest_file = DESTDIR+'/'+file
+ if os.path.isfile(dest_file):
+ os.remove(dest_file)
+ os.symlink(cwd+'/custom/'+file, dest_file)
+else:
+ shutil.copytree(cwd+'/autotua', DESTDIR+'/master')
+ for file in ['autotua_settings.py', 'urls.py']:
+ shutil.copy(cwd+'/custom/'+file, DESTDIR)
+
+settings = open(DESTDIR+'/settings.py', 'a')
+settings.write('\nfrom autotua_settings import *\n')
+settings.close()
+
+print "All done. Now you need to run `python manage.py syncdb` after editing the database settings in %s/settings.py" % DESTDIR