Mercurial > hg > config
annotate python/example/install_and_exec.py @ 923:b25fbb9257ec
Breeze GTK theme
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Thu, 14 Nov 2024 09:30:28 -0800 |
parents | 9cb40c01c10a |
children |
rev | line source |
---|---|
650
9cb40c01c10a
illustrate downloading a package and rerunning via exec
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
1 #!/usr/bin/env python |
9cb40c01c10a
illustrate downloading a package and rerunning via exec
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
2 # -*- coding: utf-8 -*- |
9cb40c01c10a
illustrate downloading a package and rerunning via exec
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
3 |
9cb40c01c10a
illustrate downloading a package and rerunning via exec
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
4 """ |
9cb40c01c10a
illustrate downloading a package and rerunning via exec
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
5 illustrates installation and execution following installation |
9cb40c01c10a
illustrate downloading a package and rerunning via exec
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
6 """ |
9cb40c01c10a
illustrate downloading a package and rerunning via exec
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
7 |
9cb40c01c10a
illustrate downloading a package and rerunning via exec
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
8 import os |
9cb40c01c10a
illustrate downloading a package and rerunning via exec
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
9 import subprocess |
9cb40c01c10a
illustrate downloading a package and rerunning via exec
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
10 import sys |
9cb40c01c10a
illustrate downloading a package and rerunning via exec
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
11 |
9cb40c01c10a
illustrate downloading a package and rerunning via exec
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
12 here = os.path.dirname(os.path.realpath(__file__)) |
9cb40c01c10a
illustrate downloading a package and rerunning via exec
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
13 |
9cb40c01c10a
illustrate downloading a package and rerunning via exec
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
14 try: |
9cb40c01c10a
illustrate downloading a package and rerunning via exec
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
15 import gnupg |
9cb40c01c10a
illustrate downloading a package and rerunning via exec
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
16 print ("gnupg installed") |
9cb40c01c10a
illustrate downloading a package and rerunning via exec
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
17 except ImportError: |
9cb40c01c10a
illustrate downloading a package and rerunning via exec
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
18 print ("gnupg not installed") |
9cb40c01c10a
illustrate downloading a package and rerunning via exec
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
19 subprocess.check_call(['pip', 'install', 'gnupg']) |
9cb40c01c10a
illustrate downloading a package and rerunning via exec
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
20 args = [sys.executable] + sys.argv |
9cb40c01c10a
illustrate downloading a package and rerunning via exec
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
21 os.execl(sys.executable, *args) |