Ejemplo n.º 1
0
def main():
    opts, args = parseCmdLine()
    argShas = ''
    LOG.info('shadir: calculating shaw for "%s"' % str(args))
    shaCount = 0
    for directory in args:
        if not os.path.isdir(directory) and os.path.isfile(directory):
            newShaw = libMisc.calculateSha(directory)
            LOG.debug('new file sha: %s' % newShaw)
        else:
            newShaw = getDirectorySha(directory) + '  %s' % directory
            LOG.debug('new dir shaw: %s' % newShaw)
        argShas += newShaw + '\n'
        shaCount += 1
    if opts.single and shaCount > 1:
        LOG.info('Hashing multiple shas into a single sha...')
        sys.stdout.write(hashlib.sha1(argShas).hexdigest() + '\n')
    else:
        LOG.debug('found single sha...')
        sys.stdout.write(argShas.split('  ')[0] + '\n')
    return 0
Ejemplo n.º 2
0
 def visitFiles(self, current, files):
     newSha = libMisc.calculateSha(' '.join([os.path.join(current, f)
                                             for f in files]))
     if not newSha:
         return
     self.shas += newSha.strip('\n')