ModuleUpdater: add -f and -y switches
-f: force update -y: skip question to run pip
This commit is contained in:
parent
eb0e5b7438
commit
1bd55b4572
|
@ -23,10 +23,13 @@ def update_command():
|
||||||
subprocess.call([sys.executable, '-m', 'pip', 'install', '-r', file, '--upgrade'])
|
subprocess.call([sys.executable, '-m', 'pip', 'install', '-r', file, '--upgrade'])
|
||||||
|
|
||||||
|
|
||||||
def update():
|
def update(yes = False, force = False):
|
||||||
global update_ran
|
global update_ran
|
||||||
if not update_ran:
|
if not update_ran:
|
||||||
update_ran = True
|
update_ran = True
|
||||||
|
if force:
|
||||||
|
update_command()
|
||||||
|
return
|
||||||
for req_file in requirements_files:
|
for req_file in requirements_files:
|
||||||
path = os.path.join(os.path.dirname(sys.argv[0]), req_file)
|
path = os.path.join(os.path.dirname(sys.argv[0]), req_file)
|
||||||
if not os.path.exists(path):
|
if not os.path.exists(path):
|
||||||
|
@ -38,6 +41,7 @@ def update():
|
||||||
try:
|
try:
|
||||||
pkg_resources.require(requirement)
|
pkg_resources.require(requirement)
|
||||||
except pkg_resources.ResolutionError:
|
except pkg_resources.ResolutionError:
|
||||||
|
if not yes:
|
||||||
import traceback
|
import traceback
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
input(f'Requirement {requirement} is not satisfied, press enter to install it')
|
input(f'Requirement {requirement} is not satisfied, press enter to install it')
|
||||||
|
@ -46,4 +50,10 @@ def update():
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
update()
|
import argparse
|
||||||
|
parser = argparse.ArgumentParser(description='Install archipelago requirements')
|
||||||
|
parser.add_argument('-y', '--yes', dest='yes', action='store_true', help='answer "yes" to all questions')
|
||||||
|
parser.add_argument('-f', '--force', dest='force', action='store_true', help='force update')
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
update(args.yes, args.force)
|
||||||
|
|
Loading…
Reference in New Issue