| # Gaudi Framework, version v22r4 |

Home |  | Generated: Fri Sep 2 2011

Public Member Functions | Static Public Attributes

# GaudiMP::FdsRegistry::FdsDict Class Reference

Collaboration diagram for GaudiMP::FdsRegistry::FdsDict:
[legend]

List of all members.

## Public Member Functions
def | __missing__
def | fname
def | fds
def | has_name
def | add
def | iomode
def | get_output_fds
def | get_input_fds
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.

    00015                               :
    00016         self[key] = ""
    00017         return ""

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

Definition at line 35 of file FdsRegistry.py.

    00036                                           :
    00037         self[i] = (fname, iomode, flags)
    00038         return

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.

    00061                                        :
    00062         """
    00063         create necessary symlinks in worker's dir if the fd is <INPUT>
    00064         otherwise copy <OUTPUT> file
    00065         """
    00066         import os,shutil
    00067         msg.info("create_symlinks: %s" % self.get_fds_in_dir())
    00068         #some files expected to be in curdir
    00069         for fd in self.get_fds_in_dir():
    00070             src = self[fd][0]
    00071             iomode = self[fd][1]
    00072             dst = os.path.join(wkdir, os.path.basename(src))
    00073             if iomode == "<INPUT>":
    00074                 if os.path.exists(dst):
    00075                     # update_io_registry took care of this
    00076                     msg.debug("fds_dict.create_symlink:update_io_registry took care of src=%s" % src)
    00077                     pass
    00078                 else:
    00079                     msg.debug("fds_dict.create_symlink:(symlink) src=%s, iomode=%s" % (src,iomode))
    00080                     os.symlink(src, dst)
    00081             else:
    00082                 msg.debug("fds_dict.create_symlink: (copy) src=%s, dst=%s" % (src, dst))
    00083                 shutil.copy(src, dst)
    00084                 pass
    00085         return

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.

    00087                                  :
    00088         """parse the fds of the processs -> build fds_dict
    00089         """
    00090         import os, fcntl
    00091         msg.info("extract_fds: making snapshot of parent process file descriptors")
    00092         self.curdir = os.path.abspath(os.curdir)
    00093         iomode = '<INPUT>'
    00094
    00095         procfd = '/proc/self/fd'
    00096         fds = os.listdir(procfd)
    00097         for i in fds:
    00098             fd = int(i)
    00099             if (fd==1 or fd==2):
    00100                 #leave stdout and stderr to redirect_log
    00101                 continue
    00102             realname = os.path.realpath(os.path.join(procfd,i))
    00103             if os.path.exists(realname):
    00104                 flags = fcntl.fcntl(fd, fcntl.F_GETFL)
    00105                 if (flags & _O_ACCMODE) == 0: #read-only --> <INPUT>
    00106                     iomode = "<INPUT>"
    00107                 else:
    00108                     iomode = "<OUTPUT>"
    00109
    00110                 self.add(fd, realname, iomode, flags)
    00111
    00112         msg.debug( "extract_fds.fds_dict=%s" % self)
    00113         return

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

Definition at line 25 of file FdsRegistry.py.

    00026                         :
    00027         return [i for i, v in self.iteritems() if v[0]==fname]

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

Definition at line 18 of file FdsRegistry.py.

    00019                      :
    00020         if i in self:
    00021             return self[i][0]
    00022         else:
    00023             msg.warning ("fds_dict:fname: No Key %s" % i)
    00024             return ""

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

Definition at line 52 of file FdsRegistry.py.

    00053                                     :
    00054         import os
    00055         if dir == "" and self.curdir is not None:
    00056             dir = self.curdir
    00057         msg.debug("get_fds_in_dir(%s)" % dir)
    00058         return [i for i in self.keys()
    00059                 if os.path.samefile(os.path.dirname(self[i][0]), dir) ]

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

Definition at line 49 of file FdsRegistry.py.

    00050                            :
    00051         return [i for i in self.keys() if self[i][1]=='<INPUT>']

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

Definition at line 46 of file FdsRegistry.py.

    00047                             :
    00048         return [i for i in self.keys() if self[i][1]=='<OUTPUT>']

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

Definition at line 28 of file FdsRegistry.py.

    00029                              :
    00030         for v in self.values():
    00031             if (v[0] == fname):
    00032                 return True
    00033         return False

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

Definition at line 39 of file FdsRegistry.py.

    00040                       :
    00041         if i in self:
    00042             return self[i][1]
    00043         else:
    00044             msg.warning ("fds_dict:iomode: No Key %s" % i)
    00045             return ""

## 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:

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v22r4/GaudiMP/python/GaudiMP/FdsRegistry.py

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines