예제 #1
0
파일: legojam.py 프로젝트: le717/PatchIt
def SelectDataFiles():
    """Select the files to compress into a JAM"""
    # Draw (then withdraw) the root Tk window
    logging.info("Drawing root Tk window")
    root = Tk()
    logging.info("Withdrawing root Tk window")
    root.withdraw()

    # Overwrite root display settings
    logging.info("Overwrite root settings to basically hide it")
    root.overrideredirect(True)
    root.geometry('0x0+0+0')

    # Show window again, lift it so it can recieve the focus
    # Otherwise, it is behind the console window
    root.deiconify()
    root.lift()
    root.focus_force()

    # The files to be compressed
    jam_files = filedialog.askdirectory(
        parent=root,
        title="Where are the extracted LEGO.JAM files located?"
    )

    if not jam_files:
        root.destroy()
        colors.text("\nCould not find a JAM archive to compress!",
                    color.FG_LIGHT_RED)
        main()

    # Compress the JAM
    root.destroy()
    BuildJAM(jam_files)
예제 #2
0
파일: legojam.py 프로젝트: le717/PatchIt
def main(*args):
    """JAM Extractor Menu"""
    colors.text('''
JAM Extractor 1.0.2
COPYRIGHT (C) 2012-2013: JrMasterModelBuilder''', color.FG_WHITE)
    logging.info("Display JAM Extractor menu to user")
    print('''
[e] Extract LEGO.JAM
[c] Compress LEGO.JAM
[q] Quit''')
    jam_opt = input("\n> ")

    # User wants to compress a JAM
    if jam_opt.lower() == "c":
        logging.info("User pressed '[c] Compress LEGO.JAM'")
        SelectDataFiles()

    # User wants to extract a JAM
    if jam_opt.lower() == "e":
        logging.info("User pressed '[e] Extract LEGO.JAM'")
        SelectJAMArchive()

    # Go back to PatchIt! menu
    else:
        PatchIt.main()
예제 #3
0
파일: rungame.py 프로젝트: le717/PatchIt
    def Race(self):
        """I'll see you... at the finish line!"""
        # Get the installation path to Racers
        install_path = Racers.getRacersPath()
        logging.info("Reported LEGO Racers installation at {0}"
                     .format(install_path))
        # Run the game directly
        try:
            logging.info("Launching LEGO Racers...")
            os.chdir(install_path)
            subprocess.call(
                [os.path.join(install_path, self.__LRE), self.__novideo]
            )
            logging.shutdown()
            raise SystemExit(0)

        # Except LEGORacers.exe could not be found
        except FileNotFoundError:  # lint:ok
            logging.warning("LEGORacers.exe could not be found at {0}!"
                            .format(install_path))
            colors.text("\nLEGORacers.exe could not be found at \n\n{0}"
                  .format(install_path), color.FG_LIGHT_RED)

        # Except we need admin righs to do it
        except (OSError, PermissionError):  # lint:ok
            logging.exception('''Oops! Something went wrong! Here's what happened
''', exc_info=True)
            # Temp excuse since I can't get RunAsAdmin working
            # and I don't think I can sneak a registry string in
            # without having admin rights anyway.
            logging.warning("LEGO Racers cannot be launched at this time.")
            colors.text("\nLEGO Racers cannot be launched at this time.\n",
                        color.FG_LIGHT_RED)

        finally:
            time.sleep(1)
            PatchIt.main()
예제 #4
0
파일: legojam.py 프로젝트: le717/PatchIt
def SelectJAMArchive():
    """Select the JAM Archive to extract"""
    # Draw (then withdraw) the root Tk window
    logging.info("Drawing root Tk window")
    root = Tk()
    logging.info("Withdrawing root Tk window")
    root.withdraw()

    # Overwrite root display settings
    logging.info("Overwrite root Tk window settings to hide it")
    root.overrideredirect(True)
    root.geometry('0x0+0+0')

    # Show window again, lift it so it can receive the focus
    # Otherwise, it is behind the console window
    root.deiconify()
    root.lift()
    root.focus_force()

    # Select the LEGO Racers installation
    logging.info("Where is the JAM archive to be extracted located?")
    jam_location = filedialog.askopenfilename(
        parent=root,
        title="Where is LEGO.JAM",
        defaultextension=".JAM",
        filetypes=[("LEGO.JAM", "*.JAM")]
    )

    if not jam_location:
        root.destroy()
        colors.text("\nCould not find a JAM archive to extract!",
                    color.FG_LIGHT_RED)
        main()

    # Extract the JAM
    root.destroy()
    ExtractJAM(jam_location)