8 msg = logging.getLogger(
'FdsRegistry' )
22 msg.warning (
"fds_dict:fname: No Key %s" % i)
26 return [i
for i, v
in self.iteritems()
if v[0]==fname]
29 for v
in self.values():
35 def add(self, i, fname, iomode, flags):
36 self[i] = (fname, iomode, flags)
43 msg.warning (
"fds_dict:iomode: No Key %s" % i)
47 return [i
for i
in self.keys()
if self[i][1]==
'<OUTPUT>']
50 return [i
for i
in self.keys()
if self[i][1]==
'<INPUT>']
54 if dir ==
"" and self.
curdir is not None:
56 msg.debug(
"get_fds_in_dir(%s)" % dir)
57 return [i
for i
in self.keys()
58 if os.path.samefile(os.path.dirname(self[i][0]), dir) ]
62 create necessary symlinks in worker's dir if the fd is <INPUT> 63 otherwise copy <OUTPUT> file 71 dst = os.path.join(wkdir, os.path.basename(src))
72 if iomode ==
"<INPUT>":
73 if os.path.exists(dst):
75 msg.debug(
"fds_dict.create_symlink:update_io_registry took care of src=%s" % src)
78 msg.debug(
"fds_dict.create_symlink:(symlink) src=%s, iomode=%s" % (src,iomode))
81 msg.debug(
"fds_dict.create_symlink: (copy) src=%s, dst=%s" % (src, dst))
87 """parse the fds of the processs -> build fds_dict 90 msg.info(
"extract_fds: making snapshot of parent process file descriptors")
91 self.
curdir = os.path.abspath(os.curdir)
94 procfd =
'/proc/self/fd' 95 fds = os.listdir(procfd)
106 realname = os.path.realpath(os.path.join(procfd,i))
107 except (OSError, IOError, TypeError):
110 msg.debug(
"failed to resolve: %s ... skipping", os.path.join(procfd,i) )
113 if os.path.exists(realname):
115 flags = fcntl.fcntl(fd, fcntl.F_GETFL)
116 if (flags & _O_ACCMODE) == 0:
121 self.
add(fd, realname, iomode, flags)
122 except (OSError, IOError):
125 msg.debug(
"failed access to: %s ... skipping", realname )
133 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="")