pmbootstrap.py: move all features to pmb:main()
Prepare to modernize the python packaging. pmbootstrap.py will not be part of the packaging, so add a note there and move both features (python version check, ^C check) to pmb/__init__.py:main(). Reviewed-by: Luca Weiss <luca@z3ntu.xyz> Link: https://lists.sr.ht/~postmarketos/pmbootstrap-devel/%3C20230407233026.1712-3-ollieparanoid@postmarketos.org%3E
This commit is contained in:
parent
49cd288078
commit
5d28c5ccf3
|
@ -14,6 +14,13 @@ from .helpers import logging as pmb_logging
|
|||
from .helpers import mount
|
||||
from .helpers import other
|
||||
|
||||
version = sys.version_info
|
||||
if version < (3, 7):
|
||||
print("You need at least Python 3.7 to run pmbootstrap")
|
||||
print("(You are running it with Python " + str(version.major) +
|
||||
"." + str(version.minor) + ")")
|
||||
sys.exit()
|
||||
|
||||
|
||||
def main():
|
||||
# Wrap everything to display nice error messages
|
||||
|
@ -59,6 +66,10 @@ def main():
|
|||
" shutdown' as necessary)")
|
||||
logging.info("DONE!")
|
||||
|
||||
except KeyboardInterrupt:
|
||||
print("\nCaught KeyboardInterrupt, exiting …")
|
||||
sys.exit(130) # SIGINT(2) + 128
|
||||
|
||||
except Exception as e:
|
||||
# Dump log to stdout when args (and therefore logging) init failed
|
||||
if not args:
|
||||
|
|
|
@ -4,17 +4,9 @@
|
|||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
# PYTHON_ARGCOMPLETE_OK
|
||||
import sys
|
||||
version = sys.version_info
|
||||
if version < (3, 7):
|
||||
print("You need at least Python 3.7 to run pmbootstrap")
|
||||
print("(You are running it with Python " + str(version.major) +
|
||||
"." + str(version.minor) + ")")
|
||||
sys.exit()
|
||||
import pmb
|
||||
|
||||
# A convenience wrapper for running pmbootstrap from the git repository. This
|
||||
# script is not part of the python packaging, so don't add more logic here!
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
sys.exit(pmb.main())
|
||||
except KeyboardInterrupt:
|
||||
print("\nCaught KeyboardInterrupt, exiting …")
|
||||
sys.exit(130) # SIGINT(2) + 128
|
||||
sys.exit(pmb.main())
|
||||
|
|
Loading…
Reference in New Issue