Skip to content

Commit

Permalink
stop hanging checking commands, fix for Windows when renaming final CIA
Browse files Browse the repository at this point in the history
  • Loading branch information
ihaveamac committed Apr 15, 2016
1 parent 08088ca commit 628bbb3
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions 3dsconv.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
output_directory = ""

#################
version = "2.0"
version = "2.01"

helptext = """3dsconv.py ~ version %s
https://github.com/ihaveamac/3dsconv
Expand All @@ -29,13 +29,20 @@
or in the directory specified by --xorpads=<dir>
- encrypted and decrypted roms can be converted at the same time"""

cleanup = not "--nocleanup" in sys.argv
verbose = "--verbose" in sys.argv

def print_v(msg):
if verbose:
print(msg)

def testcommand(cmd):
print_v("- testing: %s" % cmd)
try:
proc = subprocess.Popen([cmd], stdout=subprocess.PIPE, stderr=subprocess.PIPE).wait()
proc = subprocess.Popen([cmd], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
proc.stdout.close()
proc.stderr.close()
proc.wait()
return True
except OSError as e:
if e.errno != 2:
Expand Down Expand Up @@ -102,9 +109,6 @@ def docleanup(tid):
if not os.path.isdir("work"):
raise

cleanup = not "--nocleanup" in sys.argv
verbose = "--verbose" in sys.argv

# probably should've used argparse
for arg in sys.argv[1:]:
if arg[:2] != "--":
Expand Down Expand Up @@ -219,6 +223,8 @@ def docleanup(tid):
runcommand(cmds)
os.chdir("..")

# apparently if the file exists, it will throw an error on Windows
silentremove(os.path.join(output_directory, romname+".cia"))
os.rename("work/%s-game-conv.cia" % tid, os.path.join(output_directory, romname+".cia"))
if cleanup:
docleanup(tid)
Expand Down

0 comments on commit 628bbb3

Please sign in to comment.