| The Gaudi Framework v29r1 (5cd95fa2)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Static Public Attributes | List of all members
GaudiMP.FdsRegistry.FdsDict Class Reference
Inheritance diagram for GaudiMP.FdsRegistry.FdsDict:
[legend]
Collaboration diagram for GaudiMP.FdsRegistry.FdsDict:
[legend]

## Public Member Functions
def | __missing__ (self, key)
def | fname (self, i)
def | fds (self, fname)
def | has_name (self, fname)
def | add (self, i, fname, iomode, flags)
def | iomode (self, i)
def | get_output_fds (self)
def | get_input_fds (self)
def | get_fds_in_dir (self, dir="")
def | create_symlinks (self, wkdir="")
def | extract_fds (self, dir="")

## Static Public Attributes
string | name = "fds_dict"
| curdir = None

## Detailed Description

Definition at line 11 of file FdsRegistry.py.

## Member Function Documentation

def GaudiMP.FdsRegistry.FdsDict.__missing__ | ( |  | self,
|  |  | key
| ) |  |

Definition at line 15 of file FdsRegistry.py.

15 def __missing__(self, key):
16 self[key] = ""
17 return ""
18
GaudiMP.FdsRegistry.FdsDict.__missing__
def __missing__(self, key)
Definition: FdsRegistry.py:15

def GaudiMP.FdsRegistry.FdsDict.add | ( |  | self,
|  |  | i,
|  |  | fname,
|  |  | iomode,
|  |  | flags
| ) |  |

Definition at line 36 of file FdsRegistry.py.

36 def add(self, i, fname, iomode, flags):
37 self[i] = (fname, iomode, flags)
38 return
39
GaudiMP.FdsRegistry.FdsDict.add
def add(self, i, fname, iomode, flags)
Definition: FdsRegistry.py:36

def GaudiMP.FdsRegistry.FdsDict.create_symlinks | ( |  | self,
|  |  | wkdir = `""`
| ) |  |

    create necessary symlinks in worker's dir if the fd is <INPUT>
    otherwise copy <OUTPUT> file

Definition at line 61 of file FdsRegistry.py.

61 def create_symlinks(self, wkdir=""):
62 """
63 create necessary symlinks in worker's dir if the fd is <INPUT>
64 otherwise copy <OUTPUT> file
65 """
66 import os
67 import shutil
68 msg.info("create_symlinks: %s" % self.get_fds_in_dir())
69 # some files expected to be in curdir
70 for fd in self.get_fds_in_dir():
71 src = self[fd][0]
72 iomode = self[fd][1]
73 dst = os.path.join(wkdir, os.path.basename(src))
74 if iomode == "<INPUT>":
75 if os.path.exists(dst):
76 # update_io_registry took care of this
77 msg.debug(
78 "fds_dict.create_symlink:update_io_registry took care of src=%s" % src)
79 pass
80 else:
81 msg.debug(
82 "fds_dict.create_symlink:(symlink) src=%s, iomode=%s" % (src, iomode))
83 os.symlink(src, dst)
84 else:
85 msg.debug(
86 "fds_dict.create_symlink: (copy) src=%s, dst=%s" % (src, dst))
87 shutil.copy(src, dst)
88 pass
89 return
90
GaudiMP.FdsRegistry.FdsDict.get_fds_in_dir
def get_fds_in_dir(self, dir="")
Definition: FdsRegistry.py:53
GaudiMP.FdsRegistry.FdsDict.create_symlinks
def create_symlinks(self, wkdir="")
Definition: FdsRegistry.py:61

def GaudiMP.FdsRegistry.FdsDict.extract_fds | ( |  | self,
|  |  | dir = `""`
| ) |  |

    parse the fds of the processs -> build fds_dict

Definition at line 91 of file FdsRegistry.py.

91 def extract_fds(self, dir=""):
92 """parse the fds of the processs -> build fds_dict
93 """
94 import os
95 import fcntl
96 msg.info("extract_fds: making snapshot of parent process file descriptors")
97 self.curdir = os.path.abspath(os.curdir)
98 iomode = '<INPUT>'
99
100 procfd = '/proc/self/fd'
101 fds = os.listdir(procfd)
102 for i in fds:
103 fd = int(i) # spurious entries should raise at this point
104 if (fd == 1 or fd == 2):
105 # leave stdout and stderr to redirect_log
106 continue
107 elif (fd == 0):
108 # with only a single controlling terminal, leave stdin alone
109 continue
110
111 try:
112 realname = os.path.realpath(os.path.join(procfd, i))
113 except (OSError, IOError, TypeError):
114 # can fail because the symlink resolution (why is that needed
115 # anyway?) may follow while a temp file disappears
116 msg.debug("failed to resolve: %s ... skipping",
117 os.path.join(procfd, i))
118 continue
119
120 if os.path.exists(realname):
121 try:
122 flags = fcntl.fcntl(fd, fcntl.F_GETFL)
123 if (flags & _O_ACCMODE) == 0: # read-only --> <INPUT>
124 iomode = "<INPUT>"
125 else:
126 iomode = "<OUTPUT>"
127
128 self.add(fd, realname, iomode, flags)
129 except (OSError, IOError):
130 # likely saw a temoorary file; for now log a debug
131 # message, but this is fine if silently ignored
132 msg.debug("failed access to: %s ... skipping", realname)
133 continue
134
135 # at this point the list of fds may still include temp files
136 # TODO: figure out if they can be identified (seeing /tmp is
137 # not enough as folks like to run with data from /tmp b/c of
138 # space constraints on /afs
139
140 msg.debug("extract_fds.fds_dict=%s" % self)
141 return
142
GaudiMP.FdsRegistry.FdsDict.extract_fds
def extract_fds(self, dir="")
Definition: FdsRegistry.py:91
GaudiMP.FdsRegistry.FdsDict.add
def add(self, i, fname, iomode, flags)
Definition: FdsRegistry.py:36
GaudiMP.FdsRegistry.FdsDict.curdir
curdir
Definition: FdsRegistry.py:13

def GaudiMP.FdsRegistry.FdsDict.fds | ( |  | self,
|  |  | fname
| ) |  |

Definition at line 26 of file FdsRegistry.py.

26 def fds(self, fname):
27 return [i for i, v in self.iteritems() if v[0] == fname]
28
GaudiMP.FdsRegistry.FdsDict.fds
def fds(self, fname)
Definition: FdsRegistry.py:26

def GaudiMP.FdsRegistry.FdsDict.fname | ( |  | self,
|  |  | i
| ) |  |

Definition at line 19 of file FdsRegistry.py.

19 def fname(self, i):
20 if i in self:
21 return self[i][0]
22 else:
23 msg.warning("fds_dict:fname: No Key %s" % i)
24 return ""
25
GaudiMP.FdsRegistry.FdsDict.fname
def fname(self, i)
Definition: FdsRegistry.py:19

def GaudiMP.FdsRegistry.FdsDict.get_fds_in_dir | ( |  | self,
|  |  | dir = `""`
| ) |  |

Definition at line 53 of file FdsRegistry.py.

53 def get_fds_in_dir(self, dir=""):
54 import os
55 if dir == "" and self.curdir is not None:
56 dir = self.curdir
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)]
60
GaudiMP.FdsRegistry.FdsDict.get_fds_in_dir
def get_fds_in_dir(self, dir="")
Definition: FdsRegistry.py:53
GaudiMP.FdsRegistry.FdsDict.curdir
curdir
Definition: FdsRegistry.py:13

def GaudiMP.FdsRegistry.FdsDict.get_input_fds | ( |  | self | ) |

Definition at line 50 of file FdsRegistry.py.

50 def get_input_fds(self):
51 return [i for i in self.keys() if self[i][1] == '<INPUT>']
52
GaudiMP.FdsRegistry.FdsDict.get_input_fds
def get_input_fds(self)
Definition: FdsRegistry.py:50

def GaudiMP.FdsRegistry.FdsDict.get_output_fds | ( |  | self | ) |

Definition at line 47 of file FdsRegistry.py.

47 def get_output_fds(self):
48 return [i for i in self.keys() if self[i][1] == '<OUTPUT>']
49
GaudiMP.FdsRegistry.FdsDict.get_output_fds
def get_output_fds(self)
Definition: FdsRegistry.py:47

def GaudiMP.FdsRegistry.FdsDict.has_name | ( |  | self,
|  |  | fname
| ) |  |

Definition at line 29 of file FdsRegistry.py.

29 def has_name(self, fname):
30 for v in self.values():
31 if (v[0] == fname):
32 return True
33 return False
34
GaudiMP.FdsRegistry.FdsDict.has_name
def has_name(self, fname)
Definition: FdsRegistry.py:29

def GaudiMP.FdsRegistry.FdsDict.iomode | ( |  | self,
|  |  | i
| ) |  |

Definition at line 40 of file FdsRegistry.py.

40 def iomode(self, i):
41 if i in self:
42 return self[i][1]
43 else:
44 msg.warning("fds_dict:iomode: No Key %s" % i)
45 return ""
46
GaudiMP.FdsRegistry.FdsDict.iomode
def iomode(self, i)
Definition: FdsRegistry.py:40

## Member Data Documentation

GaudiMP.FdsRegistry.FdsDict.curdir = None
| static

Definition at line 13 of file FdsRegistry.py.

string GaudiMP.FdsRegistry.FdsDict.name = "fds_dict"
| static

Definition at line 12 of file FdsRegistry.py.

The documentation for this class was generated from the following file:

- GaudiMP/python/GaudiMP/FdsRegistry.py