Source code for PyFoam.ThirdParty.winhacks

'''
------------------------------------------------------------------------------
 License
    This file is part of blueCAPE's modifications to PyFoam for working on
    Windows. For more information on these modifications, visit:
        http://www.bluecape.com.pt/blueCFD

    PyFoam is free software; you can redistribute it and/or modify it
    under the terms of the GNU General Public License as published by the
    Free Software Foundation; either version 2 of the License, or (at your
    option) any later version.  See the file COPYING in this directory,
    for a description of the GNU General Public License terms under which 
    you can copy the files.

 Script
     winhacks.py

 Description
     This script file acts mostly as a dummy stub for several POSIX functions
     that are not available on Windows and on Python for Windows.
     Source code available on this file is a compilation of public domain
     solutions.

------------------------------------------------------------------------------
'''

import os

__CSL = None


[docs]def getlogin(): '''getlogin() Get login username from environment.''' return os.getenv('USERNAME')
[docs]def getloadavg(): '''Dummy result, 1 to avoid division by zero''' return 1
'''hack the three functions above into the os module''' os.symlink = symlink os.getlogin = getlogin os.getloadavg = getloadavg """These 3 can be improved if we use http://code.google.com/p/psutil/""" """All return 1 to avoid divisions by zero"""
[docs]def getrusage(who): return 1
[docs]def getpagesize(): return 1
RUSAGE_CHILDREN = 1