| The Gaudi Framework v27r1

- 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
def | create_symlinks
def | extract_fds

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

## Detailed Description

Definition at line 10 of file FdsRegistry.py.

## Member Function Documentation

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

Definition at line 14 of file FdsRegistry.py.

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

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

Definition at line 35 of file FdsRegistry.py.

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

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 60 of file FdsRegistry.py.

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

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

    parse the fds of the processs -> build fds_dict

Definition at line 86 of file FdsRegistry.py.

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

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

Definition at line 25 of file FdsRegistry.py.

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

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

Definition at line 18 of file FdsRegistry.py.

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

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

Definition at line 52 of file FdsRegistry.py.

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

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

Definition at line 49 of file FdsRegistry.py.

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

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

Definition at line 46 of file FdsRegistry.py.

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

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

Definition at line 28 of file FdsRegistry.py.

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

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

Definition at line 39 of file FdsRegistry.py.

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

## Member Data Documentation

GaudiMP.FdsRegistry.FdsDict.curdir = None
| static

Definition at line 12 of file FdsRegistry.py.

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

Definition at line 11 of file FdsRegistry.py.

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

- GaudiMP/python/GaudiMP/FdsRegistry.py