22 lines
541 B
Python
22 lines
541 B
Python
"""
|
|
General helpers for my scripts
|
|
"""
|
|
import os
|
|
from subprocess import call
|
|
|
|
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|
|
__author__ = 'lanxu <jukka.lankinen@gmail.com>'
|
|
|
|
def is_exe(fpath):
|
|
""" Tells if the given file is an executable """
|
|
return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
|
|
|
|
def run_command(command):
|
|
""" Attempts to run the given command """
|
|
try:
|
|
return_value = call(command)
|
|
except (RuntimeError, TypeError, NameError, OSError) as error:
|
|
raise
|
|
|
|
return return_value
|