Beispiel #1
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 #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 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 #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_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)
Beispiel #6
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)
Beispiel #7
0
 def execv(filename,args):
     #  Create an O_TEMPORARY file and pass its name to the slave process.
     #  When this master process dies, the file will be deleted and the
     #  slave process will know to terminate.
     tdir = nt.environ.get("TEMP",None)
     if tdir:
         tfile = None
         try:
             nt.mkdir(pathjoin(tdir,"esky-slave-procs"))
         except EnvironmentError:
             pass
         if exists(pathjoin(tdir,"esky-slave-procs")):
             flags = nt.O_CREAT|nt.O_EXCL|nt.O_TEMPORARY|nt.O_NOINHERIT
             for i in xrange(10):
                 tfilenm = "slave-%d.%d.txt" % (nt.getpid(),i,)
                 tfilenm = pathjoin(tdir,"esky-slave-procs",tfilenm)
                 try:
                     tfile = nt.open(tfilenm,flags)
                     break
                 except EnvironmentError:
                     raise
                     pass
     if tdir and tfile:
         args.insert(1,tfilenm)
         args.insert(1,"--esky-slave-proc")
     res = spawnv(P_WAIT,filename,args)
     raise SystemExit(res)
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 #9
0
def GetShipList(dir = None):
	import nt
	import strop
	
	if (not dir is None):
		loaddir = dir
	else:
		loaddir = "scripts\Custom"
		
	ships = []
	
	f = nt.open(loaddir + "\ships.txt", nt.O_RDONLY)
	l = nt.lseek((f, 0, 2))
	nt.lseek((f, 0, 0))
	s = nt.read((f, l))
	list = strop.split(s)
	nt.close(f)
	
	for ship in list:
		s = strop.split(ship, '.')
		if (len(s)>1) and ((s[-1] == 'pyc') or (s[-1] == 'py')):
			shipname = s[0]
			pModule = __import__('ships.'+shipname)
			
			if (hasattr(pModule, 'GetShipStats')):
				stats = pModule.GetShipStats()
			
				if (shipname != '__init__') and (ships.count([shipname, stats["Name"]]) == 0):
					ships.append([shipname, stats["Name"]])
	
	ships.sort()

	return ships
Beispiel #10
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 #11
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
Beispiel #12
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()
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 #14
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 GetMd5(filename):
        file = nt.open(filename, nt.O_CREAT)
        mdsum = MD5new()
        readBytes = 1024
        while(readBytes):
                readString = nt.read(file, 1024)
                mdsum.update(readString)
                readBytes = len(readString)
        nt.close(file)
        return mdsum.hexdigest()
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)
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 #19
0
    def test_open(self):
        file('temp.txt', 'w+').close()
        try:
            fd = nt.open('temp.txt', nt.O_WRONLY | nt.O_CREAT)
            nt.close(fd)

            self.assertRaisesNumber(OSError, 17, nt.open, 'temp.txt',
                                    nt.O_CREAT | nt.O_EXCL)
            for flag in [nt.O_EXCL, nt.O_APPEND]:
                fd = nt.open('temp.txt', nt.O_RDONLY | flag)
                nt.close(fd)

                fd = nt.open('temp.txt', nt.O_WRONLY | flag)
                nt.close(fd)

                fd = nt.open('temp.txt', nt.O_RDWR | flag)
                nt.close(fd)

            # sanity test
            tempfilename = "temp.txt"
            fd = nt.open(tempfilename, 256, 1)
            nt.close(fd)

            nt.unlink('temp.txt')

            f = nt.open('temp.txt', nt.O_TEMPORARY | nt.O_CREAT)
            nt.close(f)
            self.assertRaises(OSError, nt.stat, 'temp.txt')

            # TODO: These tests should probably test more functionality regarding O_SEQUENTIAL/O_RANDOM
            f = nt.open(
                'temp.txt',
                nt.O_TEMPORARY | nt.O_CREAT | nt.O_SEQUENTIAL | nt.O_RDWR)
            nt.close(f)
            self.assertRaises(OSError, nt.stat, 'temp.txt')

            f = nt.open('temp.txt',
                        nt.O_TEMPORARY | nt.O_CREAT | nt.O_RANDOM | nt.O_RDWR)
            nt.close(f)
            self.assertRaises(OSError, nt.stat, 'temp.txt')
        finally:
            try:
                # should fail if the file doesn't exist
                nt.unlink('temp.txt')
            except:
                pass
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()
	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):
	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()
Beispiel #23
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 #24
0
def test_open():
    file('temp.txt', 'w+').close()
    try:
        fd = nt.open('temp.txt', nt.O_WRONLY | nt.O_CREAT)
        nt.close(fd)

        AssertErrorWithNumber(OSError, 17, nt.open, 'temp.txt', nt.O_CREAT | nt.O_EXCL)
        for flag in [nt.O_EXCL, nt.O_APPEND]:
            fd = nt.open('temp.txt', nt.O_RDONLY | flag)
            nt.close(fd)
            
            fd = nt.open('temp.txt', nt.O_WRONLY | flag)
            nt.close(fd)
            
            fd = nt.open('temp.txt', nt.O_RDWR | flag)
            nt.close(fd)

        # sanity test
        tempfilename = "temp.txt"
        fd = nt.open(tempfilename,256,1)
        nt.close(fd)
        
        nt.unlink('temp.txt')
    
        f = nt.open('temp.txt', nt.O_TEMPORARY | nt.O_CREAT)
        nt.close(f)
        AssertError(OSError, nt.stat, 'temp.txt')
    
        # TODO: These tests should probably test more functionality regarding O_SEQUENTIAL/O_RANDOM
        f = nt.open('temp.txt', nt.O_TEMPORARY | nt.O_CREAT | nt.O_SEQUENTIAL | nt.O_RDWR)
        nt.close(f)
        AssertError(OSError, nt.stat, 'temp.txt')
        
        f = nt.open('temp.txt', nt.O_TEMPORARY | nt.O_CREAT | nt.O_RANDOM | nt.O_RDWR)
        nt.close(f)
        AssertError(OSError, nt.stat, 'temp.txt')
    finally:
        try:    
            # should fail if the file doesn't exist
            nt.unlink('temp.txt')
        except: 
            pass
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 #26
0
def GetSystemList(dir = None):	
	import nt
	import strop
	
	if (not dir is None):
		loaddir = dir
	else:
		loaddir = "scripts\Custom"
		
	systems = []
	
	f = nt.open(loaddir + "\systems.txt", nt.O_RDONLY)
	l = nt.lseek((f, 0, 2))
	nt.lseek((f, 0, 0))
	s = nt.read((f, l))
	list = strop.split(s)
	nt.close(f)

	for system in list:
		s = strop.split(system, '.')
		if (len(s)==1):
			systemname = s[0]
			
			if (systemname == "Starbase12"):
				continue # Starbase12 will only crash us
				pModule = __import__('Systems.Starbase12.Starbase')
			elif (systemname == "DryDock"):
				pModule = __import__('Systems.DryDock.DryDockSystem')
			elif (systemname == "QuickBattle"):
				pModule = __import__('Systems.QuickBattle.QuickBattleSystem')
			else:
				pModule = __import__('Systems.'+systemname+'.'+systemname)
			
			if (hasattr(pModule, 'CreateMenus')):
				systems.append(systemname)
	
	systems.sort()
	return systems
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 #28
0
def test_fdopen():
    fd_lambda = lambda x: nt.dup(x)

    # fd = 0
    result = None
    result = nt.fdopen(fd_lambda(0), "r", 1024)
    Assert(result != None, "1,The file object was not returned correctly")

    result = None
    result = nt.fdopen(fd_lambda(0), "w", 2048)
    Assert(result != None, "2,The file object was not returned correctly")

    result = None
    result = nt.fdopen(fd_lambda(0), "a", 512)
    Assert(result != None, "3,The file object was not returned correctly")

    # fd = 1
    result = None
    result = nt.fdopen(fd_lambda(1), "a", 1024)
    Assert(result != None, "4,The file object was not returned correctly")

    result = None
    result = nt.fdopen(fd_lambda(1), "r", 2048)
    Assert(result != None, "5,The file object was not returned correctly")

    result = None
    result = nt.fdopen(fd_lambda(1), "w", 512)
    Assert(result != None, "6,The file object was not returned correctly")

    # fd = 2
    result = None
    result = nt.fdopen(fd_lambda(2), "r", 1024)
    Assert(result != None, "7,The file object was not returned correctly")

    result = None
    result = nt.fdopen(fd_lambda(2), "a", 2048)
    Assert(result != None, "8,The file object was not returned correctly")

    result = None
    result = nt.fdopen(fd_lambda(2), "w", 512)
    Assert(result != None, "9,The file object was not returned correctly")

    if not is_cli:
        result.close()

    # The file descriptor is not valid
    AssertError(OSError, nt.fdopen, 3000)
    AssertError(OSError, nt.fdopen, -1)
    AssertError(OSError, nt.fdopen, 3000, "w")
    AssertError(OSError, nt.fdopen, 3000, "w", 1024)

    # The file mode does not exist
    AssertError(ValueError, nt.fdopen, 0, "p")

    stuff = "\x00a\x01\x02b\x03 \x04  \x05\n\x06_\0xFE\0xFFxyz"
    name = "cp5633.txt"
    fd = nt.open(name, nt.O_CREAT | nt.O_BINARY | nt.O_TRUNC | nt.O_WRONLY)
    f = nt.fdopen(fd, 'wb')
    f.write(stuff)
    f.close()
    f = file(name, 'rb')
    try:
        AreEqual(stuff, f.read())
    finally:
        f.close()
        nt.remove(name)
Beispiel #29
0
def test_fdopen():
    
    # IronPython does not implement the nt.dup function
    if not is_cli:
        fd_lambda = lambda x: nt.dup(x)
    else:
        AssertError(AttributeError, lambda: nt.dup)
        fd_lambda = lambda x: x
    
    # fd = 0    
    result = None
    result = nt.fdopen(fd_lambda(0),"r",1024)
    Assert(result!=None,"1,The file object was not returned correctly")
    
    result = None
    result = nt.fdopen(fd_lambda(0),"w",2048)
    Assert(result!=None,"2,The file object was not returned correctly")
    
    result = None
    result = nt.fdopen(fd_lambda(0),"a",512)
    Assert(result!=None,"3,The file object was not returned correctly")
    
    # fd = 1
    result = None
    result = nt.fdopen(fd_lambda(1),"a",1024)
    Assert(result!=None,"4,The file object was not returned correctly")
    
    result = None
    result = nt.fdopen(fd_lambda(1),"r",2048)
    Assert(result!=None,"5,The file object was not returned correctly")
    
    result = None
    result = nt.fdopen(fd_lambda(1),"w",512)
    Assert(result!=None,"6,The file object was not returned correctly")
    
    # fd = 2
    result = None
    result = nt.fdopen(fd_lambda(2),"r",1024)
    Assert(result!=None,"7,The file object was not returned correctly")
    
    result = None
    result = nt.fdopen(fd_lambda(2),"a",2048)
    Assert(result!=None,"8,The file object was not returned correctly")
    
    result = None
    result = nt.fdopen(fd_lambda(2),"w",512)
    Assert(result!=None,"9,The file object was not returned correctly")
    
    if not is_cli:
        result.close()
         
    # The file descriptor is not valid
    AssertError(OSError,nt.fdopen,3000)
    AssertError(OSError,nt.fdopen,-1)
    AssertError(OSError,nt.fdopen,3000, "w")
    AssertError(OSError,nt.fdopen,3000, "w", 1024)
    
    # The file mode does not exist
    AssertError(ValueError,nt.fdopen,0,"p")
 
    stuff = "\x00a\x01\x02b\x03 \x04  \x05\n\x06_\0xFE\0xFFxyz"
    name = "cp5633.txt"
    fd = nt.open(name, nt.O_CREAT | nt.O_BINARY | nt.O_TRUNC | nt.O_WRONLY)
    f = nt.fdopen(fd, 'wb')
    f.write(stuff)
    f.close()
    f = file(name, 'rb')
    try:
        AreEqual(stuff, f.read())
    finally:
        f.close()
        nt.remove(name)
Beispiel #30
0
def NtOpenFile(filePath, mode):
    return nt.open(filePath, mode);
Beispiel #31
0
 def test_fdopen(self):
     fd_lambda = lambda x: nt.dup(x)
     
     # fd = 0    
     result = None
     result = nt.fdopen(fd_lambda(0),"r",1024)
     self.assertTrue(result!=None,"1,The file object was not returned correctly")
     
     result = None
     result = nt.fdopen(fd_lambda(0),"w",2048)
     self.assertTrue(result!=None,"2,The file object was not returned correctly")
     
     result = None
     result = nt.fdopen(fd_lambda(0),"a",512)
     self.assertTrue(result!=None,"3,The file object was not returned correctly")
     
     # fd = 1
     result = None
     result = nt.fdopen(fd_lambda(1),"a",1024)
     self.assertTrue(result!=None,"4,The file object was not returned correctly")
     
     result = None
     result = nt.fdopen(fd_lambda(1),"r",2048)
     self.assertTrue(result!=None,"5,The file object was not returned correctly")
     
     result = None
     result = nt.fdopen(fd_lambda(1),"w",512)
     self.assertTrue(result!=None,"6,The file object was not returned correctly")
     
     # fd = 2
     result = None
     result = nt.fdopen(fd_lambda(2),"r",1024)
     self.assertTrue(result!=None,"7,The file object was not returned correctly")
     
     result = None
     result = nt.fdopen(fd_lambda(2),"a",2048)
     self.assertTrue(result!=None,"8,The file object was not returned correctly")
     
     result = None
     result = nt.fdopen(fd_lambda(2),"w",512)
     self.assertTrue(result!=None,"9,The file object was not returned correctly")
     
     if not is_cli:
         result.close()
         
     # The file descriptor is not valid
     self.assertRaises(OSError,nt.fdopen,3000)
     self.assertRaises(OSError,nt.fdopen,-1)
     self.assertRaises(OSError,nt.fdopen,3000, "w")
     self.assertRaises(OSError,nt.fdopen,3000, "w", 1024)
     
     # The file mode does not exist
     self.assertRaises(ValueError,nt.fdopen,0,"p")
 
     stuff = "\x00a\x01\x02b\x03 \x04  \x05\n\x06_\0xFE\0xFFxyz"
     name = "cp5633.txt"
     fd = nt.open(name, nt.O_CREAT | nt.O_BINARY | nt.O_TRUNC | nt.O_WRONLY)
     f = nt.fdopen(fd, 'wb')
     f.write(stuff)
     f.close()
     f = file(name, 'rb')
     try:
         self.assertEqual(stuff, f.read())
     finally:
         f.close()
         nt.remove(name)
Beispiel #32
0
    def test_fdopen(self):
        fd_lambda = lambda x: nt.dup(x)

        # fd = 0
        result = None
        result = os.fdopen(fd_lambda(0),"r",1024)
        self.assertFalse(result is None,"1,The file object was not returned correctly")

        result = None
        result = os.fdopen(fd_lambda(0),"w",2048)
        self.assertFalse(result is None,"2,The file object was not returned correctly")

        with self.assertRaises(OSError):
            os.fdopen(fd_lambda(0),"a",512)

        # fd = 1
        with self.assertRaises(OSError):
            os.fdopen(fd_lambda(1),"a",1024)

        result = None
        result = os.fdopen(fd_lambda(1),"r",2048)
        self.assertFalse(result is None,"5,The file object was not returned correctly")

        result = None
        result = os.fdopen(fd_lambda(1),"w",512)
        self.assertFalse(result is None,"6,The file object was not returned correctly")

        # fd = 2
        result = None
        result = os.fdopen(fd_lambda(2),"r",1024)
        self.assertFalse(result is None,"7,The file object was not returned correctly")

        with self.assertRaises(OSError):
            os.fdopen(fd_lambda(2),"a",2048)

        result = None
        result = os.fdopen(fd_lambda(2),"w",512)
        self.assertFalse(result is None,"9,The file object was not returned correctly")

        if not is_cli:
            result.close()

        # The file descriptor is not valid
        self.assertRaises(OSError,os.fdopen,3000)
        self.assertRaises(ValueError,os.fdopen,-1)
        self.assertRaises(OSError,os.fdopen,3000, "w")
        self.assertRaises(OSError,os.fdopen,3000, "w", 1024)

        # The file mode does not exist
        self.assertRaises(ValueError,os.fdopen,0,"p")

        stuff = b"\x00a\x01\x02b\x03 \x04  \x05\n\x06_\0xFE\0xFFxyz"
        name = "cp5633.txt"
        fd = nt.open(name, nt.O_CREAT | nt.O_BINARY | nt.O_TRUNC | nt.O_WRONLY)
        f = os.fdopen(fd, 'wb')
        f.write(stuff)
        f.close()
        try:
            with open(name, 'rb') as f:
                self.assertEqual(stuff, f.read())
        finally:
            nt.remove(name)
Beispiel #33
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)
Beispiel #34
0
 def return_fd2():
     return nt.open(temp_file, 0)
Beispiel #35
0
 def return_fd2():
     return nt.open(temp_file, 0)
Beispiel #36
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