Advertisement
DarKnighTitan

iiec_run

Jan 13th, 2020
464
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.08 KB | None | 0 0
  1. # Earlier it was named "hackrun" because it is full of hacky code.
  2. # Some dudes didn't get it tho, so we had to rename it. Hopefully they are happy now.
  3. import os
  4. import sys
  5. is_pydroid_2 = sys.version_info.major == 2
  6. mainpyfile = sys.argv[1]
  7. del sys.argv[0]
  8. fakepyfile = os.getenv("ANDROID_ORIGFNAME",mainpyfile)
  9. sys.path[0] = os.path.dirname(fakepyfile)
  10. sys.argv[0] = fakepyfile
  11.  
  12. def start(fakepyfile,mainpyfile):
  13.     if(is_pydroid_2):
  14.         import __main__
  15.         tmp=__main__.__builtins__
  16.         __main__.__dict__.clear()
  17.         __main__.__dict__.update({"__name__"    : "__main__",
  18.                       "__file__"    : fakepyfile,
  19.                       "__builtins__": tmp,
  20.                      })
  21.         execfile(mainpyfile,  __main__.__dict__)
  22.     else:
  23.         import __main__
  24.         from time import time as t69t69
  25.         start69up=t69t69()
  26.         tmp=__main__.__builtins__
  27.         __main__.__dict__.clear()
  28.         __main__.__dict__.update({"__name__"    : "__main__",
  29.                       "__file__"    : fakepyfile,
  30.                       "__builtins__": tmp,
  31.                      })
  32.         exec(open(mainpyfile).read(),  __main__.__dict__)
  33.         print('\n\n[Runtime: ', t69t69()-start69up,'s]')
  34. start(fakepyfile,mainpyfile)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement