[Blends-commit] [SCM] website branch, master, updated. 09d127c63dc2c9fc0b6aafe04338d245bb01bd00
Andreas Tille
tille at debian.org
Thu Sep 19 13:40:33 UTC 2013
The following commit has been merged in the master branch:
commit 09d127c63dc2c9fc0b6aafe04338d245bb01bd00
Author: Andreas Tille <tille at debian.org>
Date: Thu Sep 19 15:44:21 2013 +0200
Make sure output files have correct group and permission
diff --git a/webtools/blendstasktools.py b/webtools/blendstasktools.py
index afe09af..5270ac4 100644
--- a/webtools/blendstasktools.py
+++ b/webtools/blendstasktools.py
@@ -211,6 +211,16 @@ try:
except ImportError:
has_psutils=False
+def SetFilePermissions(usefile):
+ try:
+ blendsgid = grp.getgrnam("blends").gr_gid
+ os.chown(usefile, -1, blendsgid)
+ os.chmod(usefile, stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IWGRP | stat.S_IROTH )
+ # os.system("ls -l %s" % usefile)
+ except KeyError:
+ # if groups 'blends' does not exist on the machine we are simply testing and setting group permissions is not needed
+ pass
+
LOCKFILE='/var/lock/blends.lock'
def LockBlendsTools():
"""Locking mechanism to make sure the scripts will not run in parallel
@@ -235,14 +245,7 @@ def LockBlendsTools():
lf = open(LOCKFILE, 'w')
print >>lf, pid
lf.close()
- try:
- blendsgid = grp.getgrnam("blends").gr_gid
- os.chown(LOCKFILE, -1, blendsgid)
- os.chmod(LOCKFILE, stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IWGRP | stat.S_IROTH )
- # os.system("ls -l %s" % LOCKFILE)
- except KeyError:
- # if groups 'blends' does not exist on the machine we are simply testing and setting group permissions is not needed
- pass
+ SetFilePermissions(LOCKFILE)
def UnlockBlendsTools():
"""Unlock previousely locked file"""
diff --git a/webtools/tasks.py b/webtools/tasks.py
index 9a16788..5260d69 100755
--- a/webtools/tasks.py
+++ b/webtools/tasks.py
@@ -17,7 +17,7 @@ from genshi.template import TemplateLoader
from genshi import Markup
from genshi.template.eval import UndefinedError
-from blendstasktools import Tasks, GetDependencies2Use, pkgstatus, pkgstatus_sortedkeys, UnlockBlendsTools, CheckOrCreateOutputDir
+from blendstasktools import Tasks, GetDependencies2Use, pkgstatus, pkgstatus_sortedkeys, UnlockBlendsTools, CheckOrCreateOutputDir, SetFilePermissions
from blendsunicode import to_unicode
from blendslanguages import languages, language_dict
@@ -185,6 +185,7 @@ the right shows the tasks of %s.""" ) \
% (lang, errtxt)
f.close()
+ SetFilePermissions(outputfile)
data['dependencies'] = {}
data['projects'] = {}
@@ -246,6 +247,7 @@ the right shows the tasks of %s.""" ) \
"UndefinedError while rendering task %s for lang %s.\n%s" \
% (task, lang, errtxt)
f.close()
+ SetFilePermissions(outputfile+'_tmp')
# Really rude hack to get back '<' / '>' signs which actually shoul be
# in the output
tmp = open(outputfile+'_tmp', "r")
@@ -256,9 +258,10 @@ the right shows the tasks of %s.""" ) \
if detect_ampersand_code_re.search(line):
line = re.sub('%26', '&', line)
print >>f, line,
- f.close
- tmp.close
+ f.close()
+ tmp.close()
os.unlink(outputfile+'_tmp')
+ SetFilePermissions(outputfile)
template = loader.load('packagelist.xhtml')
@@ -287,6 +290,7 @@ the right shows the tasks of %s.""" ) \
% (lang, errtxt)
f.close()
+ SetFilePermissions(outputfile)
print >> htafp, "LanguagePriority",
@@ -295,5 +299,6 @@ for lang in languages:
print >> htafp
htafp.close()
+SetFilePermissions(htaccess)
UnlockBlendsTools()
--
Static and dynamic websites for Debian Pure Blends
More information about the Blends-commit
mailing list