mirror of
https://github.com/a2-4am/passport.py.git
synced 2024-06-01 20:41:28 +00:00
command line changes
This commit is contained in:
parent
6831c7bca6
commit
deb27ebca9
54
passport.py
54
passport.py
|
@ -3,30 +3,40 @@
|
||||||
from passport import *
|
from passport import *
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
def usage():
|
def usage(error_code):
|
||||||
print("usage: passport image.woz [Crack]\n"
|
exe = sys.argv[0]
|
||||||
" passport image.woz [Verify]\n"
|
print(STRINGS["header"])
|
||||||
" passport image.edd [Convert]\n"
|
print("""usage: {exe} crack image.woz
|
||||||
" default is Crack if .woz specified, Convert if .edd is specified"
|
{exe} verify image.woz
|
||||||
)
|
{exe} convert image.edd""".format(**locals()))
|
||||||
sys.exit()
|
sys.exit(error_code)
|
||||||
|
|
||||||
args = len(sys.argv)
|
args = len(sys.argv)
|
||||||
|
|
||||||
if args < 2:
|
if args < 3:
|
||||||
usage()
|
usage(0)
|
||||||
|
|
||||||
base, ext = os.path.splitext(sys.argv[1])
|
cmd, inputfile = sys.argv[1:3]
|
||||||
ext = ext.lower()
|
if cmd == "crack":
|
||||||
|
processor = Crack
|
||||||
if ext == ".woz":
|
elif cmd == "verify":
|
||||||
if args == 2 or sys.argv[2].lower() == "crack":
|
processor = Verify
|
||||||
Crack(wozimage.WozReader(sys.argv[1]), DefaultLogger)
|
elif cmd == "convert":
|
||||||
elif sys.argv[2].lower() == "verify":
|
processor = EDDToWoz
|
||||||
Verify(wozimage.WozReader(sys.argv[1]), DefaultLogger)
|
|
||||||
else:
|
|
||||||
usage()
|
|
||||||
elif ext == ".edd":
|
|
||||||
EDDToWoz(wozimage.EDDReader(sys.argv[1]), DefaultLogger)
|
|
||||||
else:
|
else:
|
||||||
raise RuntimeError("unrecognized file type")
|
print("unrecognized command")
|
||||||
|
usage(1)
|
||||||
|
|
||||||
|
base, ext = os.path.splitext(inputfile)
|
||||||
|
ext = ext.lower()
|
||||||
|
if ext == ".woz":
|
||||||
|
reader = wozimage.WozReader
|
||||||
|
elif ext == ".edd":
|
||||||
|
reader = wozimage.EDDReader
|
||||||
|
else:
|
||||||
|
print("unrecognized file type")
|
||||||
|
usage(1)
|
||||||
|
|
||||||
|
logger = DefaultLogger # TODO add flag to change this
|
||||||
|
|
||||||
|
processor(reader(inputfile), logger)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
STRINGS = {
|
STRINGS = {
|
||||||
"header": "Passport.py by 4am (2018-05-21)\n", # max 32 characters
|
"header": "Passport.py by 4am (2018-05-24)\n", # max 32 characters
|
||||||
"reading": "Reading from {filename}\n",
|
"reading": "Reading from {filename}\n",
|
||||||
"diskrwts": "Using disk's own RWTS\n",
|
"diskrwts": "Using disk's own RWTS\n",
|
||||||
"bb00": "T00,S05 Found $BB00 protection check\n"
|
"bb00": "T00,S05 Found $BB00 protection check\n"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user