def FindBuildRoot(dir): if os.path.isfile(os.path.join(dir, 'config.h')) and hash_utils.md5sum(os.path.join(dir, 'config.h')) == '9be4cb7407a148db2bec34f03ba83e6d' and \ os.path.isfile(os.path.join(dir, 'stdafx.h')) and hash_utils.md5sum(os.path.join(dir, 'stdafx.h')) == '056492cf438c354554d18215b33519cb' and \ os.path.isdir(os.path.join(dir, '3rdparty')): return dir else: new_dir = os.path.normpath(os.path.join(dir, '..',)) if os.path.splitdrive(new_dir)[1] == os.path.sep: raise RuntimeError('Unable to find build root') else: return FindBuildRoot(new_dir)
def Add(self, program, version, reginfo, url): # Add the URL to the list of URLs if we haven't seen it already chksum = hash_utils.md5sum(url.lower()) if chksum not in list(self.URLs.keys()): self.URLs[chksum] = url # Add the software program serial information chksum = hash_utils.md5sum(program.lower()) if chksum in list(self.Programs.keys()): self.Programs[chksum].Add(version, reginfo) else: self.Programs[chksum] = Program(program, version, reginfo)
def Add(self, platform, company, program, version, reginfo, url): chksum = hash_utils.md5sum(platform.lower()) if chksum in list(self.Platforms.keys()): self.Platforms[chksum].Add(company, program, version, reginfo, url) else: self.Platforms[chksum] = Platform(platform, company, program, version, reginfo, url)
def Add(self, company, program, version, reginfo, url): chksum = hash_utils.md5sum(company.lower()) if chksum in list(self.Companies.keys()): self.Companies[chksum].Add(program, version, reginfo, url) else: self.Companies[chksum] = Company(company, program, version, reginfo, url)
def GetFileList(path): files = glob.glob(os.path.join(path, '*.txt')) new_files = [] for file in files: new_files.append('%s - %s\n' % (os.path.basename(file), hash_utils.md5sum(file))) new_files.sort() return new_files
def Find(self, expr, platform=None): regex = re.compile(expr, re.I) str = '' if platform: chksum = hash_utils.md5sum(platform.lower()) if chksum in list(self.Platforms.keys()): str += self.Platforms[chksum].Find(regex) else: for platform in list(self.Platforms.values()): str += platform.Find(regex) return str
def _dump_file(self, filename): filepath = os.path.splitdrive(filename)[1][self.dir_length:] output = '' if self.timestamp: output += '{0:%m/%d/%Y %I:%M:%S %p} '.format( datetime.fromtimestamp(os.path.getmtime(filename))) if self.do_chksum: if self.quick: output += hash_utils.crc32(filename) + ' *' else: output += hash_utils.md5sum(filename) + ' *' return output + filepath
def GetFiles(dir, files, outfile): for d in dirs: dirs.remove(d) for f in os.listdir(dir): if f.find('?') != -1 or f.find( 'System Volume Information') != -1 or f.find('RECYCLER') != -1: continue pathname = os.path.join(dir, f) if os.path.isdir(pathname): if recurse == 1: dirs.append(pathname) else: chksum = hash_utils.md5sum(pathname) if chksum in files: filestr = pathname[2:len(pathname)] + ' == ' + ( files[chksum])[2:len((files[chksum]))] print(filestr) outfile.write(filestr + '\n') else: files[chksum] = pathname return files
def Add(self, version, reginfo): chksum = hash_utils.md5sum(version.lower()) if chksum in list(self.Versions.keys()): self.Versions[chksum].Add(reginfo) else: self.Versions[chksum] = Version(version, reginfo)
def Add(self, reginfo): chksum = hash_utils.md5sum(reginfo.lower()) if chksum in list(self.RegInfos.keys()): self.Duplicates += 1 else: self.RegInfos[chksum] = RegInfo(reginfo)
def _internal_get_chksum(filename, crc_chk=False, md5_chk=True): assert (crc_chk or md5_chk) and not (crc_chk and md5_chk) if crc_chk: return hash_utils.crc32(filename) else: return hash_utils.md5sum(filename)
outfile.write('<table align="center" width="600">\n') outfile.write('\t<tr>\n') outfile.write('\t\t<th align=center>Episode Name</th>\n') outfile.write('\t\t<th align=center>MD5SUM</th>\n') outfile.write('\t</tr>\n') def CloseIndexPhp(outfile): outfile.write('</table>\n\n') outfile.write('<?php include( \'../../footer.php\' ); ?>\n') outfile.write('</html>\n') if __name__ == '__main__': with open('index.php', 'w') as outfile: StartIndexPhp() for f in os.listdir('.'): if f == 'index.php' or f.find('?') != -1 or f.find( 'System Volume Information') != -1 or f.find( 'RECYCLER') != -1: continue if os.path.isdir(f): md5str = hash_utils.md5sum(f) print(f + ' - ' + md5str) outfile.write('\t<tr>\n') outfile.write('\t\t<td align=center><a href="' + f + '">' + f + '</a></td>\n') outfile.write('\t\t<td align=center>' + md5str + '</td>\n') outfile.write('\t</tr>\n') CloseIndexPhp(outfile)