mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-05-29 12:29:10 -07:00
Port the copy module over to the new "common module" logic.
This commit is contained in:
parent
d76c8c9c85
commit
d0f4358730
3 changed files with 60 additions and 93 deletions
|
@ -39,6 +39,11 @@ import subprocess
|
|||
import sys
|
||||
import syslog
|
||||
|
||||
try:
|
||||
from hashlib import md5 as _md5
|
||||
except ImportError:
|
||||
from md5 import md5 as _md5
|
||||
|
||||
class AnsibleModule(object):
|
||||
|
||||
def __init__(self, argument_spec, bypass_checks=False, no_log=False):
|
||||
|
@ -135,6 +140,21 @@ class AnsibleModule(object):
|
|||
print json.dumps(kwargs)
|
||||
sys.exit(1)
|
||||
|
||||
def md5(self, filename):
|
||||
''' Return MD5 hex digest of local file, or None if file is not present. '''
|
||||
if not os.path.exists(filename):
|
||||
return None
|
||||
digest = _md5()
|
||||
blocksize = 64 * 1024
|
||||
infile = open(filename, 'rb')
|
||||
block = infile.read(blocksize)
|
||||
while block:
|
||||
digest.update(block)
|
||||
block = infile.read(blocksize)
|
||||
infile.close()
|
||||
return digest.hexdigest()
|
||||
|
||||
|
||||
# == END DYNAMICALLY INSERTED CODE ===
|
||||
|
||||
"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue