Example #1
0
def main(argv):
    """
    Setup display, bundled schematics. Handle unclean
    shutdowns.
    """
    try:
        display.init()
    except pygame.error:
        os.environ['SDL_VIDEODRIVER'] = 'directx'
        try:
            display.init()
        except pygame.error:
            os.environ['SDL_VIDEODRIVER'] = 'windib'
            display.init()
    pygame.font.init()

    try:
        if not os.path.exists(directories.schematicsDir):
            shutil.copytree(
                # os.path.join(directories.getDataDir(), u'stock-schematics'),
                directories.getDataFile('stock-schematics'),
                directories.schematicsDir)
    except Exception as e:
        logging.warning('Error copying bundled schematics: {0!r}'.format(e))
        try:
            os.mkdir(directories.schematicsDir)
        except Exception as e:
            logging.warning(
                'Error creating schematics folder: {0!r}'.format(e))

    try:
        ServerJarStorage()
    except Exception as e:
        logging.warning(
            'Error creating server jar storage folder: {0!r}'.format(e))

    try:
        MCEdit.main()
    except Exception as e:
        print("mcedit.main MCEdit exited with errors.")
        logging.error("MCEdit version %s", release.get_version())
        display.quit()
        if hasattr(sys, 'frozen') and sys.platform == 'win32':
            logging.exception("%s", e)
            print("Press RETURN or close this window to dismiss.")
            input()

        raise

    return 0
Example #2
0
def portableConfigExists():
    return (
        os.path.exists(portableConfigFilePath)  # mcedit.ini in MCEdit folder
        or
        (sys.platform != 'darwin' and not os.path.exists(fixedConfigFilePath))
    )  # no mcedit.ini in Documents folder (except on OS X when we always want it in Library/Preferences


if portableConfigExists():
    print "Running in portable mode. MCEdit-schematics and mcedit.ini are stored alongside " + (
        sys.platform == "darwin" and "the MCEdit app bundle" or "MCEditData")
    portable = True
    schematicsDir = portableSchematicsDir
    configFilePath = portableConfigFilePath
    filtersDir = portableFiltersDir

else:
    print "Running in fixed install mode. MCEdit-schematics and mcedit.ini are in your Documents folder."
    schematicsDir = fixedSchematicsDir
    configFilePath = fixedConfigFilePath
    filtersDir = fixedFiltersDir
    portable = False

if portable:
    serverJarStorageDir = (os.path.join(parentDir, "ServerJarStorage"))
    ServerJarStorage.defaultCacheDir = serverJarStorageDir
    jarStorage = ServerJarStorage(serverJarStorageDir)
else:
    jarStorage = ServerJarStorage()
Example #3
0
    try:
        if not os.path.exists(directories.schematicsDir):
            shutil.copytree(
                os.path.join(directories.getDataDir(), u'stock-schematics'),
                directories.schematicsDir)
    except Exception, e:
        logging.warning('Error copying bundled schematics: {0!r}'.format(e))
        try:
            os.mkdir(directories.schematicsDir)
        except Exception, e:
            logging.warning(
                'Error creating schematics folder: {0!r}'.format(e))

    try:
        ServerJarStorage()
    except Exception, e:
        logging.warning(
            'Error creating server jar storage folder: {0!r}'.format(e))

    try:
        MCEdit.main()
    except Exception as e:
        print "mcedit.main MCEdit exited with errors."
        logging.error("MCEdit version %s", release.get_version())
        display.quit()
        if hasattr(sys, 'frozen') and sys.platform == 'win32':
            logging.exception("%s", e)
            print "Press RETURN or close this window to dismiss."
            raw_input()