add --unpack cmd-opt

This commit is contained in:
Christopher Roy Bratusek 2012-11-25 11:49:09 +01:00
parent 4cd1cf23af
commit bb7ca22946
3 changed files with 33 additions and 5 deletions

View File

@ -8,6 +8,7 @@
-h / --help = show help -h / --help = show help
-v / --version = show Qwad version and exit -v / --version = show Qwad version and exit
-d / --download = download IOS (see examples below) -d / --download = download IOS (see examples below)
-u / --unpack = unpack a wad file
-g / --getversions = get available versions of given IOS -g / --getversions = get available versions of given IOS
-c / --convert = convert IOS name to hex (and vice versa) -c / --convert = convert IOS name to hex (and vice versa)
====================================================================== ======================================================================
@ -19,6 +20,11 @@
qwad -d 000000010000003a 6176 $PWD/IOS58.wad True False qwad -d 000000010000003a 6176 $PWD/IOS58.wad True False
>> Result: IOS58.wad >> Result: IOS58.wad
**Unpack**
qwad -u <WAD> <FOLDER>
qwad -u IOS58.wad IOS58-Unpacked
>> Result: IOS58-Unpacked/
**GetVersions** **GetVersions**
qwad -g <IOS> qwad -g <IOS>
qwad -g IOS9 qwad -g IOS9

View File

@ -5,7 +5,7 @@ from optparse import OptionParser
from optparse import Option, OptionValueError from optparse import Option, OptionValueError
from PyQt4.QtGui import QApplication from PyQt4.QtGui import QApplication
from PyQt4.QtCore import QTranslator, QString, QLocale from PyQt4.QtCore import QTranslator, QString, QLocale
from GUI.VenPri import MWQwad, nusDownloadingCLI from GUI.VenPri import MWQwad, nusDownloadingCLI, PackingCLI, UnpackingCLI
from TitleIDs import TitleDict, IOSdict, swap_dic from TitleIDs import TitleDict, IOSdict, swap_dic
class MultipleOption(Option): class MultipleOption(Option):
@ -23,6 +23,7 @@ class MultipleOption(Option):
VERSION = '0.6' VERSION = '0.6'
def opts(): def opts():
os.chdir(sys.path[0])
description = """NUS-Downloader, WadManager and TMD-Viewer for Linux""" description = """NUS-Downloader, WadManager and TMD-Viewer for Linux"""
parser = OptionParser(option_class=MultipleOption, parser = OptionParser(option_class=MultipleOption,
usage='usage: qwad [OPTIONS] ARGUMENT', usage='usage: qwad [OPTIONS] ARGUMENT',
@ -31,11 +32,14 @@ def opts():
action="extend", type="string", action="extend", type="string",
dest='download', dest='download',
metavar='Arguments', metavar='Arguments',
help='IOS <IOS> <Version> <Output> <DeCrypt> <Pack>') help="IOS Version Output Decrypt Pack")
parser.add_option('-u', "--unpack", dest="unpack", action="extend",
type="string", metavar='Arguments', help="unpack a WAD")
parser.add_option('-g', "--getversions", dest="getversions", parser.add_option('-g', "--getversions", dest="getversions",
action="store_true", default=False, help="get available versions for IOS") action="store_true", default=False, help="get available versions for IOS")
parser.add_option('-c', "--convert", dest="convert", parser.add_option('-c', "--convert", dest="convert",
action="store_true", default=False, help="convert between IOSX and xxxxxxx-xxxxxxx") action="store_true", default=False, help="convert between IOSxx and hex-value")
parser.add_option("-v", "--version", dest="version", parser.add_option("-v", "--version", dest="version",
action="store_true", default=False, help="print version and exit") action="store_true", default=False, help="print version and exit")
@ -73,6 +77,24 @@ def opts():
print "%s == %s" % (str(args[0]), xarg) print "%s == %s" % (str(args[0]), xarg)
sys.exit(0) sys.exit(0)
if options.unpack:
if os.access(str(options.unpack[0]), os.R_OK):
wad = str(options.unpack[0])
else:
print "WAD file %s does not exist." % str(options.unpack[0])
sys.exit(1)
if os.access(str(args[0]), os.W_OK):
folder = str(args[0])
else:
os.mkdir(str(args[0]), 0755)
if os.access(str(args[0]), os.W_OK):
folder = str(args[0])
UnpackingCLI(wad, folder).start()
sys.exit(0)
else:
print "Output folder %s not writeable." % str(args[0])
sys.exit(1)
def main(): def main():
# load our own translations # load our own translations
translator = QTranslator() translator = QTranslator()

4
qwad
View File

@ -1,3 +1,3 @@
#!/bin/sh #!/bin/sh
cd /usr/share/Qwad PYTHONPATH="/usr/share/Qwad/"
python Qwad.pyw $@ python /usr/share/Qwad/Qwad.pyw $@