~cjohnston/loco-team-portal/667093

« back to all changes in this revision

Viewing changes to loco_directory/teams/management/commands/release.py

  • Committer: Thomas Bechtold
  • Date: 2009-12-23 12:14:59 UTC
  • mfrom: (3.1.6 loco-directory.0.2)
  • Revision ID: thomasbechtold@jpberlin.de-20091223121459-mfdpc3bi6lzidfuq
merge from trunk; add revision stuff; add team-detail l&f improvements

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python
 
2
 
 
3
from django.core.management.base import LabelCommand
 
4
from django.conf import settings
 
5
 
 
6
import sys
 
7
import os
 
8
 
 
9
def write_version_strings(version):
 
10
    try:
 
11
        from bzrlib.branch import Branch
 
12
        branch = Branch.open_containing('.')[0]
 
13
        bzr_revno = '%s' % branch.revno()
 
14
    except:
 
15
        bzr_revno = 'unknown'
 
16
 
 
17
    file_name = os.path.join(settings.PROJECT_PATH, "version")
 
18
    if os.path.exists(file_name):
 
19
        os.remove(file_name)
 
20
    f = open(file_name, "w")
 
21
    f.write("""version: %s
 
22
revno: %s
 
23
""" % (version, bzr_revno))
 
24
    f.close()
 
25
 
 
26
class Command(LabelCommand):
 
27
    help = "Prepare release of LoCo Directory. Please pass <version> as an argument."
 
28
 
 
29
    def handle_label(self, label, **options):
 
30
        write_version_strings(label)
 
31
        print >> sys.stdout, "Released %s." % label