File: dt-createdb

package info (click to toggle)
ditrack 0.8-1.2
  • links: PTS
  • area: main
  • in suites: buster, jessie, jessie-kfreebsd, stretch
  • size: 516 kB
  • ctags: 645
  • sloc: python: 3,762; makefile: 43
file content (135 lines) | stat: -rwxr-xr-x 3,974 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#! /usr/bin/env python
#
# The script to create empty issue database.
#
# Copyright (c) 2006-2007 The DITrack Project, www.ditrack.org.
#
# $Id: dt-createdb 2439 2008-01-21 16:17:21Z gli $
# $HeadURL: https://svn.xiolabs.com/ditrack/src/tags/0.8/dt-createdb $
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
#  * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#  * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#

import os
import sys

def mkdir(path):
    try:
        os.mkdir(path)
    except:
        sys.stdout.write("Failed to mkdir '%s'\n" % path)
        sys.exit(1)

#############################################################################
# ENTRY POINT                                                               #
#############################################################################

if len(sys.argv) != 4:
    sys.stdout.write(
        """Syntax:
    %s <repository-url> <issue-db-dir> <local-wc>

The script non-recursively checks out <repository-url> into <local-wc> (which
should not exist), creates <issue-db-dir> there and schedules it for addition.

""" % os.path.basename(sys.argv[0]))
    sys.exit(1)

(repo, dbdir, localwc) = sys.argv[1:4]

if os.path.exists(localwc):
    sys.stdout.write("'%s' already exists\n" % localwc)
    sys.exit(1)

if os.system("svn co -Nq %s %s" % (repo, localwc)):
    sys.stdout.write("Can't check out working copy to %s\n" % localwc)
    sys.exit(1)

dbdir = os.path.join(localwc, dbdir)

mkdir(dbdir)
mkdir("%s/data" % dbdir)
mkdir("%s/etc" % dbdir)
mkdir("%s/meta" % dbdir)

open("%s/README.txt" % dbdir, "w").write(
"""This is an issue database maintained by DITrack.
Check out http://www.ditrack.org/ for more information.
"""
)

open("%s/etc/categories" % dbdir, "w").write(
"""Category: sample
Default-owner: sample-user
Version-set: sample-versions-set
"""
)

open("%s/etc/filters" % dbdir, "w").write(
"""sample-filter: Status=open,Owned-by=sample-user
"""
)

open("%s/etc/listing-format" % dbdir, "w").write(
"""[listing-formats]
default: %(id)-4s %(Owned-by)-8s %(Due-in)-8s %(Status)-6s %(Title)s
"""
)

open("%s/etc/users" % dbdir, "w").write(
"""sample-user
"""
)

open("%s/etc/versions" % dbdir, "w").write(
"""sample-versions-set: 0.1 0.2 / 0.3 0.4 / 0.5 0.6
"""
)

open("%s/meta/next-id" % dbdir, "w").write("1\n")

if os.system("svn add -q %s" % dbdir):
    sys.stdout.write("Can't schedule '%s' for addition\n" % dbdir)
    sys.exit(1)

try:
    open(os.path.join(dbdir, "format"),"w").write("4\n")
except:
    sys.stdout.write("Can't initialize database format version file\n")
    sys.exit(1)


if os.system("svn ps svn:ignore .ditrack %s" %dbdir):
    sys.stdout.write("Can't set the ignore list\n")
    sys.exit(1)



sys.stdout.write("""
Empty issue database created at:
'%s'

Now you should probably type something like:

svn commit %s

""" % (dbdir, dbdir))