Guest User

Untitled

a guest
May 30th, 2014
325
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. # cat /usr/lib/python-exec/python-exec2
  2. #!/usr/lib/python-exec/python-exec2-c
  3. # vim:fileencoding=utf-8:ft=python
  4. # (c) 2012 Michał Górny
  5. # Released under the terms of the 2-clause BSD license.
  6. #
  7. # This is not the script you are looking for. This is just a wrapper.
  8. # The actual scripts of this application were installed with -python*,
  9. # -pypy* or -jython* suffixes. You are most likely looking for one
  10. # of those.
  11.  
  12. from __future__ import with_statement
  13. import os, os.path, sys
  14.  
  15. try:
  16. from epython import EPYTHON
  17. except ImportError:
  18. EPYTHON = os.path.basename(sys.executable)
  19. if '' and EPYTHON.endswith(''):
  20. EPYTHON = EPYTHON[:-len('')]
  21.  
  22. # In the loop:
  23. # sys.argv[0] keeps the 'bare' name
  24. # __file__ keeps the 'full' name
  25.  
  26. while True:
  27. __file__ = os.path.join('/usr/lib/python-exec', EPYTHON,
  28. os.path.basename(sys.argv[0]))
  29.  
  30. try:
  31. kwargs = {}
  32. if sys.version_info[0] >= 3:
  33. import tokenize
  34.  
  35. # need to provide encoding
  36. with open(__file__, 'rb') as f:
  37. kwargs['encoding'] = tokenize.detect_encoding(f.readline)[0]
  38.  
  39. with open(__file__, 'r', **kwargs) as f:
  40. data = f.read()
  41. except IOError:
  42. # follow symlinks (if supported)
  43. try:
  44. sys.argv[0] = os.path.join(os.path.dirname(sys.argv[0]),
  45. os.readlink(sys.argv[0]))
  46. except (OSError, AttributeError):
  47. # no more symlinks? then it's time to fail.
  48. sys.stderr.write('This Python implementation (%s) is not supported by the script.\n'
  49. % EPYTHON)
  50. sys.exit(127)
  51. else:
  52. break
  53.  
  54. sys.argv[0] = __file__
  55. exec(data)
Advertisement
Add Comment
Please, Sign In to add comment