def SaveProgress(pObject, pEvent):
            debug(__name__ + ", SaveProgress")
            global pPlayerShipType

            file = nt.open(Path, nt.O_WRONLY | nt.O_TRUNC | nt.O_CREAT | nt.O_BINARY)
            nt.write(file, "Ship = " + "'" + pPlayerShipType + "'")
            nt.close(file)
Beispiel #2
0
    def test_fsync(self):
        fsync_file_name = 'text_fsync.txt'
        fd = nt.open(fsync_file_name, nt.O_WRONLY | nt.O_CREAT)

        # negative test, make sure it raises on invalid (closed) fd
        try:
            nt.close(fd+1)
        except:
            pass
        self.assertRaises(OSError, nt.fsync, fd+1)

        # BUG (or implementation detail)
        # On a posix system, once written to a file descriptor
        # it can be read using another fd without any additional intervention.
        # In case of IronPython the data lingers in a stream which
        # is used to simulate file descriptor.
        fd2 = nt.open(fsync_file_name, nt.O_RDONLY)
        self.assertEqual(nt.read(fd2, 1), b'')

        nt.write(fd, b'1')
        if is_cli:
            self.assertEqual(nt.read(fd2, 1), b'') # this should be visible right away, but is not
        nt.fsync(fd)
        self.assertEqual(nt.read(fd2, 1), b'1')

        nt.close(fd)
        nt.close(fd2)

        # fsync on read file descriptor
        fd = nt.open(fsync_file_name, nt.O_RDONLY)
        if not is_cli:
            self.assertRaises(OSError, nt.fsync, fd)
        nt.close(fd)

        # fsync on rdwr file descriptor
        fd = nt.open(fsync_file_name, nt.O_RDWR)
        nt.fsync(fd)
        nt.close(fd)

        # fsync on derived fd
        if not is_cli:
            for mode in ('rb', 'r'):
                with open(fsync_file_name, mode) as f:
                    self.assertRaises(OSError, nt.fsync, f.fileno())

        for mode in ('wb', 'w'):
            with open(fsync_file_name, mode) as f:
                nt.fsync(f.fileno())

        nt.unlink(fsync_file_name)

        # fsync on pipe ends
        r,w = nt.pipe()
        if not is_cli:
            self.assertRaises(OSError, nt.fsync, r)
        nt.write(w, b'1')
        if False:
            nt.fsync(w) # this blocks
        nt.close(w)
        nt.close(r)
Beispiel #3
0
def debug(s):
	if not DEBUG:
		return

	file = nt.open(logfile, nt.O_WRONLY | nt.O_APPEND | nt.O_CREAT)
	nt.write(file, s + "\n")
	nt.close(file)
Beispiel #4
0
def test_coverage():
    f = file(temp_file, 'w')
    Assert(str(f).startswith("<open file '%s', mode 'w'" % temp_file))
    Assert(f.fileno() <> -1)
    Assert(f.fileno() <> 0)

    # write
    AssertError(TypeError, f.writelines, [3])
    f.writelines(["firstline\n"])

    f.close()
    Assert(str(f).startswith("<closed file '%s', mode 'w'" % temp_file))

    # append
    f = file(temp_file, 'a+')
    f.writelines(['\n', 'secondline\n'])

    pos = len('secondline\n') + 1
    f.seek(-1 * pos, 1)

    f.writelines(['thirdline\n'])
    f.close()

    # read
    f = file(temp_file, 'r+', 512)
    f.seek(-1 * pos - 2, 2)

    AreEqual(f.readline(), 'e\n')
    AreEqual(f.readline(5), 'third')
    AreEqual(f.read(-1), 'line\n')
    AreEqual(f.read(-1), '')
    f.close()

    # read
    f = file(temp_file, 'rb', 512)
    f.seek(-1 * pos - 2, 2)

    AreEqual(f.readline(), 'e\r\n')
    AreEqual(f.readline(5), 'third')
    AreEqual(f.read(-1), 'line\r\n')
    AreEqual(f.read(-1), '')
    f.close()

    ## file op in nt
    nt.unlink(temp_file)

    fd = nt.open(temp_file, nt.O_CREAT | nt.O_WRONLY)
    nt.write(fd, "hello ")
    nt.close(fd)

    fd = nt.open(temp_file, nt.O_APPEND | nt.O_WRONLY)
    nt.write(fd, "world")
    nt.close(fd)

    fd = nt.open(temp_file, 0)
    AreEqual(nt.read(fd, 1024), "hello world")
    nt.close(fd)

    nt.unlink(temp_file)
Beispiel #5
0
def test_coverage():
    f = file(temp_file, 'w')
    Assert(str(f).startswith("<open file '%s', mode 'w'" % temp_file))
    Assert(f.fileno() <> -1)
    Assert(f.fileno() <> 0)

    # write
    AssertError(TypeError, f.writelines, [3])
    f.writelines(["firstline\n"])

    f.close()
    Assert(str(f).startswith("<closed file '%s', mode 'w'" % temp_file))

    # append
    f = file(temp_file, 'a+')
    f.writelines(['\n', 'secondline\n'])

    pos = len('secondline\n') + 1
    f.seek(-1 * pos, 1)

    f.writelines(['thirdline\n'])
    f.close()

    # read
    f = file(temp_file, 'r+', 512)
    f.seek(-1 * pos - 2, 2)

    AreEqual(f.readline(), 'e\n')
    AreEqual(f.readline(5), 'third')
    AreEqual(f.read(-1), 'line\n')
    AreEqual(f.read(-1), '')
    f.close()

    # read
    f = file(temp_file, 'rb', 512)
    f.seek(-1 * pos - 2, 2)

    AreEqual(f.readline(), 'e\r\n')
    AreEqual(f.readline(5), 'third')
    AreEqual(f.read(-1), 'line\r\n')
    AreEqual(f.read(-1), '')
    f.close()

    ## file op in nt    
    nt.unlink(temp_file)

    fd = nt.open(temp_file, nt.O_CREAT | nt.O_WRONLY)
    nt.write(fd, "hello ")
    nt.close(fd)

    fd = nt.open(temp_file, nt.O_APPEND | nt.O_WRONLY)
    nt.write(fd, "world")
    nt.close(fd)

    fd = nt.open(temp_file, 0)
    AreEqual(nt.read(fd, 1024), "hello world")
    nt.close(fd)

    nt.unlink(temp_file)
Beispiel #6
0
    def test_fsync(self):
        fsync_file_name = 'text_fsync.txt'
        fd = nt.open(fsync_file_name, nt.O_WRONLY | nt.O_CREAT)

        # negative test, make sure it raises on invalid (closed) fd
        try:
            nt.close(fd+1)
        except:
            pass
        self.assertRaises(OSError, nt.fsync, fd+1)

        # BUG (or implementation detail)
        # On a posix system, once written to a file descriptor
        # it can be read using another fd without any additional intervention.
        # In case of IronPython the data lingers in a stream which
        # is used to simulate file descriptor.
        fd2 = nt.open(fsync_file_name, nt.O_RDONLY)
        self.assertEqual(nt.read(fd2, 1), '')

        nt.write(fd, '1')
        self.assertEqual(nt.read(fd2, 1), '') # this should be visible right away, but is not
        nt.fsync(fd)
        self.assertEqual(nt.read(fd2, 1), '1')

        nt.close(fd)
        nt.close(fd2)

        # fsync on read file descriptor
        fd = nt.open(fsync_file_name, nt.O_RDONLY)
        self.assertRaises(OSError, nt.fsync, fd)
        nt.close(fd)

        # fsync on rdwr file descriptor
        fd = nt.open(fsync_file_name, nt.O_RDWR)
        nt.fsync(fd)
        nt.close(fd)

        # fsync on derived fd
        for mode in ('rb', 'r'):
            f = open(fsync_file_name, mode)
            self.assertRaises(OSError, nt.fsync, f.fileno())
            f.close()

        for mode in ('wb', 'w'):
            f = open(fsync_file_name, mode)
            nt.fsync(f.fileno())
            f.close()

        nt.unlink(fsync_file_name)

        # fsync on pipe ends
        r,w = nt.pipe()
        self.assertRaises(OSError, nt.fsync, r)
        nt.write(w, '1')
        nt.fsync(w)
        nt.close(w)
        nt.close(r)
def SaveBackup():
    debug(__name__ + ", SaveBackup")
    fConfig = LoadFoundationConfig()

    file = nt.open(sBackup, nt.O_WRONLY|nt.O_TRUNC|nt.O_CREAT)
    nt.write(file, "##### Generated by DS9FX\n##### Backup Foundation Mutator Copy\n##### Do not modify unless you know what you're doing\n\nlActiveMutators = " + str(fConfig))
    nt.close(file)
    
    reload(bFoundationConfig)
Beispiel #8
0
def debug_save(s):
	if not DEBUG:
		return
	
	lock.acquire()
	file = nt.open(logfile, nt.O_WRONLY | nt.O_APPEND | nt.O_CREAT)
	nt.write(file, s + "\n")
	nt.close(file)
	lock.release()
Beispiel #9
0
def writeInfo():
	import nt
	import Appc
	
	f = nt.open('test.txt', nt.O_RDWR | nt.O_CREAT)
	a = dir(Appc)
	for s in a:
		nt.write((f, s+'\n'))
			
	nt.close(f)
def debug(s):
    if not DEBUG:
        return

    import nt

    debug_file = nt.open(
        "scripts\\Custom\\AdvancedTechnologies\\Data\\Debug.txt", nt.O_WRONLY | nt.O_APPEND | nt.O_CREAT
    )
    nt.write(debug_file, s + "\n")
    nt.close(debug_file)
def Print(sFile = "ConsoleDump.txt"):
	debug(__name__ + ", Print")
	pTop = App.TopWindow_GetTopWindow()
	pCon = pTop.FindMainWindow(App.MWT_CONSOLE)
	pConsole = App.TGConsole_Cast(pCon.GetFirstChild())
	file = nt.open("scripts\\Custom\\DS9FX\\" + sFile, nt.O_WRONLY|nt.O_CREAT|nt.O_TRUNC)
	pString = App.TGString()
	for i in range(0, pConsole.GetNumChildren(), 1):
		pPara = App.TGParagraph_Cast(pConsole.GetNthChild(i))
		pPara.GetString(pString)
		nt.write(file, pString.GetCString() + "\n###\n")

	nt.close(file)
Beispiel #12
0
	def LogString(self, s):
		sTime = self.GetTime()
		if self.WasFileCreated == 0:
			file = nt.open(self.FilePath, nt.O_WRONLY|nt.O_CREAT|nt.O_TRUNC)
			nt.write(file, "#This is the dump of the LogCreator: "+str(self)+ "\n")
			nt.write(file, "#This log file was created on: "+sTime+ "\n########################################\n")
			self.WasFileCreated = 1
		else:
			file = nt.open(self.FilePath, nt.O_WRONLY|nt.O_APPEND)
		if sTime != self.CurrentTime:
			nt.write(file, "## -------------------- ##"+ "\n")
			nt.write(file, "####################\n#######>>>"+str(sTime)+ "\n")
			self.CurrentTime = sTime
		nt.write(file, "#>>>"+str(s)+ "\n")
		nt.close(file)
def RestoreFoundationSettings():
    debug(__name__ + ", RestoreFoundationSettings")
    fConfig = LoadBackupConfig()

    file = nt.open(sFdtnPath, nt.O_WRONLY|nt.O_TRUNC|nt.O_CREAT)
    nt.write(file, "lActiveMutators = " + str(fConfig))
    nt.close(file)
    
    reload(FoundationConfig)

    # Let people know that we restored proper settings now
    print 'DS9FX: Interacting With Foundation... Restoring Backup Mutator Settings'

    # Simply now interact with the Foundation and let it do it's thing
    Foundation.LoadConfig()
Beispiel #14
0
def Save(pObject, pEvent):
        CloseDialog(pObject)
        
        dict_Ships, dict_Systems = GetShipsAndSystems()
        
        sSaveFile = MISSIONS_SAVE_DIR + sCurSaveName + ".py"
        # delete the file if it does already exist
        try:
                nt.remove(sSaveFile)
        except:
                pass
        file = nt.open(sSaveFile, nt.O_CREAT | nt.O_RDWR)
        sSaveShip = string.replace(repr(dict_Ships), ", {", ",\\\n\t\t{")
        sSaveShip = string.replace(sSaveShip, "],", "],\\\n\t")
        nt.write(file, "Systems = " + repr(dict_Systems) + "\n")
        nt.write(file, "Ships = " + sSaveShip + "\n")
        nt.close(file)
Beispiel #15
0
def WriteSetup(filename):
	gBridge = g_sBridge
	gSystem = []
	gShips = []
	
	for system in g_pRegionListData:
		import strop
		s = strop.split(system, '.')
		gSystem.append([s[0], s[1], ''])
	
	keys = g_pShipListData.keys()

	for key in keys:
		gShips.append(g_pShipListData[key])
		
	import nt
	try: 
		if (filename == "QBSetup"):
			nt.remove("scripts\Custom\QuickBattleGame\\" + filename + ".py")
		else:
			nt.remove("scripts\Custom\QuickBattleGame\Missions\\" + filename + ".py")
	except OSError:
		pass
		
	import QuickBattle

	try:
		if (filename == "QBSetup"):     # We have to save the mainsetup in the main directory
			file = nt.open('scripts\Custom\QuickBattleGame\\' + filename + '.py', nt.O_CREAT | nt.O_RDWR)
		else:                           # rest here.
			file = nt.open('scripts\Custom\QuickBattleGame\Missions\\' + filename + '.py', nt.O_CREAT | nt.O_RDWR)
	
		nt.write(file, "gVersion=" + repr(QuickBattle.g_version) + "\n")
		nt.write(file, "gSystem=" + repr(gSystem) + "\n")
		nt.write(file, "gBridge=" + repr(gBridge) + "\n")
	
		nt.write(file, "gShips=" + repr(gShips) + "\n")
	
		import plugin
		nt.write(file, "gPluginData=" + repr(plugin.gPluginData) + "\n")
				
		nt.close(file)
	except:
		return 0
		
	return -1
def SaveConfig():
	import nt
	global mutatorList

	pModule = __import__('Custom.FoundationConfig')
	pModule.lActiveMutators = []

	sOut = [ 'lActiveMutators = [' ]
	for i in mutatorList._keyList.values():
		if i.IsEnabled():
			pModule.lActiveMutators.append(i.name)
			sOut.append('\t"""%s""",' % (i.name))
	sOut.append(']')

	print sOut

	file = nt.open('scripts\\Custom\\FoundationConfig.py', nt.O_WRONLY|nt.O_TRUNC|nt.O_CREAT)
	for i in sOut:
		nt.write(file, i + '\n')
	nt.close(file)
Beispiel #17
0
def test_write():
    # write the file
    tempfilename = "temp.txt"
    file = open(tempfilename, "w")
    nt.write(file.fileno(), "Hello,here is the value of test string")
    file.close()

    # read from the file
    file = open(tempfilename, "r")
    str = nt.read(file.fileno(), 100)
    AreEqual(str, "Hello,here is the value of test string")
    file.close()
    nt.unlink(tempfilename)

    # BUG 8783 the argument buffersize in nt.read(fd, buffersize) is less than zero
    # the string written to the file is empty string
    tempfilename = "temp.txt"
    file = open(tempfilename, "w")
    nt.write(file.fileno(), "bug test")
    file.close()
    file = open(tempfilename, "r")
    AssertError(OSError, nt.read, file.fileno(), -10)
    file.close()
    nt.unlink(tempfilename)
Beispiel #18
0
def test_write():
    # write the file
    tempfilename = "temp.txt"
    file = open(tempfilename,"w")
    nt.write(file.fileno(),"Hello,here is the value of test string")
    file.close()
    
    # read from the file
    file =   open(tempfilename,"r")
    str = nt.read(file.fileno(),100)
    AreEqual(str,"Hello,here is the value of test string")
    file.close()
    nt.unlink(tempfilename)
    
    # BUG 8783 the argument buffersize in nt.read(fd, buffersize) is less than zero
    # the string written to the file is empty string
    tempfilename = "temp.txt"
    file = open(tempfilename,"w")
    nt.write(file.fileno(),"bug test")
    file.close()
    file = open(tempfilename,"r")
    AssertError(OSError,nt.read,file.fileno(),-10)
    file.close()
    nt.unlink(tempfilename)
	def SaveFile(self):
		debug(__name__ + ", SaveFile")
		config = {}
		if self.module:
			config.update(self.module.config)

		file = nt.open(self.sFile, nt.O_CREAT | nt.O_WRONLY | nt.O_BINARY | nt.O_TRUNC)
		nt.write(file, "# File generated by the Config Library from MLeo Daalder\n# Edit on own accord!\n\n")

		# Yes, I know I could just stringify the dictonary, but I like readable configuration files.
		nt.write(file, "config = {\n")
		for key, value in config.items():
			nt.write(file, '"""' + str(key) + '""": ' + str(value) + ",\n")
		nt.write(file, "}\n")
		nt.close(file)
		if self.module:
			reload(self.module)
def SaveConfig(pObject, pEvent):
                # Write all data to the Config file.
                global ESRHullCustomizationOption
                global SRCutscene, SRCutsceneFile
                # ESR data:
                file = nt.open(ConfigPath, nt.O_WRONLY | nt.O_TRUNC | nt.O_CREAT | nt.O_BINARY)
                nt.write(file, "ESRHullCustomizationOptionDefault = " + str(ESRHullCustomizationOption))
                nt.write(file, "\nSRCutsceneDefault = \"" + str(SRCutscene) + "\"")
                nt.write(file, "\nEngineeringOptionDefault = " + str(pEngineeringButton.IsChosen()))
                nt.close(file)
print(fileName[0:4])
# slicing
print(fileName[4:0])
# *Wrong*  fileName[3] = "a";


print(type(fileName))
# <class "str">
print(type(mode))
# <class "int">
print(type(testData))
# <class "bytes">

if fileDesc == -1:
    print("Open Error!\n")
else:
    nt.write(fileDesc, testData)
    nt.close(fileDesc)


x = 3 - 4j
print(type(x))
print(type(x.imag))
print(type(x.real))
print(x.conjugate())
print(type(x.conjugate()))


print(hex(ord("s")))
print(chr(115))
Beispiel #22
0
def SaveConfig():
    TRUE = 1
    FALSE = 0
    ###[BridgeFX Settings]###
    bFX_Enabled = NanoFX_Config.bFX_Enabled
    ###
    bFX_ExpSparkFXLevel = NanoFX_Config.bFX_ExpSparkFXLevel
    bFX_DamageSparkFXLevel = NanoFX_Config.bFX_DamageSparkFXLevel
    bFX_DamageSparkFXDuration = NanoFX_Config.bFX_DamageSparkFXDuration
    bFX_ParticleControl = NanoFX_Config.bFX_ParticleControl
    ###
    ###[CameraFX Settings]###
    cFX_Enabled = NanoFX_Config.cFX_Enabled
    ###
    cFX_ViewScreenDefault = NanoFX_Config.cFX_ViewScreenDefault
    cFX_ViewScreenMax = NanoFX_Config.cFX_ViewScreenMax
    cFX_AwayDistance = NanoFX_Config.cFX_AwayDistance
    cFX_ForwardDistance = NanoFX_Config.cFX_ForwardDistance
    ###
    ###[ExplosionFX Settings]###
    eFX_Enabled = NanoFX_Config.eFX_Enabled
    ###
    eFX_LightFlickerFX = NanoFX_Config.eFX_LightFlickerFX
    eFX_FixBrightGlows = NanoFX_Config.eFX_FixBrightGlows
    eFX_ExpSparkFXLevel = NanoFX_Config.eFX_ExpSparkFXLevel
    eFX_DamageSparkFXLevel = NanoFX_Config.eFX_DamageSparkFXLevel
    eFX_DamageSparkFXDuration = NanoFX_Config.eFX_DamageSparkFXDuration
    eFX_DebrisFXLevel = NanoFX_Config.eFX_DebrisFXLevel
    eFX_DebrisFXDuration = NanoFX_Config.eFX_DebrisFXDuration
    eFX_ParticleControl = NanoFX_Config.eFX_ParticleControl
    eFX_RotationFX = NanoFX_Config.eFX_RotationFX
    eFX_SplashRadius = NanoFX_Config.eFX_SplashRadius
    ###
    ###[SpecialFX Settings]###
    sFX_Enabled = NanoFX_Config.sFX_Enabled
    ###
    sFX_AtmosphereGlowFX = NanoFX_Config.sFX_AtmosphereGlowFX
    sFX_PlasmaFX = NanoFX_Config.sFX_PlasmaFX
    ###
    ###[WarpFX Settings]###
    wFX_Enabled = NanoFX_Config.wFX_Enabled
    ###
    wFX_MaxRandomDistance = NanoFX_Config.wFX_MaxRandomDistance
    ###

    import nt
    file = nt.open(ConfigPath, nt.O_WRONLY | nt.O_TRUNC | nt.O_CREAT | nt.O_BINARY)
    # Write header...
    nt.write(file, "TRUE = 1\nFALSE = 0\n")
    # Write bridge stuff
    nt.write(file, "###[BridgeFX Settings]###\nbFX_Enabled = " + str(bFX_Enabled) +
             "\n###\nbFX_ExpSparkFXLevel = " + str(bFX_ExpSparkFXLevel) +
             "\nbFX_DamageSparkFXLevel = " + str(bFX_DamageSparkFXLevel) +
             "\nbFX_DamageSparkFXDuration = " + str(bFX_DamageSparkFXDuration) +
             "\nbFX_ParticleControl = " + str(bFX_ParticleControl) + "\n###\n")
    # Write camera stuff
    nt.write(file, "###[CameraFX Settings]###\ncFX_Enabled = " + str(cFX_Enabled) +
             "\n###\ncFX_ViewScreenDefault = " + str(cFX_ViewScreenDefault) +
             "\ncFX_ViewScreenMax = " + str(cFX_ViewScreenMax) +
             "\ncFX_AwayDistance = " + str(cFX_AwayDistance) +
             "\ncFX_ForwardDistance = " + str(cFX_ForwardDistance) + "\n###\n")
    # Write explosion stuff
    nt.write(file, "###[ExplosionFX Settings]###\neFX_Enabled = " + str(eFX_Enabled) +
             "\n###\neFX_LightFlickerFX = \"" + str(eFX_LightFlickerFX) + "\"" +
             "\neFX_FixBrightGlows = \"" + str(eFX_FixBrightGlows) + "\"" +
             "\neFX_ExpSparkFXLevel = " + str(eFX_ExpSparkFXLevel) +
             "\neFX_DamageSparkFXLevel = " + str(eFX_DamageSparkFXLevel) +
             "\neFX_DamageSparkFXDuration = " + str(eFX_DamageSparkFXDuration) +
             "\neFX_DebrisFXLevel = " + str(eFX_DebrisFXLevel) +
             "\neFX_DebrisFXDuration = " + str(eFX_DebrisFXDuration) +
             "\neFX_ParticleControl = " + str(eFX_ParticleControl) +
             "\neFX_RotationFX = \"" + str(eFX_RotationFX) + "\"" +
             "\neFX_SplashRadius = " + str(eFX_SplashRadius) + "\n###\n")
    # Write special stuff
    nt.write(file, "###[SpecialFX Settings]###\nsFX_Enabled = " + str(sFX_Enabled) +
             "\n###\nsFX_AtmosphereGlowFX = \"" + str(sFX_AtmosphereGlowFX) + "\"" +
             "\nsFX_PlasmaFX = \"" + str(sFX_PlasmaFX) + "\"\n###\n")
    # Write warp stuff
    nt.write(file, "###[WarpFX Settings]###\nwFX_Enabled = " + str(wFX_Enabled) +
             "\n###\nwFX_MaxRandomDistance = " + str(wFX_MaxRandomDistance) + "\n###\n")
    nt.close(file)

    reload(NanoFX_Config)
def CorrectConfig(pObject, pEvent):
                rExcaliburSelection  = DS9FXSavedConfig.ExcaliburSelection
                rDefiantSelection = DS9FXSavedConfig.DefiantSelection
                rOregonSelection = DS9FXSavedConfig.OregonSelection
                rLakotaSelection = DS9FXSavedConfig.LakotaSelection
                rDS9Selection = DS9FXSavedConfig.DS9Selection
                rBugship1Selection = DS9FXSavedConfig.Bugship1Selection
                rBugship2Selection = DS9FXSavedConfig.Bugship2Selection
                rBugship3Selection = DS9FXSavedConfig.Bugship3Selection
                rWormholeSelection = DS9FXSavedConfig.WormholeSelection
                rVideoSelection = DS9FXSavedConfig.VideoSelection
                rModelPreloadingSelection = DS9FXSavedConfig.ModelPreloadingSelection
                rRandomEnemyFleetAttacks = DS9FXSavedConfig.RandomEnemyFleetAttacks
                rDomIS = DS9FXSavedConfig.DomIS
                rDS9Music = DS9FXSavedConfig.DS9Music
                rWormholeMusic = DS9FXSavedConfig.WormholeMusic 
                rGammaMusic = DS9FXSavedConfig.GammaMusic
                rRandomDomStrength = DS9FXSavedConfig.RandomDomStrength
                rFederationSide = DS9FXSavedConfig.FederationSide
                rDominionSide = DS9FXSavedConfig.DominionSide
                rCometSelection = DS9FXSavedConfig.CometSelection
                rDS9Planets = DS9FXSavedConfig.DS9Planets
                rDS9NanoFX = DS9FXSavedConfig.DS9NanoFX
                rGammaPlanets = DS9FXSavedConfig.GammaPlanets
                rGammaNanoFX = DS9FXSavedConfig.GammaNanoFX
                rDominionTimeSpan = DS9FXSavedConfig.DominionTimeSpan
                rCometAlphaTrail = DS9FXSavedConfig.CometAlphaTrail
                rCometAlphaTrailTexture = DS9FXSavedConfig.CometAlphaTrailTexture
                rDebugMode = DS9FXSavedConfig.DebugMode
                rDS9MapPlanetDetail = DS9FXSavedConfig.DS9MapPlanetDetail
                rGammaMapPlanetDetail = DS9FXSavedConfig.GammaMapPlanetDetail
                rInsideWormholeBackgroundTexture = DS9FXSavedConfig.InsideWormholeBackgroundTexture
                rInsideWormholeModel = DS9FXSavedConfig.InsideWormholeModel
                rStabilizeBC = DS9FXSavedConfig.StabilizeBC
                rIntroVid = DS9FXSavedConfig.IntroVid
                rCompletionVid = DS9FXSavedConfig.CompletionVid

                file = nt.open(UnsavedPath, nt.O_WRONLY | nt.O_TRUNC | nt.O_CREAT | nt.O_BINARY)
                nt.write(file, "ExcaliburSelection = " + str(rExcaliburSelection) +
                "\nDefiantSelection = " + str(rDefiantSelection) +
                "\nOregonSelection = " + str(rOregonSelection) +
                "\nLakotaSelection = " + str(rLakotaSelection) +
                "\nDS9Selection = " + str(rDS9Selection) +
                "\nBugship1Selection = " + str(rBugship1Selection) +
                "\nBugship2Selection = " + str(rBugship2Selection)+
                "\nBugship3Selection = " + str(rBugship3Selection) +
                "\nWormholeSelection = " + str(rWormholeSelection) +
                "\nVideoSelection = " + str(rVideoSelection) +
                "\nModelPreloadingSelection = " + str(rModelPreloadingSelection) +
                "\nRandomEnemyFleetAttacks = " + str(rRandomEnemyFleetAttacks) +
                "\nDomIS = " + str(rDomIS) +
                "\nDS9Music = " + str(rDS9Music) +
                "\nWormholeMusic = " + str(rWormholeMusic) +
                "\nGammaMusic = " + str(rGammaMusic) +
                "\nRandomDomStrength = " + str(rRandomDomStrength) +
                "\nFederationSide = " + str(rFederationSide) +
                "\nDominionSide = " + str(rDominionSide) +
                "\nCometSelection = " + str(rCometSelection) +
                "\nDS9Planets = " + str(rDS9Planets) +
                "\nDS9NanoFX = " + str(rDS9NanoFX) +
                "\nGammaPlanets = " + str(rGammaPlanets) +
                "\nGammaNanoFX = " + str(rGammaNanoFX) +
                "\nDominionTimeSpan = " + str(rDominionTimeSpan) +
                "\nCometAlphaTrail = " + str(rCometAlphaTrail) +
                "\nCometAlphaTrailTexture = " + str(rCometAlphaTrailTexture) +
                "\nDebugMode = " + str(rDebugMode) +
                "\nDS9MapPlanetDetail = " + str(rDS9MapPlanetDetail) +
                "\nGammaMapPlanetDetail = " + str(rGammaMapPlanetDetail) +
                "\nInsideWormholeBackgroundTexture = " + str(rInsideWormholeBackgroundTexture) +
                "\nInsideWormholeModel = " + str(rInsideWormholeModel) +
                "\nStabilizeBC = " + str(rStabilizeBC) +
                "\nIntroVid = " + str(rIntroVid) +
                "\nCompletionVid = " + str(rCompletionVid))
                nt.close(file)

                reload(DS9FXUnsavedConfig)
Beispiel #24
0
	def DumpEnd(self):
		if self.WasFileCreated and self.NotQuitted:
			file = nt.open(self.FilePath, nt.O_WRONLY|nt.O_APPEND)
			nt.write(file, "########################################\n# "+self.GetTime()+"\n#Ending of log dump - User is quiting the game\n########################################\n")
			nt.close(file)
			self.NotQuitted = 0
Beispiel #25
0
	def LogException(self, et, s = ""):
		sTime = self.GetTime()
		if self.WasFileCreated == 0:
			file = nt.open(self.FilePath, nt.O_WRONLY|nt.O_CREAT|nt.O_TRUNC)
			nt.write(file, "#This is the dump of the LogCreator: "+str(self)+ "\n")
			nt.write(file, "#This log file was created on: "+sTime+ "\n########################################\n")
			self.WasFileCreated = 1
		else:
			file = nt.open(self.FilePath, nt.O_WRONLY|nt.O_APPEND)
		if sTime != self.CurrentTime:
			nt.write(file, "## -------------------- ##"+ "\n")
			nt.write(file, "####################\n#######>>>"+str(sTime)+ "\n")
			self.CurrentTime = sTime
		nt.write(file, "< ------------------------------------------- >\n<----------------- EXCEPTION ----------------->\n")
		if s != "":
			nt.write(file, str(s) + "\n")
		nt.write(file, "Traceback of Error: "+str(et[0])+": "+str(et[1])+ "\n")
		if et[2]:
			tl = GetTracebackList(et[2])
		else:
			tl = []
		for tline in tl:
			sline = "Script: \""+str(tline[0])+"\", Line "+str(tline[1])+", in the function \""+str(tline[2])+"\"."
			nt.write(file, sline + "\n")
		nt.write(file, "<--------------- END EXCEPTION --------------->\n< ------------------------------------------- >\n")
		nt.close(file)
Beispiel #26
0
def NtWriteFile(fileDesc, str):
    return nt.write(fileDesc, str);
def SaveConfig(pObject, pEvent):
	global pBar, pSetButton, pStationsButton, pThrusterStat 
	GravForceXvalue = pBar.GetValue()
	if GravForceXvalue == 0.0:
		GravForceXvalue = 1.0
	nSystemMapScale = pSMScaleBar.GetValue()
	if nSystemMapScale < 1.0:
		nSystemMapScale = 1.0
	ConfigPath  = "scripts\\Custom\\UnifiedMainMenu\\ConfigModules\\Options\\SavedConfigs\\GravityFXConfigValues.py"
	file = nt.open(ConfigPath, nt.O_WRONLY | nt.O_TRUNC | nt.O_CREAT | nt.O_BINARY)
	nt.write(file, "# Saved Configuration File for Gravity FX,   by USS Frontier" + "\n")
	nt.write(file, "GravForceXvalue = " + str(GravForceXvalue) + "\n")
	nt.write(file, "SetStockPlanetsDensity = " + str(pSetButton.IsChosen()) + "\n")
	nt.write(file, "SystemMapScale = " + str(nSystemMapScale) + "\n")
	nt.write(file, "SetSMScaleLightyear = " + str(pSMScaleButton.IsChosen()) + "\n")
	nt.write(file, "GravDmgFac = " + str(pCloseDmgBar.GetValue()) + "\n")
	nt.write(file, "class SetUseLogs:" + "\n")
	nt.write(file, "\t"+ "LoadGravityFX = " +str(SetUseLog['LoadGravityFX'].IsChosen())+ "\n")
	nt.write(file, "\t"+ "GravityManager = " +str(SetUseLog['GravityManager'].IsChosen())+ "\n")
	nt.write(file, "\t"+ "GravWellPlugins = " +str(SetUseLog['GravWellPlugins'].IsChosen())+ "\n")
	nt.write(file, "\t"+ "TorpGravEffects = " +str(SetUseLog['TorpGravEffects'].IsChosen())+ "\n")
	nt.write(file, "\t"+ "SystemMap = " +str(SetUseLog['SystemMap'].IsChosen())+ "\n")
	nt.write(file, "\t"+ "GravSensors = " +str(SetUseLog['GravSensors'].IsChosen())+ "\n")
	nt.write(file, "\t"+ "GravWells = " +str(SetUseLog['GravWells'].IsChosen())+ "\n")
	nt.write(file, "\t"+ "Astrometrics = " +str(SetUseLog['Astrometrics'].IsChosen())+ "\n")
	nt.write(file, "\t"+ "GravGenerator = " +str(SetUseLog['GravGen'].IsChosen())+ "\n")
	nt.write(file, "StationsAreAffected = "+str(pStationsButton.IsChosen()) + "\n")
	nt.write(file, "ThrusterState = "+str(pThrusterStat.IsChosen()) + "\n")
	nt.close(file)

	pModule.GravForceXvalue = GravForceXvalue
	pModule.SetStockPlanetsDensity = pSetButton.IsChosen()
	pModule.SystemMapScale = nSystemMapScale
	pModule.SetSMScaleLightyear = pSMScaleButton.IsChosen()
	pModule.GravDmgFac = pCloseDmgBar.GetValue()
	pModule.SetUseLogs.LoadGravityFX = SetUseLog['LoadGravityFX'].IsChosen()
	pModule.SetUseLogs.GravityManager = SetUseLog['GravityManager'].IsChosen()
	pModule.SetUseLogs.GravWellPlugins = SetUseLog['GravWellPlugins'].IsChosen()
	pModule.SetUseLogs.TorpGravEffects = SetUseLog['TorpGravEffects'].IsChosen()
	pModule.SetUseLogs.SystemMap = SetUseLog['SystemMap'].IsChosen()
	pModule.SetUseLogs.GravSensors = SetUseLog['GravSensors'].IsChosen()
	pModule.SetUseLogs.GravWells = SetUseLog['GravWells'].IsChosen()
	pModule.SetUseLogs.Astrometrics = SetUseLog['Astrometrics'].IsChosen()
	pModule.SetUseLogs.GravGenerator = SetUseLog['GravGen'].IsChosen()
	pModule.StationsAreAffected = pStationsButton.IsChosen()
	pModule.ThrusterState = pThrusterStat.IsChosen()