Advertisement
Guest User

Untitled

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