rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
,"bad" : [(0.8,"all","VAR_aggressor_dnicks attack repelled by valorous VAR_system_system - based VAR_defender_FG\\The resourceful and potent VAR_defender_nickp squadran was assaulted by the deceitful VAR_aggressor_nicks flightgroup of VAR_aggressor_FGtype starships. Far from running, the VAR_defender_nicks squad made ... | ,"bad" : [(0.4,"all","VAR_system_system Skirmish ends in defeat for VAR_aggressor_nicks\\With hositilities rising in the VAR_system_sector, the VAR_aggressor_nicks flightgroup VAR_aggressor_FG initiated combat with the VAR_defender_nickp squadron of VAR_defender_FGtype, the VAR_defender_FG s. Initially the battle wen... | def allNews(): |
flightgroupnamelist=[] | flightgroupnamelist={} | def AllFactions (): facs =[] for i in range (VS.GetNumFactions()): facs+= [VS.GetFactionName(i)] return facs |
def ReadBaseNameList(): | def ReadBaseNameList(faction): | def ReadBaseNameList(): bnl=[] try: f = open ('universe/names.txt','r') bnl = f.readlines() f.close() except: try: f = open ('../universe/names.txt','r') bnl = f.readlines() f.close() except: global genericalphabet bnl=genericalphabet for i in range(len(bnl)): bnl[i]=bnl[i].rstrip() return bnl |
f = open ('universe/names.txt','r') | f = open (filename,'r') | def ReadBaseNameList(): bnl=[] try: f = open ('universe/names.txt','r') bnl = f.readlines() f.close() except: try: f = open ('../universe/names.txt','r') bnl = f.readlines() f.close() except: global genericalphabet bnl=genericalphabet for i in range(len(bnl)): bnl[i]=bnl[i].rstrip() return bnl |
f = open ('../universe/names.txt','r') | f = open ('../'+filename,'r') | def ReadBaseNameList(): bnl=[] try: f = open ('universe/names.txt','r') bnl = f.readlines() f.close() except: try: f = open ('../universe/names.txt','r') bnl = f.readlines() f.close() except: global genericalphabet bnl=genericalphabet for i in range(len(bnl)): bnl[i]=bnl[i].rstrip() return bnl |
global genericalphabet bnl=genericalphabet | try: f = open ('../universe/names.txt','r') bnl = f.readlines() f.close() except: global genericalphabet bnl=genericalphabet | def ReadBaseNameList(): bnl=[] try: f = open ('universe/names.txt','r') bnl = f.readlines() f.close() except: try: f = open ('../universe/names.txt','r') bnl = f.readlines() f.close() except: global genericalphabet bnl=genericalphabet for i in range(len(bnl)): bnl[i]=bnl[i].rstrip() return bnl |
if (len(flightgroupnamelist)==0): flightgroupnamelist = ReadBaseNameList() | if (not (faction in flightgroupnamelist)): flightgroupnamelist[faction]=ReadBaseNameList(faction) | def GetRandomFGNames (numflightgroups, faction): global flightgroupnamelist if (len(flightgroupnamelist)==0): flightgroupnamelist = ReadBaseNameList() for i in range (numflightgroups-len(flightgroupnamelist)): flightgroupnamelist.append(str(i)) return flightgroupnamelist |
flightgroupnamelist.append(str(i)) | flightgroupnamelist[faction].append(str(i)) | def GetRandomFGNames (numflightgroups, faction): global flightgroupnamelist if (len(flightgroupnamelist)==0): flightgroupnamelist = ReadBaseNameList() for i in range (numflightgroups-len(flightgroupnamelist)): flightgroupnamelist.append(str(i)) return flightgroupnamelist |
def GetRandomBaseName (n): | def GetRandomBaseName (n,faction): | def GetRandomBaseName (n): retval=[] global basenamelist try: import seedrandom if (len(basenamelist)==0): basenamelist=ReadBaseNameList() for i in range (n): retval+=[basenamelist[seedrandom.rand()%len(basenamelist)]] except: retval=[] for i in range (n): retval+=[str(n)] n+=1 return retval |
basenamelist=ReadBaseNameList() | basenamelist=ReadBaseNameList(faction+'_base') | def GetRandomBaseName (n): retval=[] global basenamelist try: import seedrandom if (len(basenamelist)==0): basenamelist=ReadBaseNameList() for i in range (n): retval+=[basenamelist[seedrandom.rand()%len(basenamelist)]] except: retval=[] for i in range (n): retval+=[str(n)] n+=1 return retval |
nam=GetRandomBaseName (1); | nam=GetRandomBaseName (1,faction); | def launchBaseOrbit(type,faction,loc,orbitradius,orbitspeed,unit): import Vector import dynamic_universe R = Vector.Vector(vsrandom.uniform(.5*orbitradius,orbitradius), vsrandom.uniform(.5*orbitradius,orbitradius), vsrandom.uniform(.5*orbitradius,orbitradius)) RMag = Vector.Mag(R) T = Vector.Vector(vsrandom.uniform(.5*... |
def IOmessage(time,fr,to,message): sys.stderr.write("IOmessage [printed in %f seconds; from %s to %s: '%s']\n" % (time,fr,to,message)) def GetMasterPartList(a=None,b=None,c=None,d=None,e=None,f=None,g=None,h=None,i=None,j=None): print "GetMasterPartList" return Unit() def GetContrabandList(a=None,b=None,c=None,d=None,e... | def getOwner(a=None,b=None,c=None,d=None,e=None,f=None,g=None,h=None,i=None,j=None): print "getOwner" return Unit() | |
def GetCargo(self,i): print "GetCargo" return Cargo() | def GetCargo(self,i): print "GetCargo" return Cargo() | |
return 0; | return 0 | def getSignificantDistance(a=None,b=None,c=None,d=None,e=None,f=None,g=None,h=None,i=None,j=None): print "getSignificantDistance" return 0; |
return -1; | return -1 def hasCargo(a=None,b=None,c=None,d=None,e=None,f=None,g=None,h=None,i=None,j=None): print "hasCargo" return 0 def GetCargo(a=None,b=None,c=None,d=None,e=None,f=None,g=None,h=None,i=None,j=None): print "GetCargo" return Cargo("","",1,1,1,1) | def isPlayerStarship(a=None,b=None,c=None,d=None,e=None,f=None,g=None,h=None,i=None,j=None): print "isPlayerStarship" return -1; |
Director.pushSaveSting(plr, "mission_names", name) | Director.pushSaveString(plr, "mission_names", name) | def writemissionname(name,path): if len(path)<=1: name+=" - In System" Director.pushSaveSting(plr, "mission_names", name) |
Director.pushSaveSting(plr, "mission_descriptions", name) | Director.pushSaveString(plr, "mission_descriptions", name) | def writedescription(name): Director.pushSaveSting(plr, "mission_descriptions", name) |
Director.pushSaveSting(plr, "mission_scripts", name) | Director.pushSaveString(plr, "mission_scripts", name) | def writemissionsavegame (name): Director.pushSaveSting(plr, "mission_scripts", name) |
fac=faction_ships.intToFaction(fac) enemies = list(faction_ships.enemies[fac]) | facnum=faction_ships.factionToInt(fac) enemies = list(faction_ships.enemies[facnum]) | def contractMissionsFor(fac,minsysaway,maxsysaway): fac=faction_ships.intToFaction(fac) enemies = list(faction_ships.enemies[fac]) script='' cursystem = VS.getSystemFile() thisfaction = VS.GetGalaxyFaction (cursystem) preferredfaction=None if (VS.GetRelation (fac,thisfaction)>0): preferredfaction=thisfaction#try to sta... |
l = dynamic_battle.persystemattacklist | l = dynamic_battle.persystemattacklist[j] | def contractMissionsFor(fac,minsysaway,maxsysaway): fac=faction_ships.intToFaction(fac) enemies = list(faction_ships.enemies[fac]) script='' cursystem = VS.getSystemFile() thisfaction = VS.GetGalaxyFaction (cursystem) preferredfaction=None if (VS.GetRelation (fac,thisfaction)>0): preferredfaction=thisfaction#try to sta... |
if (VS.GetRelation(fac,l[1][1])>0): generateDefendMission(j,l[1][0],l[1][1],l[0][0],l[0][1]) | if (VS.GetRelation(fac,k[1][1])>0): generateDefendMission(j,k[1][0],k[1][1],k[0][0],k[0][1]) | def contractMissionsFor(fac,minsysaway,maxsysaway): fac=faction_ships.intToFaction(fac) enemies = list(faction_ships.enemies[fac]) script='' cursystem = VS.getSystemFile() thisfaction = VS.GetGalaxyFaction (cursystem) preferredfaction=None if (VS.GetRelation (fac,thisfaction)>0): preferredfaction=thisfaction#try to sta... |
generatePatrolMission(maxsysaway, minsysaway,vsrandom.randrange(4,10)) | generatePatrolMission(j,vsrandom.randrange(4,10)) | def contractMissionsFor(fac,minsysaway,maxsysaway): fac=faction_ships.intToFaction(fac) enemies = list(faction_ships.enemies[fac]) script='' cursystem = VS.getSystemFile() thisfaction = VS.GetGalaxyFaction (cursystem) preferredfaction=None if (VS.GetRelation (fac,thisfaction)>0): preferredfaction=thisfaction#try to sta... |
generateCargoMission(path,true) | generateCargoMission(j,'',basefac) | def contractMissionsFor(fac,minsysaway,maxsysaway): fac=faction_ships.intToFaction(fac) enemies = list(faction_ships.enemies[fac]) script='' cursystem = VS.getSystemFile() thisfaction = VS.GetGalaxyFaction (cursystem) preferredfaction=None if (VS.GetRelation (fac,thisfaction)>0): preferredfaction=thisfaction#try to sta... |
generateCargoMission(path,false) | generateCargoMission(j,'Contraband',basefac) | def contractMissionsFor(fac,minsysaway,maxsysaway): fac=faction_ships.intToFaction(fac) enemies = list(faction_ships.enemies[fac]) script='' cursystem = VS.getSystemFile() thisfaction = VS.GetGalaxyFaction (cursystem) preferredfaction=None if (VS.GetRelation (fac,thisfaction)>0): preferredfaction=thisfaction#try to sta... |
generatePatrolMission(path,1) def CreateMissions(minsys=1,maxsys=4): | generatePatrolMission(j,1) def CreateMissions(minsys=0,maxsys=4): | def contractMissionsFor(fac,minsysaway,maxsysaway): fac=faction_ships.intToFaction(fac) enemies = list(faction_ships.enemies[fac]) script='' cursystem = VS.getSystemFile() thisfaction = VS.GetGalaxyFaction (cursystem) preferredfaction=None if (VS.GetRelation (fac,thisfaction)>0): preferredfaction=thisfaction#try to sta... |
def LookForTrouble(faction,sys): fg = FGsInSystem(faction,sys) for i in faction_ships.enemies[faction_ships.factionToInt(faction)]: efg = AllFGsInSystem(i,sys) if (len(efg)): if vsrandom.randrange(0,3)==0: initiateAttack(fg,faction,efg,i) | def BattlesInSystem(): if sys in persystemattacklist: return persystemattacklist[sys] #return {} #used to be a hash table return [] | |
,"dockedat" : getDockFaction(system) | def makeDynamicNews (type_event,stage_event,aggressor,defender,success ,scale_event,system,keyword): | |
return formatNewsItem (getNewsItem(getDockFaction(),type_event,stage_event,getSuccessStr(success) ,getPOV(getDockFaction(),defender,aggressor,getSuccessStr(success)) | return formatNewsItem (getNewsItem(getDockFaction(system),type_event,stage_event,getSuccessStr(success) ,getPOV(getDockFaction(system),defender,aggressor,getSuccessStr(success)) | def makeDynamicNews (type_event,stage_event,aggressor,defender,success ,scale_event,system,keyword): |
return 0.15 | return 0.25 | def povCutOff(): |
def getDockFaction(): | def getDockFaction(system): | def getDockFaction(): |
global allUsefullVariables return VS.GetGalaxyFaction(allUsefullVariables["system"]) else: | print "Returning the systems faction" return VS.GetGalaxyFaction(system) else: print "Returning" + un.getFactionName() + "as units faction" | def getDockFaction(): |
VS.IOmessage (0,"defend",self.mplay,"Greetings, %s. You must patrol a system for us :" % name) | VS.IOmessage (0,"patrol",self.mplay,"Greetings, %s. You must patrol a system for us :" % name) | def __init__ (self,numsystemsaway, num_significants_to_patrol, distance_from_base, creds, jumps=(), donevar=''): Director.Mission.__init__(self) self.donevar=donevar self.jnum=0 self.cred=creds |
distInOneSec = Dot (parent.GetVelocity(),posdiff) if (distInOneSec>un.getDistance(parent)): print "%s too close to %s\n" % (parent.getName(),un.getName()) | distInOneSec = Dot (Sub(parent.GetVelocity(),un.GetVelocity()),posdiff) if (distInOneSec>un.getDistance(parent) and Dot (posdiff,un.GetOrientation()[2])>0): print "%s too close to %s \n" % (parent.getName(),un.getName()) print distInOneSec print un.getDistance (parent) | def Execute(self): VS.PythonAI.Execute(self) |
station_pos=station_unit.getPosition() | station_pos=station_unit.Position() | def launch_around_station(station_name,fgname,faction,type,ai,nr_ships,nr_waves,logo=''): station_unit=unit.getUnitByFgID(station_name) if(station_unit.isNull()): sys.stderr.write("launch.py:launch_around_station did not find unit %s\n" % (station_name)) return VS.Unit() station_pos=station_unit.getPosition() rsize=sta... |
myvec=my_unit.Position() | myvec=my_unit.LocalPosition() | def launch_wave_around_unit (fgname, faction, type, ai, nr_ships, minradius, maxradius, my_unit,logo=''): myvec = (0,0,0) if (my_unit.isNull()): un=launch_wave_around_area (fgname,faction,type,ai,nr_ships,minradius,maxradius,myvec,logo) return un myvec=my_unit.Position() print myvec rsiz=my_unit.rSize() un=launch_wave_... |
if (not self.un): | dead=not self.un if (not dead): dead = self.un.GetHull()<=0 if (dead): | def Check(self): import fg_util if (not self.un): if (VS.systemInMemory (self.starsystem)): fg_util.RemoveShipFromFG(self.fgname,self.faction,self.type) else: fg_util.LandShip(self.fgname,self.faction,self.type) return 0 else: sys=self.un.getUnitSystemFile() if (len(sys)): self.starsystem=sys return 1 |
if (self.you): | if (not self.you.isNull()): | def __init__ (self,factionname, numsystemsaway, cargoquantity, missiondifficulty, creds, launchoncapship, time_to_complete, category): Director.Mission.__init__(self); self.you=VS.Unit() self.base=VS.Unit() self.arrived=0 self.mplay="all" |
AI.PythonAI.Execute(self); | def Execute(self): | |
hi1.IncRef() | def Execute(self): | |
un.SetFgDirective ('b') | un.setFgDirective ('b') | def StopTargettingEachOther (fgname,faction,enfgname,enfaction): i=VS.getUnitList() un=i.current() while (un): if ((un.getFactionName()==enfaction and un.getFlightgroupName()==enfgname) or (un.getFactionName()==faction and un.getFlightgroupName()==fgname)): un.SetFgDirective ('b') #check to see that its' in this flight... |
self.lasttime=0.0 | self.lasttime=-1000 | def __init__(self): print "init1INITNITNITNTINTINTINTINTITNINTINTINTINTINT\nININTINTINTITNITNITNTINTINTINTINTITNITNITNITNITNITNITNITNITNIT" VS.SetDifficulty(.9) Director.Mission.__init__(self) self.lasttime=0.0 self.waittime=10.0 print "init" |
print "init" | def __init__(self): print "init1INITNITNITNTINTINTINTINTITNINTINTINTINTINT\nININTINTINTITNITNITNTINTINTINTINTITNITNITNITNITNITNITNITNITNIT" VS.SetDifficulty(.9) Director.Mission.__init__(self) self.lasttime=0.0 self.waittime=10.0 print "init" | |
print "testing" | def launch_new_wave(self): print "testing" side = vsrandom.randrange(0,2) faction="confed" ai = vsrandom.randrange(0,2) if (ai==0): ai = "printhello.py" else: ai = "default" if (side==0): faction=faction_ships.get_enemy_of("confed") else: faction=faction_ships.get_friend_of("confed") launched = launch.launch_wave_aroun... | |
launched = launch.launch_wave_around_unit ("Shadow",faction,faction_ships.getRandomFighter(faction),ai,vsrandom.randrange(1,10),2000.0,4000.0,VS.getPlayer(),'') | launched = launch.launch_wave_around_unit ("Shadow",faction,faction_ships.getRandomFighter(faction),ai,vsrandom.randrange(1,10),100.0,2000.0,VS.getPlayer(),'') if (vsrandom.randrange(0,10)==0): launch.launch_wave_around_unit ("ShadowCap",faction,faction_ships.getRandomCapitol(faction),ai,1,2000.0,4000.0,VS.getPlayer(),... | def launch_new_wave(self): print "testing" side = vsrandom.randrange(0,2) faction="confed" ai = vsrandom.randrange(0,2) if (ai==0): ai = "printhello.py" else: ai = "default" if (side==0): faction=faction_ships.get_enemy_of("confed") else: faction=faction_ships.get_friend_of("confed") launched = launch.launch_wave_aroun... |
print "ex" | def Execute (self): print "ex" time = VS.GetGameTime() if (time-self.lasttime>self.waittime): self.launch_new_wave() self.waittime=vsrandom.randrange(10.0,30.0) self.lasttime=time | |
Fixer ("rowenna","Speak with Rowenna",[("decided_iso_evil",0)],"bases/fixers/iso.spr","bases/fixers/iso.py"), | Fixer ("rowenna","Speak with Rowenna",[("decided_iso_evil",0),("iso_mission2",0)],"bases/fixers/iso.spr","bases/fixers/iso.py"), | def drawobjs(self,room,x,y,wid,hei): Base.Texture(room,self.name,self.image,x+(wid/2),y+(hei/2)) Base.Python(room,self.name,x,y,wid,hei,self.text,self.choices,True) |
addstr += '\nAlso-- we have information that the target may be informed about your attack and may be ready to run. Be quick!' | addstr += ' | def generateBountyMission (path,fg,fac): typ = fg_util.RandomShipIn(fg,fac) cap = faction_ships.isCapital(typ) diff=vsrandom.randrange(0,6) runaway=(vsrandom.random()>=.75) creds=1000+2000*runaway+500*diff+syscreds*len(path) if (cap): creds*=40 finalprice=creds+syscreds*len(path) addstr="" isFixer=vsrandom.random()<fix... |
Fixer ("rowenna","Speak with Rowenna",[("decided_iso_evil",0),("iso_mission2",-1)],"bases/fixers/iso.spr","bases/fixers/iso.py"), Fixer ("cloaked_man","Speak with hooded figure",[("decided_iso_good",0)],"bases/fixers/cloak.spr","bases/fixers/iso_antagonist.py") | Fixer ("rowenna","Speak with Rowenna",[("decided_iso_evil",0),("iso_mission2",-1)],"bases/fixers/iso.spr","bases/fixers/iso.py") | def drawobjs(self,room,x,y,wid,hei): Base.Texture(room,self.name,self.image,x+(wid/2),y+(hei/2)) Base.Python(room,self.name,x,y,wid,hei,self.text,self.choices,True) |
Fixer ("rowenna","Speak with Rowenna",[("decided_iso_evil",0),("iso_mission3",0),("iso_mission2",-1)],"bases/fixers/iso.spr","bases/fixers/iso.py") | Fixer ("rowenna","Speak with Rowenna",[("decided_iso_evil",0),("iso_mission3",0),("iso_mission2",-1)],"bases/fixers/iso.spr","bases/fixers/iso.py"), Fixer ("cloaked_man","Speak with hooded figure",[("decided_iso_good",0),("iso_evil2",1)],"bases/fixers/cloak.spr","bases/fixers/iso_antagonist.py") | def drawobjs(self,room,x,y,wid,hei): Base.Texture(room,self.name,self.image,x+(wid/2),y+(hei/2)) Base.Python(room,self.name,x,y,wid,hei,self.text,self.choices,True) |
def __init__ (self,price,factionname,numships): | def __init__ (self,price,factionname,numships,difficulty): | def __init__ (self,price,factionname,numships): Director.Mission.__init__(self) self.price=price self.faction=factionname self.you = VS.getPlayer() self.numships=numships self.adjsys=go_somewhere_significant (self.you,0,5000,0) self.wingship = faction_ships.getRandomFighter(factionname) nam = "[%s]" % self.wingship sel... |
lead.SetTarget(self.you) VS.IOmessage (0,"game","all","[%s] You don't have the agreed money... prepare to DIE") | if (self.diff>0): lead.SetTarget(self.you) VS.IOmessage (0,"game","all","[%s] You don't have the agreed money... prepare to DIE!"%lead.getName()) else: VS.IOmessage (0,"game","all","[%s] You don't have the money. A fool like you won't last long!"%lead.getName()) | def GenerateWingmen(self): if (self.you): if (self.you.getCredits()>=self.price): self.you.addCredits(-self.price) lead=launch.launch_wave_around_unit(self.you.getFlightgroupName(), self.you.getFactionName(), self.wingship, "default", self.numships, 500, 1000, self.you) VS.IOmessage (0,"wingman","all","[%s] I am at you... |
,"middle" :{"success": {"good" : [(0.3,"all","Blockade in VAR_system_system System:\\VAR_aggressor_posessive media reports that the blockade which began recently in the VAR_system_system system is still continuing. According to <VAR_aggressor_posessive>'s reporters, their military has sustained only modest losses, whi... | ,"middle" :{"success": {"good" : [(0.3,"all","Blockade in VAR_system_system System:\\VAR_aggressor_possessive media reports that the blockade which began recently in the VAR_system_system system is still continuing. According to <VAR_aggressor_possessive>'s reporters, their military has sustained only modest losses, w... | def allNews(): |
,"loss" : {"good" : [(0.3,"all","VAR_system_system Assult Crushed!\\The first assaults of the VAR_aggressor_posessive attackers on the blockade which began recently in the VAR_system_system system have been successfully stopped. Waves of <VAR_aggressor_posessive>'s fighters have been destroyed and their burning wrec... | ,"loss" : {"good" : [(0.3,"all","VAR_system_system Assult Crushed!\\The first assaults of the VAR_aggressor_possessive attackers on the blockade which began recently in the VAR_system_system system have been successfully stopped. Waves of <VAR_aggressor_possessive>'s fighters have been destroyed and their burning wr... | def allNews(): |
if (not un): | import fg_util if (not self.un): | def Check(self): if (not un): if (VS.systemInMemory (self.starsystem)): RemoveShipFromFG(self.fgname,self.faction,self.type) else: LandShip(self.fgname,self.faction,self.type) return 0 else: sys=un.getUnitSystemFile() if (len(sys)): self.starsystem=sys return 1 |
RemoveShipFromFG(self.fgname,self.faction,self.type) | fg_util.RemoveShipFromFG(self.fgname,self.faction,self.type) | def Check(self): if (not un): if (VS.systemInMemory (self.starsystem)): RemoveShipFromFG(self.fgname,self.faction,self.type) else: LandShip(self.fgname,self.faction,self.type) return 0 else: sys=un.getUnitSystemFile() if (len(sys)): self.starsystem=sys return 1 |
LandShip(self.fgname,self.faction,self.type) | fg_util.LandShip(self.fgname,self.faction,self.type) | def Check(self): if (not un): if (VS.systemInMemory (self.starsystem)): RemoveShipFromFG(self.fgname,self.faction,self.type) else: LandShip(self.fgname,self.faction,self.type) return 0 else: sys=un.getUnitSystemFile() if (len(sys)): self.starsystem=sys return 1 |
sys=un.getUnitSystemFile() | sys=self.un.getUnitSystemFile() | def Check(self): if (not un): if (VS.systemInMemory (self.starsystem)): RemoveShipFromFG(self.fgname,self.faction,self.type) else: LandShip(self.fgname,self.faction,self.type) return 0 else: sys=un.getUnitSystemFile() if (len(sys)): self.starsystem=sys return 1 |
class DownloadInfoFrame(wxFrame): | class DownloadInfoFrame: | def __init__(self, errormsg): wxPyEvent.__init__(self) self.SetEventType(wxEVT_ERROR_STATUS) self.errormsg = errormsg |
wxFrame.__init__(self, None, -1, 'BitTorrent download', size = wxSize(550, 260)) | frame = wxFrame(None, -1, 'BitTorrent download', size = wxSize(550, 300)) self.frame = frame | def __init__(self, flag): wxFrame.__init__(self, None, -1, 'BitTorrent download', size = wxSize(550, 260)) self.flag = flag self.fin = false self.shown = false self.drawGUI() |
self.drawGUI() EVT_CLOSE(self, self.done) EVT_BUTTON(self, self.cancelButton.GetId(), self.done) EVT_CHOOSE_FILE(self, self.onChooseFile) EVT_UPDATE_STATUS(self, self.onUpdateStatus) EVT_FINISH_STATUS(self, self.onFinishEvent) EVT_FAIL_STATUS(self, self.onFailEvent) EVT_ERROR_STATUS(self, self.onErrorEvent) def drawG... | panel = wxPanel(frame, -1) colSizer = wxFlexGridSizer(cols = 1, vgap = 7) colSizer.Add(wxStaticText(panel, -1, 'Saving:'), 0, wxEXPAND) | def __init__(self, flag): wxFrame.__init__(self, None, -1, 'BitTorrent download', size = wxSize(550, 260)) self.flag = flag self.fin = false self.shown = false self.drawGUI() |
colSizer.Add(self.fileNameText, 0, wxEXPAND, 4) self.gauge = wxGauge(panel, -1, range = 1000) self.gauge.SetBezelFace(5) self.gauge.SetShadowWidth(5) colSizer.Add(self.gauge, 0, wxEXPAND, 7) | colSizer.Add(self.fileNameText, 0, wxEXPAND) self.gauge = wxGauge(panel, -1, range = 1000, style = wxGA_SMOOTH) colSizer.Add(self.gauge, 0, wxEXPAND) | def drawGUI(self): panel = wxPanel(self, -1) colSizer = wxBoxSizer(wxVERTICAL) |
colSizer.Add(gridSizer, 0, wxEXPAND, 7) | colSizer.Add(gridSizer, 0, wxEXPAND) colSizer.Add(1, 1, 1, wxEXPAND) | def drawGUI(self): panel = wxPanel(self, -1) colSizer = wxBoxSizer(wxVERTICAL) |
colSizer.Add(self.cancelButton, 0, wxALIGN_RIGHT, 5) colSizer.Add(wxStaticText(panel, -1, ''), 1, wxEXPAND) | colSizer.Add(self.cancelButton, 0, wxALIGN_CENTER) colSizer.AddGrowableCol(0) colSizer.AddGrowableRow(4) | def drawGUI(self): panel = wxPanel(self, -1) colSizer = wxBoxSizer(wxVERTICAL) |
border.Add(colSizer, 1, wxALL, 25) | border.Add(colSizer, 1, wxEXPAND | wxALL, 25) | def drawGUI(self): panel = wxPanel(self, -1) colSizer = wxBoxSizer(wxVERTICAL) |
wxPostEvent(self, UpdateStatusEvent(fractionDone, timeEst, downRate, upRate, activity)) | wxPostEvent(self.frame, UpdateStatusEvent(fractionDone, timeEst, downRate, upRate, activity)) | def updateStatus(self, fractionDone = None, timeEst = None, downRate = None, upRate = None, activity=None): if self.flag.isSet(): return wxPostEvent(self, UpdateStatusEvent(fractionDone, timeEst, downRate, upRate, activity)) |
wxPostEvent(self, FinishEvent()) | wxPostEvent(self.frame, FinishEvent()) | def finished(self): if self.flag.isSet(): return self.fin = true wxPostEvent(self, FinishEvent()) |
wxPostEvent(self, FailEvent()) | wxPostEvent(self.frame, FailEvent()) | def failed(self): if self.flag.isSet(): return self.fin = true wxPostEvent(self, FailEvent()) |
wxPostEvent(self, ErrorEvent(errormsg)) | wxPostEvent(self.frame, ErrorEvent(errormsg)) | def error(self, errormsg): if self.flag.isSet(): return wxPostEvent(self, ErrorEvent(errormsg)) |
self.Show(true) dlg = wxMessageDialog(self, message = event.errormsg, | self.frame.Show(true) dlg = wxMessageDialog(self.frame, message = event.errormsg, | def onErrorEvent(self, event): if self.flag.isSet(): return if not self.shown: self.Show(true) dlg = wxMessageDialog(self, message = event.errormsg, caption = 'Download Error', style = wxOK | wxICON_ERROR) dlg.Fit() dlg.Center() dlg.Show(true) |
wxPostEvent(self, ChooseFileEvent(default, bucket, f, size, dir)) | wxPostEvent(self.frame, ChooseFileEvent(default, bucket, f, size, dir)) | def chooseFile(self, default, size, saveas, dir): if self.flag.isSet(): return '' f = Event() bucket = [None] wxPostEvent(self, ChooseFileEvent(default, bucket, f, size, dir)) f.wait() return bucket[0] |
dl = wxDirDialog(self, 'Choose a directory to save to, pick a partial download to resume', join(getcwd(), event.default)) | dl = wxDirDialog(self.frame, 'Choose a directory to save to, pick a partial download to resume', join(getcwd(), event.default), style = wxDD_DEFAULT_STYLE | wxDD_NEW_DIR_BUTTON) | def onChooseFile(self, event): if self.flag.isSet(): return if event.dir: dl = wxDirDialog(self, 'Choose a directory to save to, pick a partial download to resume', join(getcwd(), event.default)) else: dl = wxFileDialog(self, 'Choose file to save as, pick a partial download to resume', '', event.default, '*.*', wxSAVE)... |
dl = wxFileDialog(self, 'Choose file to save as, pick a partial download to resume', '', event.default, '*.*', wxSAVE) | dl = wxFileDialog(self.frame, 'Choose file to save as, pick a partial download to resume', '', event.default, '*.*', wxSAVE) | def onChooseFile(self, event): if self.flag.isSet(): return if event.dir: dl = wxDirDialog(self, 'Choose a directory to save to, pick a partial download to resume', join(getcwd(), event.default)) else: dl = wxFileDialog(self, 'Choose file to save as, pick a partial download to resume', '', event.default, '*.*', wxSAVE)... |
self.Show(true) | self.frame.Show(true) | def onChooseFile(self, event): if self.flag.isSet(): return if event.dir: dl = wxDirDialog(self, 'Choose a directory to save to, pick a partial download to resume', join(getcwd(), event.default)) else: dl = wxFileDialog(self, 'Choose file to save as, pick a partial download to resume', '', event.default, '*.*', wxSAVE)... |
self.Destroy() | self.frame.Destroy() | def done(self, event): self.flag.set() self.Destroy() |
def __init__(self, x, d): self.d = d | def __init__(self, x, params): self.params = params | def __init__(self, x, d): self.d = d wxApp.__init__(self, x) |
self.SetTopWindow(self.d) | doneflag = Event() d = DownloadInfoFrame(doneflag) self.SetTopWindow(d.frame) thread = Thread(target = next, args = [self.params, d, doneflag]) thread.setDaemon(false) thread.start() | def OnInit(self): self.SetTopWindow(self.d) return 1 |
doneflag = Event() d = DownloadInfoFrame(doneflag) app = btWxApp(0, d) thread = Thread(target = next, args = [params, d, doneflag]) thread.setDaemon(false) thread.start() | app = btWxApp(0, params) | def run(params): doneflag = Event() d = DownloadInfoFrame(doneflag) app = btWxApp(0, d) thread = Thread(target = next, args = [params, d, doneflag]) thread.setDaemon(false) thread.start() app.MainLoop() |
print formatDefinitions(configDefinitions, 80) | print formatDefinitions(defaults, 80) | def store_downloads(s = s, d = d): while true: sleep(600) try: s.lock.acquire() h = open(d, 'wb') h.write(bencode(s.downloads)) h.flush() h.close() finally: s.lock.release() |
myid = myid + ('-' * (8 - len(myid))) + b2a_hex(sha(repr(time()) + ' ' + str(getpid())).digest()[-8:]) | myid = myid + ('-' * (8 - len(myid))) + b2a_hex(sha(repr(time()) + ' ' + str(getpid())).digest()[-6:]) | def make(f, forcedir = False): if not forcedir: f = path.split(f)[0] if f != '' and not path.exists(f): makedirs(f) |
t = split(i)[-1] if t not in ignore and t[0] != '.': make_meta_file(i, url, flag = flag, progress = callback, progress_percent=0, piece_len_exp = piece_len_pow2) | make_meta_file(i, url, flag = flag, progress = callback, progress_percent=0, piece_len_exp = piece_len_pow2) | def callback(x, subtotal = subtotal, total = total, vc = vc): subtotal[0] += x vc(float(subtotal[0]) / total) |
b = becache2 | b = self.becache2 | def get(self, connection, path, headers): try: (scheme, netloc, path, pars, query, fragment) = urlparse(path) if self.uq_broken == 1: path = path.replace('+',' ') query = query.replace('+',' ') path = unquote(path)[1:] params = {} for s in query.split('&'): if s != '': i = s.index('=') params[unquote(s[:i])] = unquote(... |
b = becache1 | b = self.becache1 | def get(self, connection, path, headers): try: (scheme, netloc, path, pars, query, fragment) = urlparse(path) if self.uq_broken == 1: path = path.replace('+',' ') query = query.replace('+',' ') path = unquote(path)[1:] params = {} for s in query.split('&'): if s != '': i = s.index('=') params[unquote(s[:i])] = unquote(... |
def dummy(*stuff, **dictstuff): | def dummy(*args, **kwargs): | def dummy(*stuff, **dictstuff): pass |
if file[-len(ext):] == ext and exists(file[:-len(ext)]): Thread(target = runsingle, params = [join(d, file[:-len(ext)])]).start() | if file[-len(ext):] == ext and file[:-len(ext)] in files: Thread(target = runsingle, args = [join(d, file), params]).start() | def runmany(d, params): files = listdir(d) for file in files: if file[-len(ext):] == ext and exists(file[:-len(ext)]): Thread(target = runsingle, params = [join(d, file[:-len(ext)])]).start() |
def choose(self, default, size, saveas, dir, file = file): return file | def choose(default, size, saveas, dir, file = file): return file[:-len(ext)] | def choose(self, default, size, saveas, dir, file = file): return file |
if self.allowed != None: s.write('<table summary="files">\n' \ | if self.allowed != None and self.show_names: s.write('<table summary="files" border=1>\n' \ | def get(self, connection, path, headers): try: (scheme, netloc, path, pars, query, fragment) = urlparse(path) path = unquote(path)[1:] params = {} for s in query.split('&'): if s != '': i = s.index('=') params[unquote(s[:i])] = unquote(s[i+1:]) except ValueError, e: return (400, 'Bad Request', {'Content-Type': 'text/pl... |
if self.allowed != None and self.show_names and self.allowed.has_key(name): s.write('<tr><td><code>%s</code></td><td><code>%s</code></td><td align="right"><code>%i</code></td><td align="right"><code>%i</code></td></tr>\n' \ % (b2a_hex(name), self.allowed[name], c, d)) elif self.allowed == None: | if self.allowed != None and self.show_names: if self.allowed.has_key(name): s.write('<tr><td><code>%s</code></td><td><code>%s</code></td><td align="right"><code>%i</code></td><td align="right"><code>%i</code></td></tr>\n' \ % (b2a_hex(name), self.allowed[name], c, d)) else: | def get(self, connection, path, headers): try: (scheme, netloc, path, pars, query, fragment) = urlparse(path) path = unquote(path)[1:] params = {} for s in query.split('&'): if s != '': i = s.index('=') params[unquote(s[:i])] = unquote(s[i+1:]) except ValueError, e: return (400, 'Bad Request', {'Content-Type': 'text/pl... |
self.downTotalText.SetLabel('%.1f MiB/s' % (downTotal)) | self.downTotalText.SetLabel('%.1f M' % (downTotal)) | def onUpdateStatus(self, dict): if self.last_update_time + 0.01 > time() and dict.get('fractionDone') not in [0.0, 1.0] and dict.get('activity') is None: return activity = dict.get('activity') fractionDone = dict.get('fractionDone') timeEst = dict.get('timeEst') downRate = dict.get('downRate') upRate = dict.get('upRate... |
self.upTotalText.SetLabel('%.1f MiB/s' % (upTotal)) | self.upTotalText.SetLabel('%.1f M' % (upTotal)) | def onUpdateStatus(self, dict): if self.last_update_time + 0.01 > time() and dict.get('fractionDone') not in [0.0, 1.0] and dict.get('activity') is None: return activity = dict.get('activity') fractionDone = dict.get('fractionDone') timeEst = dict.get('timeEst') downRate = dict.get('downRate') upRate = dict.get('upRate... |
def failed(self) | def failed(self): | def failed(self) self.fin = true wxPostEvent(self, FailEvent()) |
def __init__(self, doneflag, timeout_check_interval, timeout, noisy = true, errorfunc None): | def __init__(self, doneflag, timeout_check_interval, timeout, noisy = true, errorfunc = None): | def __init__(self, doneflag, timeout_check_interval, timeout, noisy = true, errorfunc None): self.timeout_check_interval = timeout_check_interval self.timeout = timeout self.poll = poll() # {socket: SingleSocket} self.single_sockets = {} self.dead_from_write = [] self.doneflag = doneflag self.noisy = noisy self.errorfu... |
if self.last_update_time + 0.1 < time() or d.get('fractionDone') in [0.0, 1.0] or d.has_key('activity'): | if (self.last_update_time + 0.1 < time() and not self.showing_error) or d.get('fractionDone') in (0.0, 1.0) or d.has_key('activity'): | def updateStatus(self, d): if self.last_update_time + 0.1 < time() or d.get('fractionDone') in [0.0, 1.0] or d.has_key('activity'): self.invokeLater(self.onUpdateStatus, [d]) |
return str(long((n / (2 ** 10)) * 10) / 10.0) | return str(long((float(n) / (2 ** 10)) * 10) / 10.0) | def kify(n): return str(long((n / (2 ** 10)) * 10) / 10.0) |
return str(long((n / (2 ** 20)) * 10) / 10.0) | return str(long((float(n) / (2 ** 20)) * 10) / 10.0) | def mbfy(n): return str(long((n / (2 ** 20)) * 10) / 10.0) |
try: if d is not self: d.active_requests.remove((index, begin, len(piece))) | if d is not self and d.interested: if d.choked: d.fix_download_endgame() else: try: d.active_requests.remove((index, begin, len(piece))) except ValueError: continue | def got_piece(self, index, begin, piece): try: self.active_requests.remove((index, begin, len(piece))) except ValueError: return False if self.downloader.storage.is_endgame(): self.downloader.all_requests.remove((index, begin, len(piece))) self.last = time() self.measure.update_rate(len(piece)) self.downloader.measuref... |
except ValueError: pass | def got_piece(self, index, begin, piece): try: self.active_requests.remove((index, begin, len(piece))) except ValueError: return False if self.downloader.storage.is_endgame(): self.downloader.all_requests.remove((index, begin, len(piece))) self.last = time() self.measure.update_rate(len(piece)) self.downloader.measuref... | |
self.resultfunc(false) | self.resultfunc(false, self.downloadid, self.peerid, self.ip, self.port) | def connection_lost(self, connection): if not self.closed: self.closed = true self.resultfunc(false) |
for i in [len(hashes) - 1] + range(len(hashes) - 1): | for i in xrange(len(hashes) - 1, -1, -1): | def markgot(piece, pos, self = self, check_hashes = check_hashes): self.places[piece] = pos self.have[piece] = true self.amount_left -= self._piecelen(piece) self.waschecked[piece] = check_hashes |
markgot(targets[sh].pop(), i) | markgot(targets[s].pop(), i) | def markgot(piece, pos, self = self, check_hashes = check_hashes): self.places[piece] = pos self.have[piece] = true self.amount_left -= self._piecelen(piece) self.waschecked[piece] = check_hashes |
self.holes.sort() | def markgot(piece, pos, self = self, check_hashes = check_hashes): self.places[piece] = pos self.have[piece] = true self.amount_left -= self._piecelen(piece) self.waschecked[piece] = check_hashes |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.