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
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." raw_input() raise return 0
def perform(level, box, options): ver = release.get_version() if "unified" in ver.lower(): try: data.editor = editor data.isFork = True except NameError: import inspect data.editor = inspect.stack()[1][0].f_locals.get('self', None).editor pass else: import inspect data.editor = inspect.stack()[1][0].f_locals.get('self', None).editor if not data.isFork: raise NotImplemented("This filter will only work with MCEdit-Unified!") op = options["Operation"] # print dir(level.scoreboard.Objectives) # print level.init_scoreboard().PlayerScores["Chevalerie94"] print("Test Filter Ran") if op == "Yes/No Dialog": choice = editor.YesNoWidget("Place a sponge block here?") if choice: yesFunc(level, box) raise Exception("Response was Yes") else: raise Exception("Response was No") elif op == "Custom Dialog": entities = {} chunks = [] for (chunk, slices, point) in level.getChunkSlices(box): for e in chunk.Entities: x = e["Pos"][0].value y = e["Pos"][1].value z = e["Pos"][2].value if (x, y, z) in box: keyname = "{0} - {1},{2},{3}".format( e["id"].value, int(x), int(y), int(z)) entities[keyname] = e chunks.append(chunk) thing = ( ("Entity", tuple(sorted(entities.keys()))), ("Entity Name", "string"), ("Replace existing names?", False), ) result = editor.addExternalWidget(thing) if result != "user canceled": entity = entities[result["Entity"]] if "CustomName" not in result["Entity"]: entity["CustomName"] = TAG_String(result["Entity Name"]) elif "CustomName" in result["Entity"] and result[ "Replace existing names?"]: result["Entity"]["CustomName"] = TAG_String( result["Entity Name"]) for c in chunks: c.dirty = True elif op == "Scoreboard Editing (Objective)": scoreboard = level.init_scoreboard() test_objective = TAG_Compound() test_objective["Name"] = TAG_String("FilterObjective") test_objective["DisplayName"] = TAG_String("FilterObjective") test_objective["CriteriaName"] = TAG_String("dummy") test_objective["RenderType"] = TAG_String("integer") scoreboard["data"]["Objectives"].append(test_objective) level.save_scoreboard(scorebaord) for objective in score.Objectives: print("Objective Name: " + str(objective["Name"].value)) elif op == "Scoreboard Editing (Team)": if level.scoreboard is not None: for team in level.scoreboard.Teams: print("Team Name: " + str(team.DisplayName)) elif op == "Player Data": players = level.init_player_data() for p in list(players.keys()): print(players[p]["Air"].value) level.save_player_data(players)
class GLDisplayContext(object): def __init__(self): self.reset() def getWindowSize(self): w, h = (config.settings.windowWidth.get(), config.settings.windowHeight.get()) return max(20, w), max(20, h) def displayMode(self): return pygame.OPENGL | pygame.RESIZABLE | pygame.DOUBLEBUF def reset(self): pygame.key.set_repeat(500, 100) try: display.gl_set_attribute(pygame.GL_SWAP_CONTROL, config.settings.vsync.get()) except Exception, e: logging.warning('Unable to set vertical sync: {0!r}'.format(e)) display.gl_set_attribute(pygame.GL_ALPHA_SIZE, 8) d = display.set_mode(self.getWindowSize(), self.displayMode()) try: pygame.scrap.init() except: logging.warning('PyGame clipboard integration disabled.') display.set_caption('MCEdit ~ ' + release.get_version(), 'MCEdit') if sys.platform == 'win32' and config.settings.setWindowPlacement.get( ): config.settings.setWindowPlacement.set(False) config.save() X, Y = config.settings.windowX.get(), config.settings.windowY.get() if X: w, h = self.getWindowSize() hwndOwner = display.get_wm_info()['window'] flags, showCmd, ptMin, ptMax, rect = mcplatform.win32gui.GetWindowPlacement( hwndOwner) realW = rect[2] - rect[0] realH = rect[3] - rect[1] showCmd = config.settings.windowShowCmd.get() rect = (X, Y, X + realW, Y + realH) mcplatform.win32gui.SetWindowPlacement( hwndOwner, (0, showCmd, ptMin, ptMax, rect)) config.settings.setWindowPlacement.set(True) config.save() elif sys.platform == 'linux2' and mcplatform.hasXlibDisplay: # Looks like KDE need to loose time or to instanciate Xlib atoms to get the right window to place at screen # Keep this code untill the end of the 'for windowID in windowIDs' loop dis = mcplatform.Xlib.display.Display() root = dis.screen().root windowIDs = root.get_full_property( dis.intern_atom('_NET_CLIENT_LIST'), mcplatform.Xlib.X.AnyPropertyType).value for windowID in windowIDs: window = dis.create_resource_object('window', windowID) name = window.get_wm_name() # Title pid = window.get_full_property( dis.intern_atom('_NET_WM_PID'), mcplatform.Xlib.X.AnyPropertyType) # PID dis = mcplatform.Xlib.display.Display() dRoot = dis.screen().root win = dRoot.get_full_property( dis.intern_atom('_NET_ACTIVE_WINDOW'), mcplatform.Xlib.X.AnyPropertyType).value[0] win = dis.create_resource_object('window', win) win.configure(x=config.settings.windowX.get(), y=config.settings.windowY.get()) # self.win = win dis.sync() try: iconpath = os.path.join(directories.getDataDir(), 'favicon.png') iconfile = file(iconpath, 'rb') icon = pygame.image.load(iconfile, 'favicon.png') display.set_icon(icon) except Exception, e: logging.warning('Unable to set icon: {0!r}'.format(e))
class GLDisplayContext(object): def __init__(self, splash=None): self.reset(splash) @staticmethod def getWindowSize(): w, h = (config.settings.windowWidth.get(), config.settings.windowHeight.get()) return max(20, w), max(20, h) @staticmethod def displayMode(): return pygame.OPENGL | pygame.RESIZABLE | pygame.DOUBLEBUF def reset(self, splash=None): pygame.key.set_repeat(500, 100) try: display.gl_set_attribute(pygame.GL_SWAP_CONTROL, config.settings.vsync.get()) except Exception, e: logging.warning('Unable to set vertical sync: {0!r}'.format(e)) display.gl_set_attribute(pygame.GL_ALPHA_SIZE, 8) wwh = self.getWindowSize() d = display.set_mode(wwh, self.displayMode()) GL.glEnableClientState(GL.GL_VERTEX_ARRAY) GL.glAlphaFunc(GL.GL_NOTEQUAL, 0) GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA) # textures are 256x256, so with this we can specify pixel coordinates GL.glMatrixMode(GL.GL_TEXTURE) GL.glScale(1 / 256., 1 / 256., 1 / 256.) if splash: swh = splash.get_size() x, y = (wwh[0] / 2 - swh[0] / 2, wwh[1] / 2 - swh[1] / 2) w, h = swh data = image.tostring(splash, 'RGBA', 1) GL.glWindowPos2d(x, y) GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA) GL.glDrawPixels(w, h, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, numpy.fromstring(data, dtype='uint8')) display.flip() display.set_caption('MCEdit ~ ' + release.get_version(), 'MCEdit') if sys.platform == 'win32' and config.settings.setWindowPlacement.get( ): config.settings.setWindowPlacement.set(False) config.save() X, Y = config.settings.windowX.get(), config.settings.windowY.get() if X: hwndOwner = display.get_wm_info()['window'] flags, showCmd, ptMin, ptMax, rect = mcplatform.win32gui.GetWindowPlacement( hwndOwner) realW = rect[2] - rect[0] realH = rect[3] - rect[1] showCmd = config.settings.windowShowCmd.get() rect = (X, Y, X + realW, Y + realH) mcplatform.win32gui.SetWindowPlacement( hwndOwner, (0, showCmd, ptMin, ptMax, rect)) config.settings.setWindowPlacement.set(True) config.save() elif sys.platform == 'linux2' and mcplatform.hasXlibDisplay: dis = mcplatform.Xlib.display.Display() root = dis.screen().root windowIDs = root.get_full_property( dis.intern_atom('_NET_CLIENT_LIST'), mcplatform.Xlib.X.AnyPropertyType).value for windowID in windowIDs: window = dis.create_resource_object('window', windowID) name = window.get_wm_name() if "MCEdit ~ Unified" in name: win = window win.configure(x=config.settings.windowX.get(), y=config.settings.windowY.get()) self.win = win dis.sync() try: iconpath = os.path.join(directories.getDataDir(), 'favicon.png') iconfile = file(iconpath, 'rb') icon = pygame.image.load(iconfile, 'favicon.png') display.set_icon(icon) except Exception, e: logging.warning('Unable to set icon: {0!r}'.format(e))
from setuptools import setup, find_packages from release import get_version version = get_version('pyharness') setup( name='pyharness', version=version, description='A lightweight framework for running experiments', author='Daniel Haas', author_email='*****@*****.**', url='https://github.com/thisisdhaas/pyharness', download_url=( 'https://github.com/thisisdhaas/pyharness/tarball/v' + version), keywords=['experiments', 'harness'], classifiers=[], packages=find_packages(), entry_points = { 'console_scripts': ['pyharness=pyharness.command_line:main'], }, include_package_data=True, )
def main(cls): PlayerCache().load() displayContext = GLDisplayContext(splash.splash, caption=(('MCEdit ~ ' + release.get_version()%_("for")).encode('utf-8'), 'MCEdit')) os.environ['SDL_VIDEO_CENTERED'] = '0' rootwidget = RootWidget(displayContext.display) mcedit = MCEdit(displayContext) rootwidget.displayContext = displayContext rootwidget.confirm_quit = mcedit.confirm_quit rootwidget.mcedit = mcedit rootwidget.add(mcedit) rootwidget.focus_switch = mcedit if 0 == len(pymclevel.alphaMaterials.yamlDatas): albow.alert("Failed to load minecraft.yaml. Check the console window for details.") if mcedit.droppedLevel: mcedit.loadFile(mcedit.droppedLevel) cls.version_lock = threading.Lock() cls.version_info = None cls.version_checked = False fetch_version_thread = threading.Thread(target=cls.fetch_version) fetch_version_thread.start() # Disabled old update code # if hasattr(sys, 'frozen'): # # We're being run from a bundle, check for updates. # import esky # # app = esky.Esky( # sys.executable.decode(sys.getfilesystemencoding()), # 'https://bitbucket.org/codewarrior0/mcedit/downloads' # ) # try: # update_version = app.find_update() # except: # # FIXME: Horrible, hacky kludge. # update_version = None # logging.exception('Error while checking for updates') # # if update_version: # answer = albow.ask( # 'Version "%s" is available, would you like to ' # 'download it?' % update_version, # [ # 'Yes', # 'No', # ], # default=0, # cancel=1 # ) # if answer == 'Yes': # def callback(args): # status = args['status'] # status_texts = { # 'searching': u"Finding updates...", # 'found': u"Found version {new_version}", # 'downloading': u"Downloading: {received} / {size}", # 'ready': u"Downloaded {path}", # 'installing': u"Installing {new_version}", # 'cleaning up': u"Cleaning up...", # 'done': u"Done." # } # text = status_texts.get(status, 'Unknown').format(**args) # # panel = Dialog() # panel.idleevent = lambda event: panel.dismiss() # label = albow.Label(text, width=600) # panel.add(label) # panel.size = (500, 250) # panel.present() # # try: # app.auto_update(callback) # except (esky.EskyVersionError, EnvironmentError): # albow.alert(_("Failed to install update %s") % update_version) # else: # albow.alert(_("Version %s installed. Restart MCEdit to begin using it.") % update_version) # raise SystemExit() if config.settings.closeMinecraftWarning.get(): answer = albow.ask( "Warning: Only open a world in one program at a time. If you open a world at the same time in MCEdit and in Minecraft, you will lose your work and possibly damage your save file.\n\n If you are using Minecraft 1.3 or earlier, you need to close Minecraft completely before you use MCEdit.", ["Don't remind me again.", "OK"], default=1, cancel=1) if answer == "Don't remind me again.": config.settings.closeMinecraftWarning.set(False) # Disabled Crash Reporting Option # if not config.settings.reportCrashesAsked.get(): # answer = albow.ask( # "When an error occurs, MCEdit can report the details of the error to its developers. " # "The error report will include your operating system version, MCEdit version, " # "OpenGL version, plus the make and model of your CPU and graphics processor. No personal " # "information will be collected.\n\n" # "Error reporting can be enabled or disabled in the Options dialog.\n\n" # "Enable error reporting?", # ["Yes", "No"], # default=0) # config.settings.reportCrashes.set(answer == "Yes") # config.settings.reportCrashesAsked.set(True) config.settings.reportCrashes.set(False) config.settings.reportCrashesAsked.set(True) config.save() if "update" in config.version.version.get(): answer = albow.ask("There are new default controls. Do you want to replace your current controls with the new ones?", ["Yes", "No"]) if answer == "Yes": for configKey, k in keys.KeyConfigPanel.presets["WASD"]: config.keys[config.convert(configKey)].set(k) config.version.version.set("1.1.2.0") config.save() if "-causeError" in sys.argv: raise ValueError("Error requested via -causeError") while True: try: rootwidget.run() except (SystemExit, KeyboardInterrupt): print "Shutting down..." exc_txt = traceback.format_exc() if mcedit.editor.level: if config.settings.savePositionOnClose.get(): mcedit.editor.waypointManager.saveLastPosition(mcedit.editor.mainViewport, mcedit.editor.level.getPlayerDimension()) mcedit.editor.waypointManager.save() # The following Windows specific code won't be executed if we're using '--debug-wm' switch. if not USE_WM and sys.platform == "win32" and config.settings.setWindowPlacement.get(): (flags, showCmd, ptMin, ptMax, rect) = mcplatform.win32gui.GetWindowPlacement( display.get_wm_info()['window']) X, Y, r, b = rect #w = r-X #h = b-Y if (showCmd == mcplatform.win32con.SW_MINIMIZE or showCmd == mcplatform.win32con.SW_SHOWMINIMIZED): showCmd = mcplatform.win32con.SW_SHOWNORMAL config.settings.windowX.set(X) config.settings.windowY.set(Y) config.settings.windowShowCmd.set(showCmd) # Restore the previous language if we ran with '-tt' (update translation template). if albow.translate.buildTemplate: logging.warning('Restoring %s.'%orglang) config.settings.langCode.set(orglang) # config.save() mcedit.editor.renderer.discardAllChunks() mcedit.editor.deleteAllCopiedSchematics() if mcedit.editor.level: mcedit.editor.level.close() mcedit.editor.root.RemoveEditFiles() if 'SystemExit' in traceback.format_exc() or 'KeyboardInterrupt' in traceback.format_exc(): raise else: if 'SystemExit' in exc_txt: raise SystemExit if 'KeyboardInterrupt' in exc_txt: raise KeyboardInterrupt except MemoryError: traceback.print_exc() mcedit.editor.handleMemoryError()
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() raise return 0 def getSelectedMinecraftVersion(): profile = directories.getMinecraftProfileJSON()[directories.getSelectedProfile()] if 'lastVersionId' in profile: return profile['lastVersionId']
from setuptools import setup, find_packages from release import get_version version = get_version('orchestra') setup( name='orchestra', version=version, description='A framework for building complex expert workflows.', author='B12 (Unlimited Labs, Inc.)', author_email='*****@*****.**', license='Apache 2', url='https://github.com/b12io/orchestra', download_url=( 'https://github.com/b12io/orchestra/tarball/v' + version), keywords=['crowdsourcing', 'workflows'], classifiers=[], packages=find_packages(), include_package_data=True, )
from setuptools import find_packages from setuptools import setup from release import get_version version = get_version('orchestra') setup( name='orchestra', version=version, description='A framework for building complex expert workflows.', author='B12 (Unlimited Labs, Inc.)', author_email='*****@*****.**', license='Apache 2', url='https://github.com/b12io/orchestra', download_url=('https://github.com/b12io/orchestra/tarball/v' + version), keywords=['crowdsourcing', 'workflows'], classifiers=[], packages=find_packages(), include_package_data=True, )
def getHeader(cls): header = Label("MCEdit {0} ({1})".format(release.get_version(), arch), font=get_font(18, "DejaVuSans-Bold.ttf")) return header
def main(cls): PlayerCache().load() displayContext = GLDisplayContext(splash.splash, caption=( ('MCEdit ~ ' + release.get_version() % _("for")).encode('utf-8'), 'MCEdit')) os.environ['SDL_VIDEO_CENTERED'] = '0' rootwidget = RootWidget(displayContext.display) mcedit = MCEdit(displayContext) rootwidget.displayContext = displayContext rootwidget.confirm_quit = mcedit.confirm_quit rootwidget.mcedit = mcedit rootwidget.add(mcedit) rootwidget.focus_switch = mcedit if mcedit.droppedLevel: mcedit.loadFile(mcedit.droppedLevel) cls.version_lock = threading.Lock() cls.version_info = None cls.version_checked = False fetch_version_thread = threading.Thread(target=cls.fetch_version) fetch_version_thread.start() if config.settings.closeMinecraftWarning.get(): answer = albow.ask( "Warning: Only open a world in one program at a time. If you open a world at the same time in MCEdit and in Minecraft, you will lose your work and possibly damage your save file.\n\n If you are using Minecraft 1.3 or earlier, you need to close Minecraft completely before you use MCEdit.", ["Don't remind me again.", "OK"], default=1, cancel=1) if answer == "Don't remind me again.": config.settings.closeMinecraftWarning.set(False) if not config.settings.reportCrashesAsked.get(): answer = albow.ask( 'Would you like to send anonymous error reports to the MCEdit-Unified Team to help with improving future releases?\n\nError reports are stripped of any identifying user information before being sent.\n\nPyClark, the library used, is open source under the GNU LGPL v3 license and is maintained by Podshot. The source code can be located here: https://github.com/Podshot/pyClark.\n\nThere has been no modification to the library in any form.', ['Allow', 'Deny'], default=1, cancel=1 ) if answer == 'Allow': albow.alert("Error reporting will be enabled next time MCEdit-Unified is launched") config.settings.reportCrashes.set(answer == 'Allow') config.settings.reportCrashesAsked.set(True) config.save() if "update" in config.version.version.get(): answer = albow.ask( "There are new default controls. Do you want to replace your current controls with the new ones?", ["Yes", "No"]) if answer == "Yes": for configKey, k in keys.KeyConfigPanel.presets["WASD"]: config.keys[config.convert(configKey)].set(k) config.version.version.set("1.6.0.0") config.save() if "-causeError" in sys.argv: raise ValueError("Error requested via -causeError") while True: try: rootwidget.run() except (SystemExit, KeyboardInterrupt): print "Shutting down..." exc_txt = traceback.format_exc() if mcedit.editor.level: if config.settings.savePositionOnClose.get(): mcedit.editor.waypointManager.saveLastPosition(mcedit.editor.mainViewport, mcedit.editor.level.dimNo) mcedit.editor.waypointManager.save() # The following Windows specific code won't be executed if we're using '--debug-wm' switch. if not USE_WM and sys.platform == "win32" and config.settings.setWindowPlacement.get(): (flags, showCmd, ptMin, ptMax, rect) = mcplatform.win32gui.GetWindowPlacement( display.get_wm_info()['window']) X, Y, r, b = rect if (showCmd == mcplatform.win32con.SW_MINIMIZE or showCmd == mcplatform.win32con.SW_SHOWMINIMIZED): showCmd = mcplatform.win32con.SW_SHOWNORMAL config.settings.windowX.set(X) config.settings.windowY.set(Y) config.settings.windowShowCmd.set(showCmd) # Restore the previous language if we ran with '-tt' (update translation template). if albow.translate.buildTemplate: logging.warning('Restoring %s.' % orglang) config.settings.langCode.set(orglang) # config.save() mcedit.editor.renderer.discardAllChunks() mcedit.editor.deleteAllCopiedSchematics() if mcedit.editor.level: mcedit.editor.level.close() mcedit.editor.root.RemoveEditFiles() if 'SystemExit' in traceback.format_exc() or 'KeyboardInterrupt' in traceback.format_exc(): raise else: if 'SystemExit' in exc_txt: raise SystemExit if 'KeyboardInterrupt' in exc_txt: raise KeyboardInterrupt except MemoryError: traceback.print_exc() mcedit.editor.handleMemoryError()
from setuptools import setup, find_packages from release import get_version version = get_version("orchestra") setup( name="orchestra", version=version, description="A framework for building complex expert workflows.", author="Unlimited Labs, Inc.", author_email="*****@*****.**", license="Apache 2", url="https://github.com/unlimitedlabs/orchestra", download_url=("https://github.com/unlimitedlabs/orchestra/tarball/v" + version), keywords=["crowdsourcing", "workflows"], classifiers=[], packages=find_packages(), include_package_data=True, )
def __init__(self, displayContext, *args): if DEBUG_WM: print "############################ __INIT__ ###########################" self.resizeAlert = config.settings.showWindowSizeWarning.get() self.maximized = config.settings.windowMaximized.get() self.saved_pos = config.settings.windowX.get(), config.settings.windowY.get() if displayContext.win and DEBUG_WM: print "* self.displayContext.win.state", displayContext.win.get_state() print "* self.displayContext.win.position", displayContext.win.get_position() self.dis = None self.win = None self.wParent = None self.wGrandParent = None self.linux = False if sys.platform == 'linux2' and mcplatform.hasXlibDisplay: self.linux = True self.dis = dis = mcplatform.Xlib.display.Display() self.win = win = dis.create_resource_object('window', display.get_wm_info()['window']) curDesk = os.environ.get('XDG_CURRENT_DESKTOP') if curDesk in ('GNOME', 'X-Cinnamon', 'Unity'): self.geomReciever = self.maximizeHandler = wParent = win.query_tree().parent self.geomSender = wGrandParent = wParent.query_tree().parent elif curDesk == 'KDE': self.maximizeHandler = win.query_tree().parent wParent = win.query_tree().parent.query_tree().parent wGrandParent = wParent.query_tree().parent.query_tree().parent self.geomReciever = self.geomSender = win.query_tree().parent.query_tree().parent.query_tree().parent else: self.maximizeHandler = self.geomReciever = self.geomSender = wGrandParent = wParent = None self.wParent = wParent self.wGrandParent = wGrandParent root = dis.screen().root windowID = root.get_full_property(dis.intern_atom('_NET_ACTIVE_WINDOW'), mcplatform.Xlib.X.AnyPropertyType).value[0] print "###\nwindowID", windowID window = dis.create_resource_object('window', windowID) print "###\nwindow.get_geometry()", window.get_geometry() print "###\nself.win", self.win.get_geometry() print "###\nself.wParent.get_geometry()", self.wParent.get_geometry() print "###\nself.wGrandParent.get_geometry()", self.wGrandParent.get_geometry() try: print "###\nself.wGrandParent.query_tree().parent.get_geometry()", self.wGrandParent.query_tree().parent.get_geometry() except: pass print "###\nself.maximizeHandler.get_geometry()", self.maximizeHandler.get_geometry() print "###\nself.geomReciever.get_geometry()", self.geomReciever.get_geometry() print "###\nself.geomSender.get_geometry()", self.geomSender.get_geometry() print "###\nself.win", self.win print "###\nself.wParent", self.wParent print "###\nself.wGrandParent", self.wGrandParent print "###\nself.maximizeHandler", self.maximizeHandler print "###\nself.geomReciever", self.geomReciever print "###\nself.geomSender", self.geomSender ws = displayContext.getWindowSize() r = rect.Rect(0, 0, ws[0], ws[1]) GLViewport.__init__(self, r) if DEBUG_WM: print "self.size", self.size, "ws", ws if displayContext.win and self.maximized: # Send a maximize event now displayContext.win.set_state(mcplatform.MAXIMIZED) # Flip pygame.display to avoid to see the splash un-centered. pygame.display.flip() self.displayContext = displayContext self.bg_color = (0, 0, 0, 1) self.anchor = 'tlbr' if not config.config.has_section("Recent Worlds"): config.config.add_section("Recent Worlds") self.setRecentWorlds([""] * 5) self.optionsPanel = panels.OptionsPanel(self) if not albow.translate.buildTemplate: self.optionsPanel.getLanguageChoices() lng = config.settings.langCode.get() if lng not in self.optionsPanel.sgnal: lng = "en_US" config.settings.langCode.set(lng) albow.translate.setLang(lng) # Set the window caption here again, since the initialization is done through several steps... display.set_caption(('MCEdit ~ ' + release.get_version() % _("for")).encode('utf-8'), 'MCEdit') self.optionsPanel.initComponents() self.graphicsPanel = panels.GraphicsPanel(self) #.# self.keyConfigPanel = keys.KeyConfigPanel(self) #.# self.droppedLevel = None self.nbtCopyBuffer = None self.reloadEditor() """ check command line for files dropped from explorer """ if len(sys.argv) > 1: for arg in sys.argv[1:]: f = arg.decode(sys.getfilesystemencoding()) if os.path.isdir(os.path.join(pymclevel.minecraftSaveFileDir, f)): f = os.path.join(pymclevel.minecraftSaveFileDir, f) self.droppedLevel = f break if os.path.exists(f): self.droppedLevel = f break self.fileOpener = albow.FileOpener(self) self.add(self.fileOpener) self.fileOpener.focus()
def main(cls): PlayerCache().load() displayContext = GLDisplayContext( splash.splash, caption=(('MCEdit ~ ' + release.get_version() % _("for")).encode('utf-8'), 'MCEdit')) os.environ['SDL_VIDEO_CENTERED'] = '0' rootwidget = RootWidget(displayContext.display) mcedit = MCEdit(displayContext) rootwidget.displayContext = displayContext rootwidget.confirm_quit = mcedit.confirm_quit rootwidget.mcedit = mcedit rootwidget.add(mcedit) rootwidget.focus_switch = mcedit if 0 == len(pymclevel.alphaMaterials.yamlDatas): albow.alert( "Failed to load minecraft.yaml. Check the console window for details." ) if mcedit.droppedLevel: mcedit.loadFile(mcedit.droppedLevel) cls.version_lock = threading.Lock() cls.version_info = None cls.version_checked = False fetch_version_thread = threading.Thread(target=cls.fetch_version) fetch_version_thread.start() # Disabled old update code # if hasattr(sys, 'frozen'): # # We're being run from a bundle, check for updates. # import esky # # app = esky.Esky( # sys.executable.decode(sys.getfilesystemencoding()), # 'https://bitbucket.org/codewarrior0/mcedit/downloads' # ) # try: # update_version = app.find_update() # except: # # FIXME: Horrible, hacky kludge. # update_version = None # logging.exception('Error while checking for updates') # # if update_version: # answer = albow.ask( # 'Version "%s" is available, would you like to ' # 'download it?' % update_version, # [ # 'Yes', # 'No', # ], # default=0, # cancel=1 # ) # if answer == 'Yes': # def callback(args): # status = args['status'] # status_texts = { # 'searching': u"Finding updates...", # 'found': u"Found version {new_version}", # 'downloading': u"Downloading: {received} / {size}", # 'ready': u"Downloaded {path}", # 'installing': u"Installing {new_version}", # 'cleaning up': u"Cleaning up...", # 'done': u"Done." # } # text = status_texts.get(status, 'Unknown').format(**args) # # panel = Dialog() # panel.idleevent = lambda event: panel.dismiss() # label = albow.Label(text, width=600) # panel.add(label) # panel.size = (500, 250) # panel.present() # # try: # app.auto_update(callback) # except (esky.EskyVersionError, EnvironmentError): # albow.alert(_("Failed to install update %s") % update_version) # else: # albow.alert(_("Version %s installed. Restart MCEdit to begin using it.") % update_version) # raise SystemExit() if config.settings.closeMinecraftWarning.get(): answer = albow.ask( "Warning: Only open a world in one program at a time. If you open a world at the same time in MCEdit and in Minecraft, you will lose your work and possibly damage your save file.\n\n If you are using Minecraft 1.3 or earlier, you need to close Minecraft completely before you use MCEdit.", ["Don't remind me again.", "OK"], default=1, cancel=1) if answer == "Don't remind me again.": config.settings.closeMinecraftWarning.set(False) # Disabled Crash Reporting Option # if not config.settings.reportCrashesAsked.get(): # answer = albow.ask( # "When an error occurs, MCEdit can report the details of the error to its developers. " # "The error report will include your operating system version, MCEdit version, " # "OpenGL version, plus the make and model of your CPU and graphics processor. No personal " # "information will be collected.\n\n" # "Error reporting can be enabled or disabled in the Options dialog.\n\n" # "Enable error reporting?", # ["Yes", "No"], # default=0) # config.settings.reportCrashes.set(answer == "Yes") # config.settings.reportCrashesAsked.set(True) config.settings.reportCrashes.set(False) config.settings.reportCrashesAsked.set(True) config.save() if "update" in config.version.version.get(): answer = albow.ask( "There are new default controls. Do you want to replace your current controls with the new ones?", ["Yes", "No"]) if answer == "Yes": for configKey, k in keys.KeyConfigPanel.presets["WASD"]: config.keys[config.convert(configKey)].set(k) config.version.version.set("1.1.2.0") config.save() if "-causeError" in sys.argv: raise ValueError("Error requested via -causeError") while True: try: rootwidget.run() except (SystemExit, KeyboardInterrupt): print "Shutting down..." exc_txt = traceback.format_exc() if mcedit.editor.level: if config.settings.savePositionOnClose.get(): mcedit.editor.waypointManager.saveLastPosition( mcedit.editor.mainViewport, mcedit.editor.level.getPlayerDimension()) mcedit.editor.waypointManager.save() # The following Windows specific code won't be executed if we're using '--debug-wm' switch. if not USE_WM and sys.platform == "win32" and config.settings.setWindowPlacement.get( ): (flags, showCmd, ptMin, ptMax, rect) = mcplatform.win32gui.GetWindowPlacement( display.get_wm_info()['window']) X, Y, r, b = rect #w = r-X #h = b-Y if (showCmd == mcplatform.win32con.SW_MINIMIZE or showCmd == mcplatform.win32con.SW_SHOWMINIMIZED): showCmd = mcplatform.win32con.SW_SHOWNORMAL config.settings.windowX.set(X) config.settings.windowY.set(Y) config.settings.windowShowCmd.set(showCmd) # Restore the previous language if we ran with '-tt' (update translation template). if albow.translate.buildTemplate: logging.warning('Restoring %s.' % orglang) config.settings.langCode.set(orglang) # config.save() mcedit.editor.renderer.discardAllChunks() mcedit.editor.deleteAllCopiedSchematics() if mcedit.editor.level: mcedit.editor.level.close() mcedit.editor.root.RemoveEditFiles() if 'SystemExit' in traceback.format_exc( ) or 'KeyboardInterrupt' in traceback.format_exc(): raise else: if 'SystemExit' in exc_txt: raise SystemExit if 'KeyboardInterrupt' in exc_txt: raise KeyboardInterrupt except MemoryError: traceback.print_exc() mcedit.editor.handleMemoryError()
def __init__(self, displayContext, *args): if DEBUG_WM: print "############################ __INIT__ ###########################" self.resizeAlert = config.settings.showWindowSizeWarning.get() self.maximized = config.settings.windowMaximized.get() self.saved_pos = config.settings.windowX.get(), config.settings.windowY.get() if displayContext.win and DEBUG_WM: print "* self.displayContext.win.state", displayContext.win.get_state() print "* self.displayContext.win.position", displayContext.win.get_position() self.dis = None self.win = None self.wParent = None self.wGrandParent = None self.linux = False if sys.platform == 'linux2' and mcplatform.hasXlibDisplay: self.linux = True self.dis = dis = mcplatform.Xlib.display.Display() self.win = win = dis.create_resource_object('window', display.get_wm_info()['window']) curDesk = os.environ.get('XDG_CURRENT_DESKTOP') if curDesk in ('GNOME', 'X-Cinnamon', 'Unity'): self.geomReciever = self.maximizeHandler = wParent = win.query_tree().parent self.geomSender = wGrandParent = wParent.query_tree().parent elif curDesk == 'KDE': self.maximizeHandler = win.query_tree().parent wParent = win.query_tree().parent.query_tree().parent wGrandParent = wParent.query_tree().parent.query_tree().parent self.geomReciever = self.geomSender = win.query_tree().parent.query_tree().parent.query_tree().parent else: self.maximizeHandler = self.geomReciever = self.geomSender = wGrandParent = wParent = None self.wParent = wParent self.wGrandParent = wGrandParent root = dis.screen().root windowID = root.get_full_property(dis.intern_atom('_NET_ACTIVE_WINDOW'), mcplatform.Xlib.X.AnyPropertyType).value[0] print "###\nwindowID", windowID window = dis.create_resource_object('window', windowID) print "###\nwindow.get_geometry()", window.get_geometry() print "###\nself.win", self.win.get_geometry() print "###\nself.wParent.get_geometry()", self.wParent.get_geometry() print "###\nself.wGrandParent.get_geometry()", self.wGrandParent.get_geometry() try: print "###\nself.wGrandParent.query_tree().parent.get_geometry()", self.wGrandParent.query_tree().parent.get_geometry() except: pass print "###\nself.maximizeHandler.get_geometry()", self.maximizeHandler.get_geometry() print "###\nself.geomReciever.get_geometry()", self.geomReciever.get_geometry() print "###\nself.geomSender.get_geometry()", self.geomSender.get_geometry() print "###\nself.win", self.win print "###\nself.wParent", self.wParent print "###\nself.wGrandParent", self.wGrandParent print "###\nself.maximizeHandler", self.maximizeHandler print "###\nself.geomReciever", self.geomReciever print "###\nself.geomSender", self.geomSender ws = displayContext.getWindowSize() r = rect.Rect(0, 0, ws[0], ws[1]) GLViewport.__init__(self, r) if DEBUG_WM: print "self.size", self.size, "ws", ws if displayContext.win and self.maximized: # Send a maximize event now displayContext.win.set_state(mcplatform.MAXIMIZED) # Flip pygame.display to avoid to see the splash un-centered. pygame.display.flip() self.displayContext = displayContext self.bg_color = (0, 0, 0, 1) self.anchor = 'tlbr' if not config.config.has_section("Recent Worlds"): config.config.add_section("Recent Worlds") self.setRecentWorlds([""] * 5) self.optionsPanel = panels.OptionsPanel(self) if not albow.translate.buildTemplate: self.optionsPanel.getLanguageChoices() lng = config.settings.langCode.get() if lng not in self.optionsPanel.sgnal: lng = "en_US" config.settings.langCode.set(lng) albow.translate.setLang(lng) # Set the window caption here again, since the initialization is done through several steps... display.set_caption(('MCEdit ~ ' + release.get_version()%_("for")).encode('utf-8'), 'MCEdit') self.optionsPanel.initComponents() self.graphicsPanel = panels.GraphicsPanel(self) #&# Prototype for blocks/items names mclangres.buildResources(lang=albow.translate.getLang()) #&# #.# self.keyConfigPanel = keys.KeyConfigPanel(self) #.# self.droppedLevel = None self.nbtCopyBuffer = None self.reloadEditor() """ check command line for files dropped from explorer """ if len(sys.argv) > 1: for arg in sys.argv[1:]: f = arg.decode(sys.getfilesystemencoding()) if os.path.isdir(os.path.join(pymclevel.minecraftSaveFileDir, f)): f = os.path.join(pymclevel.minecraftSaveFileDir, f) self.droppedLevel = f break if os.path.exists(f): self.droppedLevel = f break self.fileOpener = albow.FileOpener(self) self.add(self.fileOpener) self.fileOpener.focus()
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() raise return 0 def getSelectedMinecraftVersion(): profile = directories.getMinecraftProfileJSON()[ directories.getSelectedProfile()] if 'lastVersionId' in profile:
def perform(level, box, options): ver = release.get_version() if "unified" in ver.lower(): try: data.editor = editor data.isFork = True except NameError: import inspect data.editor = inspect.stack()[1][0].f_locals.get('self', None).editor pass else: import inspect data.editor = inspect.stack()[1][0].f_locals.get('self', None).editor if not data.isFork: raise NotImplemented("This filter will only work with MCEdit-Unified!") op = options["Operation"] #print dir(level.scoreboard.Objectives) #print level.init_scoreboard().PlayerScores["Chevalerie94"] print "Test Filter Ran" if op == "Yes/No Dialog": choice = editor.YesNoWidget("Place a sponge block here?") if choice: yesFunc(level, box) raise Exception("Response was Yes") else: raise Exception("Response was No") elif op == "Custom Dialog": entities = {} chunks = [] for (chunk, slices, point) in level.getChunkSlices(box): for e in chunk.Entities: x = e["Pos"][0].value y = e["Pos"][1].value z = e["Pos"][2].value if (x,y,z) in box: keyname = "{0} - {1},{2},{3}".format(e["id"].value,int(x),int(y),int(z)) entities[keyname] = e chunks.append(chunk) thing = ( ("Entity", tuple(sorted(entities.keys()))), ("Entity Name", ("string")), ("Replace existing names?", False), ) result = editor.addExternalWidget(thing) if result != "user canceled": entity = entities[result["Entity"]] if "CustomName" not in result["Entity"]: entity["CustomName"] = TAG_String(result["Entity Name"]) elif "CustomName" in result["Entity"] and result["Replace existing names?"]: result["Entity"]["CustomName"] = TAG_String(result["Entity Name"]) for c in chunks: c.dirty = True elif op == "Scoreboard Editing (Objective)": scoreboard = level.init_scoreboard() test_objective = TAG_Compound() test_objective["Name"] = TAG_String("FilterObjective") test_objective["DisplayName"] = TAG_String("FilterObjective") test_objective["CriteriaName"] = TAG_String("dummy") test_objective["RenderType"] = TAG_String("integer") scoreboard["data"]["Objectives"].append(test_objective) level.save_scoreboard(scorebaord) for objective in score.Objectives: print "Objective Name: " + str(objective["Name"].value) elif op == "Scoreboard Editing (Team)": if level.scoreboard is not None: for team in level.scoreboard.Teams: print "Team Name: " + str(team.DisplayName) elif op == "Player Data": players = level.init_player_data() for p in players.keys(): print players[p]["Air"].value level.save_player_data(players)
from setuptools import setup from release import get_version, assert_unmodified, get_released_version assert_unmodified() setup( name='release-py', version=get_version(), packages=['release'], description='a utility for enforcing release process and automating build versioning with git', author='Edmund King', author_email='*****@*****.**', license = "MIT", url = 'https://github.com/eddking/release-py', download_url = 'https://github.com/eddking/release-py/tarball/' + get_released_version(), install_requires=['docopt'], keywords = ['release', 'git', 'versioning'], classifiers=[ 'Development Status :: 3 - Alpha', 'Intended Audience :: Developers', 'Programming Language :: Python :: 2.7', ], entry_points={ 'console_scripts': [ 'release=release.main:main', ], }, )