/usr/lib/python3/dist-packages/pyutilib/workflow/executable.py is in python3-pyutilib 5.3.5-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | __all__ = ['ExecutableResource']
import os.path
from pyutilib.workflow import resource
import pyutilib.services
import pyutilib.subprocess
# TODO: add support for logging
class ExecutableResource(resource.Resource):
def __init__(self, name=None, executable=None):
resource.Resource.__init__(self)
if name is None and not executable is None:
name = os.path.basename(executable)
if executable is None:
executable=name
self.register(name, executable)
def register(self, name, executable):
self.filename=executable
if name is None:
# TBD: when is this branch executed?
self.description = "Executable"+self.id
self.name = self.description
else:
self.description = "Executable_"+name
self.name = name
pyutilib.services.register_executable(executable)
def run(self, args, logfile=None, debug=False):
executable = pyutilib.services.registered_executable(self.filename)
if executable is None:
# TBD: tests generating this error do not cause global exceptions in a workflow ...
raise IOError("Cannot find executable '%s'" % self.filename)
cmd = executable.get_path()+" "+args
if debug:
print("Running... %s" % cmd)
pyutilib.subprocess.run(cmd, outfile=logfile)
def available(self):
return not pyutilib.services.registered_executable(self.filename) is None
|