1
0
Fork 0
mirror of https://github.com/DarkMatterCore/nxdumptool.git synced 2024-11-26 12:12:02 +00:00

Renamed script.

Also added a license notice at the top and modified it to create the provided output path if needed.
This commit is contained in:
Pablo Curiel 2021-02-18 23:18:30 -04:00
parent 954e250151
commit c6a60dcf1e

View file

@ -1,5 +1,29 @@
#!/usr/bin/env python3
"""
* nxdt_host.py
*
* Copyright (c) 2021, sigmaboy.
* Copyright (c) 2021, DarkMatterCore <pabloacurielz@gmail.com>.
*
* This file is part of nxdumptool (https://github.com/DarkMatterCore/nxdumptool).
*
* nxdumptool is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* nxdumptool is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
# This script depends on PyUSB and tdqm.
# You can install both with `pip install pyusb tqdm`.
import os
import usb.core
import usb.util
@ -490,10 +514,15 @@ def main():
# Expand environment variables and user's home directory.
g_outputDir = os.path.abspath(os.path.expanduser(os.path.expandvars(sys.argv[1])))
# Make sure we're dealing with an existing directory.
if (os.path.exists(g_outputDir) == False) or (os.path.isdir(g_outputDir) == False):
print('The provided path doesn\'t point to an existing directory!')
# Check if the provided directory exists.
if os.path.exists(g_outputDir) == True:
# Make sure it's a directory.
if os.path.isdir(g_outputDir) == False:
print('The provided path points to an existing file!')
return
else:
# Create directory.
os.mkdir(g_outputDir)
else:
# Create 'nxdumptool' subdirectory in the directory where the script is located.
g_outputDir = (sys.path[0] + os.path.sep + 'nxdumptool')