1
0
mirror of https://github.com/Melon-Bread/EagleJab synced 2024-11-28 13:58:20 -05:00

Overhauled Agrument Parser & Open CIA Dialog

This commit is contained in:
Rain Clark 2015-04-29 18:11:06 -04:00
parent bcb0d73a43
commit 57ecc3ca3e

View File

@ -1,21 +1,45 @@
#!/usr/bin/env python #!/usr/bin/env python
import os, socket, sys, struct, easygui import os, platform, argparse, socket, sys, struct, easygui
statinfo = os.stat(sys.argv[1]) # New & improved args parsing
parser = argparse.ArgumentParser(description='Sends .CIA files to the 3DS via FBI')
parser.add_argument('-c', '--cia', help='.CIA rom file', metavar='FILE', required=False, nargs=1)
parser.add_argument('-i', '--ip', help='The IP address of the target 3DS (e.g. 192.168.1.123)', metavar='STRING',
required=False, nargs=1)
args = parser.parse_args()
# Ask for the desired .CIA file if none is given
if args.cia:
cia = args.cia[0]
else:
cia = easygui.fileopenbox("Choose CIA to Send", "Falcon Punch", default="/", filetypes=["*.cia", "*.*"],
multiple=False)
statinfo = os.stat(cia)
fbiinfo = struct.pack('!q', statinfo.st_size) fbiinfo = struct.pack('!q', statinfo.st_size)
p = sys.argv[1]
dsip = easygui.enterbox("Enter 3DS' IP:", "FalconPunch", "192.168.1.1")
file = open(p, "rb") # Asks for the IP address of the 3DS if none is given
if args.ip:
dsip = args.ip[0]
else:
dsip = easygui.enterbox("Enter 3DS' IP:", "FalconPunch", "192.168.1.1")
file = open(cia, "rb")
sock = socket.socket() sock = socket.socket()
sock.connect((dsip, 5000)) sock.connect((dsip, 5000))
sock.send(fbiinfo) sock.send(fbiinfo)
# Sends the each chunk of the .CIA till there is nothing left
while True: while True:
chunk = file.read(16384) chunk = file.read(16384)
if not chunk: if not chunk:
easygui.msgbox("Sent " + p + " to the 3DS", "FalconPunch") # Prints or displays a confirmation based on how the program is given info
confirmation = "Sent " + cia + " to the 3DS (" + dsip + ")"
if args.cia and args.ip:
print(confirmation)
else:
easygui.msgbox(confirmation, "FalconPunch")
break # EOF break # EOF
sock.sendall(chunk) sock.sendall(chunk)