* [Cluster-devel] [PATCH 2/4] fencing: add function is_executale
[not found] <2064701903.7768150.1388419511153.JavaMail.root@redhat.com>
@ 2013-12-30 16:24 ` Ondrej Mular
0 siblings, 0 replies; only message in thread
From: Ondrej Mular @ 2013-12-30 16:24 UTC (permalink / raw)
To: cluster-devel.redhat.com
New function is_executable added to fencing library.
Function checks if path is reachable and executable.
Used for example in fence_amt to check path to amttool.
---
fence/agents/lib/fencing.py.py | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/fence/agents/lib/fencing.py.py b/fence/agents/lib/fencing.py.py
index ab14cb7..f4150ff 100644
--- a/fence/agents/lib/fencing.py.py
+++ b/fence/agents/lib/fencing.py.py
@@ -1,6 +1,6 @@
#!/usr/bin/python
-import sys, getopt, time, os, uuid, pycurl
+import sys, getopt, time, os, uuid, pycurl, stat
import pexpect, re, atexit, syslog
import __main__
@@ -1065,3 +1065,10 @@ def fence_login(options, re_login_string = "(login\s*: )|(Login Name: )|(userna
except pexpect.TIMEOUT:
fail(EC_LOGIN_DENIED)
return conn
+
+def is_executable(path):
+ if os.path.exists(path):
+ stats = os.stat(path)
+ if stat.S_ISREG(stats.st_mode) and os.access(path, os.X_OK):
+ return True
+ return False
--
1.8.3.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2013-12-30 16:24 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <2064701903.7768150.1388419511153.JavaMail.root@redhat.com>
2013-12-30 16:24 ` [Cluster-devel] [PATCH 2/4] fencing: add function is_executale Ondrej Mular
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).