0

Minor changes to the contrib manager

add --list-contribs option
construct sys.argv correctly for the contrib scripts
This commit is contained in:
Andrew Chin
2011-08-17 09:16:39 -04:00
parent cd2a2bdf2c
commit 99932f35a3

View File

@@ -5,6 +5,8 @@
import sys
import os.path
sys.path.append("overviewer_core")
import nbt
scripts=dict( # keys are names, values are scripts
benchmark="benchmark.py",
@@ -12,6 +14,12 @@ scripts=dict( # keys are names, values are scripts
validate="validateRegionFile.py"
)
# you can symlink or hardlink contribManager.py to another name to have it
# automatically find the right script to run. For example:
# > ln -s contribManager.py validate.exe
# > chmod +x validate.exe
# > ./validate.exe -h
# figure out what script to execute
argv=os.path.basename(sys.argv[0])
@@ -21,18 +29,26 @@ if argv[-4:] == ".exe":
if argv[-3:] == ".py":
argv=argv[0:-3]
print "argv is ", argv
if argv in scripts.keys():
script = scripts[argv]
sys.argv[0] = script
else:
if sys.argv[1] in scripts.keys():
if "--list-contribs" in sys.argv:
print scripts.keys()
sys.exit(0)
if len(sys.argv) > 1 and sys.argv[1] in scripts.keys():
script = scripts[sys.argv[1]]
sys.argv = [script] + sys.argv[2:]
else:
print "what do you want to run?"
sys.exit(1)
print "running", script
torun = os.path.join("contrib", script)
if not os.path.exists(torun):
print "Script '%s' is missing!" % script
sys.exit(1)
execfile(torun)
execfile(os.path.join("contrib", script))