mirror of
https://github.com/MCMi460/3DS-RPC.git
synced 2025-06-19 22:15:40 -04:00
[Cleanup] Rework __main__: Add cleaner command line & Remove unneeded function.
This commit is contained in:
parent
51d10c75bb
commit
4918ffb61c
@ -5,7 +5,7 @@ from nintendo import nasc
|
|||||||
from nintendo.nex import backend, friends, settings, streams
|
from nintendo.nex import backend, friends, settings, streams
|
||||||
from nintendo.nex import common
|
from nintendo.nex import common
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
import anyio, time, sqlite3, sys, traceback
|
import anyio, time, sqlite3, sys, traceback, argparse
|
||||||
sys.path.append('../')
|
sys.path.append('../')
|
||||||
from api.private import SERIAL_NUMBER, MAC_ADDRESS, DEVICE_CERT, DEVICE_NAME, REGION, LANGUAGE, NINTENDO_PID, PRETENDO_PID, PID_HMAC, NINTENDO_NEX_PASSWORD, PRETENDO_NEX_PASSWORD
|
from api.private import SERIAL_NUMBER, MAC_ADDRESS, DEVICE_CERT, DEVICE_NAME, REGION, LANGUAGE, NINTENDO_PID, PRETENDO_PID, PID_HMAC, NINTENDO_NEX_PASSWORD, PRETENDO_NEX_PASSWORD
|
||||||
from api import *
|
from api import *
|
||||||
@ -186,35 +186,22 @@ async def main():
|
|||||||
print('An error occurred!\n%s' % e)
|
print('An error occurred!\n%s' % e)
|
||||||
print(traceback.format_exc())
|
print(traceback.format_exc())
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
def invalidArgument():
|
|
||||||
print("Missing or Invalid Network Selection!") # Probs a better way to do these prints, but oh well, if it works, it works
|
|
||||||
print("")
|
|
||||||
print("Valid options are (seperated by commas):")
|
|
||||||
print("nintendo, 0,")
|
|
||||||
print("pretendo, 1")
|
|
||||||
exit()
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
try:
|
try:
|
||||||
if len(sys.argv) <= 1:
|
parser = argparse.ArgumentParser()
|
||||||
invalidArgument()
|
parser.add_argument('--network', choices=[member.name.lower() for member in NetworkIDsToName], required=True)
|
||||||
if sys.argv[1].isnumeric(): # number check!
|
args = parser.parse_args()
|
||||||
if (int(sys.argv[1]) in [e.value for e in NetworkIDsToName]):
|
|
||||||
network = int(sys.argv[1])
|
network = NetworkIDsToName[args.network.lower()]
|
||||||
else:
|
|
||||||
invalidArgument()
|
if network == NetworkIDsToName.pretendo:
|
||||||
else:
|
|
||||||
if (sys.argv[1] in [e.name for e in NetworkIDsToName]):
|
|
||||||
network = int(NetworkIDsToName[sys.argv[1]].value)
|
|
||||||
else:
|
|
||||||
invalidArgument()
|
|
||||||
if network == 1:
|
|
||||||
# I have no idea why getting rid of this delay works to fix pretendo, nor do i know why it was here in the first place, but dropping it for pretendo works, so who am i to judge?
|
# I have no idea why getting rid of this delay works to fix pretendo, nor do i know why it was here in the first place, but dropping it for pretendo works, so who am i to judge?
|
||||||
delay = 0
|
delay, quicker = 0, 1
|
||||||
quicker = 1
|
|
||||||
startDBTime(begun, network)
|
startDBTime(begun, network.value)
|
||||||
anyio.run(main)
|
anyio.run(main)
|
||||||
except (KeyboardInterrupt, Exception) as e:
|
except (KeyboardInterrupt, Exception) as e:
|
||||||
if network != None:
|
if network is not None:
|
||||||
startDBTime(0, network)
|
startDBTime(0, network.value)
|
||||||
print(e)
|
print(e)
|
Loading…
Reference in New Issue
Block a user