/[qa]/trunk/mole/python/Mole/common.py
ViewVC logotype

Contents of /trunk/mole/python/Mole/common.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1570 - (show annotations) (download) (as text)
Fri Jul 13 23:44:07 2007 UTC (5 years, 10 months ago) by jeroen
File MIME type: text/x-python
File size: 2171 byte(s)
Define some more common paths, and drop some obsolete ones
1 # Common functions for mole
2 # Copyright (C) 2006 Jeroen van Wolffelaar <jeroen@wolffelaar.nl>
3 # $Id$
4
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
19 import time, re, os
20 from Mole import config
21
22 def now():
23 return int(time.time())
24
25 _metaRe = re.compile("[^a-zA-Z0-9@:._+-]")
26 def noMetashit(s):
27 if _metaRe.search(s):
28 raise Exception("Aiee, invalid characters found in '%s'" % s)
29
30 # replace weird chars by _, and lowercase all, so that the resulting string can
31 # be used in filename parts such as mole databases
32 _normalRe = re.compile("[^a-z0-9.]")
33 def normalize(s):
34 s = s.lower()
35 s = _normalRe.sub("_", s)
36 return s
37
38 def lock(path):
39 # FIXME: predictable, so hackable -- and we don't want www-data able to get
40 # 'qa'. But python's os.tempnam and tmpnam are neither good either...
41 fn = path+"."+str(now())+"."+str(os.getpid())
42 fd = open(fn, 'w')
43 fd.write(str(os.getpid())+"\n")
44 fd.close()
45 try:
46 os.link(fn, path)
47 except:
48 os.unlink(fn)
49 raise Exception("Failed to create lock")
50 os.unlink(fn)
51
52 get_packages = "/home/jeroen/src/mole/ftp"
53 get_packages = "/org/qa.debian.org/data/ftp"
54 basedir = config.get("BaseDir")
55
56 dbdir = config.get("DatabasePath")
57
58 tododbdir = dbdir + "/todo"
59
60 lockdir = basedir + "/locks"
61
62 queuedir = basedir + "/queue"
63 incomingdir = queuedir + "/incoming"
64 holddir = queuedir + "/holding"
65 rejectdir = queuedir + "/rejected"
66 donedir = queuedir + "/done"
67
68 tmpdir = basedir + "/tmp"
69
70 logfile = basedir + "/logs/main.log"
71
72

Properties

Name Value
svn:keywords Id

  ViewVC Help
Powered by ViewVC 1.1.5