source: TI03-DataExtractor/branches/old_stuff/dx/localRules.py @ 793

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI03-DataExtractor/branches/old_stuff/dx/localRules.py@793
Revision 793, 1.3 KB checked in by astephen, 13 years ago (diff)

Put all the old code in the old_stuff branch.

  • Property svn:executable set to *
Line 
1"""
2localRules.py
3=============
4
5A module to hold any python objects that are specific to your build.
6
7The default holds nothing but you might need to add items to satisfy your
8own system.
9
10"""
11
12# Import standard library modules
13import os, sys
14
15# Import package modules
16from config import *
17from common import * 
18
19# Local functions
20def getUserEmail(user):
21    """
22    getUserEmail function - gets a user's email address from a database.
23    """
24    import accountUtils
25    return accountUtils.getUserEmail(user)
26
27# Local classes
28class MakeAccessControlFile:
29    """
30    MakeAccessControlFile class - creates BADC-specific access control
31    file.
32    """
33   
34    def __init__(self, username, dir):
35        """
36        __init__ method - creates a BADC access control file.
37        """
38        accessControl="""
39<Limit READ>
40        AllowUser %s 
41        AllowUser badc
42        DenyAll
43</Limit>
44<Limit WRITE>
45        AllowUser %s 
46        DenyAll
47        </Limit>
48<Limit DIRS>
49        AllowUser %s
50        AllowUser badc
51        DenyAll
52</Limit>
53""" % ((username,)*3)
54        accessControlFile=os.path.join(dir, ".ftpaccess")
55        acf=open(accessControlFile, 'w')
56        acf.write(accessControl)
57        acf.close()
58        os.chmod(accessControlFile, 0644)
59        os.system('/bin/chown %s.%s %s' % (OUTPUT_FILE_USER, OUTPUT_DIR_GROUP,                                                 accessControlFile))
Note: See TracBrowser for help on using the repository browser.