mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-24 19:31:26 -07:00
Clean up md5 functions + make the fetch module stay happy if the remote file does not exist.
This commit is contained in:
parent
b551eba6d4
commit
8220d57690
2 changed files with 40 additions and 6 deletions
|
@ -312,6 +312,22 @@ def parse_kv(args):
|
|||
options[k]=v
|
||||
return options
|
||||
|
||||
def local_md5(file):
|
||||
''' compute local md5sum, return None if file is not present '''
|
||||
cmd = "/usr/bin/md5sum %s 2> /dev/null || /sbin/md5 -q %s" % (file,file)
|
||||
if not os.path.exists(file):
|
||||
return None
|
||||
else:
|
||||
c = os.popen(cmd)
|
||||
return c.read().split()[0]
|
||||
|
||||
|
||||
####################################################################
|
||||
# option handling code for /usr/bin/ansible and ansible-playbook
|
||||
# below this line
|
||||
|
||||
# FIXME: move to seperate file
|
||||
|
||||
class SortedOptParser(optparse.OptionParser):
|
||||
'''Optparser which sorts the options by opt before outputting --help'''
|
||||
def format_help(self, formatter=None):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue