Mercurial > hg > config
comparison python/example/install_and_exec.py @ 650:9cb40c01c10a
illustrate downloading a package and rerunning via exec
| author | Jeff Hammel <k0scist@gmail.com> |
|---|---|
| date | Mon, 24 Mar 2014 13:54:24 -0700 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 649:fbfc02ea7d8e | 650:9cb40c01c10a |
|---|---|
| 1 #!/usr/bin/env python | |
| 2 # -*- coding: utf-8 -*- | |
| 3 | |
| 4 """ | |
| 5 illustrates installation and execution following installation | |
| 6 """ | |
| 7 | |
| 8 import os | |
| 9 import subprocess | |
| 10 import sys | |
| 11 | |
| 12 here = os.path.dirname(os.path.realpath(__file__)) | |
| 13 | |
| 14 try: | |
| 15 import gnupg | |
| 16 print ("gnupg installed") | |
| 17 except ImportError: | |
| 18 print ("gnupg not installed") | |
| 19 subprocess.check_call(['pip', 'install', 'gnupg']) | |
| 20 args = [sys.executable] + sys.argv | |
| 21 os.execl(sys.executable, *args) |
