8 msg = logging.getLogger(
'FdsRegistry')
23 msg.warning(
"fds_dict:fname: No Key %s" % i)
27 return [i
for i, v
in self.iteritems()
if v[0] == fname]
30 for v
in self.values():
36 def add(self, i, fname, iomode, flags):
37 self[i] = (fname, iomode, flags)
44 msg.warning(
"fds_dict:iomode: No Key %s" % i)
48 return [i
for i
in self.keys()
if self[i][1] ==
'<OUTPUT>']
51 return [i
for i
in self.keys()
if self[i][1] ==
'<INPUT>']
55 if dir ==
"" and self.
curdir is not None:
57 msg.debug(
"get_fds_in_dir(%s)" % dir)
58 return [i
for i
in self.keys()
59 if os.path.samefile(os.path.dirname(self[i][0]), dir)]
63 create necessary symlinks in worker's dir if the fd is <INPUT> 64 otherwise copy <OUTPUT> file 73 dst = os.path.join(wkdir, os.path.basename(src))
74 if iomode ==
"<INPUT>":
75 if os.path.exists(dst):
78 "fds_dict.create_symlink:update_io_registry took care of src=%s" % src)
82 "fds_dict.create_symlink:(symlink) src=%s, iomode=%s" % (src, iomode))
86 "fds_dict.create_symlink: (copy) src=%s, dst=%s" % (src, dst))
92 """parse the fds of the processs -> build fds_dict 96 msg.info(
"extract_fds: making snapshot of parent process file descriptors")
97 self.
curdir = os.path.abspath(os.curdir)
100 procfd =
'/proc/self/fd' 101 fds = os.listdir(procfd)
104 if (fd == 1
or fd == 2):
112 realname = os.path.realpath(os.path.join(procfd, i))
113 except (OSError, IOError, TypeError):
116 msg.debug(
"failed to resolve: %s ... skipping",
117 os.path.join(procfd, i))
120 if os.path.exists(realname):
122 flags = fcntl.fcntl(fd, fcntl.F_GETFL)
123 if (flags & _O_ACCMODE) == 0:
128 self.
add(fd, realname, iomode, flags)
129 except (OSError, IOError):
132 msg.debug(
"failed access to: %s ... skipping", realname)
140 msg.debug(
"extract_fds.fds_dict=%s" % self)
def has_name(self, fname)
def get_fds_in_dir(self, dir="")
def extract_fds(self, dir="")
def __missing__(self, key)
def add(self, i, fname, iomode, flags)
def create_symlinks(self, wkdir="")