apw | 059e1b1 | 2006-10-12 17:18:26 +0000 | [diff] [blame] | 1 | """The Job Configuration |
| 2 | |
| 3 | The job configuration, holding configuration variable supplied to the job. |
apw | 8ad56be | 2006-11-06 17:49:54 +0000 | [diff] [blame] | 4 | |
| 5 | The config should be viewed as a hierachical namespace. The elements |
| 6 | of the hierachy are separated by periods (.) and where multiple words |
| 7 | are required at a level they should be separated by underscores (_). |
| 8 | Please no StudlyCaps. |
| 9 | |
| 10 | For example: |
| 11 | boot.default_args |
apw | 059e1b1 | 2006-10-12 17:18:26 +0000 | [diff] [blame] | 12 | """ |
| 13 | |
| 14 | __author__ = """Copyright Andy Whitcroft 2006""" |
| 15 | |
apw | 0c01f07 | 2006-11-02 00:21:26 +0000 | [diff] [blame] | 16 | import os |
| 17 | |
apw | 059e1b1 | 2006-10-12 17:18:26 +0000 | [diff] [blame] | 18 | class config: |
| 19 | """The BASIC job configuration |
| 20 | |
| 21 | Properties: |
| 22 | job |
| 23 | The job object for this job |
| 24 | config |
| 25 | The job configuration dictionary |
| 26 | """ |
| 27 | |
| 28 | def __init__(self, job): |
| 29 | """ |
| 30 | job |
| 31 | The job object for this job |
| 32 | """ |
| 33 | self.job = job |
| 34 | self.config = {} |
| 35 | |
| 36 | |
| 37 | def set(self, name, value): |
apw | 0c01f07 | 2006-11-02 00:21:26 +0000 | [diff] [blame] | 38 | if name == "proxy": |
| 39 | os.environ['http_proxy'] = value |
| 40 | os.environ['ftp_proxy'] = value |
| 41 | |
apw | 059e1b1 | 2006-10-12 17:18:26 +0000 | [diff] [blame] | 42 | self.config[name] = value |
| 43 | |
| 44 | def get(self, name): |
| 45 | if name in self.config: |
| 46 | return self.config[name] |
| 47 | else: |
| 48 | return None |