rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
self.delAllItems() self.clearDictionaries()
def on_buttonGetNextEvent_clicked(self, event): self.delAllItems() self.clearDictionaries() # check if event list is empty and force an update if this is the case if not hasattr(self, "seishubEventList"): self.updateEventListFromSeishub(self.streams[0][0].stats.starttime, self.streams[0][0].stats.endtime) # iterate eve...
t = self.t[self.axs.index(ev.inaxes)]
def __mpl_keyPressEvent(self, ev): if self.widgets.qToolButton_showMap.isChecked(): return keys = self.keys phase_type = str(self.widgets.qComboBox_phaseType.currentText()) dict = self.dicts[self.stPt] st = self.streams[self.stPt] ####################################################################### # Start of key e...
pickSample = ev.xdata * samp_rate
pickSample = (ev.xdata - t[0]) * samp_rate
def __mpl_keyPressEvent(self, ev): if self.widgets.qToolButton_showMap.isChecked(): return keys = self.keys phase_type = str(self.widgets.qComboBox_phaseType.currentText()) dict = self.dicts[self.stPt] st = self.streams[self.stPt] ####################################################################### # Start of key e...
pickSample = pickSample / samp_rate
def __mpl_keyPressEvent(self, ev): if self.widgets.qToolButton_showMap.isChecked(): return keys = self.keys phase_type = str(self.widgets.qComboBox_phaseType.currentText()) dict = self.dicts[self.stPt] st = self.streams[self.stPt] ####################################################################### # Start of key e...
xpos = pickSample * samp_rate
xpos = pickSample pickSample = t[pickSample]
def __mpl_keyPressEvent(self, ev): if self.widgets.qToolButton_showMap.isChecked(): return keys = self.keys phase_type = str(self.widgets.qComboBox_phaseType.currentText()) dict = self.dicts[self.stPt] st = self.streams[self.stPt] ####################################################################### # Start of key e...
print "=" * 70 print sta
def __init__(self, streams = None, options = None): self.streams = streams self.options = options #Define some flags, dictionaries and plotting options self.flagFilt=False #False:no filter True:filter self.flagFiltTyp=0 #0: bandpass 1: bandstop 2:lowpass 3: highpass self.dictFiltTyp={'Bandpass':0, 'Bandstop':1, 'Lowpa...
lon, lat, ele = getCoord(self.server['BaseUrl'], net, sta)
lon, lat, ele = getCoord(self.server['BaseUrl'], self.server['User'], self.server['Password'], self.server['Timeout'], net, sta)
def __init__(self, streams = None, options = None): self.streams = streams self.options = options #Define some flags, dictionaries and plotting options self.flagFilt=False #False:no filter True:filter self.flagFiltTyp=0 #0: bandpass 1: bandstop 2:lowpass 3: highpass self.dictFiltTyp={'Bandpass':0, 'Bandstop':1, 'Lowpa...
if newLeader and len(self.current) == 1: from gungame51.core.players.shortcuts import Player
if not newLeader: return from gungame51.core.players.shortcuts import Player if len(self.current) == 1: leader = self.current[0]
def disconnected_leader(self, userid): """Handles the disconnection of players.""" userid = int(userid)
saytext2(' {'player': es.getplayername(userid),
saytext2(' {'player': es.getplayername(leader), 'level': self.leaderlevel}, False) else: msg(' {'players': ", ".join( [es.getplayername(x) for x in self.current]),
def disconnected_leader(self, userid): """Handles the disconnection of players.""" userid = int(userid)
if es.exists('userid', userid): steamid = uniqueid(str(userid), 1) else: steamid = None
steamid = uniqueid(str(userid), 1)
def __getitem__(self, userid): ''' When we get an item in the dictionary BasePlayer is instantiated if it hasn't been already. ''' userid = int(userid)
if timeleft == 1: hudhint(' 'voteInfo': None, 'votes': votes, 'totalVotes': len(voteUserids)}) return
voteInfo = "" mapsAdded = 0 for map in sorted(mapVoteOptions.items(), key=itemgetter(1), reverse=True): voteInfo += langstring('MapVotes', tokens={'map': map[0], 'votes': len(map[1])}) mapsAdded += 1 if mapsAdded >= 3: break
def voteCountDown(): ggRepeat = repeat.find('gg_map_vote') if not ggRepeat: return timeleft = ggRepeat['remaining'] # Stop the vote ? if timeleft == 0: voteEnd() return votes = len(reduce(lambda a, b: a + b, mapVoteOptions.values())) if timeleft == 1: hudhint('#human', 'Countdown_Singular', {'time': int(gg_map_vote...
hudhint(' 'voteInfo': None, 'votes': votes, 'totalVotes': len(voteUserids)})
for userid in getUseridList(' Player(userid).playsound('countDownBeep') if timeleft == 1: hudhint(' 'voteInfo': voteInfo, 'votes': votes, 'totalVotes': len(voteUserids)}) return hudhint(' 'voteInfo': voteInfo, 'votes': votes, 'totalVotes': len(voteUserids)})
def voteCountDown(): ggRepeat = repeat.find('gg_map_vote') if not ggRepeat: return timeleft = ggRepeat['remaining'] # Stop the vote ? if timeleft == 0: voteEnd() return votes = len(reduce(lambda a, b: a + b, mapVoteOptions.values())) if timeleft == 1: hudhint('#human', 'Countdown_Singular', {'time': int(gg_map_vote...
es.msg("give_weapon")
def give_weapon(self): ''' Gives a player their current levels weapon. ''' es.msg("give_weapon") error = None # Make sure player is on a team if es.getplayerteam(self.userid) < 2: error = ('Unable to give player weapon (%s):' % self.userid + ' is not on a team.')
spe.call('GiveNamedItem', spe.getPlayer(self.userid), 'weapon_%s' % self.weapon, 0)
spe.giveNamedItem(self.userid, "weapon_hegrenade")
def give_weapon(self): ''' Gives a player their current levels weapon. ''' es.msg("give_weapon") error = None # Make sure player is on a team if es.getplayerteam(self.userid) < 2: error = ('Unable to give player weapon (%s):' % self.userid + ' is not on a team.')
if spe.ownsWeapon( self.userid, 'weapon_%s' % self.weapon ):
if spe.ownsWeapon(self.userid, "weapon_%s" % self.weapon):
def give_weapon(self): ''' Gives a player their current levels weapon. ''' es.msg("give_weapon") error = None # Make sure player is on a team if es.getplayerteam(self.userid) < 2: error = ('Unable to give player weapon (%s):' % self.userid + ' is not on a team.')
pPlayer = getPlayer(self.userid) pWeapon = spe.getWeaponFromSlot( self.userid, 0 ) sWeapon = spe.getWeaponFromSlot( self.userid, 1 ) weapToStrip = None if 'weapon_%s' % self.weapon in list_sWeapons and sWeapon: weapToStrip = sWeapon elif 'weapon_%s' % self.weapon in list_pWeapons and pWeapon: weapToStrip = pWeapon ...
playerWeapons = spe.getWeaponDict(self.userid) if playerWeapons: pWeapon = set(playerWeapons.keys()).intersection(list_pWeapons) sWeapon = set(playerWeapons.keys()).intersection(list_sWeapons) weapToStrip = None if 'weapon_%s' % self.weapon in list_sWeapons and sWeapon: weapToStrip = sWeapon.pop() elif 'weap...
def give_weapon(self): ''' Gives a player their current levels weapon. ''' es.msg("give_weapon") error = None # Make sure player is on a team if es.getplayerteam(self.userid) < 2: error = ('Unable to give player weapon (%s):' % self.userid + ' is not on a team.')
spe.call('GiveNamedItem', spe.getPlayer(self.userid), 'weapon_%s' % self.weapon, 0) if not spe.ownsWeapon( self.userid, 'weapon_knife' ): spe.call('GiveNamedItem', spe.getPlayer(self.userid), 'weapon_knife', 0)
spe.giveNamedItem(self.userid, "weapon_%s" % self.weapon)
def give_weapon(self): ''' Gives a player their current levels weapon. ''' es.msg("give_weapon") error = None # Make sure player is on a team if es.getplayerteam(self.userid) < 2: error = ('Unable to give player weapon (%s):' % self.userid + ' is not on a team.')
es.msg("give")
def give(self, weapon, useWeapon=False, strip=False):
pPlayer = getPlayer(self.userid) sWeapon = pPlayer.secondary pWeapon = pPlayer.primary if weapon in [sWeapon, pWeapon]:
if spe.ownsWeapon(self.userid, weapon):
def give(self, weapon, useWeapon=False, strip=False):
stripWeapon = None if weapon in list_pWeapons and pWeapon: stripWeapon = pWeapon elif weapon in list_sWeapons and sWeapon: stripWeapon = sWeapon if stripWeapon: spe.removeEntityByIndex( pPlayer.getWeaponIndex(stripWeapon) )
playerWeapons = spe.getWeaponNameList(self.userid) if playerWeapons: pWeapon = set(playerWeapons).intersection(list_pWeapons) sWeapon = set(playerWeapons).intersection(list_sWeapons) stripWeapon = None if weapon in list_pWeapons and pWeapon: stripWeapon = pWeapon.pop() elif weapon in list_sWeapons and sWeapon:...
def give(self, weapon, useWeapon=False, strip=False):
cmd = 'es_xgive %s %s;' % (self.userid, weapon)
spe.giveNamedItem(self.userid, weapon)
def give(self, weapon, useWeapon=False, strip=False):
cmd += ' es_xsexec %s "use %s"' % (self.userid, weapon) es.server.queuecmd(cmd)
es.server.queuecmd('es_xsexec %s "use %s"' % (self.userid, weapon))
def give(self, weapon, useWeapon=False, strip=False):
pPlayer = getPlayer(self.userid) for weapon in pPlayer.getWeaponList():
pWeapons = spe.getWeaponDict(self.userid) if not pWeapons: return for weapon in pWeapons:
def strip(self, levelStrip=False, exceptions=[]): ''' * Strips/removes all weapons from the player minus the knife and their current levels weapon.
spe.removeEntityByInstance(spe.ownsWeapon(self.userid, weapon))
spe.removeEntityByInstance(pWeapons[weapon]["instance"])
def strip(self, levelStrip=False, exceptions=[]): ''' * Strips/removes all weapons from the player minus the knife and their current levels weapon.
list_lastMaps.append(eventscripts_currentmap)
list_lastMaps.append(str(eventscripts_currentmap))
def load(): # Check to see if GunGame's voting system is to be used if int(gg_map_vote) == 1: # Create player vote command registerPlayerCmd() # Store the current map in the list of recently played maps if int(gg_map_vote_dont_show_last_maps): list_lastMaps.append(eventscripts_currentmap) # Check file location if us...
maps = [x.strip('.bsp') for x in files if splitext(x)[1] == '.bsp']
maps = [x[:-4] for x in files if splitext(x)[1] == '.bsp']
def getMapList(): # Check to make sure the value of "gg_map_vote" is 1-4 if int(gg_map_vote_list_source) not in range(1, 5): raise ValueError('"gg_map_vote_list_source" must be 1-4: current ' + 'value "%s"' % int(gg_map_vote)) # Check the maps directory for a list of all maps (option 4) if int(gg_map_vote_list_source)...
config.text(' Mani: gg_map_vote_command "ma_voterandom end 4"') config.text(' BeetlesMod: gg_map_vote_command "admin_votemaps"') config.text(' SourceMod: gg_map_vote_command "sm_map_vote"')
config.text(' Mani: gg_map_vote_command "ma_voterandom end 4"') config.text(' BeetlesMod: gg_map_vote_command "admin_votemaps"') config.text(' SourceMod: gg_map_vote_command "sm_mapvote" (with ' + 'mapchooser.smx enabled)')
def load(): generate_header(config) # gg_map_vote config.text('='*76) config.text('>> GUNGAME MAP VOTE') config.text('='*76) config.text('Description:') config.text(' Allows players to vote for the next map.') config.text('Notes:') config.text(' * This does not require any additional plug-ins.') config.text('Optio...
config.text(' The configureable message is available in' + '"gg_stats_logging.txt".')
config.text(' The configureable message is available in ' + '"gg_welcome_msg.txt".')
def load(): generate_header(config) # gg_welcome_msg config.text('') config.text('='*76) config.text('>> GUNGAME WELCOME MESSAGE') config.text('='*76) config.text('Description:') config.text(' A menu displayed to newly connected players displaying ' + 'server and addon') config.text('information.') config.text(' P...
level = ggPlayer.level totalLevels = get_total_levels() leaderLevel = get_leader_level() text = langstring('LevelInfo_CurrentLevel', tokens={ 'level': level, 'total': totalLevels}) text += langstring('LevelInfo_CurrentWeapon', tokens={ 'weapon': ggPlayer.weapon}) text += langstring('LevelInfo_RequiredKills', tokens=...
send_level_info_hudhint(ggPlayer)
def player_spawn(event_var): # Check for priority addons if PriorityAddon(): return userid = int(event_var['userid']) pPlayer = getPlayer(userid) # Is a spectator or dead ? if pPlayer.isobserver or pPlayer.isdead: return ggPlayer = Player(userid) # Retrieve the defuser setting if int(gg_player_defuser): gg_map_obj ...
ggPlayer = Player(userid) ggPlayer.hudhint('LevelInfo_CurrentLevel', {'level': ggPlayer.level, 'total': get_total_levels()})
send_level_info_hudhint(Player(userid))
def gg_levelup(event_var): # Check for priority addons if PriorityAddon(): return userid = int(event_var['userid']) # Is a bot? if es.isbot(userid): return ggPlayer = Player(userid) # Send hudhint (level information) ggPlayer.hudhint('LevelInfo_CurrentLevel', {'level': ggPlayer.level, 'total': get_total_levels()})
currentOrder.set_multikill_override(int(gg_multikill_override))
if int(gg_multikill_override): currentOrder.set_multikill_override(int(gg_multikill_override))
def server_cvar(event_var): cvarName = event_var['cvarname'] if cvarName in ['gg_weapon_order_file', 'gg_weapon_order_sort_type', 'gg_multikill_override']: # Get weapon order file # Set this as the weapon order and set the weapon order type currentOrder = set_weapon_order(str(gg_weapon_order_file), str(gg_weapon_order...
self.strip_weapons(get_level_weapon(self.level - 1))
if self.level > 1: self.strip_weapons(get_level_weapon(self.level - 1)) else: self.strip()
def give_weapon(self): ''' Gives a player their current levels weapon. ''' error = None # Make sure player is on a team if es.getplayerteam(self.userid) < 2: error = ('Unable to give player weapon (%s):' % self.userid + ' is not on a team.')
if es.exists(userid):
if es.exists("userid", userid):
def disconnected_leader(self, userid): """Handles the disconnection of players.""" userid = int(userid)
knifeData = None nadeData = None
knifeData = [] nadeData = []
def __set_weapon_order_type(self, type): # ===================================================================== # RANDOM WEAPON ORDER # ===================================================================== if type == '#random': # Get weapons weapons = self.order.values()
knifeData = weapon
knifeData.append(weapon)
def __set_weapon_order_type(self, type): # ===================================================================== # RANDOM WEAPON ORDER # ===================================================================== if type == '#random': # Get weapons weapons = self.order.values()
nadeData = weapon
nadeData.append(weapon)
def __set_weapon_order_type(self, type): # ===================================================================== # RANDOM WEAPON ORDER # ===================================================================== if type == '#random': # Get weapons weapons = self.order.values()
if nadeData != None: self.order[len(self.order)+1] = nadeData if knifeData != None: self.order[len(self.order)+1] = knifeData
for weapon in nadeData: self.order[len(self.order)+1] = weapon for weapon in knifeData: self.order[len(self.order)+1] = weapon
def __set_weapon_order_type(self, type): # ===================================================================== # RANDOM WEAPON ORDER # ===================================================================== if type == '#random': # Get weapons weapons = self.order.values()
config.text(' 0 = (Enabled) Allow attackers to level up if the victim ' +
config.text(' 1 = (Enabled) Allow attackers to level up if the victim ' +
def load(): generate_header(config) # ========================================================================= # GG_KNIFE_PRO CVARS # ========================================================================= # Knife Pro config.text('='*76) config.text('>> KNIFE PRO') config.text('='*76) config.text('Description:') co...
spe.giveNamedItem(self.userid, "weapon_hegrenade")
given_weapon = spe.giveNamedItem(self.userid, "weapon_hegrenade")
def give_weapon(self): ''' Gives a player their current levels weapon. ''' error = None # Make sure player is on a team if es.getplayerteam(self.userid) < 2: error = ('Unable to give player weapon (%s):' % self.userid + ' is not on a team.')
spe.giveNamedItem(self.userid, "weapon_%s" % self.weapon)
given_weapon = spe.giveNamedItem(self.userid, "weapon_%s" % self.weapon) weapon_check = spe.ownsWeapon(self.userid, "weapon_%s" % self.weapon) if weapon_check != given_weapon: spe.removeEntityByInstance(given_weapon) if not weapon_check: self.give_weapon() return
def give_weapon(self): ''' Gives a player their current levels weapon. ''' error = None # Make sure player is on a team if es.getplayerteam(self.userid) < 2: error = ('Unable to give player weapon (%s):' % self.userid + ' is not on a team.')
es.server.cmd('es_xgive %s game_end;es_xfire %s game_end EndGame' % (userid, userid))
es.server.queuecmd("es_xgive %s game_end" % userid) es.server.queuecmd("es_xfire %s game_end EndGame" % userid)
def gg_win(event_var): # Get player info userid = int(event_var['winner']) index = getPlayer(userid).index playerName = es.getplayername(userid) if not es.isbot(userid): Player(userid).wins += 1 if event_var['round'] == '0': # ==================================================== # MAP WIN # ===========================...
if get_leader_level() <= (get_total_levels() - int(gg_map_vote_trigger)):
if get_leader_level() < (get_total_levels() - int(gg_map_vote_trigger)):
def gg_levelup(event_var): # Vote has allready been started? if voteHasStarted: return # Start vote ? if get_leader_level() <= (get_total_levels() - int(gg_map_vote_trigger)): return # Change global so we dont fire the vote twice global voteHasStarted voteHasStarted = True # Use 3rd party voting system ? if int(gg_m...
pWeapon = spe.getWeaponFromSlot( self.userid, 2 )
pWeapon = spe.getWeaponFromSlot( self.userid, 0 )
def give_weapon(self): ''' Gives a player their current levels weapon. ''' error = None # Make sure player is on a team if es.getplayerteam(self.userid) < 2: error = ('Unable to give player weapon (%s):' % self.userid + ' is not on a team.')
es.msg("give")
def give(self, weapon, useWeapon=False, strip=False):
return
return 1
def joinclass_filter(userid, args): # If the command is not joinclass, stop here if len(args) and args[0].lower() != 'joinclass': return 1 steamid = es.getplayersteamid(userid) # If gg_elimination_spawn isn't loaded, stop here if not int(gg_elimination_spawn): return # If the player didn't join an active team, stop ...
if name in ['currentorder', '__weaponorders__', 'gungameorder']:
if item in ['currentorder', '__weaponorders__', 'gungameorder']:
def __getitem__(self, item): if name in ['currentorder', '__weaponorders__', 'gungameorder']: return object.__getattr__(self, item) else: if not self.currentorder: raise AttributeError('There is no weapon order set! ' + 'Use set_order(order_name) first!')
def unload(self, order):
def unload(self, name):
def unload(self, order): ''' Unload a weapon order by name. Note: This removes the weapon order from stored memory. It is not intended to be used ''' # Delete the weapon order instance from our dictionary del self.__weaponorders__[name]
theWeapon = spe.ownsWeapon( self.userid, 'weapon_%s' % self.weapon )
def give_weapon(self): ''' Gives a player their current levels weapon. ''' error = None # Make sure player is on a team if es.getplayerteam(self.userid) < 2: error = ('Unable to give player weapon (%s):' % self.userid + ' is not on a team.')
if theWeapon != None:
if spe.ownsWeapon( self.userid, 'weapon_%s' % self.weapon ):
def give_weapon(self): ''' Gives a player their current levels weapon. ''' error = None # Make sure player is on a team if es.getplayerteam(self.userid) < 2: error = ('Unable to give player weapon (%s):' % self.userid + ' is not on a team.')
if name not in PriorityAddon(): priority_addons_added.append(name) PriorityAddon().append(name)
priority_addons_added.append(name) PriorityAddon().append(name)
def add_priority_addon(name): if name not in PriorityAddon(): priority_addons_added.append(name) PriorityAddon().append(name)
ggLevelMenu.submenu(9, 'ggLeadersMenu')
ggLevelMenu.select(9, send_leader_menu)
def load(): # Delete the popup if it exists if popuplib.exists('ggLevelMenu'): popuplib.unsendname('ggLevelMenu', getUseridList('#human')) popuplib.delete('ggLevelMenu') # Let's create the "gungameLevelMenu" popup ggLevelMenu = popuplib.create('ggLevelMenu') # Create empty instance of the popup ggLevelMenu.addline('-...
popuplib.send('ggLevelMenu', userid)
if len(args): searchInput = str(args) checkUserid = es.getuserid(searchInput) if not checkUserid: msg(userid, 'LevelInfo_PlayerSearchFailed', {'player': searchInput}) return ggPlayer = Player(checkUserid) saytext2(userid, getPlayer(checkUserid).index, 'LevelInfo_PlayerSearch', {'player': ggPlayer.name, 'level': ...
def level_menu_cmd(userid, args): # Make sure player exists if not es.exists('userid', userid): return # Send menu popuplib.send('ggLevelMenu', userid)
config.text(' ../cfg/gungame51/gg_convert/')
config.text(' ../cfg/gungame51/converter/')
def load(): generate_header(config) # gg_convert config.text('') config.text('='*76) config.text('>> CONVERT') config.text('='*76) config.text('Description:') config.text(' A tool used to convert gungame 3, 4 and 5 (prior to 5.1' + ') winner databases') config.text('& spawnpoint files.') config.text('Instructions:')...
if currentWeapon != item: return
def item_pickup(event_var): # Get variables item = event_var['item'] userid = int(event_var['userid']) # Is a weapon? if ("weapon_%s" % item) not in list_weaponNameList: return # Client exists? if not es.exists('userid', userid): return # Don't strip the knife if item == "knife": return # Check to see if the weapon...
if weapon == 'hegrenade':
if currentWeapon == 'hegrenade':
def item_pickup(event_var): # Get variables item = event_var['item'] userid = int(event_var['userid']) # Is a weapon? if ("weapon_%s" % item) not in list_weaponNameList: return # Client exists? if not es.exists('userid', userid): return # Don't strip the knife if item == "knife": return # Check to see if the weapon...
es.server.queuecmd('es_xsexec %s "use weapon_%s"' % (userid, weapon))
es.server.queuecmd('es_xsexec %s "use weapon_%s"' % (userid, currentWeapon)) gamethread.delayed(0, es.setplayerprop, (userid, 'CBaseCombatCharacter.bcc_localdata.m_flNextAttack', 0))
def item_pickup(event_var): # Get variables item = event_var['item'] userid = int(event_var['userid']) # Is a weapon? if ("weapon_%s" % item) not in list_weaponNameList: return # Client exists? if not es.exists('userid', userid): return # Don't strip the knife if item == "knife": return # Check to see if the weapon...
spe.removeEntityByInstance(spe.ownsWeapon(userid, "weapon_%s" % item))
theWeapon = spe.ownsWeapon(userid, "weapon_%s" % item) if theWeapon: spe.removeEntityByInstance(theWeapon)
def remove_weapon(userid, item): # Remove weapon spe.removeEntityByInstance(spe.ownsWeapon(userid, "weapon_%s" % item))
def emitsound(self, sound, volume=1.0, attenuation=0.0):
def emitsound(self, sound, volume=1.0, attenuation=1.0):
def emitsound(self, sound, volume=1.0, attenuation=0.0): ''' Emits the declared sound from the player. ''' # Format the sound sound = self._format_sound(sound)
for map in sorted(mapVoteOptions.items(), key=itemgetter(1), reverse=True):
sortItems = [] for map in mapVoteOptions.items(): sortItems.append((map[0], len(map[1]))) for map in sorted(sortItems, key=itemgetter(1), reverse=True):
def voteCountDown(): ggRepeat = repeat.find('gg_map_vote') if not ggRepeat: return timeleft = ggRepeat['remaining'] # Stop the vote ? if timeleft == 0: voteEnd() return votes = len(reduce(lambda a, b: a + b, mapVoteOptions.values())) voteInfo = "" mapsAdded = 0 # For the map with the most votes to the least for map...
'votes': len(map[1])})
'votes': map[1]})
def voteCountDown(): ggRepeat = repeat.find('gg_map_vote') if not ggRepeat: return timeleft = ggRepeat['remaining'] # Stop the vote ? if timeleft == 0: voteEnd() return votes = len(reduce(lambda a, b: a + b, mapVoteOptions.values())) voteInfo = "" mapsAdded = 0 # For the map with the most votes to the least for map...
ggAttacker = Player(attacker)
def player_death(event_var): # Check to see if the round is active if not roundInfo.active: return # Get userid and attacker userids userid = int(event_var['userid']) attacker = int(event_var['attacker']) ggVictim = Player(userid) ggAttacker = Player(attacker) # Was suicide? if userid == attacker or attacker == 0: g...
print list_configs
def get_config_list(type=None): ''' Retrieves a list of cfglib configs of the following types: * main (the primary GunGame configs) * included (included addon configs) * custom (custom addon configs) Note: If no argument is provided, all possible configs will be returned in the list. ''' # Initialize a blank list to s...
def _seed(self, cur_bbox, level, progess_str='', progress=1.0, all_subtiles=False):
def _seed(self, cur_bbox, level, progess_str='', progress=1.0, all_subtiles=False, already_seeded=set()):
def _seed(self, cur_bbox, level, progess_str='', progress=1.0, all_subtiles=False): """ :param cur_bbox: the bbox to seed in this call :param level: the current seed level :param all_subtiles: seed all subtiles and do not check for intersections with bbox/geom """ bbox_, tiles_, subtiles = self.grid.get_affected_level_...
progress = progress / len(sub_seeds)
def _seed(self, cur_bbox, level, progess_str='', progress=1.0, all_subtiles=False): """ :param cur_bbox: the bbox to seed in this call :param level: the current seed level :param all_subtiles: seed all subtiles and do not check for intersections with bbox/geom """ bbox_, tiles_, subtiles = self.grid.get_affected_level_...
self._seed(sub_bbox, level+1, cur_progess_str, all_subtiles=all_subtiles, progress=progress)
seeded_in_next_level.update( self._seed(sub_bbox, level+1, cur_progess_str, already_seeded=seeded_in_next_level, all_subtiles=all_subtiles, progress=progress))
def _seed(self, cur_bbox, level, progess_str='', progress=1.0, all_subtiles=False): """ :param cur_bbox: the bbox to seed in this call :param level: the current seed level :param all_subtiles: seed all subtiles and do not check for intersections with bbox/geom """ bbox_, tiles_, subtiles = self.grid.get_affected_level_...
self.count += 1
def _seed(self, cur_bbox, level, progess_str='', progress=1.0, all_subtiles=False): """ :param cur_bbox: the bbox to seed in this call :param level: the current seed level :param all_subtiles: seed all subtiles and do not check for intersections with bbox/geom """ bbox_, tiles_, subtiles = self.grid.get_affected_level_...
resp.headers['Location'] = req.script_url + 'demo/'
resp.headers['Location'] = req.script_url.rstrip('/') + '/demo/'
def handle(self, req): if req.path.startswith('/demo/static/'): filename = req.path.lstrip('/') static_file = os.path.join(os.path.dirname(__file__), 'templates', filename) type, encoding = mimetypes.guess_type(filename) return Response(open(static_file, 'rb'), content_type=type)
<!DOCTYPE ServiceExceptionReport SYSTEM "http://schemas.opengis.net/wms/1.1.1/exception_1_1_0.dtd">
<!DOCTYPE ServiceExceptionReport SYSTEM "http://schemas.opengis.net/wms/1.1.0/exception_1_1_0.dtd">
def test_render_w_code(self): req = self.mock(WMSMapRequest) req_ex = RequestError('the exception message', code='InvalidFormat', request=req) ex_handler = WMS110ExceptionHandler() self.expect(req.exception_handler).result(ex_handler) self.replay() response = req_ex.render() assert response.content_type == 'applicatio...
assert expected_resp.strip() == response.data
eq_(expected_resp.strip(), response.data)
def test_render_w_code(self): req = self.mock(WMSMapRequest) req_ex = RequestError('the exception message', code='InvalidFormat', request=req) ex_handler = WMS110ExceptionHandler() self.expect(req.exception_handler).result(ex_handler) self.replay() response = req_ex.render() assert response.content_type == 'applicatio...
print self.min_res, x_res, y_res, self.max_res
def contains(self, bbox, size, srs): width, height = bbox_size(bbox) if srs.is_latlong: width = deg_to_m(width) height = deg_to_m(height) x_res = width/size[0] y_res = height/size[1] print self.min_res, x_res, y_res, self.max_res if self.min_res: min_res = self.min_res + 1e-6 if min_res <= x_res or min_res <= y_res:...
eq_([x for x in pil_img.histogram() if x > 0], [40000, 40000, 40000, 227, 37, 64, 39672])
hist_color_counts = [x for x in pil_img.histogram() if x > 0] assert hist_color_counts == [40000, 40000, 40000, 227, 37, 64, 39672]\ or hist_color_counts == [40000, 40000, 40000, 75, 39925]
def test_filter(self): img = Image.new('RGB', (200, 200)) orig_source = ImageSource(img) self.tile.source = orig_source filtered_tile = self.filter(self.tile) assert self.tile is filtered_tile assert orig_source != filtered_tile.source pil_img = filtered_tile.source.as_image() eq_(pil_img.getpixel((0, 0)), (0, 0, 0, ...
if srs is not None: srs = SRS(srs)
def seed_from_yaml_conf(seed_conf_file, mapproxy_conf_file, verbose=True, dry_run=False, concurrency=2, skip_geoms_for_last_levels=0): if hasattr(seed_conf_file, 'read'): seed_conf = yaml.load(seed_conf_file) else: with open(seed_conf_file) as seed_conf: seed_conf = yaml.load(seed_conf) base_dir = os.path.abspath(os....
def _seed(self, cur_bbox, level, progess_str='', progress=1.0, all_subtiles=False, already_seeded=set()):
def _seed(self, cur_bbox, level, progess_str='', progress=1.0, all_subtiles=False):
def _seed(self, cur_bbox, level, progess_str='', progress=1.0, all_subtiles=False, already_seeded=set()): """ :param cur_bbox: the bbox to seed in this call :param level: the current seed level :param all_subtiles: seed all subtiles and do not check for intersections with bbox/geom """ bbox_, tiles_, subtiles = self.gr...
subtiles = [t for t in subtiles if t is not None and t not in already_seeded]
def _seed(self, cur_bbox, level, progess_str='', progress=1.0, all_subtiles=False, already_seeded=set()): """ :param cur_bbox: the bbox to seed in this call :param level: the current seed level :param all_subtiles: seed all subtiles and do not check for intersections with bbox/geom """ bbox_, tiles_, subtiles = self.gr...
print '[%s] %2s %6.2f%% %s ETA: %s' % (timestamp(), level, self.progress*100, format_bbox(cur_bbox), self._eta_string(self.progress))
print '[%s] %2s %6.2f%% %s ( format_bbox(cur_bbox), self.count, self._eta_string(self.progress))
def _seed(self, cur_bbox, level, progess_str='', progress=1.0, all_subtiles=False, already_seeded=set()): """ :param cur_bbox: the bbox to seed in this call :param level: the current seed level :param all_subtiles: seed all subtiles and do not check for intersections with bbox/geom """ bbox_, tiles_, subtiles = self.gr...
seeded_in_next_level.update( self._seed(sub_bbox, level+1, cur_progess_str, already_seeded=seeded_in_next_level, all_subtiles=all_subtiles, progress=progress))
self._seed(sub_bbox, level+1, cur_progess_str, all_subtiles=all_subtiles, progress=progress)
def _seed(self, cur_bbox, level, progess_str='', progress=1.0, all_subtiles=False, already_seeded=set()): """ :param cur_bbox: the bbox to seed in this call :param level: the current seed level :param all_subtiles: seed all subtiles and do not check for intersections with bbox/geom """ bbox_, tiles_, subtiles = self.gr...
except ProjInitError, ex:
except (ProjInitError, RuntimeError), ex:
def __init__(self, srs_code): """ Create a new SRS with the given `srs_code` code. """ self.srs_code = srs_code try: epsg_num = get_epsg_num(srs_code) self.proj = Proj(init='epsg:%d' % epsg_num) except ProjInitError, ex: init = _SRS.proj_init.get(srs_code, None) if init is not None: self.proj = init() else: raise ex
resp.content_type = 'image/png'
eq_(resp.content_type, 'image/png')
def test_get_map_png(self): resp = self.app.get(self.common_map_req) resp.content_type = 'image/png' data = StringIO(resp.body) assert is_png(data) assert Image.open(data).mode == 'RGB'
resp.content_type = 'image/png'
eq_(resp.content_type, 'image/png')
def test_get_map_png_transparent(self): self.common_map_req.params['transparent'] = 'True' resp = self.app.get(self.common_map_req) resp.content_type = 'image/png' data = StringIO(resp.body) assert is_png(data) assert Image.open(data).mode == 'RGBA'
resp.content_type = 'image/jpeg'
eq_(resp.content_type, 'image/jpeg')
def test_get_map_jpeg(self): self.common_map_req.params['format'] = 'image/jpeg' resp = self.app.get(self.common_map_req) resp.content_type = 'image/jpeg' assert is_jpeg(StringIO(resp.body))
resp.content_type = 'image/png'
eq_(resp.content_type, 'image/png')
def test_get_map_png(self): resp = self.app.get(self.common_map_req) resp.content_type = 'image/png' data = StringIO(resp.body) assert is_png(data) eq_(Image.open(data).mode, 'RGB')
resp.content_type = 'image/png'
eq_(resp.content_type, 'image/png')
def test_get_map_png_transparent_paletted(self): try: base_config().image.paletted = True self.common_map_req.params['transparent'] = 'True' resp = self.app.get(self.common_map_req) resp.content_type = 'image/png' data = StringIO(resp.body) assert is_png(data) assert Image.open(data).mode == 'P' finally: base_config()....
eq_(img.getpixel((0, 0)), (255, 255, 255, 0))
eq_(img.getpixel((0, 0))[3], 0)
def test_exception_w_transparent(self): self.req.set('exceptions', 'inimage') self.req.set('transparent', 'true' ) req = WMSMapRequest(self.req) req_ex = RequestError('the exception message', request=req) response = req_ex.render() assert response.content_type == 'image/png' data = StringIO(response.data) assert is_p...
libproj.pj_get_def.restype = c_char_p
libproj.pj_get_def.restype = c_void_p
def init_libproj(): libproj = load_library('libproj') if libproj is None: return libproj.pj_init_plus.argtypes = [c_char_p] libproj.pj_init_plus.restype = c_void_p libproj.pj_is_latlong.argtypes = [c_void_p] libproj.pj_is_latlong.restype = c_int libproj.pj_set_searchpath.argtypes = [c_int, POINTER(c_char_p)] libpr...
return libproj.pj_get_def(self._proj, 0)
res = libproj.pj_get_def(self._proj, 0) srs_def = ctypes.c_char_p(res).value libproj.pj_dalloc(res) return srs_def
def srs(self): return libproj.pj_get_def(self._proj, 0)
if isinstance(exc, socket.error) and exc.errno == errno.EPIPE: return
if isinstance(exc, socket.error): if (hasattr(exc, 'errno') and exc.errno == errno.EPIPE or exc.args[0] == errno.EPIPE): return
def handle_error(self, request, client_address): _exc_class, exc, _tb = sys.exc_info() if isinstance(exc, socket.error) and exc.errno == errno.EPIPE: # suppres 'Broken pipe' errors raised in timeout tests return HTTPServer_.handle_error(self, request, client_address)
caches = dict((grid.srs, tile_mgr) for grid, tile_mgr in caches)
caches = dict((grid.srs, tile_mgr) for grid, extent, tile_mgr in caches)
def seed_from_yaml_conf(seed_conf_file, mapproxy_conf_file, verbose=True, dry_run=False, concurrency=2, skip_geoms_for_last_levels=0): if hasattr(seed_conf_file, 'read'): seed_conf = yaml.load(seed_conf_file) else: with open(seed_conf_file) as seed_conf: seed_conf = yaml.load(seed_conf) base_dir = os.path.abspath(os....
if os.path.exists(tile_loc): os.remove(tile_loc)
if os.path.islink(tile_loc): os.unlink(tile_loc)
def store(self, tile): """ Add the given `tile` to the file cache. Stores the `_Tile.source` to `FileCache.tile_location`. All ``pre_store_filter`` will be called with the tile, before it will be stored. """ if tile.stored: return tile_loc = self.tile_location(tile, create_dir=True) if self.link_single_color_images:...
attribution_inverse = attrib.get('inverse', 'false') attribution_inverse = attribution_inverse.lower() == 'true'
attribution_inverse = attrib.get('inverse', False) if isinstance(attribution_inverse, basestring): if attribution_inverse.lower() == 'true': attribution_inverse = True else: attribution_inverse = False
def get_attribution_layer(layer_conf): attribution_text = layer_conf.layer.get('attribution', {}).get('text', None) if attribution_text is None: attribution_text = layer_conf.service.get('attribution', {}).get('text', None) if attribution_text is None or attribution_text is '': return None attribution_inverse = layer_c...
tile = Tile(self.meta_grid.tiles(tile.coord).next())
tile = Tile(self.meta_grid.tiles(tile.coord).next()[0])
def lock(self, tile): if self.meta_grid: tile = Tile(self.meta_grid.tiles(tile.coord).next()) return self.cache.lock(tile)
'flup>=1.0.3,<1.0.99', 'setuptools>=0.6c9',
'flup>1.0.2,<1.0.99', 'setuptools>=0.6c9',
def run(self): conf = os.path.join('doc', 'epydoc.ini') argv_ = sys.argv[1:] try: from epydoc import cli sys.argv[1:] = [ '--config=%s' % conf, ] if self.verbose: sys.argv.append('-v') cli.cli() except ImportError: print 'install epydoc to create the API documentation' finally: sys.argv[1:] = argv_
f = open('out.txt', 'a') print >>f, self.headers
def do_mock_request(self): assert len(requests_responses) > 0, 'got unexpected request (%s)' % self.path req, resp = requests_responses.pop(0) if req.get('require_basic_auth', False): f = open('out.txt', 'a') print >>f, self.headers if 'Authorization' not in self.headers: requests_responses.insert(0, (req, resp)) # pus...
'mapproxy_conf=mapproxy.paster_templates:ConfigurationTemplate'
'mapproxy_conf=mapproxy.paster_template:ConfigurationTemplate'
def run(self): conf = os.path.join('doc', 'epydoc.ini') argv_ = sys.argv[1:] try: from epydoc import cli sys.argv[1:] = [ '--config=%s' % conf, ] if self.verbose: sys.argv.append('-v') cli.cli() except ImportError: print 'install epydoc to create the API documentation' finally: sys.argv[1:] = argv_
client1 = HTTPClient(timeout=0.1) client2 = HTTPClient(timeout=0.2)
def test_timeouts(self): test_req = ({'path': '/', 'req_assert_function': lambda x: time.sleep(0.5) or True}, {'body': 'nothing'}) with mock_httpd(TESTSERVER_ADDRESS, [test_req]): client1 = HTTPClient(timeout=0.1) client2 = HTTPClient(timeout=0.2)
with mock_httpd(TESTSERVER_ADDRESS, [test_req]):
def test_timeouts(self): test_req = ({'path': '/', 'req_assert_function': lambda x: time.sleep(0.5) or True}, {'body': 'nothing'}) with mock_httpd(TESTSERVER_ADDRESS, [test_req]): client1 = HTTPClient(timeout=0.1) client2 = HTTPClient(timeout=0.2)
self._latlong = libproj.pj_is_latlong(self._proj)
self._latlong = bool(libproj.pj_is_latlong(self._proj))
def __init__(self, proj_def=None, init=None): if init: self._proj = libproj.pj_init_plus('+init=%s' % init) else: self._proj = libproj.pj_init_plus(proj_def) if not self._proj: errno = libproj.pj_get_errno_ref().contents raise ProjInitError('error initializing Proj(proj_def=%r, init=%r): %s' % (proj_def, init, libproj....
% (url, e.reason.args[1])), sys.exc_info() reraise_exception(e)
% (url, e.reason.args[1])) reraise_exception(e, sys.exc_info())
def open(self, url, *args, **kw): try: code = 500 result = None result = self.default_opener.open(url, *args, **kw) code = result.code return result except HTTPError, e: code = e.code reraise_exception(HTTPClientError('HTTP Error (%.30s...): %d' % (url, e.code)), sys.exc_info()) except URLError, e: if ssl and isinstanc...
meta_size = tile_mgr.meta_grid._meta_size if tile_mgr.meta_grid else (1, 1)
meta_size = tile_mgr.meta_grid.meta_size if tile_mgr.meta_grid else (1, 1)
def __init__(self, tile_mgr, task, seed_pool, skip_geoms_for_last_levels): self.tile_mgr = tile_mgr self.task = task self.seed_pool = seed_pool self.skip_geoms_for_last_levels = skip_geoms_for_last_levels num_seed_levels = task.max_level - task.start_level + 1 self.report_till_level = task.start_level + int(num_seed_l...
>>> round(grid.resolution(0), 5) 156543.03393 >>> round(grid.resolution(1), 5) 78271.51696 >>> round(grid.resolution(4), 5) 9783.93962
>>> '%.5f' % grid.resolution(0) '156543.03393' >>> '%.5f' % grid.resolution(1) '78271.51696' >>> '%.5f' % grid.resolution(4) '9783.93962'
def resolution(self, level): """ Returns the resolution of the `level` in units/pixel. :param level: the zoom level index (zero is top) >>> grid = TileGrid(SRS(900913)) >>> round(grid.resolution(0), 5) 156543.03393 >>> round(grid.resolution(1), 5) 78271.51696 >>> round(grid.resolution(4), 5) 9783.93962 """ return sel...
if not layers or not this_layer:
if not layers and not this_layer:
def wms_layer(self): layers = [] this_layer = None if 'layers' in self.conf: layers_conf = self.conf['layers'] for layer_conf in layers_conf: layers.append(WMSLayerConfiguration(layer_conf, self.context).wms_layer()) if 'sources' in self.conf: this_layer = LayerConfiguration(self.conf, self.context).wms_layer() if n...