def __writeConfig(self): """Save current config in the prc file or if no prc file exists create one. The prc file is set in the prcFile variable""" page = None # These TODO tags are as a reminder for to add any new config # variables that may occur in the future #TODO: get values of configurations here particles = "#f" if not base.particleMgrEnabled else "#t" volume = str(round(base.musicManager.getVolume(), 2)) mute = "#f" if base.AppHasAudioFocus else "#t" #TODO: add any configuration variable name that you have added customConfigVariables = [ "", "particles-enabled", "audio-mute", "audio-volume" ] if os.path.exists(prcFile): # open the config file and change values according to current # application settings page = loadPrcFile(Filename.fromOsSpecific(prcFile)) removeDecls = [] for dec in range(page.getNumDeclarations()): # Check if our variables are given. # NOTE: This check has to be done to not loose our base or other # manual config changes by the user if page.getVariableName(dec) in customConfigVariables: decl = page.modifyDeclaration(dec) removeDecls.append(decl) for dec in removeDecls: page.deleteDeclaration(dec) # NOTE: particles-enabled and audio-mute are custom variables and # have to be loaded by hand at startup # Particles page.makeDeclaration("particles-enabled", particles) # audio page.makeDeclaration("audio-volume", volume) page.makeDeclaration("audio-mute", mute) else: # Create a config file and set default values cpMgr = ConfigPageManager.getGlobalPtr() page = cpMgr.makeExplicitPage("{} Pandaconfig".format(appName)) # set OpenGL to be the default page.makeDeclaration("load-display", "pandagl") # get the displays width and height w = self.pipe.getDisplayWidth() h = self.pipe.getDisplayHeight() # set the window size in the config file page.makeDeclaration("win-size", "{} {}".format(w, h)) # set the default to fullscreen in the config file page.makeDeclaration("fullscreen", "1") # particles page.makeDeclaration("particles-enabled", "#t") # audio page.makeDeclaration("audio-volume", volume) page.makeDeclaration("audio-mute", "#f") # create a stream to the specified config file configfile = OFileStream(prcFile) # and now write it out page.write(configfile) # close the stream configfile.close()
def WritePRCFile(self): page = None customConfigVariables = ["", "motd", "hostname", "tcp-port", "backlog", "udp-port", "isPersistent"] if os.path.exists(prcFile): # load the existing config file page = loadPrcFile(Filename.fromOsSpecific(prcFile)) removeDecls = [] for dec in range(page.getNumDeclarations()): # Check if our variables are given. # NOTE: This check has to be done to not loose our base or other # manual config changes by the user if page.getVariableName(dec) in customConfigVariables: decl = page.modifyDeclaration(dec) removeDecls.append(decl) for dec in removeDecls: page.deleteDeclaration(dec) else: # create a new config file cpMgr = ConfigPageManager.getGlobalPtr() page = cpMgr.makeExplicitPage("Net Core Pandaconfig") # config declarations page.makeDeclaration("motd", str(self.MOTD)) page.makeDeclaration("hostname", str(self.HOSTNAME)) page.makeDeclaration("tcp-port", str(self.TCPPORT)) page.makeDeclaration("backlog", str(self.BACKLOG)) page.makeDeclaration("udp-port", str(self.UDPPORT)) page.makeDeclaration("isPersistent", str(self.ISPERSISTENT)) # create a stream to the specified config file configfile = OFileStream(prcFile) # and now write it out page.write(configfile) # close the stream configfile.close()
def WritePRCFile(self): page = None customConfigVariables = ["", "tcp-port","udp-port", "server-port", "server-ip","timeout-in-ms"] if os.path.exists(prcFile): # load the existing config file page = loadPrcFile(Filename.fromOsSpecific(prcFile)) removeDecls = [] for dec in range(page.getNumDeclarations()): # Check if our variables are given. # NOTE: This check has to be done to not loose our base or other # manual config changes by the user if page.getVariableName(dec) in customConfigVariables: decl = page.modifyDeclaration(dec) removeDecls.append(decl) for dec in removeDecls: page.deleteDeclaration(dec) else: # create a new config file cpMgr = ConfigPageManager.getGlobalPtr() page = cpMgr.makeExplicitPage("Grim Net Pandaconfig") # config declarations page.makeDeclaration("udp-port", str(self.UDPPORT)) page.makeDeclaration("tcp-port", str(self.TCPPORT)) page.makeDeclaration("server-port", str(self.UDPPORTSERVER)) page.makeDeclaration("server-ip", str(self.SERVERIP)) page.makeDeclaration("timeout-in-ms", str(self.TIMEOUT)) # create a stream to the specified config file configfile = OFileStream(prcFile) # and now write it out page.write(configfile) # close the stream configfile.close()
def __writeConfig(self): """Save current config in the prc file or if no prc file exists create one. The prc file is set in the prcFile variable""" page = None # These TODO tags are as a reminder for to add any new config # variables that may occur in the future #TODO: get values of configurations here particles = "#f" if not base.particleMgrEnabled else "#t" volume = str(round(base.musicManager.getVolume(), 2)) mute = "#f" if base.AppHasAudioFocus else "#t" #TODO: add any configuration variable name that you have added customConfigVariables = [ "", "particles-enabled", "audio-mute", "audio-volume"] if os.path.exists(prcFile): # open the config file and change values according to current # application settings page = loadPrcFile(Filename.fromOsSpecific(prcFile)) removeDecls = [] for dec in range(page.getNumDeclarations()): # Check if our variables are given. # NOTE: This check has to be done to not loose our base or other # manual config changes by the user if page.getVariableName(dec) in customConfigVariables: decl = page.modifyDeclaration(dec) removeDecls.append(decl) for dec in removeDecls: page.deleteDeclaration(dec) # NOTE: particles-enabled and audio-mute are custom variables and # have to be loaded by hand at startup # Particles page.makeDeclaration("particles-enabled", particles) # audio page.makeDeclaration("audio-volume", volume) page.makeDeclaration("audio-mute", mute) else: # Create a config file and set default values cpMgr = ConfigPageManager.getGlobalPtr() page = cpMgr.makeExplicitPage("{} Pandaconfig".format(appName)) # set OpenGL to be the default page.makeDeclaration("load-display", "pandagl") # get the displays width and height w = self.pipe.getDisplayWidth() h = self.pipe.getDisplayHeight() # set the window size in the config file page.makeDeclaration("win-size", "{} {}".format(w, h)) # set the default to fullscreen in the config file page.makeDeclaration("fullscreen", "1") # particles page.makeDeclaration("particles-enabled", "#t") # audio page.makeDeclaration("audio-volume", volume) page.makeDeclaration("audio-mute", "#f") # create a stream to the specified config file configfile = OFileStream(prcFile) # and now write it out page.write(configfile) # close the stream configfile.close()
def WritePRCFile(self): page = None customConfigVariables = [ "", "motd", "hostname", "tcp-port", "backlog", "udp-port", "isPersistent" ] if os.path.exists(prcFile): # load the existing config file page = loadPrcFile(Filename.fromOsSpecific(prcFile)) removeDecls = [] for dec in range(page.getNumDeclarations()): # Check if our variables are given. # NOTE: This check has to be done to not loose our base or other # manual config changes by the user if page.getVariableName(dec) in customConfigVariables: decl = page.modifyDeclaration(dec) removeDecls.append(decl) for dec in removeDecls: page.deleteDeclaration(dec) else: # create a new config file cpMgr = ConfigPageManager.getGlobalPtr() page = cpMgr.makeExplicitPage("Net Core Pandaconfig") # config declarations page.makeDeclaration("motd", str(self.MOTD)) page.makeDeclaration("hostname", str(self.HOSTNAME)) page.makeDeclaration("tcp-port", str(self.TCPPORT)) page.makeDeclaration("backlog", str(self.BACKLOG)) page.makeDeclaration("udp-port", str(self.UDPPORT)) page.makeDeclaration("isPersistent", str(self.ISPERSISTENT)) # create a stream to the specified config file configfile = OFileStream(prcFile) # and now write it out page.write(configfile) # close the stream configfile.close()
def WritePRCFile(self): page = None customConfigVariables = [ "", "tcp-port", "udp-port", "server-port", "server-ip", "timeout-in-ms" ] if os.path.exists(prcFile): # load the existing config file page = loadPrcFile(Filename.fromOsSpecific(prcFile)) removeDecls = [] for dec in range(page.getNumDeclarations()): # Check if our variables are given. # NOTE: This check has to be done to not loose our base or other # manual config changes by the user if page.getVariableName(dec) in customConfigVariables: decl = page.modifyDeclaration(dec) removeDecls.append(decl) for dec in removeDecls: page.deleteDeclaration(dec) else: # create a new config file cpMgr = ConfigPageManager.getGlobalPtr() page = cpMgr.makeExplicitPage("Grim Net Pandaconfig") # config declarations page.makeDeclaration("udp-port", str(self.UDPPORT)) page.makeDeclaration("tcp-port", str(self.TCPPORT)) page.makeDeclaration("server-port", str(self.UDPPORTSERVER)) page.makeDeclaration("server-ip", str(self.SERVERIP)) page.makeDeclaration("timeout-in-ms", str(self.TIMEOUT)) # create a stream to the specified config file configfile = OFileStream(prcFile) # and now write it out page.write(configfile) # close the stream configfile.close()
def writeConfig(self): """Save current config in the prc file or if no prc file exists create one. The prc file is set in the prcFile variable""" page = None # #TODO: add any configuration variable names that you have added # to the dictionaries in the next lines. Set the current # configurations value as value in this dictionary and it's # name as key. configVariables = { # set the window size in the config file "win-size": ConfigVariableString( "win-size", "{} {}".format(self.dispWidth, self.dispHeight)).getValue(), # set the default to fullscreen in the config file "fullscreen": "#t" if ConfigVariableBool("fullscreen", True).getValue() else "#f", # particles "particles-enabled": "#t" if self.particleMgrEnabled else "#f", # audio "audio-volume": str(round(self.musicManager.getVolume(), 2)), "audio-music-active": "#t" if self.musicActive else "#f", "audio-sfx-active": "#t" if self.sfxActive else "#f", # logging "notify-output": os.path.join(basedir, "game.log"), # window "framebuffer-multisample": "#t" if ConfigVariableBool("framebuffer-multisample").getValue() else "#f", "multisamples": str(ConfigVariableInt("multisamples", 8).getValue()), "texture-anisotropic-degree": str(ConfigVariableInt("texture-anisotropic-degree").getValue()), "textures-auto-power-2": "#t" if ConfigVariableBool("textures-auto-power-2", True).getValue() else "#f", # server connection "server-host": base.serverHost.getValue(), } page = None # Check if we have an existing configuration file if os.path.exists(prcFile): # open the config file and change values according to current # application settings page = loadPrcFile(Filename.fromOsSpecific(prcFile)) removeDecls = [] for dec in range(page.getNumDeclarations()): # Check if our variables are given. # NOTE: This check has to be done to not loose our base # or other manual config changes by the user if page.getVariableName(dec) in configVariables.keys(): removeDecls.append(page.modifyDeclaration(dec)) for dec in removeDecls: page.deleteDeclaration(dec) else: # Create a config file and set default values cpMgr = ConfigPageManager.getGlobalPtr() page = cpMgr.makeExplicitPage("Application Config") # always write custom configurations for key, value in configVariables.items(): page.makeDeclaration(key, value) # create a stream to the specified config file configfile = OFileStream(prcFile) # and now write it out page.write(configfile) # close the stream configfile.close()
def __writeConfig(self): """Save current config in the prc file or if no prc file exists create one. The prc file is set in the prcFile variable""" page = None particles = str(base.particleMgrEnabled) textSpeed = str(base.textWriteSpeed) volume = str(round(base.musicManager.getVolume(), 2)) mouseSens = str(base.mouseSensitivity) customConfigVariables = [ "", "particles-enabled", "text-write-speed", "audio-mute", "audio-volume", "control-type", "mouse-sensitivity"] if os.path.exists(prcFile): page = loadPrcFile(Filename.fromOsSpecific(prcFile)) removeDecls = [] for dec in range(page.getNumDeclarations()): # Check if our variables are given. # NOTE: This check has to be done to not loose our base or other # manual config changes by the user if page.getVariableName(dec) in customConfigVariables: decl = page.modifyDeclaration(dec) removeDecls.append(decl) for dec in removeDecls: page.deleteDeclaration(dec) # Particles particles = "#f" if not base.particleMgrEnabled else "#t" page.makeDeclaration("particles-enabled", particles) # speed of the textwriter page.makeDeclaration("text-write-speed", textSpeed) # audio page.makeDeclaration("audio-volume", volume) mute = "#f" if base.AppHasAudioFocus else "#t" page.makeDeclaration("audio-mute", mute) # controls page.makeDeclaration("control-type", base.controlType) page.makeDeclaration("mouse-sensitivity", mouseSens) else: cpMgr = ConfigPageManager.getGlobalPtr() page = cpMgr.makeExplicitPage("%s Pandaconfig"%appName) page.makeDeclaration("load-display", "pandagl") # get the displays width and height w = self.pipe.getDisplayWidth() h = self.pipe.getDisplayHeight() # set the window size in the config file page.makeDeclaration("win-size", "%d %d"%(w, h)) # set the default to fullscreen in the config file page.makeDeclaration("fullscreen", "1") # particles page.makeDeclaration("particles-enabled", "#t") # speed of the textwriter page.makeDeclaration("text-write-speed", textSpeed) # audio page.makeDeclaration("audio-volume", volume) page.makeDeclaration("audio-mute", "#f") # player controls page.makeDeclaration("control-type", base.controlType) page.makeDeclaration("mouse-sensitivity", mouseSens) # create a stream to the specified config file configfile = OFileStream(prcFile) # and now write it out page.write(configfile) # close the stream configfile.close()
def __writeConfig(self): """Save current config in the prc file or if no prc file exists create one. The prc file is set in the prcFile variable""" page = None volume = str(round(base.musicManager.getVolume(), 2)) volumeSfx = str(round(base.sfxManagerList[0].getVolume(), 2)) mute = "#f" if base.AppHasAudioFocus else "#t" difficuty = str(base.difficulty) customConfigVariables = [ "", "audio-mute", "audio-volume", "audio-volume-sfx", "difficulty" ] if os.path.exists(prcFile): # open the config file and change values according to current # application settings page = loadPrcFile(prcFile) removeDecls = [] for dec in range(page.getNumDeclarations()): # Check if our variables are given. # NOTE: This check has to be done to not loose our base or other # manual config changes by the user if page.getVariableName(dec) in customConfigVariables: decl = page.modifyDeclaration(dec) removeDecls.append(decl) for dec in removeDecls: page.deleteDeclaration(dec) # NOTE: audio-mute are custom variables and # have to be loaded by hand at startup # audio page.makeDeclaration("audio-volume", volume) page.makeDeclaration("audio-volume-sfx", volumeSfx) page.makeDeclaration("audio-mute", mute) page.makeDeclaration("difficulty", difficuty) else: # Create a config file and set default values cpMgr = ConfigPageManager.getGlobalPtr() page = cpMgr.makeExplicitPage("App Pandaconfig") # set OpenGL to be the default page.makeDeclaration("load-display", "pandagl") # get the displays width and height w = self.pipe.getDisplayWidth() h = self.pipe.getDisplayHeight() # set the window size in the config file page.makeDeclaration("win-size", "%d %d" % (w, h)) # set the default to fullscreen in the config file page.makeDeclaration("fullscreen", "1") # audio page.makeDeclaration("audio-volume", volume) page.makeDeclaration("audio-volume-sfx", volumeSfx) page.makeDeclaration("audio-mute", "#f") page.makeDeclaration("sync-video", "1") page.makeDeclaration("textures-auto-power-2", "1") page.makeDeclaration("framebuffer-multisample", "1") page.makeDeclaration("multisamples", "2") page.makeDeclaration("texture-anisotropic-degree", "0") page.makeDeclaration("difficulty", 0) # create a stream to the specified config file configfile = OFileStream(prcFile) # and now write it out page.write(configfile) # close the stream configfile.close()
def __init__(self, pipeline): DebugObject.__init__(self, "BugReporter") self.debug("Creating bug report") reportDir = "BugReports/" + str(int(time.time())) + "/" reportFname = "BugReports/" + str(int(time.time())) + "" if not isdir(reportDir): os.makedirs(reportDir) # Generate general log DebugLog = "Pipeline Bug-Report\n" DebugLog += "Created: " + datetime.datetime.now().isoformat() + "\n" DebugLog += "System: " + sys.platform + " / " + os.name + " (" + str( 8 * struct.calcsize("P")) + " Bit)\n" with open(join(reportDir, "general.log"), "w") as handle: handle.write(DebugLog) # Write stdout and stderr with open(join(reportDir, "stdout.log"), "w") as handle: handle.write(sys.stdout.getLog()) with open(join(reportDir, "stderr.log"), "w") as handle: handle.write(sys.stderr.getLog()) # Write the scene graph handle = OFileStream(join(reportDir, "scene_graph.log")) Globals.render.ls(handle) handle.close() # Write the pipeline settings SettingLog = "# Pipeline Settings Diff File:\n\n" for key, val in pipeline.settings.settings.iteritems(): if val.value != val.default: SettingLog += key + " = " + str( val.value) + " (Default " + str(val.default) + ")\n" with open(join(reportDir, "pipeline.ini"), "w") as handle: handle.write(SettingLog) # Write the panda settings handle = OFileStream(join(reportDir, "pandacfg.log")) ConfigVariableManager.getGlobalPtr().writePrcVariables(handle) handle.close() # Write lights and shadow sources with open(join(reportDir, "lights.log"), "w") as handle: pp = pprint.PrettyPrinter(indent=4, stream=handle) handle.write("\nLights:\n") pp.pprint(pipeline.lightManager.lightSlots) handle.write("\n\nShadowSources:\n") pp.pprint(pipeline.lightManager.shadowSourceSlots) # Extract buffers bufferDir = join(reportDir, "buffers") if not isdir(bufferDir): os.makedirs(bufferDir) for name, (size, entry) in MemoryMonitor.memoryEntries.iteritems(): if type(entry) == Texture: w, h = entry.getXSize(), entry.getYSize() # Ignore buffers if h < 2: continue pipeline.showbase.graphicsEngine.extractTextureData( entry, pipeline.showbase.win.getGsg()) if not entry.hasRamImage(): print "Ignoring", name continue pnmSrc = PNMImage(w, h, 4, 2**16 - 1) entry.store(pnmSrc) pnmColor = PNMImage(w, h, 3, 2**16 - 1) pnmColor.copySubImage(pnmSrc, 0, 0, 0, 0, w, h) pnmColor.write(join(bufferDir, name + "-color.png")) pnmAlpha = PNMImage(w, h, 3, 2**16 - 1) pnmAlpha.copyChannel(pnmSrc, 3, 0) pnmAlpha.write(join(bufferDir, name + "-alpha.png")) shutil.make_archive(reportFname, 'zip', reportDir) shutil.rmtree(reportDir) self.debug("Bug report saved: ", reportFname + ".zip")
def __init__(self, pipeline): DebugObject.__init__(self, "BugReporter") self.debug("Creating bug report") reportDir = "BugReports/" + str(int(time.time())) + "/" reportFname = "BugReports/" + str(int(time.time())) + "" if not isdir(reportDir): os.makedirs(reportDir) # Generate general log DebugLog = "Pipeline Bug-Report\n" DebugLog += "Created: " + datetime.datetime.now().isoformat() + "\n" DebugLog += "System: " + sys.platform + " / " + os.name + " (" + str(8 * struct.calcsize("P")) + " Bit)\n" with open(join(reportDir, "general.log"), "w") as handle: handle.write(DebugLog) # Write stdout and stderr with open(join(reportDir, "stdout.log"), "w") as handle: handle.write(sys.stdout.getLog()) with open(join(reportDir, "stderr.log"), "w") as handle: handle.write(sys.stderr.getLog()) # Write the scene graph handle = OFileStream(join(reportDir, "scene_graph.log")) Globals.render.ls(handle) handle.close() # Write the pipeline settings SettingLog = "# Pipeline Settings Diff File:\n\n" for key, val in pipeline.settings.settings.iteritems(): if val.value != val.default: SettingLog += key + " = " + str(val.value) + " (Default " + str(val.default) + ")\n" with open(join(reportDir, "pipeline.ini"), "w") as handle: handle.write(SettingLog) # Write the panda settings handle = OFileStream(join(reportDir, "pandacfg.log")) ConfigVariableManager.getGlobalPtr().writePrcVariables(handle) handle.close() # Write lights and shadow sources with open(join(reportDir, "lights.log"), "w") as handle: pp = pprint.PrettyPrinter(indent=4, stream=handle) handle.write("\nLights:\n") pp.pprint(pipeline.lightManager.lightSlots) handle.write("\n\nShadowSources:\n") pp.pprint(pipeline.lightManager.shadowSourceSlots) # Extract buffers bufferDir = join(reportDir, "buffers") if not isdir(bufferDir): os.makedirs(bufferDir) for name, (size, entry) in MemoryMonitor.memoryEntries.iteritems(): if type(entry) == Texture: w, h = entry.getXSize(), entry.getYSize() # Ignore buffers if h < 2: continue pipeline.showbase.graphicsEngine.extractTextureData(entry, pipeline.showbase.win.getGsg()) if not entry.hasRamImage(): print "Ignoring", name continue pnmSrc = PNMImage(w, h, 4, 2 ** 16 - 1) entry.store(pnmSrc) pnmColor = PNMImage(w, h, 3, 2 ** 16 - 1) pnmColor.copySubImage(pnmSrc, 0, 0, 0, 0, w, h) pnmColor.write(join(bufferDir, name + "-color.png")) pnmAlpha = PNMImage(w, h, 3, 2 ** 16 - 1) pnmAlpha.copyChannel(pnmSrc, 3, 0) pnmAlpha.write(join(bufferDir, name + "-alpha.png")) shutil.make_archive(reportFname, "zip", reportDir) shutil.rmtree(reportDir) self.debug("Bug report saved: ", reportFname + ".zip")