Rev 736 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 736 | Rev 738 | ||
|---|---|---|---|
| Line 22... | Line 22... | ||
| 22 | CHECKSUM_SECTION = 'SHA-1_CHECKSUMS' |
22 | CHECKSUM_SECTION = 'SHA-1_CHECKSUMS' |
| 23 | 23 | ||
| 24 | def __init__(self, modSubDir): |
24 | def __init__(self, modSubDir): |
| 25 | self.modSubDir = modSubDir |
25 | self.modSubDir = modSubDir |
| 26 | self.checkSumFile = modSubDir + '/' + self.CHECKSUM_FILE |
26 | self.checkSumFile = modSubDir + '/' + self.CHECKSUM_FILE |
| - | 27 | if not os.path.exists(self.checkSumFile): |
|
| 27 | 28 | self.__createCsumsFile() |
|
| 28 | 29 | ||
| 29 | def loadModule(self, className): |
30 | def loadModule(self, className): |
| 30 | pFileName = os.getcwd() + '/' + self.modSubDir + '/' + className + '.p' |
31 | pFileName = os.getcwd() + '/' + self.modSubDir + '/' + className + '.p' |
| 31 | log.debug('Reading from ' + pFileName) |
32 | log.debug('Reading from ' + pFileName) |
| 32 | fp = open(pFileName, 'r') |
33 | fp = open(pFileName, 'r') |
| Line 52... | Line 53... | ||
| 52 | for mName in modNames: |
53 | for mName in modNames: |
| 53 | classObj = self.loadModule(mName) |
54 | classObj = self.loadModule(mName) |
| 54 | if classObj is not None: |
55 | if classObj is not None: |
| 55 | myMods[mName] = classObj |
56 | myMods[mName] = classObj |
| 56 | return myMods |
57 | return myMods |
| 57 | 58 | ||
| 58 | 59 | ||
| 59 | def saveModule(self, className, classObj): |
60 | def saveModule(self, className, classObj): |
| 60 | pFileName = os.getcwd() + '/' + self.modSubDir + '/' + className + '.p' |
61 | pFileName = os.getcwd() + '/' + self.modSubDir + '/' + className + '.p' |
| 61 | log.debug('Writing to ' + pFileName) |
62 | log.debug('Writing to ' + pFileName) |
| 62 | fp = open(pFileName, 'w') |
63 | fp = open(pFileName, 'w') |
| 63 | p = pickle.Pickler(fp) |
64 | p = pickle.Pickler(fp) |
| Line 72... | Line 73... | ||
| 72 | f.close() |
73 | f.close() |
| 73 | hasher = hashlib.sha1() |
74 | hasher = hashlib.sha1() |
| 74 | hasher.update(data) |
75 | hasher.update(data) |
| 75 | digest = hasher.hexdigest() |
76 | digest = hasher.hexdigest() |
| 76 | return digest |
77 | return digest |
| - | 78 | ||
| - | 79 | ||
| - | 80 | def __createCsumsFile(self): |
|
| - | 81 | csumsfile = open(self.checkSumFile, 'w') |
|
| - | 82 | csumsfile.write('[' + self.CHECKSUM_SECTION + ']\n') |
|
| - | 83 | csumsfile.close() |
|
| 77 | 84 | ||
| 78 | 85 | ||
| 79 | def __writeCheckSum(self, entryname, filename): |
86 | def __writeCheckSum(self, entryname, filename): |
| 80 | csumsfile = open(self.checkSumFile, 'r+') |
87 | csumsfile = open(self.checkSumFile, 'r+') |
| 81 | csumcfg = ConfigParser() |
88 | csumcfg = ConfigParser() |