mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-25 06:10:22 -07:00
actually check we can run scm command for roles (#43315)
* actually check we can run scm command for roles * a better error message than file not found * more narrow exception hanlding * refactor common functions for more extended use and further 'basic.py' separation
This commit is contained in:
parent
b3c054c55e
commit
222c907ffb
4 changed files with 74 additions and 38 deletions
|
@ -32,6 +32,20 @@ class LockTimeout(Exception):
|
|||
pass
|
||||
|
||||
|
||||
def is_executable(path):
|
||||
'''is the given path executable?
|
||||
|
||||
Limitations:
|
||||
* Does not account for FSACLs.
|
||||
* Most times we really want to know "Can the current user execute this
|
||||
file" This function does not tell us that, only if an execute bit is set.
|
||||
'''
|
||||
# These are all bitfields so first bitwise-or all the permissions we're
|
||||
# looking for, then bitwise-and with the file's mode to determine if any
|
||||
# execute bits are set.
|
||||
return ((stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH) & os.stat(path)[stat.ST_MODE])
|
||||
|
||||
|
||||
class FileLock:
|
||||
'''
|
||||
Currently FileLock is implemented via fcntl.flock on a lock file, however this
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue