Skip to content

Commit

Permalink
added a funtion to get the cwd - to prevent dereferncing of symlinks
Browse files Browse the repository at this point in the history
  • Loading branch information
mfiers committed Jun 25, 2012
1 parent d5258bf commit 19ad374
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/python/moa/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,22 @@
import moa.utils
import moa.logger as l

def getCwd():
"""
Do not use os.getcwd() -
need to make sure symbolic links do not get dereferenced
hijacked some code from:
http://stackoverflow.com/questions/123958/how-to-get-set-logical-directory-path-in-python
"""

cwd = os.environ.get("PWD")
if cwd is not None:
return cwd
# no environment. fall back to calling pwd on shell
cwd = subprocess.Popen('pwd', stdout=subprocess.PIPE).communicate()[0].strip()
return cwd

def getTerminalSize():
def ioctl_GWINSZ(fd):
try:
Expand Down

0 comments on commit 19ad374

Please sign in to comment.