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)
59 i
for i
in self.keys()
60 if os.path.samefile(os.path.dirname(self[i][0]), dir)
65 create necessary symlinks in worker's dir if the fd is <INPUT> 66 otherwise copy <OUTPUT> file 75 dst = os.path.join(wkdir, os.path.basename(src))
76 if iomode ==
"<INPUT>":
77 if os.path.exists(dst):
80 "fds_dict.create_symlink:update_io_registry took care of src=%s" 85 "fds_dict.create_symlink:(symlink) src=%s, iomode=%s" %
89 msg.debug(
"fds_dict.create_symlink: (copy) src=%s, dst=%s" %
96 """parse the fds of the processs -> build fds_dict 101 "extract_fds: making snapshot of parent process file descriptors")
102 self.
curdir = os.path.abspath(os.curdir)
105 procfd =
'/proc/self/fd' 106 fds = os.listdir(procfd)
109 if (fd == 1
or fd == 2):
117 realname = os.path.realpath(os.path.join(procfd, i))
118 except (OSError, IOError, TypeError):
121 msg.debug(
"failed to resolve: %s ... skipping",
122 os.path.join(procfd, i))
125 if os.path.exists(realname):
127 flags = fcntl.fcntl(fd, fcntl.F_GETFL)
128 if (flags & _O_ACCMODE) == 0:
133 self.
add(fd, realname, iomode, flags)
134 except (OSError, IOError):
137 msg.debug(
"failed access to: %s ... skipping", realname)
145 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="")