ansible-galaxy: create parent dir for token file (#60615)

* ansible-galaxy: create parent dir for token file

* The path unfrack is already done by config

* Move common dir creation to ansible cli

* Add warning if dir failed to be created

* remove testing path

* Make mode a position arg not kwarg
pull/60749/head
Jordan Borean 5 years ago committed by GitHub
parent fb2c1d4577
commit aea52c67d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -25,6 +25,7 @@ __metaclass__ = type
__requires__ = ['ansible']
import errno
import os
import shutil
import sys
@ -100,6 +101,17 @@ if __name__ == '__main__':
else:
raise
b_ansible_dir = os.path.expanduser(os.path.expandvars(b"~/.ansible"))
try:
os.mkdir(b_ansible_dir, 0o700)
except OSError as exc:
if exc.errno != errno.EEXIST:
display.warning("Failed to create the directory '%s': %s"
% (to_text(b_ansible_dir, errors='surrogate_or_replace'),
to_text(exc, errors='surrogate_or_replace')))
else:
display.debug("Created the '%s' directory" % to_text(b_ansible_dir, errors='surrogate_or_replace'))
try:
args = [to_text(a, errors='surrogate_or_strict') for a in sys.argv]
except UnicodeError:

Loading…
Cancel
Save