repo_name
stringlengths 6
100
| path
stringlengths 4
294
| copies
stringclasses 981
values | size
stringlengths 4
6
| content
stringlengths 606
896k
| license
stringclasses 15
values | input_ids
listlengths 1.02k
1.02k
| labels
listlengths 1.02k
1.02k
| attention_mask
listlengths 1.02k
1.02k
|
|---|---|---|---|---|---|---|---|---|
dmateusp/PokemonGo-Bot
|
pokemongo_bot/inventory.py
|
1
|
40711
|
import json
import logging
import os
from collections import OrderedDict
from pokemongo_bot.base_dir import _base_dir
'''
Helper class for updating/retrieving Inventory data
Interesting info and formulas:
https://drive.google.com/file/d/0B0TeYGBPiuzaenhUNE5UWnRCVlU/view
https://www.reddit.com/r/pokemongodev/comments/4w7mdg/combat_damage_calculation_formula_exactly/
'''
#
# Abstraction
class _StaticInventoryComponent(object):
STATIC_DATA_FILE = None # optionally load static data from file,
# dropping the data in a static variable named STATIC_DATA
STATIC_DATA = None
def __init__(self):
if self.STATIC_DATA_FILE is not None:
self.init_static_data()
@classmethod
def init_static_data(cls):
if not hasattr(cls, 'STATIC_DATA') or cls.STATIC_DATA is None:
cls.STATIC_DATA = cls.process_static_data(
json.load(open(cls.STATIC_DATA_FILE)))
@classmethod
def process_static_data(cls, data):
# optional hook for processing the static data
# default is to use the data directly
return data
class _BaseInventoryComponent(_StaticInventoryComponent):
TYPE = None # base key name for items of this type
ID_FIELD = None # identifier field for items of this type
def __init__(self):
self._data = {}
super(_BaseInventoryComponent, self).__init__()
def parse(self, item):
# optional hook for parsing the dict for this item
# default is to use the dict directly
return item
def retrieve_data(self, inventory):
assert self.TYPE is not None
assert self.ID_FIELD is not None
ret = {}
for item in inventory:
data = item['inventory_item_data']
if self.TYPE in data:
item = data[self.TYPE]
key = item[self.ID_FIELD]
ret[key] = self.parse(item)
return ret
def refresh(self, inventory):
self._data = self.retrieve_data(inventory)
def get(self, object_id):
return self._data.get(object_id)
def all(self):
return list(self._data.values())
#
# Inventory Components
class Candies(_BaseInventoryComponent):
TYPE = 'candy'
ID_FIELD = 'family_id'
@classmethod
def family_id_for(cls, pokemon_id):
return Pokemons.first_evolution_id_for(pokemon_id)
def get(self, pokemon_id):
family_id = self.family_id_for(pokemon_id)
return self._data.setdefault(family_id, Candy(family_id, 0))
def parse(self, item):
candy = item['candy'] if 'candy' in item else 0
return Candy(item['family_id'], candy)
class Pokedex(_BaseInventoryComponent):
TYPE = 'pokedex_entry'
ID_FIELD = 'pokemon_id'
def seen(self, pokemon_id):
return pokemon_id in self._data
def captured(self, pokemon_id):
if not self.seen(pokemon_id):
return False
return self._data[pokemon_id]['times_captured'] > 0
class Item(object):
"""
Representation of an item.
"""
def __init__(self, item_id, item_count):
"""
Initialise an instance of an item
:param item_id: ID of the item
:type item_id: int
:param item_count: Quantity of the item
:type item_count: int
:return: An item
:rtype: Item
"""
self.id = item_id
self.name = Items.name_for(self.id)
self.count = item_count
def remove(self, amount):
"""
Remove a specified amount of an item from the cached inventory.
Note that it does **NOT** removes it in the server, it only removes it from the local cached inventory.
:param amount: Amount to remove
:type amount: int
:return: Nothing
:rtype: None
"""
if self.count < amount:
raise Exception('Tried to remove more {} than you have'.format(self.name))
self.count -= amount
def add(self, amount):
"""
Add a specified amount of the item to the local cached inventory
:param amount: Amount to add
:type amount: int
:return: Nothing.
:rtype: None
"""
if amount < 0:
raise Exception('Must add positive amount of {}'.format(self.name))
self.count += amount
def __str__(self):
return self.name + " : " + str(self.count)
class Items(_BaseInventoryComponent):
TYPE = 'item'
ID_FIELD = 'item_id'
STATIC_DATA_FILE = os.path.join(_base_dir, 'data', 'items.json')
def parse(self, item_data):
"""
Make an instance of an Item from raw item data.
:param item_data: Item data to make an item from
:return: Instance of the Item.
:rtype: Item
"""
item_id = item_data.get(Items.ID_FIELD, None)
item_count = item_data['count'] if 'count' in item_data else 0
return Item(item_id, item_count)
def all(self):
"""
Get EVERY Item from the cached inventory.
:return: List of evey item in the cached inventory
:rtype: list of Item
"""
return list(self._data.values())
def get(self, item_id):
"""
Get ONE Item from the cached inventory.
:param item_id: Item's ID to search for.
:return: Instance of the item from the cached inventory
:rtype: Item
"""
return self._data.setdefault(item_id, Item(item_id, 0))
@classmethod
def name_for(cls, item_id):
"""
Search the name for an item from its ID.
:param item_id: Item's ID to search for.
:return: Item's name.
:rtype: str
"""
return cls.STATIC_DATA[str(item_id)]
@classmethod
def get_space_used(cls):
"""
Counts the space used in item inventory.
:return: The space used in item inventory.
:rtype: int
"""
space_used = 1
for item_in_inventory in _inventory.items.all():
space_used += item_in_inventory.count
return space_used
@classmethod
def get_space_left(cls):
"""
Compute the space left in item inventory.
:return: The space left in item inventory. 0 if the player has more item than his item inventory can carry.
:rtype: int
"""
_inventory.retrieve_item_inventory_size()
space_left = _inventory.item_inventory_size - cls.get_space_used()
# Space left should never be negative. Returning 0 if the computed value is negative.
return space_left if space_left >= 0 else 0
@classmethod
def has_space_for_loot(cls):
"""
Returns a value indicating whether or not the item inventory has enough space to loot a fort
:return: True if the item inventory has enough space; otherwise, False.
:rtype: bool
"""
max_number_of_items_looted_at_stop = 5
return cls.get_space_left() >= max_number_of_items_looted_at_stop
class Pokemons(_BaseInventoryComponent):
TYPE = 'pokemon_data'
ID_FIELD = 'id'
STATIC_DATA_FILE = os.path.join(_base_dir, 'data', 'pokemon.json')
@classmethod
def process_static_data(cls, data):
data = [PokemonInfo(d) for d in data]
# process evolution info
for p in data:
next_all = p.next_evolutions_all
if len(next_all) <= 0:
continue
# only next level evolutions, not all possible
p.next_evolution_ids = [idx for idx in next_all
if data[idx-1].prev_evolution_id == p.id]
# only final evolutions
p.last_evolution_ids = [idx for idx in next_all
if not data[idx-1].has_next_evolution]
assert len(p.last_evolution_ids) > 0
return data
@classmethod
def data_for(cls, pokemon_id):
# type: (int) -> PokemonInfo
return cls.STATIC_DATA[pokemon_id - 1]
@classmethod
def name_for(cls, pokemon_id):
return cls.data_for(pokemon_id).name
@classmethod
def first_evolution_id_for(cls, pokemon_id):
return cls.data_for(pokemon_id).first_evolution_id
@classmethod
def prev_evolution_id_for(cls, pokemon_id):
return cls.data_for(pokemon_id).prev_evolution_id
@classmethod
def next_evolution_ids_for(cls, pokemon_id):
return cls.data_for(pokemon_id).next_evolution_ids
@classmethod
def last_evolution_ids_for(cls, pokemon_id):
return cls.data_for(pokemon_id).last_evolution_ids
@classmethod
def has_next_evolution(cls, pokemon_id):
return cls.data_for(pokemon_id).has_next_evolution
@classmethod
def evolution_cost_for(cls, pokemon_id):
return cls.data_for(pokemon_id).evolution_cost
def parse(self, item):
if 'is_egg' in item:
return Egg(item)
return Pokemon(item)
def all(self):
# by default don't include eggs in all pokemon (usually just
# makes caller's lives more difficult)
return [p for p in super(Pokemons, self).all() if not isinstance(p, Egg)]
def add(self, pokemon):
if pokemon.id <= 0:
raise ValueError("Can't add a pokemin whitout id")
if pokemon.id in self._data:
raise ValueError("Pokemon already present in the inventory")
self._data[pokemon.id] = pokemon
def remove(self, pokemon_id):
if pokemon_id not in self._data:
raise ValueError("Pokemon not present in the inventory")
self._data.pop(pokemon_id)
#
# Static Components
class Types(_StaticInventoryComponent):
"""
Types of attacks and pokemons
See more information:
https://i.redd.it/oy7lrixl8r9x.png
https://www.reddit.com/r/TheSilphRoad/comments/4t8seh/pokemon_go_type_advantage_chart/
https://github.com/jehy/Pokemon-Go-Weakness-calculator/blob/master/app/src/main/java/ru/jehy/pokemonweaknesscalculator/MainActivity.java#L31
"""
STATIC_DATA_FILE = os.path.join(_base_dir, 'data', 'types.json')
@classmethod
def process_static_data(cls, data):
# create instances
ret = OrderedDict()
for t in sorted(data, key=lambda x: x["name"]):
name = str(t["name"])
ret[name] = Type(name, t["effectiveAgainst"], t["weakAgainst"])
# additional manipulations
size = len(ret)
by_effectiveness = {}
by_resistance = {}
for t in ret.itervalues(): # type: Type
t.attack_effective_against = [ret[name] for name in t.attack_effective_against]
t.attack_weak_against = [ret[name] for name in t.attack_weak_against]
# group types effective against, weak against specific types
for l, d in (t.attack_effective_against, by_effectiveness), \
(t.attack_weak_against, by_resistance):
for tt in l:
if tt not in d:
d[tt] = set()
d[tt].add(t)
# calc average factor for damage of this type relative to all types
t.rate = (size
+ ((EFFECTIVENESS_FACTOR-1) * len(t.attack_effective_against))
- ((1-RESISTANCE_FACTOR) * len(t.attack_weak_against))) / size
# set pokemon type resistance/weakness info
for t in ret.itervalues(): # type: Type
t.pokemon_resistant_to = by_resistance[t]
t.pokemon_vulnerable_to = by_effectiveness[t]
return ret
@classmethod
def get(cls, type_name):
# type: (Union[string, Type]) -> Type
type_name = str(type_name)
if type_name not in cls.STATIC_DATA:
raise ValueError("Unknown type: {}".format(type_name))
return cls.STATIC_DATA[type_name]
@classmethod
def all(cls):
return cls.STATIC_DATA.values()
@classmethod
def rating(cls):
return sorted(cls.all(), key=lambda x: x.rate, reverse=True)
class LevelToCPm(_StaticInventoryComponent):
"""
Data for the CP multipliers at different levels
See http://pokemongo.gamepress.gg/cp-multiplier
See https://github.com/justinleewells/pogo-optimizer/blob/edd692d/data/game/level-to-cpm.json
"""
STATIC_DATA_FILE = os.path.join(_base_dir, 'data', 'level_to_cpm.json')
MAX_LEVEL = 40
MAX_CPM = .0
# half of the lowest difference between CPMs
HALF_DIFF_BETWEEN_HALF_LVL = 14e-3
@classmethod
def init_static_data(cls):
super(LevelToCPm, cls).init_static_data()
cls.MAX_CPM = cls.cp_multiplier_for(cls.MAX_LEVEL)
assert cls.MAX_CPM > .0
@classmethod
def cp_multiplier_for(cls, level):
# type: (Union[float, int, string]) -> float
level = float(level)
level = str(int(level) if level.is_integer() else level)
return cls.STATIC_DATA[level]
@classmethod
def level_from_cpm(cls, cp_multiplier):
# type: (float) -> float
for lvl, cpm in cls.STATIC_DATA.iteritems():
diff = abs(cpm - cp_multiplier)
if diff <= cls.HALF_DIFF_BETWEEN_HALF_LVL:
return float(lvl)
raise ValueError("Unknown cp_multiplier: {}".format(cp_multiplier))
class _Attacks(_StaticInventoryComponent):
BY_NAME = {} # type: Dict[string, Attack]
BY_TYPE = {} # type: Dict[List[Attack]]
BY_DPS = [] # type: List[Attack]
@classmethod
def process_static_data(cls, moves):
ret = {}
by_type = {}
by_name = {}
fast = cls is FastAttacks
for attack in moves:
attack = Attack(attack) if fast else ChargedAttack(attack)
ret[attack.id] = attack
by_name[attack.name] = attack
attack_type = str(attack.type)
if attack_type not in by_type:
by_type[attack_type] = []
by_type[attack_type].append(attack)
for t in by_type.iterkeys():
attacks = sorted(by_type[t], key=lambda m: m.dps, reverse=True)
min_dps = attacks[-1].dps
max_dps = attacks[0].dps - min_dps
if max_dps > .0:
for attack in attacks: # type: Attack
attack.rate_in_type = (attack.dps - min_dps) / max_dps
by_type[t] = attacks
cls.BY_NAME = by_name
cls.BY_TYPE = by_type
cls.BY_DPS = sorted(ret.values(), key=lambda m: m.dps, reverse=True)
return ret
@classmethod
def data_for(cls, attack_id):
# type: (int) -> Attack
if attack_id not in cls.STATIC_DATA:
raise ValueError("Attack {} not found in {}".format(
attack_id, cls.__name__))
return cls.STATIC_DATA[attack_id]
@classmethod
def by_name(cls, name):
# type: (string) -> Attack
return cls.BY_NAME[name]
@classmethod
def list_for_type(cls, type_name):
# type: (Union[string, Type]) -> List[Attack]
"""
:return: Attacks sorted by DPS in descending order
"""
return cls.BY_TYPE[str(type_name)]
@classmethod
def all(cls):
return cls.STATIC_DATA.values()
@classmethod
def all_by_dps(cls):
return cls.BY_DPS
class FastAttacks(_Attacks):
STATIC_DATA_FILE = os.path.join(_base_dir, 'data', 'fast_moves.json')
class ChargedAttacks(_Attacks):
STATIC_DATA_FILE = os.path.join(_base_dir, 'data', 'charged_moves.json')
#
# Instances
class Type(object):
def __init__(self, name, effective_against, weak_against):
# type: (string, Iterable[Type], Iterable[Type]) -> None
self.name = name
# effective way to represent type with one character
# for example it's very useful for nicknaming pokemon
# using its attack types
#
# if first char is unique - use it, in other case
# use suitable substitute
type_to_one_char_map = {
'Bug': 'B',
'Dark': 'K',
'Dragon': 'D',
'Electric': 'E',
'Fairy': 'Y',
'Fighting': 'T',
'Fire': 'F',
'Flying': 'L',
'Ghost': 'H',
'Grass': 'A',
'Ground': 'G',
'Ice': 'I',
'Normal': 'N',
'Poison': 'P',
'Psychic': 'C',
'Rock': 'R',
'Steel': 'S',
'Water': 'W',
}
self.as_one_char = type_to_one_char_map[name]
# attack of this type is effective against ...
self.attack_effective_against = set(effective_against)
# attack of this type is weak against ...
self.attack_weak_against = set(weak_against)
# pokemon of this type is resistant to ...
self.pokemon_resistant_to = set() # type: Set[Type]
# pokemon of this type is vulnerable to ...
self.pokemon_vulnerable_to = set() # type: Set[Type]
# average factor for damage of this type relative to all types
self.rate = 1.
def __str__(self):
return self.name
def __repr__(self):
return self.name
class Candy(object):
def __init__(self, family_id, quantity):
self.type = Pokemons.name_for(family_id)
self.quantity = quantity
def consume(self, amount):
if self.quantity < amount:
raise Exception('Tried to consume more {} candy than you have'.format(self.type))
self.quantity -= amount
def add(self, amount):
if amount < 0:
raise Exception('Must add positive amount of candy')
self.quantity += amount
class Egg(object):
def __init__(self, data):
self._data = data
def has_next_evolution(self):
return False
class PokemonInfo(object):
"""
Static information about pokemon kind
"""
def __init__(self, data):
self._data = data
self.id = int(data["Number"])
self.name = data['Name'] # type: string
self.classification = data['Classification'] # type: string
# prepare types
self.type1 = Types.get(data['Type I'][0])
self.type2 = None
self.types = [self.type1] # required type
for t in data.get('Type II', []):
self.type2 = Types.get(t)
self.types.append(self.type2) # second type
break
# base chance to capture pokemon
self.capture_rate = data['CaptureRate']
# chance of the pokemon to flee away
self.flee_rate = data['FleeRate']
# prepare attacks (moves)
self.fast_attacks = self._process_attacks()
self.charged_attack = self._process_attacks(charged=True)
# prepare movesets
self.movesets = self._process_movesets()
# Basic Values of the pokemon (identical for all pokemons of one kind)
self.base_attack = data['BaseAttack']
self.base_defense = data['BaseDefense']
self.base_stamina = data['BaseStamina']
# calculate maximum CP for the pokemon (best IVs, lvl 40)
self.max_cp = _calc_cp(self.base_attack, self.base_defense,
self.base_stamina)
#
# evolutions info for this pokemon
# id of the very first level evolution
self.first_evolution_id = self.id
# id of the previous evolution (one level only)
self.prev_evolution_id = None
# ids of all available previous evolutions in the family
self.prev_evolutions_all = []
if 'Previous evolution(s)' in data:
ids = [int(e['Number']) for e in data['Previous evolution(s)']]
self.first_evolution_id = ids[0]
self.prev_evolution_id = ids[-1]
self.prev_evolutions_all = ids
# Number of candies for the next evolution (if possible)
self.evolution_cost = 0
# next evolution flag
self.has_next_evolution = 'Next evolution(s)' in data \
or 'Next Evolution Requirements' in data
# ids of the last level evolutions
self.last_evolution_ids = [self.id]
# ids of the next possible evolutions (one level only)
self.next_evolution_ids = []
# ids of all available next evolutions in the family
self.next_evolutions_all = []
if self.has_next_evolution:
ids = [int(e['Number']) for e in data['Next evolution(s)']]
self.next_evolutions_all = ids
self.evolution_cost = int(data['Next Evolution Requirements']['Amount'])
@property
def family_id(self):
return self.first_evolution_id
@property
def is_seen(self):
return pokedex().seen(self.id)
@property
def is_captured(self):
return pokedex().captured(self.id)
def _process_movesets(self):
# type: () -> List[Moveset]
"""
The optimal moveset is the combination of two moves, one quick move
and one charge move, that deals the most damage over time.
Because each quick move gains a certain amount of energy (different
for different moves) and each charge move requires a different amount
of energy to use, sometimes, a quick move with lower DPS will be
better since it charges the charge move faster. On the same note,
sometimes a charge move that has lower DPS will be more optimal since
it may require less energy or it may last for a longer period of time.
Attacker have STAB (Same-type attack bonus - x1.25) pokemon have the
same type as attack. So we add it to the "Combo DPS" of the moveset.
The defender attacks in intervals of 1 second for the first 2 attacks,
and then in intervals of 2 seconds for the remainder of the attacks.
This explains why we see two consecutive quick attacks at the beginning
of the match. As a result, we add +2 seconds to the DPS calculation
for defender DPS output.
So to determine an optimal defensive moveset, we follow the same method
as we did for optimal offensive movesets, but instead calculate the
highest "Combo DPS" with an added 2 seconds to the quick move cool down.
Note: critical hits have not yet been implemented in the game
See http://pokemongo.gamepress.gg/optimal-moveset-explanation
See http://pokemongo.gamepress.gg/defensive-tactics
"""
# Prepare movesets
movesets = []
for fm in self.fast_attacks:
for chm in self.charged_attack:
movesets.append(Moveset(fm, chm, self.types, self.id))
assert len(movesets) > 0
# Calculate attack perfection for each moveset
movesets = sorted(movesets, key=lambda m: m.dps_attack)
worst_dps = movesets[0].dps_attack
best_dps = movesets[-1].dps_attack
if best_dps > worst_dps:
for moveset in movesets:
current_dps = moveset.dps_attack
moveset.attack_perfection = \
(current_dps - worst_dps) / (best_dps - worst_dps)
# Calculate defense perfection for each moveset
movesets = sorted(movesets, key=lambda m: m.dps_defense)
worst_dps = movesets[0].dps_defense
best_dps = movesets[-1].dps_defense
if best_dps > worst_dps:
for moveset in movesets:
current_dps = moveset.dps_defense
moveset.defense_perfection = \
(current_dps - worst_dps) / (best_dps - worst_dps)
return sorted(movesets, key=lambda m: m.dps, reverse=True)
def _process_attacks(self, charged=False):
# type: (bool) -> List[Attack]
key = 'Fast Attack(s)' if not charged else 'Special Attack(s)'
moves_dict = (ChargedAttacks if charged else FastAttacks).BY_NAME
moves = []
for name in self._data[key]:
if name not in moves_dict:
raise KeyError('Unknown {} attack: "{}"'.format(
'charged' if charged else 'fast', name))
moves.append(moves_dict[name])
moves = sorted(moves, key=lambda m: m.dps, reverse=True)
assert len(moves) > 0
return moves
class Pokemon(object):
def __init__(self, data):
self._data = data
# Unique ID for this particular Pokemon
self.id = data.get('id', 0)
# Id of the such pokemons in pokedex
self.pokemon_id = data['pokemon_id']
# Static information
self.static = Pokemons.data_for(self.pokemon_id)
# Combat points value
self.cp = data['cp']
# Base CP multiplier, fixed at the catch time
self.cp_bm = data['cp_multiplier']
# Changeable part of the CP multiplier, increasing at power up
self.cp_am = data.get('additional_cp_multiplier', .0)
# Resulting CP multiplier
self.cp_m = self.cp_bm + self.cp_am
# Current pokemon level (half of level is a normal value)
self.level = LevelToCPm.level_from_cpm(self.cp_m)
# Maximum health points
self.hp_max = data['stamina_max']
# Current health points
self.hp = data.get('stamina', self.hp_max)
assert 0 <= self.hp <= self.hp_max
# Individial Values of the current specific pokemon (different for each)
self.iv_attack = data.get('individual_attack', 0)
self.iv_defense = data.get('individual_defense', 0)
self.iv_stamina = data.get('individual_stamina', 0)
# Basic Values of the pokemon (identical for all pokemons of one kind)
base_attack = self.static.base_attack
base_defense = self.static.base_defense
base_stamina = self.static.base_stamina
self.name = self.static.name
self.nickname_raw = data.get('nickname', '')
self.nickname = self.nickname_raw or self.name
self.in_fort = 'deployed_fort_id' in data
self.is_favorite = data.get('favorite', 0) is 1
self.fast_attack = FastAttacks.data_for(data['move_1'])
self.charged_attack = ChargedAttacks.data_for(data['move_2']) # type: ChargedAttack
# Individial values (IV) perfection percent
self.iv = self._compute_iv_perfection()
# IV CP perfection - kind of IV perfection percent but calculated
# using weight of each IV in its contribution to CP of the best
# evolution of current pokemon
# So it tends to be more accurate than simple IV perfection
self.ivcp = self._compute_cp_perfection()
# Exact value of current CP (not rounded)
self.cp_exact = _calc_cp(
base_attack, base_defense, base_stamina,
self.iv_attack, self.iv_defense, self.iv_stamina, self.cp_m)
assert max(int(self.cp_exact), 10) == self.cp
# Percent of maximum possible CP
self.cp_percent = self.cp_exact / self.static.max_cp
# Get moveset instance with calculated DPS and perfection percents
self.moveset = self._get_moveset()
def __str__(self):
return self.name
def __repr__(self):
return self.name
def update_nickname(self, new_nickname):
self.nickname_raw = new_nickname
self.nickname = self.nickname_raw or self.name
def can_evolve_now(self):
return self.has_next_evolution() and \
self.candy_quantity >= self.evolution_cost
def has_next_evolution(self):
return self.static.has_next_evolution
def has_seen_next_evolution(self):
for pokemon_id in self.next_evolution_ids:
if pokedex().captured(pokemon_id):
return True
return False
@property
def family_id(self):
return self.static.family_id
@property
def first_evolution_id(self):
return self.static.first_evolution_id
@property
def prev_evolution_id(self):
return self.static.prev_evolution_id
@property
def next_evolution_ids(self):
return self.static.next_evolution_ids
@property
def last_evolution_ids(self):
return self.static.last_evolution_ids
@property
def candy_quantity(self):
return candies().get(self.pokemon_id).quantity
@property
def evolution_cost(self):
return self.static.evolution_cost
@property
def iv_display(self):
return '{}/{}/{}'.format(self.iv_attack, self.iv_defense, self.iv_stamina)
def _compute_iv_perfection(self):
total_iv = self.iv_attack + self.iv_defense + self.iv_stamina
iv_perfection = round((total_iv / 45.0), 2)
return iv_perfection
def _compute_cp_perfection(self):
"""
CP perfect percent is more accurate than IV perfect
We know attack plays an important role in CP, and different
pokemons have different base value, that's means 15/14/15 is
better than 14/15/15 for lot of pokemons, and if one pokemon's
base def is more than base sta, 15/15/14 is better than 15/14/15.
See https://github.com/jabbink/PokemonGoBot/issues/469
So calculate CP perfection at final level for the best of the final
evolutions of the pokemon.
"""
variants = []
iv_attack = self.iv_attack
iv_defense = self.iv_defense
iv_stamina = self.iv_stamina
cp_m = LevelToCPm.MAX_CPM
last_evolution_ids = self.last_evolution_ids
for pokemon_id in last_evolution_ids:
poke_info = Pokemons.data_for(pokemon_id)
base_attack = poke_info.base_attack
base_defense = poke_info.base_defense
base_stamina = poke_info.base_stamina
# calculate CP variants at maximum level
worst_cp = _calc_cp(base_attack, base_defense, base_stamina,
0, 0, 0, cp_m)
perfect_cp = _calc_cp(base_attack, base_defense, base_stamina,
cp_multiplier=cp_m)
current_cp = _calc_cp(base_attack, base_defense, base_stamina,
iv_attack, iv_defense, iv_stamina, cp_m)
cp_perfection = (current_cp - worst_cp) / (perfect_cp - worst_cp)
variants.append(cp_perfection)
# get best value (probably for the best evolution)
cp_perfection = max(variants)
return cp_perfection
def _get_moveset(self):
move1 = self.fast_attack
move2 = self.charged_attack
movesets = self.static.movesets
current_moveset = None
for moveset in movesets: # type: Moveset
if moveset.fast_attack == move1 and moveset.charged_attack == move2:
current_moveset = moveset
break
if current_moveset is None:
error = "Unexpected moveset [{}, {}] for #{} {}," \
" please update info in pokemon.json and create issue/PR" \
.format(move1, move2, self.pokemon_id, self.name)
# raise ValueError(error)
logging.getLogger(type(self).__name__).error(error)
current_moveset = Moveset(
move1, move2, self.static.types, self.pokemon_id)
return current_moveset
class Attack(object):
def __init__(self, data):
# self._data = data # Not needed - all saved in fields
self.id = data['id']
self.name = data['name']
self.type = Types.get(data['type'])
self.damage = data['damage']
self.duration = data['duration'] / 1000.0 # duration in seconds
# Energy addition for fast attack
# Energy cost for charged attack
self.energy = data['energy']
# Damage Per Second
# recalc for better precision
self.dps = self.damage / self.duration
# Perfection of the attack in it's type (from 0 to 1)
self.rate_in_type = .0
@property
def damage_with_stab(self):
# damage with STAB (Same-type attack bonus)
return self.damage * STAB_FACTOR
@property
def dps_with_stab(self):
# DPS with STAB (Same-type attack bonus)
return self.dps * STAB_FACTOR
@property
def effective_against(self):
return self.type.attack_effective_against
@property
def weak_against(self):
return self.type.attack_weak_against
@property
def energy_per_second(self):
return self.energy / self.duration
@property
def dodge_window(self):
# TODO: Attack Dodge Window
return NotImplemented
@property
def is_charged(self):
return False
def __str__(self):
return self.name
def __repr__(self):
return self.name
class ChargedAttack(Attack):
def __init__(self, data):
super(ChargedAttack, self).__init__(data)
@property
def is_charged(self):
return True
class Moveset(object):
def __init__(self, fm, chm, pokemon_types=(), pokemon_id=-1):
# type: (Attack, ChargedAttack, List[Type], int) -> None
if len(pokemon_types) <= 0 < pokemon_id:
pokemon_types = Pokemons.data_for(pokemon_id).types
self.pokemon_id = pokemon_id
self.fast_attack = fm
self.charged_attack = chm
# See Pokemons._process_movesets()
# See http://pokemongo.gamepress.gg/optimal-moveset-explanation
# See http://pokemongo.gamepress.gg/defensive-tactics
fm_number = 100 # for simplicity we use 100
fm_energy = fm.energy * fm_number
fm_damage = fm.damage * fm_number
fm_secs = fm.duration * fm_number
# Defender attacks in intervals of 1 second for the
# first 2 attacks, and then in intervals of 2 seconds
# So add 1.95 seconds to the quick move cool down for defense
# 1.95 is something like an average here
# TODO: Do something better?
fm_defense_secs = (fm.duration + 1.95) * fm_number
chm_number = fm_energy / chm.energy
chm_damage = chm.damage * chm_number
chm_secs = chm.duration * chm_number
damage_sum = fm_damage + chm_damage
# raw Damage-Per-Second for the moveset
self.dps = damage_sum / (fm_secs + chm_secs)
# average DPS for defense
self.dps_defense = damage_sum / (fm_defense_secs + chm_secs)
# apply STAB (Same-type attack bonus)
if fm.type in pokemon_types:
fm_damage *= STAB_FACTOR
if chm.type in pokemon_types:
chm_damage *= STAB_FACTOR
# DPS for attack (counting STAB)
self.dps_attack = (fm_damage + chm_damage) / (fm_secs + chm_secs)
# Moveset perfection percent for attack and for defense
# Calculated for current pokemon kind only, not between all pokemons
# So 100% perfect moveset can be weak if pokemon is weak (e.g. Caterpie)
self.attack_perfection = .0
self.defense_perfection = .0
# TODO: True DPS for real combat (floor(Attack/200 * MovePower * STAB) + 1)
# See http://pokemongo.gamepress.gg/pokemon-attack-explanation
def __str__(self):
return '[{}, {}]'.format(self.fast_attack, self.charged_attack)
def __repr__(self):
return '[{}, {}]'.format(self.fast_attack, self.charged_attack)
class Inventory(object):
def __init__(self, bot):
self.bot = bot
self.pokedex = Pokedex()
self.candy = Candies()
self.items = Items()
self.pokemons = Pokemons()
self.refresh()
self.item_inventory_size = None
def refresh(self):
# TODO: it would be better if this class was used for all
# inventory management. For now, I'm just clearing the old inventory field
self.bot.latest_inventory = None
inventory = self.bot.get_inventory()['responses']['GET_INVENTORY']['inventory_delta']['inventory_items']
for i in (self.pokedex, self.candy, self.items, self.pokemons):
i.refresh(inventory)
user_web_inventory = os.path.join(_base_dir, 'web', 'inventory-%s.json' % (self.bot.config.username))
with open(user_web_inventory, 'w') as outfile:
json.dump(inventory, outfile)
def retrieve_item_inventory_size(self):
"""
Retrieves the item inventory size
:return: Nothing.
:rtype: None
"""
# TODO: Force update of _item_inventory_size if the player upgrades its size
if self.item_inventory_size is None:
self.item_inventory_size = self.bot.api.get_player()['responses']['GET_PLAYER']['player_data']['max_item_storage']
#
# Other
# STAB (Same-type attack bonus)
# Factor applied to attack of the same type as pokemon
STAB_FACTOR = 1.25
# Factor applied to attack when it's effective against defending pokemon type
EFFECTIVENESS_FACTOR = 1.25
# Factor applied to attack when it's weak against defending pokemon type
RESISTANCE_FACTOR = 0.8
_inventory = None # type: Inventory
def _calc_cp(base_attack, base_defense, base_stamina,
iv_attack=15, iv_defense=15, iv_stamina=15,
cp_multiplier=.0):
"""
CP calculation
CP = (Attack * Defense^0.5 * Stamina^0.5 * CP_Multiplier^2) / 10
CP = (BaseAtk+AtkIV) * (BaseDef+DefIV)^0.5 * (BaseStam+StamIV)^0.5 * Lvl(CPScalar)^2 / 10
See https://www.reddit.com/r/TheSilphRoad/comments/4t7r4d/exact_pokemon_cp_formula/
See https://www.reddit.com/r/pokemongodev/comments/4t7xb4/exact_cp_formula_from_stats_and_cpm_and_an_update/
See http://pokemongo.gamepress.gg/pokemon-stats-advanced
See http://pokemongo.gamepress.gg/cp-multiplier
See http://gaming.stackexchange.com/questions/280491/formula-to-calculate-pokemon-go-cp-and-hp
:param base_attack: Pokemon BaseAttack
:param base_defense: Pokemon BaseDefense
:param base_stamina: Pokemon BaseStamina
:param iv_attack: Pokemon IndividualAttack (0..15)
:param iv_defense: Pokemon IndividualDefense (0..15)
:param iv_stamina: Pokemon IndividualStamina (0..15)
:param cp_multiplier: CP Multiplier (0.79030001 is max - value for level 40)
:return: CP as float
"""
assert base_attack > 0
assert base_defense > 0
assert base_stamina > 0
if cp_multiplier <= .0:
cp_multiplier = LevelToCPm.MAX_CPM
assert cp_multiplier > .0
return (base_attack + iv_attack) \
* ((base_defense + iv_defense)**0.5) \
* ((base_stamina + iv_stamina)**0.5) \
* (cp_multiplier ** 2) / 10
# Initialize static data in the right order
Types() # init Types
LevelToCPm() # init LevelToCPm
FastAttacks() # init FastAttacks
ChargedAttacks() # init ChargedAttacks
Pokemons() # init Pokemons
#
# Usage helpers
# TODO : Complete the doc
# Only type return have been filled for now. It helps the IDE to suggest methods of the class.
def init_inventory(bot):
"""
Initialises the cached inventory, retrieves data from the server.
:param bot: Instance of the bot.
:type bot: pokemongo_bot.PokemonGoBot
:return: Nothing.
:rtype: None
"""
global _inventory
_inventory = Inventory(bot)
def refresh_inventory():
"""
Refreshes the cached inventory, retrieves data from the server.
:return: Nothing.
:rtype: None
"""
_inventory.refresh()
def get_item_inventory_size():
"""
Access to the Item inventory size.
:return: Item inventory size.
:rtype: int
"""
_inventory.retrieve_item_inventory_size()
return _inventory.item_inventory_size
def pokedex():
"""
:return:
:rtype: Pokedex
"""
return _inventory.pokedex
def candies(refresh=False):
"""
:param refresh:
:return:
:rtype: Candies
"""
if refresh:
refresh_inventory()
return _inventory.candy
def pokemons(refresh=False):
"""
:param refresh:
:return:
:rtype: Pokemons
"""
if refresh:
refresh_inventory()
return _inventory.pokemons
def items():
"""
Access to the cached item inventory.
:return: Instance of the cached item inventory.
:rtype: Items
"""
return _inventory.items
def types_data():
"""
:return:
:rtype: Types
"""
return Types
def levels_to_cpm():
"""
:return:
:rtype: LevelToCPm
"""
return LevelToCPm
def fast_attacks():
"""
:return:
:rtype: FastAttacks
"""
return FastAttacks
def charged_attacks():
"""
:return:
:rtype: ChargedAttack
"""
return ChargedAttacks
|
mit
|
[
646,
2022,
199,
646,
2050,
199,
646,
747,
199,
504,
5055,
492,
8773,
199,
199,
504,
1115,
415,
9217,
63,
3018,
14,
1095,
63,
694,
492,
485,
1095,
63,
694,
199,
199,
2344,
199,
4433,
1021,
367,
12928,
15,
11235,
69,
4007,
19337,
666,
199,
199,
8309,
3911,
316,
2256,
436,
1824,
32646,
26,
199,
2859,
921,
9541,
14,
3098,
14,
957,
15,
493,
15,
68,
15,
16,
34,
16,
6301,
57,
6487,
10542,
85,
8076,
287,
72,
1734,
37,
21,
53,
55,
78,
8205,
54,
76,
53,
15,
1345,
199,
2859,
921,
1544,
14,
18374,
14,
957,
15,
82,
15,
31696,
22130,
380,
86,
15,
6223,
15,
20,
87,
23,
1064,
71,
15,
6560,
292,
63,
26551,
63,
31458,
63,
16798,
63,
7327,
590,
15,
199,
2344,
421,
199,
3,
199,
3,
8351,
29639,
199,
199,
533,
485,
9278,
19304,
7004,
8,
785,
304,
272,
27815,
63,
3998,
63,
3817,
275,
488,
221,
327,
14190,
2248,
2955,
666,
687,
570,
12,
2490,
327,
366,
20148,
314,
666,
315,
282,
2955,
1750,
4310,
27815,
63,
3998,
272,
27815,
63,
3998,
275,
488,
339,
347,
636,
826,
721,
277,
304,
267,
340,
291,
14,
10449,
63,
3998,
63,
3817,
365,
440,
488,
26,
288,
291,
14,
826,
63,
1986,
63,
576,
342,
339,
768,
3744,
272,
347,
4205,
63,
1986,
63,
576,
8,
1886,
304,
267,
340,
440,
2688,
8,
1886,
12,
283,
10449,
63,
3998,
358,
503,
843,
14,
10449,
63,
3998,
365,
488,
26,
288,
843,
14,
10449,
63,
3998,
275,
843,
14,
1412,
63,
1986,
63,
576,
8,
355,
2022,
14,
912,
8,
1490,
8,
1886,
14,
10449,
63,
3998,
63,
3817,
1724,
339,
768,
3744,
272,
347,
2112,
63,
1986,
63,
576,
8,
1886,
12,
666,
304,
267,
327,
2716,
5759,
367,
6661,
314,
2955,
666,
267,
327,
849,
365,
370,
675,
314,
666,
5370,
267,
372,
666,
421,
199,
533,
485,
1563,
19304,
7004,
1547,
9278,
19304,
7004,
304,
272,
11511,
275,
488,
221,
327,
1300,
790,
536,
367,
2974,
402,
642,
730,
272,
2870,
63,
8609,
275,
488,
221,
327,
5148,
901,
367,
2974,
402,
642,
730,
339,
347,
636,
826,
721,
277,
304,
267,
291,
423,
576,
275,
1052,
267,
1613,
1547,
1563,
19304,
7004,
12,
291,
2843,
826,
4533,
339,
347,
2198,
8,
277,
12,
1242,
304,
267,
327,
2716,
5759,
367,
6057,
314,
1211,
367,
642,
1242,
267,
327,
849,
365,
370,
675,
314,
1211,
5370,
267,
372,
1242,
339,
347,
8044,
63,
576,
8,
277,
12,
8200,
304,
267,
702,
291,
14,
2711,
365,
440,
488,
267,
702,
291,
14,
998,
63,
8609,
365,
440,
488,
267,
2203,
275,
1052,
267,
367,
1242,
315,
8200,
26,
288,
666,
275,
1242,
459,
7212,
63,
1053,
63,
576,
418,
288,
340,
291,
14,
2711,
315,
666,
26,
355,
1242,
275,
666,
59,
277,
14,
2711,
61,
355,
790,
275,
1242,
59,
277,
14,
998,
63,
8609,
61,
355,
2203,
59,
498,
61,
275,
291,
14,
1122,
8,
1053,
9,
267,
372,
2203,
339,
347,
9236,
8,
277,
12,
8200,
304,
267,
291,
423,
576,
275,
291,
14,
14270,
63,
576,
8,
7212,
9,
339,
347,
664,
8,
277,
12,
909,
63,
344,
304,
267,
372,
291,
423,
576,
14,
362,
8,
785,
63,
344,
9,
339,
347,
1006,
8,
277,
304,
267,
372,
769,
8,
277,
423,
576,
14,
1459,
1012,
421,
199,
3,
199,
3,
19337,
17823,
199,
199,
533,
6855,
18245,
1547,
1563,
19304,
7004,
304,
272,
11511,
275,
283,
67,
460,
89,
7,
272,
2870,
63,
8609,
275,
283,
6606,
63,
344,
7,
339,
768,
3744,
272,
347,
9614,
63,
344,
63,
509,
8,
1886,
12,
1115,
17180,
63,
344,
304,
267,
372,
4376,
17180,
83,
14,
2246,
63,
6857,
3347,
63,
344,
63,
509,
8,
28331,
63,
344,
9,
339,
347,
664,
8,
277,
12,
1115,
17180,
63,
344,
304,
267,
9614,
63,
344,
275,
291,
14,
6606,
63,
344,
63,
509,
8,
28331,
63,
344,
9,
267,
372,
291,
423,
576,
14,
5486,
8,
6606,
63,
344,
12,
445,
460,
89,
8,
6606,
63,
344,
12,
378,
430,
339,
347,
2198,
8,
277,
12,
1242,
304,
267,
28269,
89,
275,
1242,
459,
67,
460,
89,
418,
340,
283,
67,
460,
89,
7,
315,
1242,
587,
378,
267,
372,
445,
460,
89,
8,
1053,
459,
6606,
63,
344,
995,
28269,
89,
9,
421,
199,
533,
4376,
415,
731,
1547,
1563,
19304,
7004,
304,
272,
11511,
275,
283,
31696,
731,
63,
2373,
7,
272,
2870,
63,
8609,
275,
283,
28331,
63,
344,
7,
339,
347,
6775,
8,
277,
12,
1115,
17180,
63,
344,
304,
267,
372,
1115,
17180,
63,
344,
315,
291,
423,
576,
339,
347,
17487,
8,
277,
12,
1115,
17180,
63,
344,
304,
267,
340,
440,
291,
14,
8606,
8,
28331,
63,
344,
304,
288,
372,
756,
267,
372,
291,
423,
576,
59,
28331,
63,
344,
2733,
4508,
63,
28345,
418,
690,
378,
421,
199,
533,
7020,
8,
785,
304,
272,
408,
272,
17634,
425,
402,
376,
1242,
14,
272,
408,
272,
347,
636,
826,
721,
277,
12,
1242,
63,
344,
12,
1242,
63,
835,
304,
267,
408,
267,
6026,
572,
376,
1256,
402,
376,
1242,
267,
520,
635,
1242,
63,
344,
26,
2870,
402,
314,
1242,
267,
520,
466,
1242,
63,
344,
26,
1109,
267,
520,
635,
1242,
63,
835,
26,
31951,
402,
314,
1242,
267,
520,
466,
1242,
63,
835,
26,
1109,
267,
520,
1107,
26,
1626,
1242,
267,
520,
4500,
26,
7020,
267,
408,
267,
291,
14,
344,
275,
1242,
63,
344,
267,
291,
14,
354,
275,
20720,
14,
354,
63,
509,
8,
277,
14,
344,
9,
267,
291,
14,
835,
275,
1242,
63,
835,
339,
347,
2813,
8,
277,
12,
5982,
304,
267,
408,
267,
5852,
282,
2013,
5982,
402,
376,
1242,
687,
314,
6328,
8200,
14,
267,
3390,
626,
652,
1630,
1011,
4609,
538,
14185,
652,
315,
314,
1654,
12,
652,
1454,
14185,
652,
687,
314,
2257,
6328,
8200,
14,
267,
520,
635,
5982,
26,
26701,
370,
2813,
267,
520,
466,
5982,
26,
1109,
267,
520,
1107,
26,
20550,
267,
520,
4500,
26,
488,
267,
408,
267,
340,
291,
14,
835,
665,
5982,
26,
288,
746,
2186
] |
[
2022,
199,
646,
2050,
199,
646,
747,
199,
504,
5055,
492,
8773,
199,
199,
504,
1115,
415,
9217,
63,
3018,
14,
1095,
63,
694,
492,
485,
1095,
63,
694,
199,
199,
2344,
199,
4433,
1021,
367,
12928,
15,
11235,
69,
4007,
19337,
666,
199,
199,
8309,
3911,
316,
2256,
436,
1824,
32646,
26,
199,
2859,
921,
9541,
14,
3098,
14,
957,
15,
493,
15,
68,
15,
16,
34,
16,
6301,
57,
6487,
10542,
85,
8076,
287,
72,
1734,
37,
21,
53,
55,
78,
8205,
54,
76,
53,
15,
1345,
199,
2859,
921,
1544,
14,
18374,
14,
957,
15,
82,
15,
31696,
22130,
380,
86,
15,
6223,
15,
20,
87,
23,
1064,
71,
15,
6560,
292,
63,
26551,
63,
31458,
63,
16798,
63,
7327,
590,
15,
199,
2344,
421,
199,
3,
199,
3,
8351,
29639,
199,
199,
533,
485,
9278,
19304,
7004,
8,
785,
304,
272,
27815,
63,
3998,
63,
3817,
275,
488,
221,
327,
14190,
2248,
2955,
666,
687,
570,
12,
2490,
327,
366,
20148,
314,
666,
315,
282,
2955,
1750,
4310,
27815,
63,
3998,
272,
27815,
63,
3998,
275,
488,
339,
347,
636,
826,
721,
277,
304,
267,
340,
291,
14,
10449,
63,
3998,
63,
3817,
365,
440,
488,
26,
288,
291,
14,
826,
63,
1986,
63,
576,
342,
339,
768,
3744,
272,
347,
4205,
63,
1986,
63,
576,
8,
1886,
304,
267,
340,
440,
2688,
8,
1886,
12,
283,
10449,
63,
3998,
358,
503,
843,
14,
10449,
63,
3998,
365,
488,
26,
288,
843,
14,
10449,
63,
3998,
275,
843,
14,
1412,
63,
1986,
63,
576,
8,
355,
2022,
14,
912,
8,
1490,
8,
1886,
14,
10449,
63,
3998,
63,
3817,
1724,
339,
768,
3744,
272,
347,
2112,
63,
1986,
63,
576,
8,
1886,
12,
666,
304,
267,
327,
2716,
5759,
367,
6661,
314,
2955,
666,
267,
327,
849,
365,
370,
675,
314,
666,
5370,
267,
372,
666,
421,
199,
533,
485,
1563,
19304,
7004,
1547,
9278,
19304,
7004,
304,
272,
11511,
275,
488,
221,
327,
1300,
790,
536,
367,
2974,
402,
642,
730,
272,
2870,
63,
8609,
275,
488,
221,
327,
5148,
901,
367,
2974,
402,
642,
730,
339,
347,
636,
826,
721,
277,
304,
267,
291,
423,
576,
275,
1052,
267,
1613,
1547,
1563,
19304,
7004,
12,
291,
2843,
826,
4533,
339,
347,
2198,
8,
277,
12,
1242,
304,
267,
327,
2716,
5759,
367,
6057,
314,
1211,
367,
642,
1242,
267,
327,
849,
365,
370,
675,
314,
1211,
5370,
267,
372,
1242,
339,
347,
8044,
63,
576,
8,
277,
12,
8200,
304,
267,
702,
291,
14,
2711,
365,
440,
488,
267,
702,
291,
14,
998,
63,
8609,
365,
440,
488,
267,
2203,
275,
1052,
267,
367,
1242,
315,
8200,
26,
288,
666,
275,
1242,
459,
7212,
63,
1053,
63,
576,
418,
288,
340,
291,
14,
2711,
315,
666,
26,
355,
1242,
275,
666,
59,
277,
14,
2711,
61,
355,
790,
275,
1242,
59,
277,
14,
998,
63,
8609,
61,
355,
2203,
59,
498,
61,
275,
291,
14,
1122,
8,
1053,
9,
267,
372,
2203,
339,
347,
9236,
8,
277,
12,
8200,
304,
267,
291,
423,
576,
275,
291,
14,
14270,
63,
576,
8,
7212,
9,
339,
347,
664,
8,
277,
12,
909,
63,
344,
304,
267,
372,
291,
423,
576,
14,
362,
8,
785,
63,
344,
9,
339,
347,
1006,
8,
277,
304,
267,
372,
769,
8,
277,
423,
576,
14,
1459,
1012,
421,
199,
3,
199,
3,
19337,
17823,
199,
199,
533,
6855,
18245,
1547,
1563,
19304,
7004,
304,
272,
11511,
275,
283,
67,
460,
89,
7,
272,
2870,
63,
8609,
275,
283,
6606,
63,
344,
7,
339,
768,
3744,
272,
347,
9614,
63,
344,
63,
509,
8,
1886,
12,
1115,
17180,
63,
344,
304,
267,
372,
4376,
17180,
83,
14,
2246,
63,
6857,
3347,
63,
344,
63,
509,
8,
28331,
63,
344,
9,
339,
347,
664,
8,
277,
12,
1115,
17180,
63,
344,
304,
267,
9614,
63,
344,
275,
291,
14,
6606,
63,
344,
63,
509,
8,
28331,
63,
344,
9,
267,
372,
291,
423,
576,
14,
5486,
8,
6606,
63,
344,
12,
445,
460,
89,
8,
6606,
63,
344,
12,
378,
430,
339,
347,
2198,
8,
277,
12,
1242,
304,
267,
28269,
89,
275,
1242,
459,
67,
460,
89,
418,
340,
283,
67,
460,
89,
7,
315,
1242,
587,
378,
267,
372,
445,
460,
89,
8,
1053,
459,
6606,
63,
344,
995,
28269,
89,
9,
421,
199,
533,
4376,
415,
731,
1547,
1563,
19304,
7004,
304,
272,
11511,
275,
283,
31696,
731,
63,
2373,
7,
272,
2870,
63,
8609,
275,
283,
28331,
63,
344,
7,
339,
347,
6775,
8,
277,
12,
1115,
17180,
63,
344,
304,
267,
372,
1115,
17180,
63,
344,
315,
291,
423,
576,
339,
347,
17487,
8,
277,
12,
1115,
17180,
63,
344,
304,
267,
340,
440,
291,
14,
8606,
8,
28331,
63,
344,
304,
288,
372,
756,
267,
372,
291,
423,
576,
59,
28331,
63,
344,
2733,
4508,
63,
28345,
418,
690,
378,
421,
199,
533,
7020,
8,
785,
304,
272,
408,
272,
17634,
425,
402,
376,
1242,
14,
272,
408,
272,
347,
636,
826,
721,
277,
12,
1242,
63,
344,
12,
1242,
63,
835,
304,
267,
408,
267,
6026,
572,
376,
1256,
402,
376,
1242,
267,
520,
635,
1242,
63,
344,
26,
2870,
402,
314,
1242,
267,
520,
466,
1242,
63,
344,
26,
1109,
267,
520,
635,
1242,
63,
835,
26,
31951,
402,
314,
1242,
267,
520,
466,
1242,
63,
835,
26,
1109,
267,
520,
1107,
26,
1626,
1242,
267,
520,
4500,
26,
7020,
267,
408,
267,
291,
14,
344,
275,
1242,
63,
344,
267,
291,
14,
354,
275,
20720,
14,
354,
63,
509,
8,
277,
14,
344,
9,
267,
291,
14,
835,
275,
1242,
63,
835,
339,
347,
2813,
8,
277,
12,
5982,
304,
267,
408,
267,
5852,
282,
2013,
5982,
402,
376,
1242,
687,
314,
6328,
8200,
14,
267,
3390,
626,
652,
1630,
1011,
4609,
538,
14185,
652,
315,
314,
1654,
12,
652,
1454,
14185,
652,
687,
314,
2257,
6328,
8200,
14,
267,
520,
635,
5982,
26,
26701,
370,
2813,
267,
520,
466,
5982,
26,
1109,
267,
520,
1107,
26,
20550,
267,
520,
4500,
26,
488,
267,
408,
267,
340,
291,
14,
835,
665,
5982,
26,
288,
746,
2186,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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7480
|
"""
termcolors.py
"""
from django.utils import six
color_names = ('black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white')
foreground = {color_names[x]: '3%s' % x for x in range(8)}
background = {color_names[x]: '4%s' % x for x in range(8)}
RESET = '0'
opt_dict = {'bold': '1', 'underscore': '4', 'blink': '5', 'reverse': '7', 'conceal': '8'}
def colorize(text='', opts=(), **kwargs):
"""
Returns your text, enclosed in ANSI graphics codes.
Depends on the keyword arguments 'fg' and 'bg', and the contents of
the opts tuple/list.
Returns the RESET code if no parameters are given.
Valid colors:
'black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white'
Valid options:
'bold'
'underscore'
'blink'
'reverse'
'conceal'
'noreset' - string will not be auto-terminated with the RESET code
Examples:
colorize('hello', fg='red', bg='blue', opts=('blink',))
colorize()
colorize('goodbye', opts=('underscore',))
print(colorize('first line', fg='red', opts=('noreset',)))
print('this should be red too')
print(colorize('and so should this'))
print('this should not be red')
"""
code_list = []
if text == '' and len(opts) == 1 and opts[0] == 'reset':
return '\x1b[%sm' % RESET
for k, v in six.iteritems(kwargs):
if k == 'fg':
code_list.append(foreground[v])
elif k == 'bg':
code_list.append(background[v])
for o in opts:
if o in opt_dict:
code_list.append(opt_dict[o])
if 'noreset' not in opts:
text = '%s\x1b[%sm' % (text or '', RESET)
return '%s%s' % (('\x1b[%sm' % ';'.join(code_list)), text or '')
def make_style(opts=(), **kwargs):
"""
Returns a function with default parameters for colorize()
Example:
bold_red = make_style(opts=('bold',), fg='red')
print(bold_red('hello'))
KEYWORD = make_style(fg='yellow')
COMMENT = make_style(fg='blue', opts=('bold',))
"""
return lambda text: colorize(text, opts, **kwargs)
NOCOLOR_PALETTE = 'nocolor'
DARK_PALETTE = 'dark'
LIGHT_PALETTE = 'light'
PALETTES = {
NOCOLOR_PALETTE: {
'ERROR': {},
'WARNING': {},
'NOTICE': {},
'SQL_FIELD': {},
'SQL_COLTYPE': {},
'SQL_KEYWORD': {},
'SQL_TABLE': {},
'HTTP_INFO': {},
'HTTP_SUCCESS': {},
'HTTP_REDIRECT': {},
'HTTP_NOT_MODIFIED': {},
'HTTP_BAD_REQUEST': {},
'HTTP_NOT_FOUND': {},
'HTTP_SERVER_ERROR': {},
'MIGRATE_HEADING': {},
'MIGRATE_LABEL': {},
'MIGRATE_SUCCESS': {},
'MIGRATE_FAILURE': {},
},
DARK_PALETTE: {
'ERROR': {'fg': 'red', 'opts': ('bold',)},
'WARNING': {'fg': 'yellow', 'opts': ('bold',)},
'NOTICE': {'fg': 'red'},
'SQL_FIELD': {'fg': 'green', 'opts': ('bold',)},
'SQL_COLTYPE': {'fg': 'green'},
'SQL_KEYWORD': {'fg': 'yellow'},
'SQL_TABLE': {'opts': ('bold',)},
'HTTP_INFO': {'opts': ('bold',)},
'HTTP_SUCCESS': {},
'HTTP_REDIRECT': {'fg': 'green'},
'HTTP_NOT_MODIFIED': {'fg': 'cyan'},
'HTTP_BAD_REQUEST': {'fg': 'red', 'opts': ('bold',)},
'HTTP_NOT_FOUND': {'fg': 'yellow'},
'HTTP_SERVER_ERROR': {'fg': 'magenta', 'opts': ('bold',)},
'MIGRATE_HEADING': {'fg': 'cyan', 'opts': ('bold',)},
'MIGRATE_LABEL': {'opts': ('bold',)},
'MIGRATE_SUCCESS': {'fg': 'green', 'opts': ('bold',)},
'MIGRATE_FAILURE': {'fg': 'red', 'opts': ('bold',)},
},
LIGHT_PALETTE: {
'ERROR': {'fg': 'red', 'opts': ('bold',)},
'WARNING': {'fg': 'yellow', 'opts': ('bold',)},
'NOTICE': {'fg': 'red'},
'SQL_FIELD': {'fg': 'green', 'opts': ('bold',)},
'SQL_COLTYPE': {'fg': 'green'},
'SQL_KEYWORD': {'fg': 'blue'},
'SQL_TABLE': {'opts': ('bold',)},
'HTTP_INFO': {'opts': ('bold',)},
'HTTP_SUCCESS': {},
'HTTP_REDIRECT': {'fg': 'green', 'opts': ('bold',)},
'HTTP_NOT_MODIFIED': {'fg': 'green'},
'HTTP_BAD_REQUEST': {'fg': 'red', 'opts': ('bold',)},
'HTTP_NOT_FOUND': {'fg': 'red'},
'HTTP_SERVER_ERROR': {'fg': 'magenta', 'opts': ('bold',)},
'MIGRATE_HEADING': {'fg': 'cyan', 'opts': ('bold',)},
'MIGRATE_LABEL': {'opts': ('bold',)},
'MIGRATE_SUCCESS': {'fg': 'green', 'opts': ('bold',)},
'MIGRATE_FAILURE': {'fg': 'red', 'opts': ('bold',)},
}
}
DEFAULT_PALETTE = DARK_PALETTE
def parse_color_setting(config_string):
"""Parse a DJANGO_COLORS environment variable to produce the system palette
The general form of a pallete definition is:
"palette;role=fg;role=fg/bg;role=fg,option,option;role=fg/bg,option,option"
where:
palette is a named palette; one of 'light', 'dark', or 'nocolor'.
role is a named style used by Django
fg is a background color.
bg is a background color.
option is a display options.
Specifying a named palette is the same as manually specifying the individual
definitions for each role. Any individual definitions following the pallete
definition will augment the base palette definition.
Valid roles:
'error', 'notice', 'sql_field', 'sql_coltype', 'sql_keyword', 'sql_table',
'http_info', 'http_success', 'http_redirect', 'http_bad_request',
'http_not_found', 'http_server_error'
Valid colors:
'black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white'
Valid options:
'bold', 'underscore', 'blink', 'reverse', 'conceal'
"""
if not config_string:
return PALETTES[DEFAULT_PALETTE]
# Split the color configuration into parts
parts = config_string.lower().split(';')
palette = PALETTES[NOCOLOR_PALETTE].copy()
for part in parts:
if part in PALETTES:
# A default palette has been specified
palette.update(PALETTES[part])
elif '=' in part:
# Process a palette defining string
definition = {}
# Break the definition into the role,
# plus the list of specific instructions.
# The role must be in upper case
role, instructions = part.split('=')
role = role.upper()
styles = instructions.split(',')
styles.reverse()
# The first instruction can contain a slash
# to break apart fg/bg.
colors = styles.pop().split('/')
colors.reverse()
fg = colors.pop()
if fg in color_names:
definition['fg'] = fg
if colors and colors[-1] in color_names:
definition['bg'] = colors[-1]
# All remaining instructions are options
opts = tuple(s for s in styles if s in opt_dict.keys())
if opts:
definition['opts'] = opts
# The nocolor palette has all available roles.
# Use that palette as the basis for determining
# if the role is valid.
if role in PALETTES[NOCOLOR_PALETTE] and definition:
palette[role] = definition
# If there are no colors specified, return the empty palette.
if palette == PALETTES[NOCOLOR_PALETTE]:
return None
return palette
|
bsd-3-clause
|
[
624,
199,
5125,
7120,
14,
647,
199,
624,
199,
199,
504,
1639,
14,
1208,
492,
3816,
199,
199,
2326,
63,
1247,
275,
661,
8399,
297,
283,
581,
297,
283,
7731,
297,
283,
14514,
297,
283,
6304,
297,
283,
5615,
21335,
297,
283,
28291,
297,
283,
7510,
358,
199,
23801,
275,
469,
2326,
63,
1247,
59,
88,
2189,
283,
19,
5,
83,
7,
450,
671,
367,
671,
315,
1425,
8,
24,
6769,
199,
7451,
275,
469,
2326,
63,
1247,
59,
88,
2189,
283,
20,
5,
83,
7,
450,
671,
367,
671,
315,
1425,
8,
24,
6769,
199,
199,
18066,
275,
283,
16,
7,
199,
2992,
63,
807,
275,
791,
9771,
356,
283,
17,
297,
283,
21831,
356,
283,
20,
297,
283,
24042,
356,
283,
21,
297,
283,
4471,
356,
283,
23,
297,
283,
388,
301,
279,
356,
283,
24,
936,
421,
199,
318,
31019,
8,
505,
4581,
3999,
16729,
1011,
958,
304,
272,
408,
272,
1803,
2195,
1318,
12,
27828,
315,
25600,
24348,
9479,
14,
339,
21588,
3198,
641,
314,
4252,
2368,
283,
9681,
7,
436,
283,
6856,
297,
436,
314,
4072,
402,
272,
314,
3999,
2008,
15,
513,
14,
339,
1803,
314,
12565,
775,
1233,
340,
949,
2633,
787,
1627,
14,
339,
4821,
9229,
26,
267,
283,
8399,
297,
283,
581,
297,
283,
7731,
297,
283,
14514,
297,
283,
6304,
297,
283,
5615,
21335,
297,
283,
28291,
297,
283,
7510,
7,
339,
4821,
1511,
26,
267,
283,
9771,
7,
267,
283,
21831,
7,
267,
283,
24042,
7,
267,
283,
4471,
7,
267,
283,
388,
301,
279,
7,
267,
283,
27400,
409,
7,
446,
1059,
911,
440,
506,
2599,
13,
18375,
543,
314,
12565,
775,
1233,
339,
6058,
26,
267,
31019,
360,
5006,
297,
16587,
534,
581,
297,
12994,
534,
6304,
297,
3999,
7782,
24042,
16829,
267,
31019,
342,
267,
31019,
360,
8302,
16481,
297,
3999,
7782,
21831,
16829,
267,
870,
8,
2326,
794,
360,
2246,
1004,
297,
16587,
534,
581,
297,
3999,
7782,
27400,
409,
297,
1724,
267,
870,
360,
3749,
1077,
506,
8992,
4634,
358,
267,
870,
8,
2326,
794,
360,
460,
880,
1077,
642,
1333,
267,
870,
360,
3749,
1077,
440,
506,
8992,
358,
272,
408,
272,
1233,
63,
513,
275,
942,
272,
340,
1318,
508,
2125,
436,
822,
8,
3291,
9,
508,
413,
436,
3999,
59,
16,
61,
508,
283,
3958,
356,
267,
372,
1557,
88,
17,
66,
9722,
3300,
7,
450,
12565,
775,
272,
367,
1022,
12,
373,
315,
3816,
14,
4611,
8,
958,
304,
267,
340,
1022,
508,
283,
9681,
356,
288,
1233,
63,
513,
14,
740,
8,
23801,
59,
86,
566,
267,
916,
1022,
508,
283,
6856,
356,
288,
1233,
63,
513,
14,
740,
8,
7451,
59,
86,
566,
272,
367,
312,
315,
3999,
26,
267,
340,
312,
315,
2450,
63,
807,
26,
288,
1233,
63,
513,
14,
740,
8,
2992,
63,
807,
59,
79,
566,
272,
340,
283,
27400,
409,
7,
440,
315,
3999,
26,
267,
1318,
275,
1543,
83,
60,
88,
17,
66,
9722,
3300,
7,
450,
334,
505,
503,
3260,
12565,
775,
9,
272,
372,
1543,
83,
5,
83,
7,
450,
334,
2258,
88,
17,
66,
9722,
3300,
7,
450,
30955,
904,
8,
600,
63,
513,
1826,
1318,
503,
4074,
421,
199,
318,
1852,
63,
2487,
8,
3291,
16729,
1011,
958,
304,
272,
408,
272,
1803,
282,
805,
543,
849,
2633,
367,
31019,
342,
339,
5679,
26,
267,
17268,
63,
581,
275,
1852,
63,
2487,
8,
3291,
7782,
9771,
5529,
16587,
534,
581,
358,
267,
870,
8,
9771,
63,
581,
360,
5006,
1333,
267,
9301,
5172,
275,
1852,
63,
2487,
8,
9681,
534,
14514,
358,
267,
25071,
275,
1852,
63,
2487,
8,
9681,
534,
6304,
297,
3999,
7782,
9771,
16829,
272,
408,
272,
372,
2400,
1318,
26,
31019,
8,
505,
12,
3999,
12,
1011,
958,
9,
199,
199,
2826,
7134,
63,
29586,
275,
283,
889,
2326,
7,
199,
36,
5748,
63,
29586,
275,
283,
13625,
7,
199,
21613,
63,
29586,
275,
283,
4040,
7,
199,
199,
23777,
15472,
275,
469,
272,
4825,
7134,
63,
29586,
26,
469,
267,
283,
3170,
356,
5479,
267,
283,
9171,
356,
5479,
267,
283,
4609,
4047,
356,
5479,
267,
283,
4657,
63,
8609,
356,
5479,
267,
283,
4657,
63,
3978,
2711,
356,
5479,
267,
283,
4657,
63,
17714,
356,
5479,
267,
283,
4657,
63,
8723,
356,
5479,
267,
283,
2856,
63,
4531,
356,
5479,
267,
283,
2856,
63,
12779,
356,
5479,
267,
283,
2856,
63,
19747,
356,
5479,
267,
283,
2856,
63,
4609,
63,
30389,
356,
5479,
267,
283,
2856,
63,
9439,
63,
6780,
356,
5479,
267,
283,
2856,
63,
4609,
63,
13945,
356,
5479,
267,
283,
2856,
63,
6613,
63,
3170,
356,
5479,
267,
283,
22487,
16553,
63,
5211,
1206,
356,
5479,
267,
283,
22487,
16553,
63,
13837,
356,
5479,
267,
283,
22487,
16553,
63,
12779,
356,
5479,
267,
283,
22487,
16553,
63,
13989,
356,
5479,
272,
1660,
272,
577,
5748,
63,
29586,
26,
469,
267,
283,
3170,
356,
791,
9681,
356,
283,
581,
297,
283,
3291,
356,
661,
9771,
9538,
1386,
267,
283,
9171,
356,
791,
9681,
356,
283,
14514,
297,
283,
3291,
356,
661,
9771,
9538,
1386,
267,
283,
4609,
4047,
356,
791,
9681,
356,
283,
581,
2267,
267,
283,
4657,
63,
8609,
356,
791,
9681,
356,
283,
7731,
297,
283,
3291,
356,
661,
9771,
9538,
1386,
267,
283,
4657,
63,
3978,
2711,
356,
791,
9681,
356,
283,
7731,
2267,
267,
283,
4657,
63,
17714,
356,
791,
9681,
356,
283,
14514,
2267,
267,
283,
4657,
63,
8723,
356,
791,
3291,
356,
661,
9771,
9538,
1386,
267,
283,
2856,
63,
4531,
356,
791,
3291,
356,
661,
9771,
9538,
1386,
267,
283,
2856,
63,
12779,
356,
5479,
267,
283,
2856,
63,
19747,
356,
791,
9681,
356,
283,
7731,
2267,
267,
283,
2856,
63,
4609,
63,
30389,
356,
791,
9681,
356,
283,
28291,
2267,
267,
283,
2856,
63,
9439,
63,
6780,
356,
791,
9681,
356,
283,
581,
297,
283,
3291,
356,
661,
9771,
9538,
1386,
267,
283,
2856,
63,
4609,
63,
13945,
356,
791,
9681,
356,
283,
14514,
2267,
267,
283,
2856,
63,
6613,
63,
3170,
356,
791,
9681,
356,
283,
5615,
21335,
297,
283,
3291,
356,
661,
9771,
9538,
1386,
267,
283,
22487,
16553,
63,
5211,
1206,
356,
791
] |
[
199,
5125,
7120,
14,
647,
199,
624,
199,
199,
504,
1639,
14,
1208,
492,
3816,
199,
199,
2326,
63,
1247,
275,
661,
8399,
297,
283,
581,
297,
283,
7731,
297,
283,
14514,
297,
283,
6304,
297,
283,
5615,
21335,
297,
283,
28291,
297,
283,
7510,
358,
199,
23801,
275,
469,
2326,
63,
1247,
59,
88,
2189,
283,
19,
5,
83,
7,
450,
671,
367,
671,
315,
1425,
8,
24,
6769,
199,
7451,
275,
469,
2326,
63,
1247,
59,
88,
2189,
283,
20,
5,
83,
7,
450,
671,
367,
671,
315,
1425,
8,
24,
6769,
199,
199,
18066,
275,
283,
16,
7,
199,
2992,
63,
807,
275,
791,
9771,
356,
283,
17,
297,
283,
21831,
356,
283,
20,
297,
283,
24042,
356,
283,
21,
297,
283,
4471,
356,
283,
23,
297,
283,
388,
301,
279,
356,
283,
24,
936,
421,
199,
318,
31019,
8,
505,
4581,
3999,
16729,
1011,
958,
304,
272,
408,
272,
1803,
2195,
1318,
12,
27828,
315,
25600,
24348,
9479,
14,
339,
21588,
3198,
641,
314,
4252,
2368,
283,
9681,
7,
436,
283,
6856,
297,
436,
314,
4072,
402,
272,
314,
3999,
2008,
15,
513,
14,
339,
1803,
314,
12565,
775,
1233,
340,
949,
2633,
787,
1627,
14,
339,
4821,
9229,
26,
267,
283,
8399,
297,
283,
581,
297,
283,
7731,
297,
283,
14514,
297,
283,
6304,
297,
283,
5615,
21335,
297,
283,
28291,
297,
283,
7510,
7,
339,
4821,
1511,
26,
267,
283,
9771,
7,
267,
283,
21831,
7,
267,
283,
24042,
7,
267,
283,
4471,
7,
267,
283,
388,
301,
279,
7,
267,
283,
27400,
409,
7,
446,
1059,
911,
440,
506,
2599,
13,
18375,
543,
314,
12565,
775,
1233,
339,
6058,
26,
267,
31019,
360,
5006,
297,
16587,
534,
581,
297,
12994,
534,
6304,
297,
3999,
7782,
24042,
16829,
267,
31019,
342,
267,
31019,
360,
8302,
16481,
297,
3999,
7782,
21831,
16829,
267,
870,
8,
2326,
794,
360,
2246,
1004,
297,
16587,
534,
581,
297,
3999,
7782,
27400,
409,
297,
1724,
267,
870,
360,
3749,
1077,
506,
8992,
4634,
358,
267,
870,
8,
2326,
794,
360,
460,
880,
1077,
642,
1333,
267,
870,
360,
3749,
1077,
440,
506,
8992,
358,
272,
408,
272,
1233,
63,
513,
275,
942,
272,
340,
1318,
508,
2125,
436,
822,
8,
3291,
9,
508,
413,
436,
3999,
59,
16,
61,
508,
283,
3958,
356,
267,
372,
1557,
88,
17,
66,
9722,
3300,
7,
450,
12565,
775,
272,
367,
1022,
12,
373,
315,
3816,
14,
4611,
8,
958,
304,
267,
340,
1022,
508,
283,
9681,
356,
288,
1233,
63,
513,
14,
740,
8,
23801,
59,
86,
566,
267,
916,
1022,
508,
283,
6856,
356,
288,
1233,
63,
513,
14,
740,
8,
7451,
59,
86,
566,
272,
367,
312,
315,
3999,
26,
267,
340,
312,
315,
2450,
63,
807,
26,
288,
1233,
63,
513,
14,
740,
8,
2992,
63,
807,
59,
79,
566,
272,
340,
283,
27400,
409,
7,
440,
315,
3999,
26,
267,
1318,
275,
1543,
83,
60,
88,
17,
66,
9722,
3300,
7,
450,
334,
505,
503,
3260,
12565,
775,
9,
272,
372,
1543,
83,
5,
83,
7,
450,
334,
2258,
88,
17,
66,
9722,
3300,
7,
450,
30955,
904,
8,
600,
63,
513,
1826,
1318,
503,
4074,
421,
199,
318,
1852,
63,
2487,
8,
3291,
16729,
1011,
958,
304,
272,
408,
272,
1803,
282,
805,
543,
849,
2633,
367,
31019,
342,
339,
5679,
26,
267,
17268,
63,
581,
275,
1852,
63,
2487,
8,
3291,
7782,
9771,
5529,
16587,
534,
581,
358,
267,
870,
8,
9771,
63,
581,
360,
5006,
1333,
267,
9301,
5172,
275,
1852,
63,
2487,
8,
9681,
534,
14514,
358,
267,
25071,
275,
1852,
63,
2487,
8,
9681,
534,
6304,
297,
3999,
7782,
9771,
16829,
272,
408,
272,
372,
2400,
1318,
26,
31019,
8,
505,
12,
3999,
12,
1011,
958,
9,
199,
199,
2826,
7134,
63,
29586,
275,
283,
889,
2326,
7,
199,
36,
5748,
63,
29586,
275,
283,
13625,
7,
199,
21613,
63,
29586,
275,
283,
4040,
7,
199,
199,
23777,
15472,
275,
469,
272,
4825,
7134,
63,
29586,
26,
469,
267,
283,
3170,
356,
5479,
267,
283,
9171,
356,
5479,
267,
283,
4609,
4047,
356,
5479,
267,
283,
4657,
63,
8609,
356,
5479,
267,
283,
4657,
63,
3978,
2711,
356,
5479,
267,
283,
4657,
63,
17714,
356,
5479,
267,
283,
4657,
63,
8723,
356,
5479,
267,
283,
2856,
63,
4531,
356,
5479,
267,
283,
2856,
63,
12779,
356,
5479,
267,
283,
2856,
63,
19747,
356,
5479,
267,
283,
2856,
63,
4609,
63,
30389,
356,
5479,
267,
283,
2856,
63,
9439,
63,
6780,
356,
5479,
267,
283,
2856,
63,
4609,
63,
13945,
356,
5479,
267,
283,
2856,
63,
6613,
63,
3170,
356,
5479,
267,
283,
22487,
16553,
63,
5211,
1206,
356,
5479,
267,
283,
22487,
16553,
63,
13837,
356,
5479,
267,
283,
22487,
16553,
63,
12779,
356,
5479,
267,
283,
22487,
16553,
63,
13989,
356,
5479,
272,
1660,
272,
577,
5748,
63,
29586,
26,
469,
267,
283,
3170,
356,
791,
9681,
356,
283,
581,
297,
283,
3291,
356,
661,
9771,
9538,
1386,
267,
283,
9171,
356,
791,
9681,
356,
283,
14514,
297,
283,
3291,
356,
661,
9771,
9538,
1386,
267,
283,
4609,
4047,
356,
791,
9681,
356,
283,
581,
2267,
267,
283,
4657,
63,
8609,
356,
791,
9681,
356,
283,
7731,
297,
283,
3291,
356,
661,
9771,
9538,
1386,
267,
283,
4657,
63,
3978,
2711,
356,
791,
9681,
356,
283,
7731,
2267,
267,
283,
4657,
63,
17714,
356,
791,
9681,
356,
283,
14514,
2267,
267,
283,
4657,
63,
8723,
356,
791,
3291,
356,
661,
9771,
9538,
1386,
267,
283,
2856,
63,
4531,
356,
791,
3291,
356,
661,
9771,
9538,
1386,
267,
283,
2856,
63,
12779,
356,
5479,
267,
283,
2856,
63,
19747,
356,
791,
9681,
356,
283,
7731,
2267,
267,
283,
2856,
63,
4609,
63,
30389,
356,
791,
9681,
356,
283,
28291,
2267,
267,
283,
2856,
63,
9439,
63,
6780,
356,
791,
9681,
356,
283,
581,
297,
283,
3291,
356,
661,
9771,
9538,
1386,
267,
283,
2856,
63,
4609,
63,
13945,
356,
791,
9681,
356,
283,
14514,
2267,
267,
283,
2856,
63,
6613,
63,
3170,
356,
791,
9681,
356,
283,
5615,
21335,
297,
283,
3291,
356,
661,
9771,
9538,
1386,
267,
283,
22487,
16553,
63,
5211,
1206,
356,
791,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
csrocha/OpenUpgrade
|
openerp/addons/base/tests/test_uninstall.py
|
175
|
2660
|
# -*- coding: utf-8 -*-
# This assumes an existing but uninitialized database.
import unittest2
import openerp
from openerp import SUPERUSER_ID
import common
DB = common.DB
ADMIN_USER_ID = common.ADMIN_USER_ID
def registry(model):
return openerp.modules.registry.RegistryManager.get(DB)[model]
def cursor():
return openerp.modules.registry.RegistryManager.get(DB).cursor()
def get_module(module_name):
registry = openerp.modules.registry.RegistryManager.get(DB)
return registry.get(module_name)
def reload_registry():
openerp.modules.registry.RegistryManager.new(
DB, update_module=True)
def search_registry(model_name, domain):
cr = cursor()
model = registry(model_name)
record_ids = model.search(cr, SUPERUSER_ID, domain, {})
cr.close()
return record_ids
def install_module(module_name):
ir_module_module = registry('ir.module.module')
cr = cursor()
module_ids = ir_module_module.search(cr, SUPERUSER_ID,
[('name', '=', module_name)], {})
assert len(module_ids) == 1
ir_module_module.button_install(cr, SUPERUSER_ID, module_ids, {})
cr.commit()
cr.close()
reload_registry()
def uninstall_module(module_name):
ir_module_module = registry('ir.module.module')
cr = cursor()
module_ids = ir_module_module.search(cr, SUPERUSER_ID,
[('name', '=', module_name)], {})
assert len(module_ids) == 1
ir_module_module.button_uninstall(cr, SUPERUSER_ID, module_ids, {})
cr.commit()
cr.close()
reload_registry()
class test_uninstall(unittest2.TestCase):
"""
Test the install/uninstall of a test module. The module is available in
`openerp.tests` which should be present in the addons-path.
"""
def test_01_install(self):
""" Check a few things showing the module is installed. """
install_module('test_uninstall')
assert get_module('test_uninstall.model')
assert search_registry('ir.model.data',
[('module', '=', 'test_uninstall')])
assert search_registry('ir.model.fields',
[('model', '=', 'test_uninstall.model')])
def test_02_uninstall(self):
""" Check a few things showing the module is uninstalled. """
uninstall_module('test_uninstall')
assert not get_module('test_uninstall.model')
assert not search_registry('ir.model.data',
[('module', '=', 'test_uninstall')])
assert not search_registry('ir.model.fields',
[('model', '=', 'test_uninstall.model')])
if __name__ == '__main__':
unittest2.main()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
agpl-3.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
961,
15194,
376,
3411,
1325,
625,
12486,
3050,
14,
199,
646,
2882,
18,
199,
199,
646,
5166,
199,
504,
5166,
492,
12824,
63,
998,
199,
646,
2863,
199,
199,
2846,
275,
2863,
14,
2846,
199,
14288,
63,
3791,
63,
998,
275,
2863,
14,
14288,
63,
3791,
63,
998,
199,
199,
318,
7086,
8,
1238,
304,
272,
372,
5166,
14,
3112,
14,
5189,
14,
10899,
2988,
14,
362,
8,
2846,
2788,
1238,
61,
199,
199,
318,
3920,
837,
272,
372,
5166,
14,
3112,
14,
5189,
14,
10899,
2988,
14,
362,
8,
2846,
680,
3937,
342,
199,
199,
318,
664,
63,
578,
8,
578,
63,
354,
304,
272,
7086,
275,
5166,
14,
3112,
14,
5189,
14,
10899,
2988,
14,
362,
8,
2846,
9,
272,
372,
7086,
14,
362,
8,
578,
63,
354,
9,
199,
199,
318,
13101,
63,
5189,
837,
272,
5166,
14,
3112,
14,
5189,
14,
10899,
2988,
14,
1222,
8,
267,
6249,
12,
1678,
63,
578,
29,
549,
9,
199,
199,
318,
2754,
63,
5189,
8,
1238,
63,
354,
12,
2881,
304,
272,
2467,
275,
3920,
342,
272,
1402,
275,
7086,
8,
1238,
63,
354,
9,
272,
2777,
63,
1580,
275,
1402,
14,
1733,
8,
1556,
12,
12824,
63,
998,
12,
2881,
12,
5009,
272,
2467,
14,
1600,
342,
272,
372,
2777,
63,
1580,
199,
199,
318,
3907,
63,
578,
8,
578,
63,
354,
304,
272,
8190,
63,
578,
63,
578,
275,
7086,
360,
723,
14,
578,
14,
578,
358,
272,
2467,
275,
3920,
342,
272,
859,
63,
1580,
275,
8190,
63,
578,
63,
578,
14,
1733,
8,
1556,
12,
12824,
63,
998,
12,
267,
4274,
354,
297,
6291,
859,
63,
354,
4360,
5009,
272,
702,
822,
8,
578,
63,
1580,
9,
508,
413,
272,
8190,
63,
578,
63,
578,
14,
3887,
63,
3174,
8,
1556,
12,
12824,
63,
998,
12,
859,
63,
1580,
12,
5009,
272,
2467,
14,
3543,
342,
272,
2467,
14,
1600,
342,
272,
13101,
63,
5189,
342,
199,
199,
318,
22199,
63,
578,
8,
578,
63,
354,
304,
272,
8190,
63,
578,
63,
578,
275,
7086,
360,
723,
14,
578,
14,
578,
358,
272,
2467,
275,
3920,
342,
272,
859,
63,
1580,
275,
8190,
63,
578,
63,
578,
14,
1733,
8,
1556,
12,
12824,
63,
998,
12,
267,
4274,
354,
297,
6291,
859,
63,
354,
4360,
5009,
272,
702,
822,
8,
578,
63,
1580,
9,
508,
413,
272,
8190,
63,
578,
63,
578,
14,
3887,
63,
19502,
8,
1556,
12,
12824,
63,
998,
12,
859,
63,
1580,
12,
5009,
272,
2467,
14,
3543,
342,
272,
2467,
14,
1600,
342,
272,
13101,
63,
5189,
342,
199,
199,
533,
511,
63,
19502,
8,
2796,
18,
14,
1746,
304,
272,
408,
272,
1379,
314,
3907,
15,
19502,
402,
282,
511,
859,
14,
710,
859,
365,
2808,
315,
272,
658,
11267,
14,
2219,
64,
1314,
1077,
506,
3451,
315,
314,
21293,
13,
515,
14,
272,
408,
339,
347,
511,
63,
614,
63,
3174,
8,
277,
304,
267,
408,
2670,
282,
9284,
7645,
21207,
314,
859,
365,
4903,
14,
408,
267,
3907,
63,
578,
360,
396,
63,
19502,
358,
267,
702,
664,
63,
578,
360,
396,
63,
19502,
14,
1238,
358,
398,
702,
2754,
63,
5189,
360,
723,
14,
1238,
14,
576,
297,
288,
4274,
578,
297,
6291,
283,
396,
63,
19502,
2023,
398,
702,
2754,
63,
5189,
360,
723,
14,
1238,
14,
955,
297,
288,
4274,
1238,
297,
6291,
283,
396,
63,
19502,
14,
1238,
2023,
339,
347,
511,
63,
996,
63,
19502,
8,
277,
304,
267,
408,
2670,
282,
9284,
7645,
21207,
314,
859,
365,
625,
7657,
14,
408,
267,
22199,
63,
578,
360,
396,
63,
19502,
358,
267,
702,
440,
664,
63,
578,
360,
396,
63,
19502,
14,
1238,
358,
398,
702,
440,
2754,
63,
5189,
360,
723,
14,
1238,
14,
576,
297,
288,
4274,
578,
297,
6291,
283,
396,
63,
19502,
2023,
398,
702,
440,
2754,
63,
5189,
360,
723,
14,
1238,
14,
955,
297,
288,
4274,
1238,
297,
6291,
283,
396,
63,
19502,
14,
1238,
2023,
4388,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
2882,
18,
14,
973,
342,
421,
199,
3,
6695,
26,
10379,
26,
10558,
26,
6492,
29,
20,
26,
10503,
29,
20,
26,
10425,
29,
20,
26,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
961,
15194,
376,
3411,
1325,
625,
12486,
3050,
14,
199,
646,
2882,
18,
199,
199,
646,
5166,
199,
504,
5166,
492,
12824,
63,
998,
199,
646,
2863,
199,
199,
2846,
275,
2863,
14,
2846,
199,
14288,
63,
3791,
63,
998,
275,
2863,
14,
14288,
63,
3791,
63,
998,
199,
199,
318,
7086,
8,
1238,
304,
272,
372,
5166,
14,
3112,
14,
5189,
14,
10899,
2988,
14,
362,
8,
2846,
2788,
1238,
61,
199,
199,
318,
3920,
837,
272,
372,
5166,
14,
3112,
14,
5189,
14,
10899,
2988,
14,
362,
8,
2846,
680,
3937,
342,
199,
199,
318,
664,
63,
578,
8,
578,
63,
354,
304,
272,
7086,
275,
5166,
14,
3112,
14,
5189,
14,
10899,
2988,
14,
362,
8,
2846,
9,
272,
372,
7086,
14,
362,
8,
578,
63,
354,
9,
199,
199,
318,
13101,
63,
5189,
837,
272,
5166,
14,
3112,
14,
5189,
14,
10899,
2988,
14,
1222,
8,
267,
6249,
12,
1678,
63,
578,
29,
549,
9,
199,
199,
318,
2754,
63,
5189,
8,
1238,
63,
354,
12,
2881,
304,
272,
2467,
275,
3920,
342,
272,
1402,
275,
7086,
8,
1238,
63,
354,
9,
272,
2777,
63,
1580,
275,
1402,
14,
1733,
8,
1556,
12,
12824,
63,
998,
12,
2881,
12,
5009,
272,
2467,
14,
1600,
342,
272,
372,
2777,
63,
1580,
199,
199,
318,
3907,
63,
578,
8,
578,
63,
354,
304,
272,
8190,
63,
578,
63,
578,
275,
7086,
360,
723,
14,
578,
14,
578,
358,
272,
2467,
275,
3920,
342,
272,
859,
63,
1580,
275,
8190,
63,
578,
63,
578,
14,
1733,
8,
1556,
12,
12824,
63,
998,
12,
267,
4274,
354,
297,
6291,
859,
63,
354,
4360,
5009,
272,
702,
822,
8,
578,
63,
1580,
9,
508,
413,
272,
8190,
63,
578,
63,
578,
14,
3887,
63,
3174,
8,
1556,
12,
12824,
63,
998,
12,
859,
63,
1580,
12,
5009,
272,
2467,
14,
3543,
342,
272,
2467,
14,
1600,
342,
272,
13101,
63,
5189,
342,
199,
199,
318,
22199,
63,
578,
8,
578,
63,
354,
304,
272,
8190,
63,
578,
63,
578,
275,
7086,
360,
723,
14,
578,
14,
578,
358,
272,
2467,
275,
3920,
342,
272,
859,
63,
1580,
275,
8190,
63,
578,
63,
578,
14,
1733,
8,
1556,
12,
12824,
63,
998,
12,
267,
4274,
354,
297,
6291,
859,
63,
354,
4360,
5009,
272,
702,
822,
8,
578,
63,
1580,
9,
508,
413,
272,
8190,
63,
578,
63,
578,
14,
3887,
63,
19502,
8,
1556,
12,
12824,
63,
998,
12,
859,
63,
1580,
12,
5009,
272,
2467,
14,
3543,
342,
272,
2467,
14,
1600,
342,
272,
13101,
63,
5189,
342,
199,
199,
533,
511,
63,
19502,
8,
2796,
18,
14,
1746,
304,
272,
408,
272,
1379,
314,
3907,
15,
19502,
402,
282,
511,
859,
14,
710,
859,
365,
2808,
315,
272,
658,
11267,
14,
2219,
64,
1314,
1077,
506,
3451,
315,
314,
21293,
13,
515,
14,
272,
408,
339,
347,
511,
63,
614,
63,
3174,
8,
277,
304,
267,
408,
2670,
282,
9284,
7645,
21207,
314,
859,
365,
4903,
14,
408,
267,
3907,
63,
578,
360,
396,
63,
19502,
358,
267,
702,
664,
63,
578,
360,
396,
63,
19502,
14,
1238,
358,
398,
702,
2754,
63,
5189,
360,
723,
14,
1238,
14,
576,
297,
288,
4274,
578,
297,
6291,
283,
396,
63,
19502,
2023,
398,
702,
2754,
63,
5189,
360,
723,
14,
1238,
14,
955,
297,
288,
4274,
1238,
297,
6291,
283,
396,
63,
19502,
14,
1238,
2023,
339,
347,
511,
63,
996,
63,
19502,
8,
277,
304,
267,
408,
2670,
282,
9284,
7645,
21207,
314,
859,
365,
625,
7657,
14,
408,
267,
22199,
63,
578,
360,
396,
63,
19502,
358,
267,
702,
440,
664,
63,
578,
360,
396,
63,
19502,
14,
1238,
358,
398,
702,
440,
2754,
63,
5189,
360,
723,
14,
1238,
14,
576,
297,
288,
4274,
578,
297,
6291,
283,
396,
63,
19502,
2023,
398,
702,
440,
2754,
63,
5189,
360,
723,
14,
1238,
14,
955,
297,
288,
4274,
1238,
297,
6291,
283,
396,
63,
19502,
14,
1238,
2023,
4388,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
2882,
18,
14,
973,
342,
421,
199,
3,
6695,
26,
10379,
26,
10558,
26,
6492,
29,
20,
26,
10503,
29,
20,
26,
10425,
29,
20,
26,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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python
import os
import re
import sys
import pickle
import time
import traceback
import yahoo.search
from yahoo.search.web import WebSearch
APP_ID = 'P5ihFKzV34G69QolFfb3nN7p0rSsYfC9tPGq.IUS.NLWEeJ14SG9Lei0rwFtgwL8cDBrA6Egdw--'
QUERY_MODIFIERS = '-site:txdns.net -site:sitedossier.com -mx -site:dataopedia.com -site:l0t3k.net -syslog -"4.2.2.1" -site:cqcounter.com -site:flow.nttu.edu.tw -site:websiteoutlook.com -site:ipgeolocator.com -site:tdyndns.org -site:ebrara.com -site:onsamehost.com -site:ipaddresscentral.com -site:quia.jp -inetnum -site:domaintools.com -site:domainbyip.com -site:pdos.csail.mit.edu -statistics -"country name" -"Q_RTT" -site:botsvsbrowsers.com -"ptr record" -site:ip-db.com -site:chaip.com.cn -site:lookup365.com -"IP Country" -site:iptoolboxes.com -"Unknown Country" -"Q_RTT" -amerika -whois -Mozilla -site:domaincrawler.com -site:geek-tools.org -site:visualware.com -site:robtex.com -site:domaintool.se -site:opendns.se -site:ungefiltert-surfen.de -site:datakitteh.org -"SLOVAKIA (SK)" -"IP Search" -site:www.medicore.com.ua -site:dig.similarbase.com -site:ipcorporationwiki.com -site:coolwhois.com -site:corporationwiki.com -site:iptool.us'
CACHE_DIR = os.getenv('HOME') + '/.ycache'
BANNED_URL_KEYWORDS = [
'\.xls$', '\.txt$', 'spam', 'nettools', 'namebench\.cfg', 'spam', 'affinity-v1',
'corporationwiki', 'iptools', 'whois', 'iana.org', 'public.*dns', 'blocked',
'firewall', 'websitevaluespy', 'iptool', 'sshd-versions', '\.off$',
'dnsstuff', 'secspider', 'servers\.cfg'
]
def CheckPopularity(ip):
# DUH
cache_path = os.path.join(CACHE_DIR, ip) + '.pickle.pickle'
if os.path.exists(cache_path):
f = open(cache_path)
results = pickle.load(f)
else:
print "miss: %s" % ip
try:
query = '"%s" %s' % (ip, QUERY_MODIFIERS)
srch = WebSearch(APP_ID, query=query, results=50)
results = srch.parse_results()
pf = open(cache_path, 'w')
pickle.dump(results.results, pf)
pf.close()
except yahoo.search.SearchError:
print "%s failed" % (ip)
return []
use_results = []
for result in results:
reject = False
for regexp in BANNED_URL_KEYWORDS:
if re.search(regexp, result['Url'], re.I):
reject = True
if not reject:
use_results.append(result)
return use_results
def GetUrls(ip):
return [ x['Url'] for x in CheckPopularity(ip) ]
if __name__ == "__main__":
print GetUrls(sys.argv[1])
|
apache-2.0
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
646,
747,
199,
646,
295,
199,
646,
984,
199,
646,
5927,
199,
646,
900,
199,
646,
5190,
199,
646,
612,
65,
19112,
14,
1733,
199,
504,
612,
65,
19112,
14,
1733,
14,
2520,
492,
6001,
5278,
199,
199,
7121,
63,
998,
275,
283,
48,
21,
24278,
21490,
90,
54,
1082,
39,
1876,
49,
393,
38,
4675,
19,
78,
46,
23,
80,
16,
82,
32307,
57,
70,
35,
25,
84,
11115,
81,
14,
30373,
14,
14176,
5408,
69,
42,
1079,
4254,
25,
2553,
73,
16,
13057,
38,
84,
8392,
44,
24,
67,
2846,
82,
33,
22,
37,
7136,
87,
306,
7,
199,
11938,
63,
16422,
1976,
3960,
275,
2475,
2124,
26,
84,
2207,
561,
14,
846,
446,
2124,
26,
11669,
736,
338,
281,
14,
957,
446,
9457,
446,
2124,
26,
576,
13458,
2391,
14,
957,
446,
2124,
26,
76,
16,
84,
19,
75,
14,
846,
446,
16878,
446,
2,
20,
14,
18,
14,
18,
14,
17,
2,
446,
2124,
26,
26853,
5337,
14,
957,
446,
2124,
26,
1659,
14,
343,
10963,
14,
8654,
14,
8122,
446,
2124,
26,
7360,
548,
11660,
14,
957,
446,
2124,
26,
711,
6721,
6354,
14,
957,
446,
2124,
26,
2076,
89,
977,
561,
14,
1308,
446,
2124,
26,
2871,
82,
17956,
14,
957,
446,
2124,
26,
4654,
313,
1102,
14,
957,
446,
2124,
26,
21809,
16067,
14,
957,
446,
2124,
26,
783,
65,
14,
11538,
446,
10811,
1507,
446,
2124,
26,
1117,
391,
22908,
14,
957,
446,
2124,
26,
2261,
991,
711,
14,
957,
446,
2124,
26,
8961,
736,
14,
1259,
1054,
14,
1147,
14,
8654,
221,
446,
13724,
221,
446,
2,
6063,
536,
2,
446,
2,
49,
63,
50,
1481,
2,
446,
2124,
26,
3018,
2772,
83,
5750,
83,
14,
957,
446,
2,
4695,
2777,
2,
446,
2124,
26,
711,
13,
697,
14,
957,
446,
2124,
26,
9518,
711,
14,
957,
14,
6413,
446,
2124,
26,
3892,
12664,
14,
957,
446,
2,
1772,
19453,
2,
446,
2124,
26,
711,
3557,
12922,
14,
957,
446,
2,
5912,
19453,
2,
446,
2,
49,
63,
50,
1481,
2,
446,
313,
322,
7351,
446,
11345,
374,
446,
22285,
446,
2124,
26,
2261,
23972,
14,
957,
446,
2124,
26,
303,
5711,
13,
2537,
14,
1308,
446,
2124,
26,
16948,
1068,
14,
957,
446,
2124,
26,
29891,
3858,
14,
957,
446,
2124,
26,
1117,
391,
9924,
393,
14,
261,
446,
2124,
26,
411,
500,
561,
14,
261,
446,
2124,
26,
16993,
1541,
84,
13,
21579,
287,
14,
271,
446,
2124,
26,
576,
6065,
266,
72,
14,
1308,
446,
2,
51,
1484,
54,
7872,
13033,
334,
8656,
2924,
446,
2,
1772,
8730,
2,
446,
2124,
26,
1544,
14,
3700,
1018,
14,
957,
14,
1458,
446,
2124,
26,
18367,
14,
23079,
1095,
14,
957,
446,
2124,
26,
711,
989,
10633,
6797,
14,
957,
446,
2124,
26,
18499,
11345,
374,
14,
957,
446,
2124,
26,
989,
10633,
6797,
14,
957,
446,
2124,
26,
711,
3557,
14,
527,
7,
199,
8677,
63,
3022,
275,
747,
14,
12959,
360,
9524,
358,
435,
1994,
14,
89,
1637,
7,
199,
34,
879,
46,
1149,
63,
2632,
63,
32187,
275,
359,
272,
1557,
14,
19023,
4268,
1557,
14,
2424,
4268,
283,
8283,
297,
283,
846,
2537,
297,
283,
354,
16571,
4537,
4128,
297,
283,
8283,
297,
283,
15964,
13,
86,
17,
297,
272,
283,
989,
10633,
6797,
297,
283,
711,
2537,
297,
283,
11345,
374,
297,
283,
5653,
65,
14,
1308,
297,
283,
3455,
2795,
5797,
297,
283,
17726,
297,
272,
283,
10794,
297,
283,
7360,
1459,
647,
297,
283,
711,
3557,
297,
283,
5510,
68,
13,
6234,
297,
1557,
14,
1997,
4268,
272,
283,
5797,
14573,
297,
283,
3321,
12856,
297,
283,
5871,
4537,
4128,
7,
199,
61,
199,
199,
318,
2670,
9606,
22504,
8,
711,
304,
523,
327,
577,
53,
40,
523,
2581,
63,
515,
275,
747,
14,
515,
14,
904,
8,
8677,
63,
3022,
12,
3384,
9,
435,
1987,
8092,
14,
8092,
7,
523,
340,
747,
14,
515,
14,
2444,
8,
1637,
63,
515,
304,
272,
289,
275,
1551,
8,
1637,
63,
515,
9,
272,
2058,
275,
5927,
14,
912,
8,
70,
9,
523,
587,
26,
272,
870,
298,
18420,
26,
450,
83,
2,
450,
3384,
272,
862,
26,
489,
1827,
275,
18253,
83,
2,
450,
83,
7,
450,
334,
711,
12,
7813,
9418,
63,
16422,
1976,
3960,
9,
489,
11483,
335,
275,
6001,
5278,
8,
7121,
63,
998,
12,
1827,
29,
1131,
12,
2058,
29,
1400,
9,
489,
2058,
275,
11483,
335,
14,
1122,
63,
2604,
342,
489,
18258,
275,
1551,
8,
1637,
63,
515,
12,
283,
87,
358,
489,
5927,
14,
2724,
8,
2604,
14,
2604,
12,
18258,
9,
489,
18258,
14,
1600,
342,
272,
871,
612,
65,
19112,
14,
1733,
14,
5278,
547,
26,
489,
870,
2071,
83,
3405,
2,
450,
334,
711,
9,
489,
372,
942,
819,
675,
63,
2604,
275,
942,
523,
367,
754,
315,
2058,
26,
272,
17100,
275,
756,
272,
367,
13156,
315,
699,
879,
46,
1149,
63,
2632,
63,
32187,
26,
489,
340,
295,
14,
1733,
8,
11191,
12,
754,
459,
6417,
995,
295,
14,
41,
304,
267,
17100,
275,
715,
272,
340,
440,
17100,
26,
489,
675,
63,
2604,
14,
740,
8,
1099,
9,
523,
372,
675,
63,
2604,
421,
199,
318,
2372,
21867,
478,
8,
711,
304,
523,
372,
359,
671,
459,
6417,
418,
367,
671,
315,
2670,
9606,
22504,
8,
711,
9,
1622,
421,
199,
692,
636,
354,
363,
508,
4396,
973,
5727,
523,
870,
2372,
21867,
478,
8,
1274,
14,
3020,
59,
17,
566,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
646,
747,
199,
646,
295,
199,
646,
984,
199,
646,
5927,
199,
646,
900,
199,
646,
5190,
199,
646,
612,
65,
19112,
14,
1733,
199,
504,
612,
65,
19112,
14,
1733,
14,
2520,
492,
6001,
5278,
199,
199,
7121,
63,
998,
275,
283,
48,
21,
24278,
21490,
90,
54,
1082,
39,
1876,
49,
393,
38,
4675,
19,
78,
46,
23,
80,
16,
82,
32307,
57,
70,
35,
25,
84,
11115,
81,
14,
30373,
14,
14176,
5408,
69,
42,
1079,
4254,
25,
2553,
73,
16,
13057,
38,
84,
8392,
44,
24,
67,
2846,
82,
33,
22,
37,
7136,
87,
306,
7,
199,
11938,
63,
16422,
1976,
3960,
275,
2475,
2124,
26,
84,
2207,
561,
14,
846,
446,
2124,
26,
11669,
736,
338,
281,
14,
957,
446,
9457,
446,
2124,
26,
576,
13458,
2391,
14,
957,
446,
2124,
26,
76,
16,
84,
19,
75,
14,
846,
446,
16878,
446,
2,
20,
14,
18,
14,
18,
14,
17,
2,
446,
2124,
26,
26853,
5337,
14,
957,
446,
2124,
26,
1659,
14,
343,
10963,
14,
8654,
14,
8122,
446,
2124,
26,
7360,
548,
11660,
14,
957,
446,
2124,
26,
711,
6721,
6354,
14,
957,
446,
2124,
26,
2076,
89,
977,
561,
14,
1308,
446,
2124,
26,
2871,
82,
17956,
14,
957,
446,
2124,
26,
4654,
313,
1102,
14,
957,
446,
2124,
26,
21809,
16067,
14,
957,
446,
2124,
26,
783,
65,
14,
11538,
446,
10811,
1507,
446,
2124,
26,
1117,
391,
22908,
14,
957,
446,
2124,
26,
2261,
991,
711,
14,
957,
446,
2124,
26,
8961,
736,
14,
1259,
1054,
14,
1147,
14,
8654,
221,
446,
13724,
221,
446,
2,
6063,
536,
2,
446,
2,
49,
63,
50,
1481,
2,
446,
2124,
26,
3018,
2772,
83,
5750,
83,
14,
957,
446,
2,
4695,
2777,
2,
446,
2124,
26,
711,
13,
697,
14,
957,
446,
2124,
26,
9518,
711,
14,
957,
14,
6413,
446,
2124,
26,
3892,
12664,
14,
957,
446,
2,
1772,
19453,
2,
446,
2124,
26,
711,
3557,
12922,
14,
957,
446,
2,
5912,
19453,
2,
446,
2,
49,
63,
50,
1481,
2,
446,
313,
322,
7351,
446,
11345,
374,
446,
22285,
446,
2124,
26,
2261,
23972,
14,
957,
446,
2124,
26,
303,
5711,
13,
2537,
14,
1308,
446,
2124,
26,
16948,
1068,
14,
957,
446,
2124,
26,
29891,
3858,
14,
957,
446,
2124,
26,
1117,
391,
9924,
393,
14,
261,
446,
2124,
26,
411,
500,
561,
14,
261,
446,
2124,
26,
16993,
1541,
84,
13,
21579,
287,
14,
271,
446,
2124,
26,
576,
6065,
266,
72,
14,
1308,
446,
2,
51,
1484,
54,
7872,
13033,
334,
8656,
2924,
446,
2,
1772,
8730,
2,
446,
2124,
26,
1544,
14,
3700,
1018,
14,
957,
14,
1458,
446,
2124,
26,
18367,
14,
23079,
1095,
14,
957,
446,
2124,
26,
711,
989,
10633,
6797,
14,
957,
446,
2124,
26,
18499,
11345,
374,
14,
957,
446,
2124,
26,
989,
10633,
6797,
14,
957,
446,
2124,
26,
711,
3557,
14,
527,
7,
199,
8677,
63,
3022,
275,
747,
14,
12959,
360,
9524,
358,
435,
1994,
14,
89,
1637,
7,
199,
34,
879,
46,
1149,
63,
2632,
63,
32187,
275,
359,
272,
1557,
14,
19023,
4268,
1557,
14,
2424,
4268,
283,
8283,
297,
283,
846,
2537,
297,
283,
354,
16571,
4537,
4128,
297,
283,
8283,
297,
283,
15964,
13,
86,
17,
297,
272,
283,
989,
10633,
6797,
297,
283,
711,
2537,
297,
283,
11345,
374,
297,
283,
5653,
65,
14,
1308,
297,
283,
3455,
2795,
5797,
297,
283,
17726,
297,
272,
283,
10794,
297,
283,
7360,
1459,
647,
297,
283,
711,
3557,
297,
283,
5510,
68,
13,
6234,
297,
1557,
14,
1997,
4268,
272,
283,
5797,
14573,
297,
283,
3321,
12856,
297,
283,
5871,
4537,
4128,
7,
199,
61,
199,
199,
318,
2670,
9606,
22504,
8,
711,
304,
523,
327,
577,
53,
40,
523,
2581,
63,
515,
275,
747,
14,
515,
14,
904,
8,
8677,
63,
3022,
12,
3384,
9,
435,
1987,
8092,
14,
8092,
7,
523,
340,
747,
14,
515,
14,
2444,
8,
1637,
63,
515,
304,
272,
289,
275,
1551,
8,
1637,
63,
515,
9,
272,
2058,
275,
5927,
14,
912,
8,
70,
9,
523,
587,
26,
272,
870,
298,
18420,
26,
450,
83,
2,
450,
3384,
272,
862,
26,
489,
1827,
275,
18253,
83,
2,
450,
83,
7,
450,
334,
711,
12,
7813,
9418,
63,
16422,
1976,
3960,
9,
489,
11483,
335,
275,
6001,
5278,
8,
7121,
63,
998,
12,
1827,
29,
1131,
12,
2058,
29,
1400,
9,
489,
2058,
275,
11483,
335,
14,
1122,
63,
2604,
342,
489,
18258,
275,
1551,
8,
1637,
63,
515,
12,
283,
87,
358,
489,
5927,
14,
2724,
8,
2604,
14,
2604,
12,
18258,
9,
489,
18258,
14,
1600,
342,
272,
871,
612,
65,
19112,
14,
1733,
14,
5278,
547,
26,
489,
870,
2071,
83,
3405,
2,
450,
334,
711,
9,
489,
372,
942,
819,
675,
63,
2604,
275,
942,
523,
367,
754,
315,
2058,
26,
272,
17100,
275,
756,
272,
367,
13156,
315,
699,
879,
46,
1149,
63,
2632,
63,
32187,
26,
489,
340,
295,
14,
1733,
8,
11191,
12,
754,
459,
6417,
995,
295,
14,
41,
304,
267,
17100,
275,
715,
272,
340,
440,
17100,
26,
489,
675,
63,
2604,
14,
740,
8,
1099,
9,
523,
372,
675,
63,
2604,
421,
199,
318,
2372,
21867,
478,
8,
711,
304,
523,
372,
359,
671,
459,
6417,
418,
367,
671,
315,
2670,
9606,
22504,
8,
711,
9,
1622,
421,
199,
692,
636,
354,
363,
508,
4396,
973,
5727,
523,
870,
2372,
21867,
478,
8,
1274,
14,
3020,
59,
17,
566,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1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der/scheduler/filters/instance_locality_filter.py
|
25
|
5098
|
# -*- coding: utf-8 -*-
# Copyright 2014, Adrien Vergé <adrien.verge@numergy.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from oslo_log import log as logging
from oslo_utils import uuidutils
from cinder.compute import nova
from cinder import exception
from cinder.i18n import _, _LW
from cinder.openstack.common.scheduler import filters
from cinder.volume import utils as volume_utils
LOG = logging.getLogger(__name__)
HINT_KEYWORD = 'local_to_instance'
INSTANCE_HOST_PROP = 'OS-EXT-SRV-ATTR:host'
REQUESTS_TIMEOUT = 5
class InstanceLocalityFilter(filters.BaseHostFilter):
"""Schedule volume on the same host as a given instance.
This filter enables selection of a storage back-end located on the host
where the instance's hypervisor is running. This provides data locality:
the instance and the volume are located on the same physical machine.
In order to work:
- The Extended Server Attributes extension needs to be active in Nova (this
is by default), so that the 'OS-EXT-SRV-ATTR:host' property is returned
when requesting instance info.
- Either an account with privileged rights for Nova must be configured in
Cinder configuration (see 'os_privileged_user_name'), or the user making
the call needs to have sufficient rights (see
'extended_server_attributes' in Nova policy).
"""
def __init__(self):
# Cache Nova API answers directly into the Filter object.
# Since a BaseHostFilter instance lives only during the volume's
# scheduling, the cache is re-created for every new volume creation.
self._cache = {}
super(InstanceLocalityFilter, self).__init__()
def _nova_has_extended_server_attributes(self, context):
"""Check Extended Server Attributes presence
Find out whether the Extended Server Attributes extension is activated
in Nova or not. Cache the result to query Nova only once.
"""
if not hasattr(self, '_nova_ext_srv_attr'):
self._nova_ext_srv_attr = nova.API().has_extension(
context, 'ExtendedServerAttributes', timeout=REQUESTS_TIMEOUT)
return self._nova_ext_srv_attr
def host_passes(self, host_state, filter_properties):
context = filter_properties['context']
host = volume_utils.extract_host(host_state.host, 'host')
scheduler_hints = filter_properties.get('scheduler_hints') or {}
instance_uuid = scheduler_hints.get(HINT_KEYWORD, None)
# Without 'local_to_instance' hint
if not instance_uuid:
return True
if not uuidutils.is_uuid_like(instance_uuid):
raise exception.InvalidUUID(uuid=instance_uuid)
# TODO(adrienverge): Currently it is not recommended to allow instance
# migrations for hypervisors where this hint will be used. In case of
# instance migration, a previously locally-created volume will not be
# automatically migrated. Also in case of instance migration during the
# volume's scheduling, the result is unpredictable. A future
# enhancement would be to subscribe to Nova migration events (e.g. via
# Ceilometer).
# First, lookup for already-known information in local cache
if instance_uuid in self._cache:
return self._cache[instance_uuid] == host
if not self._nova_has_extended_server_attributes(context):
LOG.warning(_LW('Hint "%s" dropped because '
'ExtendedServerAttributes not active in Nova.'),
HINT_KEYWORD)
raise exception.CinderException(_('Hint "%s" not supported.') %
HINT_KEYWORD)
server = nova.API().get_server(context, instance_uuid,
privileged_user=True,
timeout=REQUESTS_TIMEOUT)
if not hasattr(server, INSTANCE_HOST_PROP):
LOG.warning(_LW('Hint "%s" dropped because Nova did not return '
'enough information. Either Nova policy needs to '
'be changed or a privileged account for Nova '
'should be specified in conf.'), HINT_KEYWORD)
raise exception.CinderException(_('Hint "%s" not supported.') %
HINT_KEYWORD)
self._cache[instance_uuid] = getattr(server, INSTANCE_HOST_PROP)
# Match if given instance is hosted on host
return self._cache[instance_uuid] == host
|
apache-2.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
1898,
6927,
12,
4431,
322,
287,
5444,
71,
5741,
665,
350,
322,
287,
14,
422,
303,
32,
10563,
82,
4312,
14,
957,
30,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
3,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
3,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
199,
504,
11258,
63,
793,
492,
943,
465,
2050,
199,
504,
11258,
63,
1208,
492,
5377,
1208,
199,
199,
504,
13069,
14,
3357,
492,
5913,
199,
504,
13069,
492,
1919,
199,
504,
13069,
14,
73,
1085,
78,
492,
5501,
485,
20145,
199,
504,
13069,
14,
8512,
14,
2330,
14,
8874,
492,
4766,
199,
504,
13069,
14,
2405,
492,
3778,
465,
3301,
63,
1208,
421,
199,
4947,
275,
2050,
14,
5572,
3460,
354,
3368,
199,
199,
32456,
63,
17714,
275,
283,
1832,
63,
475,
63,
842,
7,
199,
18235,
63,
5449,
63,
19926,
275,
283,
3100,
13,
2472,
13,
31546,
13,
5280,
26,
1102,
7,
199,
6780,
51,
63,
8899,
275,
959,
421,
199,
533,
10066,
5339,
1209,
4131,
8,
4273,
14,
1563,
4965,
4131,
304,
272,
408,
15535,
3301,
641,
314,
2011,
1591,
465,
282,
1627,
1256,
14,
339,
961,
2457,
22741,
7267,
402,
282,
4887,
1771,
13,
500,
16180,
641,
314,
1591,
272,
2382,
314,
1256,
1159,
21724,
365,
3879,
14,
961,
6571,
666,
2257,
1209,
26,
272,
314,
1256,
436,
314,
3301,
787,
16180,
641,
314,
2011,
14095,
6844,
14,
339,
1010,
1865,
370,
1736,
26,
272,
446,
710,
13706,
7146,
9382,
3329,
4839,
370,
506,
4702,
315,
28184,
334,
3749,
489,
365,
701,
849,
395,
880,
626,
314,
283,
3100,
13,
2472,
13,
31546,
13,
5280,
26,
1102,
7,
3324,
365,
2138,
489,
1380,
23502,
1256,
2256,
14,
272,
446,
13083,
376,
2933,
543,
1979,
21744,
4481,
367,
28184,
1471,
506,
7526,
315,
489,
445,
5755,
2897,
334,
3239,
283,
736,
63,
27672,
63,
751,
63,
354,
659,
503,
314,
922,
10663,
489,
314,
1240,
4839,
370,
1172,
19258,
4481,
334,
3239,
489,
283,
10525,
63,
1000,
63,
2987,
7,
315,
28184,
4592,
680,
272,
408,
339,
347,
636,
826,
721,
277,
304,
267,
327,
11977,
28184,
3261,
17133,
5370,
1901,
314,
9388,
909,
14,
267,
327,
9336,
282,
3523,
4965,
4131,
1256,
27576,
1454,
5309,
314,
3301,
1159,
267,
327,
23800,
12,
314,
2581,
365,
295,
13,
3966,
367,
4036,
892,
3301,
7143,
14,
267,
291,
423,
1637,
275,
1052,
267,
1613,
8,
3244,
5339,
1209,
4131,
12,
291,
2843,
826,
4533,
339,
347,
485,
6765,
63,
1989,
63,
10525,
63,
1000,
63,
2987,
8,
277,
12,
1067,
304,
267,
408,
1799,
13706,
7146,
9382,
20024,
398,
6668,
734,
3775,
314,
13706,
7146,
9382,
3329,
365,
22225,
267,
315,
28184,
503,
440,
14,
11977,
314,
754,
370,
1827,
28184,
1454,
5403,
14,
267,
408,
398,
340,
440,
2688,
8,
277,
12,
2513,
6765,
63,
832,
63,
15165,
63,
962,
735,
288,
291,
423,
6765,
63,
832,
63,
15165,
63,
962,
275,
5913,
14,
3735,
1252,
1989,
63,
3435,
8,
355,
1067,
12,
283,
14107,
3120,
5379,
297,
2653,
29,
6780,
51,
63,
8899,
9,
398,
372,
291,
423,
6765,
63,
832,
63,
15165,
63,
962,
339,
347,
1591,
63,
16027,
8,
277,
12,
1591,
63,
929,
12,
2457,
63,
3282,
304,
267,
1067,
275,
2457,
63,
3282,
459,
1100,
418,
267,
1591,
275,
3301,
63,
1208,
14,
5005,
63,
1102,
8,
1102,
63,
929,
14,
1102,
12,
283,
1102,
358,
398,
11899,
63,
12354,
275,
2457,
63,
3282,
14,
362,
360,
8874,
63,
12354,
358,
503,
1052,
267,
1256,
63,
2580,
275,
11899,
63,
12354,
14,
362,
8,
32456,
63,
17714,
12,
488,
9,
398,
327,
23952,
283,
1832,
63,
475,
63,
842,
7,
8328,
267,
340,
440,
1256,
63,
2580,
26,
288,
372,
715,
398,
340,
440,
5377,
1208,
14,
374,
63,
2580,
63,
2930,
8,
842,
63,
2580,
304,
288,
746,
1919,
14,
3364,
8757,
8,
2580,
29,
842,
63,
2580,
9,
398,
327,
3254,
8,
350,
322,
287,
422,
303,
304,
13550,
652,
365,
440,
14318,
370,
2040,
1256,
267,
327,
6180,
367,
10342,
27215,
2382,
642,
8328,
911,
506,
1202,
14,
1010,
1930,
402,
267,
327,
1256,
8367,
12,
282,
10889,
17738,
13,
3966,
3301,
911,
440,
506,
267,
327,
5847,
28322,
14,
6121,
315,
1930,
402,
1256,
8367,
5309,
314,
267,
327,
3301,
1159,
23800,
12,
314,
754,
365,
625,
6892,
461,
14,
437,
6466,
267,
327,
655,
14666,
434,
3955,
506,
370,
23421,
370,
28184,
8367,
4474,
334,
69,
14,
71,
14,
4799,
267,
327,
445,
69,
25617,
680,
398,
327,
7758,
12,
4237,
367,
2575,
13,
3159,
2556,
315,
2257,
2581,
267,
340,
1256,
63,
2580,
315,
291,
423,
1637,
26,
288,
372,
291,
423,
1637,
59,
842,
63,
2580,
61,
508,
1591,
398,
340,
440,
291,
423,
6765,
63,
1989,
63,
10525,
63,
1000,
63,
2987,
8,
1100,
304,
288,
5051,
14,
3764,
1547,
20145,
360,
20891,
2071,
83,
2,
17481,
2952,
283,
1169,
283,
14107,
3120,
5379,
440,
4702,
315,
28184,
8038,
717,
869,
2919,
63,
17714,
9,
288,
746,
1919,
14,
35,
5755,
1726,
6723,
20891,
2071,
83,
2,
440,
3748,
2659,
450,
4490,
869,
2919,
63,
17714,
9,
398,
1654,
275,
5913,
14,
3735,
1252,
362,
63,
1000,
8,
1100,
12,
1256,
63,
2580,
12,
4318,
1979,
21744,
63,
751,
29,
549,
12,
4318,
2653,
29,
6780,
51,
63,
8899,
9,
398,
340,
440,
2688,
8,
1000,
12,
20514,
7140,
63,
5449,
63,
19926,
304,
288,
5051,
14,
3764,
1547,
20145,
360,
20891,
2071,
83
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
1898,
6927,
12,
4431,
322,
287,
5444,
71,
5741,
665,
350,
322,
287,
14,
422,
303,
32,
10563,
82,
4312,
14,
957,
30,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
3,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
3,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
199,
504,
11258,
63,
793,
492,
943,
465,
2050,
199,
504,
11258,
63,
1208,
492,
5377,
1208,
199,
199,
504,
13069,
14,
3357,
492,
5913,
199,
504,
13069,
492,
1919,
199,
504,
13069,
14,
73,
1085,
78,
492,
5501,
485,
20145,
199,
504,
13069,
14,
8512,
14,
2330,
14,
8874,
492,
4766,
199,
504,
13069,
14,
2405,
492,
3778,
465,
3301,
63,
1208,
421,
199,
4947,
275,
2050,
14,
5572,
3460,
354,
3368,
199,
199,
32456,
63,
17714,
275,
283,
1832,
63,
475,
63,
842,
7,
199,
18235,
63,
5449,
63,
19926,
275,
283,
3100,
13,
2472,
13,
31546,
13,
5280,
26,
1102,
7,
199,
6780,
51,
63,
8899,
275,
959,
421,
199,
533,
10066,
5339,
1209,
4131,
8,
4273,
14,
1563,
4965,
4131,
304,
272,
408,
15535,
3301,
641,
314,
2011,
1591,
465,
282,
1627,
1256,
14,
339,
961,
2457,
22741,
7267,
402,
282,
4887,
1771,
13,
500,
16180,
641,
314,
1591,
272,
2382,
314,
1256,
1159,
21724,
365,
3879,
14,
961,
6571,
666,
2257,
1209,
26,
272,
314,
1256,
436,
314,
3301,
787,
16180,
641,
314,
2011,
14095,
6844,
14,
339,
1010,
1865,
370,
1736,
26,
272,
446,
710,
13706,
7146,
9382,
3329,
4839,
370,
506,
4702,
315,
28184,
334,
3749,
489,
365,
701,
849,
395,
880,
626,
314,
283,
3100,
13,
2472,
13,
31546,
13,
5280,
26,
1102,
7,
3324,
365,
2138,
489,
1380,
23502,
1256,
2256,
14,
272,
446,
13083,
376,
2933,
543,
1979,
21744,
4481,
367,
28184,
1471,
506,
7526,
315,
489,
445,
5755,
2897,
334,
3239,
283,
736,
63,
27672,
63,
751,
63,
354,
659,
503,
314,
922,
10663,
489,
314,
1240,
4839,
370,
1172,
19258,
4481,
334,
3239,
489,
283,
10525,
63,
1000,
63,
2987,
7,
315,
28184,
4592,
680,
272,
408,
339,
347,
636,
826,
721,
277,
304,
267,
327,
11977,
28184,
3261,
17133,
5370,
1901,
314,
9388,
909,
14,
267,
327,
9336,
282,
3523,
4965,
4131,
1256,
27576,
1454,
5309,
314,
3301,
1159,
267,
327,
23800,
12,
314,
2581,
365,
295,
13,
3966,
367,
4036,
892,
3301,
7143,
14,
267,
291,
423,
1637,
275,
1052,
267,
1613,
8,
3244,
5339,
1209,
4131,
12,
291,
2843,
826,
4533,
339,
347,
485,
6765,
63,
1989,
63,
10525,
63,
1000,
63,
2987,
8,
277,
12,
1067,
304,
267,
408,
1799,
13706,
7146,
9382,
20024,
398,
6668,
734,
3775,
314,
13706,
7146,
9382,
3329,
365,
22225,
267,
315,
28184,
503,
440,
14,
11977,
314,
754,
370,
1827,
28184,
1454,
5403,
14,
267,
408,
398,
340,
440,
2688,
8,
277,
12,
2513,
6765,
63,
832,
63,
15165,
63,
962,
735,
288,
291,
423,
6765,
63,
832,
63,
15165,
63,
962,
275,
5913,
14,
3735,
1252,
1989,
63,
3435,
8,
355,
1067,
12,
283,
14107,
3120,
5379,
297,
2653,
29,
6780,
51,
63,
8899,
9,
398,
372,
291,
423,
6765,
63,
832,
63,
15165,
63,
962,
339,
347,
1591,
63,
16027,
8,
277,
12,
1591,
63,
929,
12,
2457,
63,
3282,
304,
267,
1067,
275,
2457,
63,
3282,
459,
1100,
418,
267,
1591,
275,
3301,
63,
1208,
14,
5005,
63,
1102,
8,
1102,
63,
929,
14,
1102,
12,
283,
1102,
358,
398,
11899,
63,
12354,
275,
2457,
63,
3282,
14,
362,
360,
8874,
63,
12354,
358,
503,
1052,
267,
1256,
63,
2580,
275,
11899,
63,
12354,
14,
362,
8,
32456,
63,
17714,
12,
488,
9,
398,
327,
23952,
283,
1832,
63,
475,
63,
842,
7,
8328,
267,
340,
440,
1256,
63,
2580,
26,
288,
372,
715,
398,
340,
440,
5377,
1208,
14,
374,
63,
2580,
63,
2930,
8,
842,
63,
2580,
304,
288,
746,
1919,
14,
3364,
8757,
8,
2580,
29,
842,
63,
2580,
9,
398,
327,
3254,
8,
350,
322,
287,
422,
303,
304,
13550,
652,
365,
440,
14318,
370,
2040,
1256,
267,
327,
6180,
367,
10342,
27215,
2382,
642,
8328,
911,
506,
1202,
14,
1010,
1930,
402,
267,
327,
1256,
8367,
12,
282,
10889,
17738,
13,
3966,
3301,
911,
440,
506,
267,
327,
5847,
28322,
14,
6121,
315,
1930,
402,
1256,
8367,
5309,
314,
267,
327,
3301,
1159,
23800,
12,
314,
754,
365,
625,
6892,
461,
14,
437,
6466,
267,
327,
655,
14666,
434,
3955,
506,
370,
23421,
370,
28184,
8367,
4474,
334,
69,
14,
71,
14,
4799,
267,
327,
445,
69,
25617,
680,
398,
327,
7758,
12,
4237,
367,
2575,
13,
3159,
2556,
315,
2257,
2581,
267,
340,
1256,
63,
2580,
315,
291,
423,
1637,
26,
288,
372,
291,
423,
1637,
59,
842,
63,
2580,
61,
508,
1591,
398,
340,
440,
291,
423,
6765,
63,
1989,
63,
10525,
63,
1000,
63,
2987,
8,
1100,
304,
288,
5051,
14,
3764,
1547,
20145,
360,
20891,
2071,
83,
2,
17481,
2952,
283,
1169,
283,
14107,
3120,
5379,
440,
4702,
315,
28184,
8038,
717,
869,
2919,
63,
17714,
9,
288,
746,
1919,
14,
35,
5755,
1726,
6723,
20891,
2071,
83,
2,
440,
3748,
2659,
450,
4490,
869,
2919,
63,
17714,
9,
398,
1654,
275,
5913,
14,
3735,
1252,
362,
63,
1000,
8,
1100,
12,
1256,
63,
2580,
12,
4318,
1979,
21744,
63,
751,
29,
549,
12,
4318,
2653,
29,
6780,
51,
63,
8899,
9,
398,
340,
440,
2688,
8,
1000,
12,
20514,
7140,
63,
5449,
63,
19926,
304,
288,
5051,
14,
3764,
1547,
20145,
360,
20891,
2071,
83,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
driesdesmet/django-cms
|
cms/tests/page.py
|
1
|
26525
|
# -*- coding: utf-8 -*-
from __future__ import with_statement
from cms.admin.forms import PageForm
from cms.api import create_page
from cms.models import Page, Title
from cms.models.placeholdermodel import Placeholder
from cms.models.pluginmodel import CMSPlugin
from cms.plugins.text.models import Text
from cms.sitemaps import CMSSitemap
from cms.test_utils.testcases import (CMSTestCase, URL_CMS_PAGE,
URL_CMS_PAGE_ADD)
from cms.test_utils.util.context_managers import (LanguageOverride,
SettingsOverride)
from cms.utils.page_resolver import get_page_from_request
from django.conf import settings
from django.contrib.auth.models import User
from django.contrib.sites.models import Site
from django.core.urlresolvers import reverse
from django.http import HttpRequest, HttpResponse, HttpResponseNotFound
import datetime
import os.path
class PagesTestCase(CMSTestCase):
def test_add_page(self):
"""
Test that the add admin page could be displayed via the admin
"""
superuser = self.get_superuser()
with self.login_user_context(superuser):
response = self.client.get(URL_CMS_PAGE_ADD)
self.assertEqual(response.status_code, 200)
def test_create_page(self):
"""
Test that a page can be created via the admin
"""
page_data = self.get_new_page_data()
superuser = self.get_superuser()
with self.login_user_context(superuser):
response = self.client.post(URL_CMS_PAGE_ADD, page_data)
self.assertRedirects(response, URL_CMS_PAGE)
title = Title.objects.get(slug=page_data['slug'])
self.assertNotEqual(title, None)
page = title.page
page.published = True
page.save()
self.assertEqual(page.get_title(), page_data['title'])
self.assertEqual(page.get_slug(), page_data['slug'])
self.assertEqual(page.placeholders.all().count(), 2)
# were public instanes created?
title = Title.objects.drafts().get(slug=page_data['slug'])
def test_slug_collision(self):
"""
Test a slug collision
"""
page_data = self.get_new_page_data()
# create first page
superuser = self.get_superuser()
with self.login_user_context(superuser):
response = self.client.post(URL_CMS_PAGE_ADD, page_data)
self.assertRedirects(response, URL_CMS_PAGE)
#page1 = Title.objects.get(slug=page_data['slug']).page
# create page with the same page_data
response = self.client.post(URL_CMS_PAGE_ADD, page_data)
if settings.i18n_installed:
self.assertEqual(response.status_code, 302)
# did we got right redirect?
self.assertEqual(response['Location'].endswith(URL_CMS_PAGE), True)
else:
self.assertEqual(response.status_code, 200)
self.assertEqual(response['Location'].endswith(URL_CMS_PAGE_ADD), True)
# TODO: check for slug collisions after move
# TODO: check for slug collisions with different settings
def test_details_view(self):
"""
Test the details view
"""
superuser = self.get_superuser()
with self.login_user_context(superuser):
response = self.client.get(self.get_pages_root())
self.assertEqual(response.status_code, 404)
page = create_page('test page 1', "nav_playground.html", "en")
response = self.client.get(self.get_pages_root())
self.assertEqual(response.status_code, 404)
self.assertTrue(page.publish())
create_page("test page 2", "nav_playground.html", "en",
parent=page, published=True)
homepage = Page.objects.get_home()
self.assertTrue(homepage.get_slug(), 'test-page-1')
response = self.client.get(self.get_pages_root())
self.assertEqual(response.status_code, 200)
def test_edit_page(self):
"""
Test that a page can edited via the admin
"""
superuser = self.get_superuser()
with self.login_user_context(superuser):
page_data = self.get_new_page_data()
response = self.client.post(URL_CMS_PAGE_ADD, page_data)
page = Page.objects.get(title_set__slug=page_data['slug'])
response = self.client.get('/admin/cms/page/%s/' %page.id)
self.assertEqual(response.status_code, 200)
page_data['title'] = 'changed title'
response = self.client.post('/admin/cms/page/%s/' %page.id, page_data)
self.assertRedirects(response, URL_CMS_PAGE)
self.assertEqual(page.get_title(), 'changed title')
def test_meta_description_and_keywords_fields_from_admin(self):
"""
Test that description and keywords tags can be set via the admin
"""
superuser = self.get_superuser()
with self.login_user_context(superuser):
page_data = self.get_new_page_data()
page_data["meta_description"] = "I am a page"
page_data["meta_keywords"] = "page,cms,stuff"
response = self.client.post(URL_CMS_PAGE_ADD, page_data)
page = Page.objects.get(title_set__slug=page_data['slug'])
response = self.client.get('/admin/cms/page/%s/' %page.id)
self.assertEqual(response.status_code, 200)
page_data['meta_description'] = 'I am a duck'
response = self.client.post('/admin/cms/page/%s/' %page.id, page_data)
self.assertRedirects(response, URL_CMS_PAGE)
page = Page.objects.get(title_set__slug=page_data["slug"])
self.assertEqual(page.get_meta_description(), 'I am a duck')
self.assertEqual(page.get_meta_keywords(), 'page,cms,stuff')
def test_meta_description_and_keywords_from_template_tags(self):
from django import template
superuser = self.get_superuser()
with self.login_user_context(superuser):
page_data = self.get_new_page_data()
page_data["title"] = "Hello"
page_data["meta_description"] = "I am a page"
page_data["meta_keywords"] = "page,cms,stuff"
self.client.post(URL_CMS_PAGE_ADD, page_data)
page = Page.objects.get(title_set__slug=page_data['slug'])
self.client.post('/admin/cms/page/%s/' %page.id, page_data)
t = template.Template("{% load cms_tags %}{% page_attribute title %} {% page_attribute meta_description %} {% page_attribute meta_keywords %}")
req = HttpRequest()
page.published = True
page.save()
req.current_page = page
req.REQUEST = {}
self.assertEqual(t.render(template.Context({"request": req})), "Hello I am a page page,cms,stuff")
def test_copy_page(self):
"""
Test that a page can be copied via the admin
"""
page_a = create_page("page_a", "nav_playground.html", "en")
page_a_a = create_page("page_a_a", "nav_playground.html", "en",
parent=page_a)
create_page("page_a_a_a", "nav_playground.html", "en", parent=page_a_a)
page_b = create_page("page_b", "nav_playground.html", "en")
page_b_a = create_page("page_b", "nav_playground.html", "en",
parent=page_b)
count = Page.objects.drafts().count()
superuser = self.get_superuser()
with self.login_user_context(superuser):
self.copy_page(page_a, page_b_a)
self.assertEqual(Page.objects.drafts().count() - count, 3)
def test_language_change(self):
superuser = self.get_superuser()
with self.login_user_context(superuser):
page_data = self.get_new_page_data()
self.client.post(URL_CMS_PAGE_ADD, page_data)
pk = Page.objects.all()[0].pk
response = self.client.get("/admin/cms/page/%s/" % pk, {"language":"en" })
self.assertEqual(response.status_code, 200)
response = self.client.get("/admin/cms/page/%s/" % pk, {"language":"de" })
self.assertEqual(response.status_code, 200)
def test_move_page(self):
superuser = self.get_superuser()
with self.login_user_context(superuser):
page_data1 = self.get_new_page_data()
self.client.post(URL_CMS_PAGE_ADD, page_data1)
page_data2 = self.get_new_page_data()
self.client.post(URL_CMS_PAGE_ADD, page_data2)
page_data3 = self.get_new_page_data()
self.client.post(URL_CMS_PAGE_ADD, page_data3)
page1 = Page.objects.all()[0]
page2 = Page.objects.all()[1]
page3 = Page.objects.all()[2]
# move pages
response = self.client.post("/admin/cms/page/%s/move-page/" % page3.pk, {"target": page2.pk, "position": "last-child"})
self.assertEqual(response.status_code, 200)
response = self.client.post("/admin/cms/page/%s/move-page/" % page2.pk, {"target": page1.pk, "position": "last-child"})
self.assertEqual(response.status_code, 200)
# check page2 path and url
page2 = Page.objects.get(pk=page2.pk)
self.assertEqual(page2.get_path(), page_data1['slug']+"/"+page_data2['slug'])
self.assertEqual(page2.get_absolute_url(), self.get_pages_root()+page_data1['slug']+"/"+page_data2['slug']+"/")
# check page3 path and url
page3 = Page.objects.get(pk=page3.pk)
self.assertEqual(page3.get_path(), page_data1['slug']+"/"+page_data2['slug']+"/"+page_data3['slug'])
self.assertEqual(page3.get_absolute_url(), self.get_pages_root()+page_data1['slug']+"/"+page_data2['slug']+"/"+page_data3['slug']+"/")
# publish page 1 (becomes home)
page1 = Page.objects.get(pk=page1.pk)
page1.publish()
public_page1 = page1.publisher_public
self.assertEqual(public_page1.get_path(), '')
# check that page2 and page3 url have changed
page2 = Page.objects.get(pk=page2.pk)
page2.publish()
public_page2 = page2.publisher_public
self.assertEqual(public_page2.get_absolute_url(), self.get_pages_root()+page_data2['slug']+"/")
page3 = Page.objects.get(pk=page3.pk)
page3.publish()
public_page3 = page3.publisher_public
self.assertEqual(public_page3.get_absolute_url(), self.get_pages_root()+page_data2['slug']+"/"+page_data3['slug']+"/")
# move page2 back to root and check path of 2 and 3
response = self.client.post("/admin/cms/page/%s/move-page/" % page2.pk, {"target": page1.pk, "position": "right"})
self.assertEqual(response.status_code, 200)
page1 = Page.objects.get(pk=page1.pk)
self.assertEqual(page1.get_path(), page_data1['slug'])
page2 = Page.objects.get(pk=page2.pk)
self.assertEqual(page2.get_path(), page_data2['slug'])
page3 = Page.objects.get(pk=page3.pk)
self.assertEqual(page3.get_path(), page_data2['slug']+"/"+page_data3['slug'])
def test_move_page_inherit(self):
parent = create_page("Parent", 'col_three.html', "en")
child = create_page("Child", settings.CMS_TEMPLATE_INHERITANCE_MAGIC,
"en", parent=parent)
self.assertEqual(child.get_template(), parent.get_template())
child.move_page(parent, 'left')
self.assertEqual(child.get_template(), parent.get_template())
def test_add_placeholder(self):
# create page
page = create_page("Add Placeholder", "nav_playground.html", "en",
position="last-child", published=True, in_navigation=True)
page.template = 'add_placeholder.html'
page.save()
url = page.get_absolute_url()
response = self.client.get(url)
self.assertEqual(200, response.status_code)
path = os.path.join(settings.PROJECT_DIR, 'templates', 'add_placeholder.html')
f = open(path, 'r')
old = f.read()
f.close()
new = old.replace(
'<!-- SECOND_PLACEHOLDER -->',
'{% placeholder second_placeholder %}'
)
f = open(path, 'w')
f.write(new)
f.close()
response = self.client.get(url)
self.assertEqual(200, response.status_code)
f = open(path, 'w')
f.write(old)
f.close()
def test_sitemap_login_required_pages(self):
"""
Test that CMSSitemap object contains only published,public (login_required=False) pages
"""
create_page("page", "nav_playground.html", "en", login_required=True,
published=True, in_navigation=True)
self.assertEqual(CMSSitemap().items().count(),0)
def test_edit_page_other_site_and_language(self):
"""
Test that a page can edited via the admin when your current site is
different from the site you are editing and the language isn't available
for the current site.
"""
site = Site.objects.create(domain='otherlang', name='otherlang')
# Change site for this session
page_data = self.get_new_page_data()
page_data['site'] = site.pk
page_data['title'] = 'changed title'
TESTLANG = settings.CMS_SITE_LANGUAGES[site.pk][0]
page_data['language'] = TESTLANG
superuser = self.get_superuser()
with self.login_user_context(superuser):
response = self.client.post(URL_CMS_PAGE_ADD, page_data)
self.assertRedirects(response, URL_CMS_PAGE)
page = Page.objects.get(title_set__slug=page_data['slug'])
with LanguageOverride(TESTLANG):
self.assertEqual(page.get_title(), 'changed title')
def test_flat_urls(self):
with SettingsOverride(CMS_FLAT_URLS=True):
home_slug = "home"
child_slug = "child"
grandchild_slug = "grandchild"
home = create_page(home_slug, "nav_playground.html", "en",
published=True, in_navigation=True)
home.publish()
child = create_page(child_slug, "nav_playground.html", "en",
parent=home, published=True, in_navigation=True)
child.publish()
grandchild = create_page(grandchild_slug, "nav_playground.html", "en",
parent=child, published=True, in_navigation=True)
grandchild.publish()
response = self.client.get(home.get_absolute_url())
self.assertEqual(response.status_code, 200)
response = self.client.get(child.get_absolute_url())
self.assertEqual(response.status_code, 200)
response = self.client.get(grandchild.get_absolute_url())
self.assertEqual(response.status_code, 200)
self.assertFalse(child.get_absolute_url() in grandchild.get_absolute_url())
def test_templates(self):
"""
Test the inheritance magic for templates
"""
parent = create_page("parent", "nav_playground.html", "en")
child = create_page("child", "nav_playground.html", "en", parent=parent)
child.template = settings.CMS_TEMPLATE_INHERITANCE_MAGIC
child.save()
self.assertEqual(child.template, settings.CMS_TEMPLATE_INHERITANCE_MAGIC)
self.assertEqual(parent.get_template_name(), child.get_template_name())
parent.template = settings.CMS_TEMPLATE_INHERITANCE_MAGIC
parent.save()
self.assertEqual(parent.template, settings.CMS_TEMPLATE_INHERITANCE_MAGIC)
self.assertEqual(parent.get_template(), settings.CMS_TEMPLATES[0][0])
self.assertEqual(parent.get_template_name(), settings.CMS_TEMPLATES[0][1])
def test_delete_with_plugins(self):
"""
Check that plugins and placeholders get correctly deleted when we delete
a page!
"""
page = create_page("page", "nav_playground.html", "en")
page.rescan_placeholders() # create placeholders
placeholder = page.placeholders.all()[0]
plugin_base = CMSPlugin(
plugin_type='TextPlugin',
placeholder=placeholder,
position=1,
language=settings.LANGUAGES[0][0]
)
plugin_base.insert_at(None, position='last-child', save=False)
plugin = Text(body='')
plugin_base.set_base_attr(plugin)
plugin.save()
self.assertEqual(CMSPlugin.objects.count(), 1)
self.assertEqual(Text.objects.count(), 1)
self.assertTrue(Placeholder.objects.count() > 0)
page.delete()
self.assertEqual(CMSPlugin.objects.count(), 0)
self.assertEqual(Text.objects.count(), 0)
self.assertEqual(Placeholder.objects.count(), 0)
def test_get_page_from_request_on_non_cms_admin(self):
request = self.get_request(
reverse('admin:sampleapp_category_change', args=(1,))
)
page = get_page_from_request(request)
self.assertEqual(page, None)
def test_get_page_from_request_on_cms_admin(self):
page = create_page("page", "nav_playground.html", "en")
request = self.get_request(
reverse('admin:cms_page_change', args=(page.pk,))
)
found_page = get_page_from_request(request)
self.assertTrue(found_page)
self.assertEqual(found_page.pk, page.pk)
def test_get_page_from_request_on_cms_admin_nopage(self):
request = self.get_request(
reverse('admin:cms_page_change', args=(1,))
)
page = get_page_from_request(request)
self.assertEqual(page, None)
def test_get_page_from_request_cached(self):
mock_page = 'hello world'
request = self.get_request(
reverse('admin:sampleapp_category_change', args=(1,))
)
request._current_page_cache = mock_page
page = get_page_from_request(request)
self.assertEqual(page, mock_page)
def test_get_page_from_request_nopage(self):
request = self.get_request('/')
page = get_page_from_request(request)
self.assertEqual(page, None)
def test_get_page_from_request_with_page_404(self):
page = create_page("page", "nav_playground.html", "en", published=True)
page.publish()
request = self.get_request('/does-not-exist/')
found_page = get_page_from_request(request)
self.assertEqual(found_page, None)
def test_get_page_from_request_with_page_preview(self):
page = create_page("page", "nav_playground.html", "en")
request = self.get_request('%s?preview' % page.get_absolute_url())
request.user.is_staff = False
found_page = get_page_from_request(request)
self.assertEqual(found_page, None)
superuser = self.get_superuser()
with self.login_user_context(superuser):
request = self.get_request('%s?preview&draft' % page.get_absolute_url())
found_page = get_page_from_request(request)
self.assertTrue(found_page)
self.assertEqual(found_page.pk, page.pk)
def test_get_page_from_request_on_cms_admin_with_editplugin(self):
page = create_page("page", "nav_playground.html", "en")
request = self.get_request(
reverse('admin:cms_page_change', args=(page.pk,)) + 'edit-plugin/42/'
)
found_page = get_page_from_request(request)
self.assertTrue(found_page)
self.assertEqual(found_page.pk, page.pk)
def test_get_page_from_request_on_cms_admin_with_editplugin_nopage(self):
request = self.get_request(
reverse('admin:cms_page_change', args=(1,)) + 'edit-plugin/42/'
)
page = get_page_from_request(request)
self.assertEqual(page, None)
def test_page_already_expired(self):
"""
Test that a page which has a end date in the past gives a 404, not a
500.
"""
yesterday = datetime.date.today() - datetime.timedelta(days=1)
with SettingsOverride(CMS_MODERATOR=False, CMS_PERMISSION=False):
page = create_page('page', 'nav_playground.html', 'en',
publication_end_date=yesterday, published=True)
resp = self.client.get(page.get_absolute_url('en'))
self.assertEqual(resp.status_code, 404)
def test_existing_overwrite_url(self):
with SettingsOverride(CMS_MODERATOR=False, CMS_PERMISSION=False):
create_page('home', 'nav_playground.html', 'en', published=True)
create_page('boo', 'nav_playground.html', 'en', published=True)
data = {
'title': 'foo',
'overwrite_url': '/boo/',
'slug': 'foo',
'language': 'en',
'template': 'nav_playground.html',
'site': 1,
}
form = PageForm(data)
self.assertFalse(form.is_valid())
self.assertTrue('overwrite_url' in form.errors)
def test_page_urls(self):
page1 = create_page('test page 1', 'nav_playground.html', 'en',
published=True)
page2 = create_page('test page 2', 'nav_playground.html', 'en',
published=True, parent=page1)
page3 = create_page('test page 3', 'nav_playground.html', 'en',
published=True, parent=page2)
page4 = create_page('test page 4', 'nav_playground.html', 'en',
published=True)
page5 = create_page('test page 5', 'nav_playground.html', 'en',
published=True, parent=page4)
self.assertEqual(page1.get_absolute_url(),
self.get_pages_root()+'')
self.assertEqual(page2.get_absolute_url(),
self.get_pages_root()+'test-page-2/')
self.assertEqual(page3.get_absolute_url(),
self.get_pages_root()+'test-page-2/test-page-3/')
self.assertEqual(page4.get_absolute_url(),
self.get_pages_root()+'test-page-4/')
self.assertEqual(page5.get_absolute_url(),
self.get_pages_root()+'test-page-4/test-page-5/')
page3 = self.move_page(page3, page1)
self.assertEqual(page3.get_absolute_url(),
self.get_pages_root()+'test-page-3/')
page5 = self.move_page(page5, page2)
self.assertEqual(page5.get_absolute_url(),
self.get_pages_root()+'test-page-2/test-page-5/')
page3 = self.move_page(page3, page4)
self.assertEqual(page3.get_absolute_url(),
self.get_pages_root()+'test-page-4/test-page-3/')
def test_home_slug_not_accessible(self):
with SettingsOverride(CMS_MODERATOR=False, CMS_PERMISSION=False):
page = create_page('page', 'nav_playground.html', 'en', published=True)
self.assertEqual(page.get_absolute_url('en'), '/')
resp = self.client.get('/en/')
self.assertEqual(resp.status_code, HttpResponse.status_code)
resp = self.client.get('/en/page/')
self.assertEqual(resp.status_code, HttpResponseNotFound.status_code)
def test_public_home_page_replaced(self):
"""Test that publishing changes to the home page doesn't move the public version"""
home = create_page('home', 'nav_playground.html', 'en', published = True, slug = 'home')
self.assertEqual(Page.objects.drafts().get_home().get_slug(), 'home')
home.publish()
self.assertEqual(Page.objects.public().get_home().get_slug(), 'home')
other = create_page('other', 'nav_playground.html', 'en', published = True, slug = 'other')
other.publish()
self.assertEqual(Page.objects.drafts().get_home().get_slug(), 'home')
self.assertEqual(Page.objects.public().get_home().get_slug(), 'home')
home = Page.objects.get(pk = home.id)
home.in_navigation = True
home.save()
home.publish()
self.assertEqual(Page.objects.drafts().get_home().get_slug(), 'home')
self.assertEqual(Page.objects.public().get_home().get_slug(), 'home')
class NoAdminPageTests(CMSTestCase):
urls = 'project.noadmin_urls'
def setUp(self):
admin = 'django.contrib.admin'
noadmin_apps = [app for app in settings.INSTALLED_APPS if not app == admin]
self._ctx = SettingsOverride(INSTALLED_APPS=noadmin_apps)
self._ctx.__enter__()
def tearDown(self):
self._ctx.__exit__(None, None, None)
def test_get_page_from_request_fakeadmin_nopage(self):
request = self.get_request('/admin/')
page = get_page_from_request(request)
self.assertEqual(page, None)
class PreviousFilteredSiblingsTests(CMSTestCase):
def test_with_publisher(self):
home = create_page('home', 'nav_playground.html', 'en', published=True)
home.publish()
other = create_page('other', 'nav_playground.html', 'en', published=True)
other.publish()
other = Page.objects.get(pk=other.pk)
home = Page.objects.get(pk=home.pk)
self.assertEqual(other.get_previous_filtered_sibling(), home)
self.assertEqual(home.get_previous_filtered_sibling(), None)
def test_multisite(self):
firstsite = Site.objects.create(name='first', domain='first.com')
secondsite = Site.objects.create(name='second', domain='second.com')
home = create_page('home', 'nav_playground.html', 'en', published=True, site=firstsite)
home.publish()
other = create_page('other', 'nav_playground.html', 'en', published=True, site=secondsite)
other.publish()
other = Page.objects.get(pk=other.pk)
home = Page.objects.get(pk=home.pk)
self.assertEqual(other.get_previous_filtered_sibling(), None)
self.assertEqual(home.get_previous_filtered_sibling(), None)
|
bsd-3-clause
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
504,
636,
2443,
363,
492,
543,
63,
6242,
199,
504,
19240,
14,
2113,
14,
3351,
492,
10331,
2821,
199,
504,
19240,
14,
1246,
492,
1218,
63,
1606,
199,
504,
19240,
14,
992,
492,
10331,
12,
16881,
199,
504,
19240,
14,
992,
14,
6199,
1238,
492,
10902,
4302,
199,
504,
19240,
14,
992,
14,
2718,
1238,
492,
29554,
5061,
199,
504,
19240,
14,
5265,
14,
505,
14,
992,
492,
4516,
199,
504,
19240,
14,
30515,
492,
445,
45,
2300,
1175,
1130,
199,
504,
19240,
14,
396,
63,
1208,
14,
396,
9403,
492,
334,
17834,
1746,
12,
2851,
63,
17834,
63,
12898,
12,
5591,
2851,
63,
17834,
63,
12898,
63,
9732,
9,
199,
504,
19240,
14,
396,
63,
1208,
14,
1974,
14,
1100,
63,
16259,
492,
334,
8493,
11954,
12,
5591,
13303,
11954,
9,
199,
504,
19240,
14,
1208,
14,
1606,
63,
7717,
492,
664,
63,
1606,
63,
504,
63,
1069,
199,
504,
1639,
14,
2190,
492,
2202,
199,
504,
1639,
14,
2828,
14,
1178,
14,
992,
492,
2876,
199,
504,
1639,
14,
2828,
14,
8619,
14,
992,
492,
11666,
199,
504,
1639,
14,
1018,
14,
16522,
492,
3837,
199,
504,
1639,
14,
1014,
492,
20730,
12,
6183,
12,
6183,
4667,
199,
646,
2197,
199,
646,
747,
14,
515,
199,
199,
533,
510,
7441,
1746,
8,
17834,
1746,
304,
2286,
347,
511,
63,
525,
63,
1606,
8,
277,
304,
267,
408,
267,
1379,
626,
314,
1050,
4628,
2034,
4293,
506,
9080,
4799,
314,
4628,
267,
408,
267,
32590,
275,
291,
14,
362,
63,
11434,
342,
267,
543,
291,
14,
2886,
63,
751,
63,
1100,
8,
11434,
304,
288,
1177,
275,
291,
14,
1258,
14,
362,
8,
2632,
63,
17834,
63,
12898,
63,
9732,
9,
288,
291,
14,
629,
8,
1310,
14,
1205,
63,
600,
12,
1926,
9,
339,
347,
511,
63,
981,
63,
1606,
8,
277,
304,
267,
408,
267,
1379,
626,
282,
2034,
883,
506,
2737,
4799,
314,
4628,
267,
408,
267,
2034,
63,
576,
275,
291,
14,
362,
63,
1222,
63,
1606,
63,
576,
342,
398,
32590,
275,
291,
14,
362,
63,
11434,
342,
267,
543,
291,
14,
2886,
63,
751,
63,
1100,
8,
11434,
304,
288,
1177,
275,
291,
14,
1258,
14,
1932,
8,
2632,
63,
17834,
63,
12898,
63,
9732,
12,
2034,
63,
576,
9,
288,
291,
14,
17466,
8,
1310,
12,
2851,
63,
17834,
63,
12898,
9,
288,
2538,
275,
16881,
14,
1462,
14,
362,
8,
5464,
29,
1606,
63,
576,
459,
5464,
1105,
288,
291,
14,
7418,
8,
1213,
12,
488,
9,
288,
2034,
275,
2538,
14,
1606,
288,
2034,
14,
8987,
275,
715,
288,
2034,
14,
2117,
342,
288,
291,
14,
629,
8,
1606,
14,
362,
63,
1213,
1062,
2034,
63,
576,
459,
1213,
1105,
288,
291,
14,
629,
8,
1606,
14,
362,
63,
5464,
1062,
2034,
63,
576,
459,
5464,
1105,
288,
291,
14,
629,
8,
1606,
14,
22100,
14,
452,
1252,
835,
1062,
499,
9,
7846,
327,
4898,
4575,
2727,
290,
397,
2737,
31,
288,
2538,
275,
16881,
14,
1462,
14,
7185,
83,
1252,
362,
8,
5464,
29,
1606,
63,
576,
459,
5464,
1105,
199,
5493,
347,
511,
63,
5464,
63,
761,
23656,
8,
277,
304,
267,
408,
267,
1379,
282,
8889,
25061,
267,
408,
267,
2034,
63,
576,
275,
291,
14,
362,
63,
1222,
63,
1606,
63,
576,
342,
267,
327,
1218,
1642,
2034,
267,
32590,
275,
291,
14,
362,
63,
11434,
342,
267,
543,
291,
14,
2886,
63,
751,
63,
1100,
8,
11434,
304,
288,
1177,
275,
291,
14,
1258,
14,
1932,
8,
2632,
63,
17834,
63,
12898,
63,
9732,
12,
2034,
63,
576,
9,
288,
291,
14,
17466,
8,
1310,
12,
2851,
63,
17834,
63,
12898,
9,
7846,
327,
1606,
17,
275,
16881,
14,
1462,
14,
362,
8,
5464,
29,
1606,
63,
576,
459,
5464,
13227,
1606,
288,
327,
1218,
2034,
543,
314,
2011,
2034,
63,
576,
7846,
1177,
275,
291,
14,
1258,
14,
1932,
8,
2632,
63,
17834,
63,
12898,
63,
9732,
12,
2034,
63,
576,
9,
7846,
340,
2202,
14,
73,
1085,
78,
63,
7657,
26,
355,
291,
14,
629,
8,
1310,
14,
1205,
63,
600,
12,
11485,
9,
355,
327,
8103,
781,
4788,
2451,
4660,
31,
355,
291,
14,
629,
8,
1310,
459,
6592,
2278,
4130,
8,
2632,
63,
17834,
63,
12898,
395,
715,
9,
288,
587,
26,
355,
291,
14,
629,
8,
1310,
14,
1205,
63,
600,
12,
1926,
9,
355,
291,
14,
629,
8,
1310,
459,
6592,
2278,
4130,
8,
2632,
63,
17834,
63,
12898,
63,
9732,
395,
715,
9,
288,
327,
3254,
26,
1104,
367,
8889,
30063,
2410,
4057,
288,
327,
3254,
26,
1104,
367,
8889,
30063,
543,
3365,
2202,
3515,
2043,
272,
347,
511,
63,
5087,
63,
1345,
8,
277,
304,
267,
408,
267,
1379,
314,
2436,
2455,
267,
408,
267,
32590,
275,
291,
14,
362,
63,
11434,
342,
267,
543,
291,
14,
2886,
63,
751,
63,
1100,
8,
11434,
304,
288,
1177,
275,
291,
14,
1258,
14,
362,
8,
277,
14,
362,
63,
5856,
63,
1231,
1012,
288,
291,
14,
629,
8,
1310,
14,
1205,
63,
600,
12,
7901,
9,
288,
2034,
275,
1218,
63,
1606,
360,
396,
2034,
413,
297,
298,
10927,
63,
2802,
3928,
14,
1360,
401,
298,
287,
531,
288,
1177,
275,
291,
14,
1258,
14,
362,
8,
277,
14,
362,
63,
5856,
63,
1231,
1012,
288,
291,
14,
629,
8,
1310,
14,
1205,
63,
600,
12,
7901,
9,
288,
291,
14,
1815,
8,
1606,
14,
4763,
1012,
288,
1218,
63,
1606,
480,
396,
2034,
499,
401,
298,
10927,
63,
2802,
3928,
14,
1360,
401,
298,
287,
401,
221,
5644,
1676,
29,
1606,
12,
3267,
29,
549,
9,
288,
26586,
275,
10331,
14,
1462,
14,
362,
63,
4219,
342,
288,
291,
14,
1815,
8,
25539,
14,
362,
63,
5464,
1062,
283,
396,
13,
1606,
13,
17,
358,
288,
1177,
275,
291,
14,
1258,
14,
362,
8,
277,
14,
362,
63,
5856,
63,
1231,
1012,
288,
291,
14,
629,
8,
1310,
14,
1205,
63,
600,
12,
1926,
9,
339,
347,
511,
63,
3773,
63,
1606,
8,
277,
304,
267,
408,
267,
1379,
626,
282,
2034,
883,
21062,
4799,
314,
4628,
267,
408,
267,
32590,
275
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
504,
636,
2443,
363,
492,
543,
63,
6242,
199,
504,
19240,
14,
2113,
14,
3351,
492,
10331,
2821,
199,
504,
19240,
14,
1246,
492,
1218,
63,
1606,
199,
504,
19240,
14,
992,
492,
10331,
12,
16881,
199,
504,
19240,
14,
992,
14,
6199,
1238,
492,
10902,
4302,
199,
504,
19240,
14,
992,
14,
2718,
1238,
492,
29554,
5061,
199,
504,
19240,
14,
5265,
14,
505,
14,
992,
492,
4516,
199,
504,
19240,
14,
30515,
492,
445,
45,
2300,
1175,
1130,
199,
504,
19240,
14,
396,
63,
1208,
14,
396,
9403,
492,
334,
17834,
1746,
12,
2851,
63,
17834,
63,
12898,
12,
5591,
2851,
63,
17834,
63,
12898,
63,
9732,
9,
199,
504,
19240,
14,
396,
63,
1208,
14,
1974,
14,
1100,
63,
16259,
492,
334,
8493,
11954,
12,
5591,
13303,
11954,
9,
199,
504,
19240,
14,
1208,
14,
1606,
63,
7717,
492,
664,
63,
1606,
63,
504,
63,
1069,
199,
504,
1639,
14,
2190,
492,
2202,
199,
504,
1639,
14,
2828,
14,
1178,
14,
992,
492,
2876,
199,
504,
1639,
14,
2828,
14,
8619,
14,
992,
492,
11666,
199,
504,
1639,
14,
1018,
14,
16522,
492,
3837,
199,
504,
1639,
14,
1014,
492,
20730,
12,
6183,
12,
6183,
4667,
199,
646,
2197,
199,
646,
747,
14,
515,
199,
199,
533,
510,
7441,
1746,
8,
17834,
1746,
304,
2286,
347,
511,
63,
525,
63,
1606,
8,
277,
304,
267,
408,
267,
1379,
626,
314,
1050,
4628,
2034,
4293,
506,
9080,
4799,
314,
4628,
267,
408,
267,
32590,
275,
291,
14,
362,
63,
11434,
342,
267,
543,
291,
14,
2886,
63,
751,
63,
1100,
8,
11434,
304,
288,
1177,
275,
291,
14,
1258,
14,
362,
8,
2632,
63,
17834,
63,
12898,
63,
9732,
9,
288,
291,
14,
629,
8,
1310,
14,
1205,
63,
600,
12,
1926,
9,
339,
347,
511,
63,
981,
63,
1606,
8,
277,
304,
267,
408,
267,
1379,
626,
282,
2034,
883,
506,
2737,
4799,
314,
4628,
267,
408,
267,
2034,
63,
576,
275,
291,
14,
362,
63,
1222,
63,
1606,
63,
576,
342,
398,
32590,
275,
291,
14,
362,
63,
11434,
342,
267,
543,
291,
14,
2886,
63,
751,
63,
1100,
8,
11434,
304,
288,
1177,
275,
291,
14,
1258,
14,
1932,
8,
2632,
63,
17834,
63,
12898,
63,
9732,
12,
2034,
63,
576,
9,
288,
291,
14,
17466,
8,
1310,
12,
2851,
63,
17834,
63,
12898,
9,
288,
2538,
275,
16881,
14,
1462,
14,
362,
8,
5464,
29,
1606,
63,
576,
459,
5464,
1105,
288,
291,
14,
7418,
8,
1213,
12,
488,
9,
288,
2034,
275,
2538,
14,
1606,
288,
2034,
14,
8987,
275,
715,
288,
2034,
14,
2117,
342,
288,
291,
14,
629,
8,
1606,
14,
362,
63,
1213,
1062,
2034,
63,
576,
459,
1213,
1105,
288,
291,
14,
629,
8,
1606,
14,
362,
63,
5464,
1062,
2034,
63,
576,
459,
5464,
1105,
288,
291,
14,
629,
8,
1606,
14,
22100,
14,
452,
1252,
835,
1062,
499,
9,
7846,
327,
4898,
4575,
2727,
290,
397,
2737,
31,
288,
2538,
275,
16881,
14,
1462,
14,
7185,
83,
1252,
362,
8,
5464,
29,
1606,
63,
576,
459,
5464,
1105,
199,
5493,
347,
511,
63,
5464,
63,
761,
23656,
8,
277,
304,
267,
408,
267,
1379,
282,
8889,
25061,
267,
408,
267,
2034,
63,
576,
275,
291,
14,
362,
63,
1222,
63,
1606,
63,
576,
342,
267,
327,
1218,
1642,
2034,
267,
32590,
275,
291,
14,
362,
63,
11434,
342,
267,
543,
291,
14,
2886,
63,
751,
63,
1100,
8,
11434,
304,
288,
1177,
275,
291,
14,
1258,
14,
1932,
8,
2632,
63,
17834,
63,
12898,
63,
9732,
12,
2034,
63,
576,
9,
288,
291,
14,
17466,
8,
1310,
12,
2851,
63,
17834,
63,
12898,
9,
7846,
327,
1606,
17,
275,
16881,
14,
1462,
14,
362,
8,
5464,
29,
1606,
63,
576,
459,
5464,
13227,
1606,
288,
327,
1218,
2034,
543,
314,
2011,
2034,
63,
576,
7846,
1177,
275,
291,
14,
1258,
14,
1932,
8,
2632,
63,
17834,
63,
12898,
63,
9732,
12,
2034,
63,
576,
9,
7846,
340,
2202,
14,
73,
1085,
78,
63,
7657,
26,
355,
291,
14,
629,
8,
1310,
14,
1205,
63,
600,
12,
11485,
9,
355,
327,
8103,
781,
4788,
2451,
4660,
31,
355,
291,
14,
629,
8,
1310,
459,
6592,
2278,
4130,
8,
2632,
63,
17834,
63,
12898,
395,
715,
9,
288,
587,
26,
355,
291,
14,
629,
8,
1310,
14,
1205,
63,
600,
12,
1926,
9,
355,
291,
14,
629,
8,
1310,
459,
6592,
2278,
4130,
8,
2632,
63,
17834,
63,
12898,
63,
9732,
395,
715,
9,
288,
327,
3254,
26,
1104,
367,
8889,
30063,
2410,
4057,
288,
327,
3254,
26,
1104,
367,
8889,
30063,
543,
3365,
2202,
3515,
2043,
272,
347,
511,
63,
5087,
63,
1345,
8,
277,
304,
267,
408,
267,
1379,
314,
2436,
2455,
267,
408,
267,
32590,
275,
291,
14,
362,
63,
11434,
342,
267,
543,
291,
14,
2886,
63,
751,
63,
1100,
8,
11434,
304,
288,
1177,
275,
291,
14,
1258,
14,
362,
8,
277,
14,
362,
63,
5856,
63,
1231,
1012,
288,
291,
14,
629,
8,
1310,
14,
1205,
63,
600,
12,
7901,
9,
288,
2034,
275,
1218,
63,
1606,
360,
396,
2034,
413,
297,
298,
10927,
63,
2802,
3928,
14,
1360,
401,
298,
287,
531,
288,
1177,
275,
291,
14,
1258,
14,
362,
8,
277,
14,
362,
63,
5856,
63,
1231,
1012,
288,
291,
14,
629,
8,
1310,
14,
1205,
63,
600,
12,
7901,
9,
288,
291,
14,
1815,
8,
1606,
14,
4763,
1012,
288,
1218,
63,
1606,
480,
396,
2034,
499,
401,
298,
10927,
63,
2802,
3928,
14,
1360,
401,
298,
287,
401,
221,
5644,
1676,
29,
1606,
12,
3267,
29,
549,
9,
288,
26586,
275,
10331,
14,
1462,
14,
362,
63,
4219,
342,
288,
291,
14,
1815,
8,
25539,
14,
362,
63,
5464,
1062,
283,
396,
13,
1606,
13,
17,
358,
288,
1177,
275,
291,
14,
1258,
14,
362,
8,
277,
14,
362,
63,
5856,
63,
1231,
1012,
288,
291,
14,
629,
8,
1310,
14,
1205,
63,
600,
12,
1926,
9,
339,
347,
511,
63,
3773,
63,
1606,
8,
277,
304,
267,
408,
267,
1379,
626,
282,
2034,
883,
21062,
4799,
314,
4628,
267,
408,
267,
32590,
275,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
ge0rgi/cinder
|
cinder/tests/unit/test_volume.py
|
1
|
340029
|
# Copyright 2010 United States Government as represented by the
# Administrator of the National Aeronautics and Space Administration.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
"""Tests for Volume Code."""
import datetime
import ddt
import os
import shutil
import sys
import tempfile
import time
import uuid
import enum
import eventlet
import mock
import os_brick
from oslo_concurrency import processutils
from oslo_config import cfg
from oslo_serialization import jsonutils
from oslo_utils import imageutils
from oslo_utils import importutils
from oslo_utils import timeutils
from oslo_utils import units
import six
from taskflow.engines.action_engine import engine
from cinder.api import common
from cinder.brick.local_dev import lvm as brick_lvm
from cinder.common import constants
from cinder import context
from cinder import coordination
from cinder import db
from cinder import exception
from cinder.image import image_utils
from cinder import keymgr as key_manager
from cinder.message import defined_messages
from cinder.message import resource_types
from cinder import objects
from cinder.objects import fields
import cinder.policy
from cinder import quota
from cinder import test
from cinder.tests import fake_driver
from cinder.tests.unit.api import fakes
from cinder.tests.unit.brick import fake_lvm
from cinder.tests.unit import conf_fixture
from cinder.tests.unit import fake_constants as fake
from cinder.tests.unit import fake_service
from cinder.tests.unit import fake_snapshot
from cinder.tests.unit import fake_volume
from cinder.tests.unit.image import fake as fake_image
from cinder.tests.unit.keymgr import fake as fake_keymgr
from cinder.tests.unit import utils as tests_utils
from cinder.tests.unit import volume as base
from cinder import utils
import cinder.volume
from cinder.volume import api as volume_api
from cinder.volume import configuration as conf
from cinder.volume import driver
from cinder.volume.flows.manager import create_volume as create_volume_manager
from cinder.volume import manager as vol_manager
from cinder.volume import rpcapi as volume_rpcapi
import cinder.volume.targets.tgt
from cinder.volume import utils as volutils
from cinder.volume import volume_types
QUOTAS = quota.QUOTAS
CONF = cfg.CONF
ENCRYPTION_PROVIDER = 'nova.volume.encryptors.cryptsetup.CryptsetupEncryptor'
fake_opt = [
cfg.StrOpt('fake_opt1', default='fake', help='fake opts')
]
OVER_SNAPSHOT_QUOTA_EXCEPTION = exception.OverQuota(
overs=['snapshots'],
usages = {'snapshots': {'reserved': 1, 'in_use': 9}},
quotas = {'gigabytes': 10, 'snapshots': 10})
def create_snapshot(volume_id, size=1, metadata=None, ctxt=None,
**kwargs):
"""Create a snapshot object."""
metadata = metadata or {}
snap = objects.Snapshot(ctxt or context.get_admin_context())
snap.volume_size = size
snap.user_id = kwargs.get('user_id', fake.USER_ID)
snap.project_id = kwargs.get('project_id', fake.PROJECT_ID)
snap.volume_id = volume_id
snap.status = "creating"
if metadata is not None:
snap.metadata = metadata
snap.update(kwargs)
snap.create()
return snap
class FakeImageService(object):
def __init__(self, db_driver=None, image_service=None):
pass
def show(self, context, image_id):
return {'size': 2 * units.Gi,
'disk_format': 'raw',
'container_format': 'bare',
'status': 'active'}
class AvailabilityZoneTestCase(base.BaseVolumeTestCase):
def setUp(self):
super(AvailabilityZoneTestCase, self).setUp()
self.get_all = self.patch(
'cinder.db.service_get_all', autospec=True,
return_value = [{'availability_zone': 'a', 'disabled': False}])
def test_list_availability_zones_cached(self):
azs = self.volume_api.list_availability_zones(enable_cache=True)
self.assertEqual([{"name": 'a', 'available': True}], list(azs))
self.assertIsNotNone(self.volume_api.availability_zones_last_fetched)
self.assertTrue(self.get_all.called)
self.volume_api.list_availability_zones(enable_cache=True)
self.assertEqual(1, self.get_all.call_count)
def test_list_availability_zones_no_cached(self):
azs = self.volume_api.list_availability_zones(enable_cache=False)
self.assertEqual([{"name": 'a', 'available': True}], list(azs))
self.assertIsNone(self.volume_api.availability_zones_last_fetched)
self.get_all.return_value[0]['disabled'] = True
azs = self.volume_api.list_availability_zones(enable_cache=False)
self.assertEqual([{"name": 'a', 'available': False}], list(azs))
self.assertIsNone(self.volume_api.availability_zones_last_fetched)
@mock.patch('oslo_utils.timeutils.utcnow')
def test_list_availability_zones_refetched(self, mock_utcnow):
mock_utcnow.return_value = datetime.datetime.utcnow()
azs = self.volume_api.list_availability_zones(enable_cache=True)
self.assertEqual([{"name": 'a', 'available': True}], list(azs))
self.assertIsNotNone(self.volume_api.availability_zones_last_fetched)
last_fetched = self.volume_api.availability_zones_last_fetched
self.assertTrue(self.get_all.called)
self.volume_api.list_availability_zones(enable_cache=True)
self.assertEqual(1, self.get_all.call_count)
# The default cache time is 3600, push past that...
mock_utcnow.return_value = (timeutils.utcnow() +
datetime.timedelta(0, 3800))
self.get_all.return_value = [
{
'availability_zone': 'a',
'disabled': False,
},
{
'availability_zone': 'b',
'disabled': False,
},
]
azs = self.volume_api.list_availability_zones(enable_cache=True)
azs = sorted([n['name'] for n in azs])
self.assertEqual(['a', 'b'], azs)
self.assertEqual(2, self.get_all.call_count)
self.assertGreater(self.volume_api.availability_zones_last_fetched,
last_fetched)
mock_utcnow.assert_called_with()
def test_list_availability_zones_enabled_service(self):
def sort_func(obj):
return obj['name']
self.get_all.return_value = [
{'availability_zone': 'ping', 'disabled': 0},
{'availability_zone': 'ping', 'disabled': 1},
{'availability_zone': 'pong', 'disabled': 0},
{'availability_zone': 'pung', 'disabled': 1},
]
volume_api = cinder.volume.api.API()
azs = volume_api.list_availability_zones()
azs = sorted(azs, key=sort_func)
expected = sorted([
{'name': 'pung', 'available': False},
{'name': 'pong', 'available': True},
{'name': 'ping', 'available': True},
], key=sort_func)
self.assertEqual(expected, azs)
@ddt.ddt
class VolumeTestCase(base.BaseVolumeTestCase):
def setUp(self):
super(VolumeTestCase, self).setUp()
self.patch('cinder.volume.utils.clear_volume', autospec=True)
self.expected_status = 'available'
self.service_id = 1
self.user_context = context.RequestContext(user_id=fake.USER_ID,
project_id=fake.PROJECT_ID)
@mock.patch('cinder.manager.CleanableManager.init_host')
def test_init_host_count_allocated_capacity(self, init_host_mock):
vol0 = tests_utils.create_volume(
self.context, size=100, host=CONF.host)
vol1 = tests_utils.create_volume(
self.context, size=128,
host=volutils.append_host(CONF.host, 'pool0'))
vol2 = tests_utils.create_volume(
self.context, size=256,
host=volutils.append_host(CONF.host, 'pool0'))
vol3 = tests_utils.create_volume(
self.context, size=512,
host=volutils.append_host(CONF.host, 'pool1'))
vol4 = tests_utils.create_volume(
self.context, size=1024,
host=volutils.append_host(CONF.host, 'pool2'))
self.volume.init_host(service_id=self.service_id)
init_host_mock.assert_called_once_with(
service_id=self.service_id, added_to_cluster=None)
stats = self.volume.stats
self.assertEqual(2020, stats['allocated_capacity_gb'])
self.assertEqual(
384, stats['pools']['pool0']['allocated_capacity_gb'])
self.assertEqual(
512, stats['pools']['pool1']['allocated_capacity_gb'])
self.assertEqual(
1024, stats['pools']['pool2']['allocated_capacity_gb'])
# NOTE(jdg): On the create we have host='xyz', BUT
# here we do a db.volume_get, and now the host has
# been updated to xyz#pool-name. Note this is
# done via the managers init, which calls the drivers
# get_pool method, which in the legacy case is going
# to be volume_backend_name or None
vol0.refresh()
expected_host = volutils.append_host(CONF.host, 'fake')
self.assertEqual(expected_host, vol0.host)
self.volume.delete_volume(self.context, vol0)
self.volume.delete_volume(self.context, vol1)
self.volume.delete_volume(self.context, vol2)
self.volume.delete_volume(self.context, vol3)
self.volume.delete_volume(self.context, vol4)
@mock.patch('cinder.manager.CleanableManager.init_host')
def test_init_host_count_allocated_capacity_cluster(self, init_host_mock):
cluster_name = 'mycluster'
self.volume.cluster = cluster_name
# All these volumes belong to the same cluster, so we will calculate
# the capacity of them all because we query the DB by cluster_name.
tests_utils.create_volume(self.context, size=100, host=CONF.host,
cluster_name=cluster_name)
tests_utils.create_volume(
self.context, size=128, cluster_name=cluster_name,
host=volutils.append_host(CONF.host, 'pool0'))
tests_utils.create_volume(
self.context, size=256, cluster_name=cluster_name,
host=volutils.append_host(CONF.host + '2', 'pool0'))
tests_utils.create_volume(
self.context, size=512, cluster_name=cluster_name,
host=volutils.append_host(CONF.host + '2', 'pool1'))
tests_utils.create_volume(
self.context, size=1024, cluster_name=cluster_name,
host=volutils.append_host(CONF.host + '3', 'pool2'))
# These don't belong to the cluster so they will be ignored
tests_utils.create_volume(
self.context, size=1024,
host=volutils.append_host(CONF.host, 'pool2'))
tests_utils.create_volume(
self.context, size=1024, cluster_name=cluster_name + '1',
host=volutils.append_host(CONF.host + '3', 'pool2'))
self.volume.init_host(service_id=self.service_id)
init_host_mock.assert_called_once_with(
service_id=self.service_id, added_to_cluster=None)
stats = self.volume.stats
self.assertEqual(2020, stats['allocated_capacity_gb'])
self.assertEqual(
384, stats['pools']['pool0']['allocated_capacity_gb'])
self.assertEqual(
512, stats['pools']['pool1']['allocated_capacity_gb'])
self.assertEqual(
1024, stats['pools']['pool2']['allocated_capacity_gb'])
@mock.patch.object(driver.BaseVD, "update_provider_info")
def test_init_host_sync_provider_info(self, mock_update):
vol0 = tests_utils.create_volume(
self.context, size=1, host=CONF.host)
vol1 = tests_utils.create_volume(
self.context, size=1, host=CONF.host)
vol2 = tests_utils.create_volume(
self.context, size=1, host=CONF.host, status='creating')
snap0 = tests_utils.create_snapshot(self.context, vol0.id)
snap1 = tests_utils.create_snapshot(self.context, vol1.id)
# Return values for update_provider_info
volumes = [{'id': vol0.id, 'provider_id': '1 2 xxxx'},
{'id': vol1.id, 'provider_id': '3 4 yyyy'}]
snapshots = [{'id': snap0.id, 'provider_id': '5 6 xxxx'},
{'id': snap1.id, 'provider_id': '7 8 yyyy'}]
mock_update.return_value = (volumes, snapshots)
# initialize
self.volume.init_host(service_id=self.service_id)
# Grab volume and snapshot objects
vol0_obj = objects.Volume.get_by_id(context.get_admin_context(),
vol0.id)
vol1_obj = objects.Volume.get_by_id(context.get_admin_context(),
vol1.id)
vol2_obj = objects.Volume.get_by_id(context.get_admin_context(),
vol2.id)
snap0_obj = objects.Snapshot.get_by_id(self.context, snap0.id)
snap1_obj = objects.Snapshot.get_by_id(self.context, snap1.id)
# Check updated provider ids
self.assertEqual('1 2 xxxx', vol0_obj.provider_id)
self.assertEqual('3 4 yyyy', vol1_obj.provider_id)
self.assertIsNone(vol2_obj.provider_id)
self.assertEqual('5 6 xxxx', snap0_obj.provider_id)
self.assertEqual('7 8 yyyy', snap1_obj.provider_id)
# Clean up
self.volume.delete_snapshot(self.context, snap0_obj)
self.volume.delete_snapshot(self.context, snap1_obj)
self.volume.delete_volume(self.context, vol0)
self.volume.delete_volume(self.context, vol1)
@mock.patch.object(driver.BaseVD, "update_provider_info")
def test_init_host_sync_provider_info_no_update(self, mock_update):
vol0 = tests_utils.create_volume(
self.context, size=1, host=CONF.host)
vol1 = tests_utils.create_volume(
self.context, size=1, host=CONF.host)
snap0 = tests_utils.create_snapshot(self.context, vol0.id)
snap1 = tests_utils.create_snapshot(self.context, vol1.id)
mock_update.return_value = ([], [])
# initialize
self.volume.init_host(service_id=self.service_id)
# Grab volume and snapshot objects
vol0_obj = objects.Volume.get_by_id(context.get_admin_context(),
vol0.id)
vol1_obj = objects.Volume.get_by_id(context.get_admin_context(),
vol1.id)
snap0_obj = objects.Snapshot.get_by_id(self.context, snap0.id)
snap1_obj = objects.Snapshot.get_by_id(self.context, snap1.id)
# Check provider ids are not changed
self.assertIsNone(vol0_obj.provider_id)
self.assertIsNone(vol1_obj.provider_id)
self.assertIsNone(snap0_obj.provider_id)
self.assertIsNone(snap1_obj.provider_id)
# Clean up
self.volume.delete_snapshot(self.context, snap0_obj)
self.volume.delete_snapshot(self.context, snap1_obj)
self.volume.delete_volume(self.context, vol0)
self.volume.delete_volume(self.context, vol1)
@mock.patch.object(driver.BaseVD, "update_provider_info")
def test_init_host_sync_provider_info_no_update_cluster(self, mock_update):
cluster_name = 'mycluster'
self.volume.cluster = cluster_name
vol0 = tests_utils.create_volume(
self.context, size=1, host=CONF.host, cluster_name=cluster_name)
vol1 = tests_utils.create_volume(
self.context, size=1, host=CONF.host + '2',
cluster_name=cluster_name)
vol2 = tests_utils.create_volume(
self.context, size=1, host=CONF.host)
vol3 = tests_utils.create_volume(
self.context, size=1, host=CONF.host,
cluster_name=cluster_name + '2')
snap0 = tests_utils.create_snapshot(self.context, vol0.id)
snap1 = tests_utils.create_snapshot(self.context, vol1.id)
tests_utils.create_snapshot(self.context, vol2.id)
tests_utils.create_snapshot(self.context, vol3.id)
mock_update.return_value = ([], [])
# initialize
self.volume.init_host(service_id=self.service_id)
# Grab volume and snapshot objects
vol0_obj = objects.Volume.get_by_id(context.get_admin_context(),
vol0.id)
vol1_obj = objects.Volume.get_by_id(context.get_admin_context(),
vol1.id)
snap0_obj = objects.Snapshot.get_by_id(self.context, snap0.id)
snap1_obj = objects.Snapshot.get_by_id(self.context, snap1.id)
self.assertSetEqual({vol0.id, vol1.id},
{vol.id for vol in mock_update.call_args[0][0]})
self.assertSetEqual({snap0.id, snap1.id},
{snap.id for snap in mock_update.call_args[0][1]})
# Check provider ids are not changed
self.assertIsNone(vol0_obj.provider_id)
self.assertIsNone(vol1_obj.provider_id)
self.assertIsNone(snap0_obj.provider_id)
self.assertIsNone(snap1_obj.provider_id)
# Clean up
self.volume.delete_snapshot(self.context, snap0_obj)
self.volume.delete_snapshot(self.context, snap1_obj)
self.volume.delete_volume(self.context, vol0)
self.volume.delete_volume(self.context, vol1)
@mock.patch('cinder.volume.manager.VolumeManager.'
'_include_resources_in_cluster')
def test_init_host_cluster_not_changed(self, include_in_cluster_mock):
self.volume.init_host(added_to_cluster=False,
service_id=self.service_id)
include_in_cluster_mock.assert_not_called()
@mock.patch('cinder.objects.snapshot.SnapshotList.get_all',
return_value=[])
@mock.patch('cinder.objects.volume.VolumeList.get_all', return_value=[])
@mock.patch('cinder.objects.volume.VolumeList.include_in_cluster')
@mock.patch('cinder.objects.consistencygroup.ConsistencyGroupList.'
'include_in_cluster')
@mock.patch('cinder.db.image_volume_cache_include_in_cluster')
def test_init_host_added_to_cluster(self, image_cache_include_mock,
cg_include_mock,
vol_include_mock, vol_get_all_mock,
snap_get_all_mock):
cluster = str(mock.sentinel.cluster)
self.mock_object(self.volume, 'cluster', cluster)
self.volume.init_host(added_to_cluster=True,
service_id=self.service_id)
vol_include_mock.assert_called_once_with(mock.ANY, cluster,
host=self.volume.host)
cg_include_mock.assert_called_once_with(mock.ANY, cluster,
host=self.volume.host)
image_cache_include_mock.assert_called_once_with(mock.ANY, cluster,
host=self.volume.host)
vol_get_all_mock.assert_called_once_with(
mock.ANY, filters={'cluster_name': cluster})
snap_get_all_mock.assert_called_once_with(
mock.ANY, filters={'cluster_name': cluster})
@mock.patch('cinder.objects.service.Service.get_minimum_rpc_version')
@mock.patch('cinder.objects.service.Service.get_minimum_obj_version')
@mock.patch('cinder.rpc.LAST_RPC_VERSIONS', {'cinder-scheduler': '1.3'})
@mock.patch('cinder.rpc.LAST_OBJ_VERSIONS', {'cinder-scheduler': '1.4'})
def test_reset(self, get_min_obj, get_min_rpc):
vol_mgr = vol_manager.VolumeManager()
scheduler_rpcapi = vol_mgr.scheduler_rpcapi
self.assertEqual('1.3', scheduler_rpcapi.client.version_cap)
self.assertEqual('1.4',
scheduler_rpcapi.client.serializer._base.version_cap)
get_min_obj.return_value = objects.base.OBJ_VERSIONS.get_current()
vol_mgr.reset()
scheduler_rpcapi = vol_mgr.scheduler_rpcapi
self.assertEqual(get_min_rpc.return_value,
scheduler_rpcapi.client.version_cap)
self.assertEqual(get_min_obj.return_value,
scheduler_rpcapi.client.serializer._base.version_cap)
self.assertIsNone(scheduler_rpcapi.client.serializer._base.manifest)
@mock.patch.object(vol_manager.VolumeManager,
'update_service_capabilities')
def test_report_filter_goodness_function(self, mock_update):
manager = vol_manager.VolumeManager()
manager.driver.set_initialized()
myfilterfunction = "myFilterFunction"
mygoodnessfunction = "myGoodnessFunction"
expected = {'name': 'cinder-volumes',
'filter_function': myfilterfunction,
'goodness_function': mygoodnessfunction,
}
with mock.patch.object(manager.driver,
'get_volume_stats') as m_get_stats:
with mock.patch.object(manager.driver,
'get_goodness_function') as m_get_goodness:
with mock.patch.object(manager.driver,
'get_filter_function') as m_get_filter:
m_get_stats.return_value = {'name': 'cinder-volumes'}
m_get_filter.return_value = myfilterfunction
m_get_goodness.return_value = mygoodnessfunction
manager._report_driver_status(1)
self.assertTrue(m_get_stats.called)
mock_update.assert_called_once_with(expected)
def test_is_working(self):
# By default we have driver mocked to be initialized...
self.assertTrue(self.volume.is_working())
# ...lets switch it and check again!
self.volume.driver._initialized = False
self.assertFalse(self.volume.is_working())
@mock.patch('cinder.tests.unit.fake_notifier.FakeNotifier._notify')
@mock.patch.object(QUOTAS, 'reserve')
@mock.patch.object(QUOTAS, 'commit')
@mock.patch.object(QUOTAS, 'rollback')
def test_create_driver_not_initialized(self, reserve, commit, rollback,
mock_notify):
self.volume.driver._initialized = False
def fake_reserve(context, expire=None, project_id=None, **deltas):
return ["RESERVATION"]
def fake_commit_and_rollback(context, reservations, project_id=None):
pass
reserve.return_value = fake_reserve
commit.return_value = fake_commit_and_rollback
rollback.return_value = fake_commit_and_rollback
volume = tests_utils.create_volume(
self.context,
availability_zone=CONF.storage_availability_zone,
**self.volume_params)
volume_id = volume['id']
self.assertIsNone(volume['encryption_key_id'])
mock_notify.assert_not_called()
self.assertRaises(exception.DriverNotInitialized,
self.volume.create_volume, self.context, volume)
volume = db.volume_get(context.get_admin_context(), volume_id)
self.assertEqual("error", volume.status)
db.volume_destroy(context.get_admin_context(), volume_id)
def test_create_driver_not_initialized_rescheduling(self):
self.volume.driver._initialized = False
mock_delete = self.mock_object(self.volume.driver, 'delete_volume')
volume = tests_utils.create_volume(
self.context,
availability_zone=CONF.storage_availability_zone,
**self.volume_params)
volume_id = volume['id']
self.assertRaises(exception.DriverNotInitialized,
self.volume.create_volume,
self.context, volume,
{'volume_properties': self.volume_params},
{'retry': {'num_attempts': 1, 'host': []}})
# NOTE(dulek): Volume should be rescheduled as we passed request_spec
# and filter_properties, assert that it wasn't counted in
# allocated_capacity tracking.
self.assertEqual({}, self.volume.stats['pools'])
# NOTE(dulek): As we've rescheduled, make sure delete_volume was
# called.
self.assertTrue(mock_delete.called)
db.volume_destroy(context.get_admin_context(), volume_id)
def test_create_non_cinder_exception_rescheduling(self):
params = self.volume_params
del params['host']
volume = tests_utils.create_volume(
self.context,
availability_zone=CONF.storage_availability_zone,
**params)
volume_id = volume['id']
with mock.patch.object(self.volume.driver, 'create_volume',
side_effect=processutils.ProcessExecutionError):
self.assertRaises(processutils.ProcessExecutionError,
self.volume.create_volume,
self.context, volume,
{'volume_properties': params},
{'retry': {'num_attempts': 1, 'host': []}})
# NOTE(dulek): Volume should be rescheduled as we passed request_spec
# and filter_properties, assert that it wasn't counted in
# allocated_capacity tracking.
self.assertEqual({}, self.volume.stats['pools'])
db.volume_destroy(context.get_admin_context(), volume_id)
@mock.patch('cinder.tests.unit.fake_notifier.FakeNotifier._notify')
@mock.patch.object(QUOTAS, 'rollback')
@mock.patch.object(QUOTAS, 'commit')
@mock.patch.object(QUOTAS, 'reserve')
def test_delete_driver_not_initialized(self, reserve, commit, rollback,
mock_notify):
self.volume.driver._initialized = False
def fake_reserve(context, expire=None, project_id=None, **deltas):
return ["RESERVATION"]
def fake_commit_and_rollback(context, reservations, project_id=None):
pass
reserve.return_value = fake_reserve
commit.return_value = fake_commit_and_rollback
rollback.return_value = fake_commit_and_rollback
volume = tests_utils.create_volume(
self.context,
availability_zone=CONF.storage_availability_zone,
**self.volume_params)
self.assertIsNone(volume['encryption_key_id'])
mock_notify.assert_not_called()
self.assertRaises(exception.DriverNotInitialized,
self.volume.delete_volume, self.context, volume)
volume = objects.Volume.get_by_id(self.context, volume.id)
self.assertEqual("error_deleting", volume.status)
volume.destroy()
@mock.patch('cinder.tests.unit.fake_notifier.FakeNotifier._notify')
@mock.patch('cinder.quota.QUOTAS.rollback', new=mock.Mock())
@mock.patch('cinder.quota.QUOTAS.commit', new=mock.Mock())
@mock.patch('cinder.quota.QUOTAS.reserve', return_value=['RESERVATION'])
def test_create_delete_volume(self, _mock_reserve, mock_notify):
"""Test volume can be created and deleted."""
volume = tests_utils.create_volume(
self.context,
availability_zone=CONF.storage_availability_zone,
**self.volume_params)
volume_id = volume['id']
mock_notify.assert_not_called()
self.assertIsNone(volume['encryption_key_id'])
self.volume.create_volume(self.context, volume)
self.assert_notify_called(mock_notify,
(['INFO', 'volume.create.start'],
['INFO', 'volume.create.end']))
self.volume.delete_volume(self.context, volume)
vol = db.volume_get(context.get_admin_context(read_deleted='yes'),
volume_id)
self.assertEqual(vol['status'], 'deleted')
self.assert_notify_called(mock_notify,
(['INFO', 'volume.create.start'],
['INFO', 'volume.create.end'],
['INFO', 'volume.delete.start'],
['INFO', 'volume.delete.end']))
self.assertRaises(exception.NotFound,
db.volume_get,
self.context,
volume_id)
def test_create_delete_volume_with_metadata(self):
"""Test volume can be created with metadata and deleted."""
test_meta = {'fake_key': 'fake_value'}
volume = tests_utils.create_volume(self.context, metadata=test_meta,
**self.volume_params)
volume_id = volume['id']
self.volume.create_volume(self.context, volume)
self.assertEqual(test_meta, volume.metadata)
self.volume.delete_volume(self.context, volume)
self.assertRaises(exception.NotFound,
db.volume_get,
self.context,
volume_id)
def test_delete_volume_frozen(self):
service = tests_utils.create_service(self.context, {'frozen': True})
volume = tests_utils.create_volume(self.context, host=service.host)
self.assertRaises(exception.InvalidInput,
self.volume_api.delete, self.context, volume)
def test_delete_snapshot_frozen(self):
service = tests_utils.create_service(self.context, {'frozen': True})
volume = tests_utils.create_volume(self.context, host=service.host)
snapshot = tests_utils.create_snapshot(self.context, volume.id)
self.assertRaises(exception.InvalidInput,
self.volume_api.delete_snapshot, self.context,
snapshot)
@ddt.data('create_snapshot', 'create_snapshot_force')
def test_create_snapshot_frozen(self, method):
service = tests_utils.create_service(self.context, {'frozen': True})
volume = tests_utils.create_volume(self.context, host=service.host)
method = getattr(self.volume_api, method)
self.assertRaises(exception.InvalidInput,
method, self.context, volume, 'name', 'desc')
def test_delete_volume_another_cluster_fails(self):
"""Test delete of volume from another cluster fails."""
self.volume.cluster = 'mycluster'
volume = tests_utils.create_volume(self.context, status='available',
size=1, host=CONF.host + 'fake',
cluster_name=self.volume.cluster)
self.volume.delete_volume(self.context, volume)
self.assertRaises(exception.NotFound,
db.volume_get,
self.context,
volume.id)
@mock.patch('cinder.db.volume_metadata_update')
def test_create_volume_metadata(self, metadata_update):
metadata = {'fake_key': 'fake_value'}
metadata_update.return_value = metadata
volume = tests_utils.create_volume(self.context, **self.volume_params)
res = self.volume_api.create_volume_metadata(self.context,
volume, metadata)
metadata_update.assert_called_once_with(self.context, volume.id,
metadata, False,
common.METADATA_TYPES.user)
self.assertEqual(metadata, res)
@ddt.data('maintenance', 'uploading')
def test_create_volume_metadata_maintenance(self, status):
metadata = {'fake_key': 'fake_value'}
volume = tests_utils.create_volume(self.context, **self.volume_params)
volume['status'] = status
self.assertRaises(exception.InvalidVolume,
self.volume_api.create_volume_metadata,
self.context,
volume,
metadata)
def test_update_volume_metadata_with_metatype(self):
"""Test update volume metadata with different metadata type."""
test_meta1 = {'fake_key1': 'fake_value1'}
test_meta2 = {'fake_key1': 'fake_value2'}
FAKE_METADATA_TYPE = enum.Enum('METADATA_TYPES', 'fake_type')
volume = tests_utils.create_volume(self.context, metadata=test_meta1,
**self.volume_params)
self.volume.create_volume(self.context, volume)
# update user metadata associated with the volume.
result_meta = self.volume_api.update_volume_metadata(
self.context,
volume,
test_meta2,
False,
common.METADATA_TYPES.user)
self.assertEqual(test_meta2, result_meta)
# create image metadata associated with the volume.
result_meta = self.volume_api.update_volume_metadata(
self.context,
volume,
test_meta1,
False,
common.METADATA_TYPES.image)
self.assertEqual(test_meta1, result_meta)
# update image metadata associated with the volume.
result_meta = self.volume_api.update_volume_metadata(
self.context,
volume,
test_meta2,
False,
common.METADATA_TYPES.image)
self.assertEqual(test_meta2, result_meta)
# update volume metadata with invalid metadta type.
self.assertRaises(exception.InvalidMetadataType,
self.volume_api.update_volume_metadata,
self.context,
volume,
test_meta1,
False,
FAKE_METADATA_TYPE.fake_type)
def test_update_volume_metadata_maintenance(self):
"""Test update volume metadata with different metadata type."""
test_meta1 = {'fake_key1': 'fake_value1'}
FAKE_METADATA_TYPE = enum.Enum('METADATA_TYPES', 'fake_type')
volume = tests_utils.create_volume(self.context, metadata=test_meta1,
**self.volume_params)
volume['status'] = 'maintenance'
self.assertRaises(exception.InvalidVolume,
self.volume_api.update_volume_metadata,
self.context,
volume,
test_meta1,
False,
FAKE_METADATA_TYPE.fake_type)
@mock.patch('cinder.db.volume_update')
def test_update_with_ovo(self, volume_update):
"""Test update volume using oslo_versionedobject."""
volume = tests_utils.create_volume(self.context, **self.volume_params)
updates = {'display_name': 'foobbar'}
self.volume_api.update(self.context, volume, updates)
volume_update.assert_called_once_with(self.context, volume.id,
updates)
self.assertEqual('foobbar', volume.display_name)
def test_delete_volume_metadata_with_metatype(self):
"""Test delete volume metadata with different metadata type."""
test_meta1 = {'fake_key1': 'fake_value1', 'fake_key2': 'fake_value2'}
test_meta2 = {'fake_key1': 'fake_value1'}
FAKE_METADATA_TYPE = enum.Enum('METADATA_TYPES', 'fake_type')
volume = tests_utils.create_volume(self.context, metadata=test_meta1,
**self.volume_params)
volume_id = volume['id']
self.volume.create_volume(self.context, volume)
# delete user metadata associated with the volume.
self.volume_api.delete_volume_metadata(
self.context,
volume,
'fake_key2',
common.METADATA_TYPES.user)
self.assertEqual(test_meta2,
db.volume_metadata_get(self.context, volume_id))
# create image metadata associated with the volume.
result_meta = self.volume_api.update_volume_metadata(
self.context,
volume,
test_meta1,
False,
common.METADATA_TYPES.image)
self.assertEqual(test_meta1, result_meta)
# delete image metadata associated with the volume.
self.volume_api.delete_volume_metadata(
self.context,
volume,
'fake_key2',
common.METADATA_TYPES.image)
# parse the result to build the dict.
rows = db.volume_glance_metadata_get(self.context, volume_id)
result = {}
for row in rows:
result[row['key']] = row['value']
self.assertEqual(test_meta2, result)
# delete volume metadata with invalid metadta type.
self.assertRaises(exception.InvalidMetadataType,
self.volume_api.delete_volume_metadata,
self.context,
volume,
'fake_key1',
FAKE_METADATA_TYPE.fake_type)
def test_delete_volume_metadata_maintenance(self):
"""Test delete volume metadata in maintenance."""
FAKE_METADATA_TYPE = enum.Enum('METADATA_TYPES', 'fake_type')
test_meta1 = {'fake_key1': 'fake_value1', 'fake_key2': 'fake_value2'}
volume = tests_utils.create_volume(self.context, metadata=test_meta1,
**self.volume_params)
volume['status'] = 'maintenance'
self.assertRaises(exception.InvalidVolume,
self.volume_api.delete_volume_metadata,
self.context,
volume,
'fake_key1',
FAKE_METADATA_TYPE.fake_type)
def test_volume_attach_in_maintenance(self):
"""Test attach the volume in maintenance."""
test_meta1 = {'fake_key1': 'fake_value1', 'fake_key2': 'fake_value2'}
volume = tests_utils.create_volume(self.context, metadata=test_meta1,
**self.volume_params)
volume['status'] = 'maintenance'
self.assertRaises(exception.InvalidVolume,
self.volume_api.attach,
self.context,
volume, None, None, None, None)
def test_volume_detach_in_maintenance(self):
"""Test detach the volume in maintenance."""
test_meta1 = {'fake_key1': 'fake_value1', 'fake_key2': 'fake_value2'}
volume = tests_utils.create_volume(self.context, metadata=test_meta1,
**self.volume_params)
volume['status'] = 'maintenance'
volume_api = cinder.volume.api.API()
self.assertRaises(exception.InvalidVolume,
volume_api.detach,
self.context,
volume, None)
def test_initialize_connection_maintenance(self):
"""Test initialize connection in maintenance."""
test_meta1 = {'fake_key1': 'fake_value1', 'fake_key2': 'fake_value2'}
volume = tests_utils.create_volume(self.context, metadata=test_meta1,
**self.volume_params)
volume['status'] = 'maintenance'
volume_api = cinder.volume.api.API()
self.assertRaises(exception.InvalidVolume,
volume_api.initialize_connection,
self.context,
volume,
None)
def test_accept_transfer_maintenance(self):
"""Test accept transfer in maintenance."""
test_meta1 = {'fake_key1': 'fake_value1', 'fake_key2': 'fake_value2'}
volume = tests_utils.create_volume(self.context, metadata=test_meta1,
**self.volume_params)
volume['status'] = 'maintenance'
volume_api = cinder.volume.api.API()
self.assertRaises(exception.InvalidVolume,
volume_api.accept_transfer,
self.context,
volume,
None, None)
def test_copy_volume_to_image_maintenance(self):
"""Test copy volume to image in maintenance."""
test_meta1 = {'fake_key1': 'fake_value1', 'fake_key2': 'fake_value2'}
volume = tests_utils.create_volume(self.context, metadata=test_meta1,
**self.volume_params)
volume['status'] = 'maintenance'
volume_api = cinder.volume.api.API()
self.assertRaises(exception.InvalidVolume,
volume_api.copy_volume_to_image,
self.context,
volume,
test_meta1,
force=True)
@mock.patch.object(cinder.volume.api.API, 'list_availability_zones')
def test_create_volume_uses_default_availability_zone(self, mock_list_az):
"""Test setting availability_zone correctly during volume create."""
mock_list_az.return_value = ({'name': 'az1', 'available': True},
{'name': 'az2', 'available': True},
{'name': 'default-az', 'available': True})
volume_api = cinder.volume.api.API()
# Test backwards compatibility, default_availability_zone not set
self.override_config('storage_availability_zone', 'az2')
volume = volume_api.create(self.context,
1,
'name',
'description')
self.assertEqual('az2', volume['availability_zone'])
self.override_config('default_availability_zone', 'default-az')
volume = volume_api.create(self.context,
1,
'name',
'description')
self.assertEqual('default-az', volume['availability_zone'])
@mock.patch('cinder.quota.QUOTAS.rollback', new=mock.MagicMock())
@mock.patch('cinder.quota.QUOTAS.commit', new=mock.MagicMock())
@mock.patch('cinder.quota.QUOTAS.reserve', return_value=["RESERVATION"])
def test_create_volume_with_volume_type(self, _mock_reserve):
"""Test volume creation with default volume type."""
volume_api = cinder.volume.api.API()
# Create volume with default volume type while default
# volume type doesn't exist, volume_type_id should be NULL
volume = volume_api.create(self.context,
1,
'name',
'description')
self.assertIsNone(volume['volume_type_id'])
self.assertIsNone(volume['encryption_key_id'])
# Create default volume type
vol_type = conf_fixture.def_vol_type
db.volume_type_create(context.get_admin_context(),
{'name': vol_type, 'extra_specs': {}})
db_vol_type = db.volume_type_get_by_name(context.get_admin_context(),
vol_type)
# Create volume with default volume type
volume = volume_api.create(self.context,
1,
'name',
'description')
self.assertEqual(db_vol_type.get('id'), volume['volume_type_id'])
self.assertIsNone(volume['encryption_key_id'])
# Create volume with specific volume type
vol_type = 'test'
db.volume_type_create(context.get_admin_context(),
{'name': vol_type, 'extra_specs': {}})
db_vol_type = db.volume_type_get_by_name(context.get_admin_context(),
vol_type)
volume = volume_api.create(self.context,
1,
'name',
'description',
volume_type=db_vol_type)
self.assertEqual(db_vol_type.get('id'), volume['volume_type_id'])
@mock.patch.object(key_manager, 'API', fake_keymgr.fake_api)
def test_create_volume_with_encrypted_volume_type_aes(self):
ctxt = context.get_admin_context()
cipher = 'aes-xts-plain64'
key_size = 256
control_location = 'front-end'
db.volume_type_create(ctxt,
{'id': '61298380-0c12-11e3-bfd6-4b48424183be',
'name': 'LUKS'})
db.volume_type_encryption_create(
ctxt,
'61298380-0c12-11e3-bfd6-4b48424183be',
{'control_location': control_location,
'provider': ENCRYPTION_PROVIDER,
'cipher': cipher,
'key_size': key_size})
volume_api = cinder.volume.api.API()
db_vol_type = db.volume_type_get_by_name(ctxt, 'LUKS')
volume = volume_api.create(self.context,
1,
'name',
'description',
volume_type=db_vol_type)
key_manager = volume_api.key_manager
key = key_manager.get(self.context, volume['encryption_key_id'])
self.assertEqual(key_size, len(key.get_encoded()) * 8)
self.assertEqual('aes', key.algorithm)
metadata = db.volume_encryption_metadata_get(self.context, volume.id)
self.assertEqual(db_vol_type.get('id'), volume['volume_type_id'])
self.assertEqual(cipher, metadata.get('cipher'))
self.assertEqual(key_size, metadata.get('key_size'))
self.assertIsNotNone(volume['encryption_key_id'])
@mock.patch.object(key_manager, 'API', fake_keymgr.fake_api)
def test_create_volume_with_encrypted_volume_type_blowfish(self):
ctxt = context.get_admin_context()
cipher = 'blowfish-cbc'
key_size = 32
control_location = 'front-end'
db.volume_type_create(ctxt,
{'id': '61298380-0c12-11e3-bfd6-4b48424183be',
'name': 'LUKS'})
db.volume_type_encryption_create(
ctxt,
'61298380-0c12-11e3-bfd6-4b48424183be',
{'control_location': control_location,
'provider': ENCRYPTION_PROVIDER,
'cipher': cipher,
'key_size': key_size})
volume_api = cinder.volume.api.API()
db_vol_type = db.volume_type_get_by_name(ctxt, 'LUKS')
volume = volume_api.create(self.context,
1,
'name',
'description',
volume_type=db_vol_type)
key_manager = volume_api.key_manager
key = key_manager.get(self.context, volume['encryption_key_id'])
self.assertEqual('blowfish', key.algorithm)
metadata = db.volume_encryption_metadata_get(self.context, volume.id)
self.assertEqual(db_vol_type.get('id'), volume['volume_type_id'])
self.assertEqual(cipher, metadata.get('cipher'))
self.assertEqual(key_size, metadata.get('key_size'))
self.assertIsNotNone(volume['encryption_key_id'])
def test_create_volume_with_provider_id(self):
volume_params_with_provider_id = dict(provider_id=fake.PROVIDER_ID,
**self.volume_params)
volume = tests_utils.create_volume(self.context,
**volume_params_with_provider_id)
self.volume.create_volume(self.context, volume)
self.assertEqual(fake.PROVIDER_ID, volume['provider_id'])
def test_create_volume_with_admin_metadata(self):
with mock.patch.object(
self.volume.driver, 'create_volume',
return_value={'admin_metadata': {'foo': 'bar'}}):
volume = tests_utils.create_volume(self.user_context)
self.volume.create_volume(self.user_context, volume)
self.assertEqual({'foo': 'bar'}, volume['admin_metadata'])
@mock.patch.object(key_manager, 'API', new=fake_keymgr.fake_api)
def test_create_delete_volume_with_encrypted_volume_type(self):
cipher = 'aes-xts-plain64'
key_size = 256
db.volume_type_create(self.context,
{'id': fake.VOLUME_TYPE_ID, 'name': 'LUKS'})
db.volume_type_encryption_create(
self.context, fake.VOLUME_TYPE_ID,
{'control_location': 'front-end', 'provider': ENCRYPTION_PROVIDER,
'cipher': cipher, 'key_size': key_size})
db_vol_type = db.volume_type_get_by_name(self.context, 'LUKS')
volume = self.volume_api.create(self.context,
1,
'name',
'description',
volume_type=db_vol_type)
self.assertIsNotNone(volume.get('encryption_key_id', None))
self.assertEqual(db_vol_type.get('id'), volume['volume_type_id'])
volume['host'] = 'fake_host'
volume['status'] = 'available'
db.volume_update(self.context, volume['id'], {'status': 'available'})
self.volume_api.delete(self.context, volume)
volume = objects.Volume.get_by_id(self.context, volume.id)
while volume.status == 'available':
# Must wait for volume_api delete request to process enough to
# change the volume status.
time.sleep(0.5)
volume.refresh()
self.assertEqual('deleting', volume['status'])
db.volume_destroy(self.context, volume['id'])
self.assertRaises(exception.NotFound,
db.volume_get,
self.context,
volume['id'])
def test_extra_capabilities(self):
# Test valid extra_capabilities.
fake_capabilities = {'key1': 1, 'key2': 2}
with mock.patch.object(jsonutils, 'loads') as mock_loads:
mock_loads.return_value = fake_capabilities
manager = vol_manager.VolumeManager()
manager.stats = {'pools': {}}
manager.driver.set_initialized()
manager.publish_service_capabilities(self.context)
self.assertTrue(mock_loads.called)
volume_stats = manager.last_capabilities
self.assertEqual(fake_capabilities['key1'],
volume_stats['key1'])
self.assertEqual(fake_capabilities['key2'],
volume_stats['key2'])
def test_extra_capabilities_fail(self):
with mock.patch.object(jsonutils, 'loads') as mock_loads:
mock_loads.side_effect = exception.CinderException('test')
self.assertRaises(exception.CinderException,
vol_manager.VolumeManager)
def test_delete_busy_volume(self):
"""Test volume survives deletion if driver reports it as busy."""
volume = tests_utils.create_volume(self.context, **self.volume_params)
volume_id = volume['id']
self.volume.create_volume(self.context, volume)
with mock.patch.object(self.volume.driver, 'delete_volume',
side_effect=exception.VolumeIsBusy(
volume_name='fake')
) as mock_del_vol:
self.volume.delete_volume(self.context, volume)
volume_ref = db.volume_get(context.get_admin_context(), volume_id)
self.assertEqual(volume_id, volume_ref.id)
self.assertEqual("available", volume_ref.status)
mock_del_vol.assert_called_once_with(volume)
def test_get_volume_different_tenant(self):
"""Test can't get volume of another tenant when viewable_admin_meta."""
volume = tests_utils.create_volume(self.context,
**self.volume_params)
volume_id = volume['id']
self.volume.create_volume(self.context, volume)
another_context = context.RequestContext('another_user_id',
'another_project_id',
is_admin=False)
self.assertNotEqual(another_context.project_id,
self.context.project_id)
volume_api = cinder.volume.api.API()
self.assertRaises(exception.VolumeNotFound, volume_api.get,
another_context, volume_id, viewable_admin_meta=True)
self.assertEqual(volume_id,
volume_api.get(self.context, volume_id)['id'])
self.volume.delete_volume(self.context, volume)
def test_get_all_limit_bad_value(self):
"""Test value of 'limit' is numeric and >= 0"""
volume_api = cinder.volume.api.API()
self.assertRaises(exception.InvalidInput,
volume_api.get_all,
self.context,
limit="A")
self.assertRaises(exception.InvalidInput,
volume_api.get_all,
self.context,
limit="-1")
def test_get_all_tenants_volume_list(self):
"""Validate when the volume list for all tenants is returned"""
volume_api = cinder.volume.api.API()
with mock.patch.object(volume_api.db,
'volume_get_all_by_project') as by_project:
with mock.patch.object(volume_api.db,
'volume_get_all') as get_all:
db_volume = {'volume_type_id': fake.VOLUME_TYPE_ID,
'name': 'fake_name',
'host': 'fake_host',
'id': fake.VOLUME_ID}
volume = fake_volume.fake_db_volume(**db_volume)
by_project.return_value = [volume]
get_all.return_value = [volume]
volume_api.get_all(self.context, filters={'all_tenants': '0'})
self.assertTrue(by_project.called)
by_project.called = False
self.context.is_admin = False
volume_api.get_all(self.context, filters={'all_tenants': '1'})
self.assertTrue(by_project.called)
# check for volume list of all tenants
self.context.is_admin = True
volume_api.get_all(self.context, filters={'all_tenants': '1'})
self.assertTrue(get_all.called)
def test_delete_volume_in_error_extending(self):
"""Test volume can be deleted in error_extending stats."""
# create a volume
volume = tests_utils.create_volume(self.context, **self.volume_params)
self.volume.create_volume(self.context, volume)
# delete 'error_extending' volume
db.volume_update(self.context, volume['id'],
{'status': 'error_extending'})
self.volume.delete_volume(self.context, volume)
self.assertRaises(exception.NotFound, db.volume_get,
self.context, volume['id'])
@mock.patch.object(db.sqlalchemy.api, 'volume_get',
side_effect=exception.VolumeNotFound(
volume_id='12345678-1234-5678-1234-567812345678'))
def test_delete_volume_not_found(self, mock_get_volume):
"""Test delete volume moves on if the volume does not exist."""
volume_id = '12345678-1234-5678-1234-567812345678'
volume = objects.Volume(self.context, status='available', id=volume_id)
self.volume.delete_volume(self.context, volume)
self.assertTrue(mock_get_volume.called)
@mock.patch('cinder.volume.drivers.lvm.LVMVolumeDriver.'
'create_volume_from_snapshot')
def test_create_volume_from_snapshot(self, mock_create_from_snap):
"""Test volume can be created from a snapshot."""
volume_src = tests_utils.create_volume(self.context,
**self.volume_params)
self.volume.create_volume(self.context, volume_src)
snapshot_id = create_snapshot(volume_src['id'],
size=volume_src['size'])['id']
snapshot_obj = objects.Snapshot.get_by_id(self.context, snapshot_id)
self.volume.create_snapshot(self.context, snapshot_obj)
volume_dst = tests_utils.create_volume(self.context,
snapshot_id=snapshot_id,
**self.volume_params)
self.volume.create_volume(self.context, volume_dst)
self.assertEqual(volume_dst['id'],
db.volume_get(
context.get_admin_context(),
volume_dst['id']).id)
self.assertEqual(snapshot_id,
db.volume_get(context.get_admin_context(),
volume_dst['id']).snapshot_id)
self.volume.delete_volume(self.context, volume_dst)
self.volume.delete_snapshot(self.context, snapshot_obj)
self.volume.delete_volume(self.context, volume_src)
@mock.patch('cinder.volume.flows.api.create_volume.get_flow')
def test_create_volume_from_snapshot_with_types(self, _get_flow):
"""Test volume create from snapshot with types including mistmatch."""
volume_api = cinder.volume.api.API()
db.volume_type_create(
context.get_admin_context(),
{'name': 'foo',
'extra_specs': {'volume_backend_name': 'dev_1'}})
db.volume_type_create(
context.get_admin_context(),
{'name': 'biz', 'extra_specs': {'volume_backend_name': 'dev_2'}})
foo_type = db.volume_type_get_by_name(context.get_admin_context(),
'foo')
biz_type = db.volume_type_get_by_name(context.get_admin_context(),
'biz')
snapshot = {'id': fake.SNAPSHOT_ID,
'status': fields.SnapshotStatus.AVAILABLE,
'volume_size': 10,
'volume_type_id': biz_type['id']}
snapshot_obj = fake_snapshot.fake_snapshot_obj(self.context,
**snapshot)
# Make sure the case of specifying a type that
# doesn't match the snapshots type fails
self.assertRaises(exception.InvalidInput,
volume_api.create,
self.context,
size=1,
name='fake_name',
description='fake_desc',
volume_type=foo_type,
snapshot=snapshot_obj)
# Make sure that trying to specify a type
# when the snapshots type is None fails
snapshot_obj.volume_type_id = None
self.assertRaises(exception.InvalidVolumeType,
volume_api.create,
self.context,
size=1,
name='fake_name',
description='fake_desc',
volume_type=foo_type,
snapshot=snapshot_obj)
with mock.patch.object(cinder.volume.volume_types,
'get_volume_type') as mock_get_type:
mock_get_type.return_value = biz_type
snapshot_obj.volume_type_id = foo_type['id']
volume_api.create(self.context, size=1, name='fake_name',
description='fake_desc', volume_type=foo_type,
snapshot=snapshot_obj)
db.volume_type_destroy(context.get_admin_context(),
foo_type['id'])
db.volume_type_destroy(context.get_admin_context(),
biz_type['id'])
@mock.patch('cinder.volume.flows.api.create_volume.get_flow')
def test_create_volume_from_source_with_types(self, _get_flow):
"""Test volume create from source with types including mistmatch."""
volume_api = cinder.volume.api.API()
db.volume_type_create(
context.get_admin_context(),
{'name': 'foo',
'extra_specs': {'volume_backend_name': 'dev_1'}})
db.volume_type_create(
context.get_admin_context(),
{'name': 'biz', 'extra_specs': {'volume_backend_name': 'dev_2'}})
foo_type = db.volume_type_get_by_name(context.get_admin_context(),
'foo')
biz_type = db.volume_type_get_by_name(context.get_admin_context(),
'biz')
source_vol = {'id': fake.VOLUME_ID,
'status': 'available',
'volume_size': 10,
'volume_type': biz_type,
'volume_type_id': biz_type['id']}
self.assertRaises(exception.InvalidInput,
volume_api.create,
self.context,
size=1,
name='fake_name',
description='fake_desc',
volume_type=foo_type,
source_volume=source_vol)
# Make sure that trying to specify a type
# when the source type is None fails
source_vol['volume_type_id'] = None
source_vol['volume_type'] = None
self.assertRaises(exception.InvalidVolumeType,
volume_api.create,
self.context,
size=1,
name='fake_name',
description='fake_desc',
volume_type=foo_type,
source_volume=source_vol)
with mock.patch.object(cinder.volume.volume_types,
'get_volume_type') as mock_get_type:
mock_get_type.return_value = biz_type
source_vol['volume_type_id'] = biz_type['id']
source_vol['volume_type'] = biz_type
volume_api.create(self.context, size=1, name='fake_name',
description='fake_desc', volume_type=biz_type,
source_volume=source_vol)
db.volume_type_destroy(context.get_admin_context(),
foo_type['id'])
db.volume_type_destroy(context.get_admin_context(),
biz_type['id'])
@mock.patch('cinder.volume.flows.api.create_volume.get_flow')
def test_create_volume_from_source_with_same_backend(self, _get_flow):
"""Test volume create from source with type mismatch same backend."""
volume_api = cinder.volume.api.API()
foo_type = {
'name': 'foo',
'qos_specs_id': None,
'deleted': False,
'created_at': datetime.datetime(2015, 5, 8, 0, 40, 5, 408232),
'updated_at': None,
'extra_specs': {'volume_backend_name': 'dev_1'},
'is_public': True,
'deleted_at': None,
'id': '29e43b50-2cd7-4d0c-8ddd-2119daab3a38',
'description': None}
biz_type = {
'name': 'biz',
'qos_specs_id': None,
'deleted': False,
'created_at': datetime.datetime(2015, 5, 8, 0, 20, 5, 408232),
'updated_at': None,
'extra_specs': {'volume_backend_name': 'dev_1'},
'is_public': True,
'deleted_at': None,
'id': '34e54c31-3bc8-5c1d-9fff-2225bcce4b59',
'description': None}
source_vol = {'id': fake.VOLUME_ID,
'status': 'available',
'volume_size': 10,
'volume_type': biz_type,
'volume_type_id': biz_type['id']}
with mock.patch.object(cinder.volume.volume_types,
'get_volume_type') as mock_get_type:
mock_get_type.return_value = biz_type
volume_api.create(self.context,
size=1,
name='fake_name',
description='fake_desc',
volume_type=foo_type,
source_volume=source_vol)
@mock.patch('cinder.volume.flows.api.create_volume.get_flow')
def test_create_from_source_and_snap_only_one_backend(self, _get_flow):
"""Test create from source and snap with type mismatch one backend."""
volume_api = cinder.volume.api.API()
foo_type = {
'name': 'foo',
'qos_specs_id': None,
'deleted': False,
'created_at': datetime.datetime(2015, 5, 8, 0, 40, 5, 408232),
'updated_at': None,
'extra_specs': {'some_key': 3},
'is_public': True,
'deleted_at': None,
'id': '29e43b50-2cd7-4d0c-8ddd-2119daab3a38',
'description': None}
biz_type = {
'name': 'biz',
'qos_specs_id': None,
'deleted': False,
'created_at': datetime.datetime(2015, 5, 8, 0, 20, 5, 408232),
'updated_at': None,
'extra_specs': {'some_other_key': 4},
'is_public': True,
'deleted_at': None,
'id': '34e54c31-3bc8-5c1d-9fff-2225bcce4b59',
'description': None}
source_vol = {'id': fake.VOLUME_ID,
'status': 'available',
'volume_size': 10,
'volume_type': biz_type,
'volume_type_id': biz_type['id']}
snapshot = {'id': fake.SNAPSHOT_ID,
'status': fields.SnapshotStatus.AVAILABLE,
'volume_size': 10,
'volume_type_id': biz_type['id']}
snapshot_obj = fake_snapshot.fake_snapshot_obj(self.context,
**snapshot)
with mock.patch('cinder.db.service_get_all') as mock_get_service, \
mock.patch.object(volume_api,
'list_availability_zones') as mock_get_azs:
mock_get_service.return_value = [{'host': 'foo'}]
mock_get_azs.return_value = {}
volume_api.create(self.context,
size=1,
name='fake_name',
description='fake_desc',
volume_type=foo_type,
source_volume=source_vol)
volume_api.create(self.context,
size=1,
name='fake_name',
description='fake_desc',
volume_type=foo_type,
snapshot=snapshot_obj)
def _test_create_from_source_snapshot_encryptions(
self, is_snapshot=False):
volume_api = cinder.volume.api.API()
foo_type = {
'name': 'foo',
'extra_specs': {'volume_backend_name': 'dev_1'},
'id': fake.VOLUME_TYPE_ID,
'description': None}
biz_type = {
'name': 'foo',
'extra_specs': {'volume_backend_name': 'dev_1'},
'id': fake.VOLUME_TYPE2_ID,
'description': None}
source_vol = {'id': fake.VOLUME_ID,
'status': 'available',
'volume_size': 1,
'volume_type': biz_type,
'volume_type_id': biz_type['id']}
snapshot = {'id': fake.SNAPSHOT_ID,
'status': fields.SnapshotStatus.AVAILABLE,
'volume_size': 1,
'volume_type_id': biz_type['id']}
snapshot_obj = fake_snapshot.fake_snapshot_obj(self.context,
**snapshot)
with mock.patch.object(
cinder.volume.volume_types,
'volume_types_encryption_changed') as mock_encryption_changed:
mock_encryption_changed.return_value = True
self.assertRaises(exception.InvalidInput,
volume_api.create,
self.context,
size=1,
name='fake_name',
description='fake_desc',
volume_type=foo_type,
source_volume=(
source_vol if not is_snapshot else None),
snapshot=snapshot_obj if is_snapshot else None)
def test_create_from_source_encryption_changed(self):
self._test_create_from_source_snapshot_encryptions()
def test_create_from_snapshot_encryption_changed(self):
self._test_create_from_source_snapshot_encryptions(is_snapshot=True)
def test_create_snapshot_driver_not_initialized(self):
volume_src = tests_utils.create_volume(self.context,
**self.volume_params)
self.volume.create_volume(self.context, volume_src)
snapshot_id = create_snapshot(volume_src['id'],
size=volume_src['size'])['id']
snapshot_obj = objects.Snapshot.get_by_id(self.context, snapshot_id)
self.volume.driver._initialized = False
self.assertRaises(exception.DriverNotInitialized,
self.volume.create_snapshot,
self.context, snapshot_obj)
# NOTE(flaper87): The volume status should be error.
self.assertEqual(fields.SnapshotStatus.ERROR, snapshot_obj.status)
# lets cleanup the mess
self.volume.driver._initialized = True
self.volume.delete_snapshot(self.context, snapshot_obj)
self.volume.delete_volume(self.context, volume_src)
def _mock_synchronized(self, name, *s_args, **s_kwargs):
def inner_sync1(f):
def inner_sync2(*args, **kwargs):
self.called.append('lock-%s' % (name))
ret = f(*args, **kwargs)
self.called.append('unlock-%s' % (name))
return ret
return inner_sync2
return inner_sync1
def _fake_execute(self, *cmd, **kwargs):
pass
@mock.patch.object(coordination.Coordinator, 'get_lock')
@mock.patch.object(cinder.tests.fake_driver.FakeLoggingVolumeDriver,
'create_volume_from_snapshot')
def test_create_volume_from_snapshot_check_locks(
self, mock_lvm_create, mock_lock):
orig_flow = engine.ActionEngine.run
def mock_flow_run(*args, **kwargs):
# ensure the lock has been taken
mock_lock.assert_called_with('%s-delete_snapshot' % snap_id)
# now proceed with the flow.
ret = orig_flow(*args, **kwargs)
return ret
# create source volume
src_vol = tests_utils.create_volume(self.context, **self.volume_params)
# no lock
self.volume.create_volume(self.context, src_vol)
snap_id = create_snapshot(src_vol.id,
size=src_vol['size'])['id']
snapshot_obj = objects.Snapshot.get_by_id(self.context, snap_id)
# no lock
self.volume.create_snapshot(self.context, snapshot_obj)
dst_vol = tests_utils.create_volume(self.context,
snapshot_id=snap_id,
**self.volume_params)
admin_ctxt = context.get_admin_context()
# mock the flow runner so we can do some checks
self.mock_object(engine.ActionEngine, 'run', mock_flow_run)
# locked
self.volume.create_volume(self.context, dst_vol,
request_spec={'snapshot_id': snap_id})
mock_lock.assert_called_with('%s-delete_snapshot' % snap_id)
self.assertEqual(dst_vol.id, db.volume_get(admin_ctxt, dst_vol.id).id)
self.assertEqual(snap_id,
db.volume_get(admin_ctxt, dst_vol.id).snapshot_id)
# locked
self.volume.delete_volume(self.context, dst_vol)
mock_lock.assert_called_with('%s-delete_volume' % dst_vol.id)
# locked
self.volume.delete_snapshot(self.context, snapshot_obj)
mock_lock.assert_called_with('%s-delete_snapshot' % snap_id)
# locked
self.volume.delete_volume(self.context, src_vol)
mock_lock.assert_called_with('%s-delete_volume' % src_vol.id)
self.assertTrue(mock_lvm_create.called)
@mock.patch.object(coordination.Coordinator, 'get_lock')
def test_create_volume_from_volume_check_locks(self, mock_lock):
# mock the synchroniser so we can record events
self.mock_object(utils, 'execute', self._fake_execute)
orig_flow = engine.ActionEngine.run
def mock_flow_run(*args, **kwargs):
# ensure the lock has been taken
mock_lock.assert_called_with('%s-delete_volume' % src_vol_id)
# now proceed with the flow.
ret = orig_flow(*args, **kwargs)
return ret
# create source volume
src_vol = tests_utils.create_volume(self.context, **self.volume_params)
src_vol_id = src_vol['id']
# no lock
self.volume.create_volume(self.context, src_vol)
self.assertEqual(0, mock_lock.call_count)
dst_vol = tests_utils.create_volume(self.context,
source_volid=src_vol_id,
**self.volume_params)
dst_vol_id = dst_vol['id']
admin_ctxt = context.get_admin_context()
# mock the flow runner so we can do some checks
self.mock_object(engine.ActionEngine, 'run', mock_flow_run)
# locked
self.volume.create_volume(self.context, dst_vol,
request_spec={'source_volid': src_vol_id})
mock_lock.assert_called_with('%s-delete_volume' % src_vol_id)
self.assertEqual(dst_vol_id, db.volume_get(admin_ctxt, dst_vol_id).id)
self.assertEqual(src_vol_id,
db.volume_get(admin_ctxt, dst_vol_id).source_volid)
# locked
self.volume.delete_volume(self.context, dst_vol)
mock_lock.assert_called_with('%s-delete_volume' % dst_vol_id)
# locked
self.volume.delete_volume(self.context, src_vol)
mock_lock.assert_called_with('%s-delete_volume' % src_vol_id)
def test_create_volume_from_volume_delete_lock_taken(self):
# create source volume
src_vol = tests_utils.create_volume(self.context, **self.volume_params)
src_vol_id = src_vol['id']
# no lock
self.volume.create_volume(self.context, src_vol)
dst_vol = tests_utils.create_volume(self.context,
source_volid=src_vol_id,
**self.volume_params)
orig_elevated = self.context.elevated
gthreads = []
def mock_elevated(*args, **kwargs):
# unset mock so it is only called once
self.mock_object(self.context, 'elevated', orig_elevated)
# we expect this to block and then fail
t = eventlet.spawn(self.volume.create_volume,
self.context,
volume=dst_vol,
request_spec={'source_volid': src_vol_id})
gthreads.append(t)
return orig_elevated(*args, **kwargs)
# mock something from early on in the delete operation and within the
# lock so that when we do the create we expect it to block.
self.mock_object(self.context, 'elevated', mock_elevated)
# locked
self.volume.delete_volume(self.context, src_vol)
# we expect the volume create to fail with the following err since the
# source volume was deleted while the create was locked. Note that the
# volume is still in the db since it was created by the test prior to
# calling manager.create_volume.
with mock.patch('sys.stderr', new=six.StringIO()):
self.assertRaises(exception.VolumeNotFound, gthreads[0].wait)
def _raise_metadata_copy_failure(self, method, dst_vol):
# MetadataCopyFailure exception will be raised if DB service is Down
# while copying the volume glance metadata
with mock.patch.object(db, method) as mock_db:
mock_db.side_effect = exception.MetadataCopyFailure(
reason="Because of DB service down.")
self.assertRaises(exception.MetadataCopyFailure,
self.volume.create_volume,
self.context,
dst_vol)
# ensure that status of volume is 'error'
vol = db.volume_get(self.context, dst_vol.id)
self.assertEqual('error', vol['status'])
# cleanup resource
db.volume_destroy(self.context, dst_vol.id)
@mock.patch('cinder.utils.execute')
def test_create_volume_from_volume_with_glance_volume_metadata_none(
self, mock_execute):
# create source volume
mock_execute.return_value = None
src_vol = tests_utils.create_volume(self.context, **self.volume_params)
src_vol_id = src_vol['id']
self.volume.create_volume(self.context, src_vol)
# set bootable flag of volume to True
db.volume_update(self.context, src_vol['id'], {'bootable': True})
# create volume from source volume
dst_vol = tests_utils.create_volume(self.context,
source_volid=src_vol_id,
**self.volume_params)
self.volume.create_volume(self.context, dst_vol)
self.assertRaises(exception.GlanceMetadataNotFound,
db.volume_glance_metadata_copy_from_volume_to_volume,
self.context, src_vol_id, dst_vol['id'])
# ensure that status of volume is 'available'
vol = db.volume_get(self.context, dst_vol['id'])
self.assertEqual('available', vol['status'])
# cleanup resource
db.volume_destroy(self.context, src_vol_id)
db.volume_destroy(self.context, dst_vol['id'])
@mock.patch('cinder.utils.execute')
def test_create_volume_from_volume_raise_metadata_copy_failure(
self, mock_execute):
# create source volume
mock_execute.return_value = None
src_vol = tests_utils.create_volume(self.context, **self.volume_params)
src_vol_id = src_vol['id']
self.volume.create_volume(self.context, src_vol)
# set bootable flag of volume to True
db.volume_update(self.context, src_vol['id'], {'bootable': True})
# create volume from source volume
dst_vol = tests_utils.create_volume(self.context,
source_volid=src_vol_id,
**self.volume_params)
self._raise_metadata_copy_failure(
'volume_glance_metadata_copy_from_volume_to_volume',
dst_vol)
# cleanup resource
db.volume_destroy(self.context, src_vol_id)
@mock.patch('cinder.utils.execute')
def test_create_volume_from_snapshot_raise_metadata_copy_failure(
self, mock_execute):
# create source volume
mock_execute.return_value = None
src_vol = tests_utils.create_volume(self.context, **self.volume_params)
src_vol_id = src_vol['id']
self.volume.create_volume(self.context, src_vol)
# set bootable flag of volume to True
db.volume_update(self.context, src_vol['id'], {'bootable': True})
# create volume from snapshot
snapshot_id = create_snapshot(src_vol['id'])['id']
snapshot_obj = objects.Snapshot.get_by_id(self.context, snapshot_id)
self.volume.create_snapshot(self.context, snapshot_obj)
# ensure that status of snapshot is 'available'
self.assertEqual(fields.SnapshotStatus.AVAILABLE, snapshot_obj.status)
dst_vol = tests_utils.create_volume(self.context,
snapshot_id=snapshot_id,
**self.volume_params)
self._raise_metadata_copy_failure(
'volume_glance_metadata_copy_to_volume',
dst_vol)
# cleanup resource
snapshot_obj.destroy()
db.volume_destroy(self.context, src_vol_id)
@mock.patch(
'cinder.volume.driver.VolumeDriver.create_replica_test_volume')
@mock.patch('cinder.utils.execute')
def test_create_volume_from_srcreplica_raise_metadata_copy_failure(
self, mock_execute, _create_replica_test):
mock_execute.return_value = None
_create_replica_test.return_value = None
# create source volume
src_vol = tests_utils.create_volume(self.context, **self.volume_params)
src_vol_id = src_vol['id']
self.volume.create_volume(self.context, src_vol)
# set bootable flag of volume to True
db.volume_update(self.context, src_vol['id'], {'bootable': True})
# create volume from source volume
dst_vol = tests_utils.create_volume(self.context,
source_volid=src_vol_id,
**self.volume_params)
self._raise_metadata_copy_failure(
'volume_glance_metadata_copy_from_volume_to_volume',
dst_vol)
# cleanup resource
db.volume_destroy(self.context, src_vol_id)
@mock.patch('cinder.utils.execute')
def test_create_volume_from_snapshot_with_glance_volume_metadata_none(
self, mock_execute):
# create source volume
mock_execute.return_value = None
src_vol = tests_utils.create_volume(self.context, **self.volume_params)
src_vol_id = src_vol['id']
self.volume.create_volume(self.context, src_vol)
# set bootable flag of volume to True
db.volume_update(self.context, src_vol['id'], {'bootable': True})
volume = db.volume_get(self.context, src_vol_id)
# create snapshot of volume
snapshot_id = create_snapshot(volume['id'])['id']
snapshot_obj = objects.Snapshot.get_by_id(self.context, snapshot_id)
self.volume.create_snapshot(self.context, snapshot_obj)
# ensure that status of snapshot is 'available'
self.assertEqual(fields.SnapshotStatus.AVAILABLE, snapshot_obj.status)
# create volume from snapshot
dst_vol = tests_utils.create_volume(self.context,
snapshot_id=snapshot_id,
**self.volume_params)
self.volume.create_volume(self.context, dst_vol)
self.assertRaises(exception.GlanceMetadataNotFound,
db.volume_glance_metadata_copy_to_volume,
self.context, dst_vol['id'], snapshot_id)
# ensure that status of volume is 'available'
vol = db.volume_get(self.context, dst_vol['id'])
self.assertEqual('available', vol['status'])
# cleanup resource
snapshot_obj.destroy()
db.volume_destroy(self.context, src_vol_id)
db.volume_destroy(self.context, dst_vol['id'])
@mock.patch(
'cinder.volume.driver.VolumeDriver.create_replica_test_volume')
def test_create_volume_from_srcreplica_with_glance_volume_metadata_none(
self, _create_replica_test):
"""Test volume can be created from a volume replica."""
_create_replica_test.return_value = None
volume_src = tests_utils.create_volume(self.context,
**self.volume_params)
self.volume.create_volume(self.context, volume_src)
db.volume_update(self.context, volume_src['id'], {'bootable': True})
volume = db.volume_get(self.context, volume_src['id'])
volume_dst = tests_utils.create_volume(
self.context,
**self.volume_params)
self.volume.create_volume(self.context, volume_dst,
{'source_replicaid': volume.id})
self.assertRaises(exception.GlanceMetadataNotFound,
db.volume_glance_metadata_copy_from_volume_to_volume,
self.context, volume_src['id'], volume_dst['id'])
self.assertEqual('available',
db.volume_get(self.context,
volume_dst['id']).status)
self.assertTrue(_create_replica_test.called)
# cleanup resource
db.volume_destroy(self.context, volume_dst['id'])
db.volume_destroy(self.context, volume_src['id'])
def test_create_volume_from_snapshot_delete_lock_taken(self):
# create source volume
src_vol = tests_utils.create_volume(self.context, **self.volume_params)
# no lock
self.volume.create_volume(self.context, src_vol)
# create snapshot
snap_id = create_snapshot(src_vol.id,
size=src_vol['size'])['id']
snapshot_obj = objects.Snapshot.get_by_id(self.context, snap_id)
# no lock
self.volume.create_snapshot(self.context, snapshot_obj)
# create vol from snapshot...
dst_vol = tests_utils.create_volume(self.context,
snapshot_id=snap_id,
source_volid=src_vol.id,
**self.volume_params)
orig_elevated = self.context.elevated
gthreads = []
def mock_elevated(*args, **kwargs):
# unset mock so it is only called once
self.mock_object(self.context, 'elevated', orig_elevated)
# We expect this to block and then fail
t = eventlet.spawn(self.volume.create_volume, self.context,
volume=dst_vol,
request_spec={'snapshot_id': snap_id})
gthreads.append(t)
return orig_elevated(*args, **kwargs)
# mock something from early on in the delete operation and within the
# lock so that when we do the create we expect it to block.
self.mock_object(self.context, 'elevated', mock_elevated)
# locked
self.volume.delete_snapshot(self.context, snapshot_obj)
# we expect the volume create to fail with the following err since the
# snapshot was deleted while the create was locked. Note that the
# volume is still in the db since it was created by the test prior to
# calling manager.create_volume.
with mock.patch('sys.stderr', new=six.StringIO()):
self.assertRaises(exception.SnapshotNotFound, gthreads[0].wait)
# locked
self.volume.delete_volume(self.context, src_vol)
# make sure it is gone
self.assertRaises(exception.VolumeNotFound, db.volume_get,
self.context, src_vol.id)
@mock.patch.object(key_manager, 'API', fake_keymgr.fake_api)
def test_create_volume_from_snapshot_with_encryption(self):
"""Test volume can be created from a snapshot of an encrypted volume"""
ctxt = context.get_admin_context()
cipher = 'aes-xts-plain64'
key_size = 256
db.volume_type_create(ctxt,
{'id': '61298380-0c12-11e3-bfd6-4b48424183be',
'name': 'LUKS'})
db.volume_type_encryption_create(
ctxt,
'61298380-0c12-11e3-bfd6-4b48424183be',
{'control_location': 'front-end', 'provider': ENCRYPTION_PROVIDER,
'cipher': cipher, 'key_size': key_size})
volume_api = cinder.volume.api.API()
db_vol_type = db.volume_type_get_by_name(context.get_admin_context(),
'LUKS')
volume_src = volume_api.create(self.context,
1,
'name',
'description',
volume_type=db_vol_type)
volume_src['host'] = 'fake_host'
snapshot_ref = volume_api.create_snapshot_force(self.context,
volume_src,
'name',
'description')
snapshot_ref['status'] = fields.SnapshotStatus.AVAILABLE
# status must be available
volume_dst = volume_api.create(self.context,
1,
'name',
'description',
snapshot=snapshot_ref)
self.assertEqual(volume_dst['id'],
db.volume_get(
context.get_admin_context(),
volume_dst['id']).id)
self.assertEqual(snapshot_ref['id'],
db.volume_get(context.get_admin_context(),
volume_dst['id']).snapshot_id)
# ensure encryption keys match
self.assertIsNotNone(volume_src['encryption_key_id'])
self.assertIsNotNone(volume_dst['encryption_key_id'])
key_manager = volume_api.key_manager # must use *same* key manager
volume_src_key = key_manager.get(self.context,
volume_src['encryption_key_id'])
volume_dst_key = key_manager.get(self.context,
volume_dst['encryption_key_id'])
self.assertEqual(volume_src_key, volume_dst_key)
def test_create_volume_from_encrypted_volume(self):
"""Test volume can be created from an encrypted volume."""
self.mock_object(key_manager, 'API', fake_keymgr.fake_api)
cipher = 'aes-xts-plain64'
key_size = 256
volume_api = cinder.volume.api.API()
ctxt = context.get_admin_context()
db.volume_type_create(ctxt,
{'id': '61298380-0c12-11e3-bfd6-4b48424183be',
'name': 'LUKS'})
db.volume_type_encryption_create(
ctxt,
'61298380-0c12-11e3-bfd6-4b48424183be',
{'control_location': 'front-end', 'provider': ENCRYPTION_PROVIDER,
'cipher': cipher, 'key_size': key_size})
db_vol_type = db.volume_type_get_by_name(context.get_admin_context(),
'LUKS')
volume_src = volume_api.create(self.context,
1,
'name',
'description',
volume_type=db_vol_type)
volume_src['status'] = 'available' # status must be available
volume_dst = volume_api.create(self.context,
1,
'name',
'description',
source_volume=volume_src)
self.assertEqual(volume_dst['id'],
db.volume_get(context.get_admin_context(),
volume_dst['id']).id)
self.assertEqual(volume_src['id'],
db.volume_get(context.get_admin_context(),
volume_dst['id']).source_volid)
# ensure encryption keys match
self.assertIsNotNone(volume_src['encryption_key_id'])
self.assertIsNotNone(volume_dst['encryption_key_id'])
km = volume_api.key_manager # must use *same* key manager
volume_src_key = km.get(self.context,
volume_src['encryption_key_id'])
volume_dst_key = km.get(self.context,
volume_dst['encryption_key_id'])
self.assertEqual(volume_src_key, volume_dst_key)
def test_delete_encrypted_volume(self):
self.volume_params['status'] = 'active'
volume = tests_utils.create_volume(self.context,
**self.volume_params)
vol_api = cinder.volume.api.API()
with mock.patch.object(
vol_api.key_manager,
'delete',
side_effect=Exception):
self.assertRaises(exception.InvalidVolume,
vol_api.delete,
self.context, volume)
def test_create_volume_from_snapshot_fail_bad_size(self):
"""Test volume can't be created from snapshot with bad volume size."""
volume_api = cinder.volume.api.API()
snapshot = {'id': fake.SNAPSHOT_ID,
'status': fields.SnapshotStatus.AVAILABLE,
'volume_size': 10}
snapshot_obj = fake_snapshot.fake_snapshot_obj(self.context,
**snapshot)
self.assertRaises(exception.InvalidInput,
volume_api.create,
self.context,
size=1,
name='fake_name',
description='fake_desc',
snapshot=snapshot_obj)
def test_create_volume_from_snapshot_fail_wrong_az(self):
"""Test volume can't be created from snapshot in a different az."""
volume_api = cinder.volume.api.API()
def fake_list_availability_zones(enable_cache=False):
return ({'name': 'nova', 'available': True},
{'name': 'az2', 'available': True})
self.mock_object(volume_api,
'list_availability_zones',
fake_list_availability_zones)
volume_src = tests_utils.create_volume(self.context,
availability_zone='az2',
**self.volume_params)
self.volume.create_volume(self.context, volume_src)
snapshot = create_snapshot(volume_src['id'])
self.volume.create_snapshot(self.context, snapshot)
volume_dst = volume_api.create(self.context,
size=1,
name='fake_name',
description='fake_desc',
snapshot=snapshot)
self.assertEqual('az2', volume_dst['availability_zone'])
self.assertRaises(exception.InvalidInput,
volume_api.create,
self.context,
size=1,
name='fake_name',
description='fake_desc',
snapshot=snapshot,
availability_zone='nova')
def test_create_volume_with_invalid_exclusive_options(self):
"""Test volume create with multiple exclusive options fails."""
volume_api = cinder.volume.api.API()
self.assertRaises(exception.InvalidInput,
volume_api.create,
self.context,
1,
'name',
'description',
snapshot=fake.SNAPSHOT_ID,
image_id=fake.IMAGE_ID,
source_volume=fake.VOLUME_ID)
@mock.patch.object(cinder.volume.targets.iscsi.ISCSITarget,
'_get_target_chap_auth')
@mock.patch.object(db, 'volume_admin_metadata_get')
@mock.patch.object(db.sqlalchemy.api, 'volume_get')
@mock.patch.object(db, 'volume_update')
def test_initialize_connection_fetchqos(self,
_mock_volume_update,
_mock_volume_get,
_mock_volume_admin_metadata_get,
mock_get_target):
"""Make sure initialize_connection returns correct information."""
_fake_admin_meta = [{'key': 'fake-key', 'value': 'fake-value'}]
_fake_volume = {'volume_type_id': fake.VOLUME_TYPE_ID,
'name': 'fake_name',
'host': 'fake_host',
'id': fake.VOLUME_ID,
'volume_admin_metadata': _fake_admin_meta}
fake_volume_obj = fake_volume.fake_volume_obj(self.context,
**_fake_volume)
_mock_volume_get.return_value = _fake_volume
_mock_volume_update.return_value = _fake_volume
_mock_volume_admin_metadata_get.return_value = {
'fake-key': 'fake-value'}
connector = {'ip': 'IP', 'initiator': 'INITIATOR'}
qos_values = {'consumer': 'front-end',
'specs': {
'key1': 'value1',
'key2': 'value2'}
}
with mock.patch.object(cinder.volume.volume_types,
'get_volume_type_qos_specs') as type_qos, \
mock.patch.object(cinder.tests.fake_driver.FakeLoggingVolumeDriver,
'initialize_connection') as driver_init:
type_qos.return_value = dict(qos_specs=qos_values)
driver_init.return_value = {'data': {}}
mock_get_target.return_value = None
qos_specs_expected = {'key1': 'value1',
'key2': 'value2'}
# initialize_connection() passes qos_specs that is designated to
# be consumed by front-end or both front-end and back-end
conn_info = self.volume.initialize_connection(
self.context, fake_volume_obj, connector,)
self.assertDictEqual(qos_specs_expected,
conn_info['data']['qos_specs'])
qos_values.update({'consumer': 'both'})
conn_info = self.volume.initialize_connection(
self.context, fake_volume_obj, connector)
self.assertDictEqual(qos_specs_expected,
conn_info['data']['qos_specs'])
# initialize_connection() skips qos_specs that is designated to be
# consumed by back-end only
qos_values.update({'consumer': 'back-end'})
type_qos.return_value = dict(qos_specs=qos_values)
conn_info = self.volume.initialize_connection(
self.context, fake_volume_obj, connector)
self.assertIsNone(conn_info['data']['qos_specs'])
@mock.patch.object(fake_driver.FakeLoggingVolumeDriver, 'create_export')
def test_initialize_connection_export_failure(self,
_mock_create_export):
"""Test exception path for create_export failure."""
volume = tests_utils.create_volume(
self.context, admin_metadata={'fake-key': 'fake-value'},
volume_type_id=fake.VOLUME_TYPE_ID, **self.volume_params)
_mock_create_export.side_effect = exception.CinderException
connector = {'ip': 'IP', 'initiator': 'INITIATOR'}
self.assertRaises(exception.VolumeBackendAPIException,
self.volume.initialize_connection,
self.context, volume, connector)
@ddt.data(False, True)
def test_run_attach_detach_volume_for_instance(self, volume_object):
"""Make sure volume can be attached and detached from instance."""
mountpoint = "/dev/sdf"
# attach volume to the instance then to detach
instance_uuid = '12345678-1234-5678-1234-567812345678'
volume = tests_utils.create_volume(self.user_context,
**self.volume_params)
with volume.obj_as_admin():
volume.admin_metadata['readonly'] = True
volume.save()
volume_id = volume.id
self.volume.create_volume(self.user_context,
volume=volume)
volume_passed = volume if volume_object else None
attachment = self.volume.attach_volume(self.user_context,
volume_id,
instance_uuid, None,
mountpoint, 'ro',
volume=volume_passed)
vol = objects.Volume.get_by_id(self.context, volume_id)
self.assertEqual("in-use", vol.status)
self.assertEqual(fields.VolumeAttachStatus.ATTACHED,
attachment.attach_status)
self.assertEqual(mountpoint, attachment.mountpoint)
self.assertEqual(instance_uuid, attachment.instance_uuid)
self.assertIsNone(attachment.attached_host)
admin_metadata = vol.volume_admin_metadata
self.assertEqual(2, len(admin_metadata))
expected = dict(readonly='True', attached_mode='ro')
ret = {}
for item in admin_metadata:
ret.update({item['key']: item['value']})
self.assertDictEqual(expected, ret)
connector = {'initiator': 'iqn.2012-07.org.fake:01'}
volume = volume if volume_object else vol
conn_info = self.volume.initialize_connection(self.context,
volume, connector)
self.assertEqual('ro', conn_info['data']['access_mode'])
self.assertRaises(exception.VolumeAttached,
self.volume.delete_volume,
self.context,
volume=volume)
self.volume.detach_volume(self.context, volume_id,
attachment.id,
volume=volume_passed)
vol = objects.Volume.get_by_id(self.context, volume_id)
self.assertEqual('available', vol.status)
self.volume.delete_volume(self.context, volume)
self.assertRaises(exception.VolumeNotFound,
db.volume_get,
self.context,
volume_id)
def test_run_attach_detach_2volumes_for_instance(self):
"""Make sure volume can be attached and detached from instance."""
# attach first volume to the instance
mountpoint1 = "/dev/vdc"
instance_uuid = '12345678-1234-5678-1234-567812345678'
volume1 = tests_utils.create_volume(
self.context, admin_metadata={'readonly': 'True'},
**self.volume_params)
volume1_id = volume1['id']
self.volume.create_volume(self.context, volume1)
attachment = self.volume.attach_volume(self.context, volume1_id,
instance_uuid, None,
mountpoint1, 'ro')
vol1 = db.volume_get(context.get_admin_context(), volume1_id)
self.assertEqual("in-use", vol1['status'])
self.assertEqual('attached', attachment['attach_status'])
self.assertEqual(mountpoint1, attachment['mountpoint'])
self.assertEqual(instance_uuid, attachment['instance_uuid'])
self.assertIsNone(attachment['attached_host'])
admin_metadata = vol1['volume_admin_metadata']
self.assertEqual(2, len(admin_metadata))
expected = dict(readonly='True', attached_mode='ro')
ret = {}
for item in admin_metadata:
ret.update({item['key']: item['value']})
self.assertDictEqual(expected, ret)
connector = {'initiator': 'iqn.2012-07.org.fake:01'}
conn_info = self.volume.initialize_connection(self.context,
volume1, connector)
self.assertEqual('ro', conn_info['data']['access_mode'])
self.assertRaises(exception.VolumeAttached,
self.volume.delete_volume,
self.context,
volume1)
# attach 2nd volume to the instance
mountpoint2 = "/dev/vdd"
volume2 = tests_utils.create_volume(
self.context, admin_metadata={'readonly': 'False'},
**self.volume_params)
volume2_id = volume2['id']
self.volume.create_volume(self.context, volume2)
attachment2 = self.volume.attach_volume(self.context, volume2_id,
instance_uuid, None,
mountpoint2, 'rw')
vol2 = db.volume_get(context.get_admin_context(), volume2_id)
self.assertEqual("in-use", vol2['status'])
self.assertEqual('attached', attachment2['attach_status'])
self.assertEqual(mountpoint2, attachment2['mountpoint'])
self.assertEqual(instance_uuid, attachment2['instance_uuid'])
self.assertIsNone(attachment2['attached_host'])
admin_metadata = vol2['volume_admin_metadata']
self.assertEqual(2, len(admin_metadata))
expected = dict(readonly='False', attached_mode='rw')
ret = {}
for item in admin_metadata:
ret.update({item['key']: item['value']})
self.assertDictEqual(expected, ret)
connector = {'initiator': 'iqn.2012-07.org.fake:02'}
conn_info = self.volume.initialize_connection(self.context,
volume2, connector)
self.assertEqual('rw', conn_info['data']['access_mode'])
self.assertRaises(exception.VolumeAttached,
self.volume.delete_volume,
self.context,
volume2)
# detach first volume and then 2nd volume
self.volume.detach_volume(self.context, volume1_id, attachment['id'])
vol1 = db.volume_get(self.context, volume1_id)
self.assertEqual('available', vol1['status'])
self.volume.delete_volume(self.context, volume1)
self.assertRaises(exception.VolumeNotFound,
db.volume_get,
self.context,
volume1_id)
self.volume.detach_volume(self.context, volume2_id, attachment2['id'])
vol2 = db.volume_get(self.context, volume2_id)
self.assertEqual('available', vol2['status'])
self.volume.delete_volume(self.context, volume2)
self.assertRaises(exception.VolumeNotFound,
db.volume_get,
self.context,
volume2_id)
def test_detach_invalid_attachment_id(self):
"""Make sure if the attachment id isn't found we raise."""
attachment_id = "notfoundid"
volume = tests_utils.create_volume(self.context,
admin_metadata={'readonly': 'True'},
multiattach=False,
**self.volume_params)
self.volume.detach_volume(self.context, volume['id'],
attachment_id)
volume = db.volume_get(self.context, volume['id'])
self.assertEqual('available', volume['status'])
instance_uuid = '12345678-1234-5678-1234-567812345678'
attached_host = 'fake_host'
mountpoint = '/dev/fake'
tests_utils.attach_volume(self.context, volume['id'],
instance_uuid, attached_host,
mountpoint)
self.volume.detach_volume(self.context, volume['id'],
attachment_id)
volume = db.volume_get(self.context, volume['id'])
self.assertEqual('in-use', volume['status'])
def test_detach_no_attachments(self):
self.volume_params['status'] = 'detaching'
volume = tests_utils.create_volume(self.context,
admin_metadata={'readonly': 'True'},
multiattach=False,
**self.volume_params)
self.volume.detach_volume(self.context, volume['id'])
volume = db.volume_get(self.context, volume['id'])
self.assertEqual('available', volume['status'])
def test_run_attach_detach_volume_for_instance_no_attachment_id(self):
"""Make sure volume can be attached and detached from instance."""
mountpoint = "/dev/sdf"
# attach volume to the instance then to detach
instance_uuid = '12345678-1234-5678-1234-567812345678'
instance_uuid_2 = '12345678-4321-8765-4321-567812345678'
volume = tests_utils.create_volume(self.context,
admin_metadata={'readonly': 'True'},
multiattach=True,
**self.volume_params)
volume_id = volume['id']
self.volume.create_volume(self.context, volume)
attachment = self.volume.attach_volume(self.context, volume_id,
instance_uuid, None,
mountpoint, 'ro')
vol = db.volume_get(context.get_admin_context(), volume_id)
self.assertEqual('in-use', vol['status'])
self.assertEqual(fields.VolumeAttachStatus.ATTACHED,
attachment['attach_status'])
self.assertEqual(mountpoint, attachment['mountpoint'])
self.assertEqual(instance_uuid, attachment['instance_uuid'])
self.assertIsNone(attachment['attached_host'])
admin_metadata = vol['volume_admin_metadata']
self.assertEqual(2, len(admin_metadata))
expected = dict(readonly='True', attached_mode='ro')
ret = {}
for item in admin_metadata:
ret.update({item['key']: item['value']})
self.assertDictEqual(expected, ret)
attachment2 = self.volume.attach_volume(self.context, volume_id,
instance_uuid_2, None,
mountpoint, 'ro')
connector = {'initiator': 'iqn.2012-07.org.fake:01'}
conn_info = self.volume.initialize_connection(self.context,
volume, connector)
self.assertEqual('ro', conn_info['data']['access_mode'])
self.assertRaises(exception.VolumeAttached,
self.volume.delete_volume,
self.context,
volume)
self.assertRaises(exception.InvalidVolume,
self.volume.detach_volume,
self.context, volume_id)
self.volume.detach_volume(self.context, volume_id, attachment['id'])
vol = db.volume_get(self.context, volume_id)
self.assertEqual('in-use', vol['status'])
self.volume.detach_volume(self.context, volume_id, attachment2['id'])
vol = db.volume_get(self.context, volume_id)
self.assertEqual('available', vol['status'])
attachment = self.volume.attach_volume(self.context, volume_id,
instance_uuid, None,
mountpoint, 'ro')
vol = db.volume_get(self.context, volume_id)
self.assertEqual('in-use', vol['status'])
self.volume.detach_volume(self.context, volume_id)
vol = db.volume_get(self.context, volume_id)
self.assertEqual('available', vol['status'])
self.volume.delete_volume(self.context, volume)
self.assertRaises(exception.VolumeNotFound,
db.volume_get,
self.context,
volume_id)
def test_run_attach_detach_multiattach_volume_for_instances(self):
"""Make sure volume can be attached to multiple instances."""
mountpoint = "/dev/sdf"
# attach volume to the instance then to detach
instance_uuid = '12345678-1234-5678-1234-567812345678'
volume = tests_utils.create_volume(self.context,
admin_metadata={'readonly': 'True'},
multiattach=True,
**self.volume_params)
volume_id = volume['id']
self.volume.create_volume(self.context, volume)
attachment = self.volume.attach_volume(self.context, volume_id,
instance_uuid, None,
mountpoint, 'ro')
vol = db.volume_get(context.get_admin_context(), volume_id)
self.assertEqual('in-use', vol['status'])
self.assertTrue(vol['multiattach'])
self.assertEqual(fields.VolumeAttachStatus.ATTACHED,
attachment['attach_status'])
self.assertEqual(mountpoint, attachment['mountpoint'])
self.assertEqual(instance_uuid, attachment['instance_uuid'])
self.assertIsNone(attachment['attached_host'])
admin_metadata = vol['volume_admin_metadata']
self.assertEqual(2, len(admin_metadata))
expected = dict(readonly='True', attached_mode='ro')
ret = {}
for item in admin_metadata:
ret.update({item['key']: item['value']})
self.assertDictEqual(expected, ret)
connector = {'initiator': 'iqn.2012-07.org.fake:01'}
conn_info = self.volume.initialize_connection(self.context,
volume, connector)
self.assertEqual('ro', conn_info['data']['access_mode'])
instance2_uuid = '12345678-1234-5678-1234-567812345000'
mountpoint2 = "/dev/sdx"
attachment2 = self.volume.attach_volume(self.context, volume_id,
instance2_uuid, None,
mountpoint2, 'ro')
vol = db.volume_get(context.get_admin_context(), volume_id)
self.assertEqual('in-use', vol['status'])
self.assertTrue(vol['multiattach'])
self.assertEqual(fields.VolumeAttachStatus.ATTACHED,
attachment2['attach_status'])
self.assertEqual(mountpoint2, attachment2['mountpoint'])
self.assertEqual(instance2_uuid, attachment2['instance_uuid'])
self.assertIsNone(attachment2['attached_host'])
self.assertNotEqual(attachment, attachment2)
self.assertRaises(exception.VolumeAttached,
self.volume.delete_volume,
self.context,
volume)
self.volume.detach_volume(self.context, volume_id, attachment['id'])
vol = db.volume_get(self.context, volume_id)
self.assertEqual('in-use', vol['status'])
self.assertRaises(exception.VolumeAttached,
self.volume.delete_volume,
self.context,
volume)
self.volume.detach_volume(self.context, volume_id, attachment2['id'])
vol = db.volume_get(self.context, volume_id)
self.assertEqual('available', vol['status'])
self.volume.delete_volume(self.context, volume)
self.assertRaises(exception.VolumeNotFound,
db.volume_get,
self.context,
volume_id)
def test_run_attach_twice_multiattach_volume_for_instances(self):
"""Make sure volume can be attached to multiple instances."""
mountpoint = "/dev/sdf"
# attach volume to the instance then to detach
instance_uuid = '12345678-1234-5678-1234-567812345699'
volume = tests_utils.create_volume(self.context,
admin_metadata={'readonly': 'True'},
multiattach=True,
**self.volume_params)
volume_id = volume['id']
self.volume.create_volume(self.context, volume)
attachment = self.volume.attach_volume(self.context, volume_id,
instance_uuid, None,
mountpoint, 'ro')
vol = db.volume_get(context.get_admin_context(), volume_id)
self.assertEqual('in-use', vol['status'])
self.assertTrue(vol['multiattach'])
self.assertEqual(fields.VolumeAttachStatus.ATTACHED,
attachment['attach_status'])
self.assertEqual(mountpoint, attachment['mountpoint'])
self.assertEqual(instance_uuid, attachment['instance_uuid'])
self.assertIsNone(attachment['attached_host'])
admin_metadata = vol['volume_admin_metadata']
self.assertEqual(2, len(admin_metadata))
expected = dict(readonly='True', attached_mode='ro')
ret = {}
for item in admin_metadata:
ret.update({item['key']: item['value']})
self.assertDictEqual(expected, ret)
connector = {'initiator': 'iqn.2012-07.org.fake:01'}
conn_info = self.volume.initialize_connection(self.context,
volume, connector)
self.assertEqual('ro', conn_info['data']['access_mode'])
mountpoint2 = "/dev/sdx"
attachment2 = self.volume.attach_volume(self.context, volume_id,
instance_uuid, None,
mountpoint2, 'ro')
vol = db.volume_get(context.get_admin_context(), volume_id)
self.assertEqual('in-use', vol['status'])
self.assertTrue(vol['multiattach'])
self.assertEqual('attached', attachment2['attach_status'])
self.assertEqual(mountpoint, attachment2['mountpoint'])
self.assertEqual(instance_uuid, attachment2['instance_uuid'])
self.assertIsNone(attachment2['attached_host'])
self.assertRaises(exception.VolumeAttached,
self.volume.delete_volume,
self.context,
volume)
def test_attach_detach_not_multiattach_volume_for_instances(self):
"""Make sure volume can't be attached to more than one instance."""
mountpoint = "/dev/sdf"
# attach volume to the instance then to detach
instance_uuid = '12345678-1234-5678-1234-567812345678'
volume = tests_utils.create_volume(self.context,
admin_metadata={'readonly': 'True'},
multiattach=False,
**self.volume_params)
volume_id = volume['id']
self.volume.create_volume(self.context, volume)
attachment = self.volume.attach_volume(self.context, volume_id,
instance_uuid, None,
mountpoint, 'ro')
vol = db.volume_get(context.get_admin_context(), volume_id)
self.assertEqual('in-use', vol['status'])
self.assertFalse(vol['multiattach'])
self.assertEqual(fields.VolumeAttachStatus.ATTACHED,
attachment['attach_status'])
self.assertEqual(mountpoint, attachment['mountpoint'])
self.assertEqual(instance_uuid, attachment['instance_uuid'])
self.assertIsNone(attachment['attached_host'])
admin_metadata = vol['volume_admin_metadata']
self.assertEqual(2, len(admin_metadata))
expected = dict(readonly='True', attached_mode='ro')
ret = {}
for item in admin_metadata:
ret.update({item['key']: item['value']})
self.assertDictEqual(expected, ret)
connector = {'initiator': 'iqn.2012-07.org.fake:01'}
conn_info = self.volume.initialize_connection(self.context,
volume, connector)
self.assertEqual('ro', conn_info['data']['access_mode'])
instance2_uuid = '12345678-1234-5678-1234-567812345000'
mountpoint2 = "/dev/sdx"
self.assertRaises(exception.InvalidVolume,
self.volume.attach_volume,
self.context,
volume_id,
instance2_uuid,
None,
mountpoint2, 'ro')
self.assertRaises(exception.VolumeAttached,
self.volume.delete_volume,
self.context,
volume)
self.volume.detach_volume(self.context, volume_id, attachment['id'])
vol = db.volume_get(self.context, volume_id)
self.assertEqual('available', vol['status'])
self.volume.delete_volume(self.context, volume)
self.assertRaises(exception.VolumeNotFound,
db.volume_get,
self.context,
volume_id)
def test_run_attach_detach_volume_for_host(self):
"""Make sure volume can be attached and detached from host."""
mountpoint = "/dev/sdf"
volume = tests_utils.create_volume(
self.context,
admin_metadata={'readonly': 'False'},
**self.volume_params)
volume_id = volume['id']
self.volume.create_volume(self.context, volume)
attachment = self.volume.attach_volume(self.context, volume_id, None,
'fake_host', mountpoint, 'rw')
vol = db.volume_get(context.get_admin_context(), volume_id)
self.assertEqual('in-use', vol['status'])
self.assertEqual(fields.VolumeAttachStatus.ATTACHED,
attachment['attach_status'])
self.assertEqual(mountpoint, attachment['mountpoint'])
self.assertIsNone(attachment['instance_uuid'])
# sanitized, conforms to RFC-952 and RFC-1123 specs.
self.assertEqual('fake-host', attachment['attached_host'])
admin_metadata = vol['volume_admin_metadata']
self.assertEqual(2, len(admin_metadata))
expected = dict(readonly='False', attached_mode='rw')
ret = {}
for item in admin_metadata:
ret.update({item['key']: item['value']})
self.assertDictEqual(expected, ret)
connector = {'initiator': 'iqn.2012-07.org.fake:01'}
conn_info = self.volume.initialize_connection(self.context,
volume, connector)
self.assertEqual('rw', conn_info['data']['access_mode'])
self.assertRaises(exception.VolumeAttached,
self.volume.delete_volume,
self.context,
volume)
self.volume.detach_volume(self.context, volume_id, attachment['id'])
vol = db.volume_get(self.context, volume_id)
self.assertEqual("available", vol['status'])
self.volume.delete_volume(self.context, volume)
self.assertRaises(exception.VolumeNotFound,
db.volume_get,
self.context,
volume_id)
def test_run_attach_detach_multiattach_volume_for_hosts(self):
"""Make sure volume can be attached and detached from hosts."""
mountpoint = "/dev/sdf"
volume = tests_utils.create_volume(
self.context,
admin_metadata={'readonly': 'False'},
multiattach=True,
**self.volume_params)
volume_id = volume['id']
self.volume.create_volume(self.context, volume)
attachment = self.volume.attach_volume(self.context, volume_id, None,
'fake_host', mountpoint, 'rw')
vol = db.volume_get(context.get_admin_context(), volume_id)
self.assertEqual('in-use', vol['status'])
self.assertTrue(vol['multiattach'])
self.assertEqual(fields.VolumeAttachStatus.ATTACHED,
attachment['attach_status'])
self.assertEqual(mountpoint, attachment['mountpoint'])
self.assertIsNone(attachment['instance_uuid'])
# sanitized, conforms to RFC-952 and RFC-1123 specs.
self.assertEqual('fake-host', attachment['attached_host'])
admin_metadata = vol['volume_admin_metadata']
self.assertEqual(2, len(admin_metadata))
expected = dict(readonly='False', attached_mode='rw')
ret = {}
for item in admin_metadata:
ret.update({item['key']: item['value']})
self.assertDictEqual(expected, ret)
connector = {'initiator': 'iqn.2012-07.org.fake:01'}
conn_info = self.volume.initialize_connection(self.context,
volume, connector)
self.assertEqual('rw', conn_info['data']['access_mode'])
mountpoint2 = "/dev/sdx"
attachment2 = self.volume.attach_volume(self.context, volume_id, None,
'fake_host2', mountpoint2,
'rw')
vol = db.volume_get(context.get_admin_context(), volume_id)
self.assertEqual('in-use', vol['status'])
self.assertEqual(fields.VolumeAttachStatus.ATTACHED,
attachment2['attach_status'])
self.assertEqual(mountpoint2, attachment2['mountpoint'])
self.assertIsNone(attachment2['instance_uuid'])
# sanitized, conforms to RFC-952 and RFC-1123 specs.
self.assertEqual('fake-host2', attachment2['attached_host'])
self.assertRaises(exception.VolumeAttached,
self.volume.delete_volume,
self.context,
volume)
self.volume.detach_volume(self.context, volume_id, attachment['id'])
vol = db.volume_get(self.context, volume_id)
self.assertEqual("in-use", vol['status'])
self.volume.detach_volume(self.context, volume_id, attachment2['id'])
vol = db.volume_get(self.context, volume_id)
self.assertEqual("available", vol['status'])
self.volume.delete_volume(self.context, volume)
self.assertRaises(exception.VolumeNotFound,
db.volume_get,
self.context,
volume_id)
def test_run_attach_twice_multiattach_volume_for_hosts(self):
"""Make sure volume can be attached and detached from hosts."""
mountpoint = "/dev/sdf"
volume = tests_utils.create_volume(
self.context,
admin_metadata={'readonly': 'False'},
multiattach=True,
**self.volume_params)
volume_id = volume['id']
self.volume.create_volume(self.context, volume)
attachment = self.volume.attach_volume(self.context, volume_id, None,
'fake_host', mountpoint, 'rw')
vol = db.volume_get(context.get_admin_context(), volume_id)
self.assertEqual('in-use', vol['status'])
self.assertTrue(vol['multiattach'])
self.assertEqual(fields.VolumeAttachStatus.ATTACHED,
attachment['attach_status'])
self.assertEqual(mountpoint, attachment['mountpoint'])
self.assertIsNone(attachment['instance_uuid'])
# sanitized, conforms to RFC-952 and RFC-1123 specs.
self.assertEqual('fake-host', attachment['attached_host'])
admin_metadata = vol['volume_admin_metadata']
self.assertEqual(2, len(admin_metadata))
expected = dict(readonly='False', attached_mode='rw')
ret = {}
for item in admin_metadata:
ret.update({item['key']: item['value']})
self.assertDictEqual(expected, ret)
connector = {'initiator': 'iqn.2012-07.org.fake:01'}
conn_info = self.volume.initialize_connection(self.context,
volume, connector)
self.assertEqual('rw', conn_info['data']['access_mode'])
mountpoint2 = "/dev/sdx"
attachment2 = self.volume.attach_volume(self.context, volume_id, None,
'fake_host', mountpoint2,
'rw')
vol = db.volume_get(context.get_admin_context(), volume_id)
self.assertEqual('in-use', vol['status'])
self.assertEqual('attached', attachment2['attach_status'])
self.assertEqual(mountpoint, attachment2['mountpoint'])
self.assertIsNone(attachment2['instance_uuid'])
self.assertRaises(exception.VolumeAttached,
self.volume.delete_volume,
self.context,
volume)
def test_run_attach_detach_not_multiattach_volume_for_hosts(self):
"""Make sure volume can't be attached to more than one host."""
mountpoint = "/dev/sdf"
volume = tests_utils.create_volume(
self.context,
admin_metadata={'readonly': 'False'},
multiattach=False,
**self.volume_params)
volume_id = volume['id']
self.volume.create_volume(self.context, volume)
attachment = self.volume.attach_volume(self.context, volume_id, None,
'fake_host', mountpoint, 'rw')
vol = db.volume_get(context.get_admin_context(), volume_id)
self.assertEqual('in-use', vol['status'])
self.assertFalse(vol['multiattach'])
self.assertEqual(fields.VolumeAttachStatus.ATTACHED,
attachment['attach_status'])
self.assertEqual(mountpoint, attachment['mountpoint'])
self.assertIsNone(attachment['instance_uuid'])
# sanitized, conforms to RFC-952 and RFC-1123 specs.
self.assertEqual('fake-host', attachment['attached_host'])
admin_metadata = vol['volume_admin_metadata']
self.assertEqual(2, len(admin_metadata))
expected = dict(readonly='False', attached_mode='rw')
ret = {}
for item in admin_metadata:
ret.update({item['key']: item['value']})
self.assertDictEqual(expected, ret)
connector = {'initiator': 'iqn.2012-07.org.fake:01'}
conn_info = self.volume.initialize_connection(self.context,
volume, connector)
self.assertEqual('rw', conn_info['data']['access_mode'])
mountpoint2 = "/dev/sdx"
self.assertRaises(exception.InvalidVolume,
self.volume.attach_volume,
self.context,
volume_id,
None,
'fake_host2',
mountpoint2,
'rw')
vol = db.volume_get(context.get_admin_context(), volume_id)
self.assertEqual('in-use', vol['status'])
self.assertEqual(fields.VolumeAttachStatus.ATTACHED,
attachment['attach_status'])
self.assertEqual(mountpoint, attachment['mountpoint'])
self.assertIsNone(attachment['instance_uuid'])
# sanitized, conforms to RFC-952 and RFC-1123 specs.
self.assertEqual('fake-host', attachment['attached_host'])
self.assertRaises(exception.VolumeAttached,
self.volume.delete_volume,
self.context,
volume)
self.volume.detach_volume(self.context, volume_id, attachment['id'])
vol = db.volume_get(self.context, volume_id)
self.assertEqual('available', vol['status'])
self.volume.delete_volume(self.context, volume)
self.assertRaises(exception.VolumeNotFound,
db.volume_get,
self.context,
volume_id)
def test_run_attach_detach_volume_with_attach_mode(self):
instance_uuid = '12345678-1234-5678-1234-567812345678'
mountpoint = "/dev/sdf"
volume = tests_utils.create_volume(self.context,
admin_metadata={'readonly': 'True'},
**self.volume_params)
volume_id = volume['id']
db.volume_update(self.context, volume_id, {'status': 'available', })
self.volume.attach_volume(self.context, volume_id, instance_uuid,
None, mountpoint, 'ro')
vol = db.volume_get(context.get_admin_context(), volume_id)
attachment = vol['volume_attachment'][0]
self.assertEqual('in-use', vol['status'])
self.assertEqual(fields.VolumeAttachStatus.ATTACHED,
vol['attach_status'])
self.assertEqual(mountpoint, attachment['mountpoint'])
self.assertEqual(instance_uuid, attachment['instance_uuid'])
self.assertIsNone(attachment['attached_host'])
admin_metadata = vol['volume_admin_metadata']
self.assertEqual(2, len(admin_metadata))
expected = dict(readonly='True', attached_mode='ro')
ret = {}
for item in admin_metadata:
ret.update({item['key']: item['value']})
self.assertDictEqual(expected, ret)
connector = {'initiator': 'iqn.2012-07.org.fake:01'}
conn_info = self.volume.initialize_connection(self.context,
volume, connector)
self.assertEqual('ro', conn_info['data']['access_mode'])
self.volume.detach_volume(self.context, volume_id, attachment['id'])
vol = db.volume_get(self.context, volume_id)
attachment = vol['volume_attachment']
self.assertEqual('available', vol['status'])
self.assertEqual(fields.VolumeAttachStatus.DETACHED,
vol['attach_status'])
self.assertEqual([], attachment)
admin_metadata = vol['volume_admin_metadata']
self.assertEqual(1, len(admin_metadata))
self.assertEqual('readonly', admin_metadata[0]['key'])
self.assertEqual('True', admin_metadata[0]['value'])
self.volume.attach_volume(self.context, volume_id, None,
'fake_host', mountpoint, 'ro')
vol = db.volume_get(context.get_admin_context(), volume_id)
attachment = vol['volume_attachment'][0]
self.assertEqual('in-use', vol['status'])
self.assertEqual(fields.VolumeAttachStatus.ATTACHED,
vol['attach_status'])
self.assertEqual(mountpoint, attachment['mountpoint'])
self.assertIsNone(attachment['instance_uuid'])
self.assertEqual('fake-host', attachment['attached_host'])
admin_metadata = vol['volume_admin_metadata']
self.assertEqual(2, len(admin_metadata))
expected = dict(readonly='True', attached_mode='ro')
ret = {}
for item in admin_metadata:
ret.update({item['key']: item['value']})
self.assertDictEqual(expected, ret)
connector = {'initiator': 'iqn.2012-07.org.fake:01'}
conn_info = self.volume.initialize_connection(self.context,
volume, connector)
self.assertEqual('ro', conn_info['data']['access_mode'])
self.volume.detach_volume(self.context, volume_id,
attachment['id'])
vol = db.volume_get(self.context, volume_id)
attachment = vol['volume_attachment']
self.assertEqual('available', vol['status'])
self.assertEqual(fields.VolumeAttachStatus.DETACHED,
vol['attach_status'])
self.assertEqual([], attachment)
admin_metadata = vol['volume_admin_metadata']
self.assertEqual(1, len(admin_metadata))
self.assertEqual('readonly', admin_metadata[0]['key'])
self.assertEqual('True', admin_metadata[0]['value'])
self.volume.delete_volume(self.context, volume)
self.assertRaises(exception.VolumeNotFound,
db.volume_get,
self.context,
volume_id)
def test_run_manager_attach_detach_volume_with_wrong_attach_mode(self):
# Not allow using 'read-write' mode attach readonly volume
instance_uuid = '12345678-1234-5678-1234-567812345678'
mountpoint = "/dev/sdf"
volume = tests_utils.create_volume(self.context,
admin_metadata={'readonly': 'True'},
**self.volume_params)
volume_id = volume['id']
self.volume.create_volume(self.context, volume)
self.assertRaises(exception.InvalidVolumeAttachMode,
self.volume.attach_volume,
self.context,
volume_id,
instance_uuid,
None,
mountpoint,
'rw')
# Assert a user message was created
self.volume.message_api.create.assert_called_once_with(
self.context, defined_messages.EventIds.ATTACH_READONLY_VOLUME,
self.context.project_id, resource_type=resource_types.VOLUME,
resource_uuid=volume['id'])
attachment = objects.VolumeAttachmentList.get_all_by_volume_id(
context.get_admin_context(), volume_id)[0]
self.assertEqual(fields.VolumeAttachStatus.ERROR_ATTACHING,
attachment.attach_status)
vol = db.volume_get(context.get_admin_context(), volume_id)
self.assertEqual(fields.VolumeAttachStatus.DETACHED,
vol['attach_status'])
admin_metadata = vol['volume_admin_metadata']
self.assertEqual(2, len(admin_metadata))
expected = dict(readonly='True', attached_mode='rw')
ret = {}
for item in admin_metadata:
ret.update({item['key']: item['value']})
self.assertDictEqual(expected, ret)
db.volume_update(self.context, volume_id, {'status': 'available'})
self.assertRaises(exception.InvalidVolumeAttachMode,
self.volume.attach_volume,
self.context,
volume_id,
None,
'fake_host',
mountpoint,
'rw')
attachment = objects.VolumeAttachmentList.get_all_by_volume_id(
context.get_admin_context(), volume_id)[0]
self.assertEqual(fields.VolumeAttachStatus.ERROR_ATTACHING,
attachment.attach_status)
vol = db.volume_get(context.get_admin_context(), volume_id)
self.assertEqual(fields.VolumeAttachStatus.DETACHED,
vol['attach_status'])
admin_metadata = vol['volume_admin_metadata']
self.assertEqual(2, len(admin_metadata))
expected = dict(readonly='True', attached_mode='rw')
ret = {}
for item in admin_metadata:
ret.update({item['key']: item['value']})
self.assertDictEqual(expected, ret)
def test_run_api_attach_detach_volume_with_wrong_attach_mode(self):
# Not allow using 'read-write' mode attach readonly volume
instance_uuid = '12345678-1234-5678-1234-567812345678'
mountpoint = "/dev/sdf"
volume = tests_utils.create_volume(self.context,
admin_metadata={'readonly': 'True'},
**self.volume_params)
volume_id = volume['id']
self.volume.create_volume(self.context, volume)
volume_api = cinder.volume.api.API()
self.assertRaises(exception.InvalidVolumeAttachMode,
volume_api.attach,
self.context,
volume,
instance_uuid,
None,
mountpoint,
'rw')
vol = db.volume_get(context.get_admin_context(), volume_id)
self.assertEqual(fields.VolumeAttachStatus.DETACHED,
vol['attach_status'])
admin_metadata = vol['volume_admin_metadata']
self.assertEqual(1, len(admin_metadata))
self.assertEqual('readonly', admin_metadata[0]['key'])
self.assertEqual('True', admin_metadata[0]['value'])
db.volume_update(self.context, volume_id, {'status': 'available'})
self.assertRaises(exception.InvalidVolumeAttachMode,
volume_api.attach,
self.context,
volume,
None,
'fake_host',
mountpoint,
'rw')
vol = db.volume_get(context.get_admin_context(), volume_id)
self.assertEqual(fields.VolumeAttachStatus.DETACHED,
vol['attach_status'])
admin_metadata = vol['volume_admin_metadata']
self.assertEqual(1, len(admin_metadata))
self.assertEqual('readonly', admin_metadata[0]['key'])
self.assertEqual('True', admin_metadata[0]['value'])
def test_detach_volume_while_uploading_to_image_is_in_progress(self):
# If instance is booted from volume with 'Terminate on Delete' flag
# set, and when we delete instance then it tries to delete volume
# even it is in 'uploading' state.
# It is happening because detach call is setting volume status to
# 'available'.
mountpoint = "/dev/sdf"
# Attach volume to the instance
instance_uuid = '12345678-1234-5678-1234-567812345678'
volume = tests_utils.create_volume(self.context,
admin_metadata={'readonly': 'True'},
**self.volume_params)
volume_id = volume['id']
self.volume.create_volume(self.context, volume)
self.volume.attach_volume(self.context, volume_id, instance_uuid,
None, mountpoint, 'ro')
# Change volume status to 'uploading'
db.volume_update(self.context, volume_id, {'status': 'uploading'})
# Call detach api
self.volume.detach_volume(self.context, volume_id)
vol = db.volume_get(self.context, volume_id)
# Check that volume status is 'uploading'
self.assertEqual("uploading", vol['status'])
self.assertEqual(fields.VolumeAttachStatus.DETACHED,
vol['attach_status'])
def test_reserve_volume_success(self):
volume = tests_utils.create_volume(self.context, status='available')
cinder.volume.api.API().reserve_volume(self.context, volume)
volume_db = db.volume_get(self.context, volume.id)
self.assertEqual('attaching', volume_db.status)
db.volume_destroy(self.context, volume.id)
def test_reserve_volume_in_attaching(self):
self._test_reserve_volume_bad_status('attaching')
def test_reserve_volume_in_maintenance(self):
self._test_reserve_volume_bad_status('maintenance')
def _test_reserve_volume_bad_status(self, status):
volume = tests_utils.create_volume(self.context, status=status)
self.assertRaises(exception.InvalidVolume,
cinder.volume.api.API().reserve_volume,
self.context,
volume)
db.volume_destroy(self.context, volume.id)
def test_unreserve_volume_success_in_use(self):
UUID = six.text_type(uuid.uuid4())
volume = tests_utils.create_volume(self.context, status='attaching')
tests_utils.attach_volume(self.context, volume.id, UUID,
'attached_host', 'mountpoint', mode='rw')
cinder.volume.api.API().unreserve_volume(self.context, volume)
db_volume = db.volume_get(self.context, volume.id)
self.assertEqual('in-use', db_volume.status)
def test_unreserve_volume_success_available(self):
volume = tests_utils.create_volume(self.context, status='attaching')
cinder.volume.api.API().unreserve_volume(self.context, volume)
db_volume = db.volume_get(self.context, volume.id)
self.assertEqual('available', db_volume.status)
def test_multi_node(self):
# TODO(termie): Figure out how to test with two nodes,
# each of them having a different FLAG for storage_node
# This will allow us to test cross-node interactions
pass
@mock.patch('cinder.tests.unit.fake_notifier.FakeNotifier._notify')
def test_create_delete_snapshot(self, mock_notify):
"""Test snapshot can be created and deleted."""
volume = tests_utils.create_volume(
self.context,
availability_zone=CONF.storage_availability_zone,
**self.volume_params)
mock_notify.assert_not_called()
self.volume.create_volume(self.context, volume)
self.assert_notify_called(mock_notify,
(['INFO', 'volume.create.start'],
['INFO', 'volume.create.end']))
snapshot = create_snapshot(volume['id'], size=volume['size'])
snapshot_id = snapshot.id
self.volume.create_snapshot(self.context, snapshot)
self.assertEqual(
snapshot_id, objects.Snapshot.get_by_id(self.context,
snapshot_id).id)
self.assert_notify_called(mock_notify,
(['INFO', 'volume.create.start'],
['INFO', 'volume.create.end'],
['INFO', 'snapshot.create.start'],
['INFO', 'snapshot.create.end']))
self.volume.delete_snapshot(self.context, snapshot)
self.assert_notify_called(mock_notify,
(['INFO', 'volume.create.start'],
['INFO', 'volume.create.end'],
['INFO', 'snapshot.create.start'],
['INFO', 'snapshot.create.end'],
['INFO', 'snapshot.delete.start'],
['INFO', 'snapshot.delete.end']))
snap = objects.Snapshot.get_by_id(context.get_admin_context(
read_deleted='yes'), snapshot_id)
self.assertEqual(fields.SnapshotStatus.DELETED, snap.status)
self.assertRaises(exception.NotFound,
db.snapshot_get,
self.context,
snapshot_id)
self.volume.delete_volume(self.context, volume)
def test_create_delete_snapshot_with_metadata(self):
"""Test snapshot can be created with metadata and deleted."""
test_meta = {'fake_key': 'fake_value'}
volume = tests_utils.create_volume(self.context, **self.volume_params)
snapshot = create_snapshot(volume['id'], size=volume['size'],
metadata=test_meta)
snapshot_id = snapshot.id
result_dict = snapshot.metadata
self.assertEqual(test_meta, result_dict)
self.volume.delete_snapshot(self.context, snapshot)
self.assertRaises(exception.NotFound,
db.snapshot_get,
self.context,
snapshot_id)
def test_delete_snapshot_another_cluster_fails(self):
"""Test delete of snapshot from another cluster fails."""
self.volume.cluster = 'mycluster'
volume = tests_utils.create_volume(self.context, status='available',
size=1, host=CONF.host + 'fake',
cluster_name=self.volume.cluster)
snapshot = create_snapshot(volume.id, size=volume.size)
self.volume.delete_snapshot(self.context, snapshot)
self.assertRaises(exception.NotFound,
db.snapshot_get,
self.context,
snapshot.id)
@mock.patch.object(db, 'snapshot_create',
side_effect=exception.InvalidSnapshot(
'Create snapshot in db failed!'))
def test_create_snapshot_failed_db_snapshot(self, mock_snapshot):
"""Test exception handling when create snapshot in db failed."""
test_volume = tests_utils.create_volume(
self.context,
status='available',
host=CONF.host)
volume_api = cinder.volume.api.API()
self.assertRaises(exception.InvalidSnapshot,
volume_api.create_snapshot,
self.context,
test_volume,
'fake_name',
'fake_description')
def test_create_snapshot_failed_maintenance(self):
"""Test exception handling when create snapshot in maintenance."""
test_volume = tests_utils.create_volume(
self.context,
status='maintenance',
host=CONF.host)
volume_api = cinder.volume.api.API()
self.assertRaises(exception.InvalidVolume,
volume_api.create_snapshot,
self.context,
test_volume,
'fake_name',
'fake_description')
@mock.patch.object(QUOTAS, 'commit',
side_effect=exception.QuotaError(
'Snapshot quota commit failed!'))
def test_create_snapshot_failed_quota_commit(self, mock_snapshot):
"""Test exception handling when snapshot quota commit failed."""
test_volume = tests_utils.create_volume(
self.context,
status='available',
host=CONF.host)
volume_api = cinder.volume.api.API()
self.assertRaises(exception.QuotaError,
volume_api.create_snapshot,
self.context,
test_volume,
'fake_name',
'fake_description')
@mock.patch.object(QUOTAS, 'reserve',
side_effect = OVER_SNAPSHOT_QUOTA_EXCEPTION)
def test_create_snapshot_failed_quota_reserve(self, mock_reserve):
"""Test exception handling when snapshot quota reserve failed."""
test_volume = tests_utils.create_volume(
self.context,
status='available',
host=CONF.host)
volume_api = cinder.volume.api.API()
self.assertRaises(exception.SnapshotLimitExceeded,
volume_api.create_snapshot,
self.context,
test_volume,
'fake_name',
'fake_description')
@mock.patch.object(QUOTAS, 'reserve',
side_effect = OVER_SNAPSHOT_QUOTA_EXCEPTION)
def test_create_snapshots_in_db_failed_quota_reserve(self, mock_reserve):
"""Test exception handling when snapshot quota reserve failed."""
test_volume = tests_utils.create_volume(
self.context,
status='available',
host=CONF.host)
volume_api = cinder.volume.api.API()
self.assertRaises(exception.SnapshotLimitExceeded,
volume_api.create_snapshots_in_db,
self.context,
[test_volume],
'fake_name',
'fake_description',
fake.CONSISTENCY_GROUP_ID)
def test_create_snapshot_failed_host_is_None(self):
"""Test exception handling when create snapshot and host is None."""
test_volume = tests_utils.create_volume(
self.context,
host=None)
volume_api = cinder.volume.api.API()
self.assertRaises(exception.InvalidVolume,
volume_api.create_snapshot,
self.context,
test_volume,
'fake_name',
'fake_description')
def test_cannot_delete_volume_in_use(self):
"""Test volume can't be deleted in in-use status."""
self._test_cannot_delete_volume('in-use')
def test_cannot_delete_volume_maintenance(self):
"""Test volume can't be deleted in maintenance status."""
self._test_cannot_delete_volume('maintenance')
def _test_cannot_delete_volume(self, status):
"""Test volume can't be deleted in invalid stats."""
# create a volume and assign to host
volume = tests_utils.create_volume(self.context, CONF.host,
status=status)
# 'in-use' status raises InvalidVolume
self.assertRaises(exception.InvalidVolume,
self.volume_api.delete,
self.context,
volume)
# clean up
self.volume.delete_volume(self.context, volume)
def test_force_delete_volume(self):
"""Test volume can be forced to delete."""
# create a volume and assign to host
self.volume_params['status'] = 'error_deleting'
volume = tests_utils.create_volume(self.context, **self.volume_params)
# 'error_deleting' volumes can't be deleted
self.assertRaises(exception.InvalidVolume,
self.volume_api.delete,
self.context,
volume)
# delete with force
self.volume_api.delete(self.context, volume, force=True)
# status is deleting
volume = objects.Volume.get_by_id(context.get_admin_context(),
volume.id)
self.assertEqual('deleting', volume.status)
# clean up
self.volume.delete_volume(self.context, volume)
def test_cannot_force_delete_attached_volume(self):
"""Test volume can't be force delete in attached state."""
volume = tests_utils.create_volume(self.context, CONF.host,
status='in-use',
attach_status=
fields.VolumeAttachStatus.ATTACHED)
self.assertRaises(exception.InvalidVolume,
self.volume_api.delete,
self.context,
volume,
force=True)
db.volume_destroy(self.context, volume.id)
def test_cannot_delete_volume_with_snapshots(self):
"""Test volume can't be deleted with dependent snapshots."""
volume = tests_utils.create_volume(self.context, **self.volume_params)
self.volume.create_volume(self.context, volume)
snapshot = create_snapshot(volume['id'], size=volume['size'])
self.volume.create_snapshot(self.context, snapshot)
self.assertEqual(
snapshot.id, objects.Snapshot.get_by_id(self.context,
snapshot.id).id)
volume['status'] = 'available'
volume['host'] = 'fakehost'
volume_api = cinder.volume.api.API()
self.assertRaises(exception.InvalidVolume,
volume_api.delete,
self.context,
volume)
self.volume.delete_snapshot(self.context, snapshot)
self.volume.delete_volume(self.context, volume)
def test_can_delete_errored_snapshot(self):
"""Test snapshot can be created and deleted."""
volume = tests_utils.create_volume(self.context, CONF.host)
snapshot = create_snapshot(volume.id, size=volume['size'],
ctxt=self.context,
status=fields.SnapshotStatus.ERROR)
self.volume_api.delete_snapshot(self.context, snapshot)
self.assertEqual(fields.SnapshotStatus.DELETING, snapshot.status)
self.volume.delete_volume(self.context, volume)
def test_cannot_delete_snapshot_with_bad_status(self):
volume = tests_utils.create_volume(self.context, CONF.host)
snapshot = create_snapshot(volume.id, size=volume['size'],
ctxt=self.context,
status=fields.SnapshotStatus.CREATING)
self.assertRaises(exception.InvalidSnapshot,
self.volume_api.delete_snapshot,
self.context,
snapshot)
snapshot.status = fields.SnapshotStatus.ERROR
snapshot.save()
self.volume_api.delete_snapshot(self.context, snapshot)
self.assertEqual(fields.SnapshotStatus.DELETING, snapshot.status)
self.volume.delete_volume(self.context, volume)
def test_create_snapshot_force(self):
"""Test snapshot in use can be created forcibly."""
instance_uuid = '12345678-1234-5678-1234-567812345678'
# create volume and attach to the instance
volume = tests_utils.create_volume(self.context, **self.volume_params)
self.volume.create_volume(self.context, volume)
values = {'volume_id': volume['id'],
'instance_uuid': instance_uuid,
'attach_status': fields.VolumeAttachStatus.ATTACHING, }
attachment = db.volume_attach(self.context, values)
db.volume_attached(self.context, attachment['id'], instance_uuid,
None, '/dev/sda1')
volume_api = cinder.volume.api.API()
volume = volume_api.get(self.context, volume['id'])
self.assertRaises(exception.InvalidVolume,
volume_api.create_snapshot,
self.context, volume,
'fake_name', 'fake_description')
snapshot_ref = volume_api.create_snapshot_force(self.context,
volume,
'fake_name',
'fake_description')
snapshot_ref.destroy()
db.volume_destroy(self.context, volume['id'])
# create volume and attach to the host
volume = tests_utils.create_volume(self.context, **self.volume_params)
self.volume.create_volume(self.context, volume)
values = {'volume_id': volume['id'],
'attached_host': 'fake_host',
'attach_status': fields.VolumeAttachStatus.ATTACHING, }
attachment = db.volume_attach(self.context, values)
db.volume_attached(self.context, attachment['id'], None,
'fake_host', '/dev/sda1')
volume_api = cinder.volume.api.API()
volume = volume_api.get(self.context, volume['id'])
self.assertRaises(exception.InvalidVolume,
volume_api.create_snapshot,
self.context, volume,
'fake_name', 'fake_description')
snapshot_ref = volume_api.create_snapshot_force(self.context,
volume,
'fake_name',
'fake_description')
snapshot_ref.destroy()
db.volume_destroy(self.context, volume['id'])
@mock.patch('cinder.image.image_utils.qemu_img_info')
def test_create_snapshot_from_bootable_volume(self, mock_qemu_info):
"""Test create snapshot from bootable volume."""
# create bootable volume from image
volume = self._create_volume_from_image()
volume_id = volume['id']
self.assertEqual('available', volume['status'])
self.assertTrue(volume['bootable'])
image_info = imageutils.QemuImgInfo()
image_info.virtual_size = '1073741824'
mock_qemu_info.return_value = image_info
# get volume's volume_glance_metadata
ctxt = context.get_admin_context()
vol_glance_meta = db.volume_glance_metadata_get(ctxt, volume_id)
self.assertTrue(vol_glance_meta)
# create snapshot from bootable volume
snap = create_snapshot(volume_id)
self.volume.create_snapshot(ctxt, snap)
# get snapshot's volume_glance_metadata
snap_glance_meta = db.volume_snapshot_glance_metadata_get(
ctxt, snap.id)
self.assertTrue(snap_glance_meta)
# ensure that volume's glance metadata is copied
# to snapshot's glance metadata
self.assertEqual(len(vol_glance_meta), len(snap_glance_meta))
vol_glance_dict = {x.key: x.value for x in vol_glance_meta}
snap_glance_dict = {x.key: x.value for x in snap_glance_meta}
self.assertDictEqual(vol_glance_dict, snap_glance_dict)
# ensure that snapshot's status is changed to 'available'
self.assertEqual(fields.SnapshotStatus.AVAILABLE, snap.status)
# cleanup resource
snap.destroy()
db.volume_destroy(ctxt, volume_id)
@mock.patch('cinder.image.image_utils.qemu_img_info')
def test_create_snapshot_from_bootable_volume_fail(self, mock_qemu_info):
"""Test create snapshot from bootable volume.
But it fails to volume_glance_metadata_copy_to_snapshot.
As a result, status of snapshot is changed to ERROR.
"""
# create bootable volume from image
volume = self._create_volume_from_image()
volume_id = volume['id']
self.assertEqual('available', volume['status'])
self.assertTrue(volume['bootable'])
image_info = imageutils.QemuImgInfo()
image_info.virtual_size = '1073741824'
mock_qemu_info.return_value = image_info
# get volume's volume_glance_metadata
ctxt = context.get_admin_context()
vol_glance_meta = db.volume_glance_metadata_get(ctxt, volume_id)
self.assertTrue(vol_glance_meta)
snap = create_snapshot(volume_id)
snap_stat = snap.status
self.assertTrue(snap.id)
self.assertTrue(snap_stat)
# set to return DB exception
with mock.patch.object(db, 'volume_glance_metadata_copy_to_snapshot')\
as mock_db:
mock_db.side_effect = exception.MetadataCopyFailure(
reason="Because of DB service down.")
# create snapshot from bootable volume
self.assertRaises(exception.MetadataCopyFailure,
self.volume.create_snapshot,
ctxt,
snap)
# get snapshot's volume_glance_metadata
self.assertRaises(exception.GlanceMetadataNotFound,
db.volume_snapshot_glance_metadata_get,
ctxt, snap.id)
# ensure that status of snapshot is 'error'
self.assertEqual(fields.SnapshotStatus.ERROR, snap.status)
# cleanup resource
snap.destroy()
db.volume_destroy(ctxt, volume_id)
def test_create_snapshot_from_bootable_volume_with_volume_metadata_none(
self):
volume = tests_utils.create_volume(self.context, **self.volume_params)
volume_id = volume['id']
self.volume.create_volume(self.context, volume)
# set bootable flag of volume to True
db.volume_update(self.context, volume_id, {'bootable': True})
snapshot = create_snapshot(volume['id'])
self.volume.create_snapshot(self.context, snapshot)
self.assertRaises(exception.GlanceMetadataNotFound,
db.volume_snapshot_glance_metadata_get,
self.context, snapshot.id)
# ensure that status of snapshot is 'available'
self.assertEqual(fields.SnapshotStatus.AVAILABLE, snapshot.status)
# cleanup resource
snapshot.destroy()
db.volume_destroy(self.context, volume_id)
def test_delete_busy_snapshot(self):
"""Test snapshot can be created and deleted."""
self.volume.driver.vg = fake_lvm.FakeBrickLVM('cinder-volumes',
False,
None,
'default')
volume = tests_utils.create_volume(self.context, **self.volume_params)
volume_id = volume['id']
self.volume.create_volume(self.context, volume)
snapshot = create_snapshot(volume_id, size=volume['size'])
self.volume.create_snapshot(self.context, snapshot)
with mock.patch.object(self.volume.driver, 'delete_snapshot',
side_effect=exception.SnapshotIsBusy(
snapshot_name='fake')
) as mock_del_snap:
snapshot_id = snapshot.id
self.volume.delete_snapshot(self.context, snapshot)
snapshot_ref = objects.Snapshot.get_by_id(self.context,
snapshot_id)
self.assertEqual(snapshot_id, snapshot_ref.id)
self.assertEqual(fields.SnapshotStatus.AVAILABLE,
snapshot_ref.status)
mock_del_snap.assert_called_once_with(snapshot)
@test.testtools.skipIf(sys.platform == "darwin", "SKIP on OSX")
def test_delete_no_dev_fails(self):
"""Test delete snapshot with no dev file fails."""
self.mock_object(os.path, 'exists', lambda x: False)
self.volume.driver.vg = fake_lvm.FakeBrickLVM('cinder-volumes',
False,
None,
'default')
volume = tests_utils.create_volume(self.context, **self.volume_params)
volume_id = volume['id']
self.volume.create_volume(self.context, volume)
snapshot = create_snapshot(volume_id)
snapshot_id = snapshot.id
self.volume.create_snapshot(self.context, snapshot)
with mock.patch.object(self.volume.driver, 'delete_snapshot',
side_effect=exception.SnapshotIsBusy(
snapshot_name='fake')) as mock_del_snap:
self.volume.delete_snapshot(self.context, snapshot)
snapshot_ref = objects.Snapshot.get_by_id(self.context,
snapshot_id)
self.assertEqual(snapshot_id, snapshot_ref.id)
self.assertEqual(fields.SnapshotStatus.AVAILABLE,
snapshot_ref.status)
mock_del_snap.assert_called_once_with(snapshot)
@mock.patch('cinder.volume.drivers.lvm.LVMVolumeDriver.'
'create_cloned_volume')
@mock.patch('cinder.quota.QUOTAS.rollback')
@mock.patch('cinder.quota.QUOTAS.commit')
@mock.patch('cinder.quota.QUOTAS.reserve', return_value=["RESERVATION"])
def test_clone_image_volume(self, mock_reserve, mock_commit,
mock_rollback, mock_cloned_volume):
vol = tests_utils.create_volume(self.context,
**self.volume_params)
# unnecessary attributes should be removed from image volume
vol.consistencygroup = None
result = self.volume._clone_image_volume(self.context, vol,
{'id': fake.VOLUME_ID})
self.assertNotEqual(False, result)
mock_reserve.assert_called_once_with(self.context, volumes=1,
gigabytes=vol.size)
mock_commit.assert_called_once_with(self.context, ["RESERVATION"],
project_id=vol.project_id)
@mock.patch('cinder.quota.QUOTAS.rollback')
@mock.patch('cinder.quota.QUOTAS.commit')
@mock.patch('cinder.quota.QUOTAS.reserve', return_value=["RESERVATION"])
def test_clone_image_volume_creation_failure(self, mock_reserve,
mock_commit, mock_rollback):
vol = tests_utils.create_volume(self.context, **self.volume_params)
with mock.patch.object(objects, 'Volume', side_effect=ValueError):
self.assertFalse(self.volume._clone_image_volume(
self.context, vol, {'id': fake.VOLUME_ID}))
mock_reserve.assert_called_once_with(self.context, volumes=1,
gigabytes=vol.size)
mock_rollback.assert_called_once_with(self.context, ["RESERVATION"])
@mock.patch('cinder.image.image_utils.qemu_img_info')
def test_create_volume_from_image_cloned_status_available(
self, mock_qemu_info):
"""Test create volume from image via cloning.
Verify that after cloning image to volume, it is in available
state and is bootable.
"""
image_info = imageutils.QemuImgInfo()
image_info.virtual_size = '1073741824'
mock_qemu_info.return_value = image_info
volume = self._create_volume_from_image()
self.assertEqual('available', volume['status'])
self.assertTrue(volume['bootable'])
self.volume.delete_volume(self.context, volume)
@mock.patch('cinder.image.image_utils.qemu_img_info')
def test_create_volume_from_image_not_cloned_status_available(
self, mock_qemu_info):
"""Test create volume from image via full copy.
Verify that after copying image to volume, it is in available
state and is bootable.
"""
image_info = imageutils.QemuImgInfo()
image_info.virtual_size = '1073741824'
mock_qemu_info.return_value = image_info
volume = self._create_volume_from_image(fakeout_clone_image=True)
self.assertEqual('available', volume['status'])
self.assertTrue(volume['bootable'])
self.volume.delete_volume(self.context, volume)
def test_create_volume_from_image_exception(self):
"""Test create volume from a non-existing image.
Verify that create volume from a non-existing image, the volume
status is 'error' and is not bootable.
"""
dst_fd, dst_path = tempfile.mkstemp()
os.close(dst_fd)
self.mock_object(self.volume.driver, 'local_path', lambda x: dst_path)
# creating volume testdata
kwargs = {'display_description': 'Test Desc',
'size': 20,
'availability_zone': 'fake_availability_zone',
'status': 'creating',
'attach_status': fields.VolumeAttachStatus.DETACHED,
'host': 'dummy'}
volume = objects.Volume(context=self.context, **kwargs)
volume.create()
self.assertRaises(exception.ImageNotFound,
self.volume.create_volume,
self.context,
volume,
{'image_id': self.FAKE_UUID})
volume = objects.Volume.get_by_id(self.context, volume.id)
self.assertEqual("error", volume['status'])
self.assertFalse(volume['bootable'])
# cleanup
volume.destroy()
os.unlink(dst_path)
@mock.patch('cinder.image.image_utils.qemu_img_info')
def test_create_volume_from_image_copy_exception_rescheduling(
self, mock_qemu_info):
"""Test create volume with ImageCopyFailure
This exception should not trigger rescheduling and allocated_capacity
should be incremented so we're having assert for that here.
"""
image_info = imageutils.QemuImgInfo()
image_info.virtual_size = '1073741824'
mock_qemu_info.return_value = image_info
def fake_copy_image_to_volume(context, volume, image_service,
image_id):
raise exception.ImageCopyFailure()
self.mock_object(self.volume.driver, 'copy_image_to_volume',
fake_copy_image_to_volume)
mock_delete = self.mock_object(self.volume.driver, 'delete_volume')
self.assertRaises(exception.ImageCopyFailure,
self._create_volume_from_image)
# NOTE(dulek): Rescheduling should not occur, so lets assert that
# allocated_capacity is incremented.
self.assertDictEqual(self.volume.stats['pools'],
{'_pool0': {'allocated_capacity_gb': 1}})
# NOTE(dulek): As we haven't rescheduled, make sure no delete_volume
# was called.
self.assertFalse(mock_delete.called)
@mock.patch('cinder.utils.brick_get_connector_properties')
@mock.patch('cinder.utils.brick_get_connector')
@mock.patch('cinder.volume.driver.BaseVD.secure_file_operations_enabled')
@mock.patch('cinder.volume.driver.BaseVD._detach_volume')
@mock.patch('cinder.image.image_utils.qemu_img_info')
def test_create_volume_from_image_unavailable(
self, mock_qemu_info, mock_detach, mock_secure, *args):
"""Test create volume with ImageCopyFailure
We'll raise an exception inside _connect_device after volume has
already been attached to confirm that it detaches the volume.
"""
mock_secure.side_effect = NameError
image_info = imageutils.QemuImgInfo()
image_info.virtual_size = '1073741824'
mock_qemu_info.return_value = image_info
unbound_copy_method = cinder.volume.driver.BaseVD.copy_image_to_volume
bound_copy_method = unbound_copy_method.__get__(self.volume.driver)
with mock.patch.object(self.volume.driver, 'copy_image_to_volume',
side_effect=bound_copy_method):
self.assertRaises(exception.ImageCopyFailure,
self._create_volume_from_image,
fakeout_copy_image_to_volume=False)
# We must have called detach method.
self.assertEqual(1, mock_detach.call_count)
@mock.patch('cinder.image.image_utils.qemu_img_info')
def test_create_volume_from_image_clone_image_volume(self, mock_qemu_info):
"""Test create volume from image via image volume.
Verify that after cloning image to volume, it is in available
state and is bootable.
"""
image_info = imageutils.QemuImgInfo()
image_info.virtual_size = '1073741824'
mock_qemu_info.return_value = image_info
volume = self._create_volume_from_image(clone_image_volume=True)
self.assertEqual('available', volume['status'])
self.assertTrue(volume['bootable'])
self.volume.delete_volume(self.context, volume)
def test_create_volume_from_exact_sized_image(self):
"""Test create volume from an image of the same size.
Verify that an image which is exactly the same size as the
volume, will work correctly.
"""
try:
volume_id = None
volume_api = cinder.volume.api.API(
image_service=FakeImageService())
volume = volume_api.create(self.context, 2, 'name', 'description',
image_id=self.FAKE_UUID)
volume_id = volume['id']
self.assertEqual('creating', volume['status'])
finally:
# cleanup
db.volume_destroy(self.context, volume_id)
def test_create_volume_from_oversized_image(self):
"""Verify that an image which is too big will fail correctly."""
class _ModifiedFakeImageService(FakeImageService):
def show(self, context, image_id):
return {'size': 2 * units.Gi + 1,
'disk_format': 'raw',
'container_format': 'bare',
'status': 'active'}
volume_api = cinder.volume.api.API(
image_service=_ModifiedFakeImageService())
self.assertRaises(exception.InvalidInput,
volume_api.create,
self.context, 2,
'name', 'description', image_id=1)
def test_create_volume_with_mindisk_error(self):
"""Verify volumes smaller than image minDisk will cause an error."""
class _ModifiedFakeImageService(FakeImageService):
def show(self, context, image_id):
return {'size': 2 * units.Gi,
'disk_format': 'raw',
'container_format': 'bare',
'min_disk': 5,
'status': 'active'}
volume_api = cinder.volume.api.API(
image_service=_ModifiedFakeImageService())
self.assertRaises(exception.InvalidInput,
volume_api.create,
self.context, 2,
'name', 'description', image_id=1)
def test_create_volume_with_deleted_imaged(self):
"""Verify create volume from image will cause an error."""
class _ModifiedFakeImageService(FakeImageService):
def show(self, context, image_id):
return {'size': 2 * units.Gi,
'disk_format': 'raw',
'container_format': 'bare',
'min_disk': 5,
'status': 'deleted'}
volume_api = cinder.volume.api.API(
image_service=_ModifiedFakeImageService())
self.assertRaises(exception.InvalidInput,
volume_api.create,
self.context, 2,
'name', 'description', image_id=1)
@mock.patch.object(QUOTAS, "rollback")
@mock.patch.object(QUOTAS, "commit")
@mock.patch.object(QUOTAS, "reserve", return_value=["RESERVATION"])
def _do_test_create_volume_with_size(self, size, *_unused_quota_mocks):
volume_api = cinder.volume.api.API()
volume = volume_api.create(self.context,
size,
'name',
'description')
self.assertEqual(int(size), volume['size'])
def test_create_volume_int_size(self):
"""Test volume creation with int size."""
self._do_test_create_volume_with_size(2)
def test_create_volume_string_size(self):
"""Test volume creation with string size."""
self._do_test_create_volume_with_size('2')
@mock.patch.object(QUOTAS, "rollback")
@mock.patch.object(QUOTAS, "commit")
@mock.patch.object(QUOTAS, "reserve", return_value=["RESERVATION"])
def test_create_volume_with_bad_size(self, *_unused_quota_mocks):
volume_api = cinder.volume.api.API()
self.assertRaises(exception.InvalidInput,
volume_api.create,
self.context,
'2Gb',
'name',
'description')
def test_create_volume_with_float_fails(self):
"""Test volume creation with invalid float size."""
volume_api = cinder.volume.api.API()
self.assertRaises(exception.InvalidInput,
volume_api.create,
self.context,
'1.5',
'name',
'description')
def test_create_volume_with_zero_size_fails(self):
"""Test volume creation with string size."""
volume_api = cinder.volume.api.API()
self.assertRaises(exception.InvalidInput,
volume_api.create,
self.context,
'0',
'name',
'description')
def test_begin_detaching_fails_available(self):
volume_api = cinder.volume.api.API()
volume = tests_utils.create_volume(self.context, status='available')
# Volume status is 'available'.
self.assertRaises(exception.InvalidVolume, volume_api.begin_detaching,
self.context, volume)
db.volume_update(self.context, volume.id,
{'status': 'in-use',
'attach_status':
fields.VolumeAttachStatus.DETACHED})
# Should raise an error since not attached
self.assertRaises(exception.InvalidVolume, volume_api.begin_detaching,
self.context, volume)
db.volume_update(self.context, volume.id,
{'attach_status':
fields.VolumeAttachStatus.ATTACHED})
# Ensure when attached no exception raised
volume_api.begin_detaching(self.context, volume)
volume_api.update(self.context, volume, {'status': 'maintenance'})
self.assertRaises(exception.InvalidVolume, volume_api.begin_detaching,
self.context, volume)
db.volume_destroy(self.context, volume.id)
def test_begin_roll_detaching_volume(self):
"""Test begin_detaching and roll_detaching functions."""
instance_uuid = '12345678-1234-5678-1234-567812345678'
volume = tests_utils.create_volume(self.context, **self.volume_params)
attachment = db.volume_attach(self.context,
{'volume_id': volume['id'],
'attached_host': 'fake-host'})
db.volume_attached(self.context, attachment['id'], instance_uuid,
'fake-host', 'vdb')
volume_api = cinder.volume.api.API()
volume_api.begin_detaching(self.context, volume)
volume = volume_api.get(self.context, volume['id'])
self.assertEqual("detaching", volume['status'])
volume_api.roll_detaching(self.context, volume)
volume = volume_api.get(self.context, volume['id'])
self.assertEqual("in-use", volume['status'])
def test_volume_api_update(self):
# create a raw vol
volume = tests_utils.create_volume(self.context, **self.volume_params)
# use volume.api to update name
volume_api = cinder.volume.api.API()
update_dict = {'display_name': 'test update name'}
volume_api.update(self.context, volume, update_dict)
# read changes from db
vol = db.volume_get(context.get_admin_context(), volume['id'])
self.assertEqual('test update name', vol['display_name'])
def test_volume_api_update_maintenance(self):
# create a raw vol
volume = tests_utils.create_volume(self.context, **self.volume_params)
volume['status'] = 'maintenance'
# use volume.api to update name
volume_api = cinder.volume.api.API()
update_dict = {'display_name': 'test update name'}
self.assertRaises(exception.InvalidVolume, volume_api.update,
self.context, volume, update_dict)
def test_volume_api_update_snapshot(self):
# create raw snapshot
volume = tests_utils.create_volume(self.context, **self.volume_params)
snapshot = create_snapshot(volume['id'])
snapshot_id = snapshot.id
self.assertIsNone(snapshot.display_name)
# use volume.api to update name
volume_api = cinder.volume.api.API()
update_dict = {'display_name': 'test update name'}
volume_api.update_snapshot(self.context, snapshot, update_dict)
# read changes from db
snap = objects.Snapshot.get_by_id(context.get_admin_context(),
snapshot_id)
self.assertEqual('test update name', snap.display_name)
def test_volume_api_get_list_volumes_image_metadata(self):
"""Test get_list_volumes_image_metadata in volume API."""
ctxt = context.get_admin_context()
db.volume_create(ctxt, {'id': 'fake1', 'status': 'available',
'host': 'test', 'provider_location': '',
'size': 1})
db.volume_glance_metadata_create(ctxt, 'fake1', 'key1', 'value1')
db.volume_glance_metadata_create(ctxt, 'fake1', 'key2', 'value2')
db.volume_create(ctxt, {'id': 'fake2', 'status': 'available',
'host': 'test', 'provider_location': '',
'size': 1})
db.volume_glance_metadata_create(ctxt, 'fake2', 'key3', 'value3')
db.volume_glance_metadata_create(ctxt, 'fake2', 'key4', 'value4')
volume_api = cinder.volume.api.API()
results = volume_api.get_list_volumes_image_metadata(ctxt, ['fake1',
'fake2'])
expect_results = {'fake1': {'key1': 'value1', 'key2': 'value2'},
'fake2': {'key3': 'value3', 'key4': 'value4'}}
self.assertEqual(expect_results, results)
@mock.patch.object(QUOTAS, 'limit_check')
@mock.patch.object(QUOTAS, 'reserve')
def test_extend_volume(self, reserve, limit_check):
"""Test volume can be extended at API level."""
# create a volume and assign to host
volume = tests_utils.create_volume(self.context, size=2,
status='in-use', host=CONF.host)
volume_api = cinder.volume.api.API()
# Extend fails when status != available
self.assertRaises(exception.InvalidVolume,
volume_api.extend,
self.context,
volume,
3)
db.volume_update(self.context, volume.id, {'status': 'available'})
# Extend fails when new_size < orig_size
self.assertRaises(exception.InvalidInput,
volume_api.extend,
self.context,
volume,
1)
# Extend fails when new_size == orig_size
self.assertRaises(exception.InvalidInput,
volume_api.extend,
self.context,
volume,
2)
# works when new_size > orig_size
reserve.return_value = ["RESERVATION"]
volume_api.extend(self.context, volume, 3)
volume.refresh()
self.assertEqual('extending', volume.status)
reserve.assert_called_once_with(self.context, gigabytes=1,
project_id=volume.project_id)
# Test the quota exceeded
db.volume_update(self.context, volume.id, {'status': 'available'})
reserve.side_effect = exception.OverQuota(overs=['gigabytes'],
quotas={'gigabytes': 20},
usages={'gigabytes':
{'reserved': 5,
'in_use': 15}})
self.assertRaises(exception.VolumeSizeExceedsAvailableQuota,
volume_api.extend, self.context,
volume, 3)
limit_check.side_effect = exception.OverQuota(
overs=['per_volume_gigabytes'], quotas={'per_volume_gigabytes': 2})
self.assertRaises(exception.VolumeSizeExceedsLimit,
volume_api.extend, self.context,
volume, 3)
# Test scheduler path
limit_check.side_effect = None
reserve.side_effect = None
db.volume_update(self.context, volume.id, {'status': 'available'})
volume_api.scheduler_rpcapi = mock.MagicMock()
volume_api.scheduler_rpcapi.extend_volume = mock.MagicMock()
volume_api.extend(self.context, volume, 3)
request_spec = {
'volume_properties': volume,
'volume_type': {},
'volume_id': volume.id
}
volume_api.scheduler_rpcapi.extend_volume.assert_called_once_with(
self.context, volume, 3, ["RESERVATION"], request_spec)
# Test direct volume path
limit_check.side_effect = None
reserve.side_effect = None
db.volume_update(self.context, volume.id, {'status': 'available'})
ext_mock = mock.MagicMock(side_effect=exception.ServiceTooOld)
volume_api.volume_rpcapi.extend_volume = mock.MagicMock()
volume_api.scheduler_rpcapi.extend_volume = ext_mock
volume_api.extend(self.context, volume, 3)
volume_api.volume_rpcapi.extend_volume.assert_called_once_with(
self.context, volume, 3, ["RESERVATION"])
# clean up
self.volume.delete_volume(self.context, volume)
def test_extend_volume_driver_not_initialized(self):
"""Test volume can be extended at API level."""
# create a volume and assign to host
fake_reservations = ['RESERVATION']
volume = tests_utils.create_volume(self.context, size=2,
status='available',
host=CONF.host)
self.volume.create_volume(self.context, volume)
self.volume.driver._initialized = False
self.assertRaises(exception.DriverNotInitialized,
self.volume.extend_volume,
self.context, volume, 3,
fake_reservations)
volume.refresh()
self.assertEqual('error_extending', volume.status)
# lets cleanup the mess.
self.volume.driver._initialized = True
self.volume.delete_volume(self.context, volume)
def test_extend_volume_manager(self):
"""Test volume can be extended at the manager level."""
def fake_extend(volume, new_size):
volume['size'] = new_size
fake_reservations = ['RESERVATION']
volume = tests_utils.create_volume(self.context, size=2,
status='creating', host=CONF.host)
self.volume.create_volume(self.context, volume)
# Test driver exception
with mock.patch.object(self.volume.driver,
'extend_volume') as extend_volume:
extend_volume.side_effect =\
exception.CinderException('fake exception')
volume['status'] = 'extending'
self.volume.extend_volume(self.context, volume, '4',
fake_reservations)
volume.refresh()
self.assertEqual(2, volume.size)
self.assertEqual('error_extending', volume.status)
# Test driver success
with mock.patch.object(self.volume.driver,
'extend_volume') as extend_volume:
with mock.patch.object(QUOTAS, 'commit') as quotas_commit:
extend_volume.return_value = fake_extend
volume.status = 'extending'
self.volume.extend_volume(self.context, volume, '4',
fake_reservations)
volume.refresh()
self.assertEqual(4, volume.size)
self.assertEqual('available', volume.status)
quotas_commit.assert_called_with(
self.context,
['RESERVATION'],
project_id=volume.project_id)
# clean up
self.volume.delete_volume(self.context, volume)
@mock.patch('cinder.volume.rpcapi.VolumeAPI.extend_volume')
def test_extend_volume_with_volume_type(self, mock_rpc_extend):
elevated = context.get_admin_context()
project_id = self.context.project_id
db.volume_type_create(elevated, {'name': 'type', 'extra_specs': {}})
vol_type = db.volume_type_get_by_name(elevated, 'type')
volume_api = cinder.volume.api.API()
volume = volume_api.create(self.context, 100, 'name', 'description',
volume_type=vol_type)
try:
usage = db.quota_usage_get(elevated, project_id, 'gigabytes_type')
volumes_in_use = usage.in_use
except exception.QuotaUsageNotFound:
volumes_in_use = 0
self.assertEqual(100, volumes_in_use)
db.volume_update(self.context, volume.id, {'status': 'available'})
volume_api.extend(self.context, volume, 200)
mock_rpc_extend.called_once_with(self.context, volume, 200, mock.ANY)
try:
usage = db.quota_usage_get(elevated, project_id, 'gigabytes_type')
volumes_reserved = usage.reserved
except exception.QuotaUsageNotFound:
volumes_reserved = 0
self.assertEqual(100, volumes_reserved)
@mock.patch(
'cinder.volume.driver.VolumeDriver.create_replica_test_volume')
def test_create_volume_from_sourcereplica(self, _create_replica_test):
"""Test volume can be created from a volume replica."""
_create_replica_test.return_value = None
volume_src = tests_utils.create_volume(self.context,
**self.volume_params)
self.volume.create_volume(self.context, volume_src)
volume_dst = tests_utils.create_volume(
self.context,
**self.volume_params)
self.volume.create_volume(self.context, volume_dst,
{'source_replicaid': volume_src.id})
self.assertEqual('available',
db.volume_get(context.get_admin_context(),
volume_dst['id']).status)
self.assertTrue(_create_replica_test.called)
self.volume.delete_volume(self.context, volume_dst)
self.volume.delete_volume(self.context, volume_src)
def test_create_volume_from_sourcevol(self):
"""Test volume can be created from a source volume."""
def fake_create_cloned_volume(volume, src_vref):
pass
self.mock_object(self.volume.driver, 'create_cloned_volume',
fake_create_cloned_volume)
volume_src = tests_utils.create_volume(self.context,
**self.volume_params)
self.volume.create_volume(self.context, volume_src)
volume_dst = tests_utils.create_volume(self.context,
source_volid=volume_src['id'],
**self.volume_params)
self.volume.create_volume(self.context, volume_dst)
volume_dst.refresh()
self.assertEqual('available', volume_dst.status)
self.volume.delete_volume(self.context, volume_dst)
self.volume.delete_volume(self.context, volume_src)
@mock.patch('cinder.volume.api.API.list_availability_zones',
return_value=({'name': 'nova', 'available': True},
{'name': 'az2', 'available': True}))
def test_create_volume_from_sourcevol_fail_wrong_az(self, _mock_laz):
"""Test volume can't be cloned from an other volume in different az."""
volume_api = cinder.volume.api.API()
volume_src = tests_utils.create_volume(self.context,
availability_zone='az2',
**self.volume_params)
self.volume.create_volume(self.context, volume_src)
volume_src = db.volume_get(self.context, volume_src['id'])
volume_dst = volume_api.create(self.context,
size=1,
name='fake_name',
description='fake_desc',
source_volume=volume_src)
self.assertEqual('az2', volume_dst['availability_zone'])
self.assertRaises(exception.InvalidInput,
volume_api.create,
self.context,
size=1,
name='fake_name',
description='fake_desc',
source_volume=volume_src,
availability_zone='nova')
@mock.patch('cinder.image.image_utils.qemu_img_info')
def test_create_volume_from_sourcevol_with_glance_metadata(
self, mock_qemu_info):
"""Test glance metadata can be correctly copied to new volume."""
def fake_create_cloned_volume(volume, src_vref):
pass
self.mock_object(self.volume.driver, 'create_cloned_volume',
fake_create_cloned_volume)
image_info = imageutils.QemuImgInfo()
image_info.virtual_size = '1073741824'
mock_qemu_info.return_value = image_info
volume_src = self._create_volume_from_image()
self.volume.create_volume(self.context, volume_src)
volume_dst = tests_utils.create_volume(self.context,
source_volid=volume_src['id'],
**self.volume_params)
self.volume.create_volume(self.context, volume_dst)
self.assertEqual('available',
db.volume_get(context.get_admin_context(),
volume_dst['id']).status)
src_glancemeta = db.volume_get(context.get_admin_context(),
volume_src['id']).volume_glance_metadata
dst_glancemeta = db.volume_get(context.get_admin_context(),
volume_dst['id']).volume_glance_metadata
for meta_src in src_glancemeta:
for meta_dst in dst_glancemeta:
if meta_dst.key == meta_src.key:
self.assertEqual(meta_src.value, meta_dst.value)
self.volume.delete_volume(self.context, volume_src)
self.volume.delete_volume(self.context, volume_dst)
def test_create_volume_from_sourcevol_failed_clone(self):
"""Test src vol status will be restore by error handling code."""
def fake_error_create_cloned_volume(volume, src_vref):
db.volume_update(self.context, src_vref['id'], {'status': 'error'})
raise exception.CinderException('fake exception')
self.mock_object(self.volume.driver, 'create_cloned_volume',
fake_error_create_cloned_volume)
volume_src = tests_utils.create_volume(self.context,
**self.volume_params)
self.assertEqual('creating', volume_src.status)
self.volume.create_volume(self.context, volume_src)
self.assertEqual('available', volume_src.status)
volume_dst = tests_utils.create_volume(self.context,
source_volid=volume_src['id'],
**self.volume_params)
self.assertEqual('creating', volume_dst.status)
self.assertRaises(exception.CinderException,
self.volume.create_volume,
self.context,
volume_dst)
# Source volume's status is still available and dst is set to error
self.assertEqual('available', volume_src.status)
self.assertEqual('error', volume_dst.status)
self.volume.delete_volume(self.context, volume_dst)
self.volume.delete_volume(self.context, volume_src)
def test_clean_temporary_volume(self):
def fake_delete_volume(ctxt, volume):
volume.destroy()
fake_volume = tests_utils.create_volume(self.context, size=1,
host=CONF.host,
migration_status='migrating')
fake_new_volume = tests_utils.create_volume(self.context, size=1,
host=CONF.host)
# 1. Only clean the db
self.volume._clean_temporary_volume(self.context, fake_volume,
fake_new_volume,
clean_db_only=True)
self.assertRaises(exception.VolumeNotFound,
db.volume_get, self.context,
fake_new_volume.id)
# 2. Delete the backend storage
fake_new_volume = tests_utils.create_volume(self.context, size=1,
host=CONF.host)
with mock.patch.object(volume_rpcapi.VolumeAPI, 'delete_volume') as \
mock_delete_volume:
mock_delete_volume.side_effect = fake_delete_volume
self.volume._clean_temporary_volume(self.context,
fake_volume,
fake_new_volume,
clean_db_only=False)
self.assertRaises(exception.VolumeNotFound,
db.volume_get, self.context,
fake_new_volume.id)
# Check when the migrated volume is not in migration
fake_new_volume = tests_utils.create_volume(self.context, size=1,
host=CONF.host)
fake_volume.migration_status = 'non-migrating'
fake_volume.save()
self.volume._clean_temporary_volume(self.context, fake_volume,
fake_new_volume)
volume = db.volume_get(context.get_admin_context(),
fake_new_volume.id)
self.assertIsNone(volume.migration_status)
def test_check_volume_filters_true(self):
"""Test bootable as filter for true"""
volume_api = cinder.volume.api.API()
filters = {'bootable': 'TRUE'}
# To convert filter value to True or False
volume_api.check_volume_filters(filters)
# Confirming converted filter value against True
self.assertTrue(filters['bootable'])
def test_check_volume_filters_false(self):
"""Test bootable as filter for false"""
volume_api = cinder.volume.api.API()
filters = {'bootable': 'false'}
# To convert filter value to True or False
volume_api.check_volume_filters(filters)
# Confirming converted filter value against False
self.assertEqual(False, filters['bootable'])
def test_check_volume_filters_invalid(self):
"""Test bootable as filter"""
volume_api = cinder.volume.api.API()
filters = {'bootable': 'invalid'}
# To convert filter value to True or False
volume_api.check_volume_filters(filters)
# Confirming converted filter value against invalid value
self.assertTrue(filters['bootable'])
def test_update_volume_readonly_flag(self):
"""Test volume readonly flag can be updated at API level."""
# create a volume and assign to host
volume = tests_utils.create_volume(self.context,
admin_metadata={'readonly': 'True'},
**self.volume_params)
self.volume.create_volume(self.context, volume)
volume.status = 'in-use'
def sort_func(obj):
return obj['name']
volume_api = cinder.volume.api.API()
# Update fails when status != available
self.assertRaises(exception.InvalidVolume,
volume_api.update_readonly_flag,
self.context,
volume,
False)
volume.status = 'available'
# works when volume in 'available' status
volume_api.update_readonly_flag(self.context, volume, False)
volume.refresh()
self.assertEqual('available', volume.status)
admin_metadata = volume.volume_admin_metadata
self.assertEqual(1, len(admin_metadata))
self.assertEqual('readonly', admin_metadata[0]['key'])
self.assertEqual('False', admin_metadata[0]['value'])
# clean up
self.volume.delete_volume(self.context, volume)
def test_secure_file_operations_enabled(self):
"""Test secure file operations setting for base driver.
General, non network file system based drivers do not have
anything to do with "secure_file_operations". This test verifies that
calling the method always returns False.
"""
ret_flag = self.volume.driver.secure_file_operations_enabled()
self.assertFalse(ret_flag)
@mock.patch.object(driver.BaseVD, 'secure_file_operations_enabled')
def test_secure_file_operations_enabled_2(self, mock_secure):
mock_secure.return_value = True
vol = tests_utils.create_volume(self.context)
result = self.volume.secure_file_operations_enabled(self.context,
vol)
mock_secure.assert_called_once_with()
self.assertTrue(result)
@mock.patch('cinder.volume.flows.common.make_pretty_name',
new=mock.MagicMock())
@mock.patch('cinder.scheduler.rpcapi.SchedulerAPI.create_volume',
return_value=None)
@mock.patch('cinder.volume.flows.manager.create_volume.'
'CreateVolumeFromSpecTask.execute',
side_effect=exception.DriverNotInitialized())
def test_create_volume_raise_rescheduled_exception(self, mock_execute,
mock_reschedule):
# Create source volume
test_vol = tests_utils.create_volume(self.context,
**self.volume_params)
test_vol_id = test_vol['id']
self.assertRaises(exception.DriverNotInitialized,
self.volume.create_volume,
self.context, test_vol,
{'volume_properties': self.volume_params},
{'retry': {'num_attempts': 1, 'host': []}})
self.assertTrue(mock_reschedule.called)
volume = db.volume_get(context.get_admin_context(), test_vol_id)
self.assertEqual('creating', volume['status'])
@mock.patch('cinder.volume.flows.manager.create_volume.'
'CreateVolumeFromSpecTask.execute')
def test_create_volume_raise_unrescheduled_exception(self, mock_execute):
# create source volume
test_vol = tests_utils.create_volume(self.context,
**self.volume_params)
test_vol_id = test_vol['id']
mock_execute.side_effect = exception.VolumeNotFound(
volume_id=test_vol_id)
self.assertRaises(exception.VolumeNotFound,
self.volume.create_volume,
self.context, test_vol,
{'volume_properties': self.volume_params},
{'retry': {'num_attempts': 1, 'host': []}})
volume = db.volume_get(context.get_admin_context(), test_vol_id)
self.assertEqual('error', volume['status'])
def test_cascade_delete_volume_with_snapshots(self):
"""Test volume deletion with dependent snapshots."""
volume = tests_utils.create_volume(self.context, **self.volume_params)
self.volume.create_volume(self.context, volume)
snapshot = create_snapshot(volume['id'], size=volume['size'])
self.volume.create_snapshot(self.context, snapshot)
self.assertEqual(
snapshot.id, objects.Snapshot.get_by_id(self.context,
snapshot.id).id)
volume['status'] = 'available'
volume['host'] = 'fakehost'
volume_api = cinder.volume.api.API()
volume_api.delete(self.context,
volume,
cascade=True)
def test_cascade_delete_volume_with_snapshots_error(self):
"""Test volume deletion with dependent snapshots."""
volume = tests_utils.create_volume(self.context, **self.volume_params)
self.volume.create_volume(self.context, volume)
snapshot = create_snapshot(volume['id'], size=volume['size'])
self.volume.create_snapshot(self.context, snapshot)
self.assertEqual(
snapshot.id, objects.Snapshot.get_by_id(self.context,
snapshot.id).id)
snapshot.update({'status': fields.SnapshotStatus.CREATING})
snapshot.save()
volume['status'] = 'available'
volume['host'] = 'fakehost'
volume_api = cinder.volume.api.API()
self.assertRaises(exception.InvalidVolume,
volume_api.delete,
self.context,
volume,
cascade=True)
def test_cascade_force_delete_volume_with_snapshots_error(self):
"""Test volume force deletion with errored dependent snapshots."""
volume = tests_utils.create_volume(self.context,
host='fakehost')
snapshot = create_snapshot(volume.id,
size=volume.size,
status=fields.SnapshotStatus.ERROR_DELETING)
self.volume.create_snapshot(self.context, snapshot)
volume_api = cinder.volume.api.API()
volume_api.delete(self.context, volume, cascade=True, force=True)
snapshot = objects.Snapshot.get_by_id(self.context, snapshot.id)
self.assertEqual('deleting', snapshot.status)
volume = objects.Volume.get_by_id(self.context, volume.id)
self.assertEqual('deleting', volume.status)
@mock.patch.object(fake_driver.FakeLoggingVolumeDriver, 'get_volume_stats')
@mock.patch.object(driver.BaseVD, '_init_vendor_properties')
def test_get_capabilities(self, mock_init_vendor, mock_get_volume_stats):
stats = {
'volume_backend_name': 'lvm',
'vendor_name': 'Open Source',
'storage_protocol': 'iSCSI',
'vendor_prefix': 'abcd'
}
expected = stats.copy()
expected['properties'] = {
'compression': {
'title': 'Compression',
'description': 'Enables compression.',
'type': 'boolean'},
'qos': {
'title': 'QoS',
'description': 'Enables QoS.',
'type': 'boolean'},
'replication_enabled': {
'title': 'Replication',
'description': 'Enables replication.',
'type': 'boolean'},
'thin_provisioning': {
'title': 'Thin Provisioning',
'description': 'Sets thin provisioning.',
'type': 'boolean'},
}
# Test to get updated capabilities
discover = True
mock_get_volume_stats.return_value = stats
mock_init_vendor.return_value = ({}, None)
capabilities = self.volume.get_capabilities(self.context,
discover)
self.assertEqual(expected, capabilities)
mock_get_volume_stats.assert_called_once_with(True)
# Test to get existing original capabilities
mock_get_volume_stats.reset_mock()
discover = False
capabilities = self.volume.get_capabilities(self.context,
discover)
self.assertEqual(expected, capabilities)
self.assertFalse(mock_get_volume_stats.called)
# Normal test case to get vendor unique capabilities
def init_vendor_properties(self):
properties = {}
self._set_property(
properties,
"abcd:minIOPS",
"Minimum IOPS QoS",
"Sets minimum IOPS if QoS is enabled.",
"integer",
minimum=10,
default=100)
return properties, 'abcd'
expected['properties'].update(
{'abcd:minIOPS': {
'title': 'Minimum IOPS QoS',
'description': 'Sets minimum IOPS if QoS is enabled.',
'type': 'integer',
'minimum': 10,
'default': 100}})
mock_get_volume_stats.reset_mock()
mock_init_vendor.reset_mock()
discover = True
mock_init_vendor.return_value = (
init_vendor_properties(self.volume.driver))
capabilities = self.volume.get_capabilities(self.context,
discover)
self.assertEqual(expected, capabilities)
self.assertTrue(mock_get_volume_stats.called)
@mock.patch.object(fake_driver.FakeLoggingVolumeDriver, 'get_volume_stats')
@mock.patch.object(driver.BaseVD, '_init_vendor_properties')
@mock.patch.object(driver.BaseVD, '_init_standard_capabilities')
def test_get_capabilities_prefix_error(self, mock_init_standard,
mock_init_vendor,
mock_get_volume_stats):
# Error test case: propety does not match vendor prefix
def init_vendor_properties(self):
properties = {}
self._set_property(
properties,
"aaa:minIOPS",
"Minimum IOPS QoS",
"Sets minimum IOPS if QoS is enabled.",
"integer")
self._set_property(
properties,
"abcd:compression_type",
"Compression type",
"Specifies compression type.",
"string")
return properties, 'abcd'
expected = {
'abcd:compression_type': {
'title': 'Compression type',
'description': 'Specifies compression type.',
'type': 'string'}}
discover = True
mock_get_volume_stats.return_value = {}
mock_init_standard.return_value = {}
mock_init_vendor.return_value = (
init_vendor_properties(self.volume.driver))
capabilities = self.volume.get_capabilities(self.context,
discover)
self.assertEqual(expected, capabilities['properties'])
@mock.patch.object(fake_driver.FakeLoggingVolumeDriver, 'get_volume_stats')
@mock.patch.object(driver.BaseVD, '_init_vendor_properties')
@mock.patch.object(driver.BaseVD, '_init_standard_capabilities')
def test_get_capabilities_fail_override(self, mock_init_standard,
mock_init_vendor,
mock_get_volume_stats):
# Error test case: propety cannot override any standard capabilities
def init_vendor_properties(self):
properties = {}
self._set_property(
properties,
"qos",
"Minimum IOPS QoS",
"Sets minimum IOPS if QoS is enabled.",
"integer")
self._set_property(
properties,
"ab::cd:compression_type",
"Compression type",
"Specifies compression type.",
"string")
return properties, 'ab::cd'
expected = {
'ab__cd:compression_type': {
'title': 'Compression type',
'description': 'Specifies compression type.',
'type': 'string'}}
discover = True
mock_get_volume_stats.return_value = {}
mock_init_standard.return_value = {}
mock_init_vendor.return_value = (
init_vendor_properties(self.volume.driver))
capabilities = self.volume.get_capabilities(self.context,
discover)
self.assertEqual(expected, capabilities['properties'])
@mock.patch.object(driver.BaseVD, 'get_backup_device')
@mock.patch.object(driver.BaseVD, 'secure_file_operations_enabled')
def test_get_backup_device(self, mock_secure, mock_get_backup):
vol = tests_utils.create_volume(self.context)
backup = tests_utils.create_backup(self.context, vol['id'])
mock_secure.return_value = False
mock_get_backup.return_value = (vol, False)
result = self.volume.get_backup_device(self.context,
backup)
mock_get_backup.assert_called_once_with(self.context, backup)
mock_secure.assert_called_once_with()
expected_result = {'backup_device': vol, 'secure_enabled': False,
'is_snapshot': False}
self.assertEqual(expected_result, result)
@mock.patch.object(driver.BaseVD, 'get_backup_device')
@mock.patch.object(driver.BaseVD, 'secure_file_operations_enabled')
def test_get_backup_device_want_objects(self, mock_secure,
mock_get_backup):
vol = tests_utils.create_volume(self.context)
backup = tests_utils.create_backup(self.context, vol['id'])
mock_secure.return_value = False
mock_get_backup.return_value = (vol, False)
result = self.volume.get_backup_device(self.context,
backup, want_objects=True)
mock_get_backup.assert_called_once_with(self.context, backup)
mock_secure.assert_called_once_with()
expected_result = objects.BackupDeviceInfo.from_primitive(
{'backup_device': vol, 'secure_enabled': False,
'is_snapshot': False},
self.context)
self.assertEqual(expected_result, result)
def test_backup_use_temp_snapshot_config(self):
local_conf = self.volume.driver.configuration.local_conf
self.assertFalse(local_conf.backup_use_temp_snapshot)
@mock.patch.object(QUOTAS, 'reserve',
side_effect = OVER_SNAPSHOT_QUOTA_EXCEPTION)
def test_existing_snapshot_failed_quota_reserve(self, mock_reserve):
vol = tests_utils.create_volume(self.context)
snap = tests_utils.create_snapshot(self.context, vol.id)
with mock.patch.object(
self.volume.driver,
'manage_existing_snapshot_get_size') as mock_get_size:
mock_get_size.return_value = 1
self.assertRaises(exception.SnapshotLimitExceeded,
self.volume.manage_existing_snapshot,
self.context,
snap)
@mock.patch('cinder.volume.drivers.lvm.LVMVolumeDriver.'
'manage_existing')
@mock.patch('cinder.volume.drivers.lvm.LVMVolumeDriver.'
'manage_existing_get_size')
@mock.patch('cinder.volume.utils.notify_about_volume_usage')
def test_manage_volume_with_notify(self, mock_notify, mock_size,
mock_manage):
elevated = context.get_admin_context()
vol_type = db.volume_type_create(
elevated, {'name': 'type1', 'extra_specs': {}})
# create source volume
volume_params = {'volume_type_id': vol_type.id, 'status': 'managing'}
test_vol = tests_utils.create_volume(self.context, **volume_params)
mock_size.return_value = 1
mock_manage.return_value = None
self.volume.manage_existing(self.context, test_vol, 'volume_ref')
mock_notify.assert_called_with(self.context, test_vol,
'manage_existing.end',
host=test_vol.host)
@mock.patch('cinder.volume.drivers.lvm.LVMVolumeDriver.'
'manage_existing_get_size')
@mock.patch('cinder.volume.flows.manager.manage_existing.'
'ManageExistingTask.execute')
def test_manage_volume_raise_driver_exception(self, mock_execute,
mock_driver_get_size):
elevated = context.get_admin_context()
project_id = self.context.project_id
db.volume_type_create(elevated, {'name': 'type1', 'extra_specs': {}})
vol_type = db.volume_type_get_by_name(elevated, 'type1')
# create source volume
self.volume_params['volume_type_id'] = vol_type['id']
self.volume_params['status'] = 'managing'
test_vol = tests_utils.create_volume(self.context,
**self.volume_params)
mock_execute.side_effect = exception.VolumeBackendAPIException(
data="volume driver got exception")
mock_driver_get_size.return_value = 1
# Set quota usage
reserve_opts = {'volumes': 1, 'gigabytes': 1}
reservations = QUOTAS.reserve(self.context, project_id=project_id,
**reserve_opts)
QUOTAS.commit(self.context, reservations)
usage = db.quota_usage_get(self.context, project_id, 'volumes')
volumes_in_use = usage.in_use
usage = db.quota_usage_get(self.context, project_id, 'gigabytes')
gigabytes_in_use = usage.in_use
self.assertRaises(exception.VolumeBackendAPIException,
self.volume.manage_existing,
self.context, test_vol,
'volume_ref')
# check volume status
volume = objects.Volume.get_by_id(context.get_admin_context(),
test_vol.id)
self.assertEqual('error_managing', volume.status)
# Delete this volume with 'error_managing_deleting' status in c-vol.
test_vol.status = 'error_managing_deleting'
test_vol.save()
self.volume.delete_volume(self.context, test_vol)
ctxt = context.get_admin_context(read_deleted='yes')
volume = objects.Volume.get_by_id(ctxt, test_vol.id)
self.assertEqual('deleted', volume.status)
# Get in_use number after deleting error_managing volume
usage = db.quota_usage_get(self.context, project_id, 'volumes')
volumes_in_use_new = usage.in_use
self.assertEqual(volumes_in_use, volumes_in_use_new)
usage = db.quota_usage_get(self.context, project_id, 'gigabytes')
gigabytes_in_use_new = usage.in_use
self.assertEqual(gigabytes_in_use, gigabytes_in_use_new)
@mock.patch('cinder.volume.drivers.lvm.LVMVolumeDriver.'
'manage_existing_get_size')
def test_manage_volume_raise_driver_size_exception(self,
mock_driver_get_size):
elevated = context.get_admin_context()
project_id = self.context.project_id
db.volume_type_create(elevated, {'name': 'type1', 'extra_specs': {}})
# create source volume
test_vol = tests_utils.create_volume(self.context,
**self.volume_params)
mock_driver_get_size.side_effect = exception.VolumeBackendAPIException(
data="volume driver got exception")
# Set quota usage
reserve_opts = {'volumes': 1, 'gigabytes': 1}
reservations = QUOTAS.reserve(self.context, project_id=project_id,
**reserve_opts)
QUOTAS.commit(self.context, reservations)
usage = db.quota_usage_get(self.context, project_id, 'volumes')
volumes_in_use = usage.in_use
usage = db.quota_usage_get(self.context, project_id, 'gigabytes')
gigabytes_in_use = usage.in_use
self.assertRaises(exception.VolumeBackendAPIException,
self.volume.manage_existing,
self.context, test_vol,
'volume_ref')
# check volume status
volume = objects.Volume.get_by_id(context.get_admin_context(),
test_vol.id)
self.assertEqual('error_managing', volume.status)
# Delete this volume with 'error_managing_deleting' status in c-vol.
test_vol.status = 'error_managing_deleting'
test_vol.save()
self.volume.delete_volume(self.context, test_vol)
ctxt = context.get_admin_context(read_deleted='yes')
volume = objects.Volume.get_by_id(ctxt, test_vol.id)
self.assertEqual('deleted', volume.status)
# Get in_use number after raising exception
usage = db.quota_usage_get(self.context, project_id, 'volumes')
volumes_in_use_new = usage.in_use
self.assertEqual(volumes_in_use, volumes_in_use_new)
usage = db.quota_usage_get(self.context, project_id, 'gigabytes')
gigabytes_in_use_new = usage.in_use
self.assertEqual(gigabytes_in_use, gigabytes_in_use_new)
@mock.patch('cinder.tests.fake_driver.FakeLoggingVolumeDriver.'
'SUPPORTS_ACTIVE_ACTIVE', True)
def test_set_resource_host_different(self):
manager = vol_manager.VolumeManager(host='localhost-1@ceph',
cluster='mycluster@ceph')
volume = tests_utils.create_volume(self.user_context,
host='localhost-2@ceph#ceph',
cluster_name='mycluster@ceph')
manager._set_resource_host(volume)
volume.refresh()
self.assertEqual('localhost-1@ceph#ceph', volume.host)
@mock.patch('cinder.tests.fake_driver.FakeLoggingVolumeDriver.'
'SUPPORTS_ACTIVE_ACTIVE', True)
def test_set_resource_host_equal(self):
manager = vol_manager.VolumeManager(host='localhost-1@ceph',
cluster='mycluster@ceph')
volume = tests_utils.create_volume(self.user_context,
host='localhost-1@ceph#ceph',
cluster_name='mycluster@ceph')
with mock.patch.object(volume, 'save') as save_mock:
manager._set_resource_host(volume)
save_mock.assert_not_called()
@ddt.ddt
class VolumeMigrationTestCase(base.BaseVolumeTestCase):
def setUp(self):
super(VolumeMigrationTestCase, self).setUp()
self._clear_patch = mock.patch('cinder.volume.utils.clear_volume',
autospec=True)
self._clear_patch.start()
self.expected_status = 'available'
def tearDown(self):
super(VolumeMigrationTestCase, self).tearDown()
self._clear_patch.stop()
def test_migrate_volume_driver(self):
"""Test volume migration done by driver."""
# Mock driver and rpc functions
self.mock_object(self.volume.driver, 'migrate_volume',
lambda x, y, z, new_type_id=None: (
True, {'user_id': fake.USER_ID}))
volume = tests_utils.create_volume(self.context, size=0,
host=CONF.host,
migration_status='migrating')
host_obj = {'host': 'newhost', 'capabilities': {}}
self.volume.migrate_volume(self.context, volume, host_obj, False)
# check volume properties
volume = objects.Volume.get_by_id(context.get_admin_context(),
volume.id)
self.assertEqual('newhost', volume.host)
self.assertEqual('success', volume.migration_status)
def _fake_create_volume(self, ctxt, volume, req_spec, filters,
allow_reschedule=True):
return db.volume_update(ctxt, volume['id'],
{'status': self.expected_status})
def test_migrate_volume_error(self):
with mock.patch.object(self.volume.driver, 'migrate_volume') as \
mock_migrate,\
mock.patch.object(self.volume.driver, 'create_export') as \
mock_create_export:
# Exception case at self.driver.migrate_volume and create_export
mock_migrate.side_effect = processutils.ProcessExecutionError
mock_create_export.side_effect = processutils.ProcessExecutionError
volume = tests_utils.create_volume(self.context, size=0,
host=CONF.host)
host_obj = {'host': 'newhost', 'capabilities': {}}
self.assertRaises(processutils.ProcessExecutionError,
self.volume.migrate_volume,
self.context,
volume,
host_obj,
False)
volume = objects.Volume.get_by_id(context.get_admin_context(),
volume.id)
self.assertEqual('error', volume.migration_status)
self.assertEqual('available', volume.status)
@mock.patch('cinder.compute.API')
@mock.patch('cinder.volume.manager.VolumeManager.'
'migrate_volume_completion')
@mock.patch('cinder.db.sqlalchemy.api.volume_get')
def test_migrate_volume_generic(self, volume_get,
migrate_volume_completion,
nova_api):
fake_db_new_volume = {'status': 'available', 'id': fake.VOLUME_ID}
fake_new_volume = fake_volume.fake_db_volume(**fake_db_new_volume)
new_volume_obj = fake_volume.fake_volume_obj(self.context,
**fake_new_volume)
host_obj = {'host': 'newhost', 'capabilities': {}}
volume_get.return_value = fake_new_volume
update_server_volume = nova_api.return_value.update_server_volume
volume = tests_utils.create_volume(self.context, size=1,
host=CONF.host)
with mock.patch.object(self.volume, '_copy_volume_data') as \
mock_copy_volume:
self.volume._migrate_volume_generic(self.context, volume,
host_obj, None)
mock_copy_volume.assert_called_with(self.context, volume,
new_volume_obj,
remote='dest')
migrate_volume_completion.assert_called_with(
self.context, volume, new_volume_obj, error=False)
self.assertFalse(update_server_volume.called)
@mock.patch('cinder.compute.API')
@mock.patch('cinder.volume.manager.VolumeManager.'
'migrate_volume_completion')
@mock.patch('cinder.db.sqlalchemy.api.volume_get')
def test_migrate_volume_generic_attached_volume(self, volume_get,
migrate_volume_completion,
nova_api):
attached_host = 'some-host'
fake_volume_id = fake.VOLUME_ID
fake_db_new_volume = {'status': 'available', 'id': fake_volume_id}
fake_new_volume = fake_volume.fake_db_volume(**fake_db_new_volume)
host_obj = {'host': 'newhost', 'capabilities': {}}
fake_uuid = fakes.get_fake_uuid()
update_server_volume = nova_api.return_value.update_server_volume
volume_get.return_value = fake_new_volume
volume = tests_utils.create_volume(self.context, size=1,
host=CONF.host)
volume_attach = tests_utils.attach_volume(
self.context, volume['id'], fake_uuid, attached_host, '/dev/vda')
self.assertIsNotNone(volume_attach['volume_attachment'][0]['id'])
self.assertEqual(
fake_uuid, volume_attach['volume_attachment'][0]['instance_uuid'])
self.assertEqual('in-use', volume_attach['status'])
self.volume._migrate_volume_generic(self.context, volume,
host_obj, None)
self.assertFalse(migrate_volume_completion.called)
update_server_volume.assert_called_with(self.context, fake_uuid,
volume['id'], fake_volume_id)
@mock.patch('cinder.objects.volume.Volume.save')
@mock.patch('cinder.volume.rpcapi.VolumeAPI.create_volume')
@mock.patch('cinder.compute.API')
@mock.patch('cinder.volume.manager.VolumeManager.'
'migrate_volume_completion')
@mock.patch('cinder.db.sqlalchemy.api.volume_get')
def test_migrate_volume_generic_volume_from_snap(self, volume_get,
migrate_volume_completion,
nova_api, create_volume,
save):
def fake_create_volume(*args, **kwargs):
context, volume, request_spec, filter_properties = args
fake_db = mock.Mock()
task = create_volume_manager.ExtractVolumeSpecTask(fake_db)
specs = task.execute(context, volume, {})
self.assertEqual('raw', specs['type'])
def fake_copy_volume_data_with_chk_param(*args, **kwargs):
context, src, dest = args
self.assertEqual(src['snapshot_id'], dest['snapshot_id'])
fake_db_new_volume = {'status': 'available', 'id': fake.VOLUME_ID}
fake_new_volume = fake_volume.fake_db_volume(**fake_db_new_volume)
host_obj = {'host': 'newhost', 'capabilities': {}}
volume_get.return_value = fake_new_volume
volume_from_snap = tests_utils.create_volume(self.context, size=1,
host=CONF.host)
volume_from_snap['snapshot_id'] = fake.SNAPSHOT_ID
create_volume.side_effect = fake_create_volume
with mock.patch.object(self.volume, '_copy_volume_data') as \
mock_copy_volume:
mock_copy_volume.side_effect = fake_copy_volume_data_with_chk_param
self.volume._migrate_volume_generic(self.context, volume_from_snap,
host_obj, None)
@mock.patch('cinder.objects.volume.Volume.save')
@mock.patch('cinder.volume.rpcapi.VolumeAPI.create_volume')
@mock.patch('cinder.compute.API')
@mock.patch('cinder.volume.manager.VolumeManager.'
'migrate_volume_completion')
@mock.patch('cinder.db.sqlalchemy.api.volume_get')
def test_migrate_volume_generic_for_clone(self, volume_get,
migrate_volume_completion,
nova_api, create_volume, save):
def fake_create_volume(*args, **kwargs):
context, volume, request_spec, filter_properties = args
fake_db = mock.Mock()
task = create_volume_manager.ExtractVolumeSpecTask(fake_db)
specs = task.execute(context, volume, {})
self.assertEqual('raw', specs['type'])
def fake_copy_volume_data_with_chk_param(*args, **kwargs):
context, src, dest = args
self.assertEqual(src['source_volid'], dest['source_volid'])
fake_db_new_volume = {'status': 'available', 'id': fake.VOLUME_ID}
fake_new_volume = fake_volume.fake_db_volume(**fake_db_new_volume)
host_obj = {'host': 'newhost', 'capabilities': {}}
volume_get.return_value = fake_new_volume
clone = tests_utils.create_volume(self.context, size=1,
host=CONF.host)
clone['source_volid'] = fake.VOLUME2_ID
create_volume.side_effect = fake_create_volume
with mock.patch.object(self.volume, '_copy_volume_data') as \
mock_copy_volume:
mock_copy_volume.side_effect = fake_copy_volume_data_with_chk_param
self.volume._migrate_volume_generic(self.context, clone,
host_obj, None)
@mock.patch.object(volume_rpcapi.VolumeAPI, 'update_migrated_volume')
@mock.patch.object(volume_rpcapi.VolumeAPI, 'delete_volume')
@mock.patch.object(volume_rpcapi.VolumeAPI, 'create_volume')
def test_migrate_volume_for_volume_generic(self, create_volume,
rpc_delete_volume,
update_migrated_volume):
fake_volume = tests_utils.create_volume(self.context, size=1,
previous_status='available',
host=CONF.host)
host_obj = {'host': 'newhost', 'capabilities': {}}
with mock.patch.object(self.volume.driver, 'migrate_volume') as \
mock_migrate_volume,\
mock.patch.object(self.volume, '_copy_volume_data'),\
mock.patch.object(self.volume.driver, 'delete_volume') as \
delete_volume:
create_volume.side_effect = self._fake_create_volume
self.volume.migrate_volume(self.context, fake_volume, host_obj,
True)
volume = objects.Volume.get_by_id(context.get_admin_context(),
fake_volume.id)
self.assertEqual('newhost', volume.host)
self.assertEqual('success', volume.migration_status)
self.assertFalse(mock_migrate_volume.called)
self.assertFalse(delete_volume.called)
self.assertTrue(rpc_delete_volume.called)
self.assertTrue(update_migrated_volume.called)
def test_migrate_volume_generic_copy_error(self):
with mock.patch.object(self.volume.driver, 'migrate_volume'),\
mock.patch.object(volume_rpcapi.VolumeAPI, 'create_volume')\
as mock_create_volume,\
mock.patch.object(self.volume, '_copy_volume_data') as \
mock_copy_volume,\
mock.patch.object(volume_rpcapi.VolumeAPI, 'delete_volume'),\
mock.patch.object(self.volume, 'migrate_volume_completion'),\
mock.patch.object(self.volume.driver, 'create_export'):
# Exception case at migrate_volume_generic
# source_volume['migration_status'] is 'migrating'
mock_create_volume.side_effect = self._fake_create_volume
mock_copy_volume.side_effect = processutils.ProcessExecutionError
volume = tests_utils.create_volume(self.context, size=0,
host=CONF.host)
host_obj = {'host': 'newhost', 'capabilities': {}}
self.assertRaises(processutils.ProcessExecutionError,
self.volume.migrate_volume,
self.context,
volume,
host_obj,
True)
volume = objects.Volume.get_by_id(context.get_admin_context(),
volume.id)
self.assertEqual('error', volume.migration_status)
self.assertEqual('available', volume.status)
@mock.patch('cinder.image.image_utils.qemu_img_info')
def test_migrate_volume_with_glance_metadata(self, mock_qemu_info):
volume = self._create_volume_from_image(clone_image_volume=True)
glance_metadata = volume.glance_metadata
# We imitate the behavior of rpcapi, by serializing and then
# deserializing the volume object we created earlier.
serializer = objects.base.CinderObjectSerializer()
serialized_volume = serializer.serialize_entity(self.context, volume)
volume = serializer.deserialize_entity(self.context, serialized_volume)
image_info = imageutils.QemuImgInfo()
image_info.virtual_size = '1073741824'
mock_qemu_info.return_value = image_info
host_obj = {'host': 'newhost', 'capabilities': {}}
with mock.patch.object(self.volume.driver,
'migrate_volume') as mock_migrate_volume:
mock_migrate_volume.side_effect = (
lambda x, y, z, new_type_id=None: (
True, {'user_id': fake.USER_ID}))
self.volume.migrate_volume(self.context, volume, host_obj,
False)
self.assertEqual('newhost', volume.host)
self.assertEqual('success', volume.migration_status)
self.assertEqual(glance_metadata, volume.glance_metadata)
@mock.patch('cinder.db.volume_update')
def test_update_migrated_volume(self, volume_update):
fake_host = 'fake_host'
fake_new_host = 'fake_new_host'
fake_update = {'_name_id': fake.VOLUME2_NAME_ID,
'provider_location': 'updated_location'}
fake_elevated = context.RequestContext(fake.USER_ID, self.project_id,
is_admin=True)
volume = tests_utils.create_volume(self.context, size=1,
status='available',
host=fake_host)
new_volume = tests_utils.create_volume(
self.context, size=1,
status='available',
provider_location='fake_provider_location',
_name_id=fake.VOLUME_NAME_ID,
host=fake_new_host)
new_volume._name_id = fake.VOLUME_NAME_ID
new_volume.provider_location = 'fake_provider_location'
fake_update_error = {'_name_id': new_volume._name_id,
'provider_location':
new_volume.provider_location}
expected_update = {'_name_id': volume._name_id,
'provider_location': volume.provider_location}
with mock.patch.object(self.volume.driver,
'update_migrated_volume') as migrate_update,\
mock.patch.object(self.context, 'elevated') as elevated:
migrate_update.return_value = fake_update
elevated.return_value = fake_elevated
self.volume.update_migrated_volume(self.context, volume,
new_volume, 'available')
volume_update.assert_has_calls((
mock.call(fake_elevated, new_volume.id, expected_update),
mock.call(fake_elevated, volume.id, fake_update)))
# Test the case for update_migrated_volume not implemented
# for the driver.
migrate_update.reset_mock()
volume_update.reset_mock()
# Reset the volume objects to their original value, since they
# were changed in the last call.
new_volume._name_id = fake.VOLUME_NAME_ID
new_volume.provider_location = 'fake_provider_location'
migrate_update.side_effect = NotImplementedError
self.volume.update_migrated_volume(self.context, volume,
new_volume, 'available')
volume_update.assert_has_calls((
mock.call(fake_elevated, new_volume.id, fake_update),
mock.call(fake_elevated, volume.id, fake_update_error)))
def test_migrate_volume_generic_create_volume_error(self):
self.expected_status = 'error'
with mock.patch.object(self.volume.driver, 'migrate_volume'), \
mock.patch.object(volume_rpcapi.VolumeAPI,
'create_volume') as mock_create_volume, \
mock.patch.object(self.volume, '_clean_temporary_volume') as \
clean_temporary_volume:
# Exception case at the creation of the new temporary volume
mock_create_volume.side_effect = self._fake_create_volume
volume = tests_utils.create_volume(self.context, size=0,
host=CONF.host)
host_obj = {'host': 'newhost', 'capabilities': {}}
self.assertRaises(exception.VolumeMigrationFailed,
self.volume.migrate_volume,
self.context,
volume,
host_obj,
True)
volume = objects.Volume.get_by_id(context.get_admin_context(),
volume.id)
self.assertEqual('error', volume['migration_status'])
self.assertEqual('available', volume['status'])
self.assertTrue(clean_temporary_volume.called)
self.expected_status = 'available'
def test_migrate_volume_generic_timeout_error(self):
CONF.set_override("migration_create_volume_timeout_secs", 2)
with mock.patch.object(self.volume.driver, 'migrate_volume'), \
mock.patch.object(volume_rpcapi.VolumeAPI,
'create_volume') as mock_create_volume, \
mock.patch.object(self.volume, '_clean_temporary_volume') as \
clean_temporary_volume, \
mock.patch.object(time, 'sleep'):
# Exception case at the timeout of the volume creation
self.expected_status = 'creating'
mock_create_volume.side_effect = self._fake_create_volume
volume = tests_utils.create_volume(self.context, size=0,
host=CONF.host)
host_obj = {'host': 'newhost', 'capabilities': {}}
self.assertRaises(exception.VolumeMigrationFailed,
self.volume.migrate_volume,
self.context,
volume,
host_obj,
True)
volume = objects.Volume.get_by_id(context.get_admin_context(),
volume.id)
self.assertEqual('error', volume['migration_status'])
self.assertEqual('available', volume['status'])
self.assertTrue(clean_temporary_volume.called)
self.expected_status = 'available'
def test_migrate_volume_generic_create_export_error(self):
with mock.patch.object(self.volume.driver, 'migrate_volume'),\
mock.patch.object(volume_rpcapi.VolumeAPI, 'create_volume')\
as mock_create_volume,\
mock.patch.object(self.volume, '_copy_volume_data') as \
mock_copy_volume,\
mock.patch.object(volume_rpcapi.VolumeAPI, 'delete_volume'),\
mock.patch.object(self.volume, 'migrate_volume_completion'),\
mock.patch.object(self.volume.driver, 'create_export') as \
mock_create_export:
# Exception case at create_export
mock_create_volume.side_effect = self._fake_create_volume
mock_copy_volume.side_effect = processutils.ProcessExecutionError
mock_create_export.side_effect = processutils.ProcessExecutionError
volume = tests_utils.create_volume(self.context, size=0,
host=CONF.host)
host_obj = {'host': 'newhost', 'capabilities': {}}
self.assertRaises(processutils.ProcessExecutionError,
self.volume.migrate_volume,
self.context,
volume,
host_obj,
True)
volume = objects.Volume.get_by_id(context.get_admin_context(),
volume.id)
self.assertEqual('error', volume['migration_status'])
self.assertEqual('available', volume['status'])
def test_migrate_volume_generic_migrate_volume_completion_error(self):
def fake_migrate_volume_completion(ctxt, volume, new_volume,
error=False):
db.volume_update(ctxt, volume['id'],
{'migration_status': 'completing'})
raise processutils.ProcessExecutionError
with mock.patch.object(self.volume.driver, 'migrate_volume'),\
mock.patch.object(volume_rpcapi.VolumeAPI, 'create_volume')\
as mock_create_volume,\
mock.patch.object(volume_rpcapi.VolumeAPI, 'delete_volume'),\
mock.patch.object(self.volume, 'migrate_volume_completion')\
as mock_migrate_compl,\
mock.patch.object(self.volume.driver, 'create_export'), \
mock.patch.object(self.volume, '_attach_volume') \
as mock_attach, \
mock.patch.object(self.volume, '_detach_volume'), \
mock.patch.object(os_brick.initiator.connector,
'get_connector_properties') \
as mock_get_connector_properties, \
mock.patch.object(volutils, 'copy_volume') as mock_copy, \
mock.patch.object(volume_rpcapi.VolumeAPI,
'get_capabilities') \
as mock_get_capabilities:
# Exception case at delete_volume
# source_volume['migration_status'] is 'completing'
mock_create_volume.side_effect = self._fake_create_volume
mock_migrate_compl.side_effect = fake_migrate_volume_completion
mock_get_connector_properties.return_value = {}
mock_attach.side_effect = [{'device': {'path': 'bar'}},
{'device': {'path': 'foo'}}]
mock_get_capabilities.return_value = {'sparse_copy_volume': True}
volume = tests_utils.create_volume(self.context, size=0,
host=CONF.host)
host_obj = {'host': 'newhost', 'capabilities': {}}
self.assertRaises(processutils.ProcessExecutionError,
self.volume.migrate_volume,
self.context,
volume,
host_obj,
True)
volume = db.volume_get(context.get_admin_context(), volume['id'])
self.assertEqual('error', volume['migration_status'])
self.assertEqual('available', volume['status'])
mock_copy.assert_called_once_with('foo', 'bar', 0, '1M',
sparse=True)
def fake_attach_volume(self, ctxt, volume, instance_uuid, host_name,
mountpoint, mode):
tests_utils.attach_volume(ctxt, volume.id,
instance_uuid, host_name,
'/dev/vda')
def _test_migrate_volume_completion(self, status='available',
instance_uuid=None, attached_host=None,
retyping=False,
previous_status='available'):
initial_status = retyping and 'retyping' or status
old_volume = tests_utils.create_volume(self.context, size=0,
host=CONF.host,
status=initial_status,
migration_status='migrating',
previous_status=previous_status)
attachment = None
if status == 'in-use':
vol = tests_utils.attach_volume(self.context, old_volume.id,
instance_uuid, attached_host,
'/dev/vda')
self.assertEqual('in-use', vol['status'])
attachment = vol['volume_attachment'][0]
target_status = 'target:%s' % old_volume.id
new_host = CONF.host + 'new'
new_volume = tests_utils.create_volume(self.context, size=0,
host=new_host,
migration_status=target_status)
with mock.patch.object(self.volume, 'detach_volume') as \
mock_detach_volume,\
mock.patch.object(volume_rpcapi.VolumeAPI,
'delete_volume') as mock_delete_volume,\
mock.patch.object(volume_rpcapi.VolumeAPI,
'attach_volume') as mock_attach_volume,\
mock.patch.object(volume_rpcapi.VolumeAPI,
'update_migrated_volume'),\
mock.patch.object(self.volume.driver, 'attach_volume'):
mock_attach_volume.side_effect = self.fake_attach_volume
old_volume_host = old_volume.host
new_volume_host = new_volume.host
self.volume.migrate_volume_completion(self.context, old_volume,
new_volume)
after_new_volume = objects.Volume.get_by_id(self.context,
new_volume.id)
after_old_volume = objects.Volume.get_by_id(self.context,
old_volume.id)
if status == 'in-use':
mock_detach_volume.assert_called_with(self.context,
old_volume.id,
attachment['id'])
attachments = db.volume_attachment_get_all_by_instance_uuid(
self.context, instance_uuid)
mock_attach_volume.assert_called_once_with(
self.context,
old_volume,
attachment['instance_uuid'],
attachment['attached_host'],
attachment['mountpoint'],
'rw'
)
self.assertIsNotNone(attachments)
self.assertEqual(attached_host,
attachments[0]['attached_host'])
self.assertEqual(instance_uuid,
attachments[0]['instance_uuid'])
else:
self.assertFalse(mock_detach_volume.called)
self.assertTrue(mock_delete_volume.called)
# NOTE(sborkows): the migrate_volume_completion method alters
# old and new volume objects, so we need to check the equality
# between the former host value and the actual one.
self.assertEqual(old_volume_host, after_new_volume.host)
self.assertEqual(new_volume_host, after_old_volume.host)
def test_migrate_volume_completion_retype_available(self):
self._test_migrate_volume_completion('available', retyping=True)
def test_migrate_volume_completion_retype_in_use(self):
self._test_migrate_volume_completion(
'in-use',
'83c969d5-065e-4c9c-907d-5394bc2e98e2',
'some-host',
retyping=True,
previous_status='in-use')
def test_migrate_volume_completion_migrate_available(self):
self._test_migrate_volume_completion()
def test_migrate_volume_completion_migrate_in_use(self):
self._test_migrate_volume_completion(
'in-use',
'83c969d5-065e-4c9c-907d-5394bc2e98e2',
'some-host',
retyping=False,
previous_status='in-use')
@ddt.data(False, True)
def test_api_migrate_volume_completion_from_swap_with_no_migration(
self, swap_error):
# This test validates that Cinder properly finishes the swap volume
# status updates for the case that no migration has occurred
instance_uuid = '83c969d5-065e-4c9c-907d-5394bc2e98e2'
attached_host = 'attached-host'
orig_attached_vol = tests_utils.create_volume(self.context, size=0)
orig_attached_vol = tests_utils.attach_volume(
self.context, orig_attached_vol['id'], instance_uuid,
attached_host, '/dev/vda')
new_volume = tests_utils.create_volume(self.context, size=0)
@mock.patch.object(volume_rpcapi.VolumeAPI, 'detach_volume')
@mock.patch.object(volume_rpcapi.VolumeAPI, 'attach_volume')
def _run_migration_completion(rpc_attach_volume,
rpc_detach_volume):
attachment = orig_attached_vol['volume_attachment'][0]
attachment_id = attachment['id']
rpc_attach_volume.side_effect = self.fake_attach_volume
vol_id = volume_api.API().migrate_volume_completion(
self.context, orig_attached_vol, new_volume, swap_error)
if swap_error:
# When swap failed, we don't want to finish attachment
self.assertFalse(rpc_detach_volume.called)
self.assertFalse(rpc_attach_volume.called)
else:
# When no error, we should be finishing the attachment
rpc_detach_volume.assert_called_with(self.context,
orig_attached_vol,
attachment_id)
rpc_attach_volume.assert_called_with(
self.context, new_volume, attachment['instance_uuid'],
attachment['attached_host'], attachment['mountpoint'],
'rw')
self.assertEqual(new_volume['id'], vol_id)
_run_migration_completion()
@mock.patch('cinder.tests.unit.fake_notifier.FakeNotifier._notify')
def test_retype_setup_fail_volume_is_available(self, mock_notify):
"""Verify volume is still available if retype prepare failed."""
elevated = context.get_admin_context()
project_id = self.context.project_id
db.volume_type_create(elevated, {'name': 'old', 'extra_specs': {}})
old_vol_type = db.volume_type_get_by_name(elevated, 'old')
db.volume_type_create(elevated, {'name': 'new', 'extra_specs': {}})
new_vol_type = db.volume_type_get_by_name(elevated, 'new')
db.quota_create(elevated, project_id, 'volumes_new', 0)
volume = tests_utils.create_volume(self.context, size=1,
host=CONF.host, status='available',
volume_type_id=old_vol_type['id'])
api = cinder.volume.api.API()
self.assertRaises(exception.VolumeLimitExceeded, api.retype,
self.context, volume, new_vol_type['id'])
volume = db.volume_get(elevated, volume.id)
mock_notify.assert_not_called()
self.assertEqual('available', volume['status'])
@mock.patch('cinder.tests.unit.fake_notifier.FakeNotifier._notify')
def _retype_volume_exec(self, driver, mock_notify,
snap=False, policy='on-demand',
migrate_exc=False, exc=None, diff_equal=False,
replica=False, reserve_vol_type_only=False,
encryption_changed=False,
replica_new=None):
elevated = context.get_admin_context()
project_id = self.context.project_id
if replica:
rep_status = 'enabled'
extra_specs = {'replication_enabled': '<is> True'}
else:
rep_status = 'disabled'
extra_specs = {}
if replica_new is None:
replica_new = replica
new_specs = {'replication_enabled': '<is> True'} if replica_new else {}
db.volume_type_create(elevated, {'name': 'old',
'extra_specs': extra_specs})
old_vol_type = db.volume_type_get_by_name(elevated, 'old')
db.volume_type_create(elevated, {'name': 'new',
'extra_specs': new_specs})
vol_type = db.volume_type_get_by_name(elevated, 'new')
db.quota_create(elevated, project_id, 'volumes_new', 10)
volume = tests_utils.create_volume(self.context, size=1,
host=CONF.host, status='retyping',
volume_type_id=old_vol_type['id'],
replication_status=rep_status)
volume.previous_status = 'available'
volume.save()
if snap:
create_snapshot(volume.id, size=volume.size,
user_id=self.user_context.user_id,
project_id=self.user_context.project_id,
ctxt=self.user_context)
if driver or diff_equal:
host_obj = {'host': CONF.host, 'capabilities': {}}
else:
host_obj = {'host': 'newhost', 'capabilities': {}}
reserve_opts = {'volumes': 1, 'gigabytes': volume.size}
QUOTAS.add_volume_type_opts(self.context,
reserve_opts,
vol_type['id'])
if reserve_vol_type_only:
reserve_opts.pop('volumes')
reserve_opts.pop('gigabytes')
try:
usage = db.quota_usage_get(elevated, project_id, 'volumes')
total_volumes_in_use = usage.in_use
usage = db.quota_usage_get(elevated, project_id, 'gigabytes')
total_gigabytes_in_use = usage.in_use
except exception.QuotaUsageNotFound:
total_volumes_in_use = 0
total_gigabytes_in_use = 0
reservations = QUOTAS.reserve(self.context,
project_id=project_id,
**reserve_opts)
old_reserve_opts = {'volumes': -1, 'gigabytes': -volume.size}
QUOTAS.add_volume_type_opts(self.context,
old_reserve_opts,
old_vol_type['id'])
old_reservations = QUOTAS.reserve(self.context,
project_id=project_id,
**old_reserve_opts)
with mock.patch.object(self.volume.driver, 'retype') as _retype,\
mock.patch.object(volume_types, 'volume_types_diff') as _diff,\
mock.patch.object(self.volume, 'migrate_volume') as _mig,\
mock.patch.object(db.sqlalchemy.api, 'volume_get') as _vget,\
mock.patch.object(context.RequestContext, 'elevated') as _ctx:
_vget.return_value = volume
_retype.return_value = driver
_ctx.return_value = self.context
returned_diff = {
'encryption': {},
'qos_specs': {},
'extra_specs': {},
}
if replica != replica_new:
returned_diff['extra_specs']['replication_enabled'] = (
extra_specs.get('replication_enabled'),
new_specs.get('replication_enabled'))
expected_replica_status = 'enabled' if replica_new else 'disabled'
if encryption_changed:
returned_diff['encryption'] = 'fake'
_diff.return_value = (returned_diff, diff_equal)
if migrate_exc:
_mig.side_effect = KeyError
else:
_mig.return_value = True
if not exc:
self.volume.retype(self.context, volume,
vol_type['id'], host_obj,
migration_policy=policy,
reservations=reservations,
old_reservations=old_reservations)
else:
self.assertRaises(exc, self.volume.retype,
self.context, volume,
vol_type['id'], host_obj,
migration_policy=policy,
reservations=reservations,
old_reservations=old_reservations)
if host_obj['host'] != CONF.host:
_retype.assert_not_called()
# get volume/quota properties
volume = objects.Volume.get_by_id(elevated, volume.id)
try:
usage = db.quota_usage_get(elevated, project_id, 'volumes_new')
volumes_in_use = usage.in_use
except exception.QuotaUsageNotFound:
volumes_in_use = 0
# Get new in_use after retype, it should not be changed.
if reserve_vol_type_only:
try:
usage = db.quota_usage_get(elevated, project_id, 'volumes')
new_total_volumes_in_use = usage.in_use
usage = db.quota_usage_get(elevated, project_id, 'gigabytes')
new_total_gigabytes_in_use = usage.in_use
except exception.QuotaUsageNotFound:
new_total_volumes_in_use = 0
new_total_gigabytes_in_use = 0
self.assertEqual(total_volumes_in_use, new_total_volumes_in_use)
self.assertEqual(total_gigabytes_in_use,
new_total_gigabytes_in_use)
# check properties
if driver or diff_equal:
self.assertEqual(vol_type['id'], volume.volume_type_id)
self.assertEqual('available', volume.status)
self.assertEqual(CONF.host, volume.host)
self.assertEqual(1, volumes_in_use)
self.assert_notify_called(mock_notify,
(['INFO', 'volume.retype'],))
elif not exc:
self.assertEqual(old_vol_type['id'], volume.volume_type_id)
self.assertEqual('retyping', volume.status)
self.assertEqual(CONF.host, volume.host)
self.assertEqual(1, volumes_in_use)
self.assert_notify_called(mock_notify,
(['INFO', 'volume.retype'],))
else:
self.assertEqual(old_vol_type['id'], volume.volume_type_id)
self.assertEqual('available', volume.status)
self.assertEqual(CONF.host, volume.host)
self.assertEqual(0, volumes_in_use)
mock_notify.assert_not_called()
if encryption_changed:
self.assertTrue(_mig.called)
self.assertEqual(expected_replica_status, volume.replication_status)
def test_retype_volume_driver_success(self):
self._retype_volume_exec(True)
@ddt.data((False, False), (False, True), (True, False), (True, True))
@ddt.unpack
def test_retype_volume_replica(self, replica, replica_new):
self._retype_volume_exec(True, replica=replica,
replica_new=replica_new)
def test_retype_volume_migration_bad_policy(self):
# Test volume retype that requires migration by not allowed
self._retype_volume_exec(False, policy='never',
exc=exception.VolumeMigrationFailed)
def test_retype_volume_migration_with_replica(self):
self._retype_volume_exec(False,
replica=True,
exc=exception.InvalidVolume)
def test_retype_volume_migration_with_snaps(self):
self._retype_volume_exec(False, snap=True, exc=exception.InvalidVolume)
def test_retype_volume_migration_failed(self):
self._retype_volume_exec(False, migrate_exc=True, exc=KeyError)
def test_retype_volume_migration_success(self):
self._retype_volume_exec(False, migrate_exc=False, exc=None)
def test_retype_volume_migration_equal_types(self):
self._retype_volume_exec(False, diff_equal=True)
def test_retype_volume_with_type_only(self):
self._retype_volume_exec(True, reserve_vol_type_only=True)
def test_retype_volume_migration_encryption(self):
self._retype_volume_exec(False, encryption_changed=True)
def test_migrate_driver_not_initialized(self):
volume = tests_utils.create_volume(self.context, size=0,
host=CONF.host)
host_obj = {'host': 'newhost', 'capabilities': {}}
self.volume.driver._initialized = False
self.assertRaises(exception.DriverNotInitialized,
self.volume.migrate_volume,
self.context, volume, host_obj, True)
volume = objects.Volume.get_by_id(context.get_admin_context(),
volume.id)
self.assertEqual('error', volume.migration_status)
# lets cleanup the mess.
self.volume.driver._initialized = True
self.volume.delete_volume(self.context, volume)
def test_delete_source_volume_in_migration(self):
"""Test deleting a source volume that is in migration."""
self._test_delete_volume_in_migration('migrating')
def test_delete_destination_volume_in_migration(self):
"""Test deleting a destination volume that is in migration."""
self._test_delete_volume_in_migration('target:vol-id')
def _test_delete_volume_in_migration(self, migration_status):
"""Test deleting a volume that is in migration."""
volume = tests_utils.create_volume(self.context, host=CONF.host,
migration_status=migration_status)
self.volume.delete_volume(self.context, volume=volume)
# The volume is successfully removed during the volume delete
# and won't exist in the database any more.
self.assertRaises(exception.VolumeNotFound, volume.refresh)
@ddt.ddt
class ReplicationTestCase(base.BaseVolumeTestCase):
@mock.patch('cinder.objects.Service.is_up', True)
@mock.patch.object(volume_rpcapi.VolumeAPI, 'failover')
@mock.patch.object(cinder.db, 'conditional_update')
@mock.patch.object(objects.ServiceList, 'get_all')
def test_failover(self, mock_get_all, mock_db_update, mock_failover):
"""Test replication failover."""
service = fake_service.fake_service_obj(self.context,
binary='cinder-volume')
mock_get_all.return_value = [service]
mock_db_update.return_value = {'replication_status': 'enabled'}
volume_api = cinder.volume.api.API()
volume_api.failover(self.context, host=CONF.host, cluster_name=None)
mock_failover.assert_called_once_with(self.context, service, None)
@mock.patch.object(volume_rpcapi.VolumeAPI, 'failover')
@mock.patch.object(cinder.db, 'conditional_update')
@mock.patch.object(cinder.db, 'service_get_all')
def test_failover_unexpected_status(self, mock_db_get_all, mock_db_update,
mock_failover):
"""Test replication failover unxepected status."""
mock_db_get_all.return_value = [fake_service.fake_service_obj(
self.context,
binary='cinder-volume')]
mock_db_update.return_value = None
volume_api = cinder.volume.api.API()
self.assertRaises(exception.InvalidInput,
volume_api.failover,
self.context,
host=CONF.host,
cluster_name=None)
@mock.patch.object(volume_rpcapi.VolumeAPI, 'freeze_host')
@mock.patch.object(cinder.db, 'conditional_update', return_value=1)
@mock.patch.object(cinder.objects.ServiceList, 'get_all')
def test_freeze_host(self, mock_get_all, mock_db_update,
mock_freeze):
"""Test replication freeze_host."""
service = fake_service.fake_service_obj(self.context,
binary='cinder-volume')
mock_get_all.return_value = [service]
mock_freeze.return_value = True
volume_api = cinder.volume.api.API()
volume_api.freeze_host(self.context, host=CONF.host, cluster_name=None)
mock_freeze.assert_called_once_with(self.context, service)
@mock.patch.object(volume_rpcapi.VolumeAPI, 'freeze_host')
@mock.patch.object(cinder.db, 'conditional_update')
@mock.patch.object(cinder.db, 'service_get_all')
def test_freeze_host_unexpected_status(self, mock_get_all,
mock_db_update,
mock_freeze):
"""Test replication freeze_host unexpected status."""
mock_get_all.return_value = [fake_service.fake_service_obj(
self.context,
binary='cinder-volume')]
mock_db_update.return_value = None
volume_api = cinder.volume.api.API()
self.assertRaises(exception.InvalidInput,
volume_api.freeze_host,
self.context,
host=CONF.host,
cluster_name=None)
@mock.patch.object(volume_rpcapi.VolumeAPI, 'thaw_host')
@mock.patch.object(cinder.db, 'conditional_update', return_value=1)
@mock.patch.object(cinder.objects.ServiceList, 'get_all')
def test_thaw_host(self, mock_get_all, mock_db_update,
mock_thaw):
"""Test replication thaw_host."""
service = fake_service.fake_service_obj(self.context,
binary='cinder-volume')
mock_get_all.return_value = [service]
mock_thaw.return_value = True
volume_api = cinder.volume.api.API()
volume_api.thaw_host(self.context, host=CONF.host, cluster_name=None)
mock_thaw.assert_called_once_with(self.context, service)
@mock.patch.object(volume_rpcapi.VolumeAPI, 'thaw_host')
@mock.patch.object(cinder.db, 'conditional_update')
@mock.patch.object(cinder.db, 'service_get_all')
def test_thaw_host_unexpected_status(self, mock_get_all,
mock_db_update,
mock_thaw):
"""Test replication thaw_host unexpected status."""
mock_get_all.return_value = [fake_service.fake_service_obj(
self.context,
binary='cinder-volume')]
mock_db_update.return_value = None
volume_api = cinder.volume.api.API()
self.assertRaises(exception.InvalidInput,
volume_api.thaw_host,
self.context,
host=CONF.host, cluster_name=None)
@mock.patch('cinder.volume.driver.BaseVD.failover_completed')
def test_failover_completed(self, completed_mock):
rep_field = fields.ReplicationStatus
svc = objects.Service(self.context, host=self.volume.host,
binary=constants.VOLUME_BINARY,
replication_status=rep_field.ENABLED)
svc.create()
self.volume.failover_completed(
self.context,
{'active_backend_id': 'secondary',
'replication_status': rep_field.FAILED_OVER})
service = objects.Service.get_by_id(self.context, svc.id)
self.assertEqual('secondary', service.active_backend_id)
self.assertEqual('failed-over', service.replication_status)
completed_mock.assert_called_once_with(self.context, 'secondary')
@mock.patch('cinder.volume.driver.BaseVD.failover_completed', wraps=True)
def test_failover_completed_driver_failure(self, completed_mock):
rep_field = fields.ReplicationStatus
svc = objects.Service(self.context, host=self.volume.host,
binary=constants.VOLUME_BINARY,
replication_status=rep_field.ENABLED)
svc.create()
self.volume.failover_completed(
self.context,
{'active_backend_id': 'secondary',
'replication_status': rep_field.FAILED_OVER})
service = objects.Service.get_by_id(self.context, svc.id)
self.assertEqual('secondary', service.active_backend_id)
self.assertEqual(rep_field.ERROR, service.replication_status)
self.assertTrue(service.disabled)
self.assertIsNotNone(service.disabled_reason)
completed_mock.assert_called_once_with(self.context, 'secondary')
@mock.patch('cinder.volume.rpcapi.VolumeAPI.failover_completed')
def test_finish_failover_non_clustered(self, completed_mock):
svc = mock.Mock(is_clustered=None)
self.volume.finish_failover(self.context, svc, mock.sentinel.updates)
svc.update.assert_called_once_with(mock.sentinel.updates)
svc.save.assert_called_once_with()
completed_mock.assert_not_called()
@mock.patch('cinder.volume.rpcapi.VolumeAPI.failover_completed')
def test_finish_failover_clustered(self, completed_mock):
svc = mock.Mock(cluster_name='cluster_name')
updates = {'status': 'error'}
self.volume.finish_failover(self.context, svc, updates)
completed_mock.assert_called_once_with(self.context, svc, updates)
svc.cluster.status = 'error'
svc.cluster.save.assert_called_once()
@ddt.data(None, 'cluster_name')
@mock.patch('cinder.volume.manager.VolumeManager.finish_failover')
@mock.patch('cinder.volume.manager.VolumeManager._get_my_volumes')
def test_failover_manager(self, cluster, get_vols_mock, finish_mock):
"""Test manager's failover method for clustered and not clustered."""
rep_field = fields.ReplicationStatus
svc = objects.Service(self.context, host=self.volume.host,
binary=constants.VOLUME_BINARY,
cluster_name=cluster,
replication_status=rep_field.ENABLED)
svc.create()
vol = objects.Volume(self.context, host=self.volume.host)
vol.create()
get_vols_mock.return_value = [vol]
with mock.patch.object(self.volume, 'driver') as driver:
called, not_called = driver.failover_host, driver.failover
if cluster:
called, not_called = not_called, called
called.return_value = ('secondary', [{'volume_id': vol.id,
'updates': {'status': 'error'}}])
self.volume.failover(self.context,
secondary_backend_id='secondary')
not_called.assert_not_called()
called.assert_called_once_with(self.context, [vol],
secondary_id='secondary')
expected_update = {'replication_status': rep_field.FAILED_OVER,
'active_backend_id': 'secondary',
'disabled': True,
'disabled_reason': 'failed-over'}
finish_mock.assert_called_once_with(self.context, svc, expected_update)
volume = objects.Volume.get_by_id(self.context, vol.id)
self.assertEqual('error', volume.status)
@ddt.data(('host1', None), (None, 'mycluster'))
@ddt.unpack
def test_failover_api_fail_multiple_results(self, host, cluster):
"""Fail if we try to failover multiple backends in the same request."""
rep_field = fields.ReplicationStatus
clusters = [
objects.Cluster(self.context,
name='mycluster@backend1',
replication_status=rep_field.ENABLED,
binary=constants.VOLUME_BINARY),
objects.Cluster(self.context,
name='mycluster@backend2',
replication_status=rep_field.ENABLED,
binary=constants.VOLUME_BINARY)
]
clusters[0].create()
clusters[1].create()
services = [
objects.Service(self.context, host='host1@backend1',
cluster_name=clusters[0].name,
replication_status=rep_field.ENABLED,
binary=constants.VOLUME_BINARY),
objects.Service(self.context, host='host1@backend2',
cluster_name=clusters[1].name,
replication_status=rep_field.ENABLED,
binary=constants.VOLUME_BINARY),
]
services[0].create()
services[1].create()
self.assertRaises(exception.Invalid,
self.volume_api.failover, self.context, host,
cluster)
def test_failover_api_not_found(self):
self.assertRaises(exception.ServiceNotFound, self.volume_api.failover,
self.context, 'host1', None)
@mock.patch('cinder.volume.rpcapi.VolumeAPI.failover')
def test_failover_api_success_multiple_results(self, failover_mock):
"""Succeed to failover multiple services for the same backend."""
rep_field = fields.ReplicationStatus
cluster_name = 'mycluster@backend1'
cluster = objects.Cluster(self.context,
name=cluster_name,
replication_status=rep_field.ENABLED,
binary=constants.VOLUME_BINARY)
cluster.create()
services = [
objects.Service(self.context, host='host1@backend1',
cluster_name=cluster_name,
replication_status=rep_field.ENABLED,
binary=constants.VOLUME_BINARY),
objects.Service(self.context, host='host2@backend1',
cluster_name=cluster_name,
replication_status=rep_field.ENABLED,
binary=constants.VOLUME_BINARY),
]
services[0].create()
services[1].create()
self.volume_api.failover(self.context, None, cluster_name,
mock.sentinel.secondary_id)
for service in services + [cluster]:
self.assertEqual(rep_field.ENABLED, service.replication_status)
service.refresh()
self.assertEqual(rep_field.FAILING_OVER,
service.replication_status)
failover_mock.assert_called_once_with(self.context, mock.ANY,
mock.sentinel.secondary_id)
self.assertEqual(services[0].id, failover_mock.call_args[0][1].id)
@mock.patch('cinder.volume.rpcapi.VolumeAPI.failover')
def test_failover_api_success_multiple_results_not_updated(self,
failover_mock):
"""Succeed to failover even if a service is not updated."""
rep_field = fields.ReplicationStatus
cluster_name = 'mycluster@backend1'
cluster = objects.Cluster(self.context,
name=cluster_name,
replication_status=rep_field.ENABLED,
binary=constants.VOLUME_BINARY)
cluster.create()
services = [
objects.Service(self.context, host='host1@backend1',
cluster_name=cluster_name,
replication_status=rep_field.ENABLED,
binary=constants.VOLUME_BINARY),
objects.Service(self.context, host='host2@backend1',
cluster_name=cluster_name,
replication_status=rep_field.ERROR,
binary=constants.VOLUME_BINARY),
]
services[0].create()
services[1].create()
self.volume_api.failover(self.context, None, cluster_name,
mock.sentinel.secondary_id)
for service in services[:1] + [cluster]:
service.refresh()
self.assertEqual(rep_field.FAILING_OVER,
service.replication_status)
services[1].refresh()
self.assertEqual(rep_field.ERROR, services[1].replication_status)
failover_mock.assert_called_once_with(self.context, mock.ANY,
mock.sentinel.secondary_id)
self.assertEqual(services[0].id, failover_mock.call_args[0][1].id)
@mock.patch('cinder.volume.rpcapi.VolumeAPI.failover')
def test_failover_api_fail_multiple_results_not_updated(self,
failover_mock):
"""Fail if none of the services could be updated."""
rep_field = fields.ReplicationStatus
cluster_name = 'mycluster@backend1'
cluster = objects.Cluster(self.context,
name=cluster_name,
replication_status=rep_field.ENABLED,
binary=constants.VOLUME_BINARY)
cluster.create()
down_time = timeutils.datetime.datetime(1970, 1, 1)
services = [
# This service is down
objects.Service(self.context, host='host1@backend1',
cluster_name=cluster_name,
replication_status=rep_field.ENABLED,
created_at=down_time,
updated_at=down_time,
modified_at=down_time,
binary=constants.VOLUME_BINARY),
# This service is not with the right replication status
objects.Service(self.context, host='host2@backend1',
cluster_name=cluster_name,
replication_status=rep_field.ERROR,
binary=constants.VOLUME_BINARY),
]
services[0].create()
services[1].create()
self.assertRaises(exception.InvalidInput,
self.volume_api.failover, self.context, None,
cluster_name, mock.sentinel.secondary_id)
for service in services:
svc = objects.Service.get_by_id(self.context, service.id)
self.assertEqual(service.replication_status,
svc.replication_status)
cluster.refresh()
self.assertEqual(rep_field.ENABLED, cluster.replication_status)
failover_mock.assert_not_called()
class CopyVolumeToImageTestCase(base.BaseVolumeTestCase):
def fake_local_path(self, volume):
return self.dst_path
def setUp(self):
super(CopyVolumeToImageTestCase, self).setUp()
self.dst_fd, self.dst_path = tempfile.mkstemp()
self.addCleanup(os.unlink, self.dst_path)
os.close(self.dst_fd)
self.mock_object(self.volume.driver, 'local_path',
self.fake_local_path)
self.image_id = '70a599e0-31e7-49b7-b260-868f441e862b'
self.image_meta = {
'id': self.image_id,
'container_format': 'bare',
'disk_format': 'raw'
}
self.volume_id = fake.VOLUME_ID
self.addCleanup(db.volume_destroy, self.context, self.volume_id)
self.volume_attrs = {
'id': self.volume_id,
'updated_at': datetime.datetime(1, 1, 1, 1, 1, 1),
'display_description': 'Test Desc',
'size': 20,
'status': 'uploading',
'host': 'dummy'
}
def test_copy_volume_to_image_status_available(self):
# creating volume testdata
self.volume_attrs['instance_uuid'] = None
db.volume_create(self.context, self.volume_attrs)
# start test
self.volume.copy_volume_to_image(self.context,
self.volume_id,
self.image_meta)
volume = db.volume_get(self.context, self.volume_id)
self.assertEqual('available', volume['status'])
def test_copy_volume_to_image_over_image_quota(self):
# creating volume testdata
self.volume_attrs['instance_uuid'] = None
volume = db.volume_create(self.context, self.volume_attrs)
with mock.patch.object(self.volume.driver,
'copy_volume_to_image') as driver_copy_mock:
driver_copy_mock.side_effect = exception.ImageLimitExceeded
# test with image not in queued state
self.assertRaises(exception.ImageLimitExceeded,
self.volume.copy_volume_to_image,
self.context,
self.volume_id,
self.image_meta)
# Assert a user message was created
self.volume.message_api.create.assert_called_once_with(
self.context,
defined_messages.EventIds.IMAGE_FROM_VOLUME_OVER_QUOTA,
self.context.project_id, resource_type=resource_types.VOLUME,
resource_uuid=volume['id'])
def test_copy_volume_to_image_instance_deleted(self):
# During uploading volume to image if instance is deleted,
# volume should be in available status.
self.image_meta['id'] = 'a440c04b-79fa-479c-bed1-0b816eaec379'
# Creating volume testdata
self.volume_attrs['instance_uuid'] = 'b21f957d-a72f-4b93-b5a5-' \
'45b1161abb02'
db.volume_create(self.context, self.volume_attrs)
method = 'volume_update_status_based_on_attachment'
with mock.patch.object(db, method,
wraps=getattr(db, method)) as mock_update:
# Start test
self.volume.copy_volume_to_image(self.context,
self.volume_id,
self.image_meta)
# Check 'volume_update_status_after_copy_volume_to_image'
# is called 1 time
self.assertEqual(1, mock_update.call_count)
# Check volume status has changed to available because
# instance is deleted
volume = db.volume_get(self.context, self.volume_id)
self.assertEqual('available', volume['status'])
def test_copy_volume_to_image_status_use(self):
self.image_meta['id'] = 'a440c04b-79fa-479c-bed1-0b816eaec379'
# creating volume testdata
db.volume_create(self.context, self.volume_attrs)
# start test
self.volume.copy_volume_to_image(self.context,
self.volume_id,
self.image_meta)
volume = db.volume_get(self.context, self.volume_id)
self.assertEqual('available', volume['status'])
def test_copy_volume_to_image_exception(self):
self.image_meta['id'] = self.FAKE_UUID
# creating volume testdata
self.volume_attrs['status'] = 'in-use'
db.volume_create(self.context, self.volume_attrs)
# start test
self.assertRaises(exception.ImageNotFound,
self.volume.copy_volume_to_image,
self.context,
self.volume_id,
self.image_meta)
volume = db.volume_get(self.context, self.volume_id)
self.assertEqual('available', volume['status'])
def test_copy_volume_to_image_driver_not_initialized(self):
# creating volume testdata
db.volume_create(self.context, self.volume_attrs)
# set initialized to False
self.volume.driver._initialized = False
# start test
self.assertRaises(exception.DriverNotInitialized,
self.volume.copy_volume_to_image,
self.context,
self.volume_id,
self.image_meta)
volume = db.volume_get(self.context, self.volume_id)
self.assertEqual('available', volume.status)
def test_copy_volume_to_image_driver_exception(self):
self.image_meta['id'] = self.image_id
image_service = fake_image.FakeImageService()
# create new image in queued state
queued_image_id = 'd5133f15-f753-41bd-920a-06b8c49275d9'
queued_image_meta = image_service.show(self.context, self.image_id)
queued_image_meta['id'] = queued_image_id
queued_image_meta['status'] = 'queued'
image_service.create(self.context, queued_image_meta)
# create new image in saving state
saving_image_id = '5c6eec33-bab4-4e7d-b2c9-88e2d0a5f6f2'
saving_image_meta = image_service.show(self.context, self.image_id)
saving_image_meta['id'] = saving_image_id
saving_image_meta['status'] = 'saving'
image_service.create(self.context, saving_image_meta)
# create volume
self.volume_attrs['status'] = 'available'
self.volume_attrs['instance_uuid'] = None
db.volume_create(self.context, self.volume_attrs)
with mock.patch.object(self.volume.driver,
'copy_volume_to_image') as driver_copy_mock:
driver_copy_mock.side_effect = exception.VolumeDriverException(
"Error")
# test with image not in queued state
self.assertRaises(exception.VolumeDriverException,
self.volume.copy_volume_to_image,
self.context,
self.volume_id,
self.image_meta)
# Make sure we are passing an OVO instance and not an ORM instance
# to the driver
self.assertIsInstance(driver_copy_mock.call_args[0][1],
objects.Volume)
volume = db.volume_get(self.context, self.volume_id)
self.assertEqual('available', volume['status'])
# image shouldn't be deleted if it is not in queued state
image_service.show(self.context, self.image_id)
# test with image in queued state
self.assertRaises(exception.VolumeDriverException,
self.volume.copy_volume_to_image,
self.context,
self.volume_id,
queued_image_meta)
volume = db.volume_get(self.context, self.volume_id)
self.assertEqual('available', volume['status'])
# queued image should be deleted
self.assertRaises(exception.ImageNotFound,
image_service.show,
self.context,
queued_image_id)
# test with image in saving state
self.assertRaises(exception.VolumeDriverException,
self.volume.copy_volume_to_image,
self.context,
self.volume_id,
saving_image_meta)
volume = db.volume_get(self.context, self.volume_id)
self.assertEqual('available', volume['status'])
# image in saving state should be deleted
self.assertRaises(exception.ImageNotFound,
image_service.show,
self.context,
saving_image_id)
@mock.patch.object(QUOTAS, 'reserve')
@mock.patch.object(QUOTAS, 'commit')
@mock.patch.object(vol_manager.VolumeManager, 'create_volume')
@mock.patch.object(fake_driver.FakeLoggingVolumeDriver,
'copy_volume_to_image')
def _test_copy_volume_to_image_with_image_volume(
self, mock_copy, mock_create, mock_quota_commit,
mock_quota_reserve):
self.flags(glance_api_version=2)
self.volume.driver.configuration.image_upload_use_cinder_backend = True
self.addCleanup(fake_image.FakeImageService_reset)
image_service = fake_image.FakeImageService()
def add_location_wrapper(ctx, id, uri, metadata):
try:
volume = db.volume_get(ctx, id)
self.assertEqual(ctx.project_id,
volume['metadata']['image_owner'])
except exception.VolumeNotFound:
pass
return image_service.add_location_orig(ctx, id, uri, metadata)
image_service.add_location_orig = image_service.add_location
image_service.add_location = add_location_wrapper
image_id = '5c6eec33-bab4-4e7d-b2c9-88e2d0a5f6f2'
self.image_meta['id'] = image_id
self.image_meta['status'] = 'queued'
image_service.create(self.context, self.image_meta)
# creating volume testdata
self.volume_attrs['instance_uuid'] = None
db.volume_create(self.context, self.volume_attrs)
def fake_create(context, volume, **kwargs):
db.volume_update(context, volume.id, {'status': 'available'})
mock_create.side_effect = fake_create
# start test
self.volume.copy_volume_to_image(self.context,
self.volume_id,
self.image_meta)
volume = db.volume_get(self.context, self.volume_id)
self.assertEqual('available', volume['status'])
# return create image
image = image_service.show(self.context, image_id)
image_service.delete(self.context, image_id)
return image
def test_copy_volume_to_image_with_image_volume(self):
image = self._test_copy_volume_to_image_with_image_volume()
self.assertTrue(image['locations'][0]['url'].startswith('cinder://'))
def test_copy_volume_to_image_with_image_volume_qcow2(self):
self.image_meta['disk_format'] = 'qcow2'
image = self._test_copy_volume_to_image_with_image_volume()
self.assertNotIn('locations', image)
@mock.patch.object(vol_manager.VolumeManager, 'delete_volume')
@mock.patch.object(fake_image._FakeImageService, 'add_location',
side_effect=exception.Invalid)
def test_copy_volume_to_image_with_image_volume_failure(
self, mock_add_location, mock_delete):
image = self._test_copy_volume_to_image_with_image_volume()
self.assertNotIn('locations', image)
self.assertTrue(mock_delete.called)
class GetActiveByWindowTestCase(base.BaseVolumeTestCase):
def setUp(self):
super(GetActiveByWindowTestCase, self).setUp()
self.ctx = context.get_admin_context(read_deleted="yes")
self.db_vol_attrs = [
{
'id': fake.VOLUME_ID,
'host': 'devstack',
'project_id': fake.PROJECT_ID,
'created_at': datetime.datetime(1, 1, 1, 1, 1, 1),
'deleted': True, 'status': 'deleted',
'deleted_at': datetime.datetime(1, 2, 1, 1, 1, 1),
},
{
'id': fake.VOLUME2_ID,
'host': 'devstack',
'project_id': fake.PROJECT_ID,
'created_at': datetime.datetime(1, 1, 1, 1, 1, 1),
'deleted': True, 'status': 'deleted',
'deleted_at': datetime.datetime(1, 3, 10, 1, 1, 1),
},
{
'id': fake.VOLUME3_ID,
'host': 'devstack',
'project_id': fake.PROJECT_ID,
'created_at': datetime.datetime(1, 1, 1, 1, 1, 1),
'deleted': True, 'status': 'deleted',
'deleted_at': datetime.datetime(1, 5, 1, 1, 1, 1),
},
{
'id': fake.VOLUME4_ID,
'host': 'devstack',
'project_id': fake.PROJECT_ID,
'created_at': datetime.datetime(1, 3, 10, 1, 1, 1),
},
{
'id': fake.VOLUME5_ID,
'host': 'devstack',
'project_id': fake.PROJECT_ID,
'created_at': datetime.datetime(1, 5, 1, 1, 1, 1),
}
]
self.db_snap_attrs = [
{
'id': fake.SNAPSHOT_ID,
'project_id': 'p1',
'created_at': datetime.datetime(1, 1, 1, 1, 1, 1),
'deleted': True,
'status': fields.SnapshotStatus.DELETED,
'deleted_at': datetime.datetime(1, 2, 1, 1, 1, 1),
'volume_id': fake.VOLUME_ID,
},
{
'id': fake.SNAPSHOT2_ID,
'project_id': 'p1',
'created_at': datetime.datetime(1, 1, 1, 1, 1, 1),
'deleted': True,
'status': fields.SnapshotStatus.DELETED,
'deleted_at': datetime.datetime(1, 3, 10, 1, 1, 1),
'volume_id': fake.VOLUME_ID,
},
{
'id': fake.SNAPSHOT3_ID,
'project_id': 'p1',
'created_at': datetime.datetime(1, 1, 1, 1, 1, 1),
'deleted': True,
'status': fields.SnapshotStatus.DELETED,
'deleted_at': datetime.datetime(1, 5, 1, 1, 1, 1),
'volume_id': fake.VOLUME_ID,
},
{
'id': fake.SNAPSHOT_ID,
'project_id': 'p1',
'created_at': datetime.datetime(1, 3, 10, 1, 1, 1),
'volume_id': fake.VOLUME_ID,
},
{
'id': fake.SNAPSHOT2_ID,
'project_id': 'p1',
'created_at': datetime.datetime(1, 5, 1, 1, 1, 1),
'volume_id': fake.VOLUME_ID
}
]
self.db_back_attrs = [
{
'id': fake.BACKUP_ID,
'host': 'devstack',
'project_id': fake.PROJECT_ID,
'created_at': datetime.datetime(1, 1, 1, 1, 1, 1),
'deleted': 1,
'status': 'deleted',
'deleted_at': datetime.datetime(1, 2, 1, 1, 1, 1)
},
{
'id': fake.BACKUP2_ID,
'host': 'devstack',
'project_id': fake.PROJECT_ID,
'created_at': datetime.datetime(1, 1, 1, 1, 1, 1),
'deleted': 1,
'status': 'deleted',
'deleted_at': datetime.datetime(1, 3, 10, 1, 1, 1)
},
{
'id': fake.BACKUP3_ID,
'host': 'devstack',
'project_id': fake.PROJECT_ID,
'created_at': datetime.datetime(1, 1, 1, 1, 1, 1),
'deleted': 1,
'status': 'deleted',
'deleted_at': datetime.datetime(1, 5, 1, 1, 1, 1)
},
{
'id': fake.BACKUP4_ID,
'host': 'devstack',
'project_id': fake.PROJECT_ID,
'created_at': datetime.datetime(1, 3, 10, 1, 1, 1),
},
{
'id': fake.BACKUP5_ID,
'host': 'devstack',
'project_id': fake.PROJECT_ID,
'created_at': datetime.datetime(1, 5, 1, 1, 1, 1),
},
]
def test_volume_get_all_active_by_window(self):
# Find all all volumes valid within a timeframe window.
# Not in window
db.volume_create(self.ctx, self.db_vol_attrs[0])
# In - deleted in window
db.volume_create(self.ctx, self.db_vol_attrs[1])
# In - deleted after window
db.volume_create(self.ctx, self.db_vol_attrs[2])
# In - created in window
db.volume_create(self.context, self.db_vol_attrs[3])
# Not of window.
db.volume_create(self.context, self.db_vol_attrs[4])
volumes = db.volume_get_all_active_by_window(
self.context,
datetime.datetime(1, 3, 1, 1, 1, 1),
datetime.datetime(1, 4, 1, 1, 1, 1),
project_id=fake.PROJECT_ID)
self.assertEqual(3, len(volumes))
self.assertEqual(fake.VOLUME2_ID, volumes[0].id)
self.assertEqual(fake.VOLUME3_ID, volumes[1].id)
self.assertEqual(fake.VOLUME4_ID, volumes[2].id)
def test_snapshot_get_all_active_by_window(self):
# Find all all snapshots valid within a timeframe window.
db.volume_create(self.context, {'id': fake.VOLUME_ID})
for i in range(5):
self.db_vol_attrs[i]['volume_id'] = fake.VOLUME_ID
# Not in window
del self.db_snap_attrs[0]['id']
snap1 = objects.Snapshot(self.ctx, **self.db_snap_attrs[0])
snap1.create()
# In - deleted in window
del self.db_snap_attrs[1]['id']
snap2 = objects.Snapshot(self.ctx, **self.db_snap_attrs[1])
snap2.create()
# In - deleted after window
del self.db_snap_attrs[2]['id']
snap3 = objects.Snapshot(self.ctx, **self.db_snap_attrs[2])
snap3.create()
# In - created in window
del self.db_snap_attrs[3]['id']
snap4 = objects.Snapshot(self.ctx, **self.db_snap_attrs[3])
snap4.create()
# Not of window.
del self.db_snap_attrs[4]['id']
snap5 = objects.Snapshot(self.ctx, **self.db_snap_attrs[4])
snap5.create()
snapshots = objects.SnapshotList.get_all_active_by_window(
self.context,
datetime.datetime(1, 3, 1, 1, 1, 1),
datetime.datetime(1, 4, 1, 1, 1, 1)).objects
self.assertEqual(3, len(snapshots))
self.assertEqual(snap2.id, snapshots[0].id)
self.assertEqual(fake.VOLUME_ID, snapshots[0].volume_id)
self.assertEqual(snap3.id, snapshots[1].id)
self.assertEqual(fake.VOLUME_ID, snapshots[1].volume_id)
self.assertEqual(snap4.id, snapshots[2].id)
self.assertEqual(fake.VOLUME_ID, snapshots[2].volume_id)
def test_backup_get_all_active_by_window(self):
# Find all backups valid within a timeframe window.
db.volume_create(self.context, {'id': fake.VOLUME_ID})
for i in range(5):
self.db_back_attrs[i]['volume_id'] = fake.VOLUME_ID
# Not in window
db.backup_create(self.ctx, self.db_back_attrs[0])
# In - deleted in window
db.backup_create(self.ctx, self.db_back_attrs[1])
# In - deleted after window
db.backup_create(self.ctx, self.db_back_attrs[2])
# In - created in window
db.backup_create(self.ctx, self.db_back_attrs[3])
# Not of window
db.backup_create(self.ctx, self.db_back_attrs[4])
backups = db.backup_get_all_active_by_window(
self.context,
datetime.datetime(1, 3, 1, 1, 1, 1),
datetime.datetime(1, 4, 1, 1, 1, 1),
project_id=fake.PROJECT_ID
)
self.assertEqual(3, len(backups))
self.assertEqual(fake.BACKUP2_ID, backups[0].id)
self.assertEqual(fake.BACKUP3_ID, backups[1].id)
self.assertEqual(fake.BACKUP4_ID, backups[2].id)
class DriverTestCase(test.TestCase):
"""Base Test class for Drivers."""
driver_name = "cinder.volume.driver.FakeBaseDriver"
def setUp(self):
super(DriverTestCase, self).setUp()
vol_tmpdir = tempfile.mkdtemp()
self.flags(volume_driver=self.driver_name,
volumes_dir=vol_tmpdir)
self.volume = importutils.import_object(CONF.volume_manager)
self.context = context.get_admin_context()
self.output = ""
self.configuration = conf.Configuration(None)
self.mock_object(brick_lvm.LVM, '_vg_exists', lambda x: True)
def _fake_execute(_command, *_args, **_kwargs):
"""Fake _execute."""
return self.output, None
exec_patcher = mock.patch.object(self.volume.driver, '_execute',
_fake_execute)
exec_patcher.start()
self.addCleanup(exec_patcher.stop)
self.volume.driver.set_initialized()
self.addCleanup(self._cleanup)
def _cleanup(self):
try:
shutil.rmtree(CONF.volumes_dir)
except OSError:
pass
def _attach_volume(self):
"""Attach volumes to an instance."""
return []
@ddt.ddt
class GenericVolumeDriverTestCase(DriverTestCase):
"""Test case for VolumeDriver."""
driver_name = "cinder.tests.fake_driver.FakeLoggingVolumeDriver"
@mock.patch.object(utils, 'temporary_chown')
@mock.patch('six.moves.builtins.open')
@mock.patch.object(os_brick.initiator.connector,
'get_connector_properties')
@mock.patch.object(db.sqlalchemy.api, 'volume_get')
def test_backup_volume_available(self, mock_volume_get,
mock_get_connector_properties,
mock_file_open,
mock_temporary_chown):
vol = tests_utils.create_volume(self.context)
self.context.user_id = fake.USER_ID
self.context.project_id = fake.PROJECT_ID
backup_obj = tests_utils.create_backup(self.context,
vol['id'])
properties = {}
attach_info = {'device': {'path': '/dev/null'}}
backup_service = mock.Mock()
self.volume.driver._attach_volume = mock.MagicMock()
self.volume.driver._detach_volume = mock.MagicMock()
self.volume.driver.terminate_connection = mock.MagicMock()
self.volume.driver.create_snapshot = mock.MagicMock()
self.volume.driver.delete_snapshot = mock.MagicMock()
mock_volume_get.return_value = vol
mock_get_connector_properties.return_value = properties
f = mock_file_open.return_value = open('/dev/null', 'rb')
backup_service.backup(backup_obj, f, None)
self.volume.driver._attach_volume.return_value = attach_info, vol
self.volume.driver.backup_volume(self.context, backup_obj,
backup_service)
mock_volume_get.assert_called_with(self.context, vol['id'])
def test_create_temp_cloned_volume(self):
with mock.patch.object(
self.volume.driver,
'create_cloned_volume') as mock_create_cloned_volume:
model_update = {'provider_location': 'dummy'}
mock_create_cloned_volume.return_value = model_update
vol = tests_utils.create_volume(self.context,
status='backing-up')
cloned_vol = self.volume.driver._create_temp_cloned_volume(
self.context, vol)
self.assertEqual('dummy', cloned_vol.provider_location)
self.assertEqual('available', cloned_vol.status)
mock_create_cloned_volume.return_value = None
vol = tests_utils.create_volume(self.context,
status='backing-up')
cloned_vol = self.volume.driver._create_temp_cloned_volume(
self.context, vol)
self.assertEqual('available', cloned_vol.status)
@mock.patch.object(utils, 'temporary_chown')
@mock.patch('six.moves.builtins.open')
@mock.patch.object(os_brick.initiator.connector,
'get_connector_properties')
@mock.patch.object(db.sqlalchemy.api, 'volume_get')
def test_backup_volume_inuse_temp_volume(self, mock_volume_get,
mock_get_connector_properties,
mock_file_open,
mock_temporary_chown):
vol = tests_utils.create_volume(self.context,
status='backing-up',
previous_status='in-use')
temp_vol = tests_utils.create_volume(self.context)
self.context.user_id = fake.USER_ID
self.context.project_id = fake.PROJECT_ID
backup_obj = tests_utils.create_backup(self.context,
vol['id'])
properties = {}
attach_info = {'device': {'path': '/dev/null'}}
backup_service = mock.Mock()
self.volume.driver._attach_volume = mock.MagicMock()
self.volume.driver._detach_volume = mock.MagicMock()
self.volume.driver.terminate_connection = mock.MagicMock()
self.volume.driver._create_temp_snapshot = mock.MagicMock()
self.volume.driver._delete_temp_snapshot = mock.MagicMock()
mock_volume_get.return_value = vol
self.volume.driver._create_temp_snapshot.return_value = temp_vol
mock_get_connector_properties.return_value = properties
f = mock_file_open.return_value = open('/dev/null', 'rb')
backup_service.backup(backup_obj, f, None)
self.volume.driver._attach_volume.return_value = attach_info, vol
self.volume.driver.backup_volume(self.context, backup_obj,
backup_service)
mock_volume_get.assert_called_with(self.context, vol['id'])
self.volume.driver._create_temp_snapshot.assert_called_once_with(
self.context, vol)
self.volume.driver._delete_temp_snapshot.assert_called_once_with(
self.context, temp_vol)
@mock.patch.object(utils, 'temporary_chown')
@mock.patch.object(os_brick.initiator.connector,
'get_connector_properties')
@mock.patch('six.moves.builtins.open')
def test_restore_backup(self,
mock_open,
mock_get_connector_properties,
mock_temporary_chown):
dev_null = '/dev/null'
vol = tests_utils.create_volume(self.context)
backup = {'volume_id': vol['id'], 'id': 'backup-for-%s' % vol['id']}
properties = {}
attach_info = {'device': {'path': dev_null}}
volume_file = mock.MagicMock()
mock_open.return_value.__enter__.return_value = volume_file
mock_get_connector_properties.return_value = properties
self.volume.driver._attach_volume = mock.MagicMock()
self.volume.driver._attach_volume.return_value = attach_info, vol
self.volume.driver._detach_volume = mock.MagicMock()
self.volume.driver.terminate_connection = mock.MagicMock()
self.volume.driver.secure_file_operations_enabled = mock.MagicMock()
self.volume.driver.secure_file_operations_enabled.side_effect = (False,
True)
backup_service = mock.MagicMock()
self.volume.driver.restore_backup(self.context, backup, vol,
backup_service)
backup_service.restore.assert_called_with(backup, vol['id'],
volume_file)
self.assertEqual(1, backup_service.restore.call_count)
def test_get_backup_device_available(self):
vol = tests_utils.create_volume(self.context)
self.context.user_id = fake.USER_ID
self.context.project_id = fake.PROJECT_ID
backup_obj = tests_utils.create_backup(self.context,
vol['id'])
(backup_device, is_snapshot) = self.volume.driver.get_backup_device(
self.context, backup_obj)
volume = objects.Volume.get_by_id(self.context, vol.id)
self.assertEqual(volume, backup_device)
self.assertFalse(is_snapshot)
backup_obj.refresh()
self.assertIsNone(backup_obj.temp_volume_id)
def test_get_backup_device_in_use(self):
vol = tests_utils.create_volume(self.context,
status='backing-up',
previous_status='in-use')
temp_vol = tests_utils.create_volume(self.context)
self.context.user_id = fake.USER_ID
self.context.project_id = fake.PROJECT_ID
backup_obj = tests_utils.create_backup(self.context,
vol['id'])
with mock.patch.object(
self.volume.driver,
'_create_temp_cloned_volume') as mock_create_temp:
mock_create_temp.return_value = temp_vol
(backup_device, is_snapshot) = (
self.volume.driver.get_backup_device(self.context,
backup_obj))
self.assertEqual(temp_vol, backup_device)
self.assertFalse(is_snapshot)
backup_obj.refresh()
self.assertEqual(temp_vol.id, backup_obj.temp_volume_id)
def test__create_temp_volume_from_snapshot(self):
volume_dict = {'id': fake.SNAPSHOT_ID,
'host': 'fakehost',
'cluster_name': 'fakecluster',
'availability_zone': 'fakezone',
'size': 1}
vol = fake_volume.fake_volume_obj(self.context, **volume_dict)
snapshot = fake_snapshot.fake_snapshot_obj(self.context)
with mock.patch.object(
self.volume.driver,
'create_volume_from_snapshot'):
temp_vol = self.volume.driver._create_temp_volume_from_snapshot(
self.context,
vol, snapshot)
self.assertEqual(fields.VolumeAttachStatus.DETACHED,
temp_vol.attach_status)
self.assertEqual('fakezone', temp_vol.availability_zone)
self.assertEqual('fakecluster', temp_vol.cluster_name)
@mock.patch.object(utils, 'brick_get_connector_properties')
@mock.patch.object(cinder.volume.manager.VolumeManager, '_attach_volume')
@mock.patch.object(cinder.volume.manager.VolumeManager, '_detach_volume')
@mock.patch.object(volutils, 'copy_volume')
@mock.patch.object(volume_rpcapi.VolumeAPI, 'get_capabilities')
@mock.patch.object(cinder.volume.volume_types,
'volume_types_encryption_changed')
@ddt.data(False, True)
def test_copy_volume_data_mgr(self,
encryption_changed,
mock_encryption_changed,
mock_get_capabilities,
mock_copy,
mock_detach,
mock_attach,
mock_get_connector):
"""Test function of _copy_volume_data."""
src_vol = tests_utils.create_volume(self.context, size=1,
host=CONF.host)
dest_vol = tests_utils.create_volume(self.context, size=1,
host=CONF.host)
mock_get_connector.return_value = {}
mock_encryption_changed.return_value = encryption_changed
self.volume.driver._throttle = mock.MagicMock()
attach_expected = [
mock.call(self.context, dest_vol, {},
remote=False,
attach_encryptor=encryption_changed),
mock.call(self.context, src_vol, {},
remote=False,
attach_encryptor=encryption_changed)]
detach_expected = [
mock.call(self.context, {'device': {'path': 'bar'}},
dest_vol, {}, force=False, remote=False,
attach_encryptor=encryption_changed),
mock.call(self.context, {'device': {'path': 'foo'}},
src_vol, {}, force=False, remote=False,
attach_encryptor=encryption_changed)]
attach_volume_returns = [
{'device': {'path': 'bar'}},
{'device': {'path': 'foo'}}
]
# Test case for sparse_copy_volume = False
mock_attach.side_effect = attach_volume_returns
mock_get_capabilities.return_value = {}
self.volume._copy_volume_data(self.context,
src_vol,
dest_vol)
self.assertEqual(attach_expected, mock_attach.mock_calls)
mock_copy.assert_called_with('foo', 'bar', 1024, '1M', sparse=False)
self.assertEqual(detach_expected, mock_detach.mock_calls)
# Test case for sparse_copy_volume = True
mock_attach.reset_mock()
mock_detach.reset_mock()
mock_attach.side_effect = attach_volume_returns
mock_get_capabilities.return_value = {'sparse_copy_volume': True}
self.volume._copy_volume_data(self.context,
src_vol,
dest_vol)
self.assertEqual(attach_expected, mock_attach.mock_calls)
mock_copy.assert_called_with('foo', 'bar', 1024, '1M', sparse=True)
self.assertEqual(detach_expected, mock_detach.mock_calls)
# cleanup resource
db.volume_destroy(self.context, src_vol['id'])
db.volume_destroy(self.context, dest_vol['id'])
@mock.patch.object(os_brick.initiator.connector,
'get_connector_properties')
@mock.patch.object(image_utils, 'fetch_to_raw')
@mock.patch.object(cinder.volume.driver.VolumeDriver, '_attach_volume')
@mock.patch.object(cinder.volume.driver.VolumeDriver, '_detach_volume')
@mock.patch.object(cinder.utils, 'brick_attach_volume_encryptor')
@mock.patch.object(cinder.utils, 'brick_detach_volume_encryptor')
def test_copy_image_to_encrypted_volume(self,
mock_detach_encryptor,
mock_attach_encryptor,
mock_detach_volume,
mock_attach_volume,
mock_fetch_to_raw,
mock_get_connector_properties):
properties = {}
volume = tests_utils.create_volume(
self.context, status='available',
size=2,
encryption_key_id=fake.ENCRYPTION_KEY_ID)
volume_id = volume['id']
volume = db.volume_get(context.get_admin_context(), volume_id)
image_service = fake_image.FakeImageService()
local_path = 'dev/sda'
attach_info = {'device': {'path': local_path},
'conn': {'driver_volume_type': 'iscsi',
'data': {}, }}
mock_get_connector_properties.return_value = properties
mock_attach_volume.return_value = [attach_info, volume]
self.volume.driver.copy_image_to_encrypted_volume(
self.context, volume, image_service, fake.IMAGE_ID)
encryption = {'encryption_key_id': fake.ENCRYPTION_KEY_ID}
mock_attach_volume.assert_called_once_with(
self.context, volume, properties)
mock_attach_encryptor.assert_called_once_with(
self.context, attach_info, encryption)
mock_fetch_to_raw.assert_called_once_with(
self.context, image_service, fake.IMAGE_ID,
local_path, '1M', size=2)
mock_detach_encryptor.assert_called_once_with(
attach_info, encryption)
mock_detach_volume.assert_called_once_with(
self.context, attach_info, volume, properties)
@mock.patch.object(os_brick.initiator.connector,
'get_connector_properties')
@mock.patch.object(image_utils, 'fetch_to_raw')
@mock.patch.object(cinder.volume.driver.VolumeDriver, '_attach_volume')
@mock.patch.object(cinder.volume.driver.VolumeDriver, '_detach_volume')
@mock.patch.object(cinder.utils, 'brick_attach_volume_encryptor')
@mock.patch.object(cinder.utils, 'brick_detach_volume_encryptor')
def test_copy_image_to_encrypted_volume_failed_attach_encryptor(
self,
mock_detach_encryptor,
mock_attach_encryptor,
mock_detach_volume,
mock_attach_volume,
mock_fetch_to_raw,
mock_get_connector_properties):
properties = {}
volume = tests_utils.create_volume(
self.context, status='available',
size=2,
encryption_key_id=fake.ENCRYPTION_KEY_ID)
volume_id = volume['id']
volume = db.volume_get(context.get_admin_context(), volume_id)
image_service = fake_image.FakeImageService()
attach_info = {'device': {'path': 'dev/sda'},
'conn': {'driver_volume_type': 'iscsi',
'data': {}, }}
mock_get_connector_properties.return_value = properties
mock_attach_volume.return_value = [attach_info, volume]
raised_exception = os_brick.exception.VolumeEncryptionNotSupported(
volume_id = "123",
volume_type = "abc")
mock_attach_encryptor.side_effect = raised_exception
self.assertRaises(os_brick.exception.VolumeEncryptionNotSupported,
self.volume.driver.copy_image_to_encrypted_volume,
self.context, volume, image_service, fake.IMAGE_ID)
encryption = {'encryption_key_id': fake.ENCRYPTION_KEY_ID}
mock_attach_volume.assert_called_once_with(
self.context, volume, properties)
mock_attach_encryptor.assert_called_once_with(
self.context, attach_info, encryption)
self.assertFalse(mock_fetch_to_raw.called)
self.assertFalse(mock_detach_encryptor.called)
mock_detach_volume.assert_called_once_with(
self.context, attach_info, volume, properties)
@mock.patch.object(os_brick.initiator.connector,
'get_connector_properties')
@mock.patch.object(image_utils, 'fetch_to_raw')
@mock.patch.object(cinder.volume.driver.VolumeDriver, '_attach_volume')
@mock.patch.object(cinder.volume.driver.VolumeDriver, '_detach_volume')
@mock.patch.object(cinder.utils, 'brick_attach_volume_encryptor')
@mock.patch.object(cinder.utils, 'brick_detach_volume_encryptor')
def test_copy_image_to_encrypted_volume_failed_fetch(
self,
mock_detach_encryptor, mock_attach_encryptor,
mock_detach_volume, mock_attach_volume, mock_fetch_to_raw,
mock_get_connector_properties):
properties = {}
volume = tests_utils.create_volume(
self.context, status='available',
size=2,
encryption_key_id=fake.ENCRYPTION_KEY_ID)
volume_id = volume['id']
volume = db.volume_get(context.get_admin_context(), volume_id)
image_service = fake_image.FakeImageService()
local_path = 'dev/sda'
attach_info = {'device': {'path': local_path},
'conn': {'driver_volume_type': 'iscsi',
'data': {}, }}
mock_get_connector_properties.return_value = properties
mock_attach_volume.return_value = [attach_info, volume]
raised_exception = exception.ImageUnacceptable(reason='fake',
image_id=fake.IMAGE_ID)
mock_fetch_to_raw.side_effect = raised_exception
encryption = {'encryption_key_id': fake.ENCRYPTION_KEY_ID}
self.assertRaises(exception.ImageUnacceptable,
self.volume.driver.copy_image_to_encrypted_volume,
self.context, volume, image_service, fake.IMAGE_ID)
mock_attach_volume.assert_called_once_with(
self.context, volume, properties)
mock_attach_encryptor.assert_called_once_with(
self.context, attach_info, encryption)
mock_fetch_to_raw.assert_called_once_with(
self.context, image_service, fake.IMAGE_ID,
local_path, '1M', size=2)
mock_detach_encryptor.assert_called_once_with(
attach_info, encryption)
mock_detach_volume.assert_called_once_with(
self.context, attach_info, volume, properties)
class FibreChannelTestCase(DriverTestCase):
"""Test Case for FibreChannelDriver."""
driver_name = "cinder.volume.driver.FibreChannelDriver"
def test_initialize_connection(self):
self.assertRaises(NotImplementedError,
self.volume.driver.initialize_connection, {}, {})
def test_validate_connector(self):
"""validate_connector() successful use case.
validate_connector() does not throw an exception when
wwpns and wwnns are both set and both are not empty.
"""
connector = {'wwpns': ["not empty"],
'wwnns': ["not empty"]}
self.volume.driver.validate_connector(connector)
def test_validate_connector_no_wwpns(self):
"""validate_connector() throws exception when it has no wwpns."""
connector = {'wwnns': ["not empty"]}
self.assertRaises(exception.InvalidConnectorException,
self.volume.driver.validate_connector, connector)
def test_validate_connector_empty_wwpns(self):
"""validate_connector() throws exception when it has empty wwpns."""
connector = {'wwpns': [],
'wwnns': ["not empty"]}
self.assertRaises(exception.InvalidConnectorException,
self.volume.driver.validate_connector, connector)
def test_validate_connector_no_wwnns(self):
"""validate_connector() throws exception when it has no wwnns."""
connector = {'wwpns': ["not empty"]}
self.assertRaises(exception.InvalidConnectorException,
self.volume.driver.validate_connector, connector)
def test_validate_connector_empty_wwnns(self):
"""validate_connector() throws exception when it has empty wwnns."""
connector = {'wwnns': [],
'wwpns': ["not empty"]}
self.assertRaises(exception.InvalidConnectorException,
self.volume.driver.validate_connector, connector)
class VolumePolicyTestCase(test.TestCase):
def setUp(self):
super(VolumePolicyTestCase, self).setUp()
cinder.policy.init()
self.context = context.get_admin_context()
def test_check_policy(self):
target = {
'project_id': self.context.project_id,
'user_id': self.context.user_id,
}
with mock.patch.object(cinder.policy, 'enforce') as mock_enforce:
cinder.volume.api.check_policy(self.context, 'attach')
mock_enforce.assert_called_once_with(self.context,
'volume:attach',
target)
def test_check_policy_with_target(self):
target = {
'project_id': self.context.project_id,
'user_id': self.context.user_id,
'id': 2,
}
with mock.patch.object(cinder.policy, 'enforce') as mock_enforce:
cinder.volume.api.check_policy(self.context, 'attach', {'id': 2})
mock_enforce.assert_called_once_with(self.context,
'volume:attach',
target)
class ImageVolumeCacheTestCase(base.BaseVolumeTestCase):
def setUp(self):
super(ImageVolumeCacheTestCase, self).setUp()
self.volume.driver.set_initialized()
@mock.patch('oslo_utils.importutils.import_object')
def test_cache_configs(self, mock_import_object):
opts = {
'image_volume_cache_enabled': True,
'image_volume_cache_max_size_gb': 100,
'image_volume_cache_max_count': 20
}
def conf_get(option):
if option in opts:
return opts[option]
else:
return None
mock_driver = mock.Mock()
mock_driver.configuration.safe_get.side_effect = conf_get
mock_driver.configuration.extra_capabilities = 'null'
def import_obj(*args, **kwargs):
return mock_driver
mock_import_object.side_effect = import_obj
manager = vol_manager.VolumeManager(volume_driver=mock_driver)
self.assertIsNotNone(manager)
self.assertIsNotNone(manager.image_volume_cache)
self.assertEqual(100, manager.image_volume_cache.max_cache_size_gb)
self.assertEqual(20, manager.image_volume_cache.max_cache_size_count)
def test_delete_image_volume(self):
volume_params = {
'status': 'creating',
'host': 'some_host',
'cluster_name': 'some_cluster',
'size': 1
}
volume_api = cinder.volume.api.API()
volume = tests_utils.create_volume(self.context, **volume_params)
volume.status = 'available'
volume.save()
image_id = '70a599e0-31e7-49b7-b260-868f441e862b'
db.image_volume_cache_create(self.context,
volume['host'],
volume_params['cluster_name'],
image_id,
datetime.datetime.utcnow(),
volume['id'],
volume['size'])
volume_api.delete(self.context, volume)
entry = db.image_volume_cache_get_by_volume_id(self.context,
volume['id'])
self.assertIsNone(entry)
def test_delete_volume_with_keymanager_exception(self):
volume_params = {
'host': 'some_host',
'size': 1
}
volume_api = cinder.volume.api.API()
volume = tests_utils.create_volume(self.context, **volume_params)
with mock.patch.object(
volume_api.key_manager, 'delete') as key_del_mock:
key_del_mock.side_effect = Exception("Key not found")
volume_api.delete(self.context, volume)
@ddt.ddt
class DiscardFlagTestCase(base.BaseVolumeTestCase):
def setUp(self):
super(DiscardFlagTestCase, self).setUp()
self.volume.driver = mock.MagicMock()
@ddt.data(dict(config_discard_flag=True,
driver_discard_flag=None,
expected_flag=True),
dict(config_discard_flag=False,
driver_discard_flag=None,
expected_flag=None),
dict(config_discard_flag=True,
driver_discard_flag=True,
expected_flag=True),
dict(config_discard_flag=False,
driver_discard_flag=True,
expected_flag=True),
dict(config_discard_flag=False,
driver_discard_flag=False,
expected_flag=False),
dict(config_discard_flag=None,
driver_discard_flag=True,
expected_flag=True),
dict(config_discard_flag=None,
driver_discard_flag=False,
expected_flag=False))
@ddt.unpack
def test_initialize_connection_discard_flag(self,
config_discard_flag,
driver_discard_flag,
expected_flag):
self.volume.driver.create_export.return_value = None
connector = {'ip': 'IP', 'initiator': 'INITIATOR'}
conn_info = {
'driver_volume_type': 'iscsi',
'data': {'access_mode': 'rw',
'encrypted': False}
}
if driver_discard_flag is not None:
conn_info['data']['discard'] = driver_discard_flag
self.volume.driver.initialize_connection.return_value = conn_info
def _safe_get(key):
if key is 'report_discard_supported':
return config_discard_flag
else:
return None
self.volume.driver.configuration.safe_get.side_effect = _safe_get
with mock.patch.object(objects, 'Volume') as mock_vol:
volume = tests_utils.create_volume(self.context)
volume.volume_type_id = None
mock_vol.get_by_id.return_value = volume
conn_info = self.volume.initialize_connection(self.context,
volume,
connector)
self.assertEqual(expected_flag, conn_info['data'].get('discard'))
|
apache-2.0
|
[
3,
1898,
7129,
1910,
5703,
24230,
598,
27639,
465,
11159,
701,
314,
199,
3,
30660,
402,
314,
20548,
437,
281,
265,
3844,
7769,
436,
19326,
9516,
4633,
14,
199,
3,
2900,
5924,
5702,
14,
199,
3,
199,
3,
259,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
1265,
1443,
199,
3,
259,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
2047,
1443,
3332,
199,
3,
259,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
260,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
259,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
259,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
2428,
199,
3,
259,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
1666,
314,
199,
3,
259,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
259,
1334,
314,
844,
14,
199,
624,
2925,
367,
15018,
5495,
1041,
199,
199,
646,
2197,
199,
646,
366,
3583,
199,
646,
747,
199,
646,
5145,
199,
646,
984,
199,
646,
5549,
199,
646,
900,
199,
646,
5377,
199,
199,
646,
4952,
199,
646,
21819,
199,
646,
1683,
199,
646,
747,
63,
29541,
199,
504,
11258,
63,
27518,
492,
2112,
1208,
199,
504,
11258,
63,
888,
492,
4810,
199,
504,
11258,
63,
12161,
492,
18705,
199,
504,
11258,
63,
1208,
492,
1834,
1208,
199,
504,
11258,
63,
1208,
492,
492,
1208,
199,
504,
11258,
63,
1208,
492,
23011,
199,
504,
11258,
63,
1208,
492,
6204,
199,
646,
3816,
199,
504,
2120,
1659,
14,
30378,
14,
1287,
63,
3908,
492,
6869,
199,
199,
504,
13069,
14,
1246,
492,
2863,
199,
504,
13069,
14,
29541,
14,
1832,
63,
2374,
492,
634,
2611,
465,
20611,
346,
63,
31283,
199,
504,
13069,
14,
2330,
492,
5262,
199,
504,
13069,
492,
1067,
199,
504,
13069,
492,
11021,
3155,
199,
504,
13069,
492,
1592,
199,
504,
13069,
492,
1919,
199,
504,
13069,
14,
1569,
492,
1834,
63,
1208,
199,
504,
13069,
492,
790,
7755,
465,
790,
63,
2609,
199,
504,
13069,
14,
1188,
492,
3247,
63,
3431,
199,
504,
13069,
14,
1188,
492,
2073,
63,
1313,
199,
504,
13069,
492,
2251,
199,
504,
13069,
14,
1462,
492,
1504,
199,
646,
13069,
14,
3185,
199,
504,
13069,
492,
12132,
199,
504,
13069,
492,
511,
199,
504,
13069,
14,
2219,
492,
4026,
63,
3090,
199,
504,
13069,
14,
2219,
14,
3248,
14,
1246,
492,
14063,
199,
504,
13069,
14,
2219,
14,
3248,
14,
29541,
492,
4026,
63,
31283,
199,
504,
13069,
14,
2219,
14,
3248,
492,
3743,
63,
5997,
199,
504,
13069,
14,
2219,
14,
3248,
492,
4026,
63,
5559,
465,
4026,
199,
504,
13069,
14,
2219,
14,
3248,
492,
4026,
63,
1364,
199,
504,
13069,
14,
2219,
14,
3248,
492,
4026,
63,
4753,
199,
504,
13069,
14,
2219,
14,
3248,
492,
4026,
63,
2405,
199,
504,
13069,
14,
2219,
14,
3248,
14,
1569,
492,
4026,
465,
4026,
63,
1569,
199,
504,
13069,
14,
2219,
14,
3248,
14,
498,
7755,
492,
4026,
465,
4026,
63,
498,
7755,
199,
504,
13069,
14,
2219,
14,
3248,
492,
3778,
465,
2295,
63,
1208,
199,
504,
13069,
14,
2219,
14,
3248,
492,
3301,
465,
1300,
199,
504,
13069,
492,
3778,
199,
646,
13069,
14,
2405,
199,
504,
13069,
14,
2405,
492,
2986,
465,
3301,
63,
1246,
199,
504,
13069,
14,
2405,
492,
2897,
465,
3743,
199,
504,
13069,
14,
2405,
492,
5253,
199,
504,
13069,
14,
2405,
14,
22777,
14,
2609,
492,
1218,
63,
2405,
465,
1218,
63,
2405,
63,
2609,
199,
504,
13069,
14,
2405,
492,
5256,
465,
5236,
63,
2609,
199,
504,
13069,
14,
2405,
492,
8985,
1246,
465,
3301,
63,
20776,
199,
646,
13069,
14,
2405,
14,
4684,
14,
15328,
199,
504,
13069,
14,
2405,
492,
3778,
465,
5236,
1208,
199,
504,
13069,
14,
2405,
492,
3301,
63,
1313,
421,
199,
18654,
1179,
275,
12132,
14,
18654,
1179,
199,
199,
3103,
275,
4810,
14,
3103,
199,
199,
742,
19079,
1075,
63,
30600,
275,
283,
6765,
14,
2405,
14,
11929,
1384,
14,
4997,
2758,
14,
35,
13656,
2758,
1327,
4997,
269,
7,
199,
199,
3183,
63,
2992,
275,
359,
272,
4810,
14,
19340,
360,
3183,
63,
2992,
17,
297,
849,
534,
3183,
297,
1720,
534,
3183,
3999,
358,
199,
61,
421,
199,
14336,
63,
30728,
63,
18654,
33,
63,
15375,
275,
1919,
14,
5674,
17610,
8,
272,
1806,
83,
2968,
15331,
995,
272,
4503,
83,
275,
791,
15331,
356,
791,
10421,
356,
413,
12,
283,
262,
63,
1180,
356,
1749,
13459,
272,
22874,
275,
791,
71,
528,
27601,
356,
1616,
12,
283,
15331,
356,
1616,
1552,
421,
199,
318,
1218,
63,
4753,
8,
2405,
63,
344,
12,
1568,
29,
17,
12,
3341,
29,
403,
12,
11216,
29,
403,
12,
490,
1011,
958,
304,
272,
408,
2499,
282,
5740,
909,
1041,
272,
3341,
275,
3341,
503,
1052,
272,
13639,
275,
2251,
14,
12038,
8,
6725,
503,
1067,
14,
362,
63,
2113,
63,
1100,
1012,
272,
13639,
14,
2405,
63,
890,
275,
1568,
272,
13639,
14,
751,
63,
344,
275,
2074,
14,
362,
360,
751,
63,
344,
297,
4026,
14,
3791,
63,
998,
9,
272,
13639,
14,
1715,
63,
344,
275,
2074,
14,
362,
360,
1715,
63,
344,
297,
4026,
14,
10797,
63,
998,
9,
272,
13639,
14,
2405,
63,
344,
275,
3301,
63,
344,
272,
13639,
14,
1205,
275,
298,
20358,
2,
272,
340,
3341,
365,
440,
488,
26,
267,
13639,
14,
2343,
275,
3341,
272,
13639,
14,
873,
8,
958,
9,
339,
13639,
14,
981,
342,
272,
372,
13639,
421,
199,
533,
7777,
3491,
3167,
8,
785,
304,
272,
347,
636,
826,
721,
277,
12,
1592,
63,
3090,
29,
403,
12,
1834,
63,
1364,
29,
403,
304,
267,
986,
339,
347,
2498,
8,
277,
12,
1067,
12,
1834,
63,
344,
304,
267,
372,
791,
890,
356,
499,
627,
6204,
14,
30815,
12,
355,
283,
4032,
63,
908,
356,
283,
1773,
297,
355,
283,
3600,
63,
908,
356,
283,
14890,
297,
355,
283,
1205,
356,
283,
2682,
936,
421,
199,
533,
16599,
7615,
11860,
1746,
8,
1095
] |
[
1898,
7129,
1910,
5703,
24230,
598,
27639,
465,
11159,
701,
314,
199,
3,
30660,
402,
314,
20548,
437,
281,
265,
3844,
7769,
436,
19326,
9516,
4633,
14,
199,
3,
2900,
5924,
5702,
14,
199,
3,
199,
3,
259,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
1265,
1443,
199,
3,
259,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
2047,
1443,
3332,
199,
3,
259,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
260,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
259,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
259,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
2428,
199,
3,
259,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
1666,
314,
199,
3,
259,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
259,
1334,
314,
844,
14,
199,
624,
2925,
367,
15018,
5495,
1041,
199,
199,
646,
2197,
199,
646,
366,
3583,
199,
646,
747,
199,
646,
5145,
199,
646,
984,
199,
646,
5549,
199,
646,
900,
199,
646,
5377,
199,
199,
646,
4952,
199,
646,
21819,
199,
646,
1683,
199,
646,
747,
63,
29541,
199,
504,
11258,
63,
27518,
492,
2112,
1208,
199,
504,
11258,
63,
888,
492,
4810,
199,
504,
11258,
63,
12161,
492,
18705,
199,
504,
11258,
63,
1208,
492,
1834,
1208,
199,
504,
11258,
63,
1208,
492,
492,
1208,
199,
504,
11258,
63,
1208,
492,
23011,
199,
504,
11258,
63,
1208,
492,
6204,
199,
646,
3816,
199,
504,
2120,
1659,
14,
30378,
14,
1287,
63,
3908,
492,
6869,
199,
199,
504,
13069,
14,
1246,
492,
2863,
199,
504,
13069,
14,
29541,
14,
1832,
63,
2374,
492,
634,
2611,
465,
20611,
346,
63,
31283,
199,
504,
13069,
14,
2330,
492,
5262,
199,
504,
13069,
492,
1067,
199,
504,
13069,
492,
11021,
3155,
199,
504,
13069,
492,
1592,
199,
504,
13069,
492,
1919,
199,
504,
13069,
14,
1569,
492,
1834,
63,
1208,
199,
504,
13069,
492,
790,
7755,
465,
790,
63,
2609,
199,
504,
13069,
14,
1188,
492,
3247,
63,
3431,
199,
504,
13069,
14,
1188,
492,
2073,
63,
1313,
199,
504,
13069,
492,
2251,
199,
504,
13069,
14,
1462,
492,
1504,
199,
646,
13069,
14,
3185,
199,
504,
13069,
492,
12132,
199,
504,
13069,
492,
511,
199,
504,
13069,
14,
2219,
492,
4026,
63,
3090,
199,
504,
13069,
14,
2219,
14,
3248,
14,
1246,
492,
14063,
199,
504,
13069,
14,
2219,
14,
3248,
14,
29541,
492,
4026,
63,
31283,
199,
504,
13069,
14,
2219,
14,
3248,
492,
3743,
63,
5997,
199,
504,
13069,
14,
2219,
14,
3248,
492,
4026,
63,
5559,
465,
4026,
199,
504,
13069,
14,
2219,
14,
3248,
492,
4026,
63,
1364,
199,
504,
13069,
14,
2219,
14,
3248,
492,
4026,
63,
4753,
199,
504,
13069,
14,
2219,
14,
3248,
492,
4026,
63,
2405,
199,
504,
13069,
14,
2219,
14,
3248,
14,
1569,
492,
4026,
465,
4026,
63,
1569,
199,
504,
13069,
14,
2219,
14,
3248,
14,
498,
7755,
492,
4026,
465,
4026,
63,
498,
7755,
199,
504,
13069,
14,
2219,
14,
3248,
492,
3778,
465,
2295,
63,
1208,
199,
504,
13069,
14,
2219,
14,
3248,
492,
3301,
465,
1300,
199,
504,
13069,
492,
3778,
199,
646,
13069,
14,
2405,
199,
504,
13069,
14,
2405,
492,
2986,
465,
3301,
63,
1246,
199,
504,
13069,
14,
2405,
492,
2897,
465,
3743,
199,
504,
13069,
14,
2405,
492,
5253,
199,
504,
13069,
14,
2405,
14,
22777,
14,
2609,
492,
1218,
63,
2405,
465,
1218,
63,
2405,
63,
2609,
199,
504,
13069,
14,
2405,
492,
5256,
465,
5236,
63,
2609,
199,
504,
13069,
14,
2405,
492,
8985,
1246,
465,
3301,
63,
20776,
199,
646,
13069,
14,
2405,
14,
4684,
14,
15328,
199,
504,
13069,
14,
2405,
492,
3778,
465,
5236,
1208,
199,
504,
13069,
14,
2405,
492,
3301,
63,
1313,
421,
199,
18654,
1179,
275,
12132,
14,
18654,
1179,
199,
199,
3103,
275,
4810,
14,
3103,
199,
199,
742,
19079,
1075,
63,
30600,
275,
283,
6765,
14,
2405,
14,
11929,
1384,
14,
4997,
2758,
14,
35,
13656,
2758,
1327,
4997,
269,
7,
199,
199,
3183,
63,
2992,
275,
359,
272,
4810,
14,
19340,
360,
3183,
63,
2992,
17,
297,
849,
534,
3183,
297,
1720,
534,
3183,
3999,
358,
199,
61,
421,
199,
14336,
63,
30728,
63,
18654,
33,
63,
15375,
275,
1919,
14,
5674,
17610,
8,
272,
1806,
83,
2968,
15331,
995,
272,
4503,
83,
275,
791,
15331,
356,
791,
10421,
356,
413,
12,
283,
262,
63,
1180,
356,
1749,
13459,
272,
22874,
275,
791,
71,
528,
27601,
356,
1616,
12,
283,
15331,
356,
1616,
1552,
421,
199,
318,
1218,
63,
4753,
8,
2405,
63,
344,
12,
1568,
29,
17,
12,
3341,
29,
403,
12,
11216,
29,
403,
12,
490,
1011,
958,
304,
272,
408,
2499,
282,
5740,
909,
1041,
272,
3341,
275,
3341,
503,
1052,
272,
13639,
275,
2251,
14,
12038,
8,
6725,
503,
1067,
14,
362,
63,
2113,
63,
1100,
1012,
272,
13639,
14,
2405,
63,
890,
275,
1568,
272,
13639,
14,
751,
63,
344,
275,
2074,
14,
362,
360,
751,
63,
344,
297,
4026,
14,
3791,
63,
998,
9,
272,
13639,
14,
1715,
63,
344,
275,
2074,
14,
362,
360,
1715,
63,
344,
297,
4026,
14,
10797,
63,
998,
9,
272,
13639,
14,
2405,
63,
344,
275,
3301,
63,
344,
272,
13639,
14,
1205,
275,
298,
20358,
2,
272,
340,
3341,
365,
440,
488,
26,
267,
13639,
14,
2343,
275,
3341,
272,
13639,
14,
873,
8,
958,
9,
339,
13639,
14,
981,
342,
272,
372,
13639,
421,
199,
533,
7777,
3491,
3167,
8,
785,
304,
272,
347,
636,
826,
721,
277,
12,
1592,
63,
3090,
29,
403,
12,
1834,
63,
1364,
29,
403,
304,
267,
986,
339,
347,
2498,
8,
277,
12,
1067,
12,
1834,
63,
344,
304,
267,
372,
791,
890,
356,
499,
627,
6204,
14,
30815,
12,
355,
283,
4032,
63,
908,
356,
283,
1773,
297,
355,
283,
3600,
63,
908,
356,
283,
14890,
297,
355,
283,
1205,
356,
283,
2682,
936,
421,
199,
533,
16599,
7615,
11860,
1746,
8,
1095,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,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5176
|
import os, sys
import socket
import pty
import pwd
import subprocess
import exceptions
__all__ = ['r_exec', 'r_popen2', 'r_popen3']
PATH = os.environ['PATH'].split(os.path.pathsep) + ['/usr/local/radist/bin/']
def find_in_path(file, search_path=PATH):
for path in search_path:
c_file = os.path.join(path, file)
if os.path.exists(c_file):
return c_file
return None
__RUNNERS = ('PYRADIST_RUNNER', 'r2sh', 'rsh', 'ssh')
__LRUNNERS = ('PYRADIST_LRUNNER', 'bash', 'sh')
def get_runner(r_list):
if r_list[0] in os.environ:
return os.environ[r_list[0]]
for runner in r_list[1:]:
xrunner = find_in_path(runner)
if xrunner is not None:
return xrunner
raise exceptions.ImportError("can't find any RUNNER")
def is_local(host):
return socket.gethostname() == host
def is_current_user(user):
if user is None:
return True
try:
pw = pwd.getpwnam(user.lstrip('-'))
if pw.pw_uid == os.getuid() and pw.pw_gid == os.getgid():
return True
return False
except KeyError:
# where is no user with name
# XXX it's better to inform user
return True
def get_user(user=None):
if user is None:
return os.environ.get('PYRADIST_USER', None)
else:
return user
RUNNER = get_runner(__RUNNERS)
LRUNNER = get_runner(__LRUNNERS)
SUDO = find_in_path('sudo')
R_SUB2 = 32 # who matters
R_SUB3 = 64
assert os.P_WAIT not in (R_SUB2, R_SUB3)
assert os.P_NOWAIT not in (R_SUB2, R_SUB3)
def r_exec(host, cmd, flags=os.P_WAIT, stdin=None, stdout=None, stderr=None, user=None):
"""Executes cmd on host using runner.
If flags equals to os.P_WAIT, routine returns exit code of runner.
If flags equals to os.P_NOWAIT, routine returns pid of runner.
If flags equals to radist.R_SUB2, routine returns tuple
(pid, stdin, stdout). If stdin or stdout is file do not include descriptor
to tuple.
If flags equals to radist.R_SUB3, routine returns tuple
(pid, stdin, stdout, stderr) like radist.R_SUB2."""
# subprocess.Popen checks if stdin, stdout and stderr is file,
# but this behavour wasn't described, that's why i fork myself...
stds = {pty.STDIN_FILENO: stdin, pty.STDOUT_FILENO: stdout, pty.STDERR_FILENO: stderr}
xstds = {}
user = get_user(user)
for std in stds.values():
assert isinstance(std, (type(None), file)), str(type(std))
if flags in (R_SUB2, R_SUB3):
if stdin is None:
r_end, w_end = os.pipe()
xstds[pty.STDIN_FILENO] = w_end, r_end
if stdout is None:
xstds[pty.STDOUT_FILENO] = os.pipe()
if flags == R_SUB3 and stderr is None:
xstds[pty.STDERR_FILENO] = os.pipe()
pid = os.fork()
if pid == 0:
for fd in stds:
if stds[fd] is not None:
os.dup2(stds[fd].fileno(), fd)
for fd in xstds:
pout, pin = xstds[fd]
os.close(pout)
os.dup2(pin, fd)
if is_local(host):
if not is_current_user(user):
return os.execl(SUDO, 'sudo', '-u', user.lstrip('-'), LRUNNER, '-c', cmd)
else:
return os.execl(LRUNNER, LRUNNER, "-c", cmd)
else:
if user:
if user.startswith('-'):
return os.execl(RUNNER, RUNNER, host,
'sudo', '-u', user.lstrip('-'),
'sh', '-c', '"%s"' % cmd.replace('"', r'\"'))
elif '@' in user:
remote, sudo = user.split('@', 1)
return os.execl(RUNNER, RUNNER, '-l', remote, host,
'sudo', '-u', sudo,
'sh', '-c', '"%s"' % cmd.replace('"', r'\"'))
else:
return os.execl(RUNNER, RUNNER, '-l', user, host, cmd)
else:
return os.execl(RUNNER, RUNNER, host, cmd)
elif pid == -1:
# XXX change Exception to something other
raise Exception("Can't fork")
else:
if flags == os.P_NOWAIT:
return pid
elif flags == os.P_WAIT:
pid, status = os.waitpid(pid, 0)
if os.WIFSIGNALED(status):
return -os.WSTOPSIG(status)
elif os.WIFEXITED(status):
return os.WEXITSTATUS(status)
else:
# XXX change Exception to something other
raise Exception("Unknown return status %d" % status)
elif flags in (R_SUB2, R_SUB3):
result = [pid]
for fd in xstds:
pout, pin = xstds[fd]
if fd == pty.STDIN_FILENO:
mode = 'w'
else:
mode = 'r'
os.close(pin)
result.append(os.fdopen(pout, mode))
return result
def r_popen3(host, cmd, **kwargs):
"""Returns popen3 on remote host."""
return r_exec(host, cmd, flags=R_SUB3, **kwargs)[1:]
def r_popen2(host, cmd, **kwargs):
"""Returns popen2 on remote host."""
return r_exec(host, cmd, flags=R_SUB2, **kwargs)[1:]
|
bsd-2-clause
|
[
646,
747,
12,
984,
199,
646,
2838,
199,
646,
31237,
199,
646,
14374,
199,
646,
3873,
199,
646,
4967,
199,
199,
363,
452,
363,
275,
788,
82,
63,
1628,
297,
283,
82,
63,
12207,
18,
297,
283,
82,
63,
12207,
19,
418,
199,
199,
3243,
275,
747,
14,
2314,
459,
3243,
2278,
1294,
8,
736,
14,
515,
14,
17843,
9,
435,
18744,
2647,
15,
1832,
15,
345,
2686,
15,
1393,
15,
418,
199,
199,
318,
2342,
63,
262,
63,
515,
8,
493,
12,
2754,
63,
515,
29,
3243,
304,
272,
367,
931,
315,
2754,
63,
515,
26,
267,
286,
63,
493,
275,
747,
14,
515,
14,
904,
8,
515,
12,
570,
9,
267,
340,
747,
14,
515,
14,
2444,
8,
67,
63,
493,
304,
288,
372,
286,
63,
493,
272,
372,
488,
199,
199,
363,
9390,
46,
3960,
275,
661,
48,
3763,
1554,
6225,
63,
9390,
15215,
297,
283,
82,
18,
609,
297,
283,
82,
609,
297,
283,
5510,
358,
199,
363,
44,
9390,
46,
3960,
275,
661,
48,
3763,
1554,
6225,
63,
44,
9390,
15215,
297,
283,
16408,
297,
283,
609,
358,
199,
199,
318,
664,
63,
5933,
8,
82,
63,
513,
304,
272,
340,
519,
63,
513,
59,
16,
61,
315,
747,
14,
2314,
26,
267,
372,
747,
14,
2314,
59,
82,
63,
513,
59,
16,
2677,
272,
367,
7876,
315,
519,
63,
513,
59,
17,
10688,
267,
671,
5933,
275,
2342,
63,
262,
63,
515,
8,
5933,
9,
267,
340,
671,
5933,
365,
440,
488,
26,
288,
372,
671,
5933,
339,
746,
4967,
14,
17825,
480,
2425,
1133,
2342,
1263,
21277,
15215,
531,
199,
199,
318,
365,
63,
1832,
8,
1102,
304,
272,
372,
2838,
14,
29789,
342,
508,
1591,
199,
199,
318,
365,
63,
1818,
63,
751,
8,
751,
304,
272,
340,
922,
365,
488,
26,
267,
372,
715,
272,
862,
26,
267,
19206,
275,
14374,
14,
362,
80,
3501,
455,
8,
751,
14,
10124,
3654,
1333,
267,
340,
19206,
14,
8796,
63,
1535,
508,
747,
14,
362,
1535,
342,
436,
19206,
14,
8796,
63,
8787,
508,
747,
14,
362,
8787,
837,
288,
372,
715,
267,
372,
756,
272,
871,
4067,
26,
267,
327,
2382,
365,
949,
922,
543,
536,
267,
327,
5787,
652,
1159,
8034,
370,
315,
964,
922,
267,
372,
715,
199,
199,
318,
664,
63,
751,
8,
751,
29,
403,
304,
272,
340,
922,
365,
488,
26,
267,
372,
747,
14,
2314,
14,
362,
360,
48,
3763,
1554,
6225,
63,
3791,
297,
488,
9,
272,
587,
26,
267,
372,
922,
199,
199,
9390,
15215,
275,
664,
63,
5933,
3460,
9390,
46,
3960,
9,
199,
44,
9390,
15215,
275,
664,
63,
5933,
3460,
44,
9390,
46,
3960,
9,
199,
6195,
1649,
275,
2342,
63,
262,
63,
515,
360,
12095,
358,
199,
50,
63,
6348,
18,
275,
4337,
327,
3963,
2530,
878,
199,
50,
63,
6348,
19,
275,
5049,
199,
199,
479,
747,
14,
48,
63,
12458,
440,
315,
334,
50,
63,
6348,
18,
12,
820,
63,
6348,
19,
9,
199,
479,
747,
14,
48,
63,
2826,
12458,
440,
315,
334,
50,
63,
6348,
18,
12,
820,
63,
6348,
19,
9,
199,
199,
318,
519,
63,
1628,
8,
1102,
12,
2088,
12,
3285,
29,
736,
14,
48,
63,
12458,
12,
9009,
29,
403,
12,
3839,
29,
403,
12,
4635,
29,
403,
12,
922,
29,
403,
304,
272,
408,
4858,
3862,
2088,
641,
1591,
1808,
7876,
14,
339,
982,
3285,
18527,
370,
747,
14,
48,
63,
12458,
12,
12981,
2529,
4458,
1233,
402,
7876,
14,
339,
982,
3285,
18527,
370,
747,
14,
48,
63,
2826,
12458,
12,
12981,
2529,
4422,
402,
7876,
14,
339,
982,
3285,
18527,
370,
660,
2686,
14,
50,
63,
6348,
18,
12,
12981,
2529,
2008,
272,
334,
3150,
12,
9009,
12,
3839,
680,
982,
9009,
503,
3839,
365,
570,
886,
440,
2387,
5872,
272,
370,
2008,
14,
339,
982,
3285,
18527,
370,
660,
2686,
14,
50,
63,
6348,
19,
12,
12981,
2529,
2008,
272,
334,
3150,
12,
9009,
12,
3839,
12,
4635,
9,
2839,
660,
2686,
14,
50,
63,
6348,
18,
1041,
272,
327,
3873,
14,
7942,
5920,
340,
9009,
12,
3839,
436,
4635,
365,
570,
12,
272,
327,
1325,
642,
15179,
1214,
567,
17373,
1133,
11736,
12,
626,
1159,
10842,
284,
14926,
3002,
277,
1396,
272,
410,
795,
275,
469,
28563,
14,
18472,
568,
63,
5110,
15577,
26,
9009,
12,
31237,
14,
13850,
63,
5110,
15577,
26,
3839,
12,
31237,
14,
18472,
2666,
63,
5110,
15577,
26,
4635,
93,
272,
671,
270,
795,
275,
1052,
272,
922,
275,
664,
63,
751,
8,
751,
9,
272,
367,
2418,
315,
410,
795,
14,
1459,
837,
267,
702,
1228,
8,
1516,
12,
334,
466,
8,
403,
395,
570,
1826,
620,
8,
466,
8,
1516,
430,
272,
340,
3285,
315,
334,
50,
63,
6348,
18,
12,
820,
63,
6348,
19,
304,
267,
340,
9009,
365,
488,
26,
288,
519,
63,
500,
12,
336,
63,
500,
275,
747,
14,
4990,
342,
288,
671,
270,
795,
59,
28563,
14,
18472,
568,
63,
5110,
15577,
61,
275,
336,
63,
500,
12,
519,
63,
500,
267,
340,
3839,
365,
488,
26,
288,
671,
270,
795,
59,
28563,
14,
13850,
63,
5110,
15577,
61,
275,
747,
14,
4990,
342,
272,
340,
3285,
508,
820,
63,
6348,
19,
436,
4635,
365,
488,
26,
267,
671,
270,
795,
59,
28563,
14,
18472,
2666,
63,
5110,
15577,
61,
275,
747,
14,
4990,
342,
272,
4422,
275,
747,
14,
11796,
342,
272,
340,
4422,
508,
378,
26,
267,
367,
6111,
315,
410,
795,
26,
288,
340,
410,
795,
59,
2592,
61,
365,
440,
488,
26,
355,
747,
14,
11048,
18,
8,
270,
795,
59,
2592,
1055,
9843,
1062,
6111,
9,
267,
367,
6111,
315,
671,
270,
795,
26,
288,
299,
548,
12,
10713,
275,
671,
270,
795,
59,
2592,
61,
288,
747,
14,
1600,
8,
80,
548,
9,
288,
747,
14,
11048,
18,
8,
7751,
12,
6111,
9,
267,
340,
365,
63,
1832,
8,
1102,
304,
288,
340,
440,
365,
63,
1818,
63,
751,
8,
751,
304,
355,
372,
747,
14,
5803,
429,
8,
6195,
1649,
12,
283,
12095,
297,
2475,
85,
297,
922,
14,
10124,
3654,
659,
491,
9390,
15215,
12,
2475,
67,
297,
2088,
9,
288
] |
[
747,
12,
984,
199,
646,
2838,
199,
646,
31237,
199,
646,
14374,
199,
646,
3873,
199,
646,
4967,
199,
199,
363,
452,
363,
275,
788,
82,
63,
1628,
297,
283,
82,
63,
12207,
18,
297,
283,
82,
63,
12207,
19,
418,
199,
199,
3243,
275,
747,
14,
2314,
459,
3243,
2278,
1294,
8,
736,
14,
515,
14,
17843,
9,
435,
18744,
2647,
15,
1832,
15,
345,
2686,
15,
1393,
15,
418,
199,
199,
318,
2342,
63,
262,
63,
515,
8,
493,
12,
2754,
63,
515,
29,
3243,
304,
272,
367,
931,
315,
2754,
63,
515,
26,
267,
286,
63,
493,
275,
747,
14,
515,
14,
904,
8,
515,
12,
570,
9,
267,
340,
747,
14,
515,
14,
2444,
8,
67,
63,
493,
304,
288,
372,
286,
63,
493,
272,
372,
488,
199,
199,
363,
9390,
46,
3960,
275,
661,
48,
3763,
1554,
6225,
63,
9390,
15215,
297,
283,
82,
18,
609,
297,
283,
82,
609,
297,
283,
5510,
358,
199,
363,
44,
9390,
46,
3960,
275,
661,
48,
3763,
1554,
6225,
63,
44,
9390,
15215,
297,
283,
16408,
297,
283,
609,
358,
199,
199,
318,
664,
63,
5933,
8,
82,
63,
513,
304,
272,
340,
519,
63,
513,
59,
16,
61,
315,
747,
14,
2314,
26,
267,
372,
747,
14,
2314,
59,
82,
63,
513,
59,
16,
2677,
272,
367,
7876,
315,
519,
63,
513,
59,
17,
10688,
267,
671,
5933,
275,
2342,
63,
262,
63,
515,
8,
5933,
9,
267,
340,
671,
5933,
365,
440,
488,
26,
288,
372,
671,
5933,
339,
746,
4967,
14,
17825,
480,
2425,
1133,
2342,
1263,
21277,
15215,
531,
199,
199,
318,
365,
63,
1832,
8,
1102,
304,
272,
372,
2838,
14,
29789,
342,
508,
1591,
199,
199,
318,
365,
63,
1818,
63,
751,
8,
751,
304,
272,
340,
922,
365,
488,
26,
267,
372,
715,
272,
862,
26,
267,
19206,
275,
14374,
14,
362,
80,
3501,
455,
8,
751,
14,
10124,
3654,
1333,
267,
340,
19206,
14,
8796,
63,
1535,
508,
747,
14,
362,
1535,
342,
436,
19206,
14,
8796,
63,
8787,
508,
747,
14,
362,
8787,
837,
288,
372,
715,
267,
372,
756,
272,
871,
4067,
26,
267,
327,
2382,
365,
949,
922,
543,
536,
267,
327,
5787,
652,
1159,
8034,
370,
315,
964,
922,
267,
372,
715,
199,
199,
318,
664,
63,
751,
8,
751,
29,
403,
304,
272,
340,
922,
365,
488,
26,
267,
372,
747,
14,
2314,
14,
362,
360,
48,
3763,
1554,
6225,
63,
3791,
297,
488,
9,
272,
587,
26,
267,
372,
922,
199,
199,
9390,
15215,
275,
664,
63,
5933,
3460,
9390,
46,
3960,
9,
199,
44,
9390,
15215,
275,
664,
63,
5933,
3460,
44,
9390,
46,
3960,
9,
199,
6195,
1649,
275,
2342,
63,
262,
63,
515,
360,
12095,
358,
199,
50,
63,
6348,
18,
275,
4337,
327,
3963,
2530,
878,
199,
50,
63,
6348,
19,
275,
5049,
199,
199,
479,
747,
14,
48,
63,
12458,
440,
315,
334,
50,
63,
6348,
18,
12,
820,
63,
6348,
19,
9,
199,
479,
747,
14,
48,
63,
2826,
12458,
440,
315,
334,
50,
63,
6348,
18,
12,
820,
63,
6348,
19,
9,
199,
199,
318,
519,
63,
1628,
8,
1102,
12,
2088,
12,
3285,
29,
736,
14,
48,
63,
12458,
12,
9009,
29,
403,
12,
3839,
29,
403,
12,
4635,
29,
403,
12,
922,
29,
403,
304,
272,
408,
4858,
3862,
2088,
641,
1591,
1808,
7876,
14,
339,
982,
3285,
18527,
370,
747,
14,
48,
63,
12458,
12,
12981,
2529,
4458,
1233,
402,
7876,
14,
339,
982,
3285,
18527,
370,
747,
14,
48,
63,
2826,
12458,
12,
12981,
2529,
4422,
402,
7876,
14,
339,
982,
3285,
18527,
370,
660,
2686,
14,
50,
63,
6348,
18,
12,
12981,
2529,
2008,
272,
334,
3150,
12,
9009,
12,
3839,
680,
982,
9009,
503,
3839,
365,
570,
886,
440,
2387,
5872,
272,
370,
2008,
14,
339,
982,
3285,
18527,
370,
660,
2686,
14,
50,
63,
6348,
19,
12,
12981,
2529,
2008,
272,
334,
3150,
12,
9009,
12,
3839,
12,
4635,
9,
2839,
660,
2686,
14,
50,
63,
6348,
18,
1041,
272,
327,
3873,
14,
7942,
5920,
340,
9009,
12,
3839,
436,
4635,
365,
570,
12,
272,
327,
1325,
642,
15179,
1214,
567,
17373,
1133,
11736,
12,
626,
1159,
10842,
284,
14926,
3002,
277,
1396,
272,
410,
795,
275,
469,
28563,
14,
18472,
568,
63,
5110,
15577,
26,
9009,
12,
31237,
14,
13850,
63,
5110,
15577,
26,
3839,
12,
31237,
14,
18472,
2666,
63,
5110,
15577,
26,
4635,
93,
272,
671,
270,
795,
275,
1052,
272,
922,
275,
664,
63,
751,
8,
751,
9,
272,
367,
2418,
315,
410,
795,
14,
1459,
837,
267,
702,
1228,
8,
1516,
12,
334,
466,
8,
403,
395,
570,
1826,
620,
8,
466,
8,
1516,
430,
272,
340,
3285,
315,
334,
50,
63,
6348,
18,
12,
820,
63,
6348,
19,
304,
267,
340,
9009,
365,
488,
26,
288,
519,
63,
500,
12,
336,
63,
500,
275,
747,
14,
4990,
342,
288,
671,
270,
795,
59,
28563,
14,
18472,
568,
63,
5110,
15577,
61,
275,
336,
63,
500,
12,
519,
63,
500,
267,
340,
3839,
365,
488,
26,
288,
671,
270,
795,
59,
28563,
14,
13850,
63,
5110,
15577,
61,
275,
747,
14,
4990,
342,
272,
340,
3285,
508,
820,
63,
6348,
19,
436,
4635,
365,
488,
26,
267,
671,
270,
795,
59,
28563,
14,
18472,
2666,
63,
5110,
15577,
61,
275,
747,
14,
4990,
342,
272,
4422,
275,
747,
14,
11796,
342,
272,
340,
4422,
508,
378,
26,
267,
367,
6111,
315,
410,
795,
26,
288,
340,
410,
795,
59,
2592,
61,
365,
440,
488,
26,
355,
747,
14,
11048,
18,
8,
270,
795,
59,
2592,
1055,
9843,
1062,
6111,
9,
267,
367,
6111,
315,
671,
270,
795,
26,
288,
299,
548,
12,
10713,
275,
671,
270,
795,
59,
2592,
61,
288,
747,
14,
1600,
8,
80,
548,
9,
288,
747,
14,
11048,
18,
8,
7751,
12,
6111,
9,
267,
340,
365,
63,
1832,
8,
1102,
304,
288,
340,
440,
365,
63,
1818,
63,
751,
8,
751,
304,
355,
372,
747,
14,
5803,
429,
8,
6195,
1649,
12,
283,
12095,
297,
2475,
85,
297,
922,
14,
10124,
3654,
659,
491,
9390,
15215,
12,
2475,
67,
297,
2088,
9,
288,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
zidootech/zidoo-kodi-15.1
|
lib/gtest/test/gtest_help_test.py
|
2968
|
5856
|
#!/usr/bin/env python
#
# Copyright 2009, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""Tests the --help flag of Google C++ Testing Framework.
SYNOPSIS
gtest_help_test.py --build_dir=BUILD/DIR
# where BUILD/DIR contains the built gtest_help_test_ file.
gtest_help_test.py
"""
__author__ = 'wan@google.com (Zhanyong Wan)'
import os
import re
import gtest_test_utils
IS_LINUX = os.name == 'posix' and os.uname()[0] == 'Linux'
IS_WINDOWS = os.name == 'nt'
PROGRAM_PATH = gtest_test_utils.GetTestExecutablePath('gtest_help_test_')
FLAG_PREFIX = '--gtest_'
DEATH_TEST_STYLE_FLAG = FLAG_PREFIX + 'death_test_style'
STREAM_RESULT_TO_FLAG = FLAG_PREFIX + 'stream_result_to'
UNKNOWN_FLAG = FLAG_PREFIX + 'unknown_flag_for_testing'
LIST_TESTS_FLAG = FLAG_PREFIX + 'list_tests'
INCORRECT_FLAG_VARIANTS = [re.sub('^--', '-', LIST_TESTS_FLAG),
re.sub('^--', '/', LIST_TESTS_FLAG),
re.sub('_', '-', LIST_TESTS_FLAG)]
INTERNAL_FLAG_FOR_TESTING = FLAG_PREFIX + 'internal_flag_for_testing'
SUPPORTS_DEATH_TESTS = "DeathTest" in gtest_test_utils.Subprocess(
[PROGRAM_PATH, LIST_TESTS_FLAG]).output
# The help message must match this regex.
HELP_REGEX = re.compile(
FLAG_PREFIX + r'list_tests.*' +
FLAG_PREFIX + r'filter=.*' +
FLAG_PREFIX + r'also_run_disabled_tests.*' +
FLAG_PREFIX + r'repeat=.*' +
FLAG_PREFIX + r'shuffle.*' +
FLAG_PREFIX + r'random_seed=.*' +
FLAG_PREFIX + r'color=.*' +
FLAG_PREFIX + r'print_time.*' +
FLAG_PREFIX + r'output=.*' +
FLAG_PREFIX + r'break_on_failure.*' +
FLAG_PREFIX + r'throw_on_failure.*' +
FLAG_PREFIX + r'catch_exceptions=0.*',
re.DOTALL)
def RunWithFlag(flag):
"""Runs gtest_help_test_ with the given flag.
Returns:
the exit code and the text output as a tuple.
Args:
flag: the command-line flag to pass to gtest_help_test_, or None.
"""
if flag is None:
command = [PROGRAM_PATH]
else:
command = [PROGRAM_PATH, flag]
child = gtest_test_utils.Subprocess(command)
return child.exit_code, child.output
class GTestHelpTest(gtest_test_utils.TestCase):
"""Tests the --help flag and its equivalent forms."""
def TestHelpFlag(self, flag):
"""Verifies correct behavior when help flag is specified.
The right message must be printed and the tests must
skipped when the given flag is specified.
Args:
flag: A flag to pass to the binary or None.
"""
exit_code, output = RunWithFlag(flag)
self.assertEquals(0, exit_code)
self.assert_(HELP_REGEX.search(output), output)
if IS_LINUX:
self.assert_(STREAM_RESULT_TO_FLAG in output, output)
else:
self.assert_(STREAM_RESULT_TO_FLAG not in output, output)
if SUPPORTS_DEATH_TESTS and not IS_WINDOWS:
self.assert_(DEATH_TEST_STYLE_FLAG in output, output)
else:
self.assert_(DEATH_TEST_STYLE_FLAG not in output, output)
def TestNonHelpFlag(self, flag):
"""Verifies correct behavior when no help flag is specified.
Verifies that when no help flag is specified, the tests are run
and the help message is not printed.
Args:
flag: A flag to pass to the binary or None.
"""
exit_code, output = RunWithFlag(flag)
self.assert_(exit_code != 0)
self.assert_(not HELP_REGEX.search(output), output)
def testPrintsHelpWithFullFlag(self):
self.TestHelpFlag('--help')
def testPrintsHelpWithShortFlag(self):
self.TestHelpFlag('-h')
def testPrintsHelpWithQuestionFlag(self):
self.TestHelpFlag('-?')
def testPrintsHelpWithWindowsStyleQuestionFlag(self):
self.TestHelpFlag('/?')
def testPrintsHelpWithUnrecognizedGoogleTestFlag(self):
self.TestHelpFlag(UNKNOWN_FLAG)
def testPrintsHelpWithIncorrectFlagStyle(self):
for incorrect_flag in INCORRECT_FLAG_VARIANTS:
self.TestHelpFlag(incorrect_flag)
def testRunsTestsWithoutHelpFlag(self):
"""Verifies that when no help flag is specified, the tests are run
and the help message is not printed."""
self.TestNonHelpFlag(None)
def testRunsTestsWithGtestInternalFlag(self):
"""Verifies that the tests are run and no help message is printed when
a flag starting with Google Test prefix and 'internal_' is supplied."""
self.TestNonHelpFlag(INTERNAL_FLAG_FOR_TESTING)
if __name__ == '__main__':
gtest_test_utils.Main()
|
gpl-2.0
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
3,
199,
3,
1898,
8937,
12,
4475,
3277,
14,
199,
3,
2900,
4481,
4644,
14,
199,
3,
199,
3,
10114,
436,
675,
315,
1350,
436,
3366,
4513,
12,
543,
503,
1928,
199,
3,
7100,
12,
787,
8211,
2741,
626,
314,
2569,
3704,
787,
199,
3,
7647,
26,
199,
3,
199,
3,
258,
627,
6823,
402,
1350,
1233,
1471,
8074,
314,
3432,
4248,
199,
3,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
14,
199,
3,
258,
627,
6823,
315,
3366,
1824,
1471,
9172,
314,
3432,
199,
3,
4248,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
199,
3,
315,
314,
3794,
436,
15,
269,
1163,
8418,
2741,
543,
314,
199,
3,
4084,
14,
199,
3,
258,
627,
11443,
314,
536,
402,
4475,
3277,
14,
6590,
314,
1561,
402,
2399,
199,
3,
8417,
1443,
506,
1202,
370,
10692,
503,
10016,
7585,
7131,
687,
199,
3,
642,
2032,
1928,
2488,
6791,
5313,
4983,
14,
199,
3,
199,
3,
5749,
4141,
2281,
7049,
6515,
2334,
5877,
8164,
2401,
6483,
199,
3,
298,
1179,
2281,
2,
2401,
1821,
7168,
1549,
5292,
2990,
12,
6931,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
2334,
5292,
2990,
1634,
3169,
2401,
3092,
2381,
199,
3,
437,
3115,
3104,
9315,
9706,
14,
1621,
4825,
6461,
7000,
2334,
5877,
199,
3,
11489,
1549,
6483,
6262,
7024,
2381,
1821,
8703,
12,
9168,
12,
9716,
12,
199,
3,
8820,
12,
9836,
12,
1549,
9110,
6736,
334,
6446,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
9838,
1634,
9103,
9764,
1549,
9714,
27,
9102,
1634,
4815,
12,
199,
3,
7126,
12,
1549,
9206,
27,
1549,
9748,
9831,
9,
9802,
9817,
2401,
5258,
1821,
199,
3,
9815,
1634,
5603,
12,
7061,
1621,
7066,
12,
9644,
5603,
12,
1549,
7056,
199,
3,
334,
6446,
9254,
1549,
7334,
9,
7043,
1621,
1821,
9683,
5738,
1634,
2334,
4815,
199,
3,
1634,
5749,
4141,
12,
9704,
8036,
9691,
1634,
2334,
9726,
1634,
9712,
9784,
14,
199,
199,
624,
2925,
314,
1553,
3437,
3305,
402,
4475,
445,
4176,
11940,
22545,
14,
199,
199,
31802,
21665,
1311,
2126,
9088,
63,
3437,
63,
396,
14,
647,
1553,
1506,
63,
694,
29,
8248,
15,
3022,
268,
327,
2382,
22974,
15,
3022,
3509,
314,
6137,
9088,
63,
3437,
63,
396,
63,
570,
14,
2126,
9088,
63,
3437,
63,
396,
14,
647,
199,
624,
199,
199,
363,
2502,
363,
275,
283,
20444,
32,
3098,
14,
957,
334,
12674,
1629,
951,
644,
290,
3171,
199,
199,
646,
747,
199,
646,
295,
199,
646,
9088,
63,
396,
63,
1208,
421,
199,
1311,
63,
26030,
275,
747,
14,
354,
508,
283,
9228,
7,
436,
747,
14,
16040,
3430,
16,
61,
508,
283,
14091,
7,
199,
1311,
63,
20509,
275,
747,
14,
354,
508,
283,
343,
7,
199,
199,
15605,
63,
3243,
275,
9088,
63,
396,
63,
1208,
14,
28967,
27602,
360,
8385,
63,
3437,
63,
396,
15452,
199,
3719,
63,
6351,
275,
2850,
8385,
8650,
199,
1093,
11695,
63,
2864,
63,
18466,
63,
3719,
275,
11031,
63,
6351,
435,
283,
23727,
63,
396,
63,
2487,
7,
199,
9484,
63,
9517,
63,
2566,
63,
3719,
275,
11031,
63,
6351,
435,
283,
1745,
63,
1099,
63,
475,
7,
199,
11588,
63,
3719,
275,
11031,
63,
6351,
435,
283,
5187,
63,
4173,
63,
509,
63,
4776,
7,
199,
4924,
63,
7569,
63,
3719,
275,
11031,
63,
6351,
435,
283,
513,
63,
2219,
7,
199,
568,
31704,
63,
3719,
63,
30582,
51,
275,
359,
264,
14,
954,
9097,
306,
297,
17525,
21716,
63,
7569,
63,
3719,
395,
2574,
295,
14,
954,
9097,
306,
297,
17220,
21716,
63,
7569,
63,
3719,
395,
2574,
295,
14,
954,
20928,
17525,
21716,
63,
7569,
63,
3719,
1874,
199,
17681,
63,
3719,
63,
2707,
63,
2864,
1206,
275,
11031,
63,
6351,
435,
283,
4672,
63,
4173,
63,
509,
63,
4776,
7,
199,
199,
10640,
51,
63,
1093,
11695,
63,
7569,
275,
298,
31577,
774,
2,
315,
9088,
63,
396,
63,
1208,
14,
22299,
8,
272,
359,
15605,
63,
3243,
12,
21716,
63,
7569,
63,
3719,
6575,
1199,
199,
199,
3,
710,
1720,
1245,
1471,
1336,
642,
5163,
14,
199,
17930,
63,
10710,
275,
295,
14,
2014,
8,
272,
11031,
63,
6351,
435,
519,
7,
513,
63,
2219,
25737,
435,
272,
11031,
63,
6351,
435,
519,
7,
1541,
29,
25737,
435,
272,
11031,
63,
6351,
435,
519,
7,
12344,
63,
1065,
63,
7011,
63,
2219,
25737,
435,
272,
11031,
63,
6351,
435,
519,
3984,
321,
292,
29,
25737,
435,
272,
11031,
63,
6351,
435,
519,
1159,
72,
6817,
25737,
435,
272,
11031,
63,
6351,
435,
519,
7,
2355,
63,
5176,
29,
25737,
435,
272,
11031,
63,
6351,
435,
519,
7,
2326,
29,
25737,
435,
272,
11031,
63,
6351,
435,
519,
7,
1361,
63,
521,
25737,
435,
272,
11031,
63,
6351,
435,
519,
7,
1199,
29,
25737,
435,
272,
11031,
63,
6351,
435,
519,
7,
4785,
63,
265,
63,
5328,
25737,
435,
272,
11031,
63,
6351,
435,
519,
1133,
72,
1143,
63,
265,
63,
5328,
25737,
435,
272,
11031,
63,
6351,
435,
519,
7,
9341,
63,
3924,
29,
16,
16110,
272,
295,
14,
16504,
9,
421,
199,
318,
3378,
3007,
5318,
8,
4173,
304,
523,
408,
16291,
9088,
63,
3437,
63,
396,
63,
543,
314,
1627,
3305,
14,
819,
1803,
26,
272,
314,
4458,
1233,
436,
314,
1318,
1072,
465,
282,
2008,
14,
523,
3033,
26,
272,
3305,
26,
314,
1414,
13,
604,
3305,
370,
986,
370,
9088,
63,
3437,
63,
396,
3131,
503,
488,
14,
523,
408,
819,
340,
3305,
365,
488,
26,
272,
1414,
275,
359,
15605,
63,
3243,
61,
523,
587,
26,
272,
1414,
275,
359,
15605,
63,
3243,
12,
3305,
61,
523,
1982,
275,
9088,
63,
396,
63,
1208,
14,
22299,
8,
1531,
9,
523,
372,
1982,
14,
2224,
63,
600,
12,
1982,
14,
1199,
421,
199,
533,
598,
774,
8673,
774,
8,
8385,
63,
396,
63,
1208,
14,
1746,
304,
523,
408,
2925,
314,
1553,
3437,
3305,
436,
2399,
7353,
4513,
1041,
819,
347,
1379,
8673,
5318,
8,
277,
12,
3305,
304,
272,
408,
21168,
3211,
5953,
1380,
1720,
3305,
365,
2013,
14,
339,
710,
2451,
1245,
1471,
506,
12487,
436,
314,
2295,
1471
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
3,
199,
3,
1898,
8937,
12,
4475,
3277,
14,
199,
3,
2900,
4481,
4644,
14,
199,
3,
199,
3,
10114,
436,
675,
315,
1350,
436,
3366,
4513,
12,
543,
503,
1928,
199,
3,
7100,
12,
787,
8211,
2741,
626,
314,
2569,
3704,
787,
199,
3,
7647,
26,
199,
3,
199,
3,
258,
627,
6823,
402,
1350,
1233,
1471,
8074,
314,
3432,
4248,
199,
3,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
14,
199,
3,
258,
627,
6823,
315,
3366,
1824,
1471,
9172,
314,
3432,
199,
3,
4248,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
199,
3,
315,
314,
3794,
436,
15,
269,
1163,
8418,
2741,
543,
314,
199,
3,
4084,
14,
199,
3,
258,
627,
11443,
314,
536,
402,
4475,
3277,
14,
6590,
314,
1561,
402,
2399,
199,
3,
8417,
1443,
506,
1202,
370,
10692,
503,
10016,
7585,
7131,
687,
199,
3,
642,
2032,
1928,
2488,
6791,
5313,
4983,
14,
199,
3,
199,
3,
5749,
4141,
2281,
7049,
6515,
2334,
5877,
8164,
2401,
6483,
199,
3,
298,
1179,
2281,
2,
2401,
1821,
7168,
1549,
5292,
2990,
12,
6931,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
2334,
5292,
2990,
1634,
3169,
2401,
3092,
2381,
199,
3,
437,
3115,
3104,
9315,
9706,
14,
1621,
4825,
6461,
7000,
2334,
5877,
199,
3,
11489,
1549,
6483,
6262,
7024,
2381,
1821,
8703,
12,
9168,
12,
9716,
12,
199,
3,
8820,
12,
9836,
12,
1549,
9110,
6736,
334,
6446,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
9838,
1634,
9103,
9764,
1549,
9714,
27,
9102,
1634,
4815,
12,
199,
3,
7126,
12,
1549,
9206,
27,
1549,
9748,
9831,
9,
9802,
9817,
2401,
5258,
1821,
199,
3,
9815,
1634,
5603,
12,
7061,
1621,
7066,
12,
9644,
5603,
12,
1549,
7056,
199,
3,
334,
6446,
9254,
1549,
7334,
9,
7043,
1621,
1821,
9683,
5738,
1634,
2334,
4815,
199,
3,
1634,
5749,
4141,
12,
9704,
8036,
9691,
1634,
2334,
9726,
1634,
9712,
9784,
14,
199,
199,
624,
2925,
314,
1553,
3437,
3305,
402,
4475,
445,
4176,
11940,
22545,
14,
199,
199,
31802,
21665,
1311,
2126,
9088,
63,
3437,
63,
396,
14,
647,
1553,
1506,
63,
694,
29,
8248,
15,
3022,
268,
327,
2382,
22974,
15,
3022,
3509,
314,
6137,
9088,
63,
3437,
63,
396,
63,
570,
14,
2126,
9088,
63,
3437,
63,
396,
14,
647,
199,
624,
199,
199,
363,
2502,
363,
275,
283,
20444,
32,
3098,
14,
957,
334,
12674,
1629,
951,
644,
290,
3171,
199,
199,
646,
747,
199,
646,
295,
199,
646,
9088,
63,
396,
63,
1208,
421,
199,
1311,
63,
26030,
275,
747,
14,
354,
508,
283,
9228,
7,
436,
747,
14,
16040,
3430,
16,
61,
508,
283,
14091,
7,
199,
1311,
63,
20509,
275,
747,
14,
354,
508,
283,
343,
7,
199,
199,
15605,
63,
3243,
275,
9088,
63,
396,
63,
1208,
14,
28967,
27602,
360,
8385,
63,
3437,
63,
396,
15452,
199,
3719,
63,
6351,
275,
2850,
8385,
8650,
199,
1093,
11695,
63,
2864,
63,
18466,
63,
3719,
275,
11031,
63,
6351,
435,
283,
23727,
63,
396,
63,
2487,
7,
199,
9484,
63,
9517,
63,
2566,
63,
3719,
275,
11031,
63,
6351,
435,
283,
1745,
63,
1099,
63,
475,
7,
199,
11588,
63,
3719,
275,
11031,
63,
6351,
435,
283,
5187,
63,
4173,
63,
509,
63,
4776,
7,
199,
4924,
63,
7569,
63,
3719,
275,
11031,
63,
6351,
435,
283,
513,
63,
2219,
7,
199,
568,
31704,
63,
3719,
63,
30582,
51,
275,
359,
264,
14,
954,
9097,
306,
297,
17525,
21716,
63,
7569,
63,
3719,
395,
2574,
295,
14,
954,
9097,
306,
297,
17220,
21716,
63,
7569,
63,
3719,
395,
2574,
295,
14,
954,
20928,
17525,
21716,
63,
7569,
63,
3719,
1874,
199,
17681,
63,
3719,
63,
2707,
63,
2864,
1206,
275,
11031,
63,
6351,
435,
283,
4672,
63,
4173,
63,
509,
63,
4776,
7,
199,
199,
10640,
51,
63,
1093,
11695,
63,
7569,
275,
298,
31577,
774,
2,
315,
9088,
63,
396,
63,
1208,
14,
22299,
8,
272,
359,
15605,
63,
3243,
12,
21716,
63,
7569,
63,
3719,
6575,
1199,
199,
199,
3,
710,
1720,
1245,
1471,
1336,
642,
5163,
14,
199,
17930,
63,
10710,
275,
295,
14,
2014,
8,
272,
11031,
63,
6351,
435,
519,
7,
513,
63,
2219,
25737,
435,
272,
11031,
63,
6351,
435,
519,
7,
1541,
29,
25737,
435,
272,
11031,
63,
6351,
435,
519,
7,
12344,
63,
1065,
63,
7011,
63,
2219,
25737,
435,
272,
11031,
63,
6351,
435,
519,
3984,
321,
292,
29,
25737,
435,
272,
11031,
63,
6351,
435,
519,
1159,
72,
6817,
25737,
435,
272,
11031,
63,
6351,
435,
519,
7,
2355,
63,
5176,
29,
25737,
435,
272,
11031,
63,
6351,
435,
519,
7,
2326,
29,
25737,
435,
272,
11031,
63,
6351,
435,
519,
7,
1361,
63,
521,
25737,
435,
272,
11031,
63,
6351,
435,
519,
7,
1199,
29,
25737,
435,
272,
11031,
63,
6351,
435,
519,
7,
4785,
63,
265,
63,
5328,
25737,
435,
272,
11031,
63,
6351,
435,
519,
1133,
72,
1143,
63,
265,
63,
5328,
25737,
435,
272,
11031,
63,
6351,
435,
519,
7,
9341,
63,
3924,
29,
16,
16110,
272,
295,
14,
16504,
9,
421,
199,
318,
3378,
3007,
5318,
8,
4173,
304,
523,
408,
16291,
9088,
63,
3437,
63,
396,
63,
543,
314,
1627,
3305,
14,
819,
1803,
26,
272,
314,
4458,
1233,
436,
314,
1318,
1072,
465,
282,
2008,
14,
523,
3033,
26,
272,
3305,
26,
314,
1414,
13,
604,
3305,
370,
986,
370,
9088,
63,
3437,
63,
396,
3131,
503,
488,
14,
523,
408,
819,
340,
3305,
365,
488,
26,
272,
1414,
275,
359,
15605,
63,
3243,
61,
523,
587,
26,
272,
1414,
275,
359,
15605,
63,
3243,
12,
3305,
61,
523,
1982,
275,
9088,
63,
396,
63,
1208,
14,
22299,
8,
1531,
9,
523,
372,
1982,
14,
2224,
63,
600,
12,
1982,
14,
1199,
421,
199,
533,
598,
774,
8673,
774,
8,
8385,
63,
396,
63,
1208,
14,
1746,
304,
523,
408,
2925,
314,
1553,
3437,
3305,
436,
2399,
7353,
4513,
1041,
819,
347,
1379,
8673,
5318,
8,
277,
12,
3305,
304,
272,
408,
21168,
3211,
5953,
1380,
1720,
3305,
365,
2013,
14,
339,
710,
2451,
1245,
1471,
506,
12487,
436,
314,
2295,
1471,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
40223211/w16b_test
|
static/Brython3.1.1-20150328-091302/Lib/atexit.py
|
743
|
1049
|
"""allow programmer to define multiple exit functions to be executedupon normal program termination.
Two public functions, register and unregister, are defined.
"""
class __loader__(object):
pass
def _clear(*args,**kw):
"""_clear() -> None
Clear the list of previously registered exit functions."""
pass
def _run_exitfuncs(*args,**kw):
"""_run_exitfuncs() -> None
Run all registered exit functions."""
pass
def register(*args,**kw):
"""register(func, *args, **kwargs) -> func
Register a function to be executed upon normal program termination
func - function to be called at exit
args - optional arguments to pass to func
kwargs - optional keyword arguments to pass to func
func is returned to facilitate usage as a decorator."""
pass
def unregister(*args,**kw):
"""unregister(func) -> None
Unregister a exit function which was previously registered using
atexit.register
func - function to be unregistered"""
pass
|
agpl-3.0
|
[
624,
3306,
2240,
2626,
370,
5627,
3663,
4458,
3423,
370,
506,
7934,
13527,
3293,
2240,
23868,
14,
199,
199,
11467,
4575,
3423,
12,
2274,
436,
24369,
12,
787,
3247,
14,
199,
624,
421,
199,
533,
636,
3422,
721,
785,
304,
272,
986,
199,
199,
318,
485,
3584,
2031,
589,
12663,
829,
304,
272,
408,
63,
3584,
342,
1035,
488,
14821,
14836,
314,
769,
402,
10889,
7264,
4458,
3423,
1041,
272,
986,
199,
199,
318,
485,
1065,
63,
2224,
9204,
2031,
589,
12663,
829,
304,
272,
408,
63,
1065,
63,
2224,
9204,
342,
1035,
488,
14821,
3378,
1006,
7264,
4458,
3423,
1041,
272,
986,
199,
199,
318,
2274,
2031,
589,
12663,
829,
304,
272,
408,
2683,
8,
1532,
12,
627,
589,
12,
1011,
958,
9,
1035,
2562,
14821,
11828,
282,
805,
370,
506,
7934,
12188,
3293,
2240,
23868,
13857,
2562,
446,
805,
370,
506,
2797,
737,
4458,
267,
1249,
446,
2716,
2368,
370,
986,
370,
2562,
267,
2074,
446,
2716,
4252,
2368,
370,
986,
370,
2562,
13857,
2562,
365,
2138,
370,
30242,
1051,
323,
4503,
465,
282,
7531,
1041,
272,
986,
199,
199,
318,
24369,
2031,
589,
12663,
829,
304,
272,
408,
18408,
8,
1532,
9,
1035,
488,
14821,
1910,
2683,
282,
4458,
805,
1314,
1990,
10889,
7264,
1808,
272,
19840,
14,
2683,
13857,
2562,
446,
805,
370,
506,
625,
11616,
624,
272,
986,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
3306,
2240,
2626,
370,
5627,
3663,
4458,
3423,
370,
506,
7934,
13527,
3293,
2240,
23868,
14,
199,
199,
11467,
4575,
3423,
12,
2274,
436,
24369,
12,
787,
3247,
14,
199,
624,
421,
199,
533,
636,
3422,
721,
785,
304,
272,
986,
199,
199,
318,
485,
3584,
2031,
589,
12663,
829,
304,
272,
408,
63,
3584,
342,
1035,
488,
14821,
14836,
314,
769,
402,
10889,
7264,
4458,
3423,
1041,
272,
986,
199,
199,
318,
485,
1065,
63,
2224,
9204,
2031,
589,
12663,
829,
304,
272,
408,
63,
1065,
63,
2224,
9204,
342,
1035,
488,
14821,
3378,
1006,
7264,
4458,
3423,
1041,
272,
986,
199,
199,
318,
2274,
2031,
589,
12663,
829,
304,
272,
408,
2683,
8,
1532,
12,
627,
589,
12,
1011,
958,
9,
1035,
2562,
14821,
11828,
282,
805,
370,
506,
7934,
12188,
3293,
2240,
23868,
13857,
2562,
446,
805,
370,
506,
2797,
737,
4458,
267,
1249,
446,
2716,
2368,
370,
986,
370,
2562,
267,
2074,
446,
2716,
4252,
2368,
370,
986,
370,
2562,
13857,
2562,
365,
2138,
370,
30242,
1051,
323,
4503,
465,
282,
7531,
1041,
272,
986,
199,
199,
318,
24369,
2031,
589,
12663,
829,
304,
272,
408,
18408,
8,
1532,
9,
1035,
488,
14821,
1910,
2683,
282,
4458,
805,
1314,
1990,
10889,
7264,
1808,
272,
19840,
14,
2683,
13857,
2562,
446,
805,
370,
506,
625,
11616,
624,
272,
986,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
neeasade/qutebrowser
|
scripts/dev/src2asciidoc.py
|
4
|
18512
|
#!/usr/bin/env python3
# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et:
# Copyright 2014-2016 Florian Bruhin (The Compiler) <mail@qutebrowser.org>
# This file is part of qutebrowser.
#
# qutebrowser is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# qutebrowser is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
"""Generate asciidoc source for qutebrowser based on docstrings."""
import os
import sys
import html
import shutil
import os.path
import inspect
import subprocess
import collections
import tempfile
import argparse
sys.path.insert(0, os.path.join(os.path.dirname(__file__), os.pardir,
os.pardir))
# We import qutebrowser.app so all @cmdutils-register decorators are run.
import qutebrowser.app
from scripts import asciidoc2html, utils
from qutebrowser import qutebrowser
from qutebrowser.commands import cmdutils, argparser
from qutebrowser.config import configdata
from qutebrowser.utils import docutils
class UsageFormatter(argparse.HelpFormatter):
"""Patched HelpFormatter to include some asciidoc markup in the usage.
This does some horrible things, but the alternative would be to reimplement
argparse.HelpFormatter while copying 99% of the code :-/
"""
def _format_usage(self, usage, actions, groups, _prefix):
"""Override _format_usage to not add the 'usage:' prefix."""
return super()._format_usage(usage, actions, groups, '')
def _get_default_metavar_for_optional(self, action):
"""Do name transforming when getting metavar."""
return argparser.arg_name(action.dest.upper())
def _get_default_metavar_for_positional(self, action):
"""Do name transforming when getting metavar."""
return argparser.arg_name(action.dest)
def _metavar_formatter(self, action, default_metavar):
"""Override _metavar_formatter to add asciidoc markup to metavars.
Most code here is copied from Python 3.4's argparse.py.
"""
if action.metavar is not None:
result = "'{}'".format(action.metavar)
elif action.choices is not None:
choice_strs = [str(choice) for choice in action.choices]
result = ('{' + ','.join('*{}*'.format(e) for e in choice_strs) +
'}')
else:
result = "'{}'".format(default_metavar)
def fmt(tuple_size):
"""Format the result according to the tuple size."""
if isinstance(result, tuple):
return result
else:
return (result, ) * tuple_size
return fmt
def _format_actions_usage(self, actions, groups):
"""Override _format_actions_usage to add asciidoc markup to flags.
Because argparse.py's _format_actions_usage is very complex, we first
monkey-patch the option strings to include the asciidoc markup, then
run the original method, then undo the patching.
"""
old_option_strings = {}
for action in actions:
old_option_strings[action] = action.option_strings[:]
action.option_strings = ['*{}*'.format(s)
for s in action.option_strings]
ret = super()._format_actions_usage(actions, groups)
for action in actions:
action.option_strings = old_option_strings[action]
return ret
def _open_file(name, mode='w'):
"""Open a file with a preset newline/encoding mode."""
return open(name, mode, newline='\n', encoding='utf-8')
def _get_cmd_syntax(_name, cmd):
"""Get the command syntax for a command.
We monkey-patch the parser's formatter_class here to use our UsageFormatter
which adds some asciidoc markup.
"""
old_fmt_class = cmd.parser.formatter_class
cmd.parser.formatter_class = UsageFormatter
usage = cmd.parser.format_usage().rstrip()
cmd.parser.formatter_class = old_fmt_class
return usage
def _get_command_quickref(cmds):
"""Generate the command quick reference."""
out = []
out.append('[options="header",width="75%",cols="25%,75%"]')
out.append('|==============')
out.append('|Command|Description')
for name, cmd in cmds:
desc = inspect.getdoc(cmd.handler).splitlines()[0]
out.append('|<<{},{}>>|{}'.format(name, name, desc))
out.append('|==============')
return '\n'.join(out)
def _get_setting_quickref():
"""Generate the settings quick reference."""
out = []
for sectname, sect in configdata.DATA.items():
if not getattr(sect, 'descriptions'):
continue
out.append("")
out.append(".Quick reference for section ``{}''".format(sectname))
out.append('[options="header",width="75%",cols="25%,75%"]')
out.append('|==============')
out.append('|Setting|Description')
for optname, _option in sect.items():
desc = sect.descriptions[optname].splitlines()[0]
out.append('|<<{}-{},{}>>|{}'.format(
sectname, optname, optname, desc))
out.append('|==============')
return '\n'.join(out)
def _get_command_doc(name, cmd):
"""Generate the documentation for a command."""
output = ['[[{}]]'.format(name)]
output += ['=== {}'.format(name)]
syntax = _get_cmd_syntax(name, cmd)
if syntax != name:
output.append('Syntax: +:{}+'.format(syntax))
output.append("")
parser = docutils.DocstringParser(cmd.handler)
output.append(parser.short_desc)
if parser.long_desc:
output.append("")
output.append(parser.long_desc)
output += list(_get_command_doc_args(cmd, parser))
output += list(_get_command_doc_count(cmd, parser))
output += list(_get_command_doc_notes(cmd))
output.append("")
output.append("")
return '\n'.join(output)
def _get_command_doc_args(cmd, parser):
"""Get docs for the arguments of a command.
Args:
cmd: The Command to get the docs for.
parser: The DocstringParser to use.
Yield:
Strings which should be added to the docs.
"""
if cmd.pos_args:
yield ""
yield "==== positional arguments"
for arg, name in cmd.pos_args:
try:
yield "* +'{}'+: {}".format(name, parser.arg_descs[arg])
except KeyError as e:
raise KeyError("No description for arg {} of command "
"'{}'!".format(e, cmd.name)) from e
if cmd.opt_args:
yield ""
yield "==== optional arguments"
for arg, (long_flag, short_flag) in cmd.opt_args.items():
try:
yield '* +*{}*+, +*{}*+: {}'.format(short_flag, long_flag,
parser.arg_descs[arg])
except KeyError as e:
raise KeyError("No description for arg {} of command "
"'{}'!".format(e, cmd.name)) from e
def _get_command_doc_count(cmd, parser):
"""Get docs for the count of a command.
Args:
cmd: The Command to get the docs for.
parser: The DocstringParser to use.
Yield:
Strings which should be added to the docs.
"""
for param in inspect.signature(cmd.handler).parameters.values():
if cmd.get_arg_info(param).count:
yield ""
yield "==== count"
try:
yield parser.arg_descs[param.name]
except KeyError as e:
raise KeyError("No description for count arg {!r} of command "
"{!r}!".format(param.name, cmd.name)) from e
def _get_command_doc_notes(cmd):
"""Get docs for the notes of a command.
Args:
cmd: The Command to get the docs for.
parser: The DocstringParser to use.
Yield:
Strings which should be added to the docs.
"""
if cmd.maxsplit is not None or cmd.no_cmd_split:
yield ""
yield "==== note"
if cmd.maxsplit is not None:
yield ("* This command does not split arguments after the last "
"argument and handles quotes literally.")
if cmd.no_cmd_split:
yield ("* With this command, +;;+ is interpreted literally "
"instead of splitting off a second command.")
def _get_action_metavar(action, nargs=1):
"""Get the metavar to display for an argparse action.
Args:
action: The argparse action to get the metavar for.
nargs: The nargs setting for the related argument.
"""
if action.metavar is not None:
if isinstance(action.metavar, str):
elems = [action.metavar] * nargs
else:
elems = action.metavar
return ' '.join("'{}'".format(e) for e in elems)
elif action.choices is not None:
choices = ','.join(str(e) for e in action.choices)
return "'{{{}}}'".format(choices)
else:
return "'{}'".format(action.dest.upper())
def _format_action_args(action):
"""Get an argument string based on an argparse action."""
if action.nargs is None:
return _get_action_metavar(action)
elif action.nargs == '?':
return '[{}]'.format(_get_action_metavar(action))
elif action.nargs == '*':
return '[{mv} [{mv} ...]]'.format(mv=_get_action_metavar(action))
elif action.nargs == '+':
return '{mv} [{mv} ...]'.format(mv=_get_action_metavar(action))
elif action.nargs == '...':
return '...'
else:
return _get_action_metavar(action, nargs=action.nargs)
def _format_action(action):
"""Get an invocation string/help from an argparse action."""
if action.help == argparse.SUPPRESS:
return None
if not action.option_strings:
invocation = '*{}*::'.format(_get_action_metavar(action))
else:
parts = []
if action.nargs == 0:
# Doesn't take a value, so the syntax is -s, --long
parts += ['*{}*'.format(s) for s in action.option_strings]
else:
# Takes a value, so the syntax is -s ARGS or --long ARGS.
args_string = _format_action_args(action)
for opt in action.option_strings:
parts.append('*{}* {}'.format(opt, args_string))
invocation = ', '.join(parts) + '::'
return '{}\n {}\n'.format(invocation, action.help)
def generate_commands(filename):
"""Generate the complete commands section."""
with _open_file(filename) as f:
f.write("= Commands\n")
normal_cmds = []
hidden_cmds = []
debug_cmds = []
for name, cmd in cmdutils.cmd_dict.items():
if name in cmdutils.aliases:
continue
if cmd.hide:
hidden_cmds.append((name, cmd))
elif cmd.debug:
debug_cmds.append((name, cmd))
elif not cmd.deprecated:
normal_cmds.append((name, cmd))
normal_cmds.sort()
hidden_cmds.sort()
debug_cmds.sort()
f.write("\n")
f.write("== Normal commands\n")
f.write(".Quick reference\n")
f.write(_get_command_quickref(normal_cmds) + '\n')
for name, cmd in normal_cmds:
f.write(_get_command_doc(name, cmd))
f.write("\n")
f.write("== Hidden commands\n")
f.write(".Quick reference\n")
f.write(_get_command_quickref(hidden_cmds) + '\n')
for name, cmd in hidden_cmds:
f.write(_get_command_doc(name, cmd))
f.write("\n")
f.write("== Debugging commands\n")
f.write("These commands are mainly intended for debugging. They are "
"hidden if qutebrowser was started without the "
"`--debug`-flag.\n")
f.write("\n")
f.write(".Quick reference\n")
f.write(_get_command_quickref(debug_cmds) + '\n')
for name, cmd in debug_cmds:
f.write(_get_command_doc(name, cmd))
def _generate_setting_section(f, sectname, sect):
"""Generate documentation for a single section."""
for optname, option in sect.items():
f.write("\n")
f.write('[[{}-{}]]'.format(sectname, optname) + "\n")
f.write("=== {}".format(optname) + "\n")
f.write(sect.descriptions[optname] + "\n")
f.write("\n")
valid_values = option.typ.valid_values
if valid_values is not None:
f.write("Valid values:\n")
f.write("\n")
for val in valid_values:
try:
desc = valid_values.descriptions[val]
f.write(" * +{}+: {}".format(val, desc) + "\n")
except KeyError:
f.write(" * +{}+".format(val) + "\n")
f.write("\n")
if option.default():
f.write("Default: +pass:[{}]+\n".format(html.escape(
option.default())))
else:
f.write("Default: empty\n")
def generate_settings(filename):
"""Generate the complete settings section."""
with _open_file(filename) as f:
f.write("= Settings\n")
f.write(_get_setting_quickref() + "\n")
for sectname, sect in configdata.DATA.items():
f.write("\n")
f.write("== {}".format(sectname) + "\n")
f.write(configdata.SECTION_DESC[sectname] + "\n")
if not getattr(sect, 'descriptions'):
pass
else:
_generate_setting_section(f, sectname, sect)
def _get_authors():
"""Get a list of authors based on git commit logs."""
corrections = {
'binix': 'sbinix',
'Averrin': 'Alexey "Averrin" Nabrodov',
'Alexey Nabrodov': 'Alexey "Averrin" Nabrodov',
'Michael': 'Halfwit',
'Error 800': 'error800',
'larryhynes': 'Larry Hynes',
'Daniel': 'Daniel Schadt',
'Alexey Glushko': 'haitaka',
'Corentin Jule': 'Corentin Julé',
}
commits = subprocess.check_output(['git', 'log', '--format=%aN'])
authors = [corrections.get(author, author)
for author in commits.decode('utf-8').splitlines()]
cnt = collections.Counter(authors)
return sorted(cnt, key=lambda k: (cnt[k], k), reverse=True)
def _format_block(filename, what, data):
"""Format a block in a file.
The block is delimited by markers like these:
// QUTE_*_START
...
// QUTE_*_END
The * part is the part which should be given as 'what'.
Args:
filename: The file to change.
what: What to change (authors, options, etc.)
data; A list of strings which is the new data.
"""
what = what.upper()
oshandle, tmpname = tempfile.mkstemp()
try:
with _open_file(filename, mode='r') as infile, \
_open_file(oshandle, mode='w') as temp:
found_start = False
found_end = False
for line in infile:
if line.strip() == '// QUTE_{}_START'.format(what):
temp.write(line)
temp.write(''.join(data))
found_start = True
elif line.strip() == '// QUTE_{}_END'.format(what.upper()):
temp.write(line)
found_end = True
elif (not found_start) or found_end:
temp.write(line)
if not found_start:
raise Exception("Marker '// QUTE_{}_START' not found in "
"'{}'!".format(what, filename))
elif not found_end:
raise Exception("Marker '// QUTE_{}_END' not found in "
"'{}'!".format(what, filename))
except:
os.remove(tmpname)
raise
else:
os.remove(filename)
shutil.move(tmpname, filename)
def regenerate_authors(filename):
"""Re-generate the authors inside README based on the commits made."""
data = ['* {}\n'.format(author) for author in _get_authors()]
_format_block(filename, 'authors', data)
def regenerate_manpage(filename):
"""Update manpage OPTIONS using an argparse parser."""
# pylint: disable=protected-access
parser = qutebrowser.get_argparser()
groups = []
# positionals, optionals and user-defined groups
for group in parser._action_groups:
groupdata = []
groupdata.append('=== {}'.format(group.title))
if group.description is not None:
groupdata.append(group.description)
for action in group._group_actions:
action_data = _format_action(action)
if action_data is not None:
groupdata.append(action_data)
groups.append('\n'.join(groupdata))
options = '\n'.join(groups)
# epilog
if parser.epilog is not None:
options += parser.epilog
_format_block(filename, 'options', options)
def regenerate_cheatsheet():
"""Generate cheatsheet PNGs based on the SVG."""
files = [
('doc/img/cheatsheet-small.png', 300, 185),
('doc/img/cheatsheet-big.png', 3342, 2060),
]
for filename, x, y in files:
subprocess.check_call(['inkscape', '-e', filename, '-b', 'white',
'-w', str(x), '-h', str(y),
'misc/cheatsheet.svg'])
def main():
"""Regenerate all documentation."""
utils.change_cwd()
print("Generating manpage...")
regenerate_manpage('doc/qutebrowser.1.asciidoc')
print("Generating settings help...")
generate_settings('doc/help/settings.asciidoc')
print("Generating command help...")
generate_commands('doc/help/commands.asciidoc')
if '--no-authors' not in sys.argv:
print("Generating authors in README...")
regenerate_authors('README.asciidoc')
if '--cheatsheet' in sys.argv:
print("Regenerating cheatsheet .pngs")
regenerate_cheatsheet()
if '--html' in sys.argv:
asciidoc2html.main()
if __name__ == '__main__':
main()
|
gpl-3.0
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
19,
199,
3,
6695,
26,
18133,
29,
1548,
570,
2991,
29,
1624,
13,
24,
23014,
29,
20,
5584,
29,
20,
10844,
26,
199,
199,
3,
1898,
6927,
13,
9261,
11040,
269,
5653,
699,
6558,
72,
262,
334,
1918,
27154,
9,
665,
1198,
32,
392,
31127,
14,
1308,
30,
199,
199,
3,
961,
570,
365,
1777,
402,
2173,
31127,
14,
199,
3,
199,
3,
2173,
31127,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
199,
3,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
844,
12,
503,
199,
3,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
2173,
31127,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
3,
3180,
543,
2173,
31127,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
199,
624,
6864,
465,
559,
344,
679,
1350,
367,
2173,
31127,
4079,
641,
20964,
1041,
199,
199,
646,
747,
199,
646,
984,
199,
646,
3517,
199,
646,
5145,
199,
646,
747,
14,
515,
199,
646,
6485,
199,
646,
3873,
199,
646,
5055,
199,
646,
5549,
199,
646,
7534,
199,
199,
1274,
14,
515,
14,
3176,
8,
16,
12,
747,
14,
515,
14,
904,
8,
736,
14,
515,
14,
3475,
3460,
493,
10139,
747,
14,
21386,
12,
1816,
747,
14,
21386,
430,
199,
199,
3,
2136,
492,
2173,
31127,
14,
571,
880,
1006,
768,
1760,
1208,
13,
2683,
20419,
787,
1255,
14,
199,
646,
2173,
31127,
14,
571,
199,
504,
10554,
492,
465,
559,
344,
679,
18,
1360,
12,
3778,
199,
504,
2173,
31127,
492,
2173,
31127,
199,
504,
2173,
31127,
14,
4405,
492,
2088,
1208,
12,
1680,
2087,
199,
504,
2173,
31127,
14,
888,
492,
1101,
576,
199,
504,
2173,
31127,
14,
1208,
492,
18382,
421,
199,
533,
11028,
7772,
8,
18978,
14,
22779,
304,
339,
408,
11173,
379,
15456,
7772,
370,
2387,
2005,
465,
559,
344,
679,
9189,
315,
314,
4503,
14,
339,
961,
1630,
2005,
394,
269,
322,
830,
7645,
12,
1325,
314,
13943,
3955,
506,
370,
295,
21463,
272,
7534,
14,
22779,
1830,
16743,
8806,
5,
402,
314,
1233,
22901,
15,
272,
408,
339,
347,
485,
908,
63,
3807,
8,
277,
12,
4503,
12,
5445,
12,
4652,
12,
485,
1861,
304,
267,
408,
11954,
485,
908,
63,
3807,
370,
440,
1050,
314,
283,
3807,
4881,
2403,
1041,
267,
372,
1613,
19050,
908,
63,
3807,
8,
3807,
12,
5445,
12,
4652,
12,
4074,
339,
347,
485,
362,
63,
885,
63,
23303,
63,
509,
63,
4144,
8,
277,
12,
1595,
304,
267,
408,
2585,
536,
5793,
316,
1380,
10232,
8214,
1041,
267,
372,
1680,
2087,
14,
1273,
63,
354,
8,
1287,
14,
2614,
14,
4142,
1012,
339,
347,
485,
362,
63,
885,
63,
23303,
63,
509,
63,
17867,
8,
277,
12,
1595,
304,
267,
408,
2585,
536,
5793,
316,
1380,
10232,
8214,
1041,
267,
372,
1680,
2087,
14,
1273,
63,
354,
8,
1287,
14,
2614,
9,
339,
347,
485,
23303,
63,
8911,
8,
277,
12,
1595,
12,
849,
63,
23303,
304,
267,
408,
11954,
485,
23303,
63,
8911,
370,
1050,
465,
559,
344,
679,
9189,
370,
3404,
2936,
14,
398,
17536,
1233,
2348,
365,
8876,
687,
2018,
650,
14,
20,
1159,
7534,
14,
647,
14,
267,
408,
267,
340,
1595,
14,
23303,
365,
440,
488,
26,
288,
754,
275,
3546,
2440,
7,
1674,
908,
8,
1287,
14,
23303,
9,
267,
916,
1595,
14,
4577,
365,
440,
488,
26,
288,
7141,
63,
16144,
275,
359,
495,
8,
5095,
9,
367,
7141,
315,
1595,
14,
4577,
61,
288,
754,
275,
661,
1445,
435,
12814,
904,
18225,
2440,
10,
1370,
908,
8,
69,
9,
367,
325,
315,
7141,
63,
16144,
9,
435,
1993,
283,
12216,
267,
587,
26,
288,
754,
275,
3546,
2440,
7,
1674,
908,
8,
885,
63,
23303,
9,
398,
347,
7104,
8,
2960,
63,
890,
304,
288,
408,
3484,
314,
754,
7182,
370,
314,
2008,
1568,
1041,
288,
340,
1228,
8,
1099,
12,
2008,
304,
355,
372,
754,
288,
587,
26,
355,
372,
334,
1099,
12,
776,
627,
2008,
63,
890,
267,
372,
7104,
339,
347,
485,
908,
63,
3723,
63,
3807,
8,
277,
12,
5445,
12,
4652,
304,
267,
408,
11954,
485,
908,
63,
3723,
63,
3807,
370,
1050,
465,
559,
344,
679,
9189,
370,
3285,
14,
398,
13821,
7534,
14,
647,
1159,
485,
908,
63,
3723,
63,
3807,
365,
7437,
6114,
12,
781,
1642,
267,
14198,
13,
2068,
314,
945,
3326,
370,
2387,
314,
465,
559,
344,
679,
9189,
12,
2066,
267,
1255,
314,
3379,
1083,
12,
2066,
18172,
314,
3371,
316,
14,
267,
408,
267,
2269,
63,
1422,
63,
5465,
275,
1052,
267,
367,
1595,
315,
5445,
26,
288,
2269,
63,
1422,
63,
5465,
59,
1287,
61,
275,
1595,
14,
1422,
63,
5465,
5873,
288,
1595,
14,
1422,
63,
5465,
275,
788,
10,
2440,
10,
1370,
908,
8,
83,
9,
3660,
367,
308,
315,
1595,
14,
1422,
63,
5465,
61,
267,
2203,
275,
1613,
19050,
908,
63,
3723,
63,
3807,
8,
3723,
12,
4652,
9,
267,
367,
1595,
315,
5445,
26,
288,
1595,
14,
1422,
63,
5465,
275,
2269,
63,
1422,
63,
5465,
59,
1287,
61,
267,
372,
2203,
421,
199,
318,
485,
1490,
63,
493,
8,
354,
12,
818,
534,
87,
735,
272,
408,
4299,
282,
570,
543,
282,
876,
409,
8057,
15,
2991,
818,
1041,
272,
372,
1551,
8,
354,
12,
818,
12,
8057,
17115,
78,
297,
2644,
534,
1624,
13,
24,
358,
421,
199,
318,
485,
362,
63,
1760,
63,
7093,
1547,
354,
12,
2088,
304,
272,
408,
1002,
314,
1414,
6302,
367,
282,
1414,
14,
339,
2136,
14198,
13,
2068,
314,
1798,
1159,
9698,
63,
533,
2348,
370,
675,
4154,
11028,
7772,
272,
1314,
9584,
2005,
465,
559
] |
[
2647,
15,
1393,
15,
1813,
2366,
19,
199,
3,
6695,
26,
18133,
29,
1548,
570,
2991,
29,
1624,
13,
24,
23014,
29,
20,
5584,
29,
20,
10844,
26,
199,
199,
3,
1898,
6927,
13,
9261,
11040,
269,
5653,
699,
6558,
72,
262,
334,
1918,
27154,
9,
665,
1198,
32,
392,
31127,
14,
1308,
30,
199,
199,
3,
961,
570,
365,
1777,
402,
2173,
31127,
14,
199,
3,
199,
3,
2173,
31127,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
199,
3,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
844,
12,
503,
199,
3,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
2173,
31127,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
3,
3180,
543,
2173,
31127,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
199,
624,
6864,
465,
559,
344,
679,
1350,
367,
2173,
31127,
4079,
641,
20964,
1041,
199,
199,
646,
747,
199,
646,
984,
199,
646,
3517,
199,
646,
5145,
199,
646,
747,
14,
515,
199,
646,
6485,
199,
646,
3873,
199,
646,
5055,
199,
646,
5549,
199,
646,
7534,
199,
199,
1274,
14,
515,
14,
3176,
8,
16,
12,
747,
14,
515,
14,
904,
8,
736,
14,
515,
14,
3475,
3460,
493,
10139,
747,
14,
21386,
12,
1816,
747,
14,
21386,
430,
199,
199,
3,
2136,
492,
2173,
31127,
14,
571,
880,
1006,
768,
1760,
1208,
13,
2683,
20419,
787,
1255,
14,
199,
646,
2173,
31127,
14,
571,
199,
504,
10554,
492,
465,
559,
344,
679,
18,
1360,
12,
3778,
199,
504,
2173,
31127,
492,
2173,
31127,
199,
504,
2173,
31127,
14,
4405,
492,
2088,
1208,
12,
1680,
2087,
199,
504,
2173,
31127,
14,
888,
492,
1101,
576,
199,
504,
2173,
31127,
14,
1208,
492,
18382,
421,
199,
533,
11028,
7772,
8,
18978,
14,
22779,
304,
339,
408,
11173,
379,
15456,
7772,
370,
2387,
2005,
465,
559,
344,
679,
9189,
315,
314,
4503,
14,
339,
961,
1630,
2005,
394,
269,
322,
830,
7645,
12,
1325,
314,
13943,
3955,
506,
370,
295,
21463,
272,
7534,
14,
22779,
1830,
16743,
8806,
5,
402,
314,
1233,
22901,
15,
272,
408,
339,
347,
485,
908,
63,
3807,
8,
277,
12,
4503,
12,
5445,
12,
4652,
12,
485,
1861,
304,
267,
408,
11954,
485,
908,
63,
3807,
370,
440,
1050,
314,
283,
3807,
4881,
2403,
1041,
267,
372,
1613,
19050,
908,
63,
3807,
8,
3807,
12,
5445,
12,
4652,
12,
4074,
339,
347,
485,
362,
63,
885,
63,
23303,
63,
509,
63,
4144,
8,
277,
12,
1595,
304,
267,
408,
2585,
536,
5793,
316,
1380,
10232,
8214,
1041,
267,
372,
1680,
2087,
14,
1273,
63,
354,
8,
1287,
14,
2614,
14,
4142,
1012,
339,
347,
485,
362,
63,
885,
63,
23303,
63,
509,
63,
17867,
8,
277,
12,
1595,
304,
267,
408,
2585,
536,
5793,
316,
1380,
10232,
8214,
1041,
267,
372,
1680,
2087,
14,
1273,
63,
354,
8,
1287,
14,
2614,
9,
339,
347,
485,
23303,
63,
8911,
8,
277,
12,
1595,
12,
849,
63,
23303,
304,
267,
408,
11954,
485,
23303,
63,
8911,
370,
1050,
465,
559,
344,
679,
9189,
370,
3404,
2936,
14,
398,
17536,
1233,
2348,
365,
8876,
687,
2018,
650,
14,
20,
1159,
7534,
14,
647,
14,
267,
408,
267,
340,
1595,
14,
23303,
365,
440,
488,
26,
288,
754,
275,
3546,
2440,
7,
1674,
908,
8,
1287,
14,
23303,
9,
267,
916,
1595,
14,
4577,
365,
440,
488,
26,
288,
7141,
63,
16144,
275,
359,
495,
8,
5095,
9,
367,
7141,
315,
1595,
14,
4577,
61,
288,
754,
275,
661,
1445,
435,
12814,
904,
18225,
2440,
10,
1370,
908,
8,
69,
9,
367,
325,
315,
7141,
63,
16144,
9,
435,
1993,
283,
12216,
267,
587,
26,
288,
754,
275,
3546,
2440,
7,
1674,
908,
8,
885,
63,
23303,
9,
398,
347,
7104,
8,
2960,
63,
890,
304,
288,
408,
3484,
314,
754,
7182,
370,
314,
2008,
1568,
1041,
288,
340,
1228,
8,
1099,
12,
2008,
304,
355,
372,
754,
288,
587,
26,
355,
372,
334,
1099,
12,
776,
627,
2008,
63,
890,
267,
372,
7104,
339,
347,
485,
908,
63,
3723,
63,
3807,
8,
277,
12,
5445,
12,
4652,
304,
267,
408,
11954,
485,
908,
63,
3723,
63,
3807,
370,
1050,
465,
559,
344,
679,
9189,
370,
3285,
14,
398,
13821,
7534,
14,
647,
1159,
485,
908,
63,
3723,
63,
3807,
365,
7437,
6114,
12,
781,
1642,
267,
14198,
13,
2068,
314,
945,
3326,
370,
2387,
314,
465,
559,
344,
679,
9189,
12,
2066,
267,
1255,
314,
3379,
1083,
12,
2066,
18172,
314,
3371,
316,
14,
267,
408,
267,
2269,
63,
1422,
63,
5465,
275,
1052,
267,
367,
1595,
315,
5445,
26,
288,
2269,
63,
1422,
63,
5465,
59,
1287,
61,
275,
1595,
14,
1422,
63,
5465,
5873,
288,
1595,
14,
1422,
63,
5465,
275,
788,
10,
2440,
10,
1370,
908,
8,
83,
9,
3660,
367,
308,
315,
1595,
14,
1422,
63,
5465,
61,
267,
2203,
275,
1613,
19050,
908,
63,
3723,
63,
3807,
8,
3723,
12,
4652,
9,
267,
367,
1595,
315,
5445,
26,
288,
1595,
14,
1422,
63,
5465,
275,
2269,
63,
1422,
63,
5465,
59,
1287,
61,
267,
372,
2203,
421,
199,
318,
485,
1490,
63,
493,
8,
354,
12,
818,
534,
87,
735,
272,
408,
4299,
282,
570,
543,
282,
876,
409,
8057,
15,
2991,
818,
1041,
272,
372,
1551,
8,
354,
12,
818,
12,
8057,
17115,
78,
297,
2644,
534,
1624,
13,
24,
358,
421,
199,
318,
485,
362,
63,
1760,
63,
7093,
1547,
354,
12,
2088,
304,
272,
408,
1002,
314,
1414,
6302,
367,
282,
1414,
14,
339,
2136,
14198,
13,
2068,
314,
1798,
1159,
9698,
63,
533,
2348,
370,
675,
4154,
11028,
7772,
272,
1314,
9584,
2005,
465,
559,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
anthonycodes/Python-Scripts
|
scp/0.3/scp.py
|
1
|
1637
|
# Steganography Cypher Program
# Made by AnthonyCodes
# Source Code: https://github.com/anthonycodes/Python-Scripts/tree/master/scp/
# Imports
import config as conf
import api as appapi
from sys import argv, exit
# Variables
unsecure = conf.unsecure
# Functions
def getstring():
try: arg = argv[1]
except:
print("Please enter a string to encrypt. To encrypt only a space use \"'space'\"")
exit()
try:
arg = argv[2]
longer = True
except:
longer = False
if not longer:
args = argv[1]
else:
indices = [1, len(argv) - 1]
args = " ".join([argv[i] for i in indices])
if argv[1] == "'space'":
args = " "
return args
def phaseone():
result = appapi.convert_string_to_number(getstring())
if unsecure: print("[DEBUG] Phase 1 Result: {}".format(result))
return result
def phasetwo(integer):
result = appapi.convert_scv_to_ptwo_hash(int(integer), conf.hl)
if unsecure: print("[DEBUG] Phase 2 Result: {}".format(result))
return result
def phasethree(string, salt):
result = appapi.two_translate(conf.scv_to_chars, string)
if unsecure: print("[DEBUG] Phase 3 Result: {}".format(result))
newsalt = appapi.translate(conf.salt1, str(salt))
index = 1
while index <= int(salt):
newsalt = appapi.translate(conf.salt2, newsalt)
index += 1
return result, newsalt
def main():
pone = phaseone()
ponepointfive = appapi.split_in_four(pone)
ptwo = phasetwo(ponepointfive)
result, salt = phasethree(ptwo, ponepointfive)
if conf.unsecure: print("{0} : {1}".format(result, salt))
else: print(result)
# Main
if __name__ == "__main__":
main()
|
mit
|
[
3,
17854,
71,
8143,
9773,
18461,
7722,
18841,
202,
199,
3,
603,
9587,
701,
1626,
898,
89,
14060,
202,
199,
3,
5800,
5495,
26,
4178,
921,
5031,
14,
957,
15,
290,
898,
89,
6021,
15,
4718,
13,
25681,
15,
2350,
15,
4133,
15,
17124,
15,
2999,
199,
3,
24339,
202,
199,
646,
1101,
465,
3743,
202,
199,
646,
2986,
465,
2771,
387,
1038,
202,
199,
504,
984,
492,
9238,
12,
4458,
2999,
199,
3,
17198,
202,
199,
324,
7817,
275,
3743,
14,
324,
7817,
2999,
199,
3,
17471,
202,
199,
318,
664,
875,
837,
1223,
198,
893,
26,
1680,
275,
9238,
59,
17,
61,
1223,
198,
2590,
26,
4122,
198,
1361,
480,
8254,
9509,
282,
1059,
370,
14645,
14,
4005,
14645,
1454,
282,
4601,
675,
971,
4507,
2638,
1154,
7230,
4122,
198,
2224,
342,
1223,
198,
893,
26,
4122,
198,
1273,
275,
9238,
59,
18,
61,
4122,
198,
5298,
836,
275,
715,
1223,
198,
2590,
26,
4122,
198,
5298,
836,
275,
756,
1223,
198,
692,
440,
8088,
26,
4122,
198,
589,
275,
9238,
59,
17,
61,
1223,
198,
2836,
26,
4122,
198,
4108,
275,
359,
17,
12,
822,
8,
3020,
9,
446,
413,
61,
26045,
198,
589,
275,
298,
3680,
904,
779,
3020,
59,
73,
61,
367,
284,
315,
4918,
566,
10060,
198,
692,
9238,
59,
17,
61,
508,
3546,
2638,
7,
582,
4122,
198,
589,
275,
298,
298,
10060,
198,
1107,
1249,
2999,
199,
318,
7669,
368,
837,
1223,
198,
1099,
275,
2771,
387,
1038,
14,
3916,
63,
875,
63,
475,
63,
1955,
8,
362,
875,
1012,
1223,
198,
692,
625,
7817,
26,
870,
10994,
5287,
61,
30752,
413,
10695,
26,
8352,
908,
8,
1099,
430,
1223,
198,
1107,
754,
2999,
199,
318,
299,
2411,
409,
2027,
8,
4115,
304,
1223,
198,
1099,
275,
2771,
387,
1038,
14,
3916,
63,
551,
86,
63,
475,
63,
541,
2027,
63,
2227,
8,
442,
8,
4115,
395,
3743,
14,
15544,
9,
1223,
198,
692,
625,
7817,
26,
870,
10994,
5287,
61,
30752,
499,
10695,
26,
8352,
908,
8,
1099,
430,
1223,
198,
1107,
754,
2999,
199,
318,
7669,
10480,
8,
875,
12,
10105,
304,
1223,
198,
1099,
275,
2771,
387,
1038,
14,
5601,
63,
5275,
8,
2190,
14,
551,
86,
63,
475,
63,
6574,
12,
1059,
9,
1223,
198,
692,
625,
7817,
26,
870,
10994,
5287,
61,
30752,
650,
10695,
26,
8352,
908,
8,
1099,
430,
1223,
198,
1222,
12597,
275,
2771,
387,
1038,
14,
5275,
8,
2190,
14,
12597,
17,
12,
620,
8,
12597,
430,
1223,
198,
1080,
275,
413,
1223,
198,
6710,
1478,
2695,
1109,
8,
12597,
304,
4122,
198,
1222,
12597,
275,
2771,
387,
1038,
14,
5275,
8,
2190,
14,
12597,
18,
12,
892,
12597,
9,
4122,
198,
1080,
847,
413,
1223,
198,
1107,
754,
12,
892,
12597,
2999,
199,
318,
2446,
837,
1223,
198,
80,
368,
275,
7669,
368,
342,
1223,
198,
80,
368,
1403,
23702,
275,
2771,
387,
1038,
14,
1294,
63,
262,
63,
13672,
8,
80,
368,
9,
1223,
198,
541,
2027,
275,
299,
2411,
409,
2027,
8,
80,
368,
1403,
23702,
9,
1223,
198,
1099,
12,
10105,
275,
7669,
10480,
8,
541,
2027,
12,
299,
368,
1403,
23702,
9,
1223,
198,
692,
3743,
14,
324,
7817,
26,
870,
13076,
16,
93,
520,
469,
17,
5469,
908,
8,
1099,
12,
10105,
430,
1223,
198,
2836,
26,
870,
8,
1099,
9,
2999,
199,
3,
11298,
202,
199,
692,
636,
354,
363,
508,
4396,
973,
5727,
1223,
198,
973,
342,
1223,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
17854,
71,
8143,
9773,
18461,
7722,
18841,
202,
199,
3,
603,
9587,
701,
1626,
898,
89,
14060,
202,
199,
3,
5800,
5495,
26,
4178,
921,
5031,
14,
957,
15,
290,
898,
89,
6021,
15,
4718,
13,
25681,
15,
2350,
15,
4133,
15,
17124,
15,
2999,
199,
3,
24339,
202,
199,
646,
1101,
465,
3743,
202,
199,
646,
2986,
465,
2771,
387,
1038,
202,
199,
504,
984,
492,
9238,
12,
4458,
2999,
199,
3,
17198,
202,
199,
324,
7817,
275,
3743,
14,
324,
7817,
2999,
199,
3,
17471,
202,
199,
318,
664,
875,
837,
1223,
198,
893,
26,
1680,
275,
9238,
59,
17,
61,
1223,
198,
2590,
26,
4122,
198,
1361,
480,
8254,
9509,
282,
1059,
370,
14645,
14,
4005,
14645,
1454,
282,
4601,
675,
971,
4507,
2638,
1154,
7230,
4122,
198,
2224,
342,
1223,
198,
893,
26,
4122,
198,
1273,
275,
9238,
59,
18,
61,
4122,
198,
5298,
836,
275,
715,
1223,
198,
2590,
26,
4122,
198,
5298,
836,
275,
756,
1223,
198,
692,
440,
8088,
26,
4122,
198,
589,
275,
9238,
59,
17,
61,
1223,
198,
2836,
26,
4122,
198,
4108,
275,
359,
17,
12,
822,
8,
3020,
9,
446,
413,
61,
26045,
198,
589,
275,
298,
3680,
904,
779,
3020,
59,
73,
61,
367,
284,
315,
4918,
566,
10060,
198,
692,
9238,
59,
17,
61,
508,
3546,
2638,
7,
582,
4122,
198,
589,
275,
298,
298,
10060,
198,
1107,
1249,
2999,
199,
318,
7669,
368,
837,
1223,
198,
1099,
275,
2771,
387,
1038,
14,
3916,
63,
875,
63,
475,
63,
1955,
8,
362,
875,
1012,
1223,
198,
692,
625,
7817,
26,
870,
10994,
5287,
61,
30752,
413,
10695,
26,
8352,
908,
8,
1099,
430,
1223,
198,
1107,
754,
2999,
199,
318,
299,
2411,
409,
2027,
8,
4115,
304,
1223,
198,
1099,
275,
2771,
387,
1038,
14,
3916,
63,
551,
86,
63,
475,
63,
541,
2027,
63,
2227,
8,
442,
8,
4115,
395,
3743,
14,
15544,
9,
1223,
198,
692,
625,
7817,
26,
870,
10994,
5287,
61,
30752,
499,
10695,
26,
8352,
908,
8,
1099,
430,
1223,
198,
1107,
754,
2999,
199,
318,
7669,
10480,
8,
875,
12,
10105,
304,
1223,
198,
1099,
275,
2771,
387,
1038,
14,
5601,
63,
5275,
8,
2190,
14,
551,
86,
63,
475,
63,
6574,
12,
1059,
9,
1223,
198,
692,
625,
7817,
26,
870,
10994,
5287,
61,
30752,
650,
10695,
26,
8352,
908,
8,
1099,
430,
1223,
198,
1222,
12597,
275,
2771,
387,
1038,
14,
5275,
8,
2190,
14,
12597,
17,
12,
620,
8,
12597,
430,
1223,
198,
1080,
275,
413,
1223,
198,
6710,
1478,
2695,
1109,
8,
12597,
304,
4122,
198,
1222,
12597,
275,
2771,
387,
1038,
14,
5275,
8,
2190,
14,
12597,
18,
12,
892,
12597,
9,
4122,
198,
1080,
847,
413,
1223,
198,
1107,
754,
12,
892,
12597,
2999,
199,
318,
2446,
837,
1223,
198,
80,
368,
275,
7669,
368,
342,
1223,
198,
80,
368,
1403,
23702,
275,
2771,
387,
1038,
14,
1294,
63,
262,
63,
13672,
8,
80,
368,
9,
1223,
198,
541,
2027,
275,
299,
2411,
409,
2027,
8,
80,
368,
1403,
23702,
9,
1223,
198,
1099,
12,
10105,
275,
7669,
10480,
8,
541,
2027,
12,
299,
368,
1403,
23702,
9,
1223,
198,
692,
3743,
14,
324,
7817,
26,
870,
13076,
16,
93,
520,
469,
17,
5469,
908,
8,
1099,
12,
10105,
430,
1223,
198,
2836,
26,
870,
8,
1099,
9,
2999,
199,
3,
11298,
202,
199,
692,
636,
354,
363,
508,
4396,
973,
5727,
1223,
198,
973,
342,
1223,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
imzers/gsutil-with-php
|
gslib/daisy_chain_wrapper.py
|
26
|
11679
|
# -*- coding: utf-8 -*-
# Copyright 2014 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Wrapper for use in daisy-chained copies."""
from collections import deque
import os
import threading
import time
from gslib.cloud_api import BadRequestException
from gslib.cloud_api import CloudApi
from gslib.util import CreateLock
from gslib.util import TRANSFER_BUFFER_SIZE
# This controls the amount of bytes downloaded per download request.
# We do not buffer this many bytes in memory at a time - that is controlled by
# DaisyChainWrapper.max_buffer_size. This is the upper bound of bytes that may
# be unnecessarily downloaded if there is a break in the resumable upload.
_DEFAULT_DOWNLOAD_CHUNK_SIZE = 1024*1024*100
class BufferWrapper(object):
"""Wraps the download file pointer to use our in-memory buffer."""
def __init__(self, daisy_chain_wrapper):
"""Provides a buffered write interface for a file download.
Args:
daisy_chain_wrapper: DaisyChainWrapper instance to use for buffer and
locking.
"""
self.daisy_chain_wrapper = daisy_chain_wrapper
def write(self, data): # pylint: disable=invalid-name
"""Waits for space in the buffer, then writes data to the buffer."""
while True:
with self.daisy_chain_wrapper.lock:
if (self.daisy_chain_wrapper.bytes_buffered <
self.daisy_chain_wrapper.max_buffer_size):
break
# Buffer was full, yield thread priority so the upload can pull from it.
time.sleep(0)
data_len = len(data)
if data_len:
with self.daisy_chain_wrapper.lock:
self.daisy_chain_wrapper.buffer.append(data)
self.daisy_chain_wrapper.bytes_buffered += data_len
class DaisyChainWrapper(object):
"""Wrapper class for daisy-chaining a cloud download to an upload.
This class instantiates a BufferWrapper object to buffer the download into
memory, consuming a maximum of max_buffer_size. It implements intelligent
behavior around read and seek that allow for all of the operations necessary
to copy a file.
This class is coupled with the XML and JSON implementations in that it
expects that small buffers (maximum of TRANSFER_BUFFER_SIZE) in size will be
used.
"""
def __init__(self, src_url, src_obj_size, gsutil_api, progress_callback=None,
download_chunk_size=_DEFAULT_DOWNLOAD_CHUNK_SIZE):
"""Initializes the daisy chain wrapper.
Args:
src_url: Source CloudUrl to copy from.
src_obj_size: Size of source object.
gsutil_api: gsutil Cloud API to use for the copy.
progress_callback: Optional callback function for progress notifications
for the download thread. Receives calls with arguments
(bytes_transferred, total_size).
download_chunk_size: Integer number of bytes to download per
GetObjectMedia request. This is the upper bound of bytes that may be
unnecessarily downloaded if there is a break in the resumable upload.
"""
# Current read position for the upload file pointer.
self.position = 0
self.buffer = deque()
self.bytes_buffered = 0
# Maximum amount of bytes in memory at a time.
self.max_buffer_size = 1024 * 1024 # 1 MiB
self._download_chunk_size = download_chunk_size
# We save one buffer's worth of data as a special case for boto,
# which seeks back one buffer and rereads to compute hashes. This is
# unnecessary because we can just compare cloud hash digests at the end,
# but it allows this to work without modfiying boto.
self.last_position = 0
self.last_data = None
# Protects buffer, position, bytes_buffered, last_position, and last_data.
self.lock = CreateLock()
# Protects download_exception.
self.download_exception_lock = CreateLock()
self.src_obj_size = src_obj_size
self.src_url = src_url
# This is safe to use the upload and download thread because the download
# thread calls only GetObjectMedia, which creates a new HTTP connection
# independent of gsutil_api. Thus, it will not share an HTTP connection
# with the upload.
self.gsutil_api = gsutil_api
# If self.download_thread dies due to an exception, it is saved here so
# that it can also be raised in the upload thread.
self.download_exception = None
self.download_thread = None
self.progress_callback = progress_callback
self.stop_download = threading.Event()
self.StartDownloadThread(progress_callback=self.progress_callback)
def StartDownloadThread(self, start_byte=0, progress_callback=None):
"""Starts the download thread for the source object (from start_byte)."""
def PerformDownload(start_byte, progress_callback):
"""Downloads the source object in chunks.
This function checks the stop_download event and exits early if it is set.
It should be set when there is an error during the daisy-chain upload,
then this function can be called again with the upload's current position
as start_byte.
Args:
start_byte: Byte from which to begin the download.
progress_callback: Optional callback function for progress
notifications. Receives calls with arguments
(bytes_transferred, total_size).
"""
# TODO: Support resumable downloads. This would require the BufferWrapper
# object to support seek() and tell() which requires coordination with
# the upload.
try:
while start_byte + self._download_chunk_size < self.src_obj_size:
self.gsutil_api.GetObjectMedia(
self.src_url.bucket_name, self.src_url.object_name,
BufferWrapper(self), start_byte=start_byte,
end_byte=start_byte + self._download_chunk_size - 1,
generation=self.src_url.generation, object_size=self.src_obj_size,
download_strategy=CloudApi.DownloadStrategy.ONE_SHOT,
provider=self.src_url.scheme, progress_callback=progress_callback)
if self.stop_download.is_set():
# Download thread needs to be restarted, so exit.
self.stop_download.clear()
return
start_byte += self._download_chunk_size
self.gsutil_api.GetObjectMedia(
self.src_url.bucket_name, self.src_url.object_name,
BufferWrapper(self), start_byte=start_byte,
generation=self.src_url.generation, object_size=self.src_obj_size,
download_strategy=CloudApi.DownloadStrategy.ONE_SHOT,
provider=self.src_url.scheme, progress_callback=progress_callback)
# We catch all exceptions here because we want to store them.
except Exception, e: # pylint: disable=broad-except
# Save the exception so that it can be seen in the upload thread.
with self.download_exception_lock:
self.download_exception = e
raise
# TODO: If we do gzip encoding transforms mid-transfer, this will fail.
self.download_thread = threading.Thread(
target=PerformDownload,
args=(start_byte, progress_callback))
self.download_thread.start()
def read(self, amt=None): # pylint: disable=invalid-name
"""Exposes a stream from the in-memory buffer to the upload."""
if self.position == self.src_obj_size or amt == 0:
# If there is no data left or 0 bytes were requested, return an empty
# string so callers can call still call len() and read(0).
return ''
if amt is None or amt > TRANSFER_BUFFER_SIZE:
raise BadRequestException(
'Invalid HTTP read size %s during daisy chain operation, '
'expected <= %s.' % (amt, TRANSFER_BUFFER_SIZE))
while True:
with self.lock:
if self.buffer:
break
with self.download_exception_lock:
if self.download_exception:
# Download thread died, so we will never recover. Raise the
# exception that killed it.
raise self.download_exception # pylint: disable=raising-bad-type
# Buffer was empty, yield thread priority so the download thread can fill.
time.sleep(0)
with self.lock:
# TODO: Need to handle the caller requesting less than a
# transfer_buffer_size worth of data.
data = self.buffer.popleft()
self.last_position = self.position
self.last_data = data
data_len = len(data)
self.position += data_len
self.bytes_buffered -= data_len
if data_len > amt:
raise BadRequestException(
'Invalid read during daisy chain operation, got data of size '
'%s, expected size %s.' % (data_len, amt))
return data
def tell(self): # pylint: disable=invalid-name
with self.lock:
return self.position
def seek(self, offset, whence=os.SEEK_SET): # pylint: disable=invalid-name
restart_download = False
if whence == os.SEEK_END:
if offset:
raise IOError(
'Invalid seek during daisy chain operation. Non-zero offset %s '
'from os.SEEK_END is not supported' % offset)
with self.lock:
self.last_position = self.position
self.last_data = None
# Safe because we check position against src_obj_size in read.
self.position = self.src_obj_size
elif whence == os.SEEK_SET:
with self.lock:
if offset == self.position:
pass
elif offset == self.last_position:
self.position = self.last_position
if self.last_data:
# If we seek to end and then back, we won't have last_data; we'll
# get it on the next call to read.
self.buffer.appendleft(self.last_data)
self.bytes_buffered += len(self.last_data)
else:
# Once a download is complete, boto seeks to 0 and re-reads to
# compute the hash if an md5 isn't already present (for example a GCS
# composite object), so we have to re-download the whole object.
# Also, when daisy-chaining to a resumable upload, on error the
# service may have received any number of the bytes; the download
# needs to be restarted from that point.
restart_download = True
if restart_download:
self.stop_download.set()
# Consume any remaining bytes in the download thread so that
# the thread can exit, then restart the thread at the desired position.
while self.download_thread.is_alive():
with self.lock:
while self.bytes_buffered:
self.bytes_buffered -= len(self.buffer.popleft())
time.sleep(0)
with self.lock:
self.position = offset
self.buffer = deque()
self.bytes_buffered = 0
self.last_position = 0
self.last_data = None
self.StartDownloadThread(start_byte=offset,
progress_callback=self.progress_callback)
else:
raise IOError('Daisy-chain download wrapper does not support '
'seek mode %s' % whence)
def seekable(self): # pylint: disable=invalid-name
return True
|
apache-2.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
1898,
6927,
4475,
3277,
14,
2900,
5924,
5702,
14,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
3,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
3,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
258,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
624,
4590,
367,
675,
315,
12927,
19765,
13,
4429,
379,
6866,
1041,
199,
199,
504,
5055,
492,
15782,
199,
646,
747,
199,
646,
5796,
199,
646,
900,
199,
199,
504,
29563,
14,
4091,
63,
1246,
492,
8857,
28724,
199,
504,
29563,
14,
4091,
63,
1246,
492,
8142,
7394,
199,
504,
29563,
14,
1974,
492,
2790,
6432,
199,
504,
29563,
14,
1974,
492,
9074,
5622,
15849,
63,
10960,
63,
4305,
421,
199,
3,
961,
13467,
314,
5982,
402,
2783,
13557,
1126,
5235,
1056,
14,
199,
3,
2136,
886,
440,
3335,
642,
5002,
2783,
315,
4402,
737,
282,
900,
446,
626,
365,
22284,
701,
199,
3,
577,
65,
19765,
10720,
4590,
14,
988,
63,
2738,
63,
890,
14,
961,
365,
314,
7008,
3914,
402,
2783,
626,
1443,
199,
3,
506,
625,
685,
19187,
13557,
340,
2337,
365,
282,
2059,
315,
314,
522,
23134,
5802,
14,
199,
63,
3472,
63,
24930,
63,
20512,
63,
4305,
275,
6619,
10,
7727,
10,
1960,
421,
199,
533,
26661,
4590,
8,
785,
304,
523,
408,
55,
8146,
314,
5235,
570,
7849,
370,
675,
4154,
315,
13,
4844,
3335,
1041,
819,
347,
636,
826,
721,
277,
12,
12927,
19765,
63,
4429,
63,
5029,
304,
272,
408,
17473,
282,
20224,
2218,
3217,
367,
282,
570,
5235,
14,
339,
3033,
26,
489,
12927,
19765,
63,
4429,
63,
5029,
26,
577,
65,
19765,
10720,
4590,
1256,
370,
675,
367,
3335,
436,
2574,
27267,
14,
272,
408,
272,
291,
14,
983,
19765,
63,
4429,
63,
5029,
275,
12927,
19765,
63,
4429,
63,
5029,
819,
347,
2218,
8,
277,
12,
666,
304,
221,
327,
4287,
26,
3507,
29,
3197,
13,
354,
272,
408,
24804,
1405,
367,
4601,
315,
314,
3335,
12,
2066,
14511,
666,
370,
314,
3335,
1041,
272,
1830,
715,
26,
489,
543,
291,
14,
983,
19765,
63,
4429,
63,
5029,
14,
831,
26,
267,
340,
334,
277,
14,
983,
19765,
63,
4429,
63,
5029,
14,
2394,
63,
17605,
665,
288,
291,
14,
983,
19765,
63,
4429,
63,
5029,
14,
988,
63,
2738,
63,
890,
304,
881,
2059,
489,
327,
26661,
1990,
2615,
12,
1995,
2462,
7464,
880,
314,
5802,
883,
10299,
687,
652,
14,
489,
900,
14,
4532,
8,
16,
9,
272,
666,
63,
552,
275,
822,
8,
576,
9,
272,
340,
666,
63,
552,
26,
489,
543,
291,
14,
983,
19765,
63,
4429,
63,
5029,
14,
831,
26,
267,
291,
14,
983,
19765,
63,
4429,
63,
5029,
14,
2738,
14,
740,
8,
576,
9,
267,
291,
14,
983,
19765,
63,
4429,
63,
5029,
14,
2394,
63,
17605,
847,
666,
63,
552,
421,
199,
533,
577,
65,
19765,
10720,
4590,
8,
785,
304,
523,
408,
4590,
1021,
367,
12927,
19765,
13,
4429,
316,
282,
8002,
5235,
370,
376,
5802,
14,
819,
961,
1021,
9034,
2335,
282,
26661,
4590,
909,
370,
3335,
314,
5235,
1901,
523,
4402,
12,
406,
26745,
282,
5696,
402,
1390,
63,
2738,
63,
890,
14,
2779,
9031,
4661,
24024,
523,
5953,
6818,
1586,
436,
12005,
626,
2040,
367,
1006,
402,
314,
5331,
5784,
523,
370,
1331,
282,
570,
14,
819,
961,
1021,
365,
512,
10769,
543,
314,
4692,
436,
4840,
12591,
315,
626,
652,
523,
14292,
626,
7425,
19383,
334,
11555,
402,
9074,
5622,
15849,
63,
10960,
63,
4305,
9,
315,
1568,
911,
506,
523,
1202,
14,
523,
408,
819,
347,
636,
826,
721,
277,
12,
2928,
63,
633,
12,
2928,
63,
1113,
63,
890,
12,
24986,
63,
1246,
12,
6696,
63,
3058,
29,
403,
12,
2049,
5235,
63,
4604,
63,
890,
3699,
3472,
63,
24930,
63,
20512,
63,
4305,
304,
272,
408,
23489,
314,
12927,
19765,
6036,
4975,
14,
339,
3033,
26,
489,
2928,
63,
633,
26,
5800,
8142,
6417,
370,
1331,
687,
14,
489,
2928,
63,
1113,
63,
890,
26,
14579,
402,
1350,
909,
14,
489,
24986,
63,
1246,
26,
24986,
8142,
3261,
370,
675,
367,
314,
1331,
14,
489,
6696,
63,
3058,
26,
4879,
3233,
805,
367,
6696,
13116,
881,
367,
314,
5235,
2462,
14,
799,
2375,
397,
4882,
543,
2368,
881,
334,
2394,
63,
1515,
5057,
12,
3141,
63,
890,
680,
489,
5235,
63,
4604,
63,
890,
26,
7225,
1329,
402,
2783,
370,
5235,
1126,
881,
2372,
1692,
11398,
1056,
14,
961,
365,
314,
7008,
3914,
402,
2783,
626,
1443,
506,
881,
625,
685,
19187,
13557,
340,
2337,
365,
282,
2059,
315,
314,
522,
23134,
5802,
14,
339,
408,
272,
327,
9338,
1586,
3421,
367,
314,
5802,
570,
7849,
14,
272,
291,
14,
3124,
275,
378,
272,
291,
14,
2738,
275,
15782,
342,
339,
291,
14,
2394,
63,
17605,
275,
378,
272,
327,
14212,
5982,
402,
2783,
315,
4402,
737,
282,
900,
14,
272,
291,
14,
988,
63,
2738,
63,
890,
275,
6619,
627,
6619,
221,
327,
413,
603,
17587,
339,
291,
423,
4249,
63,
4604,
63,
890,
275,
5235,
63,
4604,
63,
890,
339,
327,
2136,
3354,
1373,
3335,
1159,
25235,
402,
666,
465,
282,
4539,
1930,
367,
6055,
12,
272,
327,
1314,
1937,
6080,
1771,
1373,
3335,
436,
295,
15656,
370,
4526,
14647,
14,
961,
365,
272,
327,
23361,
2952,
781,
883,
2951,
6540,
8002,
2631,
10017,
83,
737,
314,
1284,
12,
272,
327,
1325,
652,
6127,
642,
370,
1736,
1928,
3413,
329,
22440,
6055,
14,
272,
291,
14,
2019,
63,
3124,
275,
378,
272,
291,
14,
2019,
63,
576,
275,
488,
339,
327,
2165
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
1898,
6927,
4475,
3277,
14,
2900,
5924,
5702,
14,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
3,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
3,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
258,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
624,
4590,
367,
675,
315,
12927,
19765,
13,
4429,
379,
6866,
1041,
199,
199,
504,
5055,
492,
15782,
199,
646,
747,
199,
646,
5796,
199,
646,
900,
199,
199,
504,
29563,
14,
4091,
63,
1246,
492,
8857,
28724,
199,
504,
29563,
14,
4091,
63,
1246,
492,
8142,
7394,
199,
504,
29563,
14,
1974,
492,
2790,
6432,
199,
504,
29563,
14,
1974,
492,
9074,
5622,
15849,
63,
10960,
63,
4305,
421,
199,
3,
961,
13467,
314,
5982,
402,
2783,
13557,
1126,
5235,
1056,
14,
199,
3,
2136,
886,
440,
3335,
642,
5002,
2783,
315,
4402,
737,
282,
900,
446,
626,
365,
22284,
701,
199,
3,
577,
65,
19765,
10720,
4590,
14,
988,
63,
2738,
63,
890,
14,
961,
365,
314,
7008,
3914,
402,
2783,
626,
1443,
199,
3,
506,
625,
685,
19187,
13557,
340,
2337,
365,
282,
2059,
315,
314,
522,
23134,
5802,
14,
199,
63,
3472,
63,
24930,
63,
20512,
63,
4305,
275,
6619,
10,
7727,
10,
1960,
421,
199,
533,
26661,
4590,
8,
785,
304,
523,
408,
55,
8146,
314,
5235,
570,
7849,
370,
675,
4154,
315,
13,
4844,
3335,
1041,
819,
347,
636,
826,
721,
277,
12,
12927,
19765,
63,
4429,
63,
5029,
304,
272,
408,
17473,
282,
20224,
2218,
3217,
367,
282,
570,
5235,
14,
339,
3033,
26,
489,
12927,
19765,
63,
4429,
63,
5029,
26,
577,
65,
19765,
10720,
4590,
1256,
370,
675,
367,
3335,
436,
2574,
27267,
14,
272,
408,
272,
291,
14,
983,
19765,
63,
4429,
63,
5029,
275,
12927,
19765,
63,
4429,
63,
5029,
819,
347,
2218,
8,
277,
12,
666,
304,
221,
327,
4287,
26,
3507,
29,
3197,
13,
354,
272,
408,
24804,
1405,
367,
4601,
315,
314,
3335,
12,
2066,
14511,
666,
370,
314,
3335,
1041,
272,
1830,
715,
26,
489,
543,
291,
14,
983,
19765,
63,
4429,
63,
5029,
14,
831,
26,
267,
340,
334,
277,
14,
983,
19765,
63,
4429,
63,
5029,
14,
2394,
63,
17605,
665,
288,
291,
14,
983,
19765,
63,
4429,
63,
5029,
14,
988,
63,
2738,
63,
890,
304,
881,
2059,
489,
327,
26661,
1990,
2615,
12,
1995,
2462,
7464,
880,
314,
5802,
883,
10299,
687,
652,
14,
489,
900,
14,
4532,
8,
16,
9,
272,
666,
63,
552,
275,
822,
8,
576,
9,
272,
340,
666,
63,
552,
26,
489,
543,
291,
14,
983,
19765,
63,
4429,
63,
5029,
14,
831,
26,
267,
291,
14,
983,
19765,
63,
4429,
63,
5029,
14,
2738,
14,
740,
8,
576,
9,
267,
291,
14,
983,
19765,
63,
4429,
63,
5029,
14,
2394,
63,
17605,
847,
666,
63,
552,
421,
199,
533,
577,
65,
19765,
10720,
4590,
8,
785,
304,
523,
408,
4590,
1021,
367,
12927,
19765,
13,
4429,
316,
282,
8002,
5235,
370,
376,
5802,
14,
819,
961,
1021,
9034,
2335,
282,
26661,
4590,
909,
370,
3335,
314,
5235,
1901,
523,
4402,
12,
406,
26745,
282,
5696,
402,
1390,
63,
2738,
63,
890,
14,
2779,
9031,
4661,
24024,
523,
5953,
6818,
1586,
436,
12005,
626,
2040,
367,
1006,
402,
314,
5331,
5784,
523,
370,
1331,
282,
570,
14,
819,
961,
1021,
365,
512,
10769,
543,
314,
4692,
436,
4840,
12591,
315,
626,
652,
523,
14292,
626,
7425,
19383,
334,
11555,
402,
9074,
5622,
15849,
63,
10960,
63,
4305,
9,
315,
1568,
911,
506,
523,
1202,
14,
523,
408,
819,
347,
636,
826,
721,
277,
12,
2928,
63,
633,
12,
2928,
63,
1113,
63,
890,
12,
24986,
63,
1246,
12,
6696,
63,
3058,
29,
403,
12,
2049,
5235,
63,
4604,
63,
890,
3699,
3472,
63,
24930,
63,
20512,
63,
4305,
304,
272,
408,
23489,
314,
12927,
19765,
6036,
4975,
14,
339,
3033,
26,
489,
2928,
63,
633,
26,
5800,
8142,
6417,
370,
1331,
687,
14,
489,
2928,
63,
1113,
63,
890,
26,
14579,
402,
1350,
909,
14,
489,
24986,
63,
1246,
26,
24986,
8142,
3261,
370,
675,
367,
314,
1331,
14,
489,
6696,
63,
3058,
26,
4879,
3233,
805,
367,
6696,
13116,
881,
367,
314,
5235,
2462,
14,
799,
2375,
397,
4882,
543,
2368,
881,
334,
2394,
63,
1515,
5057,
12,
3141,
63,
890,
680,
489,
5235,
63,
4604,
63,
890,
26,
7225,
1329,
402,
2783,
370,
5235,
1126,
881,
2372,
1692,
11398,
1056,
14,
961,
365,
314,
7008,
3914,
402,
2783,
626,
1443,
506,
881,
625,
685,
19187,
13557,
340,
2337,
365,
282,
2059,
315,
314,
522,
23134,
5802,
14,
339,
408,
272,
327,
9338,
1586,
3421,
367,
314,
5802,
570,
7849,
14,
272,
291,
14,
3124,
275,
378,
272,
291,
14,
2738,
275,
15782,
342,
339,
291,
14,
2394,
63,
17605,
275,
378,
272,
327,
14212,
5982,
402,
2783,
315,
4402,
737,
282,
900,
14,
272,
291,
14,
988,
63,
2738,
63,
890,
275,
6619,
627,
6619,
221,
327,
413,
603,
17587,
339,
291,
423,
4249,
63,
4604,
63,
890,
275,
5235,
63,
4604,
63,
890,
339,
327,
2136,
3354,
1373,
3335,
1159,
25235,
402,
666,
465,
282,
4539,
1930,
367,
6055,
12,
272,
327,
1314,
1937,
6080,
1771,
1373,
3335,
436,
295,
15656,
370,
4526,
14647,
14,
961,
365,
272,
327,
23361,
2952,
781,
883,
2951,
6540,
8002,
2631,
10017,
83,
737,
314,
1284,
12,
272,
327,
1325,
652,
6127,
642,
370,
1736,
1928,
3413,
329,
22440,
6055,
14,
272,
291,
14,
2019,
63,
3124,
275,
378,
272,
291,
14,
2019,
63,
576,
275,
488,
339,
327,
2165,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
colinnewell/odoo
|
addons/account/edi/invoice.py
|
342
|
13984
|
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Business Applications
# Copyright (c) 2011-2012 OpenERP S.A. <http://openerp.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp.osv import osv, fields
from openerp.addons.edi import EDIMixin
from werkzeug import url_encode
INVOICE_LINE_EDI_STRUCT = {
'name': True,
'origin': True,
'uos_id': True,
'product_id': True,
'price_unit': True,
'quantity': True,
'discount': True,
# fields used for web preview only - discarded on import
'price_subtotal': True,
}
INVOICE_TAX_LINE_EDI_STRUCT = {
'name': True,
'base': True,
'amount': True,
'manual': True,
'sequence': True,
'base_amount': True,
'tax_amount': True,
}
INVOICE_EDI_STRUCT = {
'name': True,
'origin': True,
'company_id': True, # -> to be changed into partner
'type': True, # -> reversed at import
'internal_number': True, # -> reference at import
'comment': True,
'date_invoice': True,
'date_due': True,
'partner_id': True,
'payment_term': True,
#custom: currency_id
'invoice_line': INVOICE_LINE_EDI_STRUCT,
'tax_line': INVOICE_TAX_LINE_EDI_STRUCT,
# fields used for web preview only - discarded on import
#custom: 'partner_ref'
'amount_total': True,
'amount_untaxed': True,
'amount_tax': True,
}
class account_invoice(osv.osv, EDIMixin):
_inherit = 'account.invoice'
def edi_export(self, cr, uid, records, edi_struct=None, context=None):
"""Exports a supplier or customer invoice"""
edi_struct = dict(edi_struct or INVOICE_EDI_STRUCT)
res_company = self.pool.get('res.company')
res_partner = self.pool.get('res.partner')
edi_doc_list = []
for invoice in records:
# generate the main report
self._edi_generate_report_attachment(cr, uid, invoice, context=context)
edi_doc = super(account_invoice,self).edi_export(cr, uid, [invoice], edi_struct, context)[0]
edi_doc.update({
'company_address': res_company.edi_export_address(cr, uid, invoice.company_id, context=context),
'company_paypal_account': invoice.company_id.paypal_account,
'partner_address': res_partner.edi_export(cr, uid, [invoice.partner_id], context=context)[0],
'currency': self.pool.get('res.currency').edi_export(cr, uid, [invoice.currency_id], context=context)[0],
'partner_ref': invoice.reference or False,
})
edi_doc_list.append(edi_doc)
return edi_doc_list
def _edi_tax_account(self, cr, uid, invoice_type='out_invoice', context=None):
#TODO/FIXME: should select proper Tax Account
account_pool = self.pool.get('account.account')
account_ids = account_pool.search(cr, uid, [('type','<>','view'),('type','<>','income'), ('type', '<>', 'closed')])
tax_account = False
if account_ids:
tax_account = account_pool.browse(cr, uid, account_ids[0])
return tax_account
def _edi_invoice_account(self, cr, uid, partner_id, invoice_type, context=None):
res_partner = self.pool.get('res.partner')
partner = res_partner.browse(cr, uid, partner_id, context=context)
if invoice_type in ('out_invoice', 'out_refund'):
invoice_account = partner.property_account_receivable
else:
invoice_account = partner.property_account_payable
return invoice_account
def _edi_product_account(self, cr, uid, product_id, invoice_type, context=None):
product_pool = self.pool.get('product.product')
product = product_pool.browse(cr, uid, product_id, context=context)
if invoice_type in ('out_invoice','out_refund'):
account = product.property_account_income or product.categ_id.property_account_income_categ
else:
account = product.property_account_expense or product.categ_id.property_account_expense_categ
return account
def _edi_import_company(self, cr, uid, edi_document, context=None):
# TODO: for multi-company setups, we currently import the document in the
# user's current company, but we should perhaps foresee a way to select
# the desired company among the user's allowed companies
self._edi_requires_attributes(('company_id','company_address','type'), edi_document)
res_partner = self.pool.get('res.partner')
xid, company_name = edi_document.pop('company_id')
# Retrofit address info into a unified partner info (changed in v7 - used to keep them separate)
company_address_edi = edi_document.pop('company_address')
company_address_edi['name'] = company_name
company_address_edi['is_company'] = True
company_address_edi['__import_model'] = 'res.partner'
company_address_edi['__id'] = xid # override address ID, as of v7 they should be the same anyway
if company_address_edi.get('logo'):
company_address_edi['image'] = company_address_edi.pop('logo')
invoice_type = edi_document['type']
if invoice_type.startswith('out_'):
company_address_edi['customer'] = True
else:
company_address_edi['supplier'] = True
partner_id = res_partner.edi_import(cr, uid, company_address_edi, context=context)
# modify edi_document to refer to new partner
partner = res_partner.browse(cr, uid, partner_id, context=context)
partner_edi_m2o = self.edi_m2o(cr, uid, partner, context=context)
edi_document['partner_id'] = partner_edi_m2o
edi_document.pop('partner_address', None) # ignored, that's supposed to be our own address!
return partner_id
def edi_import(self, cr, uid, edi_document, context=None):
""" During import, invoices will import the company that is provided in the invoice as
a new partner (e.g. supplier company for a customer invoice will be come a supplier
record for the new invoice.
Summary of tasks that need to be done:
- import company as a new partner, if type==in then supplier=1, else customer=1
- partner_id field is modified to point to the new partner
- company_address data used to add address to new partner
- change type: out_invoice'<->'in_invoice','out_refund'<->'in_refund'
- reference: should contain the value of the 'internal_number'
- reference_type: 'none'
- internal number: reset to False, auto-generated
- journal_id: should be selected based on type: simply put the 'type'
in the context when calling create(), will be selected correctly
- payment_term: if set, create a default one based on name...
- for invoice lines, the account_id value should be taken from the
product's default, i.e. from the default category, as it will not
be provided.
- for tax lines, we disconnect from the invoice.line, so all tax lines
will be of type 'manual', and default accounts should be picked based
on the tax config of the DB where it is imported.
"""
if context is None:
context = {}
self._edi_requires_attributes(('company_id','company_address','type','invoice_line','currency'), edi_document)
# extract currency info
res_currency = self.pool.get('res.currency')
currency_info = edi_document.pop('currency')
currency_id = res_currency.edi_import(cr, uid, currency_info, context=context)
currency = res_currency.browse(cr, uid, currency_id)
edi_document['currency_id'] = self.edi_m2o(cr, uid, currency, context=context)
# change type: out_invoice'<->'in_invoice','out_refund'<->'in_refund'
invoice_type = edi_document['type']
invoice_type = invoice_type.startswith('in_') and invoice_type.replace('in_','out_') or invoice_type.replace('out_','in_')
edi_document['type'] = invoice_type
# import company as a new partner
partner_id = self._edi_import_company(cr, uid, edi_document, context=context)
# Set Account
invoice_account = self._edi_invoice_account(cr, uid, partner_id, invoice_type, context=context)
edi_document['account_id'] = invoice_account and self.edi_m2o(cr, uid, invoice_account, context=context) or False
# reference: should contain the value of the 'internal_number'
edi_document['reference'] = edi_document.get('internal_number', False)
# reference_type: 'none'
edi_document['reference_type'] = 'none'
# internal number: reset to False, auto-generated
edi_document['internal_number'] = False
# discard web preview fields, if present
edi_document.pop('partner_ref', None)
# journal_id: should be selected based on type: simply put the 'type' in the context when calling create(), will be selected correctly
context = dict(context, type=invoice_type)
# for invoice lines, the account_id value should be taken from the product's default, i.e. from the default category, as it will not be provided.
for edi_invoice_line in edi_document['invoice_line']:
product_info = edi_invoice_line['product_id']
product_id = self.edi_import_relation(cr, uid, 'product.product', product_info[1],
product_info[0], context=context)
account = self._edi_product_account(cr, uid, product_id, invoice_type, context=context)
# TODO: could be improved with fiscal positions perhaps
# account = fpos_obj.map_account(cr, uid, fiscal_position_id, account.id)
edi_invoice_line['account_id'] = self.edi_m2o(cr, uid, account, context=context) if account else False
# discard web preview fields, if present
edi_invoice_line.pop('price_subtotal', None)
# for tax lines, we disconnect from the invoice.line, so all tax lines will be of type 'manual', and default accounts should be picked based
# on the tax config of the DB where it is imported.
tax_account = self._edi_tax_account(cr, uid, context=context)
tax_account_info = self.edi_m2o(cr, uid, tax_account, context=context)
for edi_tax_line in edi_document.get('tax_line', []):
edi_tax_line['account_id'] = tax_account_info
edi_tax_line['manual'] = True
return super(account_invoice,self).edi_import(cr, uid, edi_document, context=context)
def _edi_record_display_action(self, cr, uid, id, context=None):
"""Returns an appropriate action definition dict for displaying
the record with ID ``rec_id``.
:param int id: database ID of record to display
:return: action definition dict
"""
action = super(account_invoice,self)._edi_record_display_action(cr, uid, id, context=context)
try:
invoice = self.browse(cr, uid, id, context=context)
if 'out_' in invoice.type:
view_ext_id = 'invoice_form'
journal_type = 'sale'
else:
view_ext_id = 'invoice_supplier_form'
journal_type = 'purchase'
ctx = "{'type': '%s', 'journal_type': '%s'}" % (invoice.type, journal_type)
action.update(context=ctx)
view_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'account', view_ext_id)[1]
action.update(views=[(view_id,'form'), (False, 'tree')])
except ValueError:
# ignore if views are missing
pass
return action
def _edi_paypal_url(self, cr, uid, ids, field, arg, context=None):
res = dict.fromkeys(ids, False)
for inv in self.browse(cr, uid, ids, context=context):
if inv.type == 'out_invoice' and inv.company_id.paypal_account:
params = {
"cmd": "_xclick",
"business": inv.company_id.paypal_account,
"item_name": "%s Invoice %s" % (inv.company_id.name, inv.number or ''),
"invoice": inv.number,
"amount": inv.residual,
"currency_code": inv.currency_id.name,
"button_subtype": "services",
"no_note": "1",
"bn": "OpenERP_Invoice_PayNow_" + inv.currency_id.name,
}
res[inv.id] = "https://www.paypal.com/cgi-bin/webscr?" + url_encode(params)
return res
_columns = {
'paypal_url': fields.function(_edi_paypal_url, type='char', string='Paypal Url'),
}
class account_invoice_line(osv.osv, EDIMixin):
_inherit='account.invoice.line'
class account_invoice_tax(osv.osv, EDIMixin):
_inherit = "account.invoice.tax"
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
agpl-3.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
4605,
199,
3,
199,
3,
259,
7653,
12,
3232,
5800,
23813,
24636,
199,
3,
259,
1898,
334,
67,
9,
7760,
13,
7409,
7653,
428,
14,
33,
14,
665,
1014,
921,
11267,
14,
957,
30,
199,
3,
199,
3,
259,
961,
2240,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
259,
652,
1334,
314,
2895,
402,
314,
1664,
4265,
1696,
1684,
844,
465,
199,
3,
259,
3267,
701,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
199,
3,
259,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
259,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
259,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
259,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
259,
1664,
4265,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
259,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
4265,
1696,
1684,
844,
199,
3,
259,
3180,
543,
642,
2240,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
3,
199,
4605,
199,
504,
5166,
14,
4795,
492,
9506,
12,
1504,
199,
504,
5166,
14,
10788,
14,
6297,
492,
662,
19080,
3774,
199,
199,
504,
10380,
492,
1166,
63,
2143,
199,
199,
568,
10662,
4047,
63,
6174,
63,
7458,
63,
8893,
275,
469,
272,
283,
354,
356,
715,
12,
272,
283,
6493,
356,
715,
12,
272,
283,
20560,
63,
344,
356,
715,
12,
272,
283,
2558,
63,
344,
356,
715,
12,
272,
283,
4777,
63,
3248,
356,
715,
12,
272,
283,
10577,
356,
715,
12,
272,
283,
15446,
356,
715,
12,
339,
327,
1504,
1202,
367,
3330,
19653,
1454,
446,
22002,
641,
492,
272,
283,
4777,
63,
954,
2923,
356,
715,
12,
199,
93,
199,
199,
568,
10662,
4047,
63,
13110,
63,
6174,
63,
7458,
63,
8893,
275,
469,
272,
283,
354,
356,
715,
12,
272,
283,
1095,
356,
715,
12,
272,
283,
4606,
356,
715,
12,
272,
283,
9285,
356,
715,
12,
272,
283,
4041,
356,
715,
12,
272,
283,
1095,
63,
4606,
356,
715,
12,
272,
283,
5530,
63,
4606,
356,
715,
12,
199,
93,
199,
199,
568,
10662,
4047,
63,
7458,
63,
8893,
275,
469,
272,
283,
354,
356,
715,
12,
272,
283,
6493,
356,
715,
12,
272,
283,
4627,
63,
344,
356,
715,
12,
327,
1035,
370,
506,
2896,
1901,
5854,
272,
283,
466,
356,
715,
12,
327,
1035,
10822,
737,
492,
272,
283,
4672,
63,
1955,
356,
715,
12,
327,
1035,
3659,
737,
492,
272,
283,
3349,
356,
715,
12,
272,
283,
602,
63,
5404,
356,
715,
12,
272,
283,
602,
63,
11933,
356,
715,
12,
272,
283,
3899,
63,
344,
356,
715,
12,
272,
283,
7948,
63,
5125,
356,
715,
12,
272,
327,
4229,
26,
9952,
63,
344,
272,
283,
5404,
63,
604,
356,
1621,
10662,
4047,
63,
6174,
63,
7458,
63,
8893,
12,
272,
283,
5530,
63,
604,
356,
1621,
10662,
4047,
63,
13110,
63,
6174,
63,
7458,
63,
8893,
12,
339,
327,
1504,
1202,
367,
3330,
19653,
1454,
446,
22002,
641,
492,
272,
327,
4229,
26,
283,
3899,
63,
1121,
7,
272,
283,
4606,
63,
2923,
356,
715,
12,
272,
283,
4606,
63,
324,
5530,
379,
356,
715,
12,
272,
283,
4606,
63,
5530,
356,
715,
12,
199,
93,
199,
199,
533,
2933,
63,
5404,
8,
4795,
14,
4795,
12,
662,
19080,
3774,
304,
272,
485,
6486,
275,
283,
2048,
14,
5404,
7,
339,
347,
7860,
63,
3790,
8,
277,
12,
2467,
12,
1747,
12,
5767,
12,
7860,
63,
1820,
29,
403,
12,
1067,
29,
403,
304,
267,
408,
920,
5203,
282,
23700,
503,
15229,
8485,
624,
267,
7860,
63,
1820,
275,
1211,
8,
6297,
63,
1820,
503,
1621,
10662,
4047,
63,
7458,
63,
8893,
9,
267,
522,
63,
4627,
275,
291,
14,
2293,
14,
362,
360,
470,
14,
4627,
358,
267,
522,
63,
3899,
275,
291,
14,
2293,
14,
362,
360,
470,
14,
3899,
358,
267,
7860,
63,
1301,
63,
513,
275,
942,
267,
367,
8485,
315,
5767,
26,
288,
327,
3550,
314,
2446,
3622,
288,
291,
423,
6297,
63,
4208,
63,
3070,
63,
8905,
8,
1556,
12,
1747,
12,
8485,
12,
1067,
29,
1100,
9,
288,
7860,
63,
1301,
275,
1613,
8,
2048,
63,
5404,
12,
277,
680,
6297,
63,
3790,
8,
1556,
12,
1747,
12,
359,
5404,
467,
7860,
63,
1820,
12,
1067,
2788,
16,
61,
288,
7860,
63,
1301,
14,
873,
2561,
490,
283,
4627,
63,
1562,
356,
522,
63,
4627,
14,
6297,
63,
3790,
63,
1562,
8,
1556,
12,
1747,
12,
8485,
14,
4627,
63,
344,
12,
1067,
29,
1100,
395,
490,
283,
4627,
63,
25170,
63,
2048,
356,
8485,
14,
4627,
63,
344,
14,
25170,
63,
2048,
12,
490,
283,
3899,
63,
1562,
356,
522,
63,
3899,
14,
6297,
63,
3790,
8,
1556,
12,
1747,
12,
359,
5404,
14,
3899,
63,
344,
467,
1067,
29,
1100,
2788,
16,
467,
490,
283,
4968,
356,
291,
14,
2293,
14,
362,
360,
470,
14,
4968,
1959,
6297,
63,
3790,
8,
1556,
12,
1747,
12,
359,
5404,
14,
4968,
63,
344,
467,
1067,
29,
1100,
2788,
16,
467,
490,
283,
3899,
63,
1121,
356,
8485,
14,
4443,
503,
756,
12,
288,
3828,
288,
7860,
63,
1301,
63,
513,
14,
740,
8,
6297,
63,
1301,
9,
267,
372,
7860,
63,
1301,
63,
513,
339,
347,
485,
6297,
63,
5530,
63,
2048,
8,
277,
12,
2467,
12,
1747,
12,
8485,
63,
466,
534,
548,
63,
5404,
297,
1067,
29,
403,
304,
267,
327,
11768,
15,
31779,
26,
1077,
3504,
5576,
30174,
9973,
267,
2933,
63,
2293,
275,
291,
14,
2293,
14,
362,
360,
2048,
14,
2048,
358,
267,
2933,
63,
1580,
275,
2933,
63,
2293,
14,
1733,
8,
1556,
12,
1747,
12,
4274,
466,
1673,
16137,
1673,
1345,
8157,
466,
1673,
16137,
1673,
23607,
659,
661,
466,
297,
2650,
4206,
283,
5938,
2023,
267,
9067,
63,
2048,
275,
756,
267,
340,
2933,
63,
1580,
26,
288,
9067,
63,
2048,
275,
2933,
63,
2293,
14,
4570,
8,
1556
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
4605,
199,
3,
199,
3,
259,
7653,
12,
3232,
5800,
23813,
24636,
199,
3,
259,
1898,
334,
67,
9,
7760,
13,
7409,
7653,
428,
14,
33,
14,
665,
1014,
921,
11267,
14,
957,
30,
199,
3,
199,
3,
259,
961,
2240,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
259,
652,
1334,
314,
2895,
402,
314,
1664,
4265,
1696,
1684,
844,
465,
199,
3,
259,
3267,
701,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
199,
3,
259,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
259,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
259,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
259,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
259,
1664,
4265,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
259,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
4265,
1696,
1684,
844,
199,
3,
259,
3180,
543,
642,
2240,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
3,
199,
4605,
199,
504,
5166,
14,
4795,
492,
9506,
12,
1504,
199,
504,
5166,
14,
10788,
14,
6297,
492,
662,
19080,
3774,
199,
199,
504,
10380,
492,
1166,
63,
2143,
199,
199,
568,
10662,
4047,
63,
6174,
63,
7458,
63,
8893,
275,
469,
272,
283,
354,
356,
715,
12,
272,
283,
6493,
356,
715,
12,
272,
283,
20560,
63,
344,
356,
715,
12,
272,
283,
2558,
63,
344,
356,
715,
12,
272,
283,
4777,
63,
3248,
356,
715,
12,
272,
283,
10577,
356,
715,
12,
272,
283,
15446,
356,
715,
12,
339,
327,
1504,
1202,
367,
3330,
19653,
1454,
446,
22002,
641,
492,
272,
283,
4777,
63,
954,
2923,
356,
715,
12,
199,
93,
199,
199,
568,
10662,
4047,
63,
13110,
63,
6174,
63,
7458,
63,
8893,
275,
469,
272,
283,
354,
356,
715,
12,
272,
283,
1095,
356,
715,
12,
272,
283,
4606,
356,
715,
12,
272,
283,
9285,
356,
715,
12,
272,
283,
4041,
356,
715,
12,
272,
283,
1095,
63,
4606,
356,
715,
12,
272,
283,
5530,
63,
4606,
356,
715,
12,
199,
93,
199,
199,
568,
10662,
4047,
63,
7458,
63,
8893,
275,
469,
272,
283,
354,
356,
715,
12,
272,
283,
6493,
356,
715,
12,
272,
283,
4627,
63,
344,
356,
715,
12,
327,
1035,
370,
506,
2896,
1901,
5854,
272,
283,
466,
356,
715,
12,
327,
1035,
10822,
737,
492,
272,
283,
4672,
63,
1955,
356,
715,
12,
327,
1035,
3659,
737,
492,
272,
283,
3349,
356,
715,
12,
272,
283,
602,
63,
5404,
356,
715,
12,
272,
283,
602,
63,
11933,
356,
715,
12,
272,
283,
3899,
63,
344,
356,
715,
12,
272,
283,
7948,
63,
5125,
356,
715,
12,
272,
327,
4229,
26,
9952,
63,
344,
272,
283,
5404,
63,
604,
356,
1621,
10662,
4047,
63,
6174,
63,
7458,
63,
8893,
12,
272,
283,
5530,
63,
604,
356,
1621,
10662,
4047,
63,
13110,
63,
6174,
63,
7458,
63,
8893,
12,
339,
327,
1504,
1202,
367,
3330,
19653,
1454,
446,
22002,
641,
492,
272,
327,
4229,
26,
283,
3899,
63,
1121,
7,
272,
283,
4606,
63,
2923,
356,
715,
12,
272,
283,
4606,
63,
324,
5530,
379,
356,
715,
12,
272,
283,
4606,
63,
5530,
356,
715,
12,
199,
93,
199,
199,
533,
2933,
63,
5404,
8,
4795,
14,
4795,
12,
662,
19080,
3774,
304,
272,
485,
6486,
275,
283,
2048,
14,
5404,
7,
339,
347,
7860,
63,
3790,
8,
277,
12,
2467,
12,
1747,
12,
5767,
12,
7860,
63,
1820,
29,
403,
12,
1067,
29,
403,
304,
267,
408,
920,
5203,
282,
23700,
503,
15229,
8485,
624,
267,
7860,
63,
1820,
275,
1211,
8,
6297,
63,
1820,
503,
1621,
10662,
4047,
63,
7458,
63,
8893,
9,
267,
522,
63,
4627,
275,
291,
14,
2293,
14,
362,
360,
470,
14,
4627,
358,
267,
522,
63,
3899,
275,
291,
14,
2293,
14,
362,
360,
470,
14,
3899,
358,
267,
7860,
63,
1301,
63,
513,
275,
942,
267,
367,
8485,
315,
5767,
26,
288,
327,
3550,
314,
2446,
3622,
288,
291,
423,
6297,
63,
4208,
63,
3070,
63,
8905,
8,
1556,
12,
1747,
12,
8485,
12,
1067,
29,
1100,
9,
288,
7860,
63,
1301,
275,
1613,
8,
2048,
63,
5404,
12,
277,
680,
6297,
63,
3790,
8,
1556,
12,
1747,
12,
359,
5404,
467,
7860,
63,
1820,
12,
1067,
2788,
16,
61,
288,
7860,
63,
1301,
14,
873,
2561,
490,
283,
4627,
63,
1562,
356,
522,
63,
4627,
14,
6297,
63,
3790,
63,
1562,
8,
1556,
12,
1747,
12,
8485,
14,
4627,
63,
344,
12,
1067,
29,
1100,
395,
490,
283,
4627,
63,
25170,
63,
2048,
356,
8485,
14,
4627,
63,
344,
14,
25170,
63,
2048,
12,
490,
283,
3899,
63,
1562,
356,
522,
63,
3899,
14,
6297,
63,
3790,
8,
1556,
12,
1747,
12,
359,
5404,
14,
3899,
63,
344,
467,
1067,
29,
1100,
2788,
16,
467,
490,
283,
4968,
356,
291,
14,
2293,
14,
362,
360,
470,
14,
4968,
1959,
6297,
63,
3790,
8,
1556,
12,
1747,
12,
359,
5404,
14,
4968,
63,
344,
467,
1067,
29,
1100,
2788,
16,
467,
490,
283,
3899,
63,
1121,
356,
8485,
14,
4443,
503,
756,
12,
288,
3828,
288,
7860,
63,
1301,
63,
513,
14,
740,
8,
6297,
63,
1301,
9,
267,
372,
7860,
63,
1301,
63,
513,
339,
347,
485,
6297,
63,
5530,
63,
2048,
8,
277,
12,
2467,
12,
1747,
12,
8485,
63,
466,
534,
548,
63,
5404,
297,
1067,
29,
403,
304,
267,
327,
11768,
15,
31779,
26,
1077,
3504,
5576,
30174,
9973,
267,
2933,
63,
2293,
275,
291,
14,
2293,
14,
362,
360,
2048,
14,
2048,
358,
267,
2933,
63,
1580,
275,
2933,
63,
2293,
14,
1733,
8,
1556,
12,
1747,
12,
4274,
466,
1673,
16137,
1673,
1345,
8157,
466,
1673,
16137,
1673,
23607,
659,
661,
466,
297,
2650,
4206,
283,
5938,
2023,
267,
9067,
63,
2048,
275,
756,
267,
340,
2933,
63,
1580,
26,
288,
9067,
63,
2048,
275,
2933,
63,
2293,
14,
4570,
8,
1556,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
kartikdhar/djangotest
|
virt1/lib/python2.7/site-packages/django/db/backends/mysql/introspection.py
|
81
|
8902
|
from collections import namedtuple
from MySQLdb.constants import FIELD_TYPE
from django.db.backends.base.introspection import (
BaseDatabaseIntrospection, FieldInfo, TableInfo,
)
from django.utils.datastructures import OrderedSet
from django.utils.encoding import force_text
FieldInfo = namedtuple('FieldInfo', FieldInfo._fields + ('extra',))
class DatabaseIntrospection(BaseDatabaseIntrospection):
data_types_reverse = {
FIELD_TYPE.BLOB: 'TextField',
FIELD_TYPE.CHAR: 'CharField',
FIELD_TYPE.DECIMAL: 'DecimalField',
FIELD_TYPE.NEWDECIMAL: 'DecimalField',
FIELD_TYPE.DATE: 'DateField',
FIELD_TYPE.DATETIME: 'DateTimeField',
FIELD_TYPE.DOUBLE: 'FloatField',
FIELD_TYPE.FLOAT: 'FloatField',
FIELD_TYPE.INT24: 'IntegerField',
FIELD_TYPE.LONG: 'IntegerField',
FIELD_TYPE.LONGLONG: 'BigIntegerField',
FIELD_TYPE.SHORT: 'SmallIntegerField',
FIELD_TYPE.STRING: 'CharField',
FIELD_TYPE.TIME: 'TimeField',
FIELD_TYPE.TIMESTAMP: 'DateTimeField',
FIELD_TYPE.TINY: 'IntegerField',
FIELD_TYPE.TINY_BLOB: 'TextField',
FIELD_TYPE.MEDIUM_BLOB: 'TextField',
FIELD_TYPE.LONG_BLOB: 'TextField',
FIELD_TYPE.VAR_STRING: 'CharField',
}
def get_field_type(self, data_type, description):
field_type = super(DatabaseIntrospection, self).get_field_type(data_type, description)
if field_type == 'IntegerField' and 'auto_increment' in description.extra:
return 'AutoField'
return field_type
def get_table_list(self, cursor):
"""
Returns a list of table and view names in the current database.
"""
cursor.execute("SHOW FULL TABLES")
return [TableInfo(row[0], {'BASE TABLE': 't', 'VIEW': 'v'}.get(row[1]))
for row in cursor.fetchall()]
def get_table_description(self, cursor, table_name):
"""
Returns a description of the table, with the DB-API cursor.description interface."
"""
# information_schema database gives more accurate results for some figures:
# - varchar length returned by cursor.description is an internal length,
# not visible length (#5725)
# - precision and scale (for decimal fields) (#5014)
# - auto_increment is not available in cursor.description
InfoLine = namedtuple('InfoLine', 'col_name data_type max_len num_prec num_scale extra')
cursor.execute("""
SELECT column_name, data_type, character_maximum_length, numeric_precision, numeric_scale, extra
FROM information_schema.columns
WHERE table_name = %s AND table_schema = DATABASE()""", [table_name])
field_info = {line[0]: InfoLine(*line) for line in cursor.fetchall()}
cursor.execute("SELECT * FROM %s LIMIT 1" % self.connection.ops.quote_name(table_name))
to_int = lambda i: int(i) if i is not None else i
fields = []
for line in cursor.description:
col_name = force_text(line[0])
fields.append(
FieldInfo(*((col_name,)
+ line[1:3]
+ (to_int(field_info[col_name].max_len) or line[3],
to_int(field_info[col_name].num_prec) or line[4],
to_int(field_info[col_name].num_scale) or line[5])
+ (line[6],)
+ (field_info[col_name].extra,)))
)
return fields
def get_relations(self, cursor, table_name):
"""
Returns a dictionary of {field_name: (field_name_other_table, other_table)}
representing all relationships to the given table.
"""
constraints = self.get_key_columns(cursor, table_name)
relations = {}
for my_fieldname, other_table, other_field in constraints:
relations[my_fieldname] = (other_field, other_table)
return relations
def get_key_columns(self, cursor, table_name):
"""
Returns a list of (column_name, referenced_table_name, referenced_column_name) for all
key columns in given table.
"""
key_columns = []
cursor.execute("""
SELECT column_name, referenced_table_name, referenced_column_name
FROM information_schema.key_column_usage
WHERE table_name = %s
AND table_schema = DATABASE()
AND referenced_table_name IS NOT NULL
AND referenced_column_name IS NOT NULL""", [table_name])
key_columns.extend(cursor.fetchall())
return key_columns
def get_indexes(self, cursor, table_name):
cursor.execute("SHOW INDEX FROM %s" % self.connection.ops.quote_name(table_name))
# Do a two-pass search for indexes: on first pass check which indexes
# are multicolumn, on second pass check which single-column indexes
# are present.
rows = list(cursor.fetchall())
multicol_indexes = set()
for row in rows:
if row[3] > 1:
multicol_indexes.add(row[2])
indexes = {}
for row in rows:
if row[2] in multicol_indexes:
continue
if row[4] not in indexes:
indexes[row[4]] = {'primary_key': False, 'unique': False}
# It's possible to have the unique and PK constraints in separate indexes.
if row[2] == 'PRIMARY':
indexes[row[4]]['primary_key'] = True
if not row[1]:
indexes[row[4]]['unique'] = True
return indexes
def get_storage_engine(self, cursor, table_name):
"""
Retrieves the storage engine for a given table. Returns the default
storage engine if the table doesn't exist.
"""
cursor.execute(
"SELECT engine "
"FROM information_schema.tables "
"WHERE table_name = %s", [table_name])
result = cursor.fetchone()
if not result:
return self.connection.features._mysql_storage_engine
return result[0]
def get_constraints(self, cursor, table_name):
"""
Retrieves any constraints or keys (unique, pk, fk, check, index) across one or more columns.
"""
constraints = {}
# Get the actual constraint names and columns
name_query = """
SELECT kc.`constraint_name`, kc.`column_name`,
kc.`referenced_table_name`, kc.`referenced_column_name`
FROM information_schema.key_column_usage AS kc
WHERE
kc.table_schema = %s AND
kc.table_name = %s
"""
cursor.execute(name_query, [self.connection.settings_dict['NAME'], table_name])
for constraint, column, ref_table, ref_column in cursor.fetchall():
if constraint not in constraints:
constraints[constraint] = {
'columns': OrderedSet(),
'primary_key': False,
'unique': False,
'index': False,
'check': False,
'foreign_key': (ref_table, ref_column) if ref_column else None,
}
constraints[constraint]['columns'].add(column)
# Now get the constraint types
type_query = """
SELECT c.constraint_name, c.constraint_type
FROM information_schema.table_constraints AS c
WHERE
c.table_schema = %s AND
c.table_name = %s
"""
cursor.execute(type_query, [self.connection.settings_dict['NAME'], table_name])
for constraint, kind in cursor.fetchall():
if kind.lower() == "primary key":
constraints[constraint]['primary_key'] = True
constraints[constraint]['unique'] = True
elif kind.lower() == "unique":
constraints[constraint]['unique'] = True
# Now add in the indexes
cursor.execute("SHOW INDEX FROM %s" % self.connection.ops.quote_name(table_name))
for table, non_unique, index, colseq, column in [x[:5] for x in cursor.fetchall()]:
if index not in constraints:
constraints[index] = {
'columns': OrderedSet(),
'primary_key': False,
'unique': False,
'index': True,
'check': False,
'foreign_key': None,
}
constraints[index]['index'] = True
constraints[index]['columns'].add(column)
# Convert the sorted sets to lists
for constraint in constraints.values():
constraint['columns'] = list(constraint['columns'])
return constraints
|
mit
|
[
504,
5055,
492,
12863,
199,
199,
504,
25709,
14,
5559,
492,
26130,
63,
2711,
199,
199,
504,
1639,
14,
697,
14,
7765,
14,
1095,
14,
21627,
492,
334,
272,
29103,
30516,
12,
5024,
2354,
12,
6957,
2354,
12,
199,
9,
199,
504,
1639,
14,
1208,
14,
23004,
492,
23617,
199,
504,
1639,
14,
1208,
14,
2991,
492,
3542,
63,
505,
199,
199,
792,
2354,
275,
12863,
360,
792,
2354,
297,
5024,
2354,
423,
955,
435,
661,
2911,
16829,
421,
199,
533,
8692,
30516,
8,
1563,
7243,
30516,
304,
272,
666,
63,
1313,
63,
4471,
275,
469,
267,
26130,
63,
2711,
14,
26275,
26,
283,
6254,
297,
267,
26130,
63,
2711,
14,
5901,
26,
283,
2183,
297,
267,
26130,
63,
2711,
14,
23925,
26,
283,
15975,
297,
267,
26130,
63,
2711,
14,
11365,
23925,
26,
283,
15975,
297,
267,
26130,
63,
2711,
14,
5390,
26,
283,
14071,
297,
267,
26130,
63,
2711,
14,
12488,
26,
283,
4626,
297,
267,
26130,
63,
2711,
14,
14989,
26,
283,
13019,
297,
267,
26130,
63,
2711,
14,
11783,
26,
283,
13019,
297,
267,
26130,
63,
2711,
14,
2919,
1194,
26,
283,
3901,
297,
267,
26130,
63,
2711,
14,
12375,
26,
283,
3901,
297,
267,
26130,
63,
2711,
14,
44,
615,
2226,
7770,
26,
283,
25175,
297,
267,
26130,
63,
2711,
14,
13003,
26,
283,
14640,
297,
267,
26130,
63,
2711,
14,
5353,
26,
283,
2183,
297,
267,
26130,
63,
2711,
14,
4961,
26,
283,
27115,
297,
267,
26130,
63,
2711,
14,
20277,
26,
283,
4626,
297,
267,
26130,
63,
2711,
14,
31178,
26,
283,
3901,
297,
267,
26130,
63,
2711,
14,
31178,
63,
26275,
26,
283,
6254,
297,
267,
26130,
63,
2711,
14,
9754,
2639,
63,
26275,
26,
283,
6254,
297,
267,
26130,
63,
2711,
14,
12375,
63,
26275,
26,
283,
6254,
297,
267,
26130,
63,
2711,
14,
5568,
63,
5353,
26,
283,
2183,
297,
272,
789,
339,
347,
664,
63,
698,
63,
466,
8,
277,
12,
666,
63,
466,
12,
1369,
304,
267,
901,
63,
466,
275,
1613,
8,
7243,
30516,
12,
291,
680,
362,
63,
698,
63,
466,
8,
576,
63,
466,
12,
1369,
9,
267,
340,
901,
63,
466,
508,
283,
3901,
7,
436,
283,
2495,
63,
9728,
7,
315,
1369,
14,
2911,
26,
288,
372,
283,
4378,
7,
267,
372,
901,
63,
466,
339,
347,
664,
63,
1224,
63,
513,
8,
277,
12,
3920,
304,
267,
408,
267,
1803,
282,
769,
402,
1817,
436,
2455,
1561,
315,
314,
1453,
3050,
14,
267,
408,
267,
3920,
14,
2526,
480,
19085,
18530,
377,
17041,
531,
267,
372,
359,
3186,
2354,
8,
1143,
59,
16,
467,
791,
5825,
9934,
356,
283,
84,
297,
283,
12058,
356,
283,
86,
936,
14,
362,
8,
1143,
59,
17,
2459,
355,
367,
1962,
315,
3920,
14,
10174,
5106,
339,
347,
664,
63,
1224,
63,
1802,
8,
277,
12,
3920,
12,
1817,
63,
354,
304,
267,
408,
267,
1803,
282,
1369,
402,
314,
1817,
12,
543,
314,
6249,
13,
3735,
3920,
14,
1802,
3217,
2122,
267,
408,
267,
327,
2556,
63,
3629,
3050,
10557,
1655,
23189,
2058,
367,
2005,
6085,
1482,
26,
267,
327,
446,
31044,
2582,
2138,
701,
3920,
14,
1802,
365,
376,
5007,
2582,
12,
267,
327,
257,
440,
8917,
2582,
15196,
1641,
821,
9,
267,
327,
446,
7151,
436,
4666,
334,
509,
6107,
1504,
9,
15196,
8216,
20,
9,
267,
327,
446,
2599,
63,
9728,
365,
440,
2808,
315,
3920,
14,
1802,
267,
10332,
3049,
275,
12863,
360,
2354,
3049,
297,
283,
761,
63,
354,
666,
63,
466,
1390,
63,
552,
1967,
63,
9218,
1967,
63,
3467,
2402,
358,
267,
3920,
14,
2526,
4852,
288,
10468,
2763,
63,
354,
12,
666,
63,
466,
12,
4528,
63,
11555,
63,
1267,
12,
8950,
63,
6833,
12,
8950,
63,
3467,
12,
2402,
288,
4442,
2556,
63,
3629,
14,
3406,
288,
6038,
1817,
63,
354,
275,
450,
83,
2401,
1817,
63,
3629,
275,
31705,
342,
7208,
359,
1224,
63,
354,
566,
267,
901,
63,
815,
275,
469,
604,
59,
16,
2189,
10332,
3049,
2031,
604,
9,
367,
1004,
315,
3920,
14,
10174,
12737,
398,
3920,
14,
2526,
480,
4859,
627,
4442,
450,
83,
5138,
413,
2,
450,
291,
14,
2105,
14,
1483,
14,
3513,
63,
354,
8,
1224,
63,
354,
430,
267,
370,
63,
442,
275,
2400,
284,
26,
1109,
8,
73,
9,
340,
284,
365,
440,
488,
587,
284,
267,
1504,
275,
942,
267,
367,
1004,
315,
3920,
14,
1802,
26,
288,
1048,
63,
354,
275,
3542,
63,
505,
8,
604,
59,
16,
566,
288,
1504,
14,
740,
8,
355,
5024,
2354,
2031,
1332,
761,
63,
354,
4258,
1169,
435,
1004,
59,
17,
26,
19,
61,
1169,
435,
334,
475,
63,
442,
8,
698,
63,
815,
59,
761,
63,
354,
1055,
988,
63,
552,
9,
503,
1004,
59,
19,
467,
3044,
370,
63,
442,
8,
698,
63,
815,
59,
761,
63,
354,
1055,
1507,
63,
9218,
9,
503,
1004,
59,
20,
467,
3044,
370,
63,
442,
8,
698,
63,
815,
59,
761,
63,
354,
1055,
1507,
63,
3467,
9,
503,
1004,
59,
21,
566,
1169,
435,
334,
604,
59,
22,
467,
9,
1169,
435,
334,
698,
63,
815,
59,
761,
63,
354,
1055,
2911,
20097,
288,
776,
267,
372,
1504,
339,
347,
664,
63,
15741,
8,
277,
12,
3920,
12,
1817,
63,
354,
304,
267,
408,
267,
1803,
282,
2600,
402,
469,
698,
63,
354,
26,
334,
698,
63,
354,
63,
1848,
63,
1224,
12,
1163,
63,
1224,
6769,
267,
6144,
1006,
20045,
370,
314,
1627,
1817,
14,
267,
408,
267,
9565,
275,
291,
14,
362,
63,
498,
63,
3406,
8,
3937,
12,
1817,
63,
354,
9,
267,
16109,
275,
1052,
267,
367,
3002,
63,
13646,
12,
1163,
63,
1224,
12,
1163,
63,
698,
315,
9565,
26,
288,
16109,
59,
1662,
63,
13646,
61,
275,
334,
1848,
63,
698,
12,
1163,
63,
1224,
9,
267,
372,
16109,
339,
347,
664,
63,
498,
63,
3406,
8,
277,
12,
3920,
12,
1817,
63,
354,
304,
267,
408,
267,
1803,
282,
769,
402,
334,
2301,
63,
354,
12,
11812,
63,
1224,
63,
354,
12,
11812,
63,
2301,
63,
354,
9,
367,
1006,
267,
790,
4362,
315,
1627,
1817,
14,
267,
408,
267,
790,
63,
3406,
275
] |
[
5055,
492,
12863,
199,
199,
504,
25709,
14,
5559,
492,
26130,
63,
2711,
199,
199,
504,
1639,
14,
697,
14,
7765,
14,
1095,
14,
21627,
492,
334,
272,
29103,
30516,
12,
5024,
2354,
12,
6957,
2354,
12,
199,
9,
199,
504,
1639,
14,
1208,
14,
23004,
492,
23617,
199,
504,
1639,
14,
1208,
14,
2991,
492,
3542,
63,
505,
199,
199,
792,
2354,
275,
12863,
360,
792,
2354,
297,
5024,
2354,
423,
955,
435,
661,
2911,
16829,
421,
199,
533,
8692,
30516,
8,
1563,
7243,
30516,
304,
272,
666,
63,
1313,
63,
4471,
275,
469,
267,
26130,
63,
2711,
14,
26275,
26,
283,
6254,
297,
267,
26130,
63,
2711,
14,
5901,
26,
283,
2183,
297,
267,
26130,
63,
2711,
14,
23925,
26,
283,
15975,
297,
267,
26130,
63,
2711,
14,
11365,
23925,
26,
283,
15975,
297,
267,
26130,
63,
2711,
14,
5390,
26,
283,
14071,
297,
267,
26130,
63,
2711,
14,
12488,
26,
283,
4626,
297,
267,
26130,
63,
2711,
14,
14989,
26,
283,
13019,
297,
267,
26130,
63,
2711,
14,
11783,
26,
283,
13019,
297,
267,
26130,
63,
2711,
14,
2919,
1194,
26,
283,
3901,
297,
267,
26130,
63,
2711,
14,
12375,
26,
283,
3901,
297,
267,
26130,
63,
2711,
14,
44,
615,
2226,
7770,
26,
283,
25175,
297,
267,
26130,
63,
2711,
14,
13003,
26,
283,
14640,
297,
267,
26130,
63,
2711,
14,
5353,
26,
283,
2183,
297,
267,
26130,
63,
2711,
14,
4961,
26,
283,
27115,
297,
267,
26130,
63,
2711,
14,
20277,
26,
283,
4626,
297,
267,
26130,
63,
2711,
14,
31178,
26,
283,
3901,
297,
267,
26130,
63,
2711,
14,
31178,
63,
26275,
26,
283,
6254,
297,
267,
26130,
63,
2711,
14,
9754,
2639,
63,
26275,
26,
283,
6254,
297,
267,
26130,
63,
2711,
14,
12375,
63,
26275,
26,
283,
6254,
297,
267,
26130,
63,
2711,
14,
5568,
63,
5353,
26,
283,
2183,
297,
272,
789,
339,
347,
664,
63,
698,
63,
466,
8,
277,
12,
666,
63,
466,
12,
1369,
304,
267,
901,
63,
466,
275,
1613,
8,
7243,
30516,
12,
291,
680,
362,
63,
698,
63,
466,
8,
576,
63,
466,
12,
1369,
9,
267,
340,
901,
63,
466,
508,
283,
3901,
7,
436,
283,
2495,
63,
9728,
7,
315,
1369,
14,
2911,
26,
288,
372,
283,
4378,
7,
267,
372,
901,
63,
466,
339,
347,
664,
63,
1224,
63,
513,
8,
277,
12,
3920,
304,
267,
408,
267,
1803,
282,
769,
402,
1817,
436,
2455,
1561,
315,
314,
1453,
3050,
14,
267,
408,
267,
3920,
14,
2526,
480,
19085,
18530,
377,
17041,
531,
267,
372,
359,
3186,
2354,
8,
1143,
59,
16,
467,
791,
5825,
9934,
356,
283,
84,
297,
283,
12058,
356,
283,
86,
936,
14,
362,
8,
1143,
59,
17,
2459,
355,
367,
1962,
315,
3920,
14,
10174,
5106,
339,
347,
664,
63,
1224,
63,
1802,
8,
277,
12,
3920,
12,
1817,
63,
354,
304,
267,
408,
267,
1803,
282,
1369,
402,
314,
1817,
12,
543,
314,
6249,
13,
3735,
3920,
14,
1802,
3217,
2122,
267,
408,
267,
327,
2556,
63,
3629,
3050,
10557,
1655,
23189,
2058,
367,
2005,
6085,
1482,
26,
267,
327,
446,
31044,
2582,
2138,
701,
3920,
14,
1802,
365,
376,
5007,
2582,
12,
267,
327,
257,
440,
8917,
2582,
15196,
1641,
821,
9,
267,
327,
446,
7151,
436,
4666,
334,
509,
6107,
1504,
9,
15196,
8216,
20,
9,
267,
327,
446,
2599,
63,
9728,
365,
440,
2808,
315,
3920,
14,
1802,
267,
10332,
3049,
275,
12863,
360,
2354,
3049,
297,
283,
761,
63,
354,
666,
63,
466,
1390,
63,
552,
1967,
63,
9218,
1967,
63,
3467,
2402,
358,
267,
3920,
14,
2526,
4852,
288,
10468,
2763,
63,
354,
12,
666,
63,
466,
12,
4528,
63,
11555,
63,
1267,
12,
8950,
63,
6833,
12,
8950,
63,
3467,
12,
2402,
288,
4442,
2556,
63,
3629,
14,
3406,
288,
6038,
1817,
63,
354,
275,
450,
83,
2401,
1817,
63,
3629,
275,
31705,
342,
7208,
359,
1224,
63,
354,
566,
267,
901,
63,
815,
275,
469,
604,
59,
16,
2189,
10332,
3049,
2031,
604,
9,
367,
1004,
315,
3920,
14,
10174,
12737,
398,
3920,
14,
2526,
480,
4859,
627,
4442,
450,
83,
5138,
413,
2,
450,
291,
14,
2105,
14,
1483,
14,
3513,
63,
354,
8,
1224,
63,
354,
430,
267,
370,
63,
442,
275,
2400,
284,
26,
1109,
8,
73,
9,
340,
284,
365,
440,
488,
587,
284,
267,
1504,
275,
942,
267,
367,
1004,
315,
3920,
14,
1802,
26,
288,
1048,
63,
354,
275,
3542,
63,
505,
8,
604,
59,
16,
566,
288,
1504,
14,
740,
8,
355,
5024,
2354,
2031,
1332,
761,
63,
354,
4258,
1169,
435,
1004,
59,
17,
26,
19,
61,
1169,
435,
334,
475,
63,
442,
8,
698,
63,
815,
59,
761,
63,
354,
1055,
988,
63,
552,
9,
503,
1004,
59,
19,
467,
3044,
370,
63,
442,
8,
698,
63,
815,
59,
761,
63,
354,
1055,
1507,
63,
9218,
9,
503,
1004,
59,
20,
467,
3044,
370,
63,
442,
8,
698,
63,
815,
59,
761,
63,
354,
1055,
1507,
63,
3467,
9,
503,
1004,
59,
21,
566,
1169,
435,
334,
604,
59,
22,
467,
9,
1169,
435,
334,
698,
63,
815,
59,
761,
63,
354,
1055,
2911,
20097,
288,
776,
267,
372,
1504,
339,
347,
664,
63,
15741,
8,
277,
12,
3920,
12,
1817,
63,
354,
304,
267,
408,
267,
1803,
282,
2600,
402,
469,
698,
63,
354,
26,
334,
698,
63,
354,
63,
1848,
63,
1224,
12,
1163,
63,
1224,
6769,
267,
6144,
1006,
20045,
370,
314,
1627,
1817,
14,
267,
408,
267,
9565,
275,
291,
14,
362,
63,
498,
63,
3406,
8,
3937,
12,
1817,
63,
354,
9,
267,
16109,
275,
1052,
267,
367,
3002,
63,
13646,
12,
1163,
63,
1224,
12,
1163,
63,
698,
315,
9565,
26,
288,
16109,
59,
1662,
63,
13646,
61,
275,
334,
1848,
63,
698,
12,
1163,
63,
1224,
9,
267,
372,
16109,
339,
347,
664,
63,
498,
63,
3406,
8,
277,
12,
3920,
12,
1817,
63,
354,
304,
267,
408,
267,
1803,
282,
769,
402,
334,
2301,
63,
354,
12,
11812,
63,
1224,
63,
354,
12,
11812,
63,
2301,
63,
354,
9,
367,
1006,
267,
790,
4362,
315,
1627,
1817,
14,
267,
408,
267,
790,
63,
3406,
275,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
ltilve/ChromiumGStreamerBackend
|
tools/telemetry/third_party/gsutilz/third_party/boto/boto/datapipeline/__init__.py
|
141
|
1662
|
# Copyright (c) 2014 Amazon.com, Inc. or its affiliates.
# All Rights Reserved
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish, dis-
# tribute, sublicense, and/or sell copies of the Software, and to permit
# persons to whom the Software is furnished to do so, subject to the fol-
# lowing conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
# ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
#
from boto.regioninfo import get_regions
def regions():
"""
Get all available regions for the AWS Datapipeline service.
:rtype: list
:return: A list of :class:`boto.regioninfo.RegionInfo`
"""
from boto.datapipeline.layer1 import DataPipelineConnection
return get_regions('datapipeline', connection_cls=DataPipelineConnection)
def connect_to_region(region_name, **kw_params):
for region in regions():
if region.name == region_name:
return region.connect(**kw_params)
return None
|
bsd-3-clause
|
[
3,
1898,
334,
67,
9,
6927,
14347,
14,
957,
12,
3277,
14,
503,
2399,
29172,
2335,
14,
199,
3,
2900,
5924,
5702,
199,
3,
199,
3,
8779,
365,
11882,
10009,
12,
2867,
402,
11204,
12,
370,
1263,
4954,
12408,
282,
199,
3,
1331,
402,
642,
2032,
436,
4568,
3794,
1584,
334,
1589,
199,
3,
298,
10337,
1288,
370,
7962,
315,
314,
2290,
1928,
10588,
12,
5893,
199,
3,
1928,
12305,
314,
4481,
370,
675,
12,
1331,
12,
2811,
12,
5389,
12,
2780,
12,
2153,
13,
199,
3,
28420,
12,
13473,
12,
436,
15,
269,
12743,
6866,
402,
314,
2290,
12,
436,
370,
11291,
199,
3,
12103,
370,
12676,
314,
2290,
365,
13985,
370,
886,
880,
12,
5420,
370,
314,
1699,
13,
199,
3,
28486,
3704,
26,
199,
3,
199,
3,
710,
3432,
4248,
4245,
436,
642,
4983,
4245,
10989,
506,
5120,
199,
3,
315,
1006,
6866,
503,
13393,
12468,
402,
314,
2290,
14,
199,
3,
199,
3,
2334,
4141,
2281,
7049,
298,
1179,
2281,
401,
2428,
3408,
1634,
1821,
3826,
12,
7168,
199,
3,
1549,
5292,
12,
6931,
5400,
2845,
5471,
2296,
2334,
2990,
1634,
28471,
13,
199,
3,
28463,
12,
3092,
2381,
437,
3115,
3104,
2401,
13229,
14,
1621,
4825,
6461,
199,
3,
7000,
2334,
17632,
6262,
7024,
2381,
1821,
13140,
12,
6736,
1549,
5010,
5603,
12,
199,
3,
7061,
1621,
1261,
9612,
1634,
7066,
12,
7056,
1549,
7334,
12,
7043,
4442,
12,
199,
3,
5738,
1634,
1549,
1621,
11287,
1663,
2334,
4141,
1549,
2334,
4815,
1549,
5010,
13198,
199,
3,
1621,
2334,
4141,
14,
199,
3,
199,
504,
6055,
14,
4551,
815,
492,
664,
63,
11963,
421,
199,
318,
16150,
837,
272,
408,
272,
2372,
1006,
2808,
16150,
367,
314,
10168,
3918,
7379,
2435,
14,
339,
520,
4500,
26,
769,
272,
520,
1107,
26,
437,
769,
402,
520,
533,
1705,
10914,
14,
4551,
815,
14,
10708,
2354,
64,
272,
408,
272,
687,
6055,
14,
576,
7379,
14,
1897,
17,
492,
3918,
17562,
3225,
272,
372,
664,
63,
11963,
360,
576,
7379,
297,
1950,
63,
1886,
29,
1451,
17562,
3225,
9,
421,
199,
318,
4907,
63,
475,
63,
4551,
8,
4551,
63,
354,
12,
1011,
829,
63,
1162,
304,
272,
367,
4897,
315,
16150,
837,
267,
340,
4897,
14,
354,
508,
4897,
63,
354,
26,
288,
372,
4897,
14,
2242,
3682,
829,
63,
1162,
9,
272,
372,
488,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1898,
334,
67,
9,
6927,
14347,
14,
957,
12,
3277,
14,
503,
2399,
29172,
2335,
14,
199,
3,
2900,
5924,
5702,
199,
3,
199,
3,
8779,
365,
11882,
10009,
12,
2867,
402,
11204,
12,
370,
1263,
4954,
12408,
282,
199,
3,
1331,
402,
642,
2032,
436,
4568,
3794,
1584,
334,
1589,
199,
3,
298,
10337,
1288,
370,
7962,
315,
314,
2290,
1928,
10588,
12,
5893,
199,
3,
1928,
12305,
314,
4481,
370,
675,
12,
1331,
12,
2811,
12,
5389,
12,
2780,
12,
2153,
13,
199,
3,
28420,
12,
13473,
12,
436,
15,
269,
12743,
6866,
402,
314,
2290,
12,
436,
370,
11291,
199,
3,
12103,
370,
12676,
314,
2290,
365,
13985,
370,
886,
880,
12,
5420,
370,
314,
1699,
13,
199,
3,
28486,
3704,
26,
199,
3,
199,
3,
710,
3432,
4248,
4245,
436,
642,
4983,
4245,
10989,
506,
5120,
199,
3,
315,
1006,
6866,
503,
13393,
12468,
402,
314,
2290,
14,
199,
3,
199,
3,
2334,
4141,
2281,
7049,
298,
1179,
2281,
401,
2428,
3408,
1634,
1821,
3826,
12,
7168,
199,
3,
1549,
5292,
12,
6931,
5400,
2845,
5471,
2296,
2334,
2990,
1634,
28471,
13,
199,
3,
28463,
12,
3092,
2381,
437,
3115,
3104,
2401,
13229,
14,
1621,
4825,
6461,
199,
3,
7000,
2334,
17632,
6262,
7024,
2381,
1821,
13140,
12,
6736,
1549,
5010,
5603,
12,
199,
3,
7061,
1621,
1261,
9612,
1634,
7066,
12,
7056,
1549,
7334,
12,
7043,
4442,
12,
199,
3,
5738,
1634,
1549,
1621,
11287,
1663,
2334,
4141,
1549,
2334,
4815,
1549,
5010,
13198,
199,
3,
1621,
2334,
4141,
14,
199,
3,
199,
504,
6055,
14,
4551,
815,
492,
664,
63,
11963,
421,
199,
318,
16150,
837,
272,
408,
272,
2372,
1006,
2808,
16150,
367,
314,
10168,
3918,
7379,
2435,
14,
339,
520,
4500,
26,
769,
272,
520,
1107,
26,
437,
769,
402,
520,
533,
1705,
10914,
14,
4551,
815,
14,
10708,
2354,
64,
272,
408,
272,
687,
6055,
14,
576,
7379,
14,
1897,
17,
492,
3918,
17562,
3225,
272,
372,
664,
63,
11963,
360,
576,
7379,
297,
1950,
63,
1886,
29,
1451,
17562,
3225,
9,
421,
199,
318,
4907,
63,
475,
63,
4551,
8,
4551,
63,
354,
12,
1011,
829,
63,
1162,
304,
272,
367,
4897,
315,
16150,
837,
267,
340,
4897,
14,
354,
508,
4897,
63,
354,
26,
288,
372,
4897,
14,
2242,
3682,
829,
63,
1162,
9,
272,
372,
488,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
LSIR/gsn
|
gsn-extra/src/monitoring-plugin/munin/gsn-munin.py
|
3
|
1854
|
#!/usr/bin/python
import urllib
import sys
from collections import defaultdict
def main():
f = urllib.urlopen("http://127.0.0.1:22001/stat")
r = f.read().splitlines()
if len(sys.argv) < 2:
data(r)
if sys.argv[1] == "config":
groups = defaultdict(list)
for k in r:
kk = k.partition(" ")[0].split(".")
groups[(kk[0], kk[1])].append(kk)
for k, v in groups.iteritems():
print "multigraph gsn_%s_%s" % (k[0], k[1])
print "graph_title GSN Server %s %s" % (k[0], k[1])
print "graph_period minute"
for vv in v:
n = "_".join(vv[2:-1])
print "%s.label %s" % (n, " ".join(vv[2:-1]))
if vv[-1] == "counter":
print "%s.min 0" % (n)
print "%s.type DERIVE" % (n)
elif sys.argv[1] == "help":
usage()
else:
data(r)
def data(r):
groups = defaultdict(list)
for k in r:
p = k.partition(" ")
kk = p[0].split(".")
groups[(kk[0], kk[1])].append((kk, p[2]))
for k, v in groups.iteritems():
print "multigraph gsn_%s_%s" % (k[0], k[1])
for vv in v:
print "%s.value %s" % ("_".join(vv[0][2:-1]), vv[1])
sys.exit(0)
def usage():
print ' -----------------------------------------------------------------'
print ' Julien Eberle (julien.eberle@a3.epfl.ch) EPFL, LSIR Feb 2015'
print ' '
print ' Munin plugin for gathering statistics about GSN'
print ' '
print ' config get the graph configuration'
print ' help print this text'
print ' get data from the local GSN server'
print ' -----------------------------------------------------------------'
sys.exit(1)
#-------------------------------
if __name__ == "__main__":
main()
|
gpl-3.0
|
[
3381,
2647,
15,
1393,
15,
1548,
199,
199,
646,
4011,
199,
646,
984,
199,
504,
5055,
492,
10018,
421,
199,
318,
2446,
837,
272,
289,
275,
4011,
14,
10890,
480,
1014,
921,
4195,
14,
16,
14,
16,
14,
17,
26,
1081,
4587,
15,
3736,
531,
272,
519,
275,
289,
14,
739,
1252,
7644,
342,
272,
340,
822,
8,
1274,
14,
3020,
9,
665,
499,
26,
267,
666,
8,
82,
9,
339,
340,
984,
14,
3020,
59,
17,
61,
508,
298,
888,
582,
267,
4652,
275,
10018,
8,
513,
9,
267,
367,
1022,
315,
519,
26,
288,
1022,
75,
275,
1022,
14,
5312,
480,
298,
2788,
16,
1055,
1294,
15857,
288,
4652,
7528,
16247,
59,
16,
467,
1022,
75,
59,
17,
566,
1055,
740,
8,
16247,
9,
398,
367,
1022,
12,
373,
315,
4652,
14,
4611,
837,
288,
870,
298,
3029,
2180,
8763,
78,
4970,
83,
4970,
83,
2,
450,
334,
75,
59,
16,
467,
1022,
59,
17,
566,
288,
870,
298,
2180,
63,
1213,
598,
8199,
7146,
450,
83,
450,
83,
2,
450,
334,
75,
59,
16,
467,
1022,
59,
17,
566,
288,
870,
298,
2180,
63,
5191,
12709,
2,
288,
367,
373,
86,
315,
373,
26,
355,
302,
275,
2668,
1674,
904,
8,
8958,
59,
18,
6809,
17,
566,
355,
870,
2071,
83,
14,
1302,
450,
83,
2,
450,
334,
78,
12,
298,
3680,
904,
8,
8958,
59,
18,
6809,
17,
2459,
355,
340,
373,
86,
1988,
17,
61,
508,
298,
5337,
582,
490,
870,
2071,
83,
14,
827,
378,
2,
450,
334,
78,
9,
490,
870,
2071,
83,
14,
466,
577,
540,
5399,
2,
450,
334,
78,
9,
339,
916,
984,
14,
3020,
59,
17,
61,
508,
298,
3437,
582,
267,
4503,
342,
272,
587,
26,
267,
666,
8,
82,
9,
421,
199,
318,
666,
8,
82,
304,
272,
4652,
275,
10018,
8,
513,
9,
272,
367,
1022,
315,
519,
26,
267,
299,
275,
1022,
14,
5312,
480,
6099,
267,
1022,
75,
275,
299,
59,
16,
1055,
1294,
15857,
267,
4652,
7528,
16247,
59,
16,
467,
1022,
75,
59,
17,
566,
1055,
740,
1332,
16247,
12,
299,
59,
18,
2459,
339,
367,
1022,
12,
373,
315,
4652,
14,
4611,
837,
267,
870,
298,
3029,
2180,
8763,
78,
4970,
83,
4970,
83,
2,
450,
334,
75,
59,
16,
467,
1022,
59,
17,
566,
267,
367,
373,
86,
315,
373,
26,
288,
870,
2071,
83,
14,
585,
450,
83,
2,
450,
1689,
63,
1674,
904,
8,
8958,
59,
16,
1527,
18,
6809,
17,
2522,
373,
86,
59,
17,
566,
272,
984,
14,
2224,
8,
16,
9,
421,
199,
318,
4503,
837,
339,
870,
283,
5620,
15668,
272,
870,
283,
1603,
13987,
287,
662,
605,
274,
334,
74,
13987,
287,
14,
69,
605,
274,
32,
65,
19,
14,
1545,
2327,
14,
335,
9,
31922,
3143,
12,
491,
2684,
50,
21141,
6900,
7,
272,
870,
283,
283,
272,
870,
283,
603,
324,
262,
3589,
367,
13082,
316,
11076,
3595,
598,
8199,
7,
272,
870,
283,
283,
272,
870,
283,
1101,
221,
664,
314,
3343,
2897,
7,
272,
870,
283,
1720,
870,
642,
1318,
7,
272,
870,
283,
664,
666,
687,
314,
2257,
598,
8199,
1654,
7,
272,
870,
283,
5620,
15668,
272,
984,
14,
2224,
8,
17,
9,
199,
199,
32152,
18964,
199,
199,
692,
636,
354,
363,
508,
4396,
973,
5727,
272,
2446,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
2647,
15,
1393,
15,
1548,
199,
199,
646,
4011,
199,
646,
984,
199,
504,
5055,
492,
10018,
421,
199,
318,
2446,
837,
272,
289,
275,
4011,
14,
10890,
480,
1014,
921,
4195,
14,
16,
14,
16,
14,
17,
26,
1081,
4587,
15,
3736,
531,
272,
519,
275,
289,
14,
739,
1252,
7644,
342,
272,
340,
822,
8,
1274,
14,
3020,
9,
665,
499,
26,
267,
666,
8,
82,
9,
339,
340,
984,
14,
3020,
59,
17,
61,
508,
298,
888,
582,
267,
4652,
275,
10018,
8,
513,
9,
267,
367,
1022,
315,
519,
26,
288,
1022,
75,
275,
1022,
14,
5312,
480,
298,
2788,
16,
1055,
1294,
15857,
288,
4652,
7528,
16247,
59,
16,
467,
1022,
75,
59,
17,
566,
1055,
740,
8,
16247,
9,
398,
367,
1022,
12,
373,
315,
4652,
14,
4611,
837,
288,
870,
298,
3029,
2180,
8763,
78,
4970,
83,
4970,
83,
2,
450,
334,
75,
59,
16,
467,
1022,
59,
17,
566,
288,
870,
298,
2180,
63,
1213,
598,
8199,
7146,
450,
83,
450,
83,
2,
450,
334,
75,
59,
16,
467,
1022,
59,
17,
566,
288,
870,
298,
2180,
63,
5191,
12709,
2,
288,
367,
373,
86,
315,
373,
26,
355,
302,
275,
2668,
1674,
904,
8,
8958,
59,
18,
6809,
17,
566,
355,
870,
2071,
83,
14,
1302,
450,
83,
2,
450,
334,
78,
12,
298,
3680,
904,
8,
8958,
59,
18,
6809,
17,
2459,
355,
340,
373,
86,
1988,
17,
61,
508,
298,
5337,
582,
490,
870,
2071,
83,
14,
827,
378,
2,
450,
334,
78,
9,
490,
870,
2071,
83,
14,
466,
577,
540,
5399,
2,
450,
334,
78,
9,
339,
916,
984,
14,
3020,
59,
17,
61,
508,
298,
3437,
582,
267,
4503,
342,
272,
587,
26,
267,
666,
8,
82,
9,
421,
199,
318,
666,
8,
82,
304,
272,
4652,
275,
10018,
8,
513,
9,
272,
367,
1022,
315,
519,
26,
267,
299,
275,
1022,
14,
5312,
480,
6099,
267,
1022,
75,
275,
299,
59,
16,
1055,
1294,
15857,
267,
4652,
7528,
16247,
59,
16,
467,
1022,
75,
59,
17,
566,
1055,
740,
1332,
16247,
12,
299,
59,
18,
2459,
339,
367,
1022,
12,
373,
315,
4652,
14,
4611,
837,
267,
870,
298,
3029,
2180,
8763,
78,
4970,
83,
4970,
83,
2,
450,
334,
75,
59,
16,
467,
1022,
59,
17,
566,
267,
367,
373,
86,
315,
373,
26,
288,
870,
2071,
83,
14,
585,
450,
83,
2,
450,
1689,
63,
1674,
904,
8,
8958,
59,
16,
1527,
18,
6809,
17,
2522,
373,
86,
59,
17,
566,
272,
984,
14,
2224,
8,
16,
9,
421,
199,
318,
4503,
837,
339,
870,
283,
5620,
15668,
272,
870,
283,
1603,
13987,
287,
662,
605,
274,
334,
74,
13987,
287,
14,
69,
605,
274,
32,
65,
19,
14,
1545,
2327,
14,
335,
9,
31922,
3143,
12,
491,
2684,
50,
21141,
6900,
7,
272,
870,
283,
283,
272,
870,
283,
603,
324,
262,
3589,
367,
13082,
316,
11076,
3595,
598,
8199,
7,
272,
870,
283,
283,
272,
870,
283,
1101,
221,
664,
314,
3343,
2897,
7,
272,
870,
283,
1720,
870,
642,
1318,
7,
272,
870,
283,
664,
666,
687,
314,
2257,
598,
8199,
1654,
7,
272,
870,
283,
5620,
15668,
272,
984,
14,
2224,
8,
17,
9,
199,
199,
32152,
18964,
199,
199,
692,
636,
354,
363,
508,
4396,
973,
5727,
272,
2446,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
HwisooSo/gemV-update
|
src/arch/x86/isa/insts/x87/data_transfer_and_conversion/load_or_store_floating_point.py
|
65
|
3563
|
# Copyright (c) 2007 The Hewlett-Packard Development Company
# All rights reserved.
#
# The license below extends only to copyright in the software and shall
# not be construed as granting a license to any other intellectual
# property including but not limited to intellectual property relating
# to a hardware implementation of the functionality of the software
# licensed hereunder. You may use the software subject to the license
# terms below provided that you ensure that this notice is replicated
# unmodified and in its entirety in all distributions of the software,
# modified or unmodified, in source code or in binary form.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met: redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer;
# redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution;
# neither the name of the copyright holders nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# Authors: Gabe Black
microcode = '''
def macroop FLD_M {
ldfp87 ufp1, seg, sib, disp
movfp st(-1), ufp1, spm=-1
};
def macroop FLD_P {
rdip t7
ldfp87 ufp1, seg, riprel, disp
movfp st(-1), ufp1, spm=-1
};
def macroop FLD_R {
movfp st(-1), sti, spm=-1
};
def macroop FLD80_M {
ld t1, seg, sib, "DISPLACEMENT", dataSize=8
ld t2, seg, sib, "DISPLACEMENT + 8", dataSize=2
cvtint_fp80 st(-1), t1, t2, spm=-1
};
def macroop FLD80_P {
rdip t7
ld t1, seg, riprel, "DISPLACEMENT", dataSize=8
ld t2, seg, riprel, "DISPLACEMENT + 8", dataSize=2
cvtint_fp80 st(-1), t1, t2, spm=-1
};
def macroop FST_R {
movfp sti, st(0)
};
def macroop FST_M {
stfp87 st(0), seg, sib, disp
};
def macroop FST_P {
rdip t7
stfp87 st(0), seg, riprel, disp
};
def macroop FSTP_R {
movfp sti, st(0), spm=1
};
def macroop FSTP_M {
movfp ufp1, st(0)
stfp87 ufp1, seg, sib, disp
pop87
};
def macroop FSTP_P {
movfp ufp1, st(0)
rdip t7
stfp87 ufp1, seg, riprel, disp
pop87
};
def macroop FST80P_M {
cvtfp80h_int t1, st(0)
cvtfp80l_int t2, st(0)
st t1, seg, sib, "DISPLACEMENT + 0", dataSize=8
st t2, seg, sib, "DISPLACEMENT + 8", dataSize=2
pop87
};
def macroop FST80P_P {
rdip t7
cvtfp80h_int t1, st(0)
cvtfp80l_int t2, st(0)
st t1, seg, riprel, "DISPLACEMENT + 0", dataSize=8
st t2, seg, riprel, "DISPLACEMENT + 8", dataSize=2
pop87
};
'''
|
bsd-3-clause
|
[
3,
1898,
334,
67,
9,
10219,
710,
27849,
13,
29471,
15290,
15878,
199,
3,
2900,
4481,
4644,
14,
199,
3,
199,
3,
710,
4190,
5084,
16879,
1454,
370,
4248,
315,
314,
2032,
436,
10989,
199,
3,
440,
506,
950,
431,
68,
465,
16085,
316,
282,
4190,
370,
1263,
1163,
27925,
1264,
1061,
199,
3,
3324,
5893,
1325,
440,
13988,
370,
27925,
1264,
1061,
3324,
4668,
1958,
199,
3,
370,
282,
14991,
4514,
402,
314,
9330,
402,
314,
2032,
199,
3,
18233,
2348,
7138,
14,
221,
2047,
1443,
675,
314,
2032,
5420,
370,
314,
4190,
199,
3,
2895,
5084,
2741,
626,
1265,
4868,
626,
642,
4245,
365,
32436,
199,
3,
24214,
436,
315,
2399,
8039,
369,
315,
1006,
10208,
402,
314,
2032,
12,
199,
3,
6042,
503,
24214,
12,
315,
1350,
1233,
503,
315,
3366,
1824,
14,
199,
3,
199,
3,
10114,
436,
675,
315,
1350,
436,
3366,
4513,
12,
543,
503,
1928,
199,
3,
7100,
12,
787,
8211,
2741,
626,
314,
2569,
3704,
787,
199,
3,
7647,
26,
26771,
402,
1350,
1233,
1471,
8074,
314,
3432,
4248,
199,
3,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
27,
199,
3,
26771,
315,
3366,
1824,
1471,
9172,
314,
3432,
4248,
199,
3,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
315,
314,
199,
3,
3794,
436,
15,
269,
1163,
8418,
2741,
543,
314,
4084,
27,
199,
3,
15564,
314,
536,
402,
314,
4248,
31976,
6590,
314,
1561,
402,
2399,
199,
3,
8417,
1443,
506,
1202,
370,
10692,
503,
10016,
7585,
7131,
687,
199,
3,
642,
2032,
1928,
2488,
6791,
5313,
4983,
14,
199,
3,
199,
3,
5749,
4141,
2281,
7049,
6515,
2334,
5877,
8164,
2401,
6483,
199,
3,
298,
1179,
2281,
2,
2401,
1821,
7168,
1549,
5292,
2990,
12,
6931,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
2334,
5292,
2990,
1634,
3169,
2401,
3092,
2381,
199,
3,
437,
3115,
3104,
9315,
9706,
14,
1621,
4825,
6461,
7000,
2334,
5877,
199,
3,
11489,
1549,
6483,
6262,
7024,
2381,
1821,
8703,
12,
9168,
12,
9716,
12,
199,
3,
8820,
12,
9836,
12,
1549,
9110,
6736,
334,
6446,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
9838,
1634,
9103,
9764,
1549,
9714,
27,
9102,
1634,
4815,
12,
199,
3,
7126,
12,
1549,
9206,
27,
1549,
9748,
9831,
9,
9802,
9817,
2401,
5258,
1821,
199,
3,
9815,
1634,
5603,
12,
7061,
1621,
7066,
12,
9644,
5603,
12,
1549,
7056,
199,
3,
334,
6446,
9254,
1549,
7334,
9,
7043,
1621,
1821,
9683,
5738,
1634,
2334,
4815,
199,
3,
1634,
5749,
4141,
12,
9704,
8036,
9691,
1634,
2334,
9726,
1634,
9712,
9784,
14,
199,
3,
199,
3,
6642,
26,
598,
7570,
30593,
199,
199,
6453,
600,
275,
1449,
199,
318,
21308,
481,
6533,
63,
45,
469,
272,
15930,
80,
1555,
26337,
17,
12,
8812,
12,
20417,
12,
9628,
272,
26524,
3997,
410,
2801,
17,
395,
26337,
17,
12,
2249,
77,
4022,
17,
199,
12084,
199,
199,
318,
21308,
481,
6533,
63,
48,
469,
272,
519,
21846,
307,
23,
272,
15930,
80,
1555,
26337,
17,
12,
8812,
12,
8012,
30788,
12,
9628,
272,
26524,
3997,
410,
2801,
17,
395,
26337,
17,
12,
2249,
77,
4022,
17,
199,
12084,
199,
199,
318,
21308,
481,
6533,
63,
50,
469,
272,
26524,
3997,
410,
2801,
17,
395,
410,
73,
12,
2249,
77,
4022,
17,
199,
12084,
199,
199,
318,
21308,
481,
6533,
1257,
63,
45,
469,
272,
8827,
307,
17,
12,
8812,
12,
20417,
12,
298,
6178,
2749,
22194,
401,
18252,
29,
24,
272,
8827,
307,
18,
12,
8812,
12,
20417,
12,
298,
6178,
2749,
22194,
435,
1695,
401,
18252,
29,
18,
272,
286,
5941,
442,
63,
3997,
1257,
410,
2801,
17,
395,
307,
17,
12,
307,
18,
12,
2249,
77,
4022,
17,
199,
12084,
199,
199,
318,
21308,
481,
6533,
1257,
63,
48,
469,
272,
519,
21846,
307,
23,
272,
8827,
307,
17,
12,
8812,
12,
8012,
30788,
12,
298,
6178,
2749,
22194,
401,
18252,
29,
24,
272,
8827,
307,
18,
12,
8812,
12,
8012,
30788,
12,
298,
6178,
2749,
22194,
435,
1695,
401,
18252,
29,
18,
272,
286,
5941,
442,
63,
3997,
1257,
410,
2801,
17,
395,
307,
17,
12,
307,
18,
12,
2249,
77,
4022,
17,
199,
12084,
199,
199,
318,
21308,
481,
840,
63,
50,
469,
272,
26524,
3997,
410,
73,
12,
410,
8,
16,
9,
199,
12084,
199,
199,
318,
21308,
481,
840,
63,
45,
469,
272,
410,
3997,
1555,
410,
8,
16,
395,
8812,
12,
20417,
12,
9628,
199,
12084,
199,
199,
318,
21308,
481,
840,
63,
48,
469,
272,
519,
21846,
307,
23,
272,
410,
3997,
1555,
410,
8,
16,
395,
8812,
12,
8012,
30788,
12,
9628,
199,
12084,
199,
199,
318,
21308,
481,
840,
48,
63,
50,
469,
272,
26524,
3997,
410,
73,
12,
410,
8,
16,
395,
2249,
77,
29,
17,
199,
12084,
199,
199,
318,
21308,
481,
840,
48,
63,
45,
469,
272,
26524,
3997,
26337,
17,
12,
410,
8,
16,
9,
272,
410,
3997,
1555,
26337,
17,
12,
8812,
12,
20417,
12,
9628,
272,
4560,
1555,
199,
12084,
199,
199,
318,
21308,
481,
840,
48,
63,
48,
469,
272,
26524,
3997,
26337,
17,
12,
410,
8,
16,
9,
272,
519,
21846,
307,
23,
272,
410,
3997,
1555,
26337,
17,
12,
8812,
12,
8012,
30788,
12,
9628,
272,
4560,
1555,
199,
12084,
199,
199,
318,
21308,
481,
840,
1257,
48,
63,
45,
221,
469,
272,
6277,
3249,
80,
1257,
72,
63,
442,
307,
17,
12,
410,
8,
16,
9,
272,
6277,
3249,
80,
1257,
76,
63,
442,
307,
18,
12,
410,
8,
16,
9,
272,
410,
307,
17,
12,
8812,
12,
20417,
12,
298,
6178,
2749,
22194,
435,
378,
401,
18252,
29,
24,
272,
410,
307,
18,
12,
8812,
12,
20417,
12,
298,
6178,
2749,
22194,
435,
1695,
401,
18252,
29,
18,
272,
4560,
1555,
199,
12084,
199,
199,
318,
21308,
481,
840,
1257,
48,
63,
48,
221,
469,
272,
519,
21846,
307,
23,
272,
6277,
3249,
80,
1257,
72,
63,
442,
307,
17,
12,
410,
8,
16,
9,
272,
6277,
3249,
80,
1257,
76,
63,
442,
307,
18,
12,
410,
8,
16,
9,
272,
410,
307,
17,
12,
8812,
12,
8012,
30788,
12,
298,
6178,
2749,
22194,
435,
378
] |
[
1898,
334,
67,
9,
10219,
710,
27849,
13,
29471,
15290,
15878,
199,
3,
2900,
4481,
4644,
14,
199,
3,
199,
3,
710,
4190,
5084,
16879,
1454,
370,
4248,
315,
314,
2032,
436,
10989,
199,
3,
440,
506,
950,
431,
68,
465,
16085,
316,
282,
4190,
370,
1263,
1163,
27925,
1264,
1061,
199,
3,
3324,
5893,
1325,
440,
13988,
370,
27925,
1264,
1061,
3324,
4668,
1958,
199,
3,
370,
282,
14991,
4514,
402,
314,
9330,
402,
314,
2032,
199,
3,
18233,
2348,
7138,
14,
221,
2047,
1443,
675,
314,
2032,
5420,
370,
314,
4190,
199,
3,
2895,
5084,
2741,
626,
1265,
4868,
626,
642,
4245,
365,
32436,
199,
3,
24214,
436,
315,
2399,
8039,
369,
315,
1006,
10208,
402,
314,
2032,
12,
199,
3,
6042,
503,
24214,
12,
315,
1350,
1233,
503,
315,
3366,
1824,
14,
199,
3,
199,
3,
10114,
436,
675,
315,
1350,
436,
3366,
4513,
12,
543,
503,
1928,
199,
3,
7100,
12,
787,
8211,
2741,
626,
314,
2569,
3704,
787,
199,
3,
7647,
26,
26771,
402,
1350,
1233,
1471,
8074,
314,
3432,
4248,
199,
3,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
27,
199,
3,
26771,
315,
3366,
1824,
1471,
9172,
314,
3432,
4248,
199,
3,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
315,
314,
199,
3,
3794,
436,
15,
269,
1163,
8418,
2741,
543,
314,
4084,
27,
199,
3,
15564,
314,
536,
402,
314,
4248,
31976,
6590,
314,
1561,
402,
2399,
199,
3,
8417,
1443,
506,
1202,
370,
10692,
503,
10016,
7585,
7131,
687,
199,
3,
642,
2032,
1928,
2488,
6791,
5313,
4983,
14,
199,
3,
199,
3,
5749,
4141,
2281,
7049,
6515,
2334,
5877,
8164,
2401,
6483,
199,
3,
298,
1179,
2281,
2,
2401,
1821,
7168,
1549,
5292,
2990,
12,
6931,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
2334,
5292,
2990,
1634,
3169,
2401,
3092,
2381,
199,
3,
437,
3115,
3104,
9315,
9706,
14,
1621,
4825,
6461,
7000,
2334,
5877,
199,
3,
11489,
1549,
6483,
6262,
7024,
2381,
1821,
8703,
12,
9168,
12,
9716,
12,
199,
3,
8820,
12,
9836,
12,
1549,
9110,
6736,
334,
6446,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
9838,
1634,
9103,
9764,
1549,
9714,
27,
9102,
1634,
4815,
12,
199,
3,
7126,
12,
1549,
9206,
27,
1549,
9748,
9831,
9,
9802,
9817,
2401,
5258,
1821,
199,
3,
9815,
1634,
5603,
12,
7061,
1621,
7066,
12,
9644,
5603,
12,
1549,
7056,
199,
3,
334,
6446,
9254,
1549,
7334,
9,
7043,
1621,
1821,
9683,
5738,
1634,
2334,
4815,
199,
3,
1634,
5749,
4141,
12,
9704,
8036,
9691,
1634,
2334,
9726,
1634,
9712,
9784,
14,
199,
3,
199,
3,
6642,
26,
598,
7570,
30593,
199,
199,
6453,
600,
275,
1449,
199,
318,
21308,
481,
6533,
63,
45,
469,
272,
15930,
80,
1555,
26337,
17,
12,
8812,
12,
20417,
12,
9628,
272,
26524,
3997,
410,
2801,
17,
395,
26337,
17,
12,
2249,
77,
4022,
17,
199,
12084,
199,
199,
318,
21308,
481,
6533,
63,
48,
469,
272,
519,
21846,
307,
23,
272,
15930,
80,
1555,
26337,
17,
12,
8812,
12,
8012,
30788,
12,
9628,
272,
26524,
3997,
410,
2801,
17,
395,
26337,
17,
12,
2249,
77,
4022,
17,
199,
12084,
199,
199,
318,
21308,
481,
6533,
63,
50,
469,
272,
26524,
3997,
410,
2801,
17,
395,
410,
73,
12,
2249,
77,
4022,
17,
199,
12084,
199,
199,
318,
21308,
481,
6533,
1257,
63,
45,
469,
272,
8827,
307,
17,
12,
8812,
12,
20417,
12,
298,
6178,
2749,
22194,
401,
18252,
29,
24,
272,
8827,
307,
18,
12,
8812,
12,
20417,
12,
298,
6178,
2749,
22194,
435,
1695,
401,
18252,
29,
18,
272,
286,
5941,
442,
63,
3997,
1257,
410,
2801,
17,
395,
307,
17,
12,
307,
18,
12,
2249,
77,
4022,
17,
199,
12084,
199,
199,
318,
21308,
481,
6533,
1257,
63,
48,
469,
272,
519,
21846,
307,
23,
272,
8827,
307,
17,
12,
8812,
12,
8012,
30788,
12,
298,
6178,
2749,
22194,
401,
18252,
29,
24,
272,
8827,
307,
18,
12,
8812,
12,
8012,
30788,
12,
298,
6178,
2749,
22194,
435,
1695,
401,
18252,
29,
18,
272,
286,
5941,
442,
63,
3997,
1257,
410,
2801,
17,
395,
307,
17,
12,
307,
18,
12,
2249,
77,
4022,
17,
199,
12084,
199,
199,
318,
21308,
481,
840,
63,
50,
469,
272,
26524,
3997,
410,
73,
12,
410,
8,
16,
9,
199,
12084,
199,
199,
318,
21308,
481,
840,
63,
45,
469,
272,
410,
3997,
1555,
410,
8,
16,
395,
8812,
12,
20417,
12,
9628,
199,
12084,
199,
199,
318,
21308,
481,
840,
63,
48,
469,
272,
519,
21846,
307,
23,
272,
410,
3997,
1555,
410,
8,
16,
395,
8812,
12,
8012,
30788,
12,
9628,
199,
12084,
199,
199,
318,
21308,
481,
840,
48,
63,
50,
469,
272,
26524,
3997,
410,
73,
12,
410,
8,
16,
395,
2249,
77,
29,
17,
199,
12084,
199,
199,
318,
21308,
481,
840,
48,
63,
45,
469,
272,
26524,
3997,
26337,
17,
12,
410,
8,
16,
9,
272,
410,
3997,
1555,
26337,
17,
12,
8812,
12,
20417,
12,
9628,
272,
4560,
1555,
199,
12084,
199,
199,
318,
21308,
481,
840,
48,
63,
48,
469,
272,
26524,
3997,
26337,
17,
12,
410,
8,
16,
9,
272,
519,
21846,
307,
23,
272,
410,
3997,
1555,
26337,
17,
12,
8812,
12,
8012,
30788,
12,
9628,
272,
4560,
1555,
199,
12084,
199,
199,
318,
21308,
481,
840,
1257,
48,
63,
45,
221,
469,
272,
6277,
3249,
80,
1257,
72,
63,
442,
307,
17,
12,
410,
8,
16,
9,
272,
6277,
3249,
80,
1257,
76,
63,
442,
307,
18,
12,
410,
8,
16,
9,
272,
410,
307,
17,
12,
8812,
12,
20417,
12,
298,
6178,
2749,
22194,
435,
378,
401,
18252,
29,
24,
272,
410,
307,
18,
12,
8812,
12,
20417,
12,
298,
6178,
2749,
22194,
435,
1695,
401,
18252,
29,
18,
272,
4560,
1555,
199,
12084,
199,
199,
318,
21308,
481,
840,
1257,
48,
63,
48,
221,
469,
272,
519,
21846,
307,
23,
272,
6277,
3249,
80,
1257,
72,
63,
442,
307,
17,
12,
410,
8,
16,
9,
272,
6277,
3249,
80,
1257,
76,
63,
442,
307,
18,
12,
410,
8,
16,
9,
272,
410,
307,
17,
12,
8812,
12,
8012,
30788,
12,
298,
6178,
2749,
22194,
435,
378,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
pkg-ime/ibus
|
ibus/interface/iibus.py
|
2
|
2579
|
# vim:set et sts=4 sw=4:
#
# ibus - The Input Bus
#
# Copyright (c) 2007-2010 Peng Huang <shawn.p.huang@gmail.com>
# Copyright (c) 2007-2010 Red Hat, Inc.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this program; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place, Suite 330,
# Boston, MA 02111-1307 USA
__all__ = ("IIBus", )
import dbus.service
from ibus.common import \
IBUS_IFACE_IBUS, \
IBUS_IFACE_CONFIG
class IIBus(dbus.service.Object):
# define method decorator.
method = lambda **args: \
dbus.service.method(dbus_interface=IBUS_IFACE_IBUS, \
connection_keyword="dbusconn", \
**args)
# define async method decorator.
async_method = lambda **args: \
dbus.service.method(dbus_interface=IBUS_IFACE_IBUS, \
connection_keyword="dbusconn", \
async_callbacks=("reply_cb", "error_cb"), \
**args)
# define signal decorator.
signal = lambda **args: \
dbus.service.signal(dbus_interface=IBUS_IFACE_IBUS, \
**args)
@method(out_signature="s")
def GetAddress(self, dbusconn): pass
# methods for ibus clients
@method(in_signature="s", out_signature="o")
def CreateInputContext(self, client_name, dbusconn): pass
@method(out_signature="o")
def CurrentInputContext(self, dbusconn): pass
# general methods
@method(in_signature="av")
def RegisterComponent(self, components, dbusconn): pass
@method(out_signature="av")
def ListEngines(self, dbusconn): pass
@method(out_signature="av")
def ListActiveEngines(self, dbusconn): pass
@method(in_signature="s")
def SetGlobalEngine(self, name, dbusconn):pass
@method(in_signature="b")
def Exit(self, restart, dbusconn): pass
@method(in_signature="v", out_signature="v")
def Ping(self, data, dbusconn): pass
@signal(signature="")
def RegistryChanged(self): pass
|
lgpl-2.1
|
[
3,
6695,
26,
409,
10844,
23014,
29,
20,
5584,
29,
20,
26,
199,
3,
199,
3,
284,
5610,
446,
710,
6924,
18573,
199,
3,
199,
3,
1898,
334,
67,
9,
10219,
13,
6542,
510,
7420,
869,
85,
621,
665,
4835,
3501,
14,
80,
14,
10616,
621,
32,
6799,
14,
957,
30,
199,
3,
1898,
334,
67,
9,
10219,
13,
6542,
9572,
13002,
12,
3277,
14,
199,
3,
199,
3,
961,
3555,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
199,
3,
2811,
652,
1334,
314,
2895,
402,
314,
1664,
6401,
1696,
1684,
199,
3,
844,
465,
3267,
701,
314,
2868,
2290,
2752,
27,
1902,
199,
3,
1015,
499,
402,
314,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
961,
3555,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
1664,
6401,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
6401,
1696,
1684,
199,
3,
844,
3180,
543,
642,
2240,
27,
340,
440,
12,
2218,
370,
314,
199,
3,
2868,
2290,
2752,
12,
3277,
2020,
8155,
15630,
10902,
12,
14453,
13540,
12,
199,
3,
8226,
12,
4828,
221,
15673,
13,
13421,
221,
8217,
199,
199,
363,
452,
363,
275,
1689,
41,
2100,
527,
401,
776,
199,
199,
646,
21140,
14,
1364,
199,
504,
284,
5610,
14,
2330,
492,
971,
272,
473,
24753,
63,
4656,
4121,
63,
2100,
1668,
12,
971,
272,
473,
24753,
63,
4656,
4121,
63,
5569,
199,
199,
533,
473,
2100,
527,
8,
17066,
14,
1364,
14,
1692,
304,
272,
327,
5627,
1083,
7531,
14,
272,
1083,
275,
2400,
1011,
589,
26,
971,
267,
21140,
14,
1364,
14,
765,
8,
17066,
63,
3266,
29,
2100,
1668,
63,
4656,
4121,
63,
2100,
1668,
12,
971,
1169,
1950,
63,
6691,
628,
17066,
1631,
401,
971,
1169,
1011,
589,
9,
339,
327,
5627,
5316,
1083,
7531,
14,
272,
5316,
63,
765,
275,
2400,
1011,
589,
26,
971,
267,
21140,
14,
1364,
14,
765,
8,
17066,
63,
3266,
29,
2100,
1668,
63,
4656,
4121,
63,
2100,
1668,
12,
971,
1169,
1950,
63,
6691,
628,
17066,
1631,
401,
971,
1169,
5316,
63,
11948,
15387,
8102,
63,
2894,
401,
298,
705,
63,
2894,
1288,
971,
1169,
1011,
589,
9,
339,
327,
5627,
4673,
7531,
14,
272,
4673,
275,
2400,
1011,
589,
26,
971,
267,
21140,
14,
1364,
14,
4653,
8,
17066,
63,
3266,
29,
2100,
1668,
63,
4656,
4121,
63,
2100,
1668,
12,
971,
288,
1011,
589,
9,
339,
768,
765,
8,
548,
63,
5233,
628,
83,
531,
272,
347,
2372,
1476,
8,
277,
12,
21140,
1631,
304,
986,
339,
327,
3102,
367,
284,
5610,
13431,
272,
768,
765,
8,
262,
63,
5233,
628,
83,
401,
734,
63,
5233,
628,
79,
531,
272,
347,
2790,
3205,
2998,
8,
277,
12,
1890,
63,
354,
12,
21140,
1631,
304,
986,
339,
768,
765,
8,
548,
63,
5233,
628,
79,
531,
272,
347,
9338,
3205,
2998,
8,
277,
12,
21140,
1631,
304,
986,
339,
327,
8605,
3102,
272,
768,
765,
8,
262,
63,
5233,
628,
1214,
531,
272,
347,
11828,
7004,
8,
277,
12,
7323,
12,
21140,
1631,
304,
986,
339,
768,
765,
8,
548,
63,
5233,
628,
1214,
531,
272,
347,
3820,
1327,
18131,
8,
277,
12,
21140,
1631,
304,
986,
339,
768,
765,
8,
548,
63,
5233,
628,
1214,
531,
272,
347,
3820,
7472,
1327,
18131,
8,
277,
12,
21140,
1631,
304,
986,
339,
768,
765,
8,
262,
63,
5233,
628,
83,
531,
272,
347,
2494,
7025,
8524,
8,
277,
12,
536,
12,
21140,
1631,
304,
1529,
339,
768,
765,
8,
262,
63,
5233,
628,
66,
531,
272,
347,
18704,
8,
277,
12,
11004,
12,
21140,
1631,
304,
986,
339,
768,
765,
8,
262,
63,
5233,
628,
86,
401,
734,
63,
5233,
628,
86,
531,
272,
347,
510,
316,
8,
277,
12,
666,
12,
21140,
1631,
304,
986,
339,
768,
4653,
8,
5233,
18413,
272,
347,
20738,
6970,
8,
277,
304,
986,
421,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
6695,
26,
409,
10844,
23014,
29,
20,
5584,
29,
20,
26,
199,
3,
199,
3,
284,
5610,
446,
710,
6924,
18573,
199,
3,
199,
3,
1898,
334,
67,
9,
10219,
13,
6542,
510,
7420,
869,
85,
621,
665,
4835,
3501,
14,
80,
14,
10616,
621,
32,
6799,
14,
957,
30,
199,
3,
1898,
334,
67,
9,
10219,
13,
6542,
9572,
13002,
12,
3277,
14,
199,
3,
199,
3,
961,
3555,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
199,
3,
2811,
652,
1334,
314,
2895,
402,
314,
1664,
6401,
1696,
1684,
199,
3,
844,
465,
3267,
701,
314,
2868,
2290,
2752,
27,
1902,
199,
3,
1015,
499,
402,
314,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
961,
3555,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
1664,
6401,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
6401,
1696,
1684,
199,
3,
844,
3180,
543,
642,
2240,
27,
340,
440,
12,
2218,
370,
314,
199,
3,
2868,
2290,
2752,
12,
3277,
2020,
8155,
15630,
10902,
12,
14453,
13540,
12,
199,
3,
8226,
12,
4828,
221,
15673,
13,
13421,
221,
8217,
199,
199,
363,
452,
363,
275,
1689,
41,
2100,
527,
401,
776,
199,
199,
646,
21140,
14,
1364,
199,
504,
284,
5610,
14,
2330,
492,
971,
272,
473,
24753,
63,
4656,
4121,
63,
2100,
1668,
12,
971,
272,
473,
24753,
63,
4656,
4121,
63,
5569,
199,
199,
533,
473,
2100,
527,
8,
17066,
14,
1364,
14,
1692,
304,
272,
327,
5627,
1083,
7531,
14,
272,
1083,
275,
2400,
1011,
589,
26,
971,
267,
21140,
14,
1364,
14,
765,
8,
17066,
63,
3266,
29,
2100,
1668,
63,
4656,
4121,
63,
2100,
1668,
12,
971,
1169,
1950,
63,
6691,
628,
17066,
1631,
401,
971,
1169,
1011,
589,
9,
339,
327,
5627,
5316,
1083,
7531,
14,
272,
5316,
63,
765,
275,
2400,
1011,
589,
26,
971,
267,
21140,
14,
1364,
14,
765,
8,
17066,
63,
3266,
29,
2100,
1668,
63,
4656,
4121,
63,
2100,
1668,
12,
971,
1169,
1950,
63,
6691,
628,
17066,
1631,
401,
971,
1169,
5316,
63,
11948,
15387,
8102,
63,
2894,
401,
298,
705,
63,
2894,
1288,
971,
1169,
1011,
589,
9,
339,
327,
5627,
4673,
7531,
14,
272,
4673,
275,
2400,
1011,
589,
26,
971,
267,
21140,
14,
1364,
14,
4653,
8,
17066,
63,
3266,
29,
2100,
1668,
63,
4656,
4121,
63,
2100,
1668,
12,
971,
288,
1011,
589,
9,
339,
768,
765,
8,
548,
63,
5233,
628,
83,
531,
272,
347,
2372,
1476,
8,
277,
12,
21140,
1631,
304,
986,
339,
327,
3102,
367,
284,
5610,
13431,
272,
768,
765,
8,
262,
63,
5233,
628,
83,
401,
734,
63,
5233,
628,
79,
531,
272,
347,
2790,
3205,
2998,
8,
277,
12,
1890,
63,
354,
12,
21140,
1631,
304,
986,
339,
768,
765,
8,
548,
63,
5233,
628,
79,
531,
272,
347,
9338,
3205,
2998,
8,
277,
12,
21140,
1631,
304,
986,
339,
327,
8605,
3102,
272,
768,
765,
8,
262,
63,
5233,
628,
1214,
531,
272,
347,
11828,
7004,
8,
277,
12,
7323,
12,
21140,
1631,
304,
986,
339,
768,
765,
8,
548,
63,
5233,
628,
1214,
531,
272,
347,
3820,
1327,
18131,
8,
277,
12,
21140,
1631,
304,
986,
339,
768,
765,
8,
548,
63,
5233,
628,
1214,
531,
272,
347,
3820,
7472,
1327,
18131,
8,
277,
12,
21140,
1631,
304,
986,
339,
768,
765,
8,
262,
63,
5233,
628,
83,
531,
272,
347,
2494,
7025,
8524,
8,
277,
12,
536,
12,
21140,
1631,
304,
1529,
339,
768,
765,
8,
262,
63,
5233,
628,
66,
531,
272,
347,
18704,
8,
277,
12,
11004,
12,
21140,
1631,
304,
986,
339,
768,
765,
8,
262,
63,
5233,
628,
86,
401,
734,
63,
5233,
628,
86,
531,
272,
347,
510,
316,
8,
277,
12,
666,
12,
21140,
1631,
304,
986,
339,
768,
4653,
8,
5233,
18413,
272,
347,
20738,
6970,
8,
277,
304,
986,
421,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
TaskEvolution/Task-Coach-Evolution
|
taskcoach/taskcoachlib/thirdparty/xhtml2pdf/xhtml2pdf_reportlab.py
|
14
|
31590
|
# -*- coding: utf-8 -*-
# Copyright 2010 Dirk Holtwick, holtwick.it
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from hashlib import md5
from reportlab.lib.enums import TA_RIGHT
from reportlab.lib.styles import ParagraphStyle
from reportlab.lib.utils import flatten, open_for_read, getStringIO, \
LazyImageReader, haveImages
from reportlab.platypus.doctemplate import BaseDocTemplate, PageTemplate, IndexingFlowable
from reportlab.platypus.flowables import Flowable, CondPageBreak, \
KeepInFrame, ParagraphAndImage
from reportlab.platypus.tableofcontents import TableOfContents
from reportlab.platypus.tables import Table, TableStyle
from xhtml2pdf.reportlab_paragraph import Paragraph
from xhtml2pdf.util import getUID, getBorderStyle
from types import StringType, TupleType, ListType, IntType
import StringIO
import cgi
import copy
import logging
import reportlab.pdfbase.pdfform as pdfform
import sys
try:
import PIL.Image as PILImage
except:
try:
import Image as PILImage
except:
PILImage = None
log = logging.getLogger("xhtml2pdf")
MAX_IMAGE_RATIO = 0.95
class PTCycle(list):
def __init__(self):
self._restart = 0
self._idx = 0
list.__init__(self)
def cyclicIterator(self):
while 1:
yield self[self._idx]
self._idx += 1
if self._idx >= len(self):
self._idx = self._restart
class PmlMaxHeightMixIn:
def setMaxHeight(self, availHeight):
self.availHeightValue = availHeight
if availHeight < 70000:
if hasattr(self, "canv"):
if not hasattr(self.canv, "maxAvailHeightValue"):
self.canv.maxAvailHeightValue = 0
self.availHeightValue = self.canv.maxAvailHeightValue = max(
availHeight,
self.canv.maxAvailHeightValue)
else:
self.availHeightValue = availHeight
if not hasattr(self, "availHeightValue"):
self.availHeightValue = 0
return self.availHeightValue
def getMaxHeight(self):
if not hasattr(self, "availHeightValue"):
return 0
return self.availHeightValue
class PmlBaseDoc(BaseDocTemplate):
"""
We use our own document template to get access to the canvas
and set some informations once.
"""
def beforePage(self):
# Tricky way to set producer, because of not real privateness in Python
info = "pisa HTML to PDF <http://www.htmltopdf.org>"
self.canv._doc.info.producer = info
'''
# Convert to ASCII because there is a Bug in Reportlab not
# supporting other than ASCII. Send to list on 23.1.2007
author = toString(self.pml_data.get("author", "")).encode("ascii","ignore")
subject = toString(self.pml_data.get("subject", "")).encode("ascii","ignore")
title = toString(self.pml_data.get("title", "")).encode("ascii","ignore")
# print repr((author,title,subject))
self.canv.setAuthor(author)
self.canv.setSubject(subject)
self.canv.setTitle(title)
if self.pml_data.get("fullscreen", 0):
self.canv.showFullScreen0()
if self.pml_data.get("showoutline", 0):
self.canv.showOutline()
if self.pml_data.get("duration", None) is not None:
self.canv.setPageDuration(self.pml_data["duration"])
'''
def afterFlowable(self, flowable):
# Does the flowable contain fragments?
if getattr(flowable, "outline", False):
self.notify('TOCEntry', (
flowable.outlineLevel,
cgi.escape(copy.deepcopy(flowable.text), 1),
self.page))
def handle_nextPageTemplate(self, pt):
'''
if pt has also templates for even and odd page convert it to list
'''
has_left_template = self._has_template_for_name(pt + '_left')
has_right_template = self._has_template_for_name(pt + '_right')
if has_left_template and has_right_template:
pt = [pt + '_left', pt + '_right']
'''On endPage change to the page template with name or index pt'''
if type(pt) is StringType:
if hasattr(self, '_nextPageTemplateCycle'):
del self._nextPageTemplateCycle
for t in self.pageTemplates:
if t.id == pt:
self._nextPageTemplateIndex = self.pageTemplates.index(t)
return
raise ValueError("can't find template('%s')" % pt)
elif type(pt) is IntType:
if hasattr(self, '_nextPageTemplateCycle'):
del self._nextPageTemplateCycle
self._nextPageTemplateIndex = pt
elif type(pt) in (ListType, TupleType):
#used for alternating left/right pages
#collect the refs to the template objects, complain if any are bad
c = PTCycle()
for ptn in pt:
#special case name used to short circuit the iteration
if ptn == '*':
c._restart = len(c)
continue
for t in self.pageTemplates:
if t.id == ptn.strip():
c.append(t)
break
if not c:
raise ValueError("No valid page templates in cycle")
elif c._restart > len(c):
raise ValueError("Invalid cycle restart position")
#ensure we start on the first one$
self._nextPageTemplateCycle = c.cyclicIterator()
else:
raise TypeError("Argument pt should be string or integer or list")
def _has_template_for_name(self, name):
for template in self.pageTemplates:
if template.id == name.strip():
return True
return False
class PmlPageTemplate(PageTemplate):
PORTRAIT = 'portrait'
LANDSCAPE = 'landscape'
# by default portrait
pageorientation = PORTRAIT
def __init__(self, **kw):
self.pisaStaticList = []
self.pisaBackgroundList = []
self.pisaBackground = None
PageTemplate.__init__(self, **kw)
self._page_count = 0
self._first_flow = True
def isFirstFlow(self, canvas):
if self._first_flow:
if canvas.getPageNumber() <= self._page_count:
self._first_flow = False
else:
self._page_count = canvas.getPageNumber()
return self._first_flow
def isPortrait(self):
return self.pageorientation == self.PORTRAIT
def isLandscape(self):
return self.pageorientation == self.LANDSCAPE
def beforeDrawPage(self, canvas, doc):
canvas.saveState()
try:
# Background
pisaBackground = None
if (self.isFirstFlow(canvas)
and hasattr(self, "pisaBackground")
and self.pisaBackground
and (not self.pisaBackground.notFound())):
# Is image not PDF
if self.pisaBackground.mimetype.startswith("image/"):
try:
img = PmlImageReader(StringIO.StringIO(self.pisaBackground.getData()))
iw, ih = img.getSize()
pw, ph = canvas._pagesize
width = pw # min(iw, pw) # max
wfactor = float(width) / iw
height = ph # min(ih, ph) # max
hfactor = float(height) / ih
factor_min = min(wfactor, hfactor)
if self.isPortrait():
w = iw * factor_min
h = ih * factor_min
canvas.drawImage(img, 0, ph - h, w, h)
elif self.isLandscape():
factor_max = max(wfactor, hfactor)
w = ih * factor_max
h = iw * factor_min
canvas.drawImage(img, 0, 0, w, h)
except:
log.exception("Draw background")
# PDF!
else:
pisaBackground = self.pisaBackground
if pisaBackground:
self.pisaBackgroundList.append(pisaBackground)
def pageNumbering(objList):
for obj in flatten(objList):
if isinstance(obj, PmlParagraph):
for frag in obj.frags:
if frag.pageNumber:
frag.text = str(pagenumber)
elif frag.pageCount:
frag.text = str(self._page_count)
elif isinstance(obj, PmlTable):
# Flatten the cells ([[1,2], [3,4]] becomes [1,2,3,4])
flat_cells = [item for sublist in obj._cellvalues for item in sublist]
pageNumbering(flat_cells)
try:
# Paint static frames
pagenumber = canvas.getPageNumber()
for frame in self.pisaStaticList:
frame = copy.deepcopy(frame)
story = frame.pisaStaticStory
pageNumbering(story)
frame.addFromList(story, canvas)
except Exception: # TODO: Kill this!
log.debug("PmlPageTemplate", exc_info=1)
finally:
canvas.restoreState()
_ctr = 1
class PmlImageReader(object): # TODO We need a factory here, returning either a class for java or a class for PIL
"""
Wraps up either PIL or Java to get data from bitmaps
"""
_cache = {}
def __init__(self, fileName):
if isinstance(fileName, PmlImageReader):
self.__dict__ = fileName.__dict__ # borgize
return
#start wih lots of null private fields, to be populated by
#the relevant engine.
self.fileName = fileName
self._image = None
self._width = None
self._height = None
self._transparent = None
self._data = None
imageReaderFlags = 0
if PILImage and isinstance(fileName, PILImage.Image):
self._image = fileName
self.fp = getattr(fileName, 'fp', None)
try:
self.fileName = self._image.fileName
except AttributeError:
self.fileName = 'PILIMAGE_%d' % id(self)
else:
try:
self.fp = open_for_read(fileName, 'b')
if isinstance(self.fp, StringIO.StringIO().__class__):
imageReaderFlags = 0 # avoid messing with already internal files
if imageReaderFlags > 0: # interning
data = self.fp.read()
if imageReaderFlags & 2: # autoclose
try:
self.fp.close()
except:
pass
if imageReaderFlags & 4: # cache the data
if not self._cache:
from rl_config import register_reset
register_reset(self._cache.clear)
data = self._cache.setdefault(md5(data).digest(), data)
self.fp = getStringIO(data)
elif imageReaderFlags == - 1 and isinstance(fileName, (str, unicode)):
#try Ralf Schmitt's re-opening technique of avoiding too many open files
self.fp.close()
del self.fp # will become a property in the next statement
self.__class__ = LazyImageReader
if haveImages:
#detect which library we are using and open the image
if not self._image:
self._image = self._read_image(self.fp)
if getattr(self._image, 'format', None) == 'JPEG':
self.jpeg_fh = self._jpeg_fh
else:
from reportlab.pdfbase.pdfutils import readJPEGInfo
try:
self._width, self._height, c = readJPEGInfo(self.fp)
except:
raise RuntimeError('Imaging Library not available, unable to import bitmaps only jpegs')
self.jpeg_fh = self._jpeg_fh
self._data = self.fp.read()
self._dataA = None
self.fp.seek(0)
except: # TODO: Kill the catch-all
et, ev, tb = sys.exc_info()
if hasattr(ev, 'args'):
a = str(ev.args[- 1]) + (' fileName=%r' % fileName)
ev.args = ev.args[: - 1] + (a,)
raise et, ev, tb
else:
raise
def _read_image(self, fp):
if sys.platform[0:4] == 'java':
from javax.imageio import ImageIO
return ImageIO.read(fp)
elif PILImage:
return PILImage.open(fp)
def _jpeg_fh(self):
fp = self.fp
fp.seek(0)
return fp
def jpeg_fh(self):
return None
def getSize(self):
if self._width is None or self._height is None:
if sys.platform[0:4] == 'java':
self._width = self._image.getWidth()
self._height = self._image.getHeight()
else:
self._width, self._height = self._image.size
return self._width, self._height
def getRGBData(self):
"Return byte array of RGB data as string"
if self._data is None:
self._dataA = None
if sys.platform[0:4] == 'java':
import jarray # TODO: Move to top.
from java.awt.image import PixelGrabber
width, height = self.getSize()
buffer = jarray.zeros(width * height, 'i')
pg = PixelGrabber(self._image, 0, 0, width, height, buffer, 0, width)
pg.grabPixels()
# there must be a way to do this with a cast not a byte-level loop,
# I just haven't found it yet...
pixels = []
a = pixels.append
for rgb in buffer:
a(chr((rgb >> 16) & 0xff))
a(chr((rgb >> 8) & 0xff))
a(chr(rgb & 0xff))
self._data = ''.join(pixels)
self.mode = 'RGB'
else:
im = self._image
mode = self.mode = im.mode
if mode == 'RGBA':
im.load()
self._dataA = PmlImageReader(im.split()[3])
im = im.convert('RGB')
self.mode = 'RGB'
elif mode not in ('L', 'RGB', 'CMYK'):
im = im.convert('RGB')
self.mode = 'RGB'
self._data = im.tostring()
return self._data
def getImageData(self):
width, height = self.getSize()
return width, height, self.getRGBData()
def getTransparent(self):
if sys.platform[0:4] == 'java':
return None
elif "transparency" in self._image.info:
transparency = self._image.info["transparency"] * 3
palette = self._image.palette
try:
palette = palette.palette
except:
palette = palette.data
return map(ord, palette[transparency:transparency + 3])
else:
return None
def __str__(self):
try:
return "PmlImageObject_%s" % hash(self.fileName.read())
except:
return self.fileName
class PmlImage(Flowable, PmlMaxHeightMixIn):
def __init__(self, data, width=None, height=None, mask="auto", mimetype=None, **kw):
self.kw = kw
self.hAlign = 'CENTER'
self._mask = mask
self._imgdata = data
# print "###", repr(data)
self.mimetype = mimetype
img = self.getImage()
if img:
self.imageWidth, self.imageHeight = img.getSize()
self.drawWidth = width or self.imageWidth
self.drawHeight = height or self.imageHeight
def wrap(self, availWidth, availHeight):
" This can be called more than once! Do not overwrite important data like drawWidth "
availHeight = self.setMaxHeight(availHeight)
# print "image wrap", id(self), availWidth, availHeight, self.drawWidth, self.drawHeight
width = min(self.drawWidth, availWidth)
wfactor = float(width) / self.drawWidth
height = min(self.drawHeight, availHeight * MAX_IMAGE_RATIO)
hfactor = float(height) / self.drawHeight
factor = min(wfactor, hfactor)
self.dWidth = self.drawWidth * factor
self.dHeight = self.drawHeight * factor
# print "imgage result", factor, self.dWidth, self.dHeight
return self.dWidth, self.dHeight
def getImage(self):
img = PmlImageReader(StringIO.StringIO(self._imgdata))
return img
def draw(self):
img = self.getImage()
self.canv.drawImage(
img,
0, 0,
self.dWidth,
self.dHeight,
mask=self._mask)
def identity(self, maxLen=None):
r = Flowable.identity(self, maxLen)
return r
class PmlParagraphAndImage(ParagraphAndImage, PmlMaxHeightMixIn):
def wrap(self, availWidth, availHeight):
self.I.canv = self.canv
result = ParagraphAndImage.wrap(self, availWidth, availHeight)
del self.I.canv
return result
def split(self, availWidth, availHeight):
# print "# split", id(self)
if not hasattr(self, "wI"):
self.wI, self.hI = self.I.wrap(availWidth, availHeight) # drawWidth, self.I.drawHeight
return ParagraphAndImage.split(self, availWidth, availHeight)
class PmlParagraph(Paragraph, PmlMaxHeightMixIn):
def _calcImageMaxSizes(self, availWidth, availHeight):
self.hasImages = False
availHeight = self.getMaxHeight()
for frag in self.frags:
if hasattr(frag, "cbDefn") and frag.cbDefn.kind == "img":
self.hasImages = True
img = frag.cbDefn
width = min(img.width, availWidth)
wfactor = float(width) / img.width
height = min(img.height, availHeight * MAX_IMAGE_RATIO) # XXX 99% because 100% do not work...
hfactor = float(height) / img.height
factor = min(wfactor, hfactor)
img.height *= factor
img.width *= factor
def wrap(self, availWidth, availHeight):
availHeight = self.setMaxHeight(availHeight)
style = self.style
self.deltaWidth = style.paddingLeft + style.paddingRight + style.borderLeftWidth + style.borderRightWidth
self.deltaHeight = style.paddingTop + style.paddingBottom + style.borderTopWidth + style.borderBottomWidth
# reduce the available width & height by the padding so the wrapping
# will use the correct size
availWidth -= self.deltaWidth
availHeight -= self.deltaHeight
# Modify maxium image sizes
self._calcImageMaxSizes(availWidth, self.getMaxHeight() - self.deltaHeight)
# call the base class to do wrapping and calculate the size
Paragraph.wrap(self, availWidth, availHeight)
#self.height = max(1, self.height)
#self.width = max(1, self.width)
# increase the calculated size by the padding
self.width = self.width + self.deltaWidth
self.height = self.height + self.deltaHeight
return self.width, self.height
def split(self, availWidth, availHeight):
if len(self.frags) <= 0:
return []
#the split information is all inside self.blPara
if not hasattr(self, 'deltaWidth'):
self.wrap(availWidth, availHeight)
availWidth -= self.deltaWidth
availHeight -= self.deltaHeight
return Paragraph.split(self, availWidth, availHeight)
def draw(self):
# Create outline
if getattr(self, "outline", False):
# Check level and add all levels
last = getattr(self.canv, "outlineLast", - 1) + 1
while last < self.outlineLevel:
# print "(OUTLINE", last, self.text
key = getUID()
self.canv.bookmarkPage(key)
self.canv.addOutlineEntry(
self.text,
key,
last,
not self.outlineOpen)
last += 1
self.canv.outlineLast = self.outlineLevel
key = getUID()
self.canv.bookmarkPage(key)
self.canv.addOutlineEntry(
self.text,
key,
self.outlineLevel,
not self.outlineOpen)
last += 1
# Draw the background and borders here before passing control on to
# ReportLab. This is because ReportLab can't handle the individual
# components of the border independently. This will also let us
# support more border styles eventually.
canvas = self.canv
style = self.style
bg = style.backColor
leftIndent = style.leftIndent
bp = 0 # style.borderPadding
x = leftIndent - bp
y = - bp
w = self.width - (leftIndent + style.rightIndent) + 2 * bp
h = self.height + 2 * bp
if bg:
# draw a filled rectangle (with no stroke) using bg color
canvas.saveState()
canvas.setFillColor(bg)
canvas.rect(x, y, w, h, fill=1, stroke=0)
canvas.restoreState()
# we need to hide the bg color (if any) so Paragraph won't try to draw it again
style.backColor = None
# offset the origin to compensate for the padding
canvas.saveState()
canvas.translate(
(style.paddingLeft + style.borderLeftWidth),
-1 * (style.paddingTop + style.borderTopWidth)) # + (style.leading / 4)))
# Call the base class draw method to finish up
Paragraph.draw(self)
canvas.restoreState()
# Reset color because we need it again if we run 2-PASS like we
# do when using TOC
style.backColor = bg
canvas.saveState()
def _drawBorderLine(bstyle, width, color, x1, y1, x2, y2):
# We need width and border style to be able to draw a border
if width and getBorderStyle(bstyle):
# If no color for border is given, the text color is used (like defined by W3C)
if color is None:
color = style.textColor
# print "Border", bstyle, width, color
if color is not None:
canvas.setStrokeColor(color)
canvas.setLineWidth(width)
canvas.line(x1, y1, x2, y2)
_drawBorderLine(style.borderLeftStyle,
style.borderLeftWidth,
style.borderLeftColor,
x, y, x, y + h)
_drawBorderLine(style.borderRightStyle,
style.borderRightWidth,
style.borderRightColor,
x + w, y, x + w, y + h)
_drawBorderLine(style.borderTopStyle,
style.borderTopWidth,
style.borderTopColor,
x, y + h, x + w, y + h)
_drawBorderLine(style.borderBottomStyle,
style.borderBottomWidth,
style.borderBottomColor,
x, y, x + w, y)
canvas.restoreState()
class PmlKeepInFrame(KeepInFrame, PmlMaxHeightMixIn):
def wrap(self, availWidth, availHeight):
availWidth = max(availWidth, 1.0)
self.maxWidth = availWidth
self.maxHeight = self.setMaxHeight(availHeight)
return KeepInFrame.wrap(self, availWidth, availHeight)
class PmlTable(Table, PmlMaxHeightMixIn):
def _normWidth(self, w, maxw):
"""
Helper for calculating percentages
"""
if type(w) == type(""):
w = ((maxw / 100.0) * float(w[: - 1]))
elif (w is None) or (w == "*"):
w = maxw
return min(w, maxw)
def _listCellGeom(self, V, w, s, W=None, H=None, aH=72000):
# print "#", self.availHeightValue
if aH == 72000:
aH = self.getMaxHeight() or aH
return Table._listCellGeom(self, V, w, s, W=W, H=H, aH=aH)
def wrap(self, availWidth, availHeight):
self.setMaxHeight(availHeight)
# Strange bug, sometime the totalWidth is not set !?
try:
self.totalWidth
except:
self.totalWidth = availWidth
# Prepare values
totalWidth = self._normWidth(self.totalWidth, availWidth)
remainingWidth = totalWidth
remainingCols = 0
newColWidths = self._colWidths
# Calculate widths that are fix
# IMPORTANT!!! We can not substitute the private value
# self._colWidths therefore we have to modify list in place
for i, colWidth in enumerate(newColWidths):
if (colWidth is not None) or (colWidth == '*'):
colWidth = self._normWidth(colWidth, totalWidth)
remainingWidth -= colWidth
else:
remainingCols += 1
colWidth = None
newColWidths[i] = colWidth
# Distribute remaining space
minCellWidth = totalWidth * 0.01
if remainingCols > 0:
for i, colWidth in enumerate(newColWidths):
if colWidth is None:
newColWidths[i] = max(minCellWidth, remainingWidth / remainingCols) # - 0.1
# Bigger than totalWidth? Lets reduce the fix entries propotionally
if sum(newColWidths) > totalWidth:
quotient = totalWidth / sum(newColWidths)
for i in range(len(newColWidths)):
newColWidths[i] = newColWidths[i] * quotient
# To avoid rounding errors adjust one col with the difference
diff = sum(newColWidths) - totalWidth
if diff > 0:
newColWidths[0] -= diff
return Table.wrap(self, availWidth, availHeight)
class PmlPageCount(IndexingFlowable):
def __init__(self):
IndexingFlowable.__init__(self)
self.second_round = False
def isSatisfied(self):
s = self.second_round
self.second_round = True
return s
def drawOn(self, canvas, x, y, _sW=0):
pass
class PmlTableOfContents(TableOfContents):
def wrap(self, availWidth, availHeight):
"""
All table properties should be known by now.
"""
widths = (availWidth - self.rightColumnWidth,
self.rightColumnWidth)
# makes an internal table which does all the work.
# we draw the LAST RUN's entries! If there are
# none, we make some dummy data to keep the table
# from complaining
if len(self._lastEntries) == 0:
_tempEntries = [(0, 'Placeholder for table of contents', 0)]
else:
_tempEntries = self._lastEntries
lastMargin = 0
tableData = []
tableStyle = [
('VALIGN', (0, 0), (- 1, - 1), 'TOP'),
('LEFTPADDING', (0, 0), (- 1, - 1), 0),
('RIGHTPADDING', (0, 0), (- 1, - 1), 0),
('TOPPADDING', (0, 0), (- 1, - 1), 0),
('BOTTOMPADDING', (0, 0), (- 1, - 1), 0),
]
for i, entry in enumerate(_tempEntries):
level, text, pageNum = entry[:3]
leftColStyle = self.levelStyles[level]
if i: # Not for first element
tableStyle.append((
'TOPPADDING',
(0, i), (- 1, i),
max(lastMargin, leftColStyle.spaceBefore)))
# print leftColStyle.leftIndent
lastMargin = leftColStyle.spaceAfter
#right col style is right aligned
rightColStyle = ParagraphStyle(name='leftColLevel%d' % level,
parent=leftColStyle,
leftIndent=0,
alignment=TA_RIGHT)
leftPara = Paragraph(text, leftColStyle)
rightPara = Paragraph(str(pageNum), rightColStyle)
tableData.append([leftPara, rightPara])
self._table = Table(
tableData,
colWidths=widths,
style=TableStyle(tableStyle))
self.width, self.height = self._table.wrapOn(self.canv, availWidth, availHeight)
return self.width, self.height
class PmlRightPageBreak(CondPageBreak):
def __init__(self):
pass
def wrap(self, availWidth, availHeight):
if not self.canv.getPageNumber() % 2:
self.width = availWidth
self.height = availHeight
return availWidth, availHeight
self.width = self.height = 0
return 0, 0
class PmlLeftPageBreak(CondPageBreak):
def __init__(self):
pass
def wrap(self, availWidth, availHeight):
if self.canv.getPageNumber() % 2:
self.width = availWidth
self.height = availHeight
return availWidth, availHeight
self.width = self.height = 0
return 0, 0
# --- Pdf Form
class PmlInput(Flowable):
def __init__(self, name, type="text", width=10, height=10, default="", options=[]):
self.width = width
self.height = height
self.type = type
self.name = name
self.default = default
self.options = options
def wrap(self, *args):
return self.width, self.height
def draw(self):
c = self.canv
c.saveState()
c.setFont("Helvetica", 10)
if self.type == "text":
pdfform.textFieldRelative(c, self.name, 0, 0, self.width, self.height)
c.rect(0, 0, self.width, self.height)
elif self.type == "radio":
c.rect(0, 0, self.width, self.height)
elif self.type == "checkbox":
if self.default:
pdfform.buttonFieldRelative(c, self.name, "Yes", 0, 0)
else:
pdfform.buttonFieldRelative(c, self.name, "Off", 0, 0)
c.rect(0, 0, self.width, self.height)
elif self.type == "select":
pdfform.selectFieldRelative(c, self.name, self.default, self.options, 0, 0, self.width, self.height)
c.rect(0, 0, self.width, self.height)
c.restoreState()
|
gpl-3.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
3,
1898,
7129,
25866,
75,
869,
393,
8122,
2000,
12,
394,
393,
8122,
2000,
14,
390,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
3,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
3,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
258,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
199,
504,
8337,
492,
6128,
21,
199,
504,
21773,
14,
773,
14,
19921,
492,
377,
33,
63,
12811,
199,
504,
21773,
14,
773,
14,
12955,
492,
2235,
7109,
6609,
199,
504,
21773,
14,
773,
14,
1208,
492,
9378,
12,
1551,
63,
509,
63,
739,
12,
664,
6424,
12,
971,
272,
22373,
3491,
5929,
12,
1172,
18882,
199,
504,
21773,
14,
14156,
2279,
527,
14,
1301,
1160,
492,
3523,
3768,
4231,
12,
10331,
4231,
12,
5499,
316,
5060,
461,
199,
504,
21773,
14,
14156,
2279,
527,
14,
1659,
5921,
492,
20823,
461,
12,
1448,
68,
3276,
13948,
12,
971,
272,
14797,
607,
3160,
12,
2235,
7109,
3325,
3491,
199,
504,
21773,
14,
14156,
2279,
527,
14,
1224,
1618,
4407,
492,
6957,
3466,
11383,
199,
504,
21773,
14,
14156,
2279,
527,
14,
5987,
492,
6957,
12,
6957,
6609,
199,
504,
671,
1360,
18,
5607,
14,
3070,
5561,
63,
12400,
492,
2235,
7109,
199,
504,
671,
1360,
18,
5607,
14,
1974,
492,
664,
6685,
12,
664,
22590,
6609,
199,
504,
2943,
492,
32654,
12,
11634,
804,
12,
3820,
804,
12,
9805,
804,
199,
646,
5228,
199,
646,
16004,
199,
646,
1331,
199,
646,
2050,
199,
646,
21773,
14,
5607,
1095,
14,
5607,
964,
465,
11249,
964,
199,
646,
984,
421,
199,
893,
26,
272,
492,
14937,
14,
3491,
465,
14937,
3491,
199,
2590,
26,
272,
862,
26,
267,
492,
6047,
465,
14937,
3491,
272,
871,
26,
267,
14937,
3491,
275,
488,
199,
199,
793,
275,
2050,
14,
5572,
480,
12909,
18,
5607,
531,
199,
199,
4283,
63,
9438,
63,
26566,
275,
378,
14,
2720,
421,
199,
533,
510,
5708,
89,
2265,
8,
513,
304,
272,
347,
636,
826,
721,
277,
304,
267,
291,
423,
10506,
275,
378,
267,
291,
423,
2996,
275,
378,
267,
769,
855,
826,
721,
277,
9,
339,
347,
32637,
3585,
8,
277,
304,
267,
1830,
413,
26,
288,
1995,
291,
59,
277,
423,
2996,
61,
288,
291,
423,
2996,
847,
413,
288,
340,
291,
423,
2996,
2356,
822,
8,
277,
304,
355,
291,
423,
2996,
275,
291,
423,
10506,
421,
199,
533,
510,
757,
4261,
8436,
26527,
26,
272,
347,
663,
4261,
8436,
8,
277,
12,
21006,
8436,
304,
267,
291,
14,
18961,
8436,
1110,
275,
21006,
8436,
267,
340,
21006,
8436,
665,
1520,
993,
26,
288,
340,
2688,
8,
277,
12,
298,
29185,
2349,
355,
340,
440,
2688,
8,
277,
14,
29185,
12,
298,
988,
6651,
1054,
8436,
1110,
2349,
490,
291,
14,
29185,
14,
988,
6651,
1054,
8436,
1110,
275,
378,
355,
291,
14,
18961,
8436,
1110,
275,
291,
14,
29185,
14,
988,
6651,
1054,
8436,
1110,
275,
1390,
8,
490,
21006,
8436,
12,
490,
291,
14,
29185,
14,
988,
6651,
1054,
8436,
1110,
9,
267,
587,
26,
288,
291,
14,
18961,
8436,
1110,
275,
21006,
8436,
267,
340,
440,
2688,
8,
277,
12,
298,
18961,
8436,
1110,
2349,
288,
291,
14,
18961,
8436,
1110,
275,
378,
267,
372,
291,
14,
18961,
8436,
1110,
339,
347,
664,
4261,
8436,
8,
277,
304,
267,
340,
440,
2688,
8,
277,
12,
298,
18961,
8436,
1110,
2349,
288,
372,
378,
267,
372,
291,
14,
18961,
8436,
1110,
421,
199,
533,
510,
757,
1563,
3768,
8,
1563,
3768,
4231,
304,
272,
408,
272,
2136,
675,
4154,
5705,
2213,
1978,
370,
664,
2879,
370,
314,
10218,
272,
436,
663,
2005,
315,
17308,
5403,
14,
272,
408,
339,
347,
2544,
3276,
8,
277,
304,
398,
327,
12480,
346,
89,
4340,
370,
663,
17339,
12,
2952,
402,
440,
3363,
5726,
4171,
315,
2018,
267,
2256,
275,
298,
80,
13655,
4163,
370,
15537,
665,
1014,
921,
1544,
14,
1360,
2119,
1587,
14,
1308,
4335,
267,
291,
14,
29185,
423,
1301,
14,
815,
14,
16376,
275,
2256,
398,
1449,
267,
327,
7905,
370,
10485,
2952,
2337,
365,
282,
21605,
315,
11774,
5561,
440,
267,
327,
21038,
1163,
2419,
10485,
14,
10217,
370,
769,
641,
6546,
14,
17,
14,
9488,
398,
4132,
275,
370,
1558,
8,
277,
14,
80,
757,
63,
576,
14,
362,
480,
2502,
401,
298,
21688,
2143,
480,
4371,
2266,
4247,
531,
267,
5420,
275,
370,
1558,
8,
277,
14,
80,
757,
63,
576,
14,
362,
480,
5875,
401,
298,
21688,
2143,
480,
4371,
2266,
4247,
531,
267,
2538,
275,
370,
1558,
8,
277,
14,
80,
757,
63,
576,
14,
362,
480,
1213,
401,
298,
21688,
2143,
480,
4371,
2266,
4247,
531,
267,
327,
870,
4700,
1332,
2502,
12,
1213,
12,
5875,
430,
398,
291,
14,
29185,
14,
409,
5949,
8,
2502,
9,
267,
291,
14,
29185,
14,
409,
13528,
8,
5875,
9,
267,
291,
14,
29185,
14,
31675,
8,
1213,
9,
398,
340,
291,
14,
80,
757,
63,
576,
14,
362,
480,
28418,
4463,
401,
378,
304,
288,
291,
14,
29185,
14,
2384,
9042,
9616,
16,
342,
398,
340,
291,
14,
80,
757,
63,
576,
14,
362,
480,
2384,
11550,
401,
378,
304,
288,
291,
14,
29185,
14,
2384,
21432,
342,
398,
340,
291,
14,
80,
757,
63,
576,
14,
362,
480,
5553,
401,
488,
9,
365,
440,
488,
26,
288,
291,
14,
29185,
14,
409,
3276,
13283,
8,
277,
14,
80,
757,
63,
576,
905,
5553,
3135,
267,
1449,
339,
347,
2410,
5060,
461,
8,
277,
12,
6369,
461,
304,
267,
327,
12078,
314,
6369,
461,
1395,
21495
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
3,
1898,
7129,
25866,
75,
869,
393,
8122,
2000,
12,
394,
393,
8122,
2000,
14,
390,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
3,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
3,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
258,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
199,
504,
8337,
492,
6128,
21,
199,
504,
21773,
14,
773,
14,
19921,
492,
377,
33,
63,
12811,
199,
504,
21773,
14,
773,
14,
12955,
492,
2235,
7109,
6609,
199,
504,
21773,
14,
773,
14,
1208,
492,
9378,
12,
1551,
63,
509,
63,
739,
12,
664,
6424,
12,
971,
272,
22373,
3491,
5929,
12,
1172,
18882,
199,
504,
21773,
14,
14156,
2279,
527,
14,
1301,
1160,
492,
3523,
3768,
4231,
12,
10331,
4231,
12,
5499,
316,
5060,
461,
199,
504,
21773,
14,
14156,
2279,
527,
14,
1659,
5921,
492,
20823,
461,
12,
1448,
68,
3276,
13948,
12,
971,
272,
14797,
607,
3160,
12,
2235,
7109,
3325,
3491,
199,
504,
21773,
14,
14156,
2279,
527,
14,
1224,
1618,
4407,
492,
6957,
3466,
11383,
199,
504,
21773,
14,
14156,
2279,
527,
14,
5987,
492,
6957,
12,
6957,
6609,
199,
504,
671,
1360,
18,
5607,
14,
3070,
5561,
63,
12400,
492,
2235,
7109,
199,
504,
671,
1360,
18,
5607,
14,
1974,
492,
664,
6685,
12,
664,
22590,
6609,
199,
504,
2943,
492,
32654,
12,
11634,
804,
12,
3820,
804,
12,
9805,
804,
199,
646,
5228,
199,
646,
16004,
199,
646,
1331,
199,
646,
2050,
199,
646,
21773,
14,
5607,
1095,
14,
5607,
964,
465,
11249,
964,
199,
646,
984,
421,
199,
893,
26,
272,
492,
14937,
14,
3491,
465,
14937,
3491,
199,
2590,
26,
272,
862,
26,
267,
492,
6047,
465,
14937,
3491,
272,
871,
26,
267,
14937,
3491,
275,
488,
199,
199,
793,
275,
2050,
14,
5572,
480,
12909,
18,
5607,
531,
199,
199,
4283,
63,
9438,
63,
26566,
275,
378,
14,
2720,
421,
199,
533,
510,
5708,
89,
2265,
8,
513,
304,
272,
347,
636,
826,
721,
277,
304,
267,
291,
423,
10506,
275,
378,
267,
291,
423,
2996,
275,
378,
267,
769,
855,
826,
721,
277,
9,
339,
347,
32637,
3585,
8,
277,
304,
267,
1830,
413,
26,
288,
1995,
291,
59,
277,
423,
2996,
61,
288,
291,
423,
2996,
847,
413,
288,
340,
291,
423,
2996,
2356,
822,
8,
277,
304,
355,
291,
423,
2996,
275,
291,
423,
10506,
421,
199,
533,
510,
757,
4261,
8436,
26527,
26,
272,
347,
663,
4261,
8436,
8,
277,
12,
21006,
8436,
304,
267,
291,
14,
18961,
8436,
1110,
275,
21006,
8436,
267,
340,
21006,
8436,
665,
1520,
993,
26,
288,
340,
2688,
8,
277,
12,
298,
29185,
2349,
355,
340,
440,
2688,
8,
277,
14,
29185,
12,
298,
988,
6651,
1054,
8436,
1110,
2349,
490,
291,
14,
29185,
14,
988,
6651,
1054,
8436,
1110,
275,
378,
355,
291,
14,
18961,
8436,
1110,
275,
291,
14,
29185,
14,
988,
6651,
1054,
8436,
1110,
275,
1390,
8,
490,
21006,
8436,
12,
490,
291,
14,
29185,
14,
988,
6651,
1054,
8436,
1110,
9,
267,
587,
26,
288,
291,
14,
18961,
8436,
1110,
275,
21006,
8436,
267,
340,
440,
2688,
8,
277,
12,
298,
18961,
8436,
1110,
2349,
288,
291,
14,
18961,
8436,
1110,
275,
378,
267,
372,
291,
14,
18961,
8436,
1110,
339,
347,
664,
4261,
8436,
8,
277,
304,
267,
340,
440,
2688,
8,
277,
12,
298,
18961,
8436,
1110,
2349,
288,
372,
378,
267,
372,
291,
14,
18961,
8436,
1110,
421,
199,
533,
510,
757,
1563,
3768,
8,
1563,
3768,
4231,
304,
272,
408,
272,
2136,
675,
4154,
5705,
2213,
1978,
370,
664,
2879,
370,
314,
10218,
272,
436,
663,
2005,
315,
17308,
5403,
14,
272,
408,
339,
347,
2544,
3276,
8,
277,
304,
398,
327,
12480,
346,
89,
4340,
370,
663,
17339,
12,
2952,
402,
440,
3363,
5726,
4171,
315,
2018,
267,
2256,
275,
298,
80,
13655,
4163,
370,
15537,
665,
1014,
921,
1544,
14,
1360,
2119,
1587,
14,
1308,
4335,
267,
291,
14,
29185,
423,
1301,
14,
815,
14,
16376,
275,
2256,
398,
1449,
267,
327,
7905,
370,
10485,
2952,
2337,
365,
282,
21605,
315,
11774,
5561,
440,
267,
327,
21038,
1163,
2419,
10485,
14,
10217,
370,
769,
641,
6546,
14,
17,
14,
9488,
398,
4132,
275,
370,
1558,
8,
277,
14,
80,
757,
63,
576,
14,
362,
480,
2502,
401,
298,
21688,
2143,
480,
4371,
2266,
4247,
531,
267,
5420,
275,
370,
1558,
8,
277,
14,
80,
757,
63,
576,
14,
362,
480,
5875,
401,
298,
21688,
2143,
480,
4371,
2266,
4247,
531,
267,
2538,
275,
370,
1558,
8,
277,
14,
80,
757,
63,
576,
14,
362,
480,
1213,
401,
298,
21688,
2143,
480,
4371,
2266,
4247,
531,
267,
327,
870,
4700,
1332,
2502,
12,
1213,
12,
5875,
430,
398,
291,
14,
29185,
14,
409,
5949,
8,
2502,
9,
267,
291,
14,
29185,
14,
409,
13528,
8,
5875,
9,
267,
291,
14,
29185,
14,
31675,
8,
1213,
9,
398,
340,
291,
14,
80,
757,
63,
576,
14,
362,
480,
28418,
4463,
401,
378,
304,
288,
291,
14,
29185,
14,
2384,
9042,
9616,
16,
342,
398,
340,
291,
14,
80,
757,
63,
576,
14,
362,
480,
2384,
11550,
401,
378,
304,
288,
291,
14,
29185,
14,
2384,
21432,
342,
398,
340,
291,
14,
80,
757,
63,
576,
14,
362,
480,
5553,
401,
488,
9,
365,
440,
488,
26,
288,
291,
14,
29185,
14,
409,
3276,
13283,
8,
277,
14,
80,
757,
63,
576,
905,
5553,
3135,
267,
1449,
339,
347,
2410,
5060,
461,
8,
277,
12,
6369,
461,
304,
267,
327,
12078,
314,
6369,
461,
1395,
21495,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
laperry1/android_external_chromium_org
|
tools/perf/page_sets/alexa1-10000.py
|
34
|
666264
|
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
from telemetry.page.page_set import PageSet
from telemetry.page.page import Page
class Alexa1To10000Page(Page):
def __init__(self, url, page_set):
super(Alexa1To10000Page, self).__init__(url=url, page_set=page_set)
self.make_javascript_deterministic = True
def RunSmoothness(self, action_runner):
interaction = action_runner.BeginGestureInteraction(
'ScrollAction', is_smooth=True)
action_runner.ScrollPage()
interaction.End()
class Alexa1To10000PageSet(PageSet):
""" Top 1-10000 Alexa global.
Generated on 2013-09-03 13:59:53.459117 by rmistry using
create_page_set.py.
"""
def __init__(self):
super(Alexa1To10000PageSet, self).__init__(
make_javascript_deterministic=True,
user_agent_type='desktop')
urls_list = [
# Why: #1 in Alexa global
'http://www.facebook.com/',
# Why: #2 in Alexa global
'http://www.google.com/',
# Why: #3 in Alexa global
'http://www.youtube.com/',
# Why: #4 in Alexa global
'http://www.yahoo.com/',
# Why: #5 in Alexa global
'http://baidu.com/',
# Why: #6 in Alexa global
'http://www.amazon.com/',
# Why: #7 in Alexa global
'http://www.wikipedia.org/',
# Why: #8 in Alexa global
'http://www.qq.com/',
# Why: #9 in Alexa global
'http://www.live.com/',
# Why: #10 in Alexa global
'http://www.taobao.com/',
# Why: #11 in Alexa global
'http://www.google.co.in/',
# Why: #12 in Alexa global
'http://www.twitter.com/',
# Why: #13 in Alexa global
'http://www.blogspot.com/',
# Why: #14 in Alexa global
'http://www.linkedin.com/',
# Why: #15 in Alexa global
'http://www.yahoo.co.jp/',
# Why: #16 in Alexa global
'http://www.bing.com/',
# Why: #17 in Alexa global
'http://sina.com.cn/',
# Why: #18 in Alexa global
'http://www.yandex.ru/',
# Why: #19 in Alexa global
'http://www.vk.com/',
# Why: #20 in Alexa global
'http://www.ask.com/',
# Why: #21 in Alexa global
'http://www.ebay.com/',
# Why: #22 in Alexa global
'http://www.wordpress.com/',
# Why: #23 in Alexa global
'http://www.google.de/',
# Why: #24 in Alexa global
'http://www.msn.com/',
# Why: #25 in Alexa global
'http://www.tumblr.com/',
# Why: #26 in Alexa global
'http://163.com/',
# Why: #27 in Alexa global
'http://www.google.com.hk/',
# Why: #28 in Alexa global
'http://www.mail.ru/',
# Why: #29 in Alexa global
'http://www.google.co.uk/',
# Why: #30 in Alexa global
'http://hao123.com/',
# Why: #31 in Alexa global
'http://www.google.com.br/',
# Why: #32 in Alexa global
'http://www.amazon.co.jp/',
# Why: #33 in Alexa global
'http://www.weibo.com/',
# Why: #34 in Alexa global
'http://www.xvideos.com/',
# Why: #35 in Alexa global
'http://www.google.co.jp/',
# Why: #36 in Alexa global
'http://www.microsoft.com/',
# Why: #38 in Alexa global
'http://www.delta-search.com/',
# Why: #39 in Alexa global
'http://www.google.fr/',
# Why: #40 in Alexa global
'http://www.conduit.com/',
# Why: #41 in Alexa global
'http://www.fc2.com/',
# Why: #42 in Alexa global
'http://www.craigslist.org/',
# Why: #43 in Alexa global
'http://www.google.ru/',
# Why: #44 in Alexa global
'http://www.pinterest.com/',
# Why: #45 in Alexa global
'http://www.instagram.com/',
# Why: #46 in Alexa global
'http://www.tmall.com/',
# Why: #47 in Alexa global
'http://www.xhamster.com/',
# Why: #48 in Alexa global
'http://www.odnoklassniki.ru/',
# Why: #49 in Alexa global
'http://www.google.it/',
# Why: #50 in Alexa global
'http://www.sohu.com/',
# Why: #51 in Alexa global
'http://www.paypal.com/',
# Why: #52 in Alexa global
'http://www.babylon.com/',
# Why: #53 in Alexa global
'http://www.google.es/',
# Why: #54 in Alexa global
'http://www.imdb.com/',
# Why: #55 in Alexa global
'http://www.apple.com/',
# Why: #56 in Alexa global
'http://www.amazon.de/',
# Why: #58 in Alexa global
'http://www.bbc.co.uk/',
# Why: #59 in Alexa global
'http://www.adobe.com/',
# Why: #60 in Alexa global
'http://www.soso.com/',
# Why: #61 in Alexa global
'http://www.pornhub.com/',
# Why: #62 in Alexa global
'http://www.google.com.mx/',
# Why: #63 in Alexa global
'http://www.blogger.com/',
# Why: #64 in Alexa global
'http://www.neobux.com/',
# Why: #65 in Alexa global
'http://www.amazon.co.uk/',
# Why: #66 in Alexa global
'http://www.ifeng.com/',
# Why: #67 in Alexa global
'http://www.google.ca/',
# Why: #68 in Alexa global
'http://www.avg.com/',
# Why: #69 in Alexa global
'http://www.go.com/',
# Why: #70 in Alexa global
'http://www.xnxx.com/',
# Why: #71 in Alexa global
'http://www.blogspot.in/',
# Why: #72 in Alexa global
'http://www.alibaba.com/',
# Why: #73 in Alexa global
'http://www.aol.com/',
# Why: #74 in Alexa global
'http://www.buildathome.info/',
# Why: #75 in Alexa global
'http://www.cnn.com/',
# Why: #76 in Alexa global
'http://www.mywebsearch.com/',
# Why: #77 in Alexa global
'http://www.ku6.com/',
# Why: #79 in Alexa global
'http://www.alipay.com/',
# Why: #80 in Alexa global
'http://www.vube.com/',
# Why: #81 in Alexa global
'http://www.google.com.tr/',
# Why: #82 in Alexa global
'http://www.youku.com/',
# Why: #83 in Alexa global
'http://www.redtube.com/',
# Why: #84 in Alexa global
'http://www.dailymotion.com/',
# Why: #85 in Alexa global
'http://www.google.com.au/',
# Why: #86 in Alexa global
'http://www.adf.ly/',
# Why: #87 in Alexa global
'http://www.netflix.com/',
# Why: #88 in Alexa global
'http://www.adcash.com/',
# Why: #89 in Alexa global
'http://www.about.com/',
# Why: #90 in Alexa global
'http://www.google.pl/',
# Why: #91 in Alexa global
'http://www.imgur.com/',
# Why: #92 in Alexa global
'http://www.ebay.de/',
# Why: #93 in Alexa global
'http://www.amazon.fr/',
# Why: #94 in Alexa global
'http://www.flickr.com/',
# Why: #95 in Alexa global
'http://www.thepiratebay.sx/',
# Why: #96 in Alexa global
'http://www.youporn.com/',
# Why: #97 in Alexa global
'http://www.uol.com.br/',
# Why: #98 in Alexa global
'http://www.huffingtonpost.com/',
# Why: #99 in Alexa global
'http://www.stackoverflow.com/',
# Why: #100 in Alexa global
'http://www.jd.com/',
# Why: #101 in Alexa global
'http://t.co/',
# Why: #102 in Alexa global
'http://www.rakuten.co.jp/',
# Why: #103 in Alexa global
'http://www.livejasmin.com/',
# Why: #105 in Alexa global
'http://www.ebay.co.uk/',
# Why: #106 in Alexa global
'http://www.yieldmanager.com/',
# Why: #107 in Alexa global
'http://www.sogou.com/',
# Why: #108 in Alexa global
'http://www.globo.com/',
# Why: #109 in Alexa global
'http://www.softonic.com/',
# Why: #110 in Alexa global
'http://www.cnet.com/',
# Why: #111 in Alexa global
'http://www.livedoor.com/',
# Why: #112 in Alexa global
'http://www.nicovideo.jp/',
# Why: #113 in Alexa global
'http://www.directrev.com/',
# Why: #114 in Alexa global
'http://www.espn.go.com/',
# Why: #115 in Alexa global
'http://www.ameblo.jp/',
# Why: #116 in Alexa global
'http://www.indiatimes.com/',
# Why: #117 in Alexa global
'http://www.wordpress.org/',
# Why: #118 in Alexa global
'http://www.weather.com/',
# Why: #119 in Alexa global
'http://www.pixnet.net/',
# Why: #120 in Alexa global
'http://www.google.com.sa/',
# Why: #122 in Alexa global
'http://www.clkmon.com/',
# Why: #123 in Alexa global
'http://www.reddit.com/',
# Why: #124 in Alexa global
'http://www.amazon.it/',
# Why: #125 in Alexa global
'http://www.google.com.eg/',
# Why: #126 in Alexa global
'http://www.booking.com/',
# Why: #127 in Alexa global
'http://www.google.nl/',
# Why: #128 in Alexa global
'http://www.douban.com/',
# Why: #129 in Alexa global
'http://www.amazon.cn/',
# Why: #130 in Alexa global
'http://www.slideshare.net/',
# Why: #131 in Alexa global
'http://www.google.com.ar/',
# Why: #132 in Alexa global
'http://www.badoo.com/',
# Why: #133 in Alexa global
'http://www.dailymail.co.uk/',
# Why: #134 in Alexa global
'http://www.google.co.th/',
# Why: #135 in Alexa global
'http://www.ask.fm/',
# Why: #136 in Alexa global
'http://www.wikia.com/',
# Why: #137 in Alexa global
'http://www.godaddy.com/',
# Why: #138 in Alexa global
'http://www.google.com.tw/',
# Why: #139 in Alexa global
'http://www.xinhuanet.com/',
# Why: #140 in Alexa global
'http://www.mediafire.com/',
# Why: #141 in Alexa global
'http://www.deviantart.com/',
# Why: #142 in Alexa global
'http://www.google.com.pk/',
# Why: #143 in Alexa global
'http://www.bankofamerica.com/',
# Why: #144 in Alexa global
'http://www.amazon.es/',
# Why: #145 in Alexa global
'http://www.blogfa.com/',
# Why: #146 in Alexa global
'http://www.nytimes.com/',
# Why: #147 in Alexa global
'http://www.4shared.com/',
# Why: #148 in Alexa global
'http://www.google.co.id/',
# Why: #149 in Alexa global
'http://www.youjizz.com/',
# Why: #150 in Alexa global
'http://www.amazonaws.com/',
# Why: #151 in Alexa global
'http://www.tube8.com/',
# Why: #152 in Alexa global
'http://www.kickass.to/',
# Why: #154 in Alexa global
'http://www.livejournal.com/',
# Why: #155 in Alexa global
'http://www.snapdo.com/',
# Why: #156 in Alexa global
'http://www.google.co.za/',
# Why: #158 in Alexa global
'http://www.vimeo.com/',
# Why: #160 in Alexa global
'http://www.wigetmedia.com/',
# Why: #161 in Alexa global
'http://www.yelp.com/',
# Why: #162 in Alexa global
'http://www.outbrain.com/',
# Why: #163 in Alexa global
'http://www.dropbox.com/',
# Why: #164 in Alexa global
'http://www.siteadvisor.com/',
# Why: #165 in Alexa global
'http://www.foxnews.com/',
# Why: #166 in Alexa global
'http://www.renren.com/',
# Why: #167 in Alexa global
'http://www.aliexpress.com/',
# Why: #168 in Alexa global
'http://www.walmart.com/',
# Why: #169 in Alexa global
'http://www.skype.com/',
# Why: #170 in Alexa global
'http://www.ilivid.com/',
# Why: #171 in Alexa global
'http://www.bizcoaching.info/',
# Why: #172 in Alexa global
'http://www.google.cn/',
# Why: #173 in Alexa global
'http://www.wikimedia.org/',
# Why: #174 in Alexa global
'http://people.com.cn/',
# Why: #175 in Alexa global
'http://www.flipkart.com/',
# Why: #176 in Alexa global
'http://www.zedo.com/',
# Why: #177 in Alexa global
'http://tianya.cn/',
# Why: #178 in Alexa global
'http://www.searchnu.com/',
# Why: #179 in Alexa global
'http://www.indeed.com/',
# Why: #180 in Alexa global
'http://www.leboncoin.fr/',
# Why: #181 in Alexa global
'http://www.goo.ne.jp/',
# Why: #182 in Alexa global
'http://www.liveinternet.ru/',
# Why: #183 in Alexa global
'http://www.google.co.ve/',
# Why: #184 in Alexa global
'http://www.56.com/',
# Why: #185 in Alexa global
'http://www.google.com.vn/',
# Why: #186 in Alexa global
'http://www.google.gr/',
# Why: #187 in Alexa global
'http://www.comcast.net/',
# Why: #188 in Alexa global
'http://www.torrentz.eu/',
# Why: #189 in Alexa global
'http://www.etsy.com/',
# Why: #190 in Alexa global
'http://www.orange.fr/',
# Why: #191 in Alexa global
'http://www.systweak.com/',
# Why: #192 in Alexa global
'http://www.onet.pl/',
# Why: #193 in Alexa global
'http://www.wellsfargo.com/',
# Why: #194 in Alexa global
'http://pconline.com.cn/',
# Why: #195 in Alexa global
'http://www.letv.com/',
# Why: #196 in Alexa global
'http://www.goodgamestudios.com/',
# Why: #197 in Alexa global
'http://www.secureserver.net/',
# Why: #198 in Alexa global
'http://www.allegro.pl/',
# Why: #199 in Alexa global
'http://www.themeforest.net/',
# Why: #200 in Alexa global
'http://www.china.com.cn/',
# Why: #201 in Alexa global
'http://www.tripadvisor.com/',
# Why: #202 in Alexa global
'http://www.web.de/',
# Why: #203 in Alexa global
'http://www.answers.com/',
# Why: #204 in Alexa global
'http://www.amazon.ca/',
# Why: #205 in Alexa global
'http://www.mozilla.org/',
# Why: #206 in Alexa global
'http://www.guardian.co.uk/',
# Why: #207 in Alexa global
'http://www.stumbleupon.com/',
# Why: #208 in Alexa global
'http://www.hardsextube.com/',
# Why: #209 in Alexa global
'http://www.espncricinfo.com/',
# Why: #210 in Alexa global
'http://www.gmx.net/',
# Why: #211 in Alexa global
'http://www.photobucket.com/',
# Why: #212 in Alexa global
'http://www.ehow.com/',
# Why: #213 in Alexa global
'http://www.rediff.com/',
# Why: #214 in Alexa global
'http://www.popads.net/',
# Why: #215 in Alexa global
'http://www.wikihow.com/',
# Why: #216 in Alexa global
'http://www.search-results.com/',
# Why: #217 in Alexa global
'http://www.fiverr.com/',
# Why: #218 in Alexa global
'http://www.google.com.ua/',
# Why: #219 in Alexa global
'http://www.files.wordpress.com/',
# Why: #220 in Alexa global
'http://www.onlineaway.net/',
# Why: #221 in Alexa global
'http://www.nbcnews.com/',
# Why: #222 in Alexa global
'http://www.google.com.co/',
# Why: #223 in Alexa global
'http://www.hootsuite.com/',
# Why: #224 in Alexa global
'http://www.4dsply.com/',
# Why: #225 in Alexa global
'http://www.google.ro/',
# Why: #227 in Alexa global
'http://www.sourceforge.net/',
# Why: #228 in Alexa global
'http://www.cnzz.com/',
# Why: #229 in Alexa global
'http://www.java.com/',
# Why: #230 in Alexa global
'http://www.hudong.com/',
# Why: #231 in Alexa global
'http://www.ucoz.ru/',
# Why: #232 in Alexa global
'http://www.tudou.com/',
# Why: #233 in Alexa global
'http://www.addthis.com/',
# Why: #234 in Alexa global
'http://zol.com.cn/',
# Why: #235 in Alexa global
'http://www.google.com.ng/',
# Why: #236 in Alexa global
'http://www.soundcloud.com/',
# Why: #237 in Alexa global
'http://www.onclickads.net/',
# Why: #238 in Alexa global
'http://www.google.com.ph/',
# Why: #239 in Alexa global
'http://www.dmm.co.jp/',
# Why: #240 in Alexa global
'http://www.reference.com/',
# Why: #241 in Alexa global
'http://www.google.be/',
# Why: #242 in Alexa global
'http://www.wp.pl/',
# Why: #243 in Alexa global
'http://www.interbiz.me/',
# Why: #244 in Alexa global
'http://www.beeg.com/',
# Why: #245 in Alexa global
'http://www.rambler.ru/',
# Why: #246 in Alexa global
'http://www.sweetim.com/',
# Why: #247 in Alexa global
'http://www.aweber.com/',
# Why: #248 in Alexa global
'http://www.google.com.my/',
# Why: #249 in Alexa global
'http://www.pandora.com/',
# Why: #250 in Alexa global
'http://www.w3schools.com/',
# Why: #251 in Alexa global
'http://www.pengyou.com/',
# Why: #252 in Alexa global
'http://www.archive.org/',
# Why: #253 in Alexa global
'http://www.qvo6.com/',
# Why: #254 in Alexa global
'http://www.bet365.com/',
# Why: #255 in Alexa global
'http://www.etao.com/',
# Why: #256 in Alexa global
'http://www.lollipop-network.com/',
# Why: #257 in Alexa global
'http://www.qtrax.com/',
# Why: #258 in Alexa global
'http://www.naver.jp/',
# Why: #259 in Alexa global
'http://www.google.se/',
# Why: #260 in Alexa global
'http://www.google.dz/',
# Why: #261 in Alexa global
'http://www.usatoday.com/',
# Why: #262 in Alexa global
'http://www.zillow.com/',
# Why: #263 in Alexa global
'http://www.goal.com/',
# Why: #264 in Alexa global
'http://www.avito.ru/',
# Why: #265 in Alexa global
'http://kaixin001.com/',
# Why: #266 in Alexa global
'http://yesky.com/',
# Why: #267 in Alexa global
'http://www.mobile01.com/',
# Why: #268 in Alexa global
'http://www.soufun.com/',
# Why: #269 in Alexa global
'http://www.tagged.com/',
# Why: #270 in Alexa global
'http://www.warriorforum.com/',
# Why: #271 in Alexa global
'http://www.statcounter.com/',
# Why: #272 in Alexa global
'http://www.google.com.pe/',
# Why: #273 in Alexa global
'http://www.libero.it/',
# Why: #274 in Alexa global
'http://www.thefreedictionary.com/',
# Why: #275 in Alexa global
'http://www.soku.com/',
# Why: #276 in Alexa global
'http://www.incredibar.com/',
# Why: #277 in Alexa global
'http://www.kaskus.co.id/',
# Why: #278 in Alexa global
'http://www.likes.com/',
# Why: #279 in Alexa global
'http://www.weebly.com/',
# Why: #280 in Alexa global
'http://iqiyi.com/',
# Why: #281 in Alexa global
'http://www.pch.com/',
# Why: #282 in Alexa global
'http://www.ameba.jp/',
# Why: #284 in Alexa global
'http://www.samsung.com/',
# Why: #285 in Alexa global
'http://www.linkbucks.com/',
# Why: #286 in Alexa global
'http://www.uploaded.net/',
# Why: #287 in Alexa global
'http://www.bild.de/',
# Why: #288 in Alexa global
'http://www.google.com.bd/',
# Why: #289 in Alexa global
'http://www.google.at/',
# Why: #290 in Alexa global
'http://www.webcrawler.com/',
# Why: #291 in Alexa global
'http://www.t-online.de/',
# Why: #292 in Alexa global
'http://www.iminent.com/',
# Why: #293 in Alexa global
'http://www.google.pt/',
# Why: #294 in Alexa global
'http://www.detik.com/',
# Why: #295 in Alexa global
'http://www.ganji.com/',
# Why: #296 in Alexa global
'http://www.milliyet.com.tr/',
# Why: #297 in Alexa global
'http://www.bleacherreport.com/',
# Why: #298 in Alexa global
'http://www.forbes.com/',
# Why: #299 in Alexa global
'http://www.twoo.com/',
# Why: #300 in Alexa global
'http://www.olx.in/',
# Why: #301 in Alexa global
'http://www.mercadolivre.com.br/',
# Why: #302 in Alexa global
'http://www.hurriyet.com.tr/',
# Why: #303 in Alexa global
'http://www.pof.com/',
# Why: #304 in Alexa global
'http://www.wsj.com/',
# Why: #305 in Alexa global
'http://www.hostgator.com/',
# Why: #306 in Alexa global
'http://www.naver.com/',
# Why: #307 in Alexa global
'http://www.putlocker.com/',
# Why: #308 in Alexa global
'http://www.varzesh3.com/',
# Why: #309 in Alexa global
'http://www.rutracker.org/',
# Why: #311 in Alexa global
'http://www.optmd.com/',
# Why: #312 in Alexa global
'http://www.youm7.com/',
# Why: #313 in Alexa global
'http://www.google.cl/',
# Why: #314 in Alexa global
'http://www.ikea.com/',
# Why: #316 in Alexa global
'http://www.4399.com/',
# Why: #317 in Alexa global
'http://www.salesforce.com/',
# Why: #318 in Alexa global
'http://www.scribd.com/',
# Why: #319 in Alexa global
'http://www.google.com.sg/',
# Why: #320 in Alexa global
'http://it168.com/',
# Why: #321 in Alexa global
'http://www.goodreads.com/',
# Why: #322 in Alexa global
'http://www.target.com/',
# Why: #323 in Alexa global
'http://www.xunlei.com/',
# Why: #324 in Alexa global
'http://www.hulu.com/',
# Why: #325 in Alexa global
'http://www.github.com/',
# Why: #326 in Alexa global
'http://www.hp.com/',
# Why: #327 in Alexa global
'http://www.buzzfeed.com/',
# Why: #328 in Alexa global
'http://www.google.ch/',
# Why: #329 in Alexa global
'http://www.youdao.com/',
# Why: #330 in Alexa global
'http://www.blogspot.com.es/',
# Why: #331 in Alexa global
'http://so.com/',
# Why: #332 in Alexa global
'http://www.ups.com/',
# Why: #333 in Alexa global
'http://www.google.co.kr/',
# Why: #334 in Alexa global
'http://www.extratorrent.com/',
# Why: #335 in Alexa global
'http://www.match.com/',
# Why: #336 in Alexa global
'http://www.seznam.cz/',
# Why: #337 in Alexa global
'http://autohome.com.cn/',
# Why: #338 in Alexa global
'http://www.naukri.com/',
# Why: #339 in Alexa global
'http://www.gmw.cn/',
# Why: #340 in Alexa global
'http://www.drtuber.com/',
# Why: #341 in Alexa global
'http://www.spiegel.de/',
# Why: #342 in Alexa global
'http://www.marca.com/',
# Why: #343 in Alexa global
'http://www.ign.com/',
# Why: #344 in Alexa global
'http://www.domaintools.com/',
# Why: #345 in Alexa global
'http://www.free.fr/',
# Why: #346 in Alexa global
'http://www.telegraph.co.uk/',
# Why: #347 in Alexa global
'http://www.mypcbackup.com/',
# Why: #348 in Alexa global
'http://www.kakaku.com/',
# Why: #349 in Alexa global
'http://www.imageshack.us/',
# Why: #350 in Alexa global
'http://www.reuters.com/',
# Why: #351 in Alexa global
'http://www.ndtv.com/',
# Why: #352 in Alexa global
'http://www.ig.com.br/',
# Why: #353 in Alexa global
'http://www.bestbuy.com/',
# Why: #354 in Alexa global
'http://www.glispa.com/',
# Why: #355 in Alexa global
'http://www.quikr.com/',
# Why: #356 in Alexa global
'http://www.deadlyblessing.com/',
# Why: #357 in Alexa global
'http://www.wix.com/',
# Why: #358 in Alexa global
'http://xcar.com.cn/',
# Why: #359 in Alexa global
'http://paipai.com/',
# Why: #360 in Alexa global
'http://www.ebay.com.au/',
# Why: #361 in Alexa global
'http://www.yandex.ua/',
# Why: #362 in Alexa global
'http://chinanews.com/',
# Why: #363 in Alexa global
'http://www.clixsense.com/',
# Why: #364 in Alexa global
'http://nih.gov/',
# Why: #365 in Alexa global
'http://www.aili.com/',
# Why: #366 in Alexa global
'http://www.zing.vn/',
# Why: #367 in Alexa global
'http://pchome.net/',
# Why: #369 in Alexa global
'http://www.webmd.com/',
# Why: #370 in Alexa global
'http://www.terra.com.br/',
# Why: #371 in Alexa global
'http://pixiv.net/',
# Why: #372 in Alexa global
'http://www.in.com/',
# Why: #373 in Alexa global
'http://csdn.net/',
# Why: #374 in Alexa global
'http://www.pcpop.com/',
# Why: #375 in Alexa global
'http://www.google.co.hu/',
# Why: #376 in Alexa global
'http://www.lnksr.com/',
# Why: #377 in Alexa global
'http://www.jobrapido.com/',
# Why: #378 in Alexa global
'http://inbox.com/',
# Why: #379 in Alexa global
'http://dianping.com/',
# Why: #380 in Alexa global
'http://www.gsmarena.com/',
# Why: #381 in Alexa global
'http://www.mlb.com/',
# Why: #382 in Alexa global
'http://www.clicksor.com/',
# Why: #383 in Alexa global
'http://www.hdfcbank.com/',
# Why: #384 in Alexa global
'http://www.acesse.com/',
# Why: #385 in Alexa global
'http://www.homedepot.com/',
# Why: #386 in Alexa global
'http://www.twitch.tv/',
# Why: #387 in Alexa global
'http://www.morefreecamsecrets.com/',
# Why: #388 in Alexa global
'http://www.groupon.com/',
# Why: #389 in Alexa global
'http://www.lnksdata.com/',
# Why: #390 in Alexa global
'http://enet.com.cn/',
# Why: #391 in Alexa global
'http://www.google.cz/',
# Why: #392 in Alexa global
'http://www.usps.com/',
# Why: #393 in Alexa global
'http://xyxy.net/',
# Why: #394 in Alexa global
'http://www.att.com/',
# Why: #395 in Alexa global
'http://webs.com/',
# Why: #396 in Alexa global
'http://51job.com/',
# Why: #397 in Alexa global
'http://www.mashable.com/',
# Why: #398 in Alexa global
'http://www.yihaodian.com/',
# Why: #399 in Alexa global
'http://taringa.net/',
# Why: #400 in Alexa global
'http://www.fedex.com/',
# Why: #401 in Alexa global
'http://blogspot.co.uk/',
# Why: #402 in Alexa global
'http://www.ck101.com/',
# Why: #403 in Alexa global
'http://www.abcnews.go.com/',
# Why: #404 in Alexa global
'http://www.washingtonpost.com/',
# Why: #405 in Alexa global
'http://www.narod.ru/',
# Why: #406 in Alexa global
'http://www.china.com/',
# Why: #407 in Alexa global
'http://www.doubleclick.com/',
# Why: #409 in Alexa global
'http://www.cam4.com/',
# Why: #410 in Alexa global
'http://www.google.ie/',
# Why: #411 in Alexa global
'http://dangdang.com/',
# Why: #412 in Alexa global
'http://americanexpress.com/',
# Why: #413 in Alexa global
'http://www.disqus.com/',
# Why: #414 in Alexa global
'http://www.ixxx.com/',
# Why: #415 in Alexa global
'http://39.net/',
# Why: #416 in Alexa global
'http://www.isohunt.com/',
# Why: #417 in Alexa global
'http://php.net/',
# Why: #418 in Alexa global
'http://www.exoclick.com/',
# Why: #419 in Alexa global
'http://www.shutterstock.com/',
# Why: #420 in Alexa global
'http://www.dell.com/',
# Why: #421 in Alexa global
'http://www.google.ae/',
# Why: #422 in Alexa global
'http://histats.com/',
# Why: #423 in Alexa global
'http://www.outlook.com/',
# Why: #424 in Alexa global
'http://www.wordreference.com/',
# Why: #425 in Alexa global
'http://sahibinden.com/',
# Why: #426 in Alexa global
'http://www.126.com/',
# Why: #427 in Alexa global
'http://oyodomo.com/',
# Why: #428 in Alexa global
'http://www.gazeta.pl/',
# Why: #429 in Alexa global
'http://www.expedia.com/',
# Why: #430 in Alexa global
'http://cntv.cn/',
# Why: #431 in Alexa global
'http://www.kijiji.ca/',
# Why: #432 in Alexa global
'http://www.myfreecams.com/',
# Why: #433 in Alexa global
'http://rednet.cn/',
# Why: #434 in Alexa global
'http://www.capitalone.com/',
# Why: #435 in Alexa global
'http://moz.com/',
# Why: #436 in Alexa global
'http://qunar.com/',
# Why: #437 in Alexa global
'http://www.taleo.net/',
# Why: #438 in Alexa global
'http://www.google.co.il/',
# Why: #439 in Alexa global
'http://www.microsoftonline.com/',
# Why: #440 in Alexa global
'http://datasrvrs.com/',
# Why: #441 in Alexa global
'http://www.zippyshare.com/',
# Why: #442 in Alexa global
'http://google.no/',
# Why: #444 in Alexa global
'http://justdial.com/',
# Why: #445 in Alexa global
'http://www.2345.com/',
# Why: #446 in Alexa global
'http://adultfriendfinder.com/',
# Why: #447 in Alexa global
'http://www.shaadi.com/',
# Why: #448 in Alexa global
'http://www.mobile.de/',
# Why: #449 in Alexa global
'http://abril.com.br/',
# Why: #450 in Alexa global
'http://empowernetwork.com/',
# Why: #451 in Alexa global
'http://www.icicibank.com/',
# Why: #452 in Alexa global
'http://xe.com/',
# Why: #454 in Alexa global
'http://www.mailchimp.com/',
# Why: #455 in Alexa global
'http://fbcdn.net/',
# Why: #456 in Alexa global
'http://www.ccb.com/',
# Why: #457 in Alexa global
'http://huanqiu.com/',
# Why: #458 in Alexa global
'http://www.seesaa.net/',
# Why: #459 in Alexa global
'http://jimdo.com/',
# Why: #460 in Alexa global
'http://fucked-tube.com/',
# Why: #461 in Alexa global
'http://google.dk/',
# Why: #462 in Alexa global
'http://www.yellowpages.com/',
# Why: #463 in Alexa global
'http://www.constantcontact.com/',
# Why: #464 in Alexa global
'http://www.tinyurl.com/',
# Why: #465 in Alexa global
'http://mysearchresults.com/',
# Why: #466 in Alexa global
'http://www.friv.com/',
# Why: #467 in Alexa global
'http://www.ebay.it/',
# Why: #468 in Alexa global
'http://www.aizhan.com/',
# Why: #469 in Alexa global
'http://accuweather.com/',
# Why: #470 in Alexa global
'http://www.51buy.com/',
# Why: #472 in Alexa global
'http://www.snapdeal.com/',
# Why: #473 in Alexa global
'http://google.az/',
# Why: #474 in Alexa global
'http://pogo.com/',
# Why: #475 in Alexa global
'http://www.adultadworld.com/',
# Why: #476 in Alexa global
'http://www.nifty.com/',
# Why: #477 in Alexa global
'http://bitauto.com/',
# Why: #478 in Alexa global
'http://drudgereport.com/',
# Why: #479 in Alexa global
'http://www.bloomberg.com/',
# Why: #480 in Alexa global
'http://www.vnexpress.net/',
# Why: #481 in Alexa global
'http://eastmoney.com/',
# Why: #482 in Alexa global
'http://www.verizonwireless.com/',
# Why: #483 in Alexa global
'http://pcauto.com.cn/',
# Why: #485 in Alexa global
'http://www.onlinesbi.com/',
# Why: #486 in Alexa global
'http://www.2ch.net/',
# Why: #487 in Alexa global
'http://speedtest.net/',
# Why: #488 in Alexa global
'http://www.largeporntube.com/',
# Why: #489 in Alexa global
'http://www.stackexchange.com/',
# Why: #490 in Alexa global
'http://roblox.com/',
# Why: #492 in Alexa global
'http://pclady.com.cn/',
# Why: #493 in Alexa global
'http://miniclip.com/',
# Why: #495 in Alexa global
'http://www.tmz.com/',
# Why: #496 in Alexa global
'http://google.fi/',
# Why: #497 in Alexa global
'http://ning.com/',
# Why: #498 in Alexa global
'http://monster.com/',
# Why: #499 in Alexa global
'http://www.jrj.com.cn/',
# Why: #500 in Alexa global
'http://www.mihanblog.com/',
# Why: #501 in Alexa global
'http://www.biglobe.ne.jp/',
# Why: #502 in Alexa global
'http://steampowered.com/',
# Why: #503 in Alexa global
'http://www.nuvid.com/',
# Why: #504 in Alexa global
'http://kooora.com/',
# Why: #505 in Alexa global
'http://ebay.in/',
# Why: #506 in Alexa global
'http://mp3skull.com/',
# Why: #507 in Alexa global
'http://www.icbc.com.cn/',
# Why: #508 in Alexa global
'http://blogspot.ru/',
# Why: #509 in Alexa global
'http://duowan.com/',
# Why: #510 in Alexa global
'http://www.blogspot.de/',
# Why: #511 in Alexa global
'http://www.fhserve.com/',
# Why: #512 in Alexa global
'http://moneycontrol.com/',
# Why: #513 in Alexa global
'http://pornerbros.com/',
# Why: #514 in Alexa global
'http://eazel.com/',
# Why: #515 in Alexa global
'http://xgo.com.cn/',
# Why: #516 in Alexa global
'http://daum.net/',
# Why: #517 in Alexa global
'http://www.10086.cn/',
# Why: #518 in Alexa global
'http://lady8844.com/',
# Why: #519 in Alexa global
'http://www.rapidgator.net/',
# Why: #520 in Alexa global
'http://thesun.co.uk/',
# Why: #521 in Alexa global
'http://youtube-mp3.org/',
# Why: #522 in Alexa global
'http://www.v9.com/',
# Why: #523 in Alexa global
'http://www.disney.go.com/',
# Why: #524 in Alexa global
'http://www.homeway.com.cn/',
# Why: #525 in Alexa global
'http://porntube.com/',
# Why: #526 in Alexa global
'http://www.surveymonkey.com/',
# Why: #527 in Alexa global
'http://www.meetup.com/',
# Why: #528 in Alexa global
'http://www.ero-advertising.com/',
# Why: #529 in Alexa global
'http://www.bravotube.net/',
# Why: #530 in Alexa global
'http://appround.biz/',
# Why: #531 in Alexa global
'http://blogspot.it/',
# Why: #532 in Alexa global
'http://ctrip.com/',
# Why: #533 in Alexa global
'http://www.9gag.com/',
# Why: #534 in Alexa global
'http://www.odesk.com/',
# Why: #535 in Alexa global
'http://www.kinopoisk.ru/',
# Why: #536 in Alexa global
'http://www.trulia.com/',
# Why: #537 in Alexa global
'http://www.mercadolibre.com.ar/',
# Why: #538 in Alexa global
'http://www.repubblica.it/',
# Why: #539 in Alexa global
'http://hupu.com/',
# Why: #540 in Alexa global
'http://www.imesh.com/',
# Why: #541 in Alexa global
'http://searchfunmoods.com/',
# Why: #542 in Alexa global
'http://www.backpage.com/',
# Why: #543 in Alexa global
'http://latimes.com/',
# Why: #544 in Alexa global
'http://www.news.com.au/',
# Why: #545 in Alexa global
'http://www.gc.ca/',
# Why: #546 in Alexa global
'http://ce.cn/',
# Why: #547 in Alexa global
'http://www.hubpages.com/',
# Why: #548 in Alexa global
'http://www.clickbank.com/',
# Why: #549 in Alexa global
'http://www.mapquest.com/',
# Why: #550 in Alexa global
'http://www.sweetpacks.com/',
# Why: #551 in Alexa global
'http://www.hypergames.net/',
# Why: #552 in Alexa global
'http://alimama.com/',
# Why: #553 in Alexa global
'http://www.cnblogs.com/',
# Why: #554 in Alexa global
'http://www.vancl.com/',
# Why: #555 in Alexa global
'http://www.bitly.com/',
# Why: #556 in Alexa global
'http://www.tokobagus.com/',
# Why: #557 in Alexa global
'http://www.webmoney.ru/',
# Why: #558 in Alexa global
'http://www.google.sk/',
# Why: #559 in Alexa global
'http://www.shopathome.com/',
# Why: #560 in Alexa global
'http://elpais.com/',
# Why: #561 in Alexa global
'http://www.oneindia.in/',
# Why: #562 in Alexa global
'http://www.codecanyon.net/',
# Why: #563 in Alexa global
'http://www.businessinsider.com/',
# Why: #564 in Alexa global
'http://www.blackhatworld.com/',
# Why: #565 in Alexa global
'http://www.farsnews.com/',
# Why: #566 in Alexa global
'http://www.spankwire.com/',
# Why: #567 in Alexa global
'http://www.mynet.com/',
# Why: #568 in Alexa global
'http://www.sape.ru/',
# Why: #569 in Alexa global
'http://www.bhaskar.com/',
# Why: #570 in Alexa global
'http://www.lenta.ru/',
# Why: #571 in Alexa global
'http://www.gutefrage.net/',
# Why: #572 in Alexa global
'http://www.nba.com/',
# Why: #573 in Alexa global
'http://www.feedly.com/',
# Why: #574 in Alexa global
'http://www.chaturbate.com/',
# Why: #575 in Alexa global
'http://elmundo.es/',
# Why: #576 in Alexa global
'http://www.ad6media.fr/',
# Why: #577 in Alexa global
'http://www.sberbank.ru/',
# Why: #578 in Alexa global
'http://www.lockyourhome.com/',
# Why: #579 in Alexa global
'http://kinox.to/',
# Why: #580 in Alexa global
'http://www.subito.it/',
# Why: #581 in Alexa global
'http://www.rbc.ru/',
# Why: #582 in Alexa global
'http://sfr.fr/',
# Why: #584 in Alexa global
'http://www.skyrock.com/',
# Why: #585 in Alexa global
'http://priceline.com/',
# Why: #586 in Alexa global
'http://www.jabong.com/',
# Why: #587 in Alexa global
'http://www.y8.com/',
# Why: #588 in Alexa global
'http://www.wunderground.com/',
# Why: #589 in Alexa global
'http://mixi.jp/',
# Why: #590 in Alexa global
'http://www.habrahabr.ru/',
# Why: #591 in Alexa global
'http://www.softpedia.com/',
# Why: #592 in Alexa global
'http://www.ancestry.com/',
# Why: #593 in Alexa global
'http://bluehost.com/',
# Why: #594 in Alexa global
'http://www.123rf.com/',
# Why: #595 in Alexa global
'http://lowes.com/',
# Why: #596 in Alexa global
'http://www.free-tv-video-online.me/',
# Why: #597 in Alexa global
'http://tabelog.com/',
# Why: #598 in Alexa global
'http://www.vehnix.com/',
# Why: #599 in Alexa global
'http://55bbs.com/',
# Why: #600 in Alexa global
'http://www.swagbucks.com/',
# Why: #601 in Alexa global
'http://www.speedanalysis.net/',
# Why: #603 in Alexa global
'http://www.virgilio.it/',
# Why: #604 in Alexa global
'http://www.peyvandha.ir/',
# Why: #605 in Alexa global
'http://www.infusionsoft.com/',
# Why: #606 in Alexa global
'http://newegg.com/',
# Why: #608 in Alexa global
'http://www.sulekha.com/',
# Why: #609 in Alexa global
'http://myspace.com/',
# Why: #610 in Alexa global
'http://yxlady.com/',
# Why: #611 in Alexa global
'http://www.haber7.com/',
# Why: #612 in Alexa global
'http://www.w3.org/',
# Why: #613 in Alexa global
'http://squidoo.com/',
# Why: #614 in Alexa global
'http://www.hotels.com/',
# Why: #615 in Alexa global
'http://oracle.com/',
# Why: #616 in Alexa global
'http://fatakat.com/',
# Why: #617 in Alexa global
'http://www.joomla.org/',
# Why: #618 in Alexa global
'http://qidian.com/',
# Why: #619 in Alexa global
'http://hatena.ne.jp/',
# Why: #620 in Alexa global
'http://adbooth.net/',
# Why: #621 in Alexa global
'http://wretch.cc/',
# Why: #622 in Alexa global
'http://www.freelancer.com/',
# Why: #623 in Alexa global
'http://www.typepad.com/',
# Why: #624 in Alexa global
'http://foxsports.com/',
# Why: #625 in Alexa global
'http://www.allrecipes.com/',
# Why: #626 in Alexa global
'http://www.searchengines.ru/',
# Why: #628 in Alexa global
'http://babytree.com/',
# Why: #629 in Alexa global
'http://interia.pl/',
# Why: #630 in Alexa global
'http://xhamstercams.com/',
# Why: #632 in Alexa global
'http://www.verizon.com/',
# Why: #633 in Alexa global
'http://intoday.in/',
# Why: #634 in Alexa global
'http://sears.com/',
# Why: #635 in Alexa global
'http://www.okcupid.com/',
# Why: #636 in Alexa global
'http://6.cn/',
# Why: #637 in Alexa global
'http://kompas.com/',
# Why: #638 in Alexa global
'http://cj.com/',
# Why: #639 in Alexa global
'http://www.4tube.com/',
# Why: #640 in Alexa global
'http://www.chip.de/',
# Why: #641 in Alexa global
'http://force.com/',
# Why: #643 in Alexa global
'http://www.advertserve.com/',
# Why: #644 in Alexa global
'http://maktoob.com/',
# Why: #645 in Alexa global
'http://www.24h.com.vn/',
# Why: #646 in Alexa global
'http://foursquare.com/',
# Why: #647 in Alexa global
'http://cbsnews.com/',
# Why: #648 in Alexa global
'http://pornhublive.com/',
# Why: #649 in Alexa global
'http://www.xda-developers.com/',
# Why: #651 in Alexa global
'http://www.milanuncios.com/',
# Why: #652 in Alexa global
'http://retailmenot.com/',
# Why: #653 in Alexa global
'http://www.keezmovies.com/',
# Why: #654 in Alexa global
'http://nydailynews.com/',
# Why: #655 in Alexa global
'http://h2porn.com/',
# Why: #656 in Alexa global
'http://www.careerbuilder.com/',
# Why: #657 in Alexa global
'http://xing.com/',
# Why: #658 in Alexa global
'http://www.sakura.ne.jp/',
# Why: #659 in Alexa global
'http://citibank.com/',
# Why: #660 in Alexa global
'http://www.linkwithin.com/',
# Why: #661 in Alexa global
'http://www.blogspot.jp/',
# Why: #662 in Alexa global
'http://singlessalad.com/',
# Why: #663 in Alexa global
'http://www.altervista.org/',
# Why: #664 in Alexa global
'http://www.turbobit.net/',
# Why: #665 in Alexa global
'http://www.zoosk.com/',
# Why: #666 in Alexa global
'http://www.digg.com/',
# Why: #667 in Alexa global
'http://hespress.com/',
# Why: #668 in Alexa global
'http://bigpoint.com/',
# Why: #669 in Alexa global
'http://www.yourlust.com/',
# Why: #670 in Alexa global
'http://www.myntra.com/',
# Why: #671 in Alexa global
'http://issuu.com/',
# Why: #672 in Alexa global
'http://macys.com/',
# Why: #673 in Alexa global
'http://google.bg/',
# Why: #674 in Alexa global
'http://github.io/',
# Why: #675 in Alexa global
'http://filestube.com/',
# Why: #677 in Alexa global
'http://cmbchina.com/',
# Why: #678 in Alexa global
'http://irctc.co.in/',
# Why: #679 in Alexa global
'http://filehippo.com/',
# Why: #680 in Alexa global
'http://mop.com/',
# Why: #681 in Alexa global
'http://bodybuilding.com/',
# Why: #682 in Alexa global
'http://www.paidui.com/',
# Why: #683 in Alexa global
'http://zimbio.com/',
# Why: #684 in Alexa global
'http://www.panet.co.il/',
# Why: #685 in Alexa global
'http://www.mgid.com/',
# Why: #686 in Alexa global
'http://www.ya.ru/',
# Why: #687 in Alexa global
'http://probux.com/',
# Why: #688 in Alexa global
'http://haberturk.com/',
# Why: #689 in Alexa global
'http://persianblog.ir/',
# Why: #690 in Alexa global
'http://meituan.com/',
# Why: #691 in Alexa global
'http://www.mercadolibre.com.mx/',
# Why: #692 in Alexa global
'http://ppstream.com/',
# Why: #693 in Alexa global
'http://www.atwiki.jp/',
# Why: #694 in Alexa global
'http://sunporno.com/',
# Why: #695 in Alexa global
'http://vodly.to/',
# Why: #696 in Alexa global
'http://forgeofempires.com/',
# Why: #697 in Alexa global
'http://elance.com/',
# Why: #698 in Alexa global
'http://adscale.de/',
# Why: #699 in Alexa global
'http://vipshop.com/',
# Why: #700 in Alexa global
'http://babycenter.com/',
# Why: #701 in Alexa global
'http://istockphoto.com/',
# Why: #702 in Alexa global
'http://www.commentcamarche.net/',
# Why: #704 in Alexa global
'http://upworthy.com/',
# Why: #705 in Alexa global
'http://www.download.com/',
# Why: #706 in Alexa global
'http://www.so-net.ne.jp/',
# Why: #707 in Alexa global
'http://battle.net/',
# Why: #708 in Alexa global
'http://beva.com/',
# Why: #709 in Alexa global
'http://list-manage.com/',
# Why: #710 in Alexa global
'http://www.corriere.it/',
# Why: #711 in Alexa global
'http://noticias24.com/',
# Why: #712 in Alexa global
'http://www.ucoz.com/',
# Why: #713 in Alexa global
'http://www.porn.com/',
# Why: #714 in Alexa global
'http://www.google.lk/',
# Why: #715 in Alexa global
'http://www.lifehacker.com/',
# Why: #716 in Alexa global
'http://www.today.com/',
# Why: #717 in Alexa global
'http://chinabyte.com/',
# Why: #718 in Alexa global
'http://southwest.com/',
# Why: #719 in Alexa global
'http://www.ca.gov/',
# Why: #720 in Alexa global
'http://nudevista.com/',
# Why: #721 in Alexa global
'http://www.yandex.com.tr/',
# Why: #722 in Alexa global
'http://people.com/',
# Why: #723 in Alexa global
'http://www.docin.com/',
# Why: #724 in Alexa global
'http://www.norton.com/',
# Why: #725 in Alexa global
'http://perfectgirls.net/',
# Why: #726 in Alexa global
'http://www.engadget.com/',
# Why: #727 in Alexa global
'http://www.realtor.com/',
# Why: #728 in Alexa global
'http://www.techcrunch.com/',
# Why: #729 in Alexa global
'http://www.time.com/',
# Why: #730 in Alexa global
'http://indianrail.gov.in/',
# Why: #731 in Alexa global
'http://www.dtiblog.com/',
# Why: #732 in Alexa global
'http://www.way2sms.com/',
# Why: #733 in Alexa global
'http://foodnetwork.com/',
# Why: #735 in Alexa global
'http://subscene.com/',
# Why: #736 in Alexa global
'http://www.worldstarhiphop.com/',
# Why: #737 in Alexa global
'http://tabnak.ir/',
# Why: #738 in Alexa global
'http://weather.com.cn/',
# Why: #739 in Alexa global
'http://aeriagames.com/',
# Why: #741 in Alexa global
'http://leagueoflegends.com/',
# Why: #742 in Alexa global
'http://51.la/',
# Why: #743 in Alexa global
'http://www.facenama.com/',
# Why: #744 in Alexa global
'http://189.cn/',
# Why: #745 in Alexa global
'http://sapo.pt/',
# Why: #746 in Alexa global
'http://www.bitshare.com/',
# Why: #748 in Alexa global
'http://gamespot.com/',
# Why: #749 in Alexa global
'http://cy-pr.com/',
# Why: #750 in Alexa global
'http://kankan.com/',
# Why: #751 in Alexa global
'http://google.co.nz/',
# Why: #752 in Alexa global
'http://www.liveleak.com/',
# Why: #753 in Alexa global
'http://video-one.com/',
# Why: #754 in Alexa global
'http://marktplaats.nl/',
# Why: #755 in Alexa global
'http://elwatannews.com/',
# Why: #756 in Alexa global
'http://www.roulettebotplus.com/',
# Why: #757 in Alexa global
'http://www.adserverplus.com/',
# Why: #758 in Alexa global
'http://www.akhbarak.net/',
# Why: #759 in Alexa global
'http://gumtree.com/',
# Why: #760 in Alexa global
'http://weheartit.com/',
# Why: #761 in Alexa global
'http://www.openadserving.com/',
# Why: #762 in Alexa global
'http://sporx.com/',
# Why: #763 in Alexa global
'http://www.focus.cn/',
# Why: #764 in Alexa global
'http://www.mercadolibre.com.ve/',
# Why: #765 in Alexa global
'http://www.zendesk.com/',
# Why: #766 in Alexa global
'http://www.houzz.com/',
# Why: #767 in Alexa global
'http://asos.com/',
# Why: #768 in Alexa global
'http://www.letitbit.net/',
# Why: #769 in Alexa global
'http://www.geocities.jp/',
# Why: #770 in Alexa global
'http://www.ocn.ne.jp/',
# Why: #771 in Alexa global
'http://quora.com/',
# Why: #772 in Alexa global
'http://www.yandex.kz/',
# Why: #773 in Alexa global
'http://www.mcafee.com/',
# Why: #774 in Alexa global
'http://www.ensonhaber.com/',
# Why: #775 in Alexa global
'http://www.gamefaqs.com/',
# Why: #776 in Alexa global
'http://vk.me/',
# Why: #777 in Alexa global
'http://avast.com/',
# Why: #778 in Alexa global
'http://website-unavailable.com/',
# Why: #779 in Alexa global
'http://www.22find.com/',
# Why: #780 in Alexa global
'http://www.admagnet.net/',
# Why: #781 in Alexa global
'http://rottentomatoes.com/',
# Why: #782 in Alexa global
'http://google.com.kw/',
# Why: #783 in Alexa global
'http://www.cloob.com/',
# Why: #784 in Alexa global
'http://www.nokia.com/',
# Why: #785 in Alexa global
'http://wetter.com/',
# Why: #786 in Alexa global
'http://www.taboola.com/',
# Why: #787 in Alexa global
'http://www.tenpay.com/',
# Why: #788 in Alexa global
'http://www.888.com/',
# Why: #789 in Alexa global
'http://flipora.com/',
# Why: #790 in Alexa global
'http://www.adhitprofits.com/',
# Why: #791 in Alexa global
'http://www.timeanddate.com/',
# Why: #792 in Alexa global
'http://www.as.com/',
# Why: #793 in Alexa global
'http://www.fanpop.com/',
# Why: #794 in Alexa global
'http://informer.com/',
# Why: #795 in Alexa global
'http://www.blogimg.jp/',
# Why: #796 in Alexa global
'http://exblog.jp/',
# Why: #797 in Alexa global
'http://www.over-blog.com/',
# Why: #798 in Alexa global
'http://www.itau.com.br/',
# Why: #799 in Alexa global
'http://balagana.net/',
# Why: #800 in Alexa global
'http://www.ellechina.com/',
# Why: #801 in Alexa global
'http://avazutracking.net/',
# Why: #802 in Alexa global
'http://www.gap.com/',
# Why: #803 in Alexa global
'http://www.examiner.com/',
# Why: #804 in Alexa global
'http://www.vporn.com/',
# Why: #805 in Alexa global
'http://lenovo.com/',
# Why: #806 in Alexa global
'http://www.eonline.com/',
# Why: #807 in Alexa global
'http://r7.com/',
# Why: #808 in Alexa global
'http://majesticseo.com/',
# Why: #809 in Alexa global
'http://immobilienscout24.de/',
# Why: #810 in Alexa global
'http://www.google.kz/',
# Why: #811 in Alexa global
'http://goo.gl/',
# Why: #812 in Alexa global
'http://zwaar.net/',
# Why: #814 in Alexa global
'http://www.bankmellat.ir/',
# Why: #815 in Alexa global
'http://alphaporno.com/',
# Why: #816 in Alexa global
'http://whitepages.com/',
# Why: #817 in Alexa global
'http://viva.co.id/',
# Why: #818 in Alexa global
'http://www.rutor.org/',
# Why: #819 in Alexa global
'http://wiktionary.org/',
# Why: #820 in Alexa global
'http://intuit.com/',
# Why: #821 in Alexa global
'http://www.gismeteo.ru/',
# Why: #822 in Alexa global
'http://dantri.com.vn/',
# Why: #823 in Alexa global
'http://www.xbox.com/',
# Why: #824 in Alexa global
'http://www.myegy.com/',
# Why: #825 in Alexa global
'http://www.xtube.com/',
# Why: #826 in Alexa global
'http://masrawy.com/',
# Why: #827 in Alexa global
'http://www.urbandictionary.com/',
# Why: #828 in Alexa global
'http://agoda.com/',
# Why: #829 in Alexa global
'http://www.ebay.fr/',
# Why: #830 in Alexa global
'http://www.kickstarter.com/',
# Why: #831 in Alexa global
'http://www.6park.com/',
# Why: #832 in Alexa global
'http://www.metacafe.com/',
# Why: #833 in Alexa global
'http://www.yamahaonlinestore.com/',
# Why: #834 in Alexa global
'http://www.anysex.com/',
# Why: #835 in Alexa global
'http://www.azlyrics.com/',
# Why: #836 in Alexa global
'http://www.rt.com/',
# Why: #837 in Alexa global
'http://www.ibm.com/',
# Why: #838 in Alexa global
'http://www.nordstrom.com/',
# Why: #839 in Alexa global
'http://ezinearticles.com/',
# Why: #840 in Alexa global
'http://www.cnbc.com/',
# Why: #841 in Alexa global
'http://redtubelive.com/',
# Why: #842 in Alexa global
'http://clicksvenue.com/',
# Why: #843 in Alexa global
'http://www.tradus.com/',
# Why: #844 in Alexa global
'http://www.gamer.com.tw/',
# Why: #846 in Alexa global
'http://www.m2newmedia.com/',
# Why: #848 in Alexa global
'http://www.custhelp.com/',
# Why: #849 in Alexa global
'http://www.4chan.org/',
# Why: #850 in Alexa global
'http://www.kioskea.net/',
# Why: #851 in Alexa global
'http://yoka.com/',
# Why: #852 in Alexa global
'http://www.7k7k.com/',
# Why: #853 in Alexa global
'http://www.opensiteexplorer.org/',
# Why: #854 in Alexa global
'http://www.musica.com/',
# Why: #855 in Alexa global
'http://www.coupons.com/',
# Why: #856 in Alexa global
'http://cracked.com/',
# Why: #857 in Alexa global
'http://www.caixa.gov.br/',
# Why: #858 in Alexa global
'http://www.skysports.com/',
# Why: #859 in Alexa global
'http://www.kizi.com/',
# Why: #860 in Alexa global
'http://www.getresponse.com/',
# Why: #861 in Alexa global
'http://www.sky.com/',
# Why: #862 in Alexa global
'http://www.marketwatch.com/',
# Why: #863 in Alexa global
'http://www.google.com.ec/',
# Why: #864 in Alexa global
'http://www.cbslocal.com/',
# Why: #865 in Alexa global
'http://www.zhihu.com/',
# Why: #866 in Alexa global
'http://www.888poker.com/',
# Why: #867 in Alexa global
'http://www.digitalpoint.com/',
# Why: #868 in Alexa global
'http://www.blog.163.com/',
# Why: #869 in Alexa global
'http://www.rantsports.com/',
# Why: #870 in Alexa global
'http://videosexarchive.com/',
# Why: #871 in Alexa global
'http://www.who.is/',
# Why: #875 in Alexa global
'http://www.gogetlinks.net/',
# Why: #876 in Alexa global
'http://www.idnes.cz/',
# Why: #877 in Alexa global
'http://www.king.com/',
# Why: #878 in Alexa global
'http://www.say-move.org/',
# Why: #879 in Alexa global
'http://www.motherless.com/',
# Why: #880 in Alexa global
'http://www.npr.org/',
# Why: #881 in Alexa global
'http://www.legacy.com/',
# Why: #882 in Alexa global
'http://www.aljazeera.net/',
# Why: #883 in Alexa global
'http://barnesandnoble.com/',
# Why: #884 in Alexa global
'http://www.overstock.com/',
# Why: #885 in Alexa global
'http://www.drom.ru/',
# Why: #886 in Alexa global
'http://www.weather.gov/',
# Why: #887 in Alexa global
'http://gstatic.com/',
# Why: #888 in Alexa global
'http://www.amung.us/',
# Why: #889 in Alexa global
'http://www.traidnt.net/',
# Why: #890 in Alexa global
'http://www.ovh.net/',
# Why: #891 in Alexa global
'http://www.rtl.de/',
# Why: #892 in Alexa global
'http://howstuffworks.com/',
# Why: #893 in Alexa global
'http://digikala.com/',
# Why: #894 in Alexa global
'http://www.bannersbroker.com/',
# Why: #895 in Alexa global
'http://www.kohls.com/',
# Why: #896 in Alexa global
'http://www.google.com.do/',
# Why: #897 in Alexa global
'http://www.dealfish.co.th/',
# Why: #899 in Alexa global
'http://19lou.com/',
# Why: #900 in Alexa global
'http://www.okwave.jp/',
# Why: #901 in Alexa global
'http://www.ezpowerads.com/',
# Why: #902 in Alexa global
'http://www.lemonde.fr/',
# Why: #904 in Alexa global
'http://www.chexun.com/',
# Why: #905 in Alexa global
'http://folha.uol.com.br/',
# Why: #906 in Alexa global
'http://www.imagebam.com/',
# Why: #907 in Alexa global
'http://viooz.co/',
# Why: #908 in Alexa global
'http://www.prothom-alo.com/',
# Why: #909 in Alexa global
'http://360doc.com/',
# Why: #910 in Alexa global
'http://m-w.com/',
# Why: #912 in Alexa global
'http://fanfiction.net/',
# Why: #914 in Alexa global
'http://semrush.com/',
# Why: #915 in Alexa global
'http://www.mama.cn/',
# Why: #916 in Alexa global
'http://ci123.com/',
# Why: #917 in Alexa global
'http://www.plugrush.com/',
# Why: #918 in Alexa global
'http://www.cafemom.com/',
# Why: #919 in Alexa global
'http://mangareader.net/',
# Why: #920 in Alexa global
'http://haizhangs.com/',
# Why: #921 in Alexa global
'http://cdiscount.com/',
# Why: #922 in Alexa global
'http://zappos.com/',
# Why: #923 in Alexa global
'http://www.manta.com/',
# Why: #924 in Alexa global
'http://www.novinky.cz/',
# Why: #925 in Alexa global
'http://www.hi5.com/',
# Why: #926 in Alexa global
'http://www.blogspot.kr/',
# Why: #927 in Alexa global
'http://www.pr-cy.ru/',
# Why: #928 in Alexa global
'http://movie4k.to/',
# Why: #929 in Alexa global
'http://www.patch.com/',
# Why: #930 in Alexa global
'http://alarabiya.net/',
# Why: #931 in Alexa global
'http://indiamart.com/',
# Why: #932 in Alexa global
'http://www.nhk.or.jp/',
# Why: #933 in Alexa global
'http://cartrailor.com/',
# Why: #934 in Alexa global
'http://almasryalyoum.com/',
# Why: #935 in Alexa global
'http://315che.com/',
# Why: #936 in Alexa global
'http://www.google.by/',
# Why: #937 in Alexa global
'http://tomshardware.com/',
# Why: #938 in Alexa global
'http://minecraft.net/',
# Why: #939 in Alexa global
'http://www.gulfup.com/',
# Why: #940 in Alexa global
'http://www.rr.com/',
# Why: #942 in Alexa global
'http://www.spotify.com/',
# Why: #943 in Alexa global
'http://www.airtel.in/',
# Why: #944 in Alexa global
'http://www.espnfc.com/',
# Why: #945 in Alexa global
'http://sanook.com/',
# Why: #946 in Alexa global
'http://ria.ru/',
# Why: #947 in Alexa global
'http://google.com.qa/',
# Why: #948 in Alexa global
'http://jquery.com/',
# Why: #950 in Alexa global
'http://pinshan.com/',
# Why: #951 in Alexa global
'http://onlylady.com/',
# Why: #952 in Alexa global
'http://www.pornoxo.com/',
# Why: #953 in Alexa global
'http://cookpad.com/',
# Why: #954 in Alexa global
'http://www.pagesjaunes.fr/',
# Why: #955 in Alexa global
'http://www.usmagazine.com/',
# Why: #956 in Alexa global
'http://www.google.lt/',
# Why: #957 in Alexa global
'http://www.nu.nl/',
# Why: #958 in Alexa global
'http://www.hm.com/',
# Why: #959 in Alexa global
'http://fixya.com/',
# Why: #960 in Alexa global
'http://theblaze.com/',
# Why: #961 in Alexa global
'http://cbssports.com/',
# Why: #962 in Alexa global
'http://www.eyny.com/',
# Why: #963 in Alexa global
'http://17173.com/',
# Why: #964 in Alexa global
'http://www.excite.co.jp/',
# Why: #965 in Alexa global
'http://hc360.com/',
# Why: #966 in Alexa global
'http://www.cbs.com/',
# Why: #967 in Alexa global
'http://www.telegraaf.nl/',
# Why: #968 in Alexa global
'http://netlog.com/',
# Why: #969 in Alexa global
'http://voc.com.cn/',
# Why: #970 in Alexa global
'http://slickdeals.net/',
# Why: #971 in Alexa global
'http://www.ldblog.jp/',
# Why: #972 in Alexa global
'http://ruten.com.tw/',
# Why: #973 in Alexa global
'http://yobt.com/',
# Why: #974 in Alexa global
'http://certified-toolbar.com/',
# Why: #975 in Alexa global
'http://miercn.com/',
# Why: #976 in Alexa global
'http://aparat.com/',
# Why: #977 in Alexa global
'http://billdesk.com/',
# Why: #978 in Alexa global
'http://yandex.by/',
# Why: #979 in Alexa global
'http://888casino.com/',
# Why: #980 in Alexa global
'http://twitpic.com/',
# Why: #981 in Alexa global
'http://google.hr/',
# Why: #982 in Alexa global
'http://tubegalore.com/',
# Why: #983 in Alexa global
'http://dhgate.com/',
# Why: #984 in Alexa global
'http://makemytrip.com/',
# Why: #986 in Alexa global
'http://shop.com/',
# Why: #987 in Alexa global
'http://www.nike.com/',
# Why: #988 in Alexa global
'http://kayak.com/',
# Why: #989 in Alexa global
'http://pcbaby.com.cn/',
# Why: #990 in Alexa global
'http://fandango.com/',
# Why: #991 in Alexa global
'http://tutsplus.com/',
# Why: #992 in Alexa global
'http://gotomeeting.com/',
# Why: #994 in Alexa global
'http://shareasale.com/',
# Why: #995 in Alexa global
'http://www.boc.cn/',
# Why: #996 in Alexa global
'http://mpnrs.com/',
# Why: #997 in Alexa global
'http://keepvid.com/',
# Why: #998 in Alexa global
'http://www.lequipe.fr/',
# Why: #999 in Alexa global
'http://namecheap.com/',
# Why: #1000 in Alexa global
'http://doublepimp.com/',
# Why: #1001 in Alexa global
'http://softigloo.com/',
# Why: #1002 in Alexa global
'http://givemesport.com/',
# Why: #1003 in Alexa global
'http://mtime.com/',
# Why: #1004 in Alexa global
'http://letras.mus.br/',
# Why: #1005 in Alexa global
'http://pole-emploi.fr/',
# Why: #1006 in Alexa global
'http://biblegateway.com/',
# Why: #1007 in Alexa global
'http://independent.co.uk/',
# Why: #1009 in Alexa global
'http://e-hentai.org/',
# Why: #1010 in Alexa global
'http://www.gumtree.com.au/',
# Why: #1011 in Alexa global
'http://livestrong.com/',
# Why: #1012 in Alexa global
'http://game321.com/',
# Why: #1014 in Alexa global
'http://www.comcast.com/',
# Why: #1015 in Alexa global
'http://clubpenguin.com/',
# Why: #1016 in Alexa global
'http://rightmove.co.uk/',
# Why: #1017 in Alexa global
'http://steamcommunity.com/',
# Why: #1018 in Alexa global
'http://sockshare.com/',
# Why: #1019 in Alexa global
'http://globalconsumersurvey.com/',
# Why: #1020 in Alexa global
'http://rapidshare.com/',
# Why: #1021 in Alexa global
'http://auto.ru/',
# Why: #1022 in Alexa global
'http://www.staples.com/',
# Why: #1023 in Alexa global
'http://anitube.se/',
# Why: #1024 in Alexa global
'http://rozblog.com/',
# Why: #1025 in Alexa global
'http://reliancenetconnect.co.in/',
# Why: #1026 in Alexa global
'http://credit-agricole.fr/',
# Why: #1027 in Alexa global
'http://exposedwebcams.com/',
# Why: #1028 in Alexa global
'http://www.webalta.ru/',
# Why: #1029 in Alexa global
'http://www.usbank.com/',
# Why: #1030 in Alexa global
'http://www.google.com.ly/',
# Why: #1031 in Alexa global
'http://www.pantip.com/',
# Why: #1032 in Alexa global
'http://aftonbladet.se/',
# Why: #1033 in Alexa global
'http://scoop.it/',
# Why: #1034 in Alexa global
'http://www.mayoclinic.com/',
# Why: #1035 in Alexa global
'http://www.evernote.com/',
# Why: #1036 in Alexa global
'http://www.nyaa.eu/',
# Why: #1037 in Alexa global
'http://www.livingsocial.com/',
# Why: #1038 in Alexa global
'http://www.noaa.gov/',
# Why: #1039 in Alexa global
'http://www.imagefap.com/',
# Why: #1040 in Alexa global
'http://www.abchina.com/',
# Why: #1041 in Alexa global
'http://www.google.rs/',
# Why: #1042 in Alexa global
'http://www.amazon.in/',
# Why: #1043 in Alexa global
'http://www.tnaflix.com/',
# Why: #1044 in Alexa global
'http://www.xici.net/',
# Why: #1045 in Alexa global
'http://www.united.com/',
# Why: #1046 in Alexa global
'http://www.templatemonster.com/',
# Why: #1047 in Alexa global
'http://www.deezer.com/',
# Why: #1048 in Alexa global
'http://www.pixlr.com/',
# Why: #1049 in Alexa global
'http://www.tradedoubler.com/',
# Why: #1050 in Alexa global
'http://www.gumtree.co.za/',
# Why: #1051 in Alexa global
'http://www.r10.net/',
# Why: #1052 in Alexa global
'http://www.kongregate.com/',
# Why: #1053 in Alexa global
'http://www.jeuxvideo.com/',
# Why: #1054 in Alexa global
'http://www.gawker.com/',
# Why: #1055 in Alexa global
'http://chewen.com/',
# Why: #1056 in Alexa global
'http://www.r2games.com/',
# Why: #1057 in Alexa global
'http://www.mayajo.com/',
# Why: #1058 in Alexa global
'http://www.topix.com/',
# Why: #1059 in Alexa global
'http://www.easyhits4u.com/',
# Why: #1060 in Alexa global
'http://www.netteller.com/',
# Why: #1061 in Alexa global
'http://www.ing.nl/',
# Why: #1062 in Alexa global
'http://www.tripadvisor.co.uk/',
# Why: #1063 in Alexa global
'http://www.udn.com/',
# Why: #1064 in Alexa global
'http://www.cheezburger.com/',
# Why: #1065 in Alexa global
'http://www.fotostrana.ru/',
# Why: #1066 in Alexa global
'http://www.bbc.com/',
# Why: #1067 in Alexa global
'http://www.behance.net/',
# Why: #1068 in Alexa global
'http://www.lefigaro.fr/',
# Why: #1069 in Alexa global
'http://www.nikkei.com/',
# Why: #1070 in Alexa global
'http://www.fidelity.com/',
# Why: #1071 in Alexa global
'http://www.baomihua.com/',
# Why: #1072 in Alexa global
'http://www.fool.com/',
# Why: #1073 in Alexa global
'http://www.nairaland.com/',
# Why: #1074 in Alexa global
'http://www.sendspace.com/',
# Why: #1075 in Alexa global
'http://www.woot.com/',
# Why: #1076 in Alexa global
'http://www.travelocity.com/',
# Why: #1077 in Alexa global
'http://www.shopclues.com/',
# Why: #1078 in Alexa global
'http://www.sureonlinefind.com/',
# Why: #1080 in Alexa global
'http://www.gizmodo.com/',
# Why: #1081 in Alexa global
'http://www.hidemyass.com/',
# Why: #1082 in Alexa global
'http://www.o2.pl/',
# Why: #1083 in Alexa global
'http://www.clickbank.net/',
# Why: #1084 in Alexa global
'http://www.fotolia.com/',
# Why: #1085 in Alexa global
'http://www.opera.com/',
# Why: #1086 in Alexa global
'http://www.sabah.com.tr/',
# Why: #1087 in Alexa global
'http://www.n-mobile.net/',
# Why: #1088 in Alexa global
'http://www.chacha.com/',
# Why: #1089 in Alexa global
'http://www.autotrader.com/',
# Why: #1090 in Alexa global
'http://www.anonym.to/',
# Why: #1091 in Alexa global
'http://www.walmart.com.br/',
# Why: #1092 in Alexa global
'http://www.yjc.ir/',
# Why: #1093 in Alexa global
'http://www.autoscout24.de/',
# Why: #1094 in Alexa global
'http://www.gobookee.net/',
# Why: #1096 in Alexa global
'http://www.yaolan.com/',
# Why: #1097 in Alexa global
'http://www.india.com/',
# Why: #1098 in Alexa global
'http://www.tribalfusion.com/',
# Why: #1099 in Alexa global
'http://www.gittigidiyor.com/',
# Why: #1100 in Alexa global
'http://www.otto.de/',
# Why: #1101 in Alexa global
'http://www.adclickxpress.com/',
# Why: #1102 in Alexa global
'http://www.made-in-china.com/',
# Why: #1103 in Alexa global
'http://www.ahram.org.eg/',
# Why: #1104 in Alexa global
'http://www.asriran.com/',
# Why: #1105 in Alexa global
'http://www.blackberry.com/',
# Why: #1106 in Alexa global
'http://www.beytoote.com/',
# Why: #1107 in Alexa global
'http://www.piriform.com/',
# Why: #1108 in Alexa global
'http://www.ilmeteo.it/',
# Why: #1109 in Alexa global
'http://www.att.net/',
# Why: #1110 in Alexa global
'http://www.brainyquote.com/',
# Why: #1111 in Alexa global
'http://www.last.fm/',
# Why: #1112 in Alexa global
'http://www.directadvert.ru/',
# Why: #1113 in Alexa global
'http://www.slate.com/',
# Why: #1114 in Alexa global
'http://www.mangahere.com/',
# Why: #1115 in Alexa global
'http://www.jalan.net/',
# Why: #1116 in Alexa global
'http://www.blog.com/',
# Why: #1117 in Alexa global
'http://www.tuvaro.com/',
# Why: #1118 in Alexa global
'http://www.doc88.com/',
# Why: #1119 in Alexa global
'http://www.mbc.net/',
# Why: #1120 in Alexa global
'http://www.europa.eu/',
# Why: #1121 in Alexa global
'http://www.onlinedown.net/',
# Why: #1122 in Alexa global
'http://www.jcpenney.com/',
# Why: #1123 in Alexa global
'http://www.myplaycity.com/',
# Why: #1124 in Alexa global
'http://www.bahn.de/',
# Why: #1125 in Alexa global
'http://www.laredoute.fr/',
# Why: #1126 in Alexa global
'http://www.alexa.com/',
# Why: #1127 in Alexa global
'http://www.rakuten.ne.jp/',
# Why: #1128 in Alexa global
'http://www.flashx.tv/',
# Why: #1129 in Alexa global
'http://51.com/',
# Why: #1130 in Alexa global
'http://www.mail.com/',
# Why: #1131 in Alexa global
'http://www.costco.com/',
# Why: #1132 in Alexa global
'http://www.mirror.co.uk/',
# Why: #1133 in Alexa global
'http://www.chinadaily.com.cn/',
# Why: #1134 in Alexa global
'http://www.japanpost.jp/',
# Why: #1135 in Alexa global
'http://www.hubspot.com/',
# Why: #1136 in Alexa global
'http://www.tf1.fr/',
# Why: #1137 in Alexa global
'http://www.merdeka.com/',
# Why: #1138 in Alexa global
'http://www.nypost.com/',
# Why: #1139 in Alexa global
'http://www.1mall.com/',
# Why: #1140 in Alexa global
'http://www.wmtransfer.com/',
# Why: #1141 in Alexa global
'http://www.pcmag.com/',
# Why: #1142 in Alexa global
'http://www.univision.com/',
# Why: #1143 in Alexa global
'http://www.nationalgeographic.com/',
# Why: #1144 in Alexa global
'http://www.sourtimes.org/',
# Why: #1145 in Alexa global
'http://www.iciba.com/',
# Why: #1146 in Alexa global
'http://www.petardas.com/',
# Why: #1147 in Alexa global
'http://www.wmmail.ru/',
# Why: #1148 in Alexa global
'http://www.light-dark.net/',
# Why: #1149 in Alexa global
'http://www.ultimate-guitar.com/',
# Why: #1150 in Alexa global
'http://www.koramgame.com/',
# Why: #1151 in Alexa global
'http://www.megavod.fr/',
# Why: #1152 in Alexa global
'http://www.smh.com.au/',
# Why: #1153 in Alexa global
'http://www.ticketmaster.com/',
# Why: #1154 in Alexa global
'http://www.admin5.com/',
# Why: #1155 in Alexa global
'http://get-a-fuck-tonight.com/',
# Why: #1156 in Alexa global
'http://www.eenadu.net/',
# Why: #1157 in Alexa global
'http://www.argos.co.uk/',
# Why: #1159 in Alexa global
'http://www.nipic.com/',
# Why: #1160 in Alexa global
'http://www.google.iq/',
# Why: #1161 in Alexa global
'http://www.alhea.com/',
# Why: #1162 in Alexa global
'http://www.citrixonline.com/',
# Why: #1163 in Alexa global
'http://www.girlsgogames.com/',
# Why: #1164 in Alexa global
'http://www.fanatik.com.tr/',
# Why: #1165 in Alexa global
'http://www.yahoo-mbga.jp/',
# Why: #1166 in Alexa global
'http://www.google.tn/',
# Why: #1167 in Alexa global
'http://www.usaa.com/',
# Why: #1168 in Alexa global
'http://www.earthlink.net/',
# Why: #1169 in Alexa global
'http://www.ryanair.com/',
# Why: #1170 in Alexa global
'http://www.city-data.com/',
# Why: #1171 in Alexa global
'http://www.lloydstsb.co.uk/',
# Why: #1173 in Alexa global
'http://www.pornsharia.com/',
# Why: #1174 in Alexa global
'http://www.blogspot.tw/',
# Why: #1175 in Alexa global
'http://www.baixing.com/',
# Why: #1176 in Alexa global
'http://www.all-free-download.com/',
# Why: #1177 in Alexa global
'http://www.qianyan001.com/',
# Why: #1178 in Alexa global
'http://www.hellporno.com/',
# Why: #1179 in Alexa global
'http://www.pornmd.com/',
# Why: #1180 in Alexa global
'http://www.conferenceplus.com/',
# Why: #1181 in Alexa global
'http://www.docstoc.com/',
# Why: #1182 in Alexa global
'http://www.christian-dogma.com/',
# Why: #1183 in Alexa global
'http://www.sinaimg.cn/',
# Why: #1184 in Alexa global
'http://www.dmoz.org/',
# Why: #1185 in Alexa global
'http://www.perezhilton.com/',
# Why: #1186 in Alexa global
'http://www.mega.co.nz/',
# Why: #1187 in Alexa global
'http://www.pchome.com.tw/',
# Why: #1188 in Alexa global
'http://www.zazzle.com/',
# Why: #1189 in Alexa global
'http://www.echoroukonline.com/',
# Why: #1190 in Alexa global
'http://www.ea.com/',
# Why: #1191 in Alexa global
'http://www.yiqifa.com/',
# Why: #1193 in Alexa global
'http://www.mysearchdial.com/',
# Why: #1194 in Alexa global
'http://www.hotwire.com/',
# Why: #1195 in Alexa global
'http://www.ninemsn.com.au/',
# Why: #1196 in Alexa global
'http://www.tablica.pl/',
# Why: #1197 in Alexa global
'http://www.brazzers.com/',
# Why: #1198 in Alexa global
'http://www.americanas.com.br/',
# Why: #1199 in Alexa global
'http://www.extremetube.com/',
# Why: #1200 in Alexa global
'http://www.zynga.com/',
# Why: #1201 in Alexa global
'http://www.buscape.com.br/',
# Why: #1202 in Alexa global
'http://www.t-mobile.com/',
# Why: #1204 in Alexa global
'http://www.portaldosites.com/',
# Why: #1205 in Alexa global
'http://www.businessweek.com/',
# Why: #1206 in Alexa global
'http://www.feedburner.com/',
# Why: #1207 in Alexa global
'http://www.contenko.com/',
# Why: #1208 in Alexa global
'http://www.homeshop18.com/',
# Why: #1209 in Alexa global
'http://www.bmi.ir/',
# Why: #1210 in Alexa global
'http://www.wwe.com/',
# Why: #1211 in Alexa global
'http://www.adult-empire.com/',
# Why: #1212 in Alexa global
'http://www.nfl.com/',
# Why: #1213 in Alexa global
'http://www.globososo.com/',
# Why: #1214 in Alexa global
'http://www.sfgate.com/',
# Why: #1215 in Alexa global
'http://www.mmotraffic.com/',
# Why: #1216 in Alexa global
'http://www.zalando.de/',
# Why: #1217 in Alexa global
'http://www.warthunder.com/',
# Why: #1218 in Alexa global
'http://www.icloud.com/',
# Why: #1219 in Alexa global
'http://www.xiami.com/',
# Why: #1220 in Alexa global
'http://www.newsmax.com/',
# Why: #1221 in Alexa global
'http://www.solarmovie.so/',
# Why: #1222 in Alexa global
'http://www.junglee.com/',
# Why: #1223 in Alexa global
'http://www.discovercard.com/',
# Why: #1224 in Alexa global
'http://www.hh.ru/',
# Why: #1225 in Alexa global
'http://www.searchengineland.com/',
# Why: #1226 in Alexa global
'http://www.labanquepostale.fr/',
# Why: #1227 in Alexa global
'http://www.51cto.com/',
# Why: #1228 in Alexa global
'http://www.appledaily.com.tw/',
# Why: #1229 in Alexa global
'http://www.fling.com/',
# Why: #1230 in Alexa global
'http://www.liveperson.net/',
# Why: #1231 in Alexa global
'http://www.sulit.com.ph/',
# Why: #1232 in Alexa global
'http://www.tinypic.com/',
# Why: #1233 in Alexa global
'http://www.meilishuo.com/',
# Why: #1234 in Alexa global
'http://googleadservices.com/',
# Why: #1235 in Alexa global
'http://www.boston.com/',
# Why: #1236 in Alexa global
'http://www.chron.com/',
# Why: #1237 in Alexa global
'http://www.breitbart.com/',
# Why: #1238 in Alexa global
'http://www.youjizzlive.com/',
# Why: #1239 in Alexa global
'http://www.commbank.com.au/',
# Why: #1240 in Alexa global
'http://www.axisbank.com/',
# Why: #1241 in Alexa global
'http://www.wired.com/',
# Why: #1242 in Alexa global
'http://www.trialpay.com/',
# Why: #1243 in Alexa global
'http://www.berniaga.com/',
# Why: #1244 in Alexa global
'http://cnmo.com/',
# Why: #1245 in Alexa global
'http://www.tunein.com/',
# Why: #1246 in Alexa global
'http://www.hotfile.com/',
# Why: #1247 in Alexa global
'http://www.dubizzle.com/',
# Why: #1248 in Alexa global
'http://www.olx.com.br/',
# Why: #1249 in Alexa global
'http://haxiu.com/',
# Why: #1250 in Alexa global
'http://www.zulily.com/',
# Why: #1251 in Alexa global
'http://www.infolinks.com/',
# Why: #1252 in Alexa global
'http://www.yourgirlfriends.com/',
# Why: #1253 in Alexa global
'http://www.logmein.com/',
# Why: #1255 in Alexa global
'http://www.irs.gov/',
# Why: #1256 in Alexa global
'http://www.noticiadeldia.com/',
# Why: #1257 in Alexa global
'http://www.nbcsports.com/',
# Why: #1258 in Alexa global
'http://www.holasearch.com/',
# Why: #1259 in Alexa global
'http://www.wo.com.cn/',
# Why: #1260 in Alexa global
'http://www.indianexpress.com/',
# Why: #1261 in Alexa global
'http://www.depositfiles.com/',
# Why: #1262 in Alexa global
'http://www.elfagr.org/',
# Why: #1263 in Alexa global
'http://himado.in/',
# Why: #1264 in Alexa global
'http://www.lumosity.com/',
# Why: #1265 in Alexa global
'http://www.mbank.com.pl/',
# Why: #1266 in Alexa global
'http://www.primewire.ag/',
# Why: #1267 in Alexa global
'http://www.dreamstime.com/',
# Why: #1268 in Alexa global
'http://sootoo.com/',
# Why: #1269 in Alexa global
'http://www.souq.com/',
# Why: #1270 in Alexa global
'http://www.weblio.jp/',
# Why: #1272 in Alexa global
'http://www.craigslist.ca/',
# Why: #1273 in Alexa global
'http://www.zara.com/',
# Why: #1274 in Alexa global
'http://www.cheshi.com.cn/',
# Why: #1275 in Alexa global
'http://www.groupon.it/',
# Why: #1276 in Alexa global
'http://www.mangafox.me/',
# Why: #1277 in Alexa global
'http://www.casino.com/',
# Why: #1278 in Alexa global
'http://www.armorgames.com/',
# Why: #1279 in Alexa global
'http://www.zanox.com/',
# Why: #1280 in Alexa global
'http://www.finn.no/',
# Why: #1281 in Alexa global
'http://www.qihoo.com/',
# Why: #1282 in Alexa global
'http://www.toysrus.com/',
# Why: #1283 in Alexa global
'http://www.airasia.com/',
# Why: #1284 in Alexa global
'http://www.dafont.com/',
# Why: #1285 in Alexa global
'http://www.tvmuse.eu/',
# Why: #1286 in Alexa global
'http://www.pnc.com/',
# Why: #1287 in Alexa global
'http://www.donanimhaber.com/',
# Why: #1288 in Alexa global
'http://cnbeta.com/',
# Why: #1289 in Alexa global
'http://www.prntscr.com/',
# Why: #1290 in Alexa global
'http://www.cox.net/',
# Why: #1291 in Alexa global
'http://www.bloglovin.com/',
# Why: #1292 in Alexa global
'http://www.picmonkey.com/',
# Why: #1293 in Alexa global
'http://www.zoho.com/',
# Why: #1294 in Alexa global
'http://www.glassdoor.com/',
# Why: #1295 in Alexa global
'http://www.myfitnesspal.com/',
# Why: #1296 in Alexa global
'http://www.change.org/',
# Why: #1297 in Alexa global
'http://www.aa.com/',
# Why: #1298 in Alexa global
'http://www.playstation.com/',
# Why: #1300 in Alexa global
'http://www.b1.org/',
# Why: #1301 in Alexa global
'http://www.correios.com.br/',
# Why: #1302 in Alexa global
'http://www.hindustantimes.com/',
# Why: #1303 in Alexa global
'http://www.softlayer.com/',
# Why: #1304 in Alexa global
'http://www.imagevenue.com/',
# Why: #1305 in Alexa global
'http://www.windowsphone.com/',
# Why: #1306 in Alexa global
'http://www.wikimapia.org/',
# Why: #1307 in Alexa global
'http://www.transfermarkt.de/',
# Why: #1308 in Alexa global
'http://www.dict.cc/',
# Why: #1309 in Alexa global
'http://www.blocket.se/',
# Why: #1310 in Alexa global
'http://www.lacaixa.es/',
# Why: #1311 in Alexa global
'http://www.hilton.com/',
# Why: #1312 in Alexa global
'http://www.mtv.com/',
# Why: #1313 in Alexa global
'http://www.cbc.ca/',
# Why: #1314 in Alexa global
'http://www.msn.ca/',
# Why: #1315 in Alexa global
'http://www.box.com/',
# Why: #1316 in Alexa global
'http://www.szn.cz/',
# Why: #1317 in Alexa global
'http://www.haodf.com/',
# Why: #1318 in Alexa global
'http://www.monsterindia.com/',
# Why: #1319 in Alexa global
'http://www.okezone.com/',
# Why: #1320 in Alexa global
'http://www.entertainment-factory.com/',
# Why: #1321 in Alexa global
'http://www.linternaute.com/',
# Why: #1322 in Alexa global
'http://www.break.com/',
# Why: #1323 in Alexa global
'http://www.ustream.tv/',
# Why: #1324 in Alexa global
'http://www.songspk.name/',
# Why: #1325 in Alexa global
'http://www.bilibili.tv/',
# Why: #1326 in Alexa global
'http://www.avira.com/',
# Why: #1327 in Alexa global
'http://www.thehindu.com/',
# Why: #1328 in Alexa global
'http://www.watchmygf.com/',
# Why: #1329 in Alexa global
'http://www.google.co.ma/',
# Why: #1330 in Alexa global
'http://www.nick.com/',
# Why: #1331 in Alexa global
'http://www.sp.gov.br/',
# Why: #1332 in Alexa global
'http://www.zeobit.com/',
# Why: #1333 in Alexa global
'http://www.sprint.com/',
# Why: #1334 in Alexa global
'http://www.khabaronline.ir/',
# Why: #1335 in Alexa global
'http://www.magentocommerce.com/',
# Why: #1336 in Alexa global
'http://www.hsbc.co.uk/',
# Why: #1337 in Alexa global
'http://www.trafficholder.com/',
# Why: #1338 in Alexa global
'http://www.gamestop.com/',
# Why: #1339 in Alexa global
'http://www.cartoonnetwork.com/',
# Why: #1340 in Alexa global
'http://www.fifa.com/',
# Why: #1341 in Alexa global
'http://www.ebay.ca/',
# Why: #1342 in Alexa global
'http://www.vatanim.com.tr/',
# Why: #1343 in Alexa global
'http://www.qvc.com/',
# Why: #1344 in Alexa global
'http://www.marriott.com/',
# Why: #1345 in Alexa global
'http://www.eventbrite.com/',
# Why: #1346 in Alexa global
'http://www.gi-akademie.com/',
# Why: #1347 in Alexa global
'http://www.intel.com/',
# Why: #1348 in Alexa global
'http://www.oschina.net/',
# Why: #1349 in Alexa global
'http://www.dojki.com/',
# Why: #1350 in Alexa global
'http://www.thechive.com/',
# Why: #1351 in Alexa global
'http://www.viadeo.com/',
# Why: #1352 in Alexa global
'http://www.walgreens.com/',
# Why: #1353 in Alexa global
'http://www.leo.org/',
# Why: #1354 in Alexa global
'http://www.statscrop.com/',
# Why: #1355 in Alexa global
'http://www.brothersoft.com/',
# Why: #1356 in Alexa global
'http://www.allocine.fr/',
# Why: #1357 in Alexa global
'http://www.slutload.com/',
# Why: #1358 in Alexa global
'http://www.google.com.gt/',
# Why: #1359 in Alexa global
'http://www.santabanta.com/',
# Why: #1360 in Alexa global
'http://www.stardoll.com/',
# Why: #1361 in Alexa global
'http://www.polyvore.com/',
# Why: #1362 in Alexa global
'http://www.focus.de/',
# Why: #1363 in Alexa global
'http://www.duckduckgo.com/',
# Why: #1364 in Alexa global
'http://www.funshion.com/',
# Why: #1365 in Alexa global
'http://www.marieclairechina.com/',
# Why: #1366 in Alexa global
'http://www.internethaber.com/',
# Why: #1367 in Alexa global
'http://www.worldoftanks.ru/',
# Why: #1369 in Alexa global
'http://www.1und1.de/',
# Why: #1370 in Alexa global
'http://www.anyporn.com/',
# Why: #1371 in Alexa global
'http://www.17u.cn/',
# Why: #1372 in Alexa global
'http://www.cars.com/',
# Why: #1373 in Alexa global
'http://www.asg.to/',
# Why: #1374 in Alexa global
'http://www.alice.it/',
# Why: #1375 in Alexa global
'http://www.hongkiat.com/',
# Why: #1376 in Alexa global
'http://www.bhphotovideo.com/',
# Why: #1377 in Alexa global
'http://www.bdnews24.com/',
# Why: #1378 in Alexa global
'http://sdo.com/',
# Why: #1379 in Alexa global
'http://www.cerdas.com/',
# Why: #1380 in Alexa global
'http://www.clarin.com/',
# Why: #1381 in Alexa global
'http://www.victoriassecret.com/',
# Why: #1382 in Alexa global
'http://www.instructables.com/',
# Why: #1383 in Alexa global
'http://www.state.gov/',
# Why: #1384 in Alexa global
'http://www.agame.com/',
# Why: #1385 in Alexa global
'http://www.xiaomi.com/',
# Why: #1386 in Alexa global
'http://esporte.uol.com.br/',
# Why: #1387 in Alexa global
'http://www.adfoc.us/',
# Why: #1388 in Alexa global
'http://www.telekom.com/',
# Why: #1389 in Alexa global
'http://www.skycn.com/',
# Why: #1390 in Alexa global
'http://www.orbitz.com/',
# Why: #1391 in Alexa global
'http://www.nhl.com/',
# Why: #1392 in Alexa global
'http://www.vistaprint.com/',
# Why: #1393 in Alexa global
'http://trklnks.com/',
# Why: #1394 in Alexa global
'http://www.basecamp.com/',
# Why: #1395 in Alexa global
'http://www.hot-sex-tube.com/',
# Why: #1396 in Alexa global
'http://www.incredibar-search.com/',
# Why: #1397 in Alexa global
'http://www.qingdaonews.com/',
# Why: #1398 in Alexa global
'http://www.sabq.org/',
# Why: #1399 in Alexa global
'http://www.nasa.gov/',
# Why: #1400 in Alexa global
'http://www.dx.com/',
# Why: #1401 in Alexa global
'http://www.addmefast.com/',
# Why: #1402 in Alexa global
'http://www.yepi.com/',
# Why: #1403 in Alexa global
'http://www.xxx-ok.com/',
# Why: #1405 in Alexa global
'http://www.sex.com/',
# Why: #1406 in Alexa global
'http://www.food.com/',
# Why: #1407 in Alexa global
'http://www.freeones.com/',
# Why: #1408 in Alexa global
'http://www.tesco.com/',
# Why: #1409 in Alexa global
'http://www.a10.com/',
# Why: #1410 in Alexa global
'http://www.mynavi.jp/',
# Why: #1411 in Alexa global
'http://www.abc.net.au/',
# Why: #1412 in Alexa global
'http://www.internetdownloadmanager.com/',
# Why: #1413 in Alexa global
'http://www.seowhy.com/',
# Why: #1414 in Alexa global
'http://114so.cn/',
# Why: #1415 in Alexa global
'http://www.otomoto.pl/',
# Why: #1416 in Alexa global
'http://www.idealo.de/',
# Why: #1417 in Alexa global
'http://www.laposte.net/',
# Why: #1418 in Alexa global
'http://www.eroprofile.com/',
# Why: #1419 in Alexa global
'http://www.bbb.org/',
# Why: #1420 in Alexa global
'http://www.gnavi.co.jp/',
# Why: #1421 in Alexa global
'http://www.tiu.ru/',
# Why: #1422 in Alexa global
'http://www.blogsky.com/',
# Why: #1423 in Alexa global
'http://www.bigfishgames.com/',
# Why: #1424 in Alexa global
'http://www.weiphone.com/',
# Why: #1425 in Alexa global
'http://www.livescore.com/',
# Why: #1426 in Alexa global
'http://www.tubepleasure.com/',
# Why: #1427 in Alexa global
'http://www.net.cn/',
# Why: #1428 in Alexa global
'http://www.jagran.com/',
# Why: #1429 in Alexa global
'http://www.livestream.com/',
# Why: #1430 in Alexa global
'http://stagram.com/',
# Why: #1431 in Alexa global
'http://www.vine.co/',
# Why: #1432 in Alexa global
'http://www.olx.com.pk/',
# Why: #1433 in Alexa global
'http://www.edmunds.com/',
# Why: #1434 in Alexa global
'http://www.banglanews24.com/',
# Why: #1435 in Alexa global
'http://www.reverso.net/',
# Why: #1436 in Alexa global
'http://www.stargames.at/',
# Why: #1437 in Alexa global
'http://www.postimg.org/',
# Why: #1438 in Alexa global
'http://www.overthumbs.com/',
# Why: #1439 in Alexa global
'http://www.iteye.com/',
# Why: #1440 in Alexa global
'http://www.yify-torrents.com/',
# Why: #1441 in Alexa global
'http://www.forexfactory.com/',
# Why: #1442 in Alexa global
'http://www.jugem.jp/',
# Why: #1443 in Alexa global
'http://www.hefei.cc/',
# Why: #1444 in Alexa global
'http://www.thefreecamsecret.com/',
# Why: #1445 in Alexa global
'http://www.sponichi.co.jp/',
# Why: #1446 in Alexa global
'http://www.lanacion.com.ar/',
# Why: #1447 in Alexa global
'http://www.jeu-a-telecharger.com/',
# Why: #1448 in Alexa global
'http://www.spartoo.com/',
# Why: #1449 in Alexa global
'http://www.adv-adserver.com/',
# Why: #1450 in Alexa global
'http://www.asus.com/',
# Why: #1451 in Alexa global
'http://www.91.com/',
# Why: #1452 in Alexa global
'http://www.wimbledon.com/',
# Why: #1454 in Alexa global
'http://www.yam.com/',
# Why: #1455 in Alexa global
'http://www.grooveshark.com/',
# Why: #1456 in Alexa global
'http://www.tdcanadatrust.com/',
# Why: #1457 in Alexa global
'http://www.lovetime.com/',
# Why: #1458 in Alexa global
'http://www.iltalehti.fi/',
# Why: #1459 in Alexa global
'http://www.alnaddy.com/',
# Why: #1460 in Alexa global
'http://www.bb.com.br/',
# Why: #1461 in Alexa global
'http://www.msn.co.jp/',
# Why: #1462 in Alexa global
'http://www.tebyan.net/',
# Why: #1463 in Alexa global
'http://www.redbox.com/',
# Why: #1464 in Alexa global
'http://www.filecrop.com/',
# Why: #1465 in Alexa global
'http://www.aliyun.com/',
# Why: #1466 in Alexa global
'http://www.21cn.com/',
# Why: #1467 in Alexa global
'http://www.news24.com/',
# Why: #1468 in Alexa global
'http://www.infowars.com/',
# Why: #1469 in Alexa global
'http://www.thetaoofbadass.com/',
# Why: #1470 in Alexa global
'http://www.juegos.com/',
# Why: #1471 in Alexa global
'http://www.p5w.net/',
# Why: #1472 in Alexa global
'http://www.vg.no/',
# Why: #1473 in Alexa global
'http://www.discovery.com/',
# Why: #1474 in Alexa global
'http://www.gazzetta.it/',
# Why: #1475 in Alexa global
'http://www.tvguide.com/',
# Why: #1476 in Alexa global
'http://www.khabarfarsi.com/',
# Why: #1477 in Alexa global
'http://www.bradesco.com.br/',
# Why: #1478 in Alexa global
'http://www.autotrader.co.uk/',
# Why: #1479 in Alexa global
'http://www.wetransfer.com/',
# Why: #1480 in Alexa global
'http://jinti.com/',
# Why: #1481 in Alexa global
'http://www.xhamsterhq.com/',
# Why: #1482 in Alexa global
'http://www.appround.net/',
# Why: #1483 in Alexa global
'http://lotour.com/',
# Why: #1484 in Alexa global
'http://www.reverbnation.com/',
# Why: #1485 in Alexa global
'http://www.thedailybeast.com/',
# Why: #1486 in Alexa global
'http://www.vente-privee.com/',
# Why: #1487 in Alexa global
'http://www.subscribe.ru/',
# Why: #1488 in Alexa global
'http://www.clickjogos.uol.com.br/',
# Why: #1489 in Alexa global
'http://www.marketgid.com/',
# Why: #1490 in Alexa global
'http://www.super.cz/',
# Why: #1491 in Alexa global
'http://www.jvzoo.com/',
# Why: #1492 in Alexa global
'http://www.shine.com/',
# Why: #1493 in Alexa global
'http://www.screencast.com/',
# Why: #1494 in Alexa global
'http://www.picofile.com/',
# Why: #1495 in Alexa global
'http://www.manoramaonline.com/',
# Why: #1496 in Alexa global
'http://www.kbb.com/',
# Why: #1497 in Alexa global
'http://www.seasonvar.ru/',
# Why: #1498 in Alexa global
'http://www.android.com/',
# Why: #1499 in Alexa global
'http://www.egrana.com.br/',
# Why: #1501 in Alexa global
'http://www.ettoday.net/',
# Why: #1502 in Alexa global
'http://www.webstatsdomain.net/',
# Why: #1503 in Alexa global
'http://www.haberler.com/',
# Why: #1504 in Alexa global
'http://www.vesti.ru/',
# Why: #1505 in Alexa global
'http://www.fastpic.ru/',
# Why: #1506 in Alexa global
'http://www.dpreview.com/',
# Why: #1507 in Alexa global
'http://www.google.si/',
# Why: #1508 in Alexa global
'http://www.ouedkniss.com/',
# Why: #1509 in Alexa global
'http://www.crackle.com/',
# Why: #1510 in Alexa global
'http://www.chefkoch.de/',
# Why: #1511 in Alexa global
'http://www.mogujie.com/',
# Why: #1513 in Alexa global
'http://www.brassring.com/',
# Why: #1514 in Alexa global
'http://www.govome.com/',
# Why: #1515 in Alexa global
'http://www.copyscape.com/',
# Why: #1516 in Alexa global
'http://www.minecraftforum.net/',
# Why: #1517 in Alexa global
'http://www.mit.edu/',
# Why: #1518 in Alexa global
'http://www.cvs.com/',
# Why: #1519 in Alexa global
'http://www.timesjobs.com/',
# Why: #1520 in Alexa global
'http://www.ksl.com/',
# Why: #1521 in Alexa global
'http://www.verizon.net/',
# Why: #1522 in Alexa global
'http://www.direct.gov.uk/',
# Why: #1523 in Alexa global
'http://www.miralinks.ru/',
# Why: #1524 in Alexa global
'http://www.elheddaf.com/',
# Why: #1525 in Alexa global
'http://www.stockphoto9.com/',
# Why: #1526 in Alexa global
'http://www.ashemaletube.com/',
# Why: #1527 in Alexa global
'http://www.dmm.com/',
# Why: #1528 in Alexa global
'http://www.abckj123.com/',
# Why: #1529 in Alexa global
'http://www.smzdm.com/',
# Why: #1530 in Alexa global
'http://www.china.cn/',
# Why: #1531 in Alexa global
'http://www.cox.com/',
# Why: #1532 in Alexa global
'http://www.welt.de/',
# Why: #1533 in Alexa global
'http://www.guyspy.com/',
# Why: #1534 in Alexa global
'http://www.makeuseof.com/',
# Why: #1535 in Alexa global
'http://www.tiscali.it/',
# Why: #1536 in Alexa global
'http://www.178.com/',
# Why: #1537 in Alexa global
'http://www.metrolyrics.com/',
# Why: #1538 in Alexa global
'http://www.vsuch.com/',
# Why: #1539 in Alexa global
'http://www.seosprint.net/',
# Why: #1540 in Alexa global
'http://www.samanyoluhaber.com/',
# Why: #1541 in Alexa global
'http://www.garanti.com.tr/',
# Why: #1542 in Alexa global
'http://www.chicagotribune.com/',
# Why: #1543 in Alexa global
'http://www.hinet.net/',
# Why: #1544 in Alexa global
'http://www.kp.ru/',
# Why: #1545 in Alexa global
'http://www.chomikuj.pl/',
# Why: #1546 in Alexa global
'http://www.nk.pl/',
# Why: #1547 in Alexa global
'http://www.webhostingtalk.com/',
# Why: #1548 in Alexa global
'http://www.dnaindia.com/',
# Why: #1550 in Alexa global
'http://www.programme-tv.net/',
# Why: #1551 in Alexa global
'http://www.ievbz.com/',
# Why: #1552 in Alexa global
'http://www.mysql.com/',
# Why: #1553 in Alexa global
'http://www.perfectmoney.is/',
# Why: #1554 in Alexa global
'http://www.liveundnackt.com/',
# Why: #1555 in Alexa global
'http://www.flippa.com/',
# Why: #1556 in Alexa global
'http://www.vevo.com/',
# Why: #1557 in Alexa global
'http://www.jappy.de/',
# Why: #1558 in Alexa global
'http://www.bidvertiser.com/',
# Why: #1559 in Alexa global
'http://www.bankmandiri.co.id/',
# Why: #1560 in Alexa global
'http://www.letour.fr/',
# Why: #1561 in Alexa global
'http://www.yr.no/',
# Why: #1562 in Alexa global
'http://www.suning.com/',
# Why: #1563 in Alexa global
'http://www.nosub.tv/',
# Why: #1564 in Alexa global
'http://www.delicious.com/',
# Why: #1565 in Alexa global
'http://www.pornpoly.com/',
# Why: #1566 in Alexa global
'http://www.echo.msk.ru/',
# Why: #1567 in Alexa global
'http://www.coingeneration.com/',
# Why: #1568 in Alexa global
'http://www.shutterfly.com/',
# Why: #1569 in Alexa global
'http://www.royalbank.com/',
# Why: #1570 in Alexa global
'http://www.techradar.com/',
# Why: #1571 in Alexa global
'http://www.114la.com/',
# Why: #1572 in Alexa global
'http://www.bizrate.com/',
# Why: #1573 in Alexa global
'http://www.srvey.net/',
# Why: #1574 in Alexa global
'http://www.heavy-r.com/',
# Why: #1575 in Alexa global
'http://www.telexfree.com/',
# Why: #1576 in Alexa global
'http://www.lego.com/',
# Why: #1577 in Alexa global
'http://www.battlefield.com/',
# Why: #1578 in Alexa global
'http://www.shahrekhabar.com/',
# Why: #1579 in Alexa global
'http://www.tuenti.com/',
# Why: #1580 in Alexa global
'http://www.bookmyshow.com/',
# Why: #1581 in Alexa global
'http://www.gamme.com.tw/',
# Why: #1582 in Alexa global
'http://www.ft.com/',
# Why: #1583 in Alexa global
'http://www.prweb.com/',
# Why: #1584 in Alexa global
'http://www.1337x.org/',
# Why: #1585 in Alexa global
'http://www.networkedblogs.com/',
# Why: #1586 in Alexa global
'http://www.pbskids.org/',
# Why: #1587 in Alexa global
'http://aipai.com/',
# Why: #1588 in Alexa global
'http://www.jang.com.pk/',
# Why: #1589 in Alexa global
'http://www.dribbble.com/',
# Why: #1590 in Alexa global
'http://www.ezdownloadpro.info/',
# Why: #1591 in Alexa global
'http://www.gonzoxxxmovies.com/',
# Why: #1592 in Alexa global
'http://www.aufeminin.com/',
# Why: #1594 in Alexa global
'http://www.6pm.com/',
# Why: #1596 in Alexa global
'http://www.azet.sk/',
# Why: #1597 in Alexa global
'http://www.trustedoffer.com/',
# Why: #1598 in Alexa global
'http://www.simplyhired.com/',
# Why: #1599 in Alexa global
'http://www.adserverpub.com/',
# Why: #1600 in Alexa global
'http://www.privalia.com/',
# Why: #1601 in Alexa global
'http://www.bedbathandbeyond.com/',
# Why: #1602 in Alexa global
'http://www.yyets.com/',
# Why: #1603 in Alexa global
'http://verycd.com/',
# Why: #1604 in Alexa global
'http://www.sbnation.com/',
# Why: #1605 in Alexa global
'http://www.blogspot.nl/',
# Why: #1606 in Alexa global
'http://www.ikariam.com/',
# Why: #1607 in Alexa global
'http://www.sitepoint.com/',
# Why: #1608 in Alexa global
'http://www.gazeta.ru/',
# Why: #1609 in Alexa global
'http://www.tataindicom.com/',
# Why: #1610 in Alexa global
'http://chekb.com/',
# Why: #1611 in Alexa global
'http://www.literotica.com/',
# Why: #1612 in Alexa global
'http://www.ah-me.com/',
# Why: #1613 in Alexa global
'http://eztv.it/',
# Why: #1614 in Alexa global
'http://www.onliner.by/',
# Why: #1615 in Alexa global
'http://pptv.com/',
# Why: #1616 in Alexa global
'http://www.macrumors.com/',
# Why: #1617 in Alexa global
'http://www.xvideo-jp.com/',
# Why: #1618 in Alexa global
'http://www.state.tx.us/',
# Why: #1619 in Alexa global
'http://www.jamnews.ir/',
# Why: #1620 in Alexa global
'http://etoro.com/',
# Why: #1621 in Alexa global
'http://www.ny.gov/',
# Why: #1622 in Alexa global
'http://www.searchenginewatch.com/',
# Why: #1623 in Alexa global
'http://www.google.co.cr/',
# Why: #1624 in Alexa global
'http://www.td.com/',
# Why: #1625 in Alexa global
'http://www.ahrefs.com/',
# Why: #1626 in Alexa global
'http://www.337.com/',
# Why: #1627 in Alexa global
'http://www.klout.com/',
# Why: #1628 in Alexa global
'http://www.ebay.es/',
# Why: #1629 in Alexa global
'http://www.theverge.com/',
# Why: #1631 in Alexa global
'http://www.kapook.com/',
# Why: #1632 in Alexa global
'http://www.barclays.co.uk/',
# Why: #1634 in Alexa global
'http://nuomi.com/',
# Why: #1635 in Alexa global
'http://www.index-of-mp3s.com/',
# Why: #1636 in Alexa global
'http://www.ohfreesex.com/',
# Why: #1637 in Alexa global
'http://www.mts.ru/',
# Why: #1638 in Alexa global
'http://www.itmedia.co.jp/',
# Why: #1639 in Alexa global
'http://www.instantcheckmate.com/',
# Why: #1640 in Alexa global
'http://www.sport.es/',
# Why: #1641 in Alexa global
'http://www.sitescout.com/',
# Why: #1642 in Alexa global
'http://www.irr.ru/',
# Why: #1643 in Alexa global
'http://tuniu.com/',
# Why: #1644 in Alexa global
'http://www.startimes.com/',
# Why: #1645 in Alexa global
'http://www.tvn24.pl/',
# Why: #1646 in Alexa global
'http://www.kenh14.vn/',
# Why: #1647 in Alexa global
'http://www.myvideo.de/',
# Why: #1648 in Alexa global
'http://www.speedbit.com/',
# Why: #1649 in Alexa global
'http://www.aljazeera.com/',
# Why: #1650 in Alexa global
'http://www.pudelek.pl/',
# Why: #1651 in Alexa global
'http://www.mmgp.ru/',
# Why: #1652 in Alexa global
'http://www.empflix.com/',
# Why: #1653 in Alexa global
'http://www.tigerdirect.com/',
# Why: #1655 in Alexa global
'http://www.elegantthemes.com/',
# Why: #1657 in Alexa global
'http://www.ted.com/',
# Why: #1658 in Alexa global
'http://www.carview.co.jp/',
# Why: #1659 in Alexa global
'http://www.down1oads.com/',
# Why: #1660 in Alexa global
'http://www.bancobrasil.com.br/',
# Why: #1661 in Alexa global
'http://www.qip.ru/',
# Why: #1662 in Alexa global
'http://www.nikkeibp.co.jp/',
# Why: #1663 in Alexa global
'http://www.fapdu.com/',
# Why: #1664 in Alexa global
'http://www.softango.com/',
# Why: #1665 in Alexa global
'http://www.ap.org/',
# Why: #1666 in Alexa global
'http://www.meteofrance.com/',
# Why: #1667 in Alexa global
'http://www.gentenocturna.com/',
# Why: #1668 in Alexa global
'http://www.2ch-c.net/',
# Why: #1669 in Alexa global
'http://www.orf.at/',
# Why: #1670 in Alexa global
'http://www.maybank2u.com.my/',
# Why: #1671 in Alexa global
'http://www.minecraftwiki.net/',
# Why: #1672 in Alexa global
'http://www.tv.com/',
# Why: #1673 in Alexa global
'http://www.orkut.com/',
# Why: #1674 in Alexa global
'http://www.adp.com/',
# Why: #1675 in Alexa global
'http://www.woorank.com/',
# Why: #1676 in Alexa global
'http://www.imagetwist.com/',
# Why: #1677 in Alexa global
'http://www.pastebin.com/',
# Why: #1678 in Alexa global
'http://www.airtel.com/',
# Why: #1679 in Alexa global
'http://www.ew.com/',
# Why: #1680 in Alexa global
'http://www.forever21.com/',
# Why: #1681 in Alexa global
'http://www.adam4adam.com/',
# Why: #1682 in Alexa global
'http://www.voyages-sncf.com/',
# Why: #1683 in Alexa global
'http://www.nextag.com/',
# Why: #1684 in Alexa global
'http://www.usnews.com/',
# Why: #1685 in Alexa global
'http://www.dinamalar.com/',
# Why: #1686 in Alexa global
'http://www.impress.co.jp/',
# Why: #1687 in Alexa global
'http://www.virginmedia.com/',
# Why: #1688 in Alexa global
'http://www.investopedia.com/',
# Why: #1689 in Alexa global
'http://www.seekingalpha.com/',
# Why: #1690 in Alexa global
'http://www.jumponhottie.com/',
# Why: #1691 in Alexa global
'http://www.national-lottery.co.uk/',
# Why: #1692 in Alexa global
'http://www.mobifiesta.com/',
# Why: #1693 in Alexa global
'http://www.kapanlagi.com/',
# Why: #1694 in Alexa global
'http://www.segundamano.es/',
# Why: #1695 in Alexa global
'http://gfan.com/',
# Why: #1696 in Alexa global
'http://www.xdating.com/',
# Why: #1697 in Alexa global
'http://www.ynet.com/',
# Why: #1698 in Alexa global
'http://www.medu.ir/',
# Why: #1699 in Alexa global
'http://www.hsn.com/',
# Why: #1700 in Alexa global
'http://www.newsru.com/',
# Why: #1701 in Alexa global
'http://www.minus.com/',
# Why: #1702 in Alexa global
'http://www.sitetalk.com/',
# Why: #1703 in Alexa global
'http://www.aarp.org/',
# Why: #1704 in Alexa global
'http://www.clickpaid.com/',
# Why: #1705 in Alexa global
'http://www.panoramio.com/',
# Why: #1706 in Alexa global
'http://www.webcamo.com/',
# Why: #1707 in Alexa global
'http://www.yobt.tv/',
# Why: #1708 in Alexa global
'http://www.slutfinder.com/',
# Why: #1709 in Alexa global
'http://www.freelotto.com/',
# Why: #1710 in Alexa global
'http://www.mudah.my/',
# Why: #1711 in Alexa global
'http://www.toptenreviews.com/',
# Why: #1712 in Alexa global
'http://www.caisse-epargne.fr/',
# Why: #1713 in Alexa global
'http://www.wimp.com/',
# Why: #1714 in Alexa global
'http://www.woothemes.com/',
# Why: #1715 in Alexa global
'http://www.css-tricks.com/',
# Why: #1716 in Alexa global
'http://www.coolmath-games.com/',
# Why: #1717 in Alexa global
'http://www.tagu.com.ar/',
# Why: #1718 in Alexa global
'http://www.sheknows.com/',
# Why: #1719 in Alexa global
'http://www.advancedfileoptimizer.com/',
# Why: #1720 in Alexa global
'http://www.drupal.org/',
# Why: #1721 in Alexa global
'http://www.centrum.cz/',
# Why: #1722 in Alexa global
'http://www.charter.net/',
# Why: #1724 in Alexa global
'http://adxhosting.net/',
# Why: #1725 in Alexa global
'http://www.squarespace.com/',
# Why: #1726 in Alexa global
'http://www.trademe.co.nz/',
# Why: #1727 in Alexa global
'http://www.sitesell.com/',
# Why: #1728 in Alexa global
'http://www.birthrecods.com/',
# Why: #1729 in Alexa global
'http://www.megashare.info/',
# Why: #1730 in Alexa global
'http://www.freepornvs.com/',
# Why: #1731 in Alexa global
'http://www.isna.ir/',
# Why: #1732 in Alexa global
'http://www.ziddu.com/',
# Why: #1733 in Alexa global
'http://www.airtelforum.com/',
# Why: #1734 in Alexa global
'http://www.justin.tv/',
# Why: #1735 in Alexa global
'http://www.01net.com/',
# Why: #1736 in Alexa global
'http://www.ed.gov/',
# Why: #1737 in Alexa global
'http://www.no-ip.com/',
# Why: #1738 in Alexa global
'http://www.nikkansports.com/',
# Why: #1739 in Alexa global
'http://www.smashingmagazine.com/',
# Why: #1740 in Alexa global
'http://www.salon.com/',
# Why: #1741 in Alexa global
'http://www.nmisr.com/',
# Why: #1742 in Alexa global
'http://www.wanggou.com/',
# Why: #1743 in Alexa global
'http://www.bayt.com/',
# Why: #1744 in Alexa global
'http://www.codeproject.com/',
# Why: #1745 in Alexa global
'http://www.downloadha.com/',
# Why: #1746 in Alexa global
'http://www.local.com/',
# Why: #1747 in Alexa global
'http://www.abola.pt/',
# Why: #1748 in Alexa global
'http://www.delta-homes.com/',
# Why: #1749 in Alexa global
'http://www.filmweb.pl/',
# Why: #1750 in Alexa global
'http://www.gov.uk/',
# Why: #1751 in Alexa global
'http://www.worldoftanks.eu/',
# Why: #1752 in Alexa global
'http://www.ads-id.com/',
# Why: #1753 in Alexa global
'http://www.sergey-mavrodi.com/',
# Why: #1754 in Alexa global
'http://www.pornoid.com/',
# Why: #1755 in Alexa global
'http://www.freakshare.com/',
# Why: #1756 in Alexa global
'http://www.51fanli.com/',
# Why: #1757 in Alexa global
'http://www.bankrate.com/',
# Why: #1758 in Alexa global
'http://www.grindtv.com/',
# Why: #1759 in Alexa global
'http://www.webmasterworld.com/',
# Why: #1760 in Alexa global
'http://www.torrentz.in/',
# Why: #1761 in Alexa global
'http://www.bwin.com/',
# Why: #1762 in Alexa global
'http://www.watchtower.com/',
# Why: #1763 in Alexa global
'http://www.payza.com/',
# Why: #1764 in Alexa global
'http://www.eol.cn/',
# Why: #1765 in Alexa global
'http://www.anz.com/',
# Why: #1766 in Alexa global
'http://www.vagalume.com.br/',
# Why: #1767 in Alexa global
'http://www.ozon.ru/',
# Why: #1768 in Alexa global
'http://www.cnr.cn/',
# Why: #1769 in Alexa global
'http://www.tonicmovies.com/',
# Why: #1771 in Alexa global
'http://www.arbeitsagentur.de/',
# Why: #1772 in Alexa global
'http://www.graphicriver.net/',
# Why: #1773 in Alexa global
'http://www.theweathernetwork.com/',
# Why: #1774 in Alexa global
'http://www.samsclub.com/',
# Why: #1775 in Alexa global
'http://www.tribunnews.com/',
# Why: #1776 in Alexa global
'http://www.soldonsmart.com/',
# Why: #1777 in Alexa global
'http://www.tut.by/',
# Why: #1778 in Alexa global
'http://www.voila.fr/',
# Why: #1779 in Alexa global
'http://www.doctissimo.fr/',
# Why: #1780 in Alexa global
'http://www.sueddeutsche.de/',
# Why: #1781 in Alexa global
'http://www.mamba.ru/',
# Why: #1782 in Alexa global
'http://www.kmart.com/',
# Why: #1783 in Alexa global
'http://www.noticias.uol.com.br/',
# Why: #1784 in Alexa global
'http://www.abc.es/',
# Why: #1785 in Alexa global
'http://www.manager.co.th/',
# Why: #1786 in Alexa global
'http://www.spokeo.com/',
# Why: #1787 in Alexa global
'http://www.apache.org/',
# Why: #1788 in Alexa global
'http://www.tdbank.com/',
# Why: #1789 in Alexa global
'http://www.asklaila.com/',
# Why: #1790 in Alexa global
'http://admin5.net/',
# Why: #1791 in Alexa global
'http://www.rtve.es/',
# Why: #1792 in Alexa global
'http://www.ynet.co.il/',
# Why: #1793 in Alexa global
'http://www.infospace.com/',
# Why: #1794 in Alexa global
'http://yimg.com/',
# Why: #1795 in Alexa global
'http://www.torcache.net/',
# Why: #1796 in Alexa global
'http://www.zap2it.com/',
# Why: #1797 in Alexa global
'http://www.smallseotools.com/',
# Why: #1798 in Alexa global
'http://www.privatbank.ua/',
# Why: #1799 in Alexa global
'http://www.nnm-club.ru/',
# Why: #1800 in Alexa global
'http://www.payoneer.com/',
# Why: #1801 in Alexa global
'http://www.bidorbuy.co.za/',
# Why: #1802 in Alexa global
'http://www.islamweb.net/',
# Why: #1803 in Alexa global
'http://www.juicyads.com/',
# Why: #1804 in Alexa global
'http://www.vid2c.com/',
# Why: #1805 in Alexa global
'http://rising.cn/',
# Why: #1806 in Alexa global
'http://www.dnsrsearch.com/',
# Why: #1807 in Alexa global
'http://www.the-bux.net/',
# Why: #1808 in Alexa global
'http://www.yaplakal.com/',
# Why: #1809 in Alexa global
'http://www.ex.ua/',
# Why: #1810 in Alexa global
'http://www.mtsindia.in/',
# Why: #1811 in Alexa global
'http://www.reclameaqui.com.br/',
# Why: #1812 in Alexa global
'http://www.postbank.de/',
# Why: #1813 in Alexa global
'http://www.gogvo.com/',
# Why: #1814 in Alexa global
'http://www.bearshare.net/',
# Why: #1815 in Alexa global
'http://www.socialsex.com/',
# Why: #1816 in Alexa global
'http://www.yebhi.com/',
# Why: #1817 in Alexa global
'http://www.mktmobi.com/',
# Why: #1818 in Alexa global
'http://www.hotpepper.jp/',
# Why: #1819 in Alexa global
'http://www.dfiles.eu/',
# Why: #1820 in Alexa global
'http://www.citibank.co.in/',
# Why: #1821 in Alexa global
'http://gamersky.com/',
# Why: #1822 in Alexa global
'http://www.kotaku.com/',
# Why: #1823 in Alexa global
'http://www.teamviewer.com/',
# Why: #1824 in Alexa global
'http://www.kwejk.pl/',
# Why: #1825 in Alexa global
'http://www.hamariweb.com/',
# Why: #1826 in Alexa global
'http://www.tom.com/',
# Why: #1827 in Alexa global
'http://www.gayromeo.com/',
# Why: #1828 in Alexa global
'http://www.sony.com/',
# Why: #1829 in Alexa global
'http://www.westpac.com.au/',
# Why: #1830 in Alexa global
'http://www.gtmetrix.com/',
# Why: #1831 in Alexa global
'http://www.shorouknews.com/',
# Why: #1832 in Alexa global
'http://www.xl.pt/',
# Why: #1833 in Alexa global
'http://www.networksolutions.com/',
# Why: #1834 in Alexa global
'http://www.500px.com/',
# Why: #1835 in Alexa global
'http://www.ypmate.com/',
# Why: #1836 in Alexa global
'http://www.indowebster.com/',
# Why: #1837 in Alexa global
'http://www.sports.ru/',
# Why: #1838 in Alexa global
'http://www.netshoes.com.br/',
# Why: #1839 in Alexa global
'http://familydoctor.com.cn/',
# Why: #1840 in Alexa global
'http://www.dfiles.ru/',
# Why: #1841 in Alexa global
'http://www.cpasbien.me/',
# Why: #1842 in Alexa global
'http://www.webgame.web.id/',
# Why: #1843 in Alexa global
'http://www.tuto4pc.com/',
# Why: #1844 in Alexa global
'http://www.poponclick.com/',
# Why: #1845 in Alexa global
'http://www.complex.com/',
# Why: #1846 in Alexa global
'http://www.sakshi.com/',
# Why: #1847 in Alexa global
'http://www.infobae.com/',
# Why: #1848 in Alexa global
'http://www.allabout.co.jp/',
# Why: #1849 in Alexa global
'http://www.sify.com/',
# Why: #1850 in Alexa global
'http://www.4pda.ru/',
# Why: #1851 in Alexa global
'http://www.starsue.net/',
# Why: #1852 in Alexa global
'http://www.newgrounds.com/',
# Why: #1853 in Alexa global
'http://www.mehrnews.com/',
# Why: #1854 in Alexa global
'http://www.depositphotos.com/',
# Why: #1855 in Alexa global
'http://www.keek.com/',
# Why: #1856 in Alexa global
'http://www.indeed.co.in/',
# Why: #1857 in Alexa global
'http://www.stanford.edu/',
# Why: #1858 in Alexa global
'http://www.hepsiburada.com/',
# Why: #1859 in Alexa global
'http://www.20minutos.es/',
# Why: #1860 in Alexa global
'http://www.paper.li/',
# Why: #1861 in Alexa global
'http://www.prizee.com/',
# Why: #1862 in Alexa global
'http://www.xlovecam.com/',
# Why: #1863 in Alexa global
'http://www.criteo.com/',
# Why: #1864 in Alexa global
'http://www.endlessmatches.com/',
# Why: #1865 in Alexa global
'http://www.dyndns.org/',
# Why: #1866 in Alexa global
'http://www.lightinthebox.com/',
# Why: #1867 in Alexa global
'http://www.easyjet.com/',
# Why: #1869 in Alexa global
'http://www.vice.com/',
# Why: #1870 in Alexa global
'http://tiexue.net/',
# Why: #1871 in Alexa global
'http://www.monstermarketplace.com/',
# Why: #1872 in Alexa global
'http://www.mojang.com/',
# Why: #1873 in Alexa global
'http://www.cams.com/',
# Why: #1874 in Alexa global
'http://www.pingdom.com/',
# Why: #1875 in Alexa global
'http://www.askmen.com/',
# Why: #1876 in Alexa global
'http://www.list-manage1.com/',
# Why: #1878 in Alexa global
'http://www.express.com.pk/',
# Why: #1879 in Alexa global
'http://www.priceminister.com/',
# Why: #1880 in Alexa global
'http://www.duba.com/',
# Why: #1881 in Alexa global
'http://www.meinestadt.de/',
# Why: #1882 in Alexa global
'http://www.mediatakeout.com/',
# Why: #1883 in Alexa global
'http://www.w3school.com.cn/',
# Why: #1884 in Alexa global
'http://www.terere.info/',
# Why: #1885 in Alexa global
'http://www.streamate.com/',
# Why: #1886 in Alexa global
'http://www.garmin.com/',
# Why: #1887 in Alexa global
'http://www.a-telecharger.com/',
# Why: #1888 in Alexa global
'http://www.vipzona.info/',
# Why: #1889 in Alexa global
'http://www.coffetube.com/',
# Why: #1890 in Alexa global
'http://www.discuz.net/',
# Why: #1891 in Alexa global
'http://www.directv.com/',
# Why: #1892 in Alexa global
'http://www.foreningssparbanken.se/',
# Why: #1893 in Alexa global
'http://www.fatwallet.com/',
# Why: #1894 in Alexa global
'http://www.mackolik.com/',
# Why: #1895 in Alexa global
'http://www.megacinema.fr/',
# Why: #1896 in Alexa global
'http://www.chess.com/',
# Why: #1897 in Alexa global
'http://www.suntrust.com/',
# Why: #1898 in Alexa global
'http://www.investing.com/',
# Why: #1899 in Alexa global
'http://www.whois.com/',
# Why: #1900 in Alexa global
'http://www.dummies.com/',
# Why: #1901 in Alexa global
'http://www.yinyuetai.com/',
# Why: #1902 in Alexa global
'http://www.mihandownload.com/',
# Why: #1903 in Alexa global
'http://www.freapp.com/',
# Why: #1904 in Alexa global
'http://www.theage.com.au/',
# Why: #1905 in Alexa global
'http://www.audible.com/',
# Why: #1906 in Alexa global
'http://www.hangame.co.jp/',
# Why: #1907 in Alexa global
'http://www.hotelurbano.com.br/',
# Why: #1908 in Alexa global
'http://www.vatgia.com/',
# Why: #1909 in Alexa global
'http://www.wizard101.com/',
# Why: #1910 in Alexa global
'http://www.ceneo.pl/',
# Why: #1911 in Alexa global
'http://1ting.com/',
# Why: #1912 in Alexa global
'http://www.meetic.fr/',
# Why: #1913 in Alexa global
'http://www.cardekho.com/',
# Why: #1914 in Alexa global
'http://www.tripadvisor.it/',
# Why: #1915 in Alexa global
'http://www.dhl.com/',
# Why: #1916 in Alexa global
'http://www.aibang.com/',
# Why: #1917 in Alexa global
'http://www.asp.net/',
# Why: #1918 in Alexa global
'http://www.toing.com.br/',
# Why: #1920 in Alexa global
'http://zhubajie.com/',
# Why: #1921 in Alexa global
'http://www.telecomitalia.it/',
# Why: #1922 in Alexa global
'http://www.claro-search.com/',
# Why: #1923 in Alexa global
'http://www.nickjr.com/',
# Why: #1924 in Alexa global
'http://www.iconfinder.com/',
# Why: #1925 in Alexa global
'http://www.mobile9.com/',
# Why: #1926 in Alexa global
'http://www.mainichi.jp/',
# Why: #1927 in Alexa global
'http://www.cisco.com/',
# Why: #1928 in Alexa global
'http://www.cpanel.net/',
# Why: #1929 in Alexa global
'http://www.indiegogo.com/',
# Why: #1930 in Alexa global
'http://www.egotastic.com/',
# Why: #1931 in Alexa global
'http://www.hforcare.com/',
# Why: #1932 in Alexa global
'http://www.pbs.org/',
# Why: #1933 in Alexa global
'http://www.realestate.com.au/',
# Why: #1934 in Alexa global
'http://www.abv.bg/',
# Why: #1935 in Alexa global
'http://www.drugs.com/',
# Why: #1936 in Alexa global
'http://www.bt.com/',
# Why: #1937 in Alexa global
'http://www.wildberries.ru/',
# Why: #1938 in Alexa global
'http://www.edreams.it/',
# Why: #1939 in Alexa global
'http://www.statigr.am/',
# Why: #1940 in Alexa global
'http://www.prestashop.com/',
# Why: #1941 in Alexa global
'http://www.adxite.com/',
# Why: #1942 in Alexa global
'http://www.birthdaypeoms.com/',
# Why: #1943 in Alexa global
'http://www.exbii.com/',
# Why: #1944 in Alexa global
'http://www.blogmura.com/',
# Why: #1945 in Alexa global
'http://www.sciencedirect.com/',
# Why: #1946 in Alexa global
'http://www.sanspo.com/',
# Why: #1947 in Alexa global
'http://www.nextmedia.com/',
# Why: #1948 in Alexa global
'http://www.tvoyauda4a.ru/',
# Why: #1949 in Alexa global
'http://tangdou.com/',
# Why: #1950 in Alexa global
'http://www.blackboard.com/',
# Why: #1951 in Alexa global
'http://qiyou.com/',
# Why: #1952 in Alexa global
'http://www.youth.cn/',
# Why: #1953 in Alexa global
'http://www.prezentacya.ru/',
# Why: #1954 in Alexa global
'http://www.clicrbs.com.br/',
# Why: #1955 in Alexa global
'http://www.wayfair.com/',
# Why: #1956 in Alexa global
'http://www.xvideos-field.com/',
# Why: #1957 in Alexa global
'http://www.national.com.au/',
# Why: #1958 in Alexa global
'http://www.friendfeed.com/',
# Why: #1959 in Alexa global
'http://www.plurk.com/',
# Why: #1960 in Alexa global
'http://www.lolmake.com/',
# Why: #1961 in Alexa global
'http://www.b9dm.com/',
# Why: #1962 in Alexa global
'http://www.afkarnews.ir/',
# Why: #1963 in Alexa global
'http://www.dhl.de/',
# Why: #1964 in Alexa global
'http://www.championat.com/',
# Why: #1965 in Alexa global
'http://www.moviefone.com/',
# Why: #1966 in Alexa global
'http://www.popcash.net/',
# Why: #1967 in Alexa global
'http://www.cliphunter.com/',
# Why: #1968 in Alexa global
'http://www.sharebeast.com/',
# Why: #1969 in Alexa global
'http://www.wowhead.com/',
# Why: #1970 in Alexa global
'http://www.firstpost.com/',
# Why: #1971 in Alexa global
'http://www.lloydstsb.com/',
# Why: #1972 in Alexa global
'http://www.fazenda.gov.br/',
# Why: #1973 in Alexa global
'http://www.lonelyplanet.com/',
# Why: #1974 in Alexa global
'http://www.freenet.de/',
# Why: #1975 in Alexa global
'http://www.justanswer.com/',
# Why: #1977 in Alexa global
'http://www.qiwi.com/',
# Why: #1978 in Alexa global
'http://www.shufuni.com/',
# Why: #1979 in Alexa global
'http://www.drive2.ru/',
# Why: #1980 in Alexa global
'http://www.slando.ua/',
# Why: #1981 in Alexa global
'http://www.caribbeancom.com/',
# Why: #1982 in Alexa global
'http://www.uniblue.com/',
# Why: #1983 in Alexa global
'http://www.real.com/',
# Why: #1984 in Alexa global
'http://www.addictinggames.com/',
# Why: #1985 in Alexa global
'http://www.wnd.com/',
# Why: #1986 in Alexa global
'http://www.col3negoriginal.org/',
# Why: #1987 in Alexa global
'http://www.loltrk.com/',
# Why: #1988 in Alexa global
'http://www.videodownloadconverter.com/',
# Why: #1989 in Alexa global
'http://www.google.lv/',
# Why: #1990 in Alexa global
'http://www.seriesyonkis.com/',
# Why: #1991 in Alexa global
'http://www.ryushare.com/',
# Why: #1992 in Alexa global
'http://s1979.com/',
# Why: #1993 in Alexa global
'http://www.cheapoair.com/',
# Why: #1994 in Alexa global
'http://www.plala.or.jp/',
# Why: #1995 in Alexa global
'http://www.submarino.com.br/',
# Why: #1996 in Alexa global
'http://www.topface.com/',
# Why: #1998 in Alexa global
'http://www.hotelscombined.com/',
# Why: #1999 in Alexa global
'http://www.whatismyipaddress.com/',
# Why: #2000 in Alexa global
'http://www.z6.com/',
# Why: #2001 in Alexa global
'http://www.sozcu.com.tr/',
# Why: #2002 in Alexa global
'http://www.sonymobile.com/',
# Why: #2003 in Alexa global
'http://www.planetminecraft.com/',
# Why: #2004 in Alexa global
'http://www.optimum.net/',
# Why: #2005 in Alexa global
'http://www.google.com.pr/',
# Why: #2006 in Alexa global
'http://mthai.com/',
# Why: #2007 in Alexa global
'http://www.onlinecreditcenter6.com/',
# Why: #2008 in Alexa global
'http://www.tharunaya.co.uk/',
# Why: #2009 in Alexa global
'http://www.sfimg.com/',
# Why: #2010 in Alexa global
'http://www.natwest.com/',
# Why: #2011 in Alexa global
'http://www.zergnet.com/',
# Why: #2012 in Alexa global
'http://www.alotporn.com/',
# Why: #2013 in Alexa global
'http://www.urbanspoon.com/',
# Why: #2014 in Alexa global
'http://www.punishtube.com/',
# Why: #2015 in Alexa global
'http://www.proboards.com/',
# Why: #2016 in Alexa global
'http://www.betfair.com/',
# Why: #2017 in Alexa global
'http://www.iltasanomat.fi/',
# Why: #2018 in Alexa global
'http://www.ssisurveys.com/',
# Why: #2019 in Alexa global
'http://www.mapion.co.jp/',
# Why: #2020 in Alexa global
'http://www.harvard.edu/',
# Why: #2021 in Alexa global
'http://www.blic.rs/',
# Why: #2022 in Alexa global
'http://www.clicksia.com/',
# Why: #2023 in Alexa global
'http://www.skillpages.com/',
# Why: #2024 in Alexa global
'http://www.mobilewap.com/',
# Why: #2025 in Alexa global
'http://www.fiducia.de/',
# Why: #2026 in Alexa global
'http://www.torntvz.org/',
# Why: #2027 in Alexa global
'http://www.leparisien.fr/',
# Why: #2028 in Alexa global
'http://anjuke.com/',
# Why: #2029 in Alexa global
'http://www.rabobank.nl/',
# Why: #2030 in Alexa global
'http://www.sport.pl/',
# Why: #2031 in Alexa global
'http://www.schwab.com/',
# Why: #2032 in Alexa global
'http://www.buenastareas.com/',
# Why: #2033 in Alexa global
'http://www.befuck.com/',
# Why: #2034 in Alexa global
'http://www.smart-search.com/',
# Why: #2035 in Alexa global
'http://www.ivi.ru/',
# Why: #2036 in Alexa global
'http://www.2z.cn/',
# Why: #2037 in Alexa global
'http://www.dvdvideosoft.com/',
# Why: #2038 in Alexa global
'http://www.ubi.com/',
# Why: #2039 in Alexa global
'http://makepolo.com/',
# Why: #2040 in Alexa global
'http://www.1and1.com/',
# Why: #2041 in Alexa global
'http://www.anipo.jp/',
# Why: #2042 in Alexa global
'http://www.pcworld.com/',
# Why: #2043 in Alexa global
'http://www.caf.fr/',
# Why: #2044 in Alexa global
'http://www.fnb.co.za/',
# Why: #2045 in Alexa global
'http://www.vanguardngr.com/',
# Why: #2046 in Alexa global
'http://www.floozycity.com/',
# Why: #2047 in Alexa global
'http://www.ubuntu.com/',
# Why: #2048 in Alexa global
'http://www.my-link.pro/',
# Why: #2049 in Alexa global
'http://www.daily.co.jp/',
# Why: #2050 in Alexa global
'http://www.centurylink.com/',
# Why: #2051 in Alexa global
'http://www.slashdot.org/',
# Why: #2052 in Alexa global
'http://www.mirrorcreator.com/',
# Why: #2053 in Alexa global
'http://www.rutube.ru/',
# Why: #2054 in Alexa global
'http://www.tubeplus.me/',
# Why: #2055 in Alexa global
'http://www.kicker.de/',
# Why: #2056 in Alexa global
'http://www.unibet.com/',
# Why: #2057 in Alexa global
'http://www.pornyaz.com/',
# Why: #2058 in Alexa global
'http://www.learntotradethemarket.com/',
# Why: #2059 in Alexa global
'http://www.tokyo-porn-tube.com/',
# Why: #2060 in Alexa global
'http://www.luvcow.com/',
# Why: #2061 in Alexa global
'http://www.i.ua/',
# Why: #2062 in Alexa global
'http://www.ole.com.ar/',
# Why: #2063 in Alexa global
'http://www.redfin.com/',
# Why: #2064 in Alexa global
'http://www.cnki.net/',
# Why: #2065 in Alexa global
'http://www.2shared.com/',
# Why: #2066 in Alexa global
'http://www.infibeam.com/',
# Why: #2067 in Alexa global
'http://www.zdnet.com/',
# Why: #2068 in Alexa global
'http://www.fishki.net/',
# Why: #2069 in Alexa global
'http://msn.com.cn/',
# Why: #2070 in Alexa global
'http://www.ukr.net/',
# Why: #2071 in Alexa global
'http://www.scol.com.cn/',
# Why: #2072 in Alexa global
'http://www.jiameng.com/',
# Why: #2073 in Alexa global
'http://www.utorrent.com/',
# Why: #2074 in Alexa global
'http://www.elkhabar.com/',
# Why: #2075 in Alexa global
'http://www.anime44.com/',
# Why: #2076 in Alexa global
'http://www.societegenerale.fr/',
# Why: #2077 in Alexa global
'http://www.livememe.com/',
# Why: #2078 in Alexa global
'http://www.warning.or.kr/',
# Why: #2079 in Alexa global
'http://www.startertv.fr/',
# Why: #2080 in Alexa global
'http://www.pingomatic.com/',
# Why: #2081 in Alexa global
'http://www.indeed.co.uk/',
# Why: #2082 in Alexa global
'http://www.dpstream.net/',
# Why: #2083 in Alexa global
'http://www.mundodeportivo.com/',
# Why: #2084 in Alexa global
'http://www.gravatar.com/',
# Why: #2085 in Alexa global
'http://www.ip138.com/',
# Why: #2086 in Alexa global
'http://www.zcool.com.cn/',
# Why: #2087 in Alexa global
'http://www.yandex.net/',
# Why: #2088 in Alexa global
'http://www.barbie.com/',
# Why: #2089 in Alexa global
'http://www.wattpad.com/',
# Why: #2090 in Alexa global
'http://www.dzwww.com/',
# Why: #2091 in Alexa global
'http://www.technorati.com/',
# Why: #2092 in Alexa global
'http://meishichina.com/',
# Why: #2093 in Alexa global
'http://www.russianpost.ru/',
# Why: #2094 in Alexa global
'http://www.kboing.com.br/',
# Why: #2095 in Alexa global
'http://www.lzjl.com/',
# Why: #2096 in Alexa global
'http://www.newsnow.co.uk/',
# Why: #2097 in Alexa global
'http://www.dw.de/',
# Why: #2098 in Alexa global
'http://www.inetglobal.com/',
# Why: #2099 in Alexa global
'http://www.tripadvisor.in/',
# Why: #2100 in Alexa global
'http://www.ashleyrnadison.com/',
# Why: #2101 in Alexa global
'http://www.rapgenius.com/',
# Why: #2102 in Alexa global
'http://www.xuite.net/',
# Why: #2103 in Alexa global
'http://www.nowvideo.eu/',
# Why: #2104 in Alexa global
'http://www.search.us.com/',
# Why: #2105 in Alexa global
'http://www.usagc.org/',
# Why: #2106 in Alexa global
'http://www.santander.co.uk/',
# Why: #2107 in Alexa global
'http://www.99acres.com/',
# Why: #2108 in Alexa global
'http://www.bigcartel.com/',
# Why: #2109 in Alexa global
'http://www.haivl.com/',
# Why: #2110 in Alexa global
'http://www.jsfiddle.net/',
# Why: #2111 in Alexa global
'http://www.io9.com/',
# Why: #2112 in Alexa global
'http://www.lg.com/',
# Why: #2113 in Alexa global
'http://www.veoh.com/',
# Why: #2114 in Alexa global
'http://www.dafiti.com.br/',
# Why: #2115 in Alexa global
'http://www.heise.de/',
# Why: #2117 in Alexa global
'http://www.wikispaces.com/',
# Why: #2118 in Alexa global
'http://www.google.com.bo/',
# Why: #2119 in Alexa global
'http://www.skyscrapercity.com/',
# Why: #2120 in Alexa global
'http://www.zaobao.com/',
# Why: #2121 in Alexa global
'http://www.pirateproxy.net/',
# Why: #2122 in Alexa global
'http://www.muyzorras.com/',
# Why: #2123 in Alexa global
'http://www.iza.ne.jp/',
# Why: #2124 in Alexa global
'http://www.entrepreneur.com/',
# Why: #2125 in Alexa global
'http://www.sxc.hu/',
# Why: #2126 in Alexa global
'http://www.superuser.com/',
# Why: #2127 in Alexa global
'http://www.jb51.net/',
# Why: #2128 in Alexa global
'http://www.bitsnoop.com/',
# Why: #2129 in Alexa global
'http://www.index.hu/',
# Why: #2130 in Alexa global
'http://www.tubexclips.com/',
# Why: #2131 in Alexa global
'http://www.symantec.com/',
# Why: #2132 in Alexa global
'http://www.sedo.com/',
# Why: #2133 in Alexa global
'http://www.gongchang.com/',
# Why: #2134 in Alexa global
'http://www.haibao.cn/',
# Why: #2135 in Alexa global
'http://www.newsmth.net/',
# Why: #2136 in Alexa global
'http://srclick.ru/',
# Why: #2137 in Alexa global
'http://www.bomnegocio.com/',
# Why: #2138 in Alexa global
'http://www.omegle.com/',
# Why: #2139 in Alexa global
'http://www.sweetpacks-search.com/',
# Why: #2140 in Alexa global
'http://www.000webhost.com/',
# Why: #2141 in Alexa global
'http://www.rencontreshard.com/',
# Why: #2142 in Alexa global
'http://www.jumei.com/',
# Why: #2143 in Alexa global
'http://www.acfun.tv/',
# Why: #2144 in Alexa global
'http://www.celebuzz.com/',
# Why: #2145 in Alexa global
'http://www.el-balad.com/',
# Why: #2146 in Alexa global
'http://www.wajam.com/',
# Why: #2147 in Alexa global
'http://www.zoopla.co.uk/',
# Why: #2148 in Alexa global
'http://sc4888.com/',
# Why: #2149 in Alexa global
'http://www.mobileaziende.it/',
# Why: #2150 in Alexa global
'http://www.officialsurvey.org/',
# Why: #2151 in Alexa global
'http://googleapis.com/',
# Why: #2152 in Alexa global
'http://www.mufg.jp/',
# Why: #2153 in Alexa global
'http://www.jobsdb.com/',
# Why: #2154 in Alexa global
'http://www.yahoo.com.cn/',
# Why: #2155 in Alexa global
'http://www.google.com.sv/',
# Why: #2156 in Alexa global
'http://www.freejobalert.com/',
# Why: #2157 in Alexa global
'http://www.walla.co.il/',
# Why: #2158 in Alexa global
'http://www.hollywoodreporter.com/',
# Why: #2159 in Alexa global
'http://www.shop-pro.jp/',
# Why: #2160 in Alexa global
'http://www.inc.com/',
# Why: #2161 in Alexa global
'http://www.bbandt.com/',
# Why: #2162 in Alexa global
'http://www.williamhill.com/',
# Why: #2163 in Alexa global
'http://www.jeu.info/',
# Why: #2164 in Alexa global
'http://www.vrbo.com/',
# Why: #2165 in Alexa global
'http://www.arabseed.com/',
# Why: #2166 in Alexa global
'http://www.spielaffe.de/',
# Why: #2167 in Alexa global
'http://www.wykop.pl/',
# Why: #2168 in Alexa global
'http://www.name.com/',
# Why: #2169 in Alexa global
'http://www.web-opinions.com/',
# Why: #2170 in Alexa global
'http://www.ehowenespanol.com/',
# Why: #2171 in Alexa global
'http://www.uuzu.com/',
# Why: #2173 in Alexa global
'http://www.cafepress.com/',
# Why: #2174 in Alexa global
'http://www.beeline.ru/',
# Why: #2175 in Alexa global
'http://www.searchenginejournal.com/',
# Why: #2176 in Alexa global
'http://mafengwo.cn/',
# Why: #2177 in Alexa global
'http://www.webex.com/',
# Why: #2178 in Alexa global
'http://www.zerohedge.com/',
# Why: #2179 in Alexa global
'http://www.cityads.ru/',
# Why: #2180 in Alexa global
'http://www.columbia.edu/',
# Why: #2181 in Alexa global
'http://jia.com/',
# Why: #2182 in Alexa global
'http://www.tistory.com/',
# Why: #2183 in Alexa global
'http://www.100bestbuy.com/',
# Why: #2184 in Alexa global
'http://www.realitykings.com/',
# Why: #2185 in Alexa global
'http://www.shopify.com/',
# Why: #2186 in Alexa global
'http://www.gametop.com/',
# Why: #2187 in Alexa global
'http://www.eharmony.com/',
# Why: #2188 in Alexa global
'http://www.ngoisao.net/',
# Why: #2189 in Alexa global
'http://www.angieslist.com/',
# Why: #2190 in Alexa global
'http://www.grotal.com/',
# Why: #2191 in Alexa global
'http://www.manhunt.net/',
# Why: #2192 in Alexa global
'http://www.adslgate.com/',
# Why: #2193 in Alexa global
'http://www.demotywatory.pl/',
# Why: #2194 in Alexa global
'http://www.enfemenino.com/',
# Why: #2195 in Alexa global
'http://www.yallakora.com/',
# Why: #2196 in Alexa global
'http://www.careesma.in/',
# Why: #2197 in Alexa global
'http://www.draugiem.lv/',
# Why: #2198 in Alexa global
'http://www.greatandhra.com/',
# Why: #2199 in Alexa global
'http://www.lifescript.com/',
# Why: #2201 in Alexa global
'http://www.androidcentral.com/',
# Why: #2202 in Alexa global
'http://www.wiley.com/',
# Why: #2203 in Alexa global
'http://www.alot.com/',
# Why: #2204 in Alexa global
'http://www.10010.com/',
# Why: #2205 in Alexa global
'http://www.next.co.uk/',
# Why: #2206 in Alexa global
'http://115.com/',
# Why: #2207 in Alexa global
'http://www.omgpm.com/',
# Why: #2208 in Alexa global
'http://www.mycalendarbook.com/',
# Why: #2209 in Alexa global
'http://www.playxn.com/',
# Why: #2210 in Alexa global
'http://www.niksalehi.com/',
# Why: #2211 in Alexa global
'http://www.serviporno.com/',
# Why: #2212 in Alexa global
'http://www.poste.it/',
# Why: #2213 in Alexa global
'http://kimiss.com/',
# Why: #2214 in Alexa global
'http://www.bearshare.com/',
# Why: #2215 in Alexa global
'http://www.clickpoint.com/',
# Why: #2216 in Alexa global
'http://www.seek.com.au/',
# Why: #2217 in Alexa global
'http://www.bab.la/',
# Why: #2218 in Alexa global
'http://www.ads8.com/',
# Why: #2219 in Alexa global
'http://www.viewster.com/',
# Why: #2220 in Alexa global
'http://www.ideacellular.com/',
# Why: #2221 in Alexa global
'http://www.tympanus.net/',
# Why: #2222 in Alexa global
'http://www.wwwblogto.com/',
# Why: #2223 in Alexa global
'http://www.tblop.com/',
# Why: #2224 in Alexa global
'http://elong.com/',
# Why: #2225 in Alexa global
'http://www.funnyordie.com/',
# Why: #2226 in Alexa global
'http://www.radikal.ru/',
# Why: #2227 in Alexa global
'http://www.rk.com/',
# Why: #2228 in Alexa global
'http://www.alarab.net/',
# Why: #2229 in Alexa global
'http://www.willhaben.at/',
# Why: #2230 in Alexa global
'http://www.infoseek.co.jp/',
# Why: #2231 in Alexa global
'http://www.beyond.com/',
# Why: #2232 in Alexa global
'http://www.punchng.com/',
# Why: #2233 in Alexa global
'http://www.viglink.com/',
# Why: #2234 in Alexa global
'http://www.microsoftstore.com/',
# Why: #2235 in Alexa global
'http://www.tripleclicks.com/',
# Why: #2236 in Alexa global
'http://www.m1905.com/',
# Why: #2237 in Alexa global
'http://www.ofreegames.com/',
# Why: #2238 in Alexa global
'http://www.s2d6.com/',
# Why: #2239 in Alexa global
'http://www.360buy.com/',
# Why: #2240 in Alexa global
'http://www.rakuten.com/',
# Why: #2241 in Alexa global
'http://www.evite.com/',
# Why: #2242 in Alexa global
'http://www.kompasiana.com/',
# Why: #2243 in Alexa global
'http://www.dailycaller.com/',
# Why: #2246 in Alexa global
'http://www.holidaycheck.de/',
# Why: #2248 in Alexa global
'http://www.imvu.com/',
# Why: #2249 in Alexa global
'http://www.unfranchise.com.tw/',
# Why: #2250 in Alexa global
'http://www.nate.com/',
# Why: #2251 in Alexa global
'http://fnac.com/',
# Why: #2252 in Alexa global
'http://www.htc.com/',
# Why: #2253 in Alexa global
'http://www.savenkeep.com/',
# Why: #2254 in Alexa global
'http://www.alfabank.ru/',
# Why: #2255 in Alexa global
'http://www.zaycev.net/',
# Why: #2256 in Alexa global
'http://www.vidtomp3.com/',
# Why: #2257 in Alexa global
'http://www.eluniversal.com.mx/',
# Why: #2258 in Alexa global
'http://haiwainet.cn/',
# Why: #2259 in Alexa global
'http://www.theatlantic.com/',
# Why: #2260 in Alexa global
'http://www.gamigo.de/',
# Why: #2261 in Alexa global
'http://www.lolking.net/',
# Why: #2262 in Alexa global
'http://www.wer-kennt-wen.de/',
# Why: #2263 in Alexa global
'http://www.stern.de/',
# Why: #2264 in Alexa global
'http://sport1.de/',
# Why: #2265 in Alexa global
'http://www.goalunited.org/',
# Why: #2266 in Alexa global
'http://www.discogs.com/',
# Why: #2267 in Alexa global
'http://www.whirlpool.net.au/',
# Why: #2268 in Alexa global
'http://www.savefrom.net/',
# Why: #2269 in Alexa global
'http://www.eurosport.fr/',
# Why: #2270 in Alexa global
'http://www.juegosjuegos.com/',
# Why: #2271 in Alexa global
'http://www.open24news.tv/',
# Why: #2272 in Alexa global
'http://www.zozo.jp/',
# Why: #2273 in Alexa global
'http://sinaapp.com/',
# Why: #2274 in Alexa global
'http://www.fuq.com/',
# Why: #2275 in Alexa global
'http://www.index.hr/',
# Why: #2276 in Alexa global
'http://www.realpopbid.com/',
# Why: #2277 in Alexa global
'http://www.rollingstone.com/',
# Why: #2278 in Alexa global
'http://www.globaltestmarket.com/',
# Why: #2279 in Alexa global
'http://www.seopult.ru/',
# Why: #2280 in Alexa global
'http://www.wumii.com/',
# Why: #2281 in Alexa global
'http://www.ford.com/',
# Why: #2282 in Alexa global
'http://www.cabelas.com/',
# Why: #2283 in Alexa global
'http://www.securepaynet.net/',
# Why: #2284 in Alexa global
'http://www.zhibo8.cc/',
# Why: #2285 in Alexa global
'http://www.jiji.com/',
# Why: #2286 in Alexa global
'http://www.gezinti.com/',
# Why: #2287 in Alexa global
'http://www.meb.gov.tr/',
# Why: #2288 in Alexa global
'http://www.classifiedads.com/',
# Why: #2289 in Alexa global
'http://www.kitco.com/',
# Why: #2290 in Alexa global
'http://www.incredimail.com/',
# Why: #2291 in Alexa global
'http://www.esmas.com/',
# Why: #2292 in Alexa global
'http://www.soccerway.com/',
# Why: #2293 in Alexa global
'http://www.rivals.com/',
# Why: #2294 in Alexa global
'http://www.prezi.com/',
# Why: #2295 in Alexa global
'http://www.shopping.com/',
# Why: #2296 in Alexa global
'http://www.superjob.ru/',
# Why: #2297 in Alexa global
'http://chinaacc.com/',
# Why: #2298 in Alexa global
'http://www.amoureux.com/',
# Why: #2299 in Alexa global
'http://www.mysmartprice.com/',
# Why: #2300 in Alexa global
'http://www.eleconomista.es/',
# Why: #2301 in Alexa global
'http://www.mercola.com/',
# Why: #2302 in Alexa global
'http://www.imlive.com/',
# Why: #2303 in Alexa global
'http://www.teacup.com/',
# Why: #2304 in Alexa global
'http://www.modelmayhem.com/',
# Why: #2305 in Alexa global
'http://www.nic.ru/',
# Why: #2306 in Alexa global
'http://www.brazzersnetwork.com/',
# Why: #2307 in Alexa global
'http://www.everything.org.uk/',
# Why: #2308 in Alexa global
'http://www.bhg.com/',
# Why: #2309 in Alexa global
'http://www.longhoo.net/',
# Why: #2311 in Alexa global
'http://www.superpages.com/',
# Why: #2312 in Alexa global
'http://www.tny.cz/',
# Why: #2313 in Alexa global
'http://www.yourfilezone.com/',
# Why: #2314 in Alexa global
'http://www.tuan800.com/',
# Why: #2315 in Alexa global
'http://www.streev.com/',
# Why: #2316 in Alexa global
'http://www.sedty.com/',
# Why: #2317 in Alexa global
'http://www.bol.uol.com.br/',
# Why: #2318 in Alexa global
'http://www.boxofficemojo.com/',
# Why: #2319 in Alexa global
'http://www.hollyscoop.com/',
# Why: #2320 in Alexa global
'http://www.safecart.com/',
# Why: #2321 in Alexa global
'http://www.almogaz.com/',
# Why: #2322 in Alexa global
'http://www.cashnhits.com/',
# Why: #2323 in Alexa global
'http://www.wetplace.com/',
# Why: #2324 in Alexa global
'http://www.freepik.com/',
# Why: #2325 in Alexa global
'http://www.rarbg.com/',
# Why: #2326 in Alexa global
'http://www.xxxbunker.com/',
# Why: #2327 in Alexa global
'http://www.prchecker.info/',
# Why: #2328 in Alexa global
'http://www.halifax-online.co.uk/',
# Why: #2329 in Alexa global
'http://www.trafficfactory.biz/',
# Why: #2330 in Alexa global
'http://www.telecinco.es/',
# Why: #2331 in Alexa global
'http://www.searchtermresults.com/',
# Why: #2332 in Alexa global
'http://www.unam.mx/',
# Why: #2333 in Alexa global
'http://www.akhbar-elwatan.com/',
# Why: #2335 in Alexa global
'http://lynda.com/',
# Why: #2336 in Alexa global
'http://www.yougetlaid.com/',
# Why: #2337 in Alexa global
'http://www.smart.com.au/',
# Why: #2338 in Alexa global
'http://www.advfn.com/',
# Why: #2339 in Alexa global
'http://www.unicredit.it/',
# Why: #2340 in Alexa global
'http://www.zomato.com/',
# Why: #2341 in Alexa global
'http://www.flirt.com/',
# Why: #2342 in Alexa global
'http://netease.com/',
# Why: #2343 in Alexa global
'http://www.bnpparibas.net/',
# Why: #2344 in Alexa global
'http://www.elcomercio.pe/',
# Why: #2345 in Alexa global
'http://www.mathrubhumi.com/',
# Why: #2346 in Alexa global
'http://www.koyotesoft.com/',
# Why: #2347 in Alexa global
'http://www.filmix.net/',
# Why: #2348 in Alexa global
'http://www.xnxxhdtube.com/',
# Why: #2349 in Alexa global
'http://www.ennaharonline.com/',
# Why: #2350 in Alexa global
'http://www.junbi-tracker.com/',
# Why: #2351 in Alexa global
'http://www.buzzdock.com/',
# Why: #2352 in Alexa global
'http://www.emirates.com/',
# Why: #2353 in Alexa global
'http://wikiwiki.jp/',
# Why: #2354 in Alexa global
'http://www.vivanuncios.com.mx/',
# Why: #2355 in Alexa global
'http://www.infojobs.net/',
# Why: #2356 in Alexa global
'http://www.smi2.ru/',
# Why: #2357 in Alexa global
'http://www.lotterypost.com/',
# Why: #2358 in Alexa global
'http://www.bandcamp.com/',
# Why: #2359 in Alexa global
'http://www.ekstrabladet.dk/',
# Why: #2360 in Alexa global
'http://www.nownews.com/',
# Why: #2361 in Alexa global
'http://www.bc.vc/',
# Why: #2362 in Alexa global
'http://www.google.com.af/',
# Why: #2364 in Alexa global
'http://www.ulmart.ru/',
# Why: #2365 in Alexa global
'http://www.estadao.com.br/',
# Why: #2366 in Alexa global
'http://www.politico.com/',
# Why: #2367 in Alexa global
'http://kl688.com/',
# Why: #2368 in Alexa global
'http://www.resellerclub.com/',
# Why: #2369 in Alexa global
'http://www.whois.net/',
# Why: #2370 in Alexa global
'http://www.seobuilding.ru/',
# Why: #2371 in Alexa global
'http://www.t411.me/',
# Why: #2372 in Alexa global
'http://googlesyndication.com/',
# Why: #2373 in Alexa global
'http://delfi.lt/',
# Why: #2374 in Alexa global
'http://www.eqla3.com/',
# Why: #2375 in Alexa global
'http://www.ali213.net/',
# Why: #2376 in Alexa global
'http://www.jma.go.jp/',
# Why: #2377 in Alexa global
'http://www.xvideos.jp/',
# Why: #2378 in Alexa global
'http://www.fanpage.it/',
# Why: #2379 in Alexa global
'http://www.uptobox.com/',
# Why: #2380 in Alexa global
'http://www.shinobi.jp/',
# Why: #2381 in Alexa global
'http://www.google.jo/',
# Why: #2382 in Alexa global
'http://cncn.com/',
# Why: #2383 in Alexa global
'http://www.sme.sk/',
# Why: #2384 in Alexa global
'http://www.kinozal.tv/',
# Why: #2385 in Alexa global
'http://www.ceconline.com/',
# Why: #2386 in Alexa global
'http://www.billboard.com/',
# Why: #2387 in Alexa global
'http://www.citi.com/',
# Why: #2388 in Alexa global
'http://www.naughtyamerica.com/',
# Why: #2389 in Alexa global
'http://www.classmates.com/',
# Why: #2390 in Alexa global
'http://www.coursera.org/',
# Why: #2391 in Alexa global
'http://www.pingan.com/',
# Why: #2392 in Alexa global
'http://www.voanews.com/',
# Why: #2393 in Alexa global
'http://www.tankionline.com/',
# Why: #2394 in Alexa global
'http://www.jetblue.com/',
# Why: #2395 in Alexa global
'http://www.spainshtranslation.com/',
# Why: #2396 in Alexa global
'http://www.ebookbrowse.com/',
# Why: #2397 in Alexa global
'http://www.met-art.com/',
# Why: #2398 in Alexa global
'http://www.megafon.ru/',
# Why: #2399 in Alexa global
'http://www.quibids.com/',
# Why: #2400 in Alexa global
'http://www.prcm.jp/',
# Why: #2401 in Alexa global
'http://www.smartfren.com/',
# Why: #2402 in Alexa global
'http://www.cleartrip.com/',
# Why: #2403 in Alexa global
'http://www.pixmania.com/',
# Why: #2405 in Alexa global
'http://www.vivastreet.com/',
# Why: #2406 in Alexa global
'http://www.thegfnetwork.com/',
# Why: #2407 in Alexa global
'http://www.paytm.com/',
# Why: #2408 in Alexa global
'http://www.meinsextagebuch.net/',
# Why: #2409 in Alexa global
'http://www.memecenter.com/',
# Why: #2410 in Alexa global
'http://www.ixbt.com/',
# Why: #2411 in Alexa global
'http://www.dagbladet.no/',
# Why: #2412 in Alexa global
'http://www.basecamphq.com/',
# Why: #2413 in Alexa global
'http://www.chinatimes.com/',
# Why: #2414 in Alexa global
'http://www.bubblews.com/',
# Why: #2415 in Alexa global
'http://www.xtool.ru/',
# Why: #2416 in Alexa global
'http://yoho.cn/',
# Why: #2417 in Alexa global
'http://www.opodo.co.uk/',
# Why: #2418 in Alexa global
'http://www.hattrick.org/',
# Why: #2419 in Alexa global
'http://www.zopim.com/',
# Why: #2420 in Alexa global
'http://www.aol.co.uk/',
# Why: #2421 in Alexa global
'http://www.gazzetta.gr/',
# Why: #2422 in Alexa global
'http://www.18andabused.com/',
# Why: #2423 in Alexa global
'http://www.panasonic.jp/',
# Why: #2424 in Alexa global
'http://www.mcssl.com/',
# Why: #2425 in Alexa global
'http://www.economist.com/',
# Why: #2426 in Alexa global
'http://www.zeit.de/',
# Why: #2427 in Alexa global
'http://www.google.com.uy/',
# Why: #2428 in Alexa global
'http://www.pinoy-ako.info/',
# Why: #2429 in Alexa global
'http://www.lazada.co.id/',
# Why: #2430 in Alexa global
'http://www.filgoal.com/',
# Why: #2431 in Alexa global
'http://www.rozetka.com.ua/',
# Why: #2432 in Alexa global
'http://www.almesryoon.com/',
# Why: #2433 in Alexa global
'http://www.csmonitor.com/',
# Why: #2434 in Alexa global
'http://www.bizjournals.com/',
# Why: #2435 in Alexa global
'http://www.rackspace.com/',
# Why: #2436 in Alexa global
'http://www.webgozar.com/',
# Why: #2437 in Alexa global
'http://www.opencart.com/',
# Why: #2438 in Alexa global
'http://www.mediaplex.com/',
# Why: #2439 in Alexa global
'http://www.deutsche-bank.de/',
# Why: #2440 in Alexa global
'http://www.similarsites.com/',
# Why: #2441 in Alexa global
'http://www.sotmarket.ru/',
# Why: #2442 in Alexa global
'http://www.chatzum.com/',
# Why: #2443 in Alexa global
'http://www.huffingtonpost.co.uk/',
# Why: #2444 in Alexa global
'http://www.carwale.com/',
# Why: #2445 in Alexa global
'http://www.memez.com/',
# Why: #2446 in Alexa global
'http://www.hostmonster.com/',
# Why: #2447 in Alexa global
'http://www.muzofon.com/',
# Why: #2448 in Alexa global
'http://www.elephanttube.com/',
# Why: #2449 in Alexa global
'http://www.crunchbase.com/',
# Why: #2450 in Alexa global
'http://www.imhonet.ru/',
# Why: #2451 in Alexa global
'http://www.lusongsong.com/',
# Why: #2452 in Alexa global
'http://www.filmesonlinegratis.net/',
# Why: #2453 in Alexa global
'http://www.giaoduc.net.vn/',
# Why: #2454 in Alexa global
'http://www.manhub.com/',
# Why: #2455 in Alexa global
'http://www.tatadocomo.com/',
# Why: #2458 in Alexa global
'http://www.realitatea.net/',
# Why: #2459 in Alexa global
'http://www.freemp3x.com/',
# Why: #2460 in Alexa global
'http://www.freemail.hu/',
# Why: #2461 in Alexa global
'http://www.ganool.com/',
# Why: #2462 in Alexa global
'http://www.feedreader.com/',
# Why: #2463 in Alexa global
'http://www.sportsdirect.com/',
# Why: #2464 in Alexa global
'http://www.videolan.org/',
# Why: #2465 in Alexa global
'http://www.watchseries.lt/',
# Why: #2466 in Alexa global
'http://www.rotapost.ru/',
# Why: #2467 in Alexa global
'http://www.nwolb.com/',
# Why: #2468 in Alexa global
'http://www.searchquotes.com/',
# Why: #2469 in Alexa global
'http://www.kaspersky.com/',
# Why: #2470 in Alexa global
'http://www.go2cloud.org/',
# Why: #2471 in Alexa global
'http://www.grepolis.com/',
# Why: #2472 in Alexa global
'http://fh21.com.cn/',
# Why: #2473 in Alexa global
'http://www.profit-partner.ru/',
# Why: #2475 in Alexa global
'http://www.articlesbase.com/',
# Why: #2476 in Alexa global
'http://www.dns-shop.ru/',
# Why: #2477 in Alexa global
'http://www.radikal.com.tr/',
# Why: #2478 in Alexa global
'http://www.justjared.com/',
# Why: #2479 in Alexa global
'http://www.lancenet.com.br/',
# Why: #2480 in Alexa global
'http://www.mangapanda.com/',
# Why: #2481 in Alexa global
'http://www.theglobeandmail.com/',
# Why: #2483 in Alexa global
'http://www.ecollege.com/',
# Why: #2484 in Alexa global
'http://www.myanimelist.net/',
# Why: #2485 in Alexa global
'http://www.immoral.jp/',
# Why: #2486 in Alexa global
'http://www.fotomac.com.tr/',
# Why: #2487 in Alexa global
'http://imanhua.com/',
# Why: #2488 in Alexa global
'http://www.travelzoo.com/',
# Why: #2489 in Alexa global
'http://www.jjwxc.net/',
# Why: #2490 in Alexa global
'http://www.q.gs/',
# Why: #2491 in Alexa global
'http://www.naaptol.com/',
# Why: #2492 in Alexa global
'http://www.sambaporno.com/',
# Why: #2493 in Alexa global
'http://www.macrojuegos.com/',
# Why: #2494 in Alexa global
'http://www.ooo-sex.com/',
# Why: #2495 in Alexa global
'http://www.fab.com/',
# Why: #2496 in Alexa global
'http://www.roflzone.com/',
# Why: #2497 in Alexa global
'http://www.searchcompletion.com/',
# Why: #2498 in Alexa global
'http://www.jezebel.com/',
# Why: #2499 in Alexa global
'http://bizdec.ru/',
# Why: #2500 in Alexa global
'http://www.torrentino.com/',
# Why: #2501 in Alexa global
'http://www.multitran.ru/',
# Why: #2502 in Alexa global
'http://www.tune-up.com/',
# Why: #2503 in Alexa global
'http://www.sparkpeople.com/',
# Why: #2505 in Alexa global
'http://www.desi-tashan.com/',
# Why: #2506 in Alexa global
'http://www.mashreghnews.ir/',
# Why: #2507 in Alexa global
'http://www.talktalk.co.uk/',
# Why: #2508 in Alexa global
'http://www.hinkhoj.com/',
# Why: #2509 in Alexa global
'http://www.20minutes.fr/',
# Why: #2510 in Alexa global
'http://www.sulia.com/',
# Why: #2511 in Alexa global
'http://www.icims.com/',
# Why: #2512 in Alexa global
'http://www.dizi-mag.com/',
# Why: #2513 in Alexa global
'http://www.webaslan.com/',
# Why: #2514 in Alexa global
'http://www.en.wordpress.com/',
# Why: #2515 in Alexa global
'http://www.funmoods.com/',
# Why: #2516 in Alexa global
'http://www.softgozar.com/',
# Why: #2517 in Alexa global
'http://www.starwoodhotels.com/',
# Why: #2518 in Alexa global
'http://www.studiopress.com/',
# Why: #2519 in Alexa global
'http://www.click.in/',
# Why: #2520 in Alexa global
'http://www.meetcheap.com/',
# Why: #2521 in Alexa global
'http://www.angel-live.com/',
# Why: #2522 in Alexa global
'http://www.beforeitsnews.com/',
# Why: #2524 in Alexa global
'http://www.trello.com/',
# Why: #2525 in Alexa global
'http://www.icontact.com/',
# Why: #2526 in Alexa global
'http://www.prlog.org/',
# Why: #2527 in Alexa global
'http://www.incentria.com/',
# Why: #2528 in Alexa global
'http://www.bouyguestelecom.fr/',
# Why: #2529 in Alexa global
'http://www.dstv.com/',
# Why: #2530 in Alexa global
'http://www.arstechnica.com/',
# Why: #2531 in Alexa global
'http://www.diigo.com/',
# Why: #2532 in Alexa global
'http://www.consumers-research.com/',
# Why: #2533 in Alexa global
'http://www.metaffiliation.com/',
# Why: #2534 in Alexa global
'http://www.telekom.de/',
# Why: #2535 in Alexa global
'http://www.izlesene.com/',
# Why: #2536 in Alexa global
'http://www.newsit.gr/',
# Why: #2537 in Alexa global
'http://www.fuckingawesome.com/',
# Why: #2538 in Alexa global
'http://www.osym.gov.tr/',
# Why: #2539 in Alexa global
'http://www.svyaznoy.ru/',
# Why: #2540 in Alexa global
'http://www.watchfreemovies.ch/',
# Why: #2541 in Alexa global
'http://www.gumtree.pl/',
# Why: #2542 in Alexa global
'http://www.sportbox.ru/',
# Why: #2543 in Alexa global
'http://www.reserverunessai.com/',
# Why: #2544 in Alexa global
'http://www.hsbc.com.hk/',
# Why: #2546 in Alexa global
'http://www.cricbuzz.com/',
# Why: #2547 in Alexa global
'http://www.djelfa.info/',
# Why: #2548 in Alexa global
'http://www.nouvelobs.com/',
# Why: #2549 in Alexa global
'http://www.aruba.it/',
# Why: #2550 in Alexa global
'http://www.homes.com/',
# Why: #2551 in Alexa global
'http://www.allezleslions.com/',
# Why: #2552 in Alexa global
'http://www.orkut.com.br/',
# Why: #2553 in Alexa global
'http://www.aionfreetoplay.com/',
# Why: #2554 in Alexa global
'http://www.academia.edu/',
# Why: #2555 in Alexa global
'http://www.blogosfera.uol.com.br/',
# Why: #2556 in Alexa global
'http://www.consumerreports.org/',
# Why: #2557 in Alexa global
'http://www.ilsole24ore.com/',
# Why: #2558 in Alexa global
'http://www.sephora.com/',
# Why: #2559 in Alexa global
'http://www.lds.org/',
# Why: #2560 in Alexa global
'http://vmall.com/',
# Why: #2561 in Alexa global
'http://www.ultimasnoticias.com.ve/',
# Why: #2562 in Alexa global
'http://www.healthgrades.com/',
# Why: #2563 in Alexa global
'http://www.imgbox.com/',
# Why: #2564 in Alexa global
'http://www.dlsite.com/',
# Why: #2565 in Alexa global
'http://www.whitesmoke.com/',
# Why: #2566 in Alexa global
'http://www.thenextweb.com/',
# Why: #2567 in Alexa global
'http://www.qire123.com/',
# Why: #2568 in Alexa global
'http://www.peeplo.com/',
# Why: #2569 in Alexa global
'http://www.chitika.com/',
# Why: #2570 in Alexa global
'http://www.alwafd.org/',
# Why: #2571 in Alexa global
'http://www.phonearena.com/',
# Why: #2572 in Alexa global
'http://www.ovh.com/',
# Why: #2573 in Alexa global
'http://www.tusfiles.net/',
# Why: #2574 in Alexa global
'http://www.18schoolgirlz.com/',
# Why: #2575 in Alexa global
'http://www.bongacams.com/',
# Why: #2576 in Alexa global
'http://www.home.pl/',
# Why: #2577 in Alexa global
'http://www.footmercato.net/',
# Why: #2579 in Alexa global
'http://www.sprashivai.ru/',
# Why: #2580 in Alexa global
'http://www.megafilmeshd.net/',
# Why: #2581 in Alexa global
'http://www.premium-display.com/',
# Why: #2582 in Alexa global
'http://www.clickey.com/',
# Why: #2584 in Alexa global
'http://www.tokyo-tube.com/',
# Why: #2585 in Alexa global
'http://www.watch32.com/',
# Why: #2586 in Alexa global
'http://www.pornolab.net/',
# Why: #2587 in Alexa global
'http://www.timewarnercable.com/',
# Why: #2588 in Alexa global
'http://www.naturalnews.com/',
# Why: #2589 in Alexa global
'http://www.afimet.com/',
# Why: #2590 in Alexa global
'http://www.telderi.ru/',
# Why: #2591 in Alexa global
'http://www.ioffer.com/',
# Why: #2592 in Alexa global
'http://www.lapatilla.com/',
# Why: #2593 in Alexa global
'http://www.livetv.ru/',
# Why: #2594 in Alexa global
'http://www.cloudflare.com/',
# Why: #2595 in Alexa global
'http://www.lupoporno.com/',
# Why: #2597 in Alexa global
'http://www.nhaccuatui.com/',
# Why: #2598 in Alexa global
'http://www.thepostgame.com/',
# Why: #2599 in Alexa global
'http://www.ipage.com/',
# Why: #2600 in Alexa global
'http://www.banesconline.com/',
# Why: #2601 in Alexa global
'http://www.cdc.gov/',
# Why: #2602 in Alexa global
'http://www.adonweb.ru/',
# Why: #2603 in Alexa global
'http://www.zone-telechargement.com/',
# Why: #2604 in Alexa global
'http://www.intellicast.com/',
# Why: #2605 in Alexa global
'http://www.uloz.to/',
# Why: #2606 in Alexa global
'http://www.pikabu.ru/',
# Why: #2607 in Alexa global
'http://www.megogo.net/',
# Why: #2608 in Alexa global
'http://www.wenxuecity.com/',
# Why: #2609 in Alexa global
'http://www.xml-sitemaps.com/',
# Why: #2610 in Alexa global
'http://www.webdunia.com/',
# Why: #2611 in Alexa global
'http://www.justhost.com/',
# Why: #2612 in Alexa global
'http://www.starbucks.com/',
# Why: #2613 in Alexa global
'http://www.wargaming.net/',
# Why: #2614 in Alexa global
'http://www.hugedomains.com/',
# Why: #2615 in Alexa global
'http://magicbricks.com/',
# Why: #2616 in Alexa global
'http://gigporno.com/',
# Why: #2617 in Alexa global
'http://www.rikunabi.com/',
# Why: #2618 in Alexa global
'http://www.51auto.com/',
# Why: #2619 in Alexa global
'http://www.warriorplus.com/',
# Why: #2620 in Alexa global
'http://www.gudvin.tv/',
# Why: #2621 in Alexa global
'http://www.bigmir.net/',
# Why: #2622 in Alexa global
'http://twipple.jp/',
# Why: #2623 in Alexa global
'http://www.ansa.it/',
# Why: #2624 in Alexa global
'http://www.standardbank.co.za/',
# Why: #2625 in Alexa global
'http://www.toshiba.com/',
# Why: #2626 in Alexa global
'http://www.xinnet.com/',
# Why: #2627 in Alexa global
'http://www.geico.com/',
# Why: #2629 in Alexa global
'http://www.funnyjunk.com/',
# Why: #2630 in Alexa global
'http://affaritaliani.it/',
# Why: #2631 in Alexa global
'http://www.cityheaven.net/',
# Why: #2632 in Alexa global
'http://www.tubewolf.com/',
# Why: #2633 in Alexa global
'http://www.google.org/',
# Why: #2634 in Alexa global
'http://www.ad.nl/',
# Why: #2635 in Alexa global
'http://www.tutorialspoint.com/',
# Why: #2638 in Alexa global
'http://www.uidai.gov.in/',
# Why: #2639 in Alexa global
'http://www.everydayhealth.com/',
# Why: #2640 in Alexa global
'http://www.jzip.com/',
# Why: #2641 in Alexa global
'http://www.lolspotsarticles.com/',
# Why: #2642 in Alexa global
'http://www.ana.co.jp/',
# Why: #2643 in Alexa global
'http://www.rueducommerce.fr/',
# Why: #2644 in Alexa global
'http://www.lvmama.com/',
# Why: #2645 in Alexa global
'http://www.roboform.com/',
# Why: #2646 in Alexa global
'http://www.zoznam.sk/',
# Why: #2647 in Alexa global
'http://www.livesmi.com/',
# Why: #2648 in Alexa global
'http://www.die-boersenformel.com/',
# Why: #2649 in Alexa global
'http://www.watchcartoononline.com/',
# Why: #2650 in Alexa global
'http://www.abclocal.go.com/',
# Why: #2651 in Alexa global
'http://www.techrepublic.com/',
# Why: #2652 in Alexa global
'http://www.just-fuck.com/',
# Why: #2653 in Alexa global
'http://www.camster.com/',
# Why: #2654 in Alexa global
'http://www.akairan.com/',
# Why: #2655 in Alexa global
'http://www.yeslibertin.com/',
# Why: #2656 in Alexa global
'http://www.abc.go.com/',
# Why: #2657 in Alexa global
'http://www.searchtherightwords.com/',
# Why: #2658 in Alexa global
'http://www.scotiabank.com/',
# Why: #2659 in Alexa global
'http://www.justclick.ru/',
# Why: #2660 in Alexa global
'http://www.douguo.com/',
# Why: #2661 in Alexa global
'http://www.discover.com/',
# Why: #2662 in Alexa global
'http://www.britishairways.com/',
# Why: #2663 in Alexa global
'http://www.mobafire.com/',
# Why: #2664 in Alexa global
'http://www.gi-akademie.ning.com/',
# Why: #2666 in Alexa global
'http://www.desirulez.net/',
# Why: #2667 in Alexa global
'http://www.qiushibaike.com/',
# Why: #2668 in Alexa global
'http://www.moonbasa.com/',
# Why: #2669 in Alexa global
'http://www.all.biz/',
# Why: #2670 in Alexa global
'http://www.tbs.co.jp/',
# Why: #2671 in Alexa global
'http://www.springer.com/',
# Why: #2672 in Alexa global
'http://www.emai.com/',
# Why: #2673 in Alexa global
'http://www.deadspin.com/',
# Why: #2674 in Alexa global
'http://www.hulkshare.com/',
# Why: #2675 in Alexa global
'http://www.fast-torrent.ru/',
# Why: #2676 in Alexa global
'http://www.oriflame.com/',
# Why: #2677 in Alexa global
'http://www.imgchili.net/',
# Why: #2678 in Alexa global
'http://www.mega-juegos.mx/',
# Why: #2679 in Alexa global
'http://www.gyazo.com/',
# Why: #2680 in Alexa global
'http://www.persianv.com/',
# Why: #2681 in Alexa global
'http://www.adk2.com/',
# Why: #2682 in Alexa global
'http://www.ingbank.pl/',
# Why: #2683 in Alexa global
'http://www.nationalconsumercenter.com/',
# Why: #2684 in Alexa global
'http://www.xxxkinky.com/',
# Why: #2685 in Alexa global
'http://www.mywot.com/',
# Why: #2686 in Alexa global
'http://www.gaymaletube.com/',
# Why: #2687 in Alexa global
'http://www.1tv.ru/',
# Why: #2688 in Alexa global
'http://www.manutd.com/',
# Why: #2689 in Alexa global
'http://www.merchantcircle.com/',
# Why: #2691 in Alexa global
'http://www.canalblog.com/',
# Why: #2692 in Alexa global
'http://www.capitalone360.com/',
# Why: #2693 in Alexa global
'http://www.tlbb8.com/',
# Why: #2694 in Alexa global
'http://www.softonic.fr/',
# Why: #2695 in Alexa global
'http://www.ccavenue.com/',
# Why: #2696 in Alexa global
'http://www.vector.co.jp/',
# Why: #2697 in Alexa global
'http://www.tyroodr.com/',
# Why: #2698 in Alexa global
'http://exam8.com/',
# Why: #2699 in Alexa global
'http://www.allmusic.com/',
# Why: #2700 in Alexa global
'http://www.stubhub.com/',
# Why: #2701 in Alexa global
'http://www.arcor.de/',
# Why: #2702 in Alexa global
'http://www.yolasite.com/',
# Why: #2703 in Alexa global
'http://www.haraj.com.sa/',
# Why: #2704 in Alexa global
'http://www.mypopup.ir/',
# Why: #2705 in Alexa global
'http://www.memurlar.net/',
# Why: #2706 in Alexa global
'http://www.smugmug.com/',
# Why: #2707 in Alexa global
'http://www.filefactory.com/',
# Why: #2708 in Alexa global
'http://www.fantasti.cc/',
# Why: #2709 in Alexa global
'http://www.bokra.net/',
# Why: #2710 in Alexa global
'http://www.goarticles.com/',
# Why: #2711 in Alexa global
'http://www.empowernetwork.com/2Se8w/',
# Why: #2712 in Alexa global
'http://www.moneysavingexpert.com/',
# Why: #2713 in Alexa global
'http://www.donga.com/',
# Why: #2714 in Alexa global
'http://www.lastminute.com/',
# Why: #2715 in Alexa global
'http://www.xkcd.com/',
# Why: #2716 in Alexa global
'http://www.sou300.com/',
# Why: #2717 in Alexa global
'http://www.magnovideo.com/',
# Why: #2718 in Alexa global
'http://www.inquirer.net/',
# Why: #2719 in Alexa global
'http://www.phoenix.edu/',
# Why: #2721 in Alexa global
'http://www.videogenesis.com/',
# Why: #2722 in Alexa global
'http://www.thestar.com/',
# Why: #2723 in Alexa global
'http://www.tripadvisor.es/',
# Why: #2724 in Alexa global
'http://www.blankrefer.com/',
# Why: #2725 in Alexa global
'http://www.yle.fi/',
# Why: #2726 in Alexa global
'http://www.beamtele.com/',
# Why: #2727 in Alexa global
'http://www.oanda.com/',
# Why: #2728 in Alexa global
'http://www.yaplog.jp/',
# Why: #2729 in Alexa global
'http://www.iheart.com/',
# Why: #2730 in Alexa global
'http://www.google.co.tz/',
# Why: #2731 in Alexa global
'http://www.stargazete.com/',
# Why: #2732 in Alexa global
'http://www.bossip.com/',
# Why: #2733 in Alexa global
'http://www.defaultsear.ch/',
# Why: #2734 in Alexa global
'http://www.thaiseoboard.com/',
# Why: #2735 in Alexa global
'http://www.qinbei.com/',
# Why: #2736 in Alexa global
'http://www.ninisite.com/',
# Why: #2737 in Alexa global
'http://www.j.gs/',
# Why: #2738 in Alexa global
'http://www.xinmin.cn/',
# Why: #2739 in Alexa global
'http://www.nos.nl/',
# Why: #2740 in Alexa global
'http://www.qualtrics.com/',
# Why: #2741 in Alexa global
'http://www.kommersant.ru/',
# Why: #2743 in Alexa global
'http://www.urban-rivals.com/',
# Why: #2744 in Alexa global
'http://www.computerbild.de/',
# Why: #2745 in Alexa global
'http://www.fararu.com/',
# Why: #2746 in Alexa global
'http://www.menshealth.com/',
# Why: #2747 in Alexa global
'http://www.jobstreet.com/',
# Why: #2749 in Alexa global
'http://www.rbcroyalbank.com/',
# Why: #2750 in Alexa global
'http://www.inmotionhosting.com/',
# Why: #2751 in Alexa global
'http://www.surveyrouter.com/',
# Why: #2752 in Alexa global
'http://www.kankanews.com/',
# Why: #2753 in Alexa global
'http://www.aol.de/',
# Why: #2754 in Alexa global
'http://www.bol.com/',
# Why: #2755 in Alexa global
'http://www.datpiff.com/',
# Why: #2757 in Alexa global
'http://mplife.com/',
# Why: #2758 in Alexa global
'http://www.sale-fire.com/',
# Why: #2759 in Alexa global
'http://www.inbox.lv/',
# Why: #2760 in Alexa global
'http://www.offeratum.com/',
# Why: #2761 in Alexa global
'http://www.pandora.tv/',
# Why: #2762 in Alexa global
'http://www.eltiempo.com/',
# Why: #2763 in Alexa global
'http://www.indiarailinfo.com/',
# Why: #2764 in Alexa global
'http://www.solidtrustpay.com/',
# Why: #2765 in Alexa global
'http://www.warthunder.ru/',
# Why: #2766 in Alexa global
'http://www.kuronekoyamato.co.jp/',
# Why: #2767 in Alexa global
'http://www.novamov.com/',
# Why: #2768 in Alexa global
'http://www.folkd.com/',
# Why: #2769 in Alexa global
'http://www.envato.com/',
# Why: #2770 in Alexa global
'http://www.wetpaint.com/',
# Why: #2771 in Alexa global
'http://www.tempo.co/',
# Why: #2772 in Alexa global
'http://www.howtogeek.com/',
# Why: #2773 in Alexa global
'http://www.foundationapi.com/',
# Why: #2774 in Alexa global
'http://www.zjol.com.cn/',
# Why: #2775 in Alexa global
'http://www.care2.com/',
# Why: #2776 in Alexa global
'http://www.bendibao.com/',
# Why: #2777 in Alexa global
'http://www.mazika2day.com/',
# Why: #2779 in Alexa global
'http://www.asda.com/',
# Why: #2780 in Alexa global
'http://www.nowvideo.ch/',
# Why: #2781 in Alexa global
'http://www.hiapk.com/',
# Why: #2782 in Alexa global
'http://17u.com/',
# Why: #2783 in Alexa global
'http://www.tutu.ru/',
# Why: #2784 in Alexa global
'http://www.ncdownloader.com/',
# Why: #2785 in Alexa global
'http://www.warez-bb.org/',
# Why: #2786 in Alexa global
'http://www.jsoftj.com/',
# Why: #2787 in Alexa global
'http://www.batepapo.uol.com.br/',
# Why: #2788 in Alexa global
'http://www.xmarks.com/',
# Why: #2789 in Alexa global
'http://www.36kr.com/',
# Why: #2790 in Alexa global
'http://www.runetki.com/',
# Why: #2791 in Alexa global
'http://www.quoka.de/',
# Why: #2792 in Alexa global
'http://www.heureka.cz/',
# Why: #2793 in Alexa global
'http://www.sbisec.co.jp/',
# Why: #2794 in Alexa global
'http://www.monografias.com/',
# Why: #2796 in Alexa global
'http://www.zhenai.com/',
# Why: #2797 in Alexa global
'http://www.4porn.com/',
# Why: #2798 in Alexa global
'http://www.antena3.com/',
# Why: #2799 in Alexa global
'http://lintas.me/',
# Why: #2800 in Alexa global
'http://www.seroundtable.com/',
# Why: #2802 in Alexa global
'http://www.e1.ru/',
# Why: #2803 in Alexa global
'http://www.berkeley.edu/',
# Why: #2804 in Alexa global
'http://www.officedepot.com/',
# Why: #2805 in Alexa global
'http://www.myflorida.com/',
# Why: #2806 in Alexa global
'http://www.parispornmovies.com/',
# Why: #2807 in Alexa global
'http://www.uniqlo.com/',
# Why: #2808 in Alexa global
'http://www.topky.sk/',
# Why: #2809 in Alexa global
'http://www.lumovies.com/',
# Why: #2810 in Alexa global
'http://www.buysellads.com/',
# Why: #2811 in Alexa global
'http://www.stirileprotv.ro/',
# Why: #2812 in Alexa global
'http://www.scottrade.com/',
# Why: #2813 in Alexa global
'http://www.tiboo.cn/',
# Why: #2814 in Alexa global
'http://www.mmtrends.net/',
# Why: #2815 in Alexa global
'http://www.wholesale-dress.net/',
# Why: #2816 in Alexa global
'http://www.metacritic.com/',
# Why: #2817 in Alexa global
'http://www.pichunter.com/',
# Why: #2818 in Alexa global
'http://www.moneybookers.com/',
# Why: #2819 in Alexa global
'http://www.idealista.com/',
# Why: #2820 in Alexa global
'http://www.buzzle.com/',
# Why: #2821 in Alexa global
'http://www.rcom.co.in/',
# Why: #2822 in Alexa global
'http://www.weightwatchers.com/',
# Why: #2823 in Alexa global
'http://www.itv.com/',
# Why: #2824 in Alexa global
'http://www.inilah.com/',
# Why: #2825 in Alexa global
'http://www.vic.gov.au/',
# Why: #2826 in Alexa global
'http://www.prom.ua/',
# Why: #2827 in Alexa global
'http://www.with2.net/',
# Why: #2828 in Alexa global
'http://www.suumo.jp/',
# Why: #2830 in Alexa global
'http://www.doodle.com/',
# Why: #2831 in Alexa global
'http://www.trafficbroker.com/',
# Why: #2832 in Alexa global
'http://www.h33t.com/',
# Why: #2833 in Alexa global
'http://www.avaaz.org/',
# Why: #2834 in Alexa global
'http://www.maultalk.com/',
# Why: #2835 in Alexa global
'http://www.bmo.com/',
# Why: #2836 in Alexa global
'http://www.nerdbux.com/',
# Why: #2837 in Alexa global
'http://www.abnamro.nl/',
# Why: #2838 in Alexa global
'http://www.didigames.com/',
# Why: #2839 in Alexa global
'http://www.pornorama.com/',
# Why: #2840 in Alexa global
'http://www.forumotion.com/',
# Why: #2841 in Alexa global
'http://www.woman.ru/',
# Why: #2843 in Alexa global
'http://www.thaivisa.com/',
# Why: #2844 in Alexa global
'http://www.lexpress.fr/',
# Why: #2845 in Alexa global
'http://www.forumcommunity.net/',
# Why: #2846 in Alexa global
'http://www.regions.com/',
# Why: #2847 in Alexa global
'http://www.sf-express.com/',
# Why: #2848 in Alexa global
'http://www.donkeymails.com/',
# Why: #2849 in Alexa global
'http://www.clubic.com/',
# Why: #2850 in Alexa global
'http://www.aucfan.com/',
# Why: #2851 in Alexa global
'http://www.enterfactory.com/',
# Why: #2852 in Alexa global
'http://www.yandex.com/',
# Why: #2853 in Alexa global
'http://www.iherb.com/',
# Why: #2854 in Alexa global
'http://www.in.gr/',
# Why: #2855 in Alexa global
'http://www.olx.pt/',
# Why: #2856 in Alexa global
'http://www.fbdownloader.com/',
# Why: #2857 in Alexa global
'http://www.autoscout24.it/',
# Why: #2858 in Alexa global
'http://www.siteground.com/',
# Why: #2859 in Alexa global
'http://www.psicofxp.com/',
# Why: #2860 in Alexa global
'http://www.persiangig.com/',
# Why: #2861 in Alexa global
'http://www.metroer.com/',
# Why: #2862 in Alexa global
'http://www.tokopedia.com/',
# Why: #2863 in Alexa global
'http://www.seccam.info/',
# Why: #2864 in Alexa global
'http://www.sport-express.ru/',
# Why: #2865 in Alexa global
'http://www.vodafone.it/',
# Why: #2866 in Alexa global
'http://www.blekko.com/',
# Why: #2867 in Alexa global
'http://www.entekhab.ir/',
# Why: #2868 in Alexa global
'http://www.expressen.se/',
# Why: #2869 in Alexa global
'http://www.zalando.fr/',
# Why: #2870 in Alexa global
'http://525j.com.cn/',
# Why: #2871 in Alexa global
'http://www.hawaaworld.com/',
# Why: #2872 in Alexa global
'http://www.freeonlinegames.com/',
# Why: #2873 in Alexa global
'http://www.google.com.lb/',
# Why: #2874 in Alexa global
'http://www.oricon.co.jp/',
# Why: #2875 in Alexa global
'http://www.apple.com.cn/',
# Why: #2876 in Alexa global
'http://www.ab-in-den-urlaub.de/',
# Why: #2877 in Alexa global
'http://www.android4tw.com/',
# Why: #2879 in Alexa global
'http://www.alriyadh.com/',
# Why: #2880 in Alexa global
'http://www.drugstore.com/',
# Why: #2881 in Alexa global
'http://www.iobit.com/',
# Why: #2882 in Alexa global
'http://www.rei.com/',
# Why: #2883 in Alexa global
'http://www.racing-games.com/',
# Why: #2884 in Alexa global
'http://www.mommyfucktube.com/',
# Why: #2885 in Alexa global
'http://www.pideo.net/',
# Why: #2886 in Alexa global
'http://www.gogoanime.com/',
# Why: #2887 in Alexa global
'http://www.avaxho.me/',
# Why: #2888 in Alexa global
'http://www.christianmingle.com/',
# Why: #2889 in Alexa global
'http://www.activesearchresults.com/',
# Why: #2890 in Alexa global
'http://www.trendsonline.biz/',
# Why: #2891 in Alexa global
'http://www.planetsuzy.org/',
# Why: #2892 in Alexa global
'http://www.rubias19.com/',
# Why: #2893 in Alexa global
'http://www.cleverbridge.com/',
# Why: #2894 in Alexa global
'http://www.jeevansathi.com/',
# Why: #2895 in Alexa global
'http://www.washingtontimes.com/',
# Why: #2896 in Alexa global
'http://www.lcl.fr/',
# Why: #2897 in Alexa global
'http://www.98ia.com/',
# Why: #2899 in Alexa global
'http://www.mercadolibre.com.co/',
# Why: #2900 in Alexa global
'http://www.caijing.com.cn/',
# Why: #2902 in Alexa global
'http://www.n-tv.de/',
# Why: #2903 in Alexa global
'http://www.divyabhaskar.co.in/',
# Why: #2905 in Alexa global
'http://www.airbnb.com/',
# Why: #2907 in Alexa global
'http://www.mybrowserbar.com/',
# Why: #2908 in Alexa global
'http://www.travian.com/',
# Why: #2909 in Alexa global
'http://www.autoblog.com/',
# Why: #2910 in Alexa global
'http://www.blesk.cz/',
# Why: #2911 in Alexa global
'http://www.playboy.com/',
# Why: #2912 in Alexa global
'http://www.p30download.com/',
# Why: #2913 in Alexa global
'http://www.pazienti.net/',
# Why: #2914 in Alexa global
'http://www.uast.ac.ir/',
# Why: #2915 in Alexa global
'http://www.logsoku.com/',
# Why: #2916 in Alexa global
'http://www.zedge.net/',
# Why: #2917 in Alexa global
'http://www.creditmutuel.fr/',
# Why: #2918 in Alexa global
'http://www.absa.co.za/',
# Why: #2919 in Alexa global
'http://www.milliyet.tv/',
# Why: #2920 in Alexa global
'http://www.jiathis.com/',
# Why: #2921 in Alexa global
'http://www.liverpoolfc.tv/',
# Why: #2922 in Alexa global
'http://www.104.com.tw/',
# Why: #2923 in Alexa global
'http://www.dospy.com/',
# Why: #2924 in Alexa global
'http://www.ems.com.cn/',
# Why: #2925 in Alexa global
'http://www.calameo.com/',
# Why: #2926 in Alexa global
'http://www.netsuite.com/',
# Why: #2927 in Alexa global
'http://www.angelfire.com/',
# Why: #2929 in Alexa global
'http://www.snagajob.com/',
# Why: #2930 in Alexa global
'http://www.hollywoodlife.com/',
# Why: #2931 in Alexa global
'http://www.techtudo.com.br/',
# Why: #2932 in Alexa global
'http://www.payserve.com/',
# Why: #2933 in Alexa global
'http://www.portalnet.cl/',
# Why: #2934 in Alexa global
'http://www.worldadult-videos.info/',
# Why: #2935 in Alexa global
'http://www.indianpornvideos.com/',
# Why: #2936 in Alexa global
'http://www.france24.com/',
# Why: #2937 in Alexa global
'http://www.discuss.com.hk/',
# Why: #2938 in Alexa global
'http://www.theplanet.com/',
# Why: #2939 in Alexa global
'http://www.advego.ru/',
# Why: #2940 in Alexa global
'http://www.dion.ne.jp/',
# Why: #2941 in Alexa global
'http://starbaby.cn/',
# Why: #2942 in Alexa global
'http://www.eltiempo.es/',
# Why: #2943 in Alexa global
'http://www.55tuan.com/',
# Why: #2944 in Alexa global
'http://www.snopes.com/',
# Why: #2945 in Alexa global
'http://www.startnow.com/',
# Why: #2946 in Alexa global
'http://www.tucarro.com/',
# Why: #2947 in Alexa global
'http://www.skyscanner.net/',
# Why: #2948 in Alexa global
'http://www.wchonline.com/',
# Why: #2949 in Alexa global
'http://www.gaadi.com/',
# Why: #2950 in Alexa global
'http://www.lindaikeji.blogspot.com/',
# Why: #2952 in Alexa global
'http://www.keywordblocks.com/',
# Why: #2953 in Alexa global
'http://www.apsense.com/',
# Why: #2954 in Alexa global
'http://www.avangate.com/',
# Why: #2955 in Alexa global
'http://www.gandul.info/',
# Why: #2956 in Alexa global
'http://www.google.com.gh/',
# Why: #2957 in Alexa global
'http://www.mybigcommerce.com/',
# Why: #2958 in Alexa global
'http://www.homeaway.com/',
# Why: #2959 in Alexa global
'http://www.wikitravel.org/',
# Why: #2960 in Alexa global
'http://www.etxt.ru/',
# Why: #2961 in Alexa global
'http://www.zerx.ru/',
# Why: #2962 in Alexa global
'http://www.sidereel.com/',
# Why: #2963 in Alexa global
'http://www.edreams.es/',
# Why: #2964 in Alexa global
'http://www.india-forums.com/',
# Why: #2966 in Alexa global
'http://www.infonews.com/',
# Why: #2967 in Alexa global
'http://www.zoominfo.com/',
# Why: #2968 in Alexa global
'http://www.stylebistro.com/',
# Why: #2969 in Alexa global
'http://www.dominos.com/',
# Why: #2970 in Alexa global
'http://591hx.com/',
# Why: #2971 in Alexa global
'http://www.authorize.net/',
# Why: #2972 in Alexa global
'http://www.61baobao.com/',
# Why: #2973 in Alexa global
'http://www.digitalspy.co.uk/',
# Why: #2974 in Alexa global
'http://www.godvine.com/',
# Why: #2975 in Alexa global
'http://www.rednowtube.com/',
# Why: #2976 in Alexa global
'http://www.sony.jp/',
# Why: #2977 in Alexa global
'http://www.appbank.net/',
# Why: #2978 in Alexa global
'http://www.woozgo.fr/',
# Why: #2979 in Alexa global
'http://www.expireddomains.net/',
# Why: #2980 in Alexa global
'http://www.my-uq.com/',
# Why: #2981 in Alexa global
'http://www.peliculasyonkis.com/',
# Why: #2982 in Alexa global
'http://www.forumfree.it/',
# Why: #2983 in Alexa global
'http://www.shangdu.com/',
# Why: #2984 in Alexa global
'http://www.startmyripple.com/',
# Why: #2985 in Alexa global
'http://www.hottube.me/',
# Why: #2986 in Alexa global
'http://www.members.webs.com/',
# Why: #2987 in Alexa global
'http://www.blick.ch/',
# Why: #2988 in Alexa global
'http://www.google.cm/',
# Why: #2989 in Alexa global
'http://iautos.cn/',
# Why: #2990 in Alexa global
'http://www.tomtom.com/',
# Why: #2992 in Alexa global
'http://www.rzd.ru/',
# Why: #2993 in Alexa global
'http://www.opensooq.com/',
# Why: #2995 in Alexa global
'http://www.pizzahut.com/',
# Why: #2996 in Alexa global
'http://www.marksandspencer.com/',
# Why: #2997 in Alexa global
'http://www.filenuke.com/',
# Why: #2998 in Alexa global
'http://www.filelist.ro/',
# Why: #2999 in Alexa global
'http://www.akharinnews.com/',
# Why: #3000 in Alexa global
'http://www.etrade.com/',
# Why: #3002 in Alexa global
'http://www.planetromeo.com/',
# Why: #3003 in Alexa global
'http://www.wpbeginner.com/',
# Why: #3004 in Alexa global
'http://www.bancomercantil.com/',
# Why: #3005 in Alexa global
'http://www.pastdate.com/',
# Why: #3006 in Alexa global
'http://www.webutation.net/',
# Why: #3007 in Alexa global
'http://www.mywebgrocer.com/',
# Why: #3008 in Alexa global
'http://www.mobile.ir/',
# Why: #3009 in Alexa global
'http://www.seemorgh.com/',
# Why: #3010 in Alexa global
'http://www.nhs.uk/',
# Why: #3011 in Alexa global
'http://www.google.ba/',
# Why: #3012 in Alexa global
'http://ileehoo.com/',
# Why: #3013 in Alexa global
'http://www.seobook.com/',
# Why: #3014 in Alexa global
'http://www.wetteronline.de/',
# Why: #3015 in Alexa global
'http://www.happy-porn.com/',
# Why: #3016 in Alexa global
'http://www.theonion.com/',
# Why: #3017 in Alexa global
'http://www.webnode.com/',
# Why: #3018 in Alexa global
'http://www.svaiza.com/',
# Why: #3019 in Alexa global
'http://www.newsbomb.gr/',
# Why: #3020 in Alexa global
'http://www.t88u.com/',
# Why: #3021 in Alexa global
'http://www.tsn.ca/',
# Why: #3022 in Alexa global
'http://www.unity3d.com/',
# Why: #3023 in Alexa global
'http://www.nseindia.com/',
# Why: #3024 in Alexa global
'http://www.juegosdiarios.com/',
# Why: #3025 in Alexa global
'http://www.genieo.com/',
# Why: #3026 in Alexa global
'http://www.kelkoo.com/',
# Why: #3027 in Alexa global
'http://gome.com.cn/',
# Why: #3028 in Alexa global
'http://www.shabdkosh.com/',
# Why: #3029 in Alexa global
'http://www.tecmundo.com.br/',
# Why: #3030 in Alexa global
'http://www.chinaunix.net/',
# Why: #3031 in Alexa global
'http://pchouse.com.cn/',
# Why: #3032 in Alexa global
'http://www.goo-net.com/',
# Why: #3033 in Alexa global
'http://www.asana.com/',
# Why: #3035 in Alexa global
'http://www.hdporn.in/',
# Why: #3036 in Alexa global
'http://www.bannersbroker.com/user/adpubcombo_dashboard/',
# Why: #3037 in Alexa global
'http://www.virtapay.com/',
# Why: #3038 in Alexa global
'http://www.jobdiagnosis.com/',
# Why: #3039 in Alexa global
'http://guokr.com/',
# Why: #3040 in Alexa global
'http://www.clickpoint.it/',
# Why: #3041 in Alexa global
'http://3dmgame.com/',
# Why: #3042 in Alexa global
'http://www.ashleymadison.com/',
# Why: #3043 in Alexa global
'http://www.utsprofitads.com/',
# Why: #3044 in Alexa global
'http://www.google.ee/',
# Why: #3045 in Alexa global
'http://www.365jia.cn/',
# Why: #3046 in Alexa global
'http://www.oyunskor.com/',
# Why: #3047 in Alexa global
'http://www.metro.co.uk/',
# Why: #3048 in Alexa global
'http://www.ebaumsworld.com/',
# Why: #3049 in Alexa global
'http://www.realsimple.com/',
# Why: #3050 in Alexa global
'http://www.3file.info/',
# Why: #3051 in Alexa global
'http://www.xcams.com/',
# Why: #3052 in Alexa global
'http://www.cyberforum.ru/',
# Why: #3053 in Alexa global
'http://www.babble.com/',
# Why: #3054 in Alexa global
'http://www.lidl.de/',
# Why: #3055 in Alexa global
'http://www.pixer.mobi/',
# Why: #3056 in Alexa global
'http://www.yell.com/',
# Why: #3057 in Alexa global
'http://www.alnilin.com/',
# Why: #3058 in Alexa global
'http://www.lurkmore.to/',
# Why: #3059 in Alexa global
'http://www.olx.co.za/',
# Why: #3060 in Alexa global
'http://www.eorezo.com/',
# Why: #3061 in Alexa global
'http://www.baby.ru/',
# Why: #3062 in Alexa global
'http://www.xdf.cn/',
# Why: #3063 in Alexa global
'http://www.redporntube.com/',
# Why: #3064 in Alexa global
'http://www.extabit.com/',
# Why: #3065 in Alexa global
'http://www.wayn.com/',
# Why: #3066 in Alexa global
'http://www.gaana.com/',
# Why: #3067 in Alexa global
'http://www.islamicfinder.org/',
# Why: #3068 in Alexa global
'http://www.venturebeat.com/',
# Why: #3069 in Alexa global
'http://www.played.to/',
# Why: #3070 in Alexa global
'http://www.alrakoba.net/',
# Why: #3071 in Alexa global
'http://www.mouthshut.com/',
# Why: #3072 in Alexa global
'http://www.banquepopulaire.fr/',
# Why: #3073 in Alexa global
'http://www.jal.co.jp/',
# Why: #3074 in Alexa global
'http://www.dasoertliche.de/',
# Why: #3075 in Alexa global
'http://www.1stwebdesigner.com/',
# Why: #3076 in Alexa global
'http://www.tam.com.br/',
# Why: #3077 in Alexa global
'http://www.nature.com/',
# Why: #3078 in Alexa global
'http://www.camfrog.com/',
# Why: #3079 in Alexa global
'http://www.philly.com/',
# Why: #3080 in Alexa global
'http://www.zemtv.com/',
# Why: #3081 in Alexa global
'http://www.oprah.com/',
# Why: #3082 in Alexa global
'http://www.wmaraci.com/',
# Why: #3083 in Alexa global
'http://www.ruvr.ru/',
# Why: #3084 in Alexa global
'http://www.gsn.com/',
# Why: #3085 in Alexa global
'http://www.acrobat.com/',
# Why: #3086 in Alexa global
'http://www.depositfiles.org/',
# Why: #3087 in Alexa global
'http://www.smartresponder.ru/',
# Why: #3088 in Alexa global
'http://www.huxiu.com/',
# Why: #3089 in Alexa global
'http://www.porn-wanted.com/',
# Why: #3090 in Alexa global
'http://www.tripadvisor.fr/',
# Why: #3091 in Alexa global
'http://3366.com/',
# Why: #3092 in Alexa global
'http://www.ranker.com/',
# Why: #3093 in Alexa global
'http://www.cibc.com/',
# Why: #3094 in Alexa global
'http://www.trend.az/',
# Why: #3095 in Alexa global
'http://www.whatsapp.com/',
# Why: #3096 in Alexa global
'http://07073.com/',
# Why: #3097 in Alexa global
'http://www.netload.in/',
# Why: #3098 in Alexa global
'http://www.channel4.com/',
# Why: #3099 in Alexa global
'http://www.yatra.com/',
# Why: #3100 in Alexa global
'http://www.elconfidencial.com/',
# Why: #3101 in Alexa global
'http://www.labnol.org/',
# Why: #3102 in Alexa global
'http://www.google.co.ke/',
# Why: #3103 in Alexa global
'http://www.disneylatino.com/',
# Why: #3104 in Alexa global
'http://www.pconverter.com/',
# Why: #3105 in Alexa global
'http://www.cqnews.net/',
# Why: #3106 in Alexa global
'http://www.blog.co.uk/',
# Why: #3107 in Alexa global
'http://www.immowelt.de/',
# Why: #3108 in Alexa global
'http://www.crunchyroll.com/',
# Why: #3109 in Alexa global
'http://www.gamesgames.com/',
# Why: #3110 in Alexa global
'http://www.protothema.gr/',
# Why: #3111 in Alexa global
'http://www.vmoptions.com/',
# Why: #3112 in Alexa global
'http://www.go2jump.org/',
# Why: #3113 in Alexa global
'http://www.psu.edu/',
# Why: #3114 in Alexa global
'http://www.sanjesh.org/',
# Why: #3115 in Alexa global
'http://www.sportingnews.com/',
# Why: #3116 in Alexa global
'http://www.televisionfanatic.com/',
# Why: #3117 in Alexa global
'http://www.fansshare.com/',
# Why: #3118 in Alexa global
'http://www.xcams4u.com/',
# Why: #3119 in Alexa global
'http://www.dict.cn/',
# Why: #3120 in Alexa global
'http://www.madthumbs.com/',
# Why: #3121 in Alexa global
'http://www.ebates.com/',
# Why: #3122 in Alexa global
'http://www.eromon.net/',
# Why: #3123 in Alexa global
'http://www.copyblogger.com/',
# Why: #3124 in Alexa global
'http://www.flirt4free.com/',
# Why: #3125 in Alexa global
'http://www.gaytube.com/',
# Why: #3126 in Alexa global
'http://www.notdoppler.com/',
# Why: #3127 in Alexa global
'http://www.allmyvideos.net/',
# Why: #3128 in Alexa global
'http://www.cam4.de.com/',
# Why: #3129 in Alexa global
'http://www.chosun.com/',
# Why: #3130 in Alexa global
'http://www.adme.ru/',
# Why: #3131 in Alexa global
'http://www.codeplex.com/',
# Why: #3132 in Alexa global
'http://www.jumia.com.ng/',
# Why: #3133 in Alexa global
'http://www.digitaltrends.com/',
# Why: #3134 in Alexa global
'http://www.b92.net/',
# Why: #3135 in Alexa global
'http://www.miniinthebox.com/',
# Why: #3136 in Alexa global
'http://www.radaronline.com/',
# Why: #3137 in Alexa global
'http://www.hujiang.com/',
# Why: #3138 in Alexa global
'http://www.gardenweb.com/',
# Why: #3139 in Alexa global
'http://www.pizap.com/',
# Why: #3140 in Alexa global
'http://www.iptorrents.com/',
# Why: #3141 in Alexa global
'http://www.yuku.com/',
# Why: #3142 in Alexa global
'http://www.mega-giochi.it/',
# Why: #3143 in Alexa global
'http://www.nrk.no/',
# Why: #3144 in Alexa global
'http://www.99designs.com/',
# Why: #3145 in Alexa global
'http://www.uscis.gov/',
# Why: #3146 in Alexa global
'http://www.lostfilm.tv/',
# Why: #3147 in Alexa global
'http://www.mileroticos.com/',
# Why: #3148 in Alexa global
'http://www.republika.co.id/',
# Why: #3149 in Alexa global
'http://www.sharethis.com/',
# Why: #3150 in Alexa global
'http://www.samplicio.us/',
# Why: #3151 in Alexa global
'http://www.1saleaday.com/',
# Why: #3152 in Alexa global
'http://www.vonelo.com/',
# Why: #3153 in Alexa global
'http://www.oyunmoyun.com/',
# Why: #3154 in Alexa global
'http://www.flightradar24.com/',
# Why: #3155 in Alexa global
'http://www.geo.tv/',
# Why: #3156 in Alexa global
'http://www.nexusmods.com/',
# Why: #3157 in Alexa global
'http://www.mizuhobank.co.jp/',
# Why: #3158 in Alexa global
'http://www.blogspot.fi/',
# Why: #3159 in Alexa global
'http://www.directtrack.com/',
# Why: #3160 in Alexa global
'http://www.media.net/',
# Why: #3161 in Alexa global
'http://www.bigresource.com/',
# Why: #3162 in Alexa global
'http://www.free-lance.ru/',
# Why: #3163 in Alexa global
'http://www.loveplanet.ru/',
# Why: #3164 in Alexa global
'http://www.ilfattoquotidiano.it/',
# Why: #3165 in Alexa global
'http://www.coolmovs.com/',
# Why: #3166 in Alexa global
'http://www.mango.com/',
# Why: #3167 in Alexa global
'http://www.nj.com/',
# Why: #3168 in Alexa global
'http://www.magazineluiza.com.br/',
# Why: #3169 in Alexa global
'http://www.datehookup.com/',
# Why: #3170 in Alexa global
'http://www.registro.br/',
# Why: #3171 in Alexa global
'http://www.debenhams.com/',
# Why: #3172 in Alexa global
'http://www.jqueryui.com/',
# Why: #3173 in Alexa global
'http://www.palcomp3.com/',
# Why: #3174 in Alexa global
'http://www.opensubtitles.org/',
# Why: #3175 in Alexa global
'http://www.socialmediatoday.com/',
# Why: #3176 in Alexa global
'http://3158.cn/',
# Why: #3178 in Alexa global
'http://www.allgameshome.com/',
# Why: #3179 in Alexa global
'http://www.pricegrabber.com/',
# Why: #3180 in Alexa global
'http://www.lufthansa.com/',
# Why: #3181 in Alexa global
'http://www.ip-adress.com/',
# Why: #3182 in Alexa global
'http://www.business-standard.com/',
# Why: #3183 in Alexa global
'http://www.games.com/',
# Why: #3184 in Alexa global
'http://www.zaman.com.tr/',
# Why: #3185 in Alexa global
'http://www.jagranjosh.com/',
# Why: #3186 in Alexa global
'http://www.mint.com/',
# Why: #3187 in Alexa global
'http://www.gorillavid.in/',
# Why: #3188 in Alexa global
'http://www.google.com.om/',
# Why: #3189 in Alexa global
'http://www.blogbigtime.com/',
# Why: #3190 in Alexa global
'http://www.books.com.tw/',
# Why: #3191 in Alexa global
'http://www.korrespondent.net/',
# Why: #3192 in Alexa global
'http://www.nymag.com/',
# Why: #3193 in Alexa global
'http://www.proporn.com/',
# Why: #3194 in Alexa global
'http://ycasmd.info/',
# Why: #3195 in Alexa global
'http://www.persiantools.com/',
# Why: #3196 in Alexa global
'http://www.torrenthound.com/',
# Why: #3197 in Alexa global
'http://www.bestsexo.com/',
# Why: #3198 in Alexa global
'http://www.alwatanvoice.com/',
# Why: #3199 in Alexa global
'http://www.jahannews.com/',
# Why: #3200 in Alexa global
'http://www.bluewin.ch/',
# Why: #3201 in Alexa global
'http://www.sap.com/',
# Why: #3203 in Alexa global
'http://www.rzb.ir/',
# Why: #3204 in Alexa global
'http://www.myorderbox.com/',
# Why: #3205 in Alexa global
'http://www.dealsandsavings.net/',
# Why: #3206 in Alexa global
'http://www.goldenline.pl/',
# Why: #3207 in Alexa global
'http://www.stuff.co.nz/',
# Why: #3208 in Alexa global
'http://www.opentable.com/',
# Why: #3209 in Alexa global
'http://www.4738.com/',
# Why: #3210 in Alexa global
'http://www.freshersworld.com/',
# Why: #3211 in Alexa global
'http://www.state.pa.us/',
# Why: #3212 in Alexa global
'http://www.lavanguardia.com/',
# Why: #3213 in Alexa global
'http://www.sudu.cn/',
# Why: #3214 in Alexa global
'http://www.mob.org/',
# Why: #3215 in Alexa global
'http://www.vodafone.in/',
# Why: #3216 in Alexa global
'http://www.blogdetik.com/',
# Why: #3217 in Alexa global
'http://www.888.it/',
# Why: #3218 in Alexa global
'http://www.passportindia.gov.in/',
# Why: #3219 in Alexa global
'http://www.ssa.gov/',
# Why: #3220 in Alexa global
'http://www.desitvforum.net/',
# Why: #3221 in Alexa global
'http://www.8684.cn/',
# Why: #3222 in Alexa global
'http://www.rajasthan.gov.in/',
# Why: #3223 in Alexa global
'http://www.youtube.com/user/PewDiePie/',
# Why: #3224 in Alexa global
'http://www.zonealarm.com/',
# Why: #3225 in Alexa global
'http://www.locaweb.com.br/',
# Why: #3226 in Alexa global
'http://logme.in/',
# Why: #3227 in Alexa global
'http://www.fetlife.com/',
# Why: #3228 in Alexa global
'http://www.lyricsfreak.com/',
# Why: #3229 in Alexa global
'http://www.te3p.com/',
# Why: #3230 in Alexa global
'http://www.hmrc.gov.uk/',
# Why: #3231 in Alexa global
'http://www.bravoerotica.com/',
# Why: #3232 in Alexa global
'http://www.kolesa.kz/',
# Why: #3233 in Alexa global
'http://www.vinescope.com/',
# Why: #3234 in Alexa global
'http://www.shoplocal.com/',
# Why: #3236 in Alexa global
'http://b2b.cn/',
# Why: #3237 in Alexa global
'http://www.mydrivers.com/',
# Why: #3238 in Alexa global
'http://www.xhamster.com/user/video/',
# Why: #3239 in Alexa global
'http://www.bigideamastermind.com/',
# Why: #3240 in Alexa global
'http://www.uncoverthenet.com/',
# Why: #3241 in Alexa global
'http://www.ragecomic.com/',
# Why: #3242 in Alexa global
'http://www.yodobashi.com/',
# Why: #3243 in Alexa global
'http://titan24.com/',
# Why: #3244 in Alexa global
'http://www.nocoty.pl/',
# Why: #3245 in Alexa global
'http://www.turkishairlines.com/',
# Why: #3246 in Alexa global
'http://www.liputan6.com/',
# Why: #3247 in Alexa global
'http://www.3suisses.fr/',
# Why: #3248 in Alexa global
'http://www.cancan.ro/',
# Why: #3249 in Alexa global
'http://www.apetube.com/',
# Why: #3250 in Alexa global
'http://www.kurir-info.rs/',
# Why: #3251 in Alexa global
'http://www.wow.com/',
# Why: #3252 in Alexa global
'http://www.myblogguest.com/',
# Why: #3253 in Alexa global
'http://www.wp.com/',
# Why: #3254 in Alexa global
'http://www.tre.it/',
# Why: #3255 in Alexa global
'http://www.livrariasaraiva.com.br/',
# Why: #3256 in Alexa global
'http://www.ubuntuforums.org/',
# Why: #3257 in Alexa global
'http://www.fujitv.co.jp/',
# Why: #3258 in Alexa global
'http://www.serverfault.com/',
# Why: #3259 in Alexa global
'http://www.princeton.edu/',
# Why: #3260 in Alexa global
'http://www.experienceproject.com/',
# Why: #3261 in Alexa global
'http://www.ero-video.net/',
# Why: #3262 in Alexa global
'http://www.west263.com/',
# Why: #3263 in Alexa global
'http://www.nguoiduatin.vn/',
# Why: #3264 in Alexa global
'http://www.findthebest.com/',
# Why: #3265 in Alexa global
'http://www.iol.pt/',
# Why: #3266 in Alexa global
'http://www.hotukdeals.com/',
# Why: #3267 in Alexa global
'http://www.filmifullizle.com/',
# Why: #3268 in Alexa global
'http://www.blog.hu/',
# Why: #3269 in Alexa global
'http://www.dailyfinance.com/',
# Why: #3270 in Alexa global
'http://www.bigxvideos.com/',
# Why: #3271 in Alexa global
'http://www.adreactor.com/',
# Why: #3272 in Alexa global
'http://www.fmworld.net/',
# Why: #3273 in Alexa global
'http://www.fumu.com/',
# Why: #3274 in Alexa global
'http://www.ntv.ru/',
# Why: #3275 in Alexa global
'http://www.poringa.net/',
# Why: #3276 in Alexa global
'http://www.syosetu.com/',
# Why: #3277 in Alexa global
'http://www.giantsextube.com/',
# Why: #3278 in Alexa global
'http://www.uuu9.com/',
# Why: #3279 in Alexa global
'http://www.babosas.com/',
# Why: #3280 in Alexa global
'http://www.square-enix.com/',
# Why: #3281 in Alexa global
'http://www.bankia.es/',
# Why: #3282 in Alexa global
'http://www.freedownloadmanager.org/',
# Why: #3283 in Alexa global
'http://www.add-anime.net/',
# Why: #3284 in Alexa global
'http://www.tuttomercatoweb.com/',
# Why: #3285 in Alexa global
'http://www.192.com/',
# Why: #3286 in Alexa global
'http://www.freekaamaal.com/',
# Why: #3287 in Alexa global
'http://www.youngpornvideos.com/',
# Why: #3288 in Alexa global
'http://www.nbc.com/',
# Why: #3289 in Alexa global
'http://www.jne.co.id/',
# Why: #3290 in Alexa global
'http://www.fobshanghai.com/',
# Why: #3291 in Alexa global
'http://www.johnlewis.com/',
# Why: #3292 in Alexa global
'http://www.mvideo.ru/',
# Why: #3293 in Alexa global
'http://www.bhinneka.com/',
# Why: #3294 in Alexa global
'http://www.gooddrama.net/',
# Why: #3295 in Alexa global
'http://www.lobstertube.com/',
# Why: #3296 in Alexa global
'http://www.ovguide.com/',
# Why: #3297 in Alexa global
'http://www.joemonster.org/',
# Why: #3298 in Alexa global
'http://editor.wix.com/',
# Why: #3299 in Alexa global
'http://www.wechat.com/',
# Why: #3300 in Alexa global
'http://www.locanto.in/',
# Why: #3301 in Alexa global
'http://www.video2mp3.net/',
# Why: #3303 in Alexa global
'http://www.couchsurfing.org/',
# Why: #3304 in Alexa global
'http://www.tchibo.de/',
# Why: #3305 in Alexa global
'http://rol.ro/',
# Why: #3306 in Alexa global
'http://www.toroporno.com/',
# Why: #3307 in Alexa global
'http://www.backlinkwatch.com/',
# Why: #3308 in Alexa global
'http://www.greatergood.com/',
# Why: #3309 in Alexa global
'http://www.smartaddressbar.com/',
# Why: #3310 in Alexa global
'http://www.getgoodlinks.ru/',
# Why: #3311 in Alexa global
'http://www.fitbit.com/',
# Why: #3312 in Alexa global
'http://www.elcorteingles.es/',
# Why: #3313 in Alexa global
'http://www.up2c.com/',
# Why: #3314 in Alexa global
'http://www.rg.ru/',
# Why: #3315 in Alexa global
'http://www.ftalk.com/',
# Why: #3316 in Alexa global
'http://www.apartmenttherapy.com/',
# Why: #3317 in Alexa global
'http://www.blogspot.hu/',
# Why: #3318 in Alexa global
'http://www.e-rewards.com/',
# Why: #3319 in Alexa global
'http://weloveshopping.com/',
# Why: #3320 in Alexa global
'http://www.swtor.com/',
# Why: #3321 in Alexa global
'http://www.abs-cbnnews.com/',
# Why: #3322 in Alexa global
'http://www.webpagetest.org/',
# Why: #3323 in Alexa global
'http://www.ricardo.ch/',
# Why: #3324 in Alexa global
'http://www.ghatreh.com/',
# Why: #3325 in Alexa global
'http://www.ibps.in/',
# Why: #3326 in Alexa global
'http://www.moneymakergroup.com/',
# Why: #3327 in Alexa global
'http://www.exist.ru/',
# Why: #3328 in Alexa global
'http://www.kakprosto.ru/',
# Why: #3329 in Alexa global
'http://www.gradeuptube.com/',
# Why: #3330 in Alexa global
'http://lastampa.it/',
# Why: #3331 in Alexa global
'http://www.medicinenet.com/',
# Why: #3332 in Alexa global
'http://www.theknot.com/',
# Why: #3333 in Alexa global
'http://www.yale.edu/',
# Why: #3334 in Alexa global
'http://www.mail.uol.com.br/',
# Why: #3335 in Alexa global
'http://www.okazii.ro/',
# Why: #3336 in Alexa global
'http://www.wa.gov/',
# Why: #3337 in Alexa global
'http://www.gmhuowan.com/',
# Why: #3338 in Alexa global
'http://www.cnhubei.com/',
# Why: #3339 in Alexa global
'http://www.dickssportinggoods.com/',
# Why: #3340 in Alexa global
'http://instaforex.com/',
# Why: #3341 in Alexa global
'http://www.zdf.de/',
# Why: #3342 in Alexa global
'http://www.getpocket.com/',
# Why: #3343 in Alexa global
'http://www.takungpao.com/',
# Why: #3344 in Alexa global
'http://www.junkmail.co.za/',
# Why: #3345 in Alexa global
'http://www.tripwiremagazine.com/',
# Why: #3346 in Alexa global
'http://www.popcap.com/',
# Why: #3347 in Alexa global
'http://www.kotobank.jp/',
# Why: #3348 in Alexa global
'http://www.bangbros.com/',
# Why: #3349 in Alexa global
'http://www.shtyle.fm/',
# Why: #3350 in Alexa global
'http://www.jungle.gr/',
# Why: #3351 in Alexa global
'http://www.apserver.net/',
# Why: #3352 in Alexa global
'http://www.mzamin.com/',
# Why: #3353 in Alexa global
'http://www.google.lu/',
# Why: #3354 in Alexa global
'http://www.squarebux.com/',
# Why: #3355 in Alexa global
'http://www.bollywoodhungama.com/',
# Why: #3356 in Alexa global
'http://www.milfmovs.com/',
# Why: #3357 in Alexa global
'http://www.softonic.it/',
# Why: #3358 in Alexa global
'http://www.hsw.cn/',
# Why: #3359 in Alexa global
'http://www.cyberciti.biz/',
# Why: #3360 in Alexa global
'http://www.scout.com/',
# Why: #3361 in Alexa global
'http://www.teensnow.com/',
# Why: #3362 in Alexa global
'http://www.pornper.com/',
# Why: #3363 in Alexa global
'http://www.torrentreactor.net/',
# Why: #3364 in Alexa global
'http://www.smotri.com/',
# Why: #3365 in Alexa global
'http://www.startpage.com/',
# Why: #3366 in Alexa global
'http://www.climatempo.com.br/',
# Why: #3367 in Alexa global
'http://www.bigrock.in/',
# Why: #3368 in Alexa global
'http://www.kajabi.com/',
# Why: #3369 in Alexa global
'http://www.imgchili.com/',
# Why: #3370 in Alexa global
'http://www.dogpile.com/',
# Why: #3371 in Alexa global
'http://www.thestreet.com/',
# Why: #3372 in Alexa global
'http://www.sport24.gr/',
# Why: #3373 in Alexa global
'http://www.tophotels.ru/',
# Why: #3374 in Alexa global
'http://www.shopping.uol.com.br/',
# Why: #3375 in Alexa global
'http://www.bbva.es/',
# Why: #3376 in Alexa global
'http://www.perfectmoney.com/',
# Why: #3377 in Alexa global
'http://www.cashmachines2.com/',
# Why: #3378 in Alexa global
'http://www.skroutz.gr/',
# Why: #3379 in Alexa global
'http://www.logitech.com/',
# Why: #3380 in Alexa global
'http://www.seriescoco.com/',
# Why: #3381 in Alexa global
'http://www.fastclick.com/',
# Why: #3382 in Alexa global
'http://www.cambridge.org/',
# Why: #3383 in Alexa global
'http://www.fark.com/',
# Why: #3384 in Alexa global
'http://www.krypt.com/',
# Why: #3385 in Alexa global
'http://www.indiangilma.com/',
# Why: #3386 in Alexa global
'http://www.safe-swaps.com/',
# Why: #3387 in Alexa global
'http://www.trenitalia.com/',
# Why: #3388 in Alexa global
'http://www.flycell.com.mx/',
# Why: #3389 in Alexa global
'http://www.livefreefun.com/',
# Why: #3390 in Alexa global
'http://www.ourtoolbar.com/',
# Why: #3391 in Alexa global
'http://www.anandtech.com/',
# Why: #3392 in Alexa global
'http://www.neimanmarcus.com/',
# Why: #3393 in Alexa global
'http://www.lelong.com.my/',
# Why: #3394 in Alexa global
'http://www.pulscen.ru/',
# Why: #3395 in Alexa global
'http://www.paginegialle.it/',
# Why: #3396 in Alexa global
'http://www.intelius.com/',
# Why: #3397 in Alexa global
'http://www.orange.pl/',
# Why: #3398 in Alexa global
'http://www.aktuality.sk/',
# Why: #3399 in Alexa global
'http://www.webgame.in.th/',
# Why: #3400 in Alexa global
'http://www.runescape.com/',
# Why: #3401 in Alexa global
'http://www.rocketnews24.com/',
# Why: #3402 in Alexa global
'http://www.lineadirecta.com/',
# Why: #3403 in Alexa global
'http://www.origin.com/',
# Why: #3404 in Alexa global
'http://www.newsbeast.gr/',
# Why: #3405 in Alexa global
'http://www.justhookup.com/',
# Why: #3406 in Alexa global
'http://www.rakuten-bank.co.jp/',
# Why: #3407 in Alexa global
'http://www.lifenews.ru/',
# Why: #3408 in Alexa global
'http://www.sitemeter.com/',
# Why: #3410 in Alexa global
'http://www.isbank.com.tr/',
# Why: #3411 in Alexa global
'http://www.commerzbanking.de/',
# Why: #3412 in Alexa global
'http://www.marthastewart.com/',
# Why: #3413 in Alexa global
'http://www.ntvmsnbc.com/',
# Why: #3414 in Alexa global
'http://www.seloger.com/',
# Why: #3415 in Alexa global
'http://www.vend-o.com/',
# Why: #3416 in Alexa global
'http://www.almanar.com.lb/',
# Why: #3417 in Alexa global
'http://www.sifyitest.com/',
# Why: #3418 in Alexa global
'http://taojindi.com/',
# Why: #3419 in Alexa global
'http://www.mylife.com/',
# Why: #3420 in Alexa global
'http://www.talkfusion.com/',
# Why: #3421 in Alexa global
'http://www.hichina.com/',
# Why: #3422 in Alexa global
'http://www.paruvendu.fr/',
# Why: #3423 in Alexa global
'http://www.admcsport.com/',
# Why: #3424 in Alexa global
'http://www.tudogostoso.uol.com.br/',
# Why: #3425 in Alexa global
'http://www.faz.net/',
# Why: #3426 in Alexa global
'http://www.narutoget.com/',
# Why: #3427 in Alexa global
'http://www.wufoo.com/',
# Why: #3428 in Alexa global
'http://www.feedads-srv.com/',
# Why: #3429 in Alexa global
'http://www.gophoto.it/',
# Why: #3430 in Alexa global
'http://www.tgju.org/',
# Why: #3431 in Alexa global
'http://www.dynamicdrive.com/',
# Why: #3432 in Alexa global
'http://www.centurylink.net/',
# Why: #3433 in Alexa global
'http://www.ngs.ru/',
# Why: #3434 in Alexa global
'http://anyap.info/',
# Why: #3435 in Alexa global
'http://www.dailykos.com/',
# Why: #3437 in Alexa global
'http://www.95559.com.cn/',
# Why: #3438 in Alexa global
'http://www.malaysiakini.com/',
# Why: #3439 in Alexa global
'http://www.uefa.com/',
# Why: #3440 in Alexa global
'http://www.socialmediaexaminer.com/',
# Why: #3441 in Alexa global
'http://www.empowernetwork.com/qokpPCiefhWcRT/',
# Why: #3442 in Alexa global
'http://www.peperonity.de/',
# Why: #3443 in Alexa global
'http://www.support.wordpress.com/',
# Why: #3444 in Alexa global
'http://www.hola.com/',
# Why: #3445 in Alexa global
'http://www.readmanga.eu/',
# Why: #3446 in Alexa global
'http://www.jstv.com/',
# Why: #3447 in Alexa global
'http://www.irib.ir/',
# Why: #3448 in Alexa global
'http://www.bookingbuddy.com/',
# Why: #3449 in Alexa global
'http://www.computerhope.com/',
# Why: #3450 in Alexa global
'http://www.ilovemobi.com/',
# Why: #3451 in Alexa global
'http://www.pinkrod.com/',
# Why: #3452 in Alexa global
'http://www.videobash.com/',
# Why: #3453 in Alexa global
'http://www.alfemminile.com/',
# Why: #3454 in Alexa global
'http://www.tu.tv/',
# Why: #3455 in Alexa global
'http://www.utro.ru/',
# Why: #3456 in Alexa global
'http://www.urbanoutfitters.com/',
# Why: #3457 in Alexa global
'http://www.autozone.com/',
# Why: #3458 in Alexa global
'http://www.gilt.com/',
# Why: #3459 in Alexa global
'http://www.atpworldtour.com/',
# Why: #3460 in Alexa global
'http://www.goibibo.com/',
# Why: #3461 in Alexa global
'http://www.propellerpops.com/',
# Why: #3462 in Alexa global
'http://www.cornell.edu/',
# Why: #3463 in Alexa global
'http://www.flashscore.com/',
# Why: #3464 in Alexa global
'http://www.babyblog.ru/',
# Why: #3465 in Alexa global
'http://www.sport-fm.gr/',
# Why: #3466 in Alexa global
'http://www.viamichelin.fr/',
# Why: #3467 in Alexa global
'http://www.newyorker.com/',
# Why: #3468 in Alexa global
'http://www.tagesschau.de/',
# Why: #3469 in Alexa global
'http://www.guiamais.com.br/',
# Why: #3470 in Alexa global
'http://www.jeux.fr/',
# Why: #3471 in Alexa global
'http://www.pontofrio.com.br/',
# Why: #3472 in Alexa global
'http://www.dm5.com/',
# Why: #3474 in Alexa global
'http://www.ss.lv/',
# Why: #3475 in Alexa global
'http://www.mirtesen.ru/',
# Why: #3476 in Alexa global
'http://www.money.pl/',
# Why: #3477 in Alexa global
'http://www.tlbsearch.com/',
# Why: #3478 in Alexa global
'http://www.usembassy.gov/',
# Why: #3479 in Alexa global
'http://www.cineblog01.net/',
# Why: #3480 in Alexa global
'http://www.nur.kz/',
# Why: #3481 in Alexa global
'http://www.hotnewhiphop.com/',
# Why: #3482 in Alexa global
'http://www.mp3sheriff.com/',
# Why: #3483 in Alexa global
'http://www.games.co.id/',
# Why: #3485 in Alexa global
'http://www.deviantclip.com/',
# Why: #3486 in Alexa global
'http://www.list.ru/',
# Why: #3487 in Alexa global
'http://www.xitek.com/',
# Why: #3488 in Alexa global
'http://www.netvibes.com/',
# Why: #3489 in Alexa global
'http://www.24sata.hr/',
# Why: #3490 in Alexa global
'http://www.usda.gov/',
# Why: #3491 in Alexa global
'http://www.zerofreeporn.com/',
# Why: #3492 in Alexa global
'http://www.tvb.com/',
# Why: #3493 in Alexa global
'http://www.decolar.com/',
# Why: #3494 in Alexa global
'http://www.worldfree4u.com/',
# Why: #3495 in Alexa global
'http://www.dzone.com/',
# Why: #3496 in Alexa global
'http://www.wikiquote.org/',
# Why: #3497 in Alexa global
'http://www.techtunes.com.bd/',
# Why: #3498 in Alexa global
'http://www.pornup.me/',
# Why: #3499 in Alexa global
'http://www.blogutils.net/',
# Why: #3500 in Alexa global
'http://www.yupoo.com/',
# Why: #3501 in Alexa global
'http://www.peoplesmart.com/',
# Why: #3502 in Alexa global
'http://www.kijiji.it/',
# Why: #3503 in Alexa global
'http://usairways.com/',
# Why: #3504 in Alexa global
'http://www.betfred.com/',
# Why: #3505 in Alexa global
'http://www.ow.ly/',
# Why: #3506 in Alexa global
'http://www.nsw.gov.au/',
# Why: #3507 in Alexa global
'http://www.mci.ir/',
# Why: #3508 in Alexa global
'http://www.iranecar.com/',
# Why: #3509 in Alexa global
'http://www.wisegeek.com/',
# Why: #3510 in Alexa global
'http://www.gocomics.com/',
# Why: #3511 in Alexa global
'http://www.bramjnet.com/',
# Why: #3512 in Alexa global
'http://www.bit.ly/',
# Why: #3514 in Alexa global
'http://www.timesofindia.com/',
# Why: #3515 in Alexa global
'http://www.xingcloud.com/',
# Why: #3516 in Alexa global
'http://www.geocities.co.jp/',
# Why: #3517 in Alexa global
'http://www.tfl.gov.uk/',
# Why: #3518 in Alexa global
'http://www.derstandard.at/',
# Why: #3519 in Alexa global
'http://www.icq.com/',
# Why: #3520 in Alexa global
'http://www.orange.co.uk/',
# Why: #3521 in Alexa global
'http://www.pornokopilka.info/',
# Why: #3522 in Alexa global
'http://www.88db.com/',
# Why: #3524 in Alexa global
'http://www.house365.com/',
# Why: #3525 in Alexa global
'http://www.collegehumor.com/',
# Why: #3526 in Alexa global
'http://www.gfxtra.com/',
# Why: #3527 in Alexa global
'http://www.borsapernegati.com/',
# Why: #3528 in Alexa global
'http://pensador.uol.com.br/',
# Why: #3529 in Alexa global
'http://www.surveygifters.com/',
# Why: #3531 in Alexa global
'http://bmail.uol.com.br/',
# Why: #3532 in Alexa global
'http://www.ec21.com/',
# Why: #3533 in Alexa global
'http://www.seoprofiler.com/',
# Why: #3534 in Alexa global
'http://www.goldporntube.com/',
# Why: #3535 in Alexa global
'http://www.tvtropes.org/',
# Why: #3536 in Alexa global
'http://www.techtarget.com/',
# Why: #3537 in Alexa global
'http://www.juno.com/',
# Why: #3538 in Alexa global
'http://www.visual.ly/',
# Why: #3539 in Alexa global
'http://www.dardarkom.com/',
# Why: #3540 in Alexa global
'http://www.showup.tv/',
# Why: #3541 in Alexa global
'http://www.three.co.uk/',
# Why: #3543 in Alexa global
'http://www.shopstyle.com/',
# Why: #3544 in Alexa global
'http://www.penguinvids.com/',
# Why: #3545 in Alexa global
'http://www.trainenquiry.com/',
# Why: #3546 in Alexa global
'http://www.soha.vn/',
# Why: #3547 in Alexa global
'http://www.fengniao.com/',
# Why: #3548 in Alexa global
'http://carschina.com/',
# Why: #3549 in Alexa global
'http://www.500wan.com/',
# Why: #3550 in Alexa global
'http://www.perfectinter.net/',
# Why: #3551 in Alexa global
'http://www.elog-ch.com/',
# Why: #3552 in Alexa global
'http://www.thetoptens.com/',
# Why: #3553 in Alexa global
'http://www.ecnavi.jp/',
# Why: #3554 in Alexa global
'http://www.1616.net/',
# Why: #3555 in Alexa global
'http://www.nationwide.co.uk/',
# Why: #3556 in Alexa global
'http://www.myhabit.com/',
# Why: #3557 in Alexa global
'http://www.kinomaniak.tv/',
# Why: #3558 in Alexa global
'http://www.googlecode.com/',
# Why: #3559 in Alexa global
'http://www.kddi.com/',
# Why: #3560 in Alexa global
'http://www.wyborcza.biz/',
# Why: #3561 in Alexa global
'http://www.gtbank.com/',
# Why: #3562 in Alexa global
'http://zigwheels.com/',
# Why: #3563 in Alexa global
'http://www.lepoint.fr/',
# Why: #3564 in Alexa global
'http://www.formula1.com/',
# Why: #3565 in Alexa global
'http://www.nissen.co.jp/',
# Why: #3566 in Alexa global
'http://www.baomoi.com/',
# Why: #3567 in Alexa global
'http://www.apa.az/',
# Why: #3568 in Alexa global
'http://www.movie2k.to/',
# Why: #3569 in Alexa global
'http://www.irpopup.ir/',
# Why: #3570 in Alexa global
'http://www.nps.gov/',
# Why: #3571 in Alexa global
'http://www.lachainemeteo.com/',
# Why: #3572 in Alexa global
'http://www.x-art.com/',
# Why: #3573 in Alexa global
'http://www.bakecaincontrii.com/',
# Why: #3574 in Alexa global
'http://www.longtailvideo.com/',
# Why: #3575 in Alexa global
'http://www.yengo.com/',
# Why: #3576 in Alexa global
'http://www.listentoyoutube.com/',
# Why: #3577 in Alexa global
'http://www.dreamhost.com/',
# Why: #3578 in Alexa global
'http://www.cari.com.my/',
# Why: #3579 in Alexa global
'http://www.sergeymavrodi.com/',
# Why: #3580 in Alexa global
'http://www.boursorama.com/',
# Why: #3581 in Alexa global
'http://www.extra.com.br/',
# Why: #3582 in Alexa global
'http://www.msnbc.com/',
# Why: #3583 in Alexa global
'http://www.xiaomi.cn/',
# Why: #3585 in Alexa global
'http://www.uwants.com/',
# Why: #3586 in Alexa global
'http://www.utexas.edu/',
# Why: #3587 in Alexa global
'http://www.alc.co.jp/',
# Why: #3588 in Alexa global
'http://www.minijuegos.com/',
# Why: #3589 in Alexa global
'http://www.mumayi.com/',
# Why: #3590 in Alexa global
'http://www.sogi.com.tw/',
# Why: #3591 in Alexa global
'http://www.skorer.tv/',
# Why: #3592 in Alexa global
'http://ddmap.com/',
# Why: #3593 in Alexa global
'http://www.ebog.com/',
# Why: #3594 in Alexa global
'http://www.artlebedev.ru/',
# Why: #3595 in Alexa global
'http://www.venere.com/',
# Why: #3596 in Alexa global
'http://www.academic.ru/',
# Why: #3597 in Alexa global
'http://www.mako.co.il/',
# Why: #3598 in Alexa global
'http://www.nabble.com/',
# Why: #3599 in Alexa global
'http://www.autodesk.com/',
# Why: #3600 in Alexa global
'http://www.vertitechnologygroup.com/',
# Why: #3601 in Alexa global
'http://www.leaseweb.com/',
# Why: #3602 in Alexa global
'http://www.yoox.com/',
# Why: #3603 in Alexa global
'http://www.papajohns.com/',
# Why: #3604 in Alexa global
'http://www.unmillondeutilidades.com/',
# Why: #3605 in Alexa global
'http://www.webmasters.ru/',
# Why: #3606 in Alexa global
'http://www.seoclerks.com/',
# Why: #3607 in Alexa global
'http://www.yootheme.com/',
# Why: #3608 in Alexa global
'http://www.google.com.py/',
# Why: #3609 in Alexa global
'http://www.beemp3.com/',
# Why: #3610 in Alexa global
'http://www.yepme.com/',
# Why: #3611 in Alexa global
'http://www.alef.ir/',
# Why: #3613 in Alexa global
'http://www.gotowebinar.com/',
# Why: #3614 in Alexa global
'http://www.onec.dz/',
# Why: #3615 in Alexa global
'http://www.bonprix.de/',
# Why: #3616 in Alexa global
'http://www.landsend.com/',
# Why: #3617 in Alexa global
'http://www.libertatea.ro/',
# Why: #3618 in Alexa global
'http://www.timeout.com/',
# Why: #3619 in Alexa global
'http://www.appnexus.com/',
# Why: #3620 in Alexa global
'http://www.uproxx.com/',
# Why: #3622 in Alexa global
'http://www.alohatube.com/',
# Why: #3623 in Alexa global
'http://www.citilink.ru/',
# Why: #3624 in Alexa global
'http://www.askubuntu.com/',
# Why: #3625 in Alexa global
'http://www.freemake.com/',
# Why: #3626 in Alexa global
'http://www.rockettheme.com/',
# Why: #3627 in Alexa global
'http://www.tupaki.com/',
# Why: #3628 in Alexa global
'http://www.53.com/',
# Why: #3629 in Alexa global
'http://www.tune.pk/',
# Why: #3630 in Alexa global
'http://www.standardchartered.com/',
# Why: #3631 in Alexa global
'http://www.video-i365.com/',
# Why: #3632 in Alexa global
'http://www.knowyourmeme.com/',
# Why: #3633 in Alexa global
'http://www.gofeminin.de/',
# Why: #3634 in Alexa global
'http://www.vmware.com/',
# Why: #3635 in Alexa global
'http://www.vbox7.com/',
# Why: #3636 in Alexa global
'http://www.webfail.com/',
# Why: #3637 in Alexa global
'http://www.onewebsearch.com/',
# Why: #3638 in Alexa global
'http://www.xnxxmovies.com/',
# Why: #3639 in Alexa global
'http://www.blogspot.hk/',
# Why: #3640 in Alexa global
'http://www.hgtv.com/',
# Why: #3641 in Alexa global
'http://www.findagrave.com/',
# Why: #3642 in Alexa global
'http://www.yoast.com/',
# Why: #3643 in Alexa global
'http://www.audiopoisk.com/',
# Why: #3644 in Alexa global
'http://www.sexytube.me/',
# Why: #3645 in Alexa global
'http://www.centerblog.net/',
# Why: #3646 in Alexa global
'http://www.webpronews.com/',
# Why: #3647 in Alexa global
'http://www.prnewswire.com/',
# Why: #3648 in Alexa global
'http://www.vietnamnet.vn/',
# Why: #3649 in Alexa global
'http://www.groupon.co.in/',
# Why: #3650 in Alexa global
'http://www.bom.gov.au/',
# Why: #3651 in Alexa global
'http://www.loxblog.com/',
# Why: #3652 in Alexa global
'http://www.llnw.com/',
# Why: #3653 in Alexa global
'http://www.jcrew.com/',
# Why: #3654 in Alexa global
'http://www.carsensor.net/',
# Why: #3655 in Alexa global
'http://www.aukro.cz/',
# Why: #3656 in Alexa global
'http://www.zoomby.ru/',
# Why: #3657 in Alexa global
'http://www.wallstcheatsheet.com/',
# Why: #3658 in Alexa global
'http://www.17k.com/',
# Why: #3659 in Alexa global
'http://www.secondlife.com/',
# Why: #3660 in Alexa global
'http://www.marmiton.org/',
# Why: #3661 in Alexa global
'http://www.zorpia.com/',
# Why: #3662 in Alexa global
'http://www.searchya.com/',
# Why: #3663 in Alexa global
'http://www.rtl2.de/',
# Why: #3664 in Alexa global
'http://www.wiocha.pl/',
# Why: #3665 in Alexa global
'http://www.28tui.com/',
# Why: #3666 in Alexa global
'http://www.shopzilla.com/',
# Why: #3667 in Alexa global
'http://www.google.com.ni/',
# Why: #3668 in Alexa global
'http://www.lycos.com/',
# Why: #3669 in Alexa global
'http://www.gucheng.com/',
# Why: #3670 in Alexa global
'http://www.rajanews.com/',
# Why: #3671 in Alexa global
'http://www.blackhatteam.com/',
# Why: #3672 in Alexa global
'http://www.mp3.es/',
# Why: #3673 in Alexa global
'http://www.forums.wordpress.com/',
# Why: #3674 in Alexa global
'http://www.micromaxinfo.com/',
# Why: #3675 in Alexa global
'http://www.sub.jp/',
# Why: #3676 in Alexa global
'http://www.duden.de/',
# Why: #3677 in Alexa global
'http://www.nyc.gov/',
# Why: #3679 in Alexa global
'http://www.monova.org/',
# Why: #3680 in Alexa global
'http://www.al-wlid.com/',
# Why: #3681 in Alexa global
'http://www.dastelefonbuch.de/',
# Why: #3682 in Alexa global
'http://www.cam4ultimate.com/',
# Why: #3683 in Alexa global
'http://www.inps.it/',
# Why: #3684 in Alexa global
'http://www.nazwa.pl/',
# Why: #3685 in Alexa global
'http://www.beatport.com/',
# Why: #3686 in Alexa global
'http://www.wizzair.com/',
# Why: #3687 in Alexa global
'http://www.thomann.de/',
# Why: #3688 in Alexa global
'http://www.juntadeandalucia.es/',
# Why: #3689 in Alexa global
'http://www.oficialsurveyscenter.co/',
# Why: #3690 in Alexa global
'http://www.zaluu.com/',
# Why: #3691 in Alexa global
'http://www.videarn.com/',
# Why: #3692 in Alexa global
'http://www.azcentral.com/',
# Why: #3693 in Alexa global
'http://www.xvideosmovie.com/',
# Why: #3694 in Alexa global
'http://www.eforosh.com/',
# Why: #3696 in Alexa global
'http://www.movie25.com/',
# Why: #3697 in Alexa global
'http://www.creditkarma.com/',
# Why: #3698 in Alexa global
'http://upi.com/',
# Why: #3699 in Alexa global
'http://www.mozook.com/',
# Why: #3700 in Alexa global
'http://www.heavy.com/',
# Why: #3701 in Alexa global
'http://www.worldoftanks.com/',
# Why: #3702 in Alexa global
'http://www.vkrugudruzei.ru/',
# Why: #3704 in Alexa global
'http://www.hourlyrevshare.net/',
# Why: #3705 in Alexa global
'http://www.walkerplus.com/',
# Why: #3706 in Alexa global
'http://www.btyou.com/',
# Why: #3707 in Alexa global
'http://www.adzibiz.com/',
# Why: #3708 in Alexa global
'http://www.tryflirting.com/',
# Why: #3709 in Alexa global
'http://www.moi.gov.sa/',
# Why: #3710 in Alexa global
'http://www.cooltext.com/',
# Why: #3711 in Alexa global
'http://www.dawanda.com/',
# Why: #3712 in Alexa global
'http://www.travian.com.sa/',
# Why: #3713 in Alexa global
'http://www.va.gov/',
# Why: #3714 in Alexa global
'http://www.sunmaker.com/',
# Why: #3715 in Alexa global
'http://www.aaa.com/',
# Why: #3716 in Alexa global
'http://www.dinodirect.com/',
# Why: #3717 in Alexa global
'http://www.cima4u.com/',
# Why: #3718 in Alexa global
'http://www.huaban.com/',
# Why: #3719 in Alexa global
'http://www.nzherald.co.nz/',
# Why: #3720 in Alexa global
'http://www.plotek.pl/',
# Why: #3722 in Alexa global
'http://www.chow.com/',
# Why: #3723 in Alexa global
'http://www.rincondelvago.com/',
# Why: #3724 in Alexa global
'http://uzai.com/',
# Why: #3725 in Alexa global
'http://www.dbw.cn/',
# Why: #3727 in Alexa global
'http://www.stayfriends.de/',
# Why: #3728 in Alexa global
'http://www.reed.co.uk/',
# Why: #3729 in Alexa global
'http://www.rainpow.com/',
# Why: #3730 in Alexa global
'http://www.dallasnews.com/',
# Why: #3731 in Alexa global
'http://www.ntvspor.net/',
# Why: #3732 in Alexa global
'http://www.fonearena.com/',
# Why: #3733 in Alexa global
'http://www.forocoches.com/',
# Why: #3734 in Alexa global
'http://www.myfonts.com/',
# Why: #3735 in Alexa global
'http://www.fenopy.se/',
# Why: #3736 in Alexa global
'http://www.animefreak.tv/',
# Why: #3737 in Alexa global
'http://www.websitewelcome.com/',
# Why: #3738 in Alexa global
'http://www.indonetwork.co.id/',
# Why: #3739 in Alexa global
'http://www.mapsofindia.com/',
# Why: #3740 in Alexa global
'http://www.newlook.com/',
# Why: #3741 in Alexa global
'http://www.holiday-weather.com/',
# Why: #3742 in Alexa global
'http://zhe800.com/',
# Why: #3743 in Alexa global
'http://www.recipesfinder.com/',
# Why: #3744 in Alexa global
'http://www.bankrate.com.cn/',
# Why: #3745 in Alexa global
'http://www.bbom.com.br/',
# Why: #3746 in Alexa global
'http://www.dahe.cn/',
# Why: #3747 in Alexa global
'http://www.jalopnik.com/',
# Why: #3748 in Alexa global
'http://www.canon.com/',
# Why: #3750 in Alexa global
'http://www.freshbooks.com/',
# Why: #3751 in Alexa global
'http://www.clickcompare.info/',
# Why: #3752 in Alexa global
'http://www.aprod.hu/',
# Why: #3753 in Alexa global
'http://www.thisav.com/',
# Why: #3754 in Alexa global
'http://www.boerse.bz/',
# Why: #3755 in Alexa global
'http://www.orange.es/',
# Why: #3756 in Alexa global
'http://www.forobeta.com/',
# Why: #3757 in Alexa global
'http://www.surfactif.fr/',
# Why: #3758 in Alexa global
'http://www.listverse.com/',
# Why: #3759 in Alexa global
'http://www.feedjit.com/',
# Why: #3760 in Alexa global
'http://www.ntv.co.jp/',
# Why: #3761 in Alexa global
'http://www.bni.co.id/',
# Why: #3762 in Alexa global
'http://www.gamemazing.com/',
# Why: #3763 in Alexa global
'http://www.mbalib.com/',
# Why: #3764 in Alexa global
'http://www.topsy.com/',
# Why: #3765 in Alexa global
'http://www.torchbrowser.com/',
# Why: #3766 in Alexa global
'http://www.ieee.org/',
# Why: #3767 in Alexa global
'http://www.tinydeal.com/',
# Why: #3768 in Alexa global
'http://www.playdom.com/',
# Why: #3769 in Alexa global
'http://www.redorbit.com/',
# Why: #3770 in Alexa global
'http://www.inboxdollars.com/',
# Why: #3771 in Alexa global
'http://www.google.com.bh/',
# Why: #3772 in Alexa global
'http://www.pcanalysis.net/',
# Why: #3773 in Alexa global
'http://www.acer.com/',
# Why: #3774 in Alexa global
'http://www.jizzbell.com/',
# Why: #3775 in Alexa global
'http://www.google.com.kh/',
# Why: #3776 in Alexa global
'http://www.mappy.com/',
# Why: #3777 in Alexa global
'http://www.day.az/',
# Why: #3778 in Alexa global
'http://www.euronews.com/',
# Why: #3779 in Alexa global
'http://www.wikidot.com/',
# Why: #3780 in Alexa global
'http://www.creativecommons.org/',
# Why: #3781 in Alexa global
'http://www.quantcast.com/',
# Why: #3782 in Alexa global
'http://www.iconarchive.com/',
# Why: #3783 in Alexa global
'http://www.iyaya.com/',
# Why: #3784 in Alexa global
'http://www.jetstar.com/',
# Why: #3786 in Alexa global
'http://diandian.com/',
# Why: #3787 in Alexa global
'http://www.winzip.com/',
# Why: #3788 in Alexa global
'http://www.clixzor.com/',
# Why: #3789 in Alexa global
'http://www.teebik.com/',
# Why: #3790 in Alexa global
'http://meilele.com/',
# Why: #3791 in Alexa global
'http://www.gsm.ir/',
# Why: #3792 in Alexa global
'http://dek-d.com/',
# Why: #3793 in Alexa global
'http://www.giantbomb.com/',
# Why: #3794 in Alexa global
'http://www.tala.ir/',
# Why: #3795 in Alexa global
'http://www.extremetracking.com/',
# Why: #3796 in Alexa global
'http://www.homevv.com/',
# Why: #3797 in Alexa global
'http://www.truthaboutabs.com/',
# Why: #3798 in Alexa global
'http://www.psychologytoday.com/',
# Why: #3800 in Alexa global
'http://www.vod.pl/',
# Why: #3801 in Alexa global
'http://www.macromill.com/',
# Why: #3802 in Alexa global
'http://www.pagseguro.uol.com.br/',
# Why: #3804 in Alexa global
'http://www.amd.com/',
# Why: #3805 in Alexa global
'http://www.livescience.com/',
# Why: #3806 in Alexa global
'http://dedecms.com/',
# Why: #3807 in Alexa global
'http://www.jin115.com/',
# Why: #3808 in Alexa global
'http://www.ampxchange.com/',
# Why: #3809 in Alexa global
'http://www.profitcentr.com/',
# Why: #3810 in Alexa global
'http://www.webmotors.com.br/',
# Why: #3811 in Alexa global
'http://www.lan.com/',
# Why: #3812 in Alexa global
'http://www.fileice.net/',
# Why: #3813 in Alexa global
'http://www.ingdirect.es/',
# Why: #3814 in Alexa global
'http://www.amtrak.com/',
# Why: #3815 in Alexa global
'http://www.emag.ro/',
# Why: #3816 in Alexa global
'http://www.progressive.com/',
# Why: #3817 in Alexa global
'http://www.balatarin.com/',
# Why: #3818 in Alexa global
'http://www.immonet.de/',
# Why: #3819 in Alexa global
'http://www.e-travel.com/',
# Why: #3820 in Alexa global
'http://www.studymode.com/',
# Why: #3821 in Alexa global
'http://www.go2000.com/',
# Why: #3822 in Alexa global
'http://www.shopbop.com/',
# Why: #3823 in Alexa global
'http://www.filesfetcher.com/',
# Why: #3824 in Alexa global
'http://www.euroresidentes.com/',
# Why: #3825 in Alexa global
'http://www.movistar.es/',
# Why: #3826 in Alexa global
'http://lefeng.com/',
# Why: #3827 in Alexa global
'http://www.google.hn/',
# Why: #3828 in Alexa global
'http://www.homestead.com/',
# Why: #3829 in Alexa global
'http://www.filesonar.com/',
# Why: #3830 in Alexa global
'http://www.hsbccreditcard.com/',
# Why: #3831 in Alexa global
'http://www.google.com.np/',
# Why: #3832 in Alexa global
'http://www.parperfeito.com.br/',
# Why: #3833 in Alexa global
'http://www.sciencedaily.com/',
# Why: #3834 in Alexa global
'http://www.realgfporn.com/',
# Why: #3835 in Alexa global
'http://www.wonderhowto.com/',
# Why: #3836 in Alexa global
'http://www.rakuten-card.co.jp/',
# Why: #3837 in Alexa global
'http://www.coolrom.com/',
# Why: #3838 in Alexa global
'http://www.wikibooks.org/',
# Why: #3839 in Alexa global
'http://www.archdaily.com/',
# Why: #3840 in Alexa global
'http://www.gigazine.net/',
# Why: #3841 in Alexa global
'http://www.totaljerkface.com/',
# Why: #3842 in Alexa global
'http://www.bezaat.com/',
# Why: #3843 in Alexa global
'http://www.eurosport.com/',
# Why: #3844 in Alexa global
'http://www.fontspace.com/',
# Why: #3845 in Alexa global
'http://www.tirage24.com/',
# Why: #3846 in Alexa global
'http://www.bancomer.com.mx/',
# Why: #3847 in Alexa global
'http://www.nasdaq.com/',
# Why: #3848 in Alexa global
'http://www.bravoteens.com/',
# Why: #3849 in Alexa global
'http://www.bdjobs.com/',
# Why: #3850 in Alexa global
'http://www.zimbra.free.fr/',
# Why: #3851 in Alexa global
'http://www.arsenal.com/',
# Why: #3852 in Alexa global
'http://www.rabota.ru/',
# Why: #3853 in Alexa global
'http://www.lovefilm.com/',
# Why: #3854 in Alexa global
'http://www.artemisweb.jp/',
# Why: #3855 in Alexa global
'http://www.tsetmc.com/',
# Why: #3856 in Alexa global
'http://www.movshare.net/',
# Why: #3857 in Alexa global
'http://www.debonairblog.com/',
# Why: #3858 in Alexa global
'http://www.zmovie.co/',
# Why: #3859 in Alexa global
'http://www.peoplefinders.com/',
# Why: #3860 in Alexa global
'http://www.mercadolibre.com/',
# Why: #3861 in Alexa global
'http://www.connectlondoner.com/',
# Why: #3862 in Alexa global
'http://www.forbes.ru/',
# Why: #3863 in Alexa global
'http://www.gagnezauxoptions.com/',
# Why: #3864 in Alexa global
'http://www.taikang.com/',
# Why: #3865 in Alexa global
'http://www.mywapblog.com/',
# Why: #3866 in Alexa global
'http://www.citysearch.com/',
# Why: #3867 in Alexa global
'http://www.novafinanza.com/',
# Why: #3868 in Alexa global
'http://www.gruposantander.es/',
# Why: #3869 in Alexa global
'http://www.relianceada.com/',
# Why: #3870 in Alexa global
'http://www.rankingsandreviews.com/',
# Why: #3871 in Alexa global
'http://www.p-world.co.jp/',
# Why: #3872 in Alexa global
'http://hjenglish.com/',
# Why: #3873 in Alexa global
'http://www.state.nj.us/',
# Why: #3874 in Alexa global
'http://www.comdirect.de/',
# Why: #3875 in Alexa global
'http://www.claro.com.br/',
# Why: #3876 in Alexa global
'http://www.alluc.to/',
# Why: #3877 in Alexa global
'http://www.godlikeproductions.com/',
# Why: #3878 in Alexa global
'http://www.lowyat.net/',
# Why: #3879 in Alexa global
'http://www.dawn.com/',
# Why: #3880 in Alexa global
'http://www.18xgirls.com/',
# Why: #3881 in Alexa global
'http://www.origo.hu/',
# Why: #3882 in Alexa global
'http://www.loopnet.com/',
# Why: #3883 in Alexa global
'http://www.payu.in/',
# Why: #3884 in Alexa global
'http://www.digitalmedia-comunicacion.com/',
# Why: #3885 in Alexa global
'http://www.newsvine.com/',
# Why: #3886 in Alexa global
'http://www.petfinder.com/',
# Why: #3887 in Alexa global
'http://www.kuaibo.com/',
# Why: #3888 in Alexa global
'http://www.soft32.com/',
# Why: #3889 in Alexa global
'http://www.yellowpages.ca/',
# Why: #3890 in Alexa global
'http://www.1fichier.com/',
# Why: #3891 in Alexa global
'http://www.egyup.com/',
# Why: #3892 in Alexa global
'http://www.iskullgames.com/',
# Why: #3893 in Alexa global
'http://www.androidforums.com/',
# Why: #3894 in Alexa global
'http://www.blogspot.cz/',
# Why: #3895 in Alexa global
'http://www.umich.edu/',
# Why: #3896 in Alexa global
'http://www.madsextube.com/',
# Why: #3897 in Alexa global
'http://www.bigcinema.tv/',
# Why: #3898 in Alexa global
'http://www.donedeal.ie/',
# Why: #3899 in Alexa global
'http://www.winporn.com/',
# Why: #3900 in Alexa global
'http://www.cosmopolitan.com/',
# Why: #3901 in Alexa global
'http://www.reg.ru/',
# Why: #3902 in Alexa global
'http://www.localmoxie.com/',
# Why: #3903 in Alexa global
'http://www.kootation.com/',
# Why: #3904 in Alexa global
'http://www.gidonline.ru/',
# Why: #3905 in Alexa global
'http://www.clipconverter.cc/',
# Why: #3906 in Alexa global
'http://www.gioco.it/',
# Why: #3907 in Alexa global
'http://www.ravelry.com/',
# Why: #3908 in Alexa global
'http://www.gettyimages.com/',
# Why: #3909 in Alexa global
'http://www.nanapi.jp/',
# Why: #3910 in Alexa global
'http://www.medicalnewsreporter.com/',
# Why: #3911 in Alexa global
'http://www.shop411.com/',
# Why: #3912 in Alexa global
'http://www.aif.ru/',
# Why: #3913 in Alexa global
'http://www.journaldesfemmes.com/',
# Why: #3914 in Alexa global
'http://www.blogcu.com/',
# Why: #3915 in Alexa global
'http://www.vanguard.com/',
# Why: #3916 in Alexa global
'http://www.freemp3go.com/',
# Why: #3917 in Alexa global
'http://www.google.ci/',
# Why: #3918 in Alexa global
'http://www.findicons.com/',
# Why: #3919 in Alexa global
'http://www.tineye.com/',
# Why: #3920 in Alexa global
'http://www.webdesignerdepot.com/',
# Why: #3921 in Alexa global
'http://www.nomorerack.com/',
# Why: #3922 in Alexa global
'http://www.iqoo.me/',
# Why: #3923 in Alexa global
'http://www.amarujala.com/',
# Why: #3924 in Alexa global
'http://pengfu.com/',
# Why: #3925 in Alexa global
'http://www.leadpages.net/',
# Why: #3926 in Alexa global
'http://www.zalukaj.tv/',
# Why: #3927 in Alexa global
'http://www.avon.com/',
# Why: #3928 in Alexa global
'http://www.casasbahia.com.br/',
# Why: #3929 in Alexa global
'http://www.juegosdechicas.com/',
# Why: #3930 in Alexa global
'http://www.tvrain.ru/',
# Why: #3931 in Alexa global
'http://www.askmefast.com/',
# Why: #3932 in Alexa global
'http://www.stockcharts.com/',
# Why: #3934 in Alexa global
'http://www.footlocker.com/',
# Why: #3935 in Alexa global
'http://www.allanalpass.com/',
# Why: #3936 in Alexa global
'http://www.theoatmeal.com/',
# Why: #3937 in Alexa global
'http://www.storify.com/',
# Why: #3938 in Alexa global
'http://www.santander.com.br/',
# Why: #3939 in Alexa global
'http://www.laughnfiddle.com/',
# Why: #3940 in Alexa global
'http://www.lomadee.com/',
# Why: #3941 in Alexa global
'http://aftenposten.no/',
# Why: #3942 in Alexa global
'http://www.lamoda.ru/',
# Why: #3943 in Alexa global
'http://www.tasteofhome.com/',
# Why: #3944 in Alexa global
'http://www.news247.gr/',
# Why: #3946 in Alexa global
'http://www.sherdog.com/',
# Why: #3947 in Alexa global
'http://www.milb.com/',
# Why: #3948 in Alexa global
'http://www.3djuegos.com/',
# Why: #3949 in Alexa global
'http://www.dreammovies.com/',
# Why: #3950 in Alexa global
'http://www.commonfloor.com/',
# Why: #3951 in Alexa global
'http://www.tharunee.lk/',
# Why: #3952 in Alexa global
'http://www.chatrandom.com/',
# Why: #3953 in Alexa global
'http://xs8.cn/',
# Why: #3955 in Alexa global
'http://www.rechargeitnow.com/',
# Why: #3956 in Alexa global
'http://am15.net/',
# Why: #3957 in Alexa global
'http://www.sexad.net/',
# Why: #3958 in Alexa global
'http://www.herokuapp.com/',
# Why: #3959 in Alexa global
'http://www.apontador.com.br/',
# Why: #3960 in Alexa global
'http://www.rfi.fr/',
# Why: #3961 in Alexa global
'http://www.woozworld.com/',
# Why: #3962 in Alexa global
'http://www.hitta.se/',
# Why: #3963 in Alexa global
'http://www.comedycentral.com/',
# Why: #3964 in Alexa global
'http://www.fbsbx.com/',
# Why: #3965 in Alexa global
'http://www.aftabnews.ir/',
# Why: #3966 in Alexa global
'http://www.stepstone.de/',
# Why: #3967 in Alexa global
'http://www.filmon.com/',
# Why: #3969 in Alexa global
'http://www.smbc.co.jp/',
# Why: #3970 in Alexa global
'http://www.ameritrade.com/',
# Why: #3971 in Alexa global
'http://www.ecitic.com/',
# Why: #3972 in Alexa global
'http://www.bola.net/',
# Why: #3973 in Alexa global
'http://www.nexon.co.jp/',
# Why: #3974 in Alexa global
'http://www.hellowork.go.jp/',
# Why: #3975 in Alexa global
'http://www.hq-sex-tube.com/',
# Why: #3976 in Alexa global
'http://www.gsp.ro/',
# Why: #3977 in Alexa global
'http://www.groupon.co.uk/',
# Why: #3978 in Alexa global
'http://www.20min.ch/',
# Why: #3979 in Alexa global
'http://www.barclaycardus.com/',
# Why: #3980 in Alexa global
'http://www.dice.com/',
# Why: #3981 in Alexa global
'http://himasoku.com/',
# Why: #3982 in Alexa global
'http://www.nwsource.com/',
# Why: #3983 in Alexa global
'http://www.gougou.com/',
# Why: #3984 in Alexa global
'http://www.iol.co.za/',
# Why: #3985 in Alexa global
'http://www.thinkgeek.com/',
# Why: #3986 in Alexa global
'http://www.governmentjobs.com/',
# Why: #3987 in Alexa global
'http://www.500.com/',
# Why: #3988 in Alexa global
'http://www.caixin.com/',
# Why: #3989 in Alexa global
'http://www.elsevier.com/',
# Why: #3990 in Alexa global
'http://www.navitime.co.jp/',
# Why: #3991 in Alexa global
'http://www.rafflecopter.com/',
# Why: #3992 in Alexa global
'http://www.auctiva.com/',
# Why: #3994 in Alexa global
'http://www.pracuj.pl/',
# Why: #3995 in Alexa global
'http://www.strato.de/',
# Why: #3996 in Alexa global
'http://www.ricardoeletro.com.br/',
# Why: #3997 in Alexa global
'http://www.vodafone.de/',
# Why: #3998 in Alexa global
'http://www.jike.com/',
# Why: #3999 in Alexa global
'http://www.smosh.com/',
# Why: #4000 in Alexa global
'http://www.downlite.net/',
# Why: #4001 in Alexa global
'http://to8to.com/',
# Why: #4003 in Alexa global
'http://www.tikona.in/',
# Why: #4004 in Alexa global
'http://www.royalmail.com/',
# Why: #4005 in Alexa global
'http://www.tripadvisor.de/',
# Why: #4006 in Alexa global
'http://www.realclearpolitics.com/',
# Why: #4007 in Alexa global
'http://www.pubdirecte.com/',
# Why: #4008 in Alexa global
'http://www.rassd.com/',
# Why: #4009 in Alexa global
'http://www.ptt.cc/',
# Why: #4010 in Alexa global
'http://www.townhall.com/',
# Why: #4011 in Alexa global
'http://www.theoldreader.com/',
# Why: #4012 in Alexa global
'http://www.viki.com/',
# Why: #4013 in Alexa global
'http://www.one.com/',
# Why: #4014 in Alexa global
'http://www.peopleperhour.com/',
# Why: #4015 in Alexa global
'http://www.desidime.com/',
# Why: #4016 in Alexa global
'http://www.17track.net/',
# Why: #4017 in Alexa global
'http://www.duote.com/',
# Why: #4018 in Alexa global
'http://www.emuch.net/',
# Why: #4019 in Alexa global
'http://www.mlgame.co.uk/',
# Why: #4020 in Alexa global
'http://www.rockstargames.com/',
# Why: #4021 in Alexa global
'http://www.slaati.com/',
# Why: #4022 in Alexa global
'http://www.ibibo.com/',
# Why: #4023 in Alexa global
'http://www.journaldunet.com/',
# Why: #4024 in Alexa global
'http://www.ria.ua/',
# Why: #4025 in Alexa global
'http://www.odatv.com/',
# Why: #4026 in Alexa global
'http://www.comodo.com/',
# Why: #4027 in Alexa global
'http://www.clickfair.com/',
# Why: #4028 in Alexa global
'http://www.system500.com/',
# Why: #4029 in Alexa global
'http://www.wordstream.com/',
# Why: #4030 in Alexa global
'http://www.alexaboostup.com/',
# Why: #4031 in Alexa global
'http://www.yjbys.com/',
# Why: #4032 in Alexa global
'http://www.hsbc.com/',
# Why: #4033 in Alexa global
'http://www.online-convert.com/',
# Why: #4034 in Alexa global
'http://www.miui.com/',
# Why: #4035 in Alexa global
'http://www.totaljobs.com/',
# Why: #4036 in Alexa global
'http://www.travian.fr/',
# Why: #4037 in Alexa global
'http://www.funda.nl/',
# Why: #4038 in Alexa global
'http://www.bazos.sk/',
# Why: #4039 in Alexa global
'http://www.efukt.com/',
# Why: #4040 in Alexa global
'http://www.startlap.com/',
# Why: #4041 in Alexa global
'http://www.hir24.hu/',
# Why: #4042 in Alexa global
'http://www.mrskin.com/',
# Why: #4043 in Alexa global
'http://dbs.com/',
# Why: #4044 in Alexa global
'http://www.sevenforums.com/',
# Why: #4045 in Alexa global
'http://www.admitad.com/',
# Why: #4046 in Alexa global
'http://www.graaam.com/',
# Why: #4047 in Alexa global
'http://www.exactme.com/',
# Why: #4048 in Alexa global
'http://www.roadrunner.com/',
# Why: #4049 in Alexa global
'http://www.liberation.fr/',
# Why: #4050 in Alexa global
'http://www.cas.sk/',
# Why: #4051 in Alexa global
'http://www.redbubble.com/',
# Why: #4052 in Alexa global
'http://www.ezilon.com/',
# Why: #4053 in Alexa global
'http://www.hihi2.com/',
# Why: #4054 in Alexa global
'http://www.net.hr/',
# Why: #4055 in Alexa global
'http://www.mediaite.com/',
# Why: #4056 in Alexa global
'http://www.clip2net.com/',
# Why: #4057 in Alexa global
'http://www.wapka.mobi/',
# Why: #4058 in Alexa global
'http://www.dailybasis.com/',
# Why: #4059 in Alexa global
'http://www.o2online.de/',
# Why: #4060 in Alexa global
'http://www.tweetdeck.com/',
# Why: #4061 in Alexa global
'http://www.tripadvisor.jp/',
# Why: #4062 in Alexa global
'http://www.fakt.pl/',
# Why: #4063 in Alexa global
'http://www.service-public.fr/',
# Why: #4064 in Alexa global
'http://www.shueisha.co.jp/',
# Why: #4065 in Alexa global
'http://www.searchina.ne.jp/',
# Why: #4066 in Alexa global
'http://www.bodisparking.com/',
# Why: #4067 in Alexa global
'http://www.corporationwiki.com/',
# Why: #4068 in Alexa global
'http://www.jandan.net/',
# Why: #4069 in Alexa global
'http://www.chsi.com.cn/',
# Why: #4070 in Alexa global
'http://www.alisoft.com/',
# Why: #4071 in Alexa global
'http://www.gosuslugi.ru/',
# Why: #4072 in Alexa global
'http://www.grxf.com/',
# Why: #4073 in Alexa global
'http://www.daserste.de/',
# Why: #4074 in Alexa global
'http://www.freedigitalphotos.net/',
# Why: #4075 in Alexa global
'http://www.flirchi.ru/',
# Why: #4076 in Alexa global
'http://www.seesaa.jp/',
# Why: #4077 in Alexa global
'http://www.htmlbook.ru/',
# Why: #4078 in Alexa global
'http://www.independent.ie/',
# Why: #4079 in Alexa global
'http://www.bufferapp.com/',
# Why: #4080 in Alexa global
'http://www.panzar.com/',
# Why: #4081 in Alexa global
'http://www.sport.cz/',
# Why: #4082 in Alexa global
'http://matomeantena.com/',
# Why: #4083 in Alexa global
'http://www.thenewporn.com/',
# Why: #4084 in Alexa global
'http://www.iran-tejarat.com/',
# Why: #4085 in Alexa global
'http://www.rotoworld.com/',
# Why: #4086 in Alexa global
'http://maalaimalar.com/',
# Why: #4087 in Alexa global
'http://www.poppen.de/',
# Why: #4088 in Alexa global
'http://www.tenki.jp/',
# Why: #4089 in Alexa global
'http://www.homes.co.jp/',
# Why: #4090 in Alexa global
'http://www.csfd.cz/',
# Why: #4091 in Alexa global
'http://www.2ip.ru/',
# Why: #4092 in Alexa global
'http://www.hawamer.com/',
# Why: #4093 in Alexa global
'http://www.telkomsel.com/',
# Why: #4094 in Alexa global
'http://www.un.org/',
# Why: #4095 in Alexa global
'http://www.autobinaryea.com/',
# Why: #4096 in Alexa global
'http://www.emgoldex.com/',
# Why: #4097 in Alexa global
'http://www.saksfifthavenue.com/',
# Why: #4098 in Alexa global
'http://www.realtor.ca/',
# Why: #4099 in Alexa global
'http://www.hdwallpapers.in/',
# Why: #4100 in Alexa global
'http://www.chinahr.com/',
# Why: #4101 in Alexa global
'http://www.niazerooz.com/',
# Why: #4102 in Alexa global
'http://www.sina.com/',
# Why: #4103 in Alexa global
'http://www.kinopod.ru/',
# Why: #4104 in Alexa global
'http://www.funweek.it/',
# Why: #4105 in Alexa global
'http://www.pornsake.com/',
# Why: #4106 in Alexa global
'http://www.vitacost.com/',
# Why: #4107 in Alexa global
'http://www.band.uol.com.br/',
# Why: #4108 in Alexa global
'http://www.110.com/',
# Why: #4109 in Alexa global
'http://www.jobomas.com/',
# Why: #4110 in Alexa global
'http://www.joyreactor.cc/',
# Why: #4111 in Alexa global
'http://www.3dnews.ru/',
# Why: #4112 in Alexa global
'http://www.vedomosti.ru/',
# Why: #4113 in Alexa global
'http://www.stansberryresearch.com/',
# Why: #4114 in Alexa global
'http://www.performersoft.com/',
# Why: #4115 in Alexa global
'http://www.codecademy.com/',
# Why: #4116 in Alexa global
'http://www.petsmart.com/',
# Why: #4118 in Alexa global
'http://www.kissmetrics.com/',
# Why: #4119 in Alexa global
'http://www.infojobs.it/',
# Why: #4120 in Alexa global
'http://www.wealink.com/',
# Why: #4121 in Alexa global
'http://www.rapidtrk.com/',
# Why: #4122 in Alexa global
'http://www.enterprise.com/',
# Why: #4123 in Alexa global
'http://www.iran-forum.ir/',
# Why: #4124 in Alexa global
'http://www.express-files.com/',
# Why: #4126 in Alexa global
'http://www.cyberpresse.ca/',
# Why: #4127 in Alexa global
'http://www.dobreprogramy.pl/',
# Why: #4128 in Alexa global
'http://www.uploading.com/',
# Why: #4129 in Alexa global
'http://www.profitclicking.com/',
# Why: #4130 in Alexa global
'http://www.playwartune.com/',
# Why: #4131 in Alexa global
'http://www.toluna.com/',
# Why: #4132 in Alexa global
'http://www.shoptime.com.br/',
# Why: #4134 in Alexa global
'http://www.totaladperformance.com/',
# Why: #4135 in Alexa global
'http://www.handelsblatt.com/',
# Why: #4136 in Alexa global
'http://www.hamshahrionline.ir/',
# Why: #4137 in Alexa global
'http://www.15min.lt/',
# Why: #4138 in Alexa global
'http://www.wyborcza.pl/',
# Why: #4139 in Alexa global
'http://www.flvto.com/',
# Why: #4140 in Alexa global
'http://www.microsofttranslator.com/',
# Why: #4141 in Alexa global
'http://www.trovaprezzi.it/',
# Why: #4142 in Alexa global
'http://www.eversave.com/',
# Why: #4143 in Alexa global
'http://www.wmzona.com/',
# Why: #4144 in Alexa global
'http://www.hardwarezone.com.sg/',
# Why: #4145 in Alexa global
'http://thestar.com.my/',
# Why: #4146 in Alexa global
'http://www.siliconindia.com/',
# Why: #4147 in Alexa global
'http://www.jfranews.com/',
# Why: #4148 in Alexa global
'http://www.emol.com/',
# Why: #4149 in Alexa global
'http://www.nordea.fi/',
# Why: #4150 in Alexa global
'http://hers.com.cn/',
# Why: #4151 in Alexa global
'http://www.heroturko.me/',
# Why: #4152 in Alexa global
'http://www.xat.com/',
# Why: #4153 in Alexa global
'http://www.3asq.com/',
# Why: #4154 in Alexa global
'http://www.hlntv.com/',
# Why: #4155 in Alexa global
'http://incruit.com/',
# Why: #4156 in Alexa global
'http://www.list-manage2.com/',
# Why: #4157 in Alexa global
'http://www.bulbagarden.net/',
# Why: #4158 in Alexa global
'http://www.blogdohotelurbano.com/',
# Why: #4159 in Alexa global
'http://www.suomi24.fi/',
# Why: #4160 in Alexa global
'http://www.nicozon.net/',
# Why: #4161 in Alexa global
'http://www.tuporno.tv/',
# Why: #4162 in Alexa global
'http://www.perfectworld.com/',
# Why: #4163 in Alexa global
'http://www.ayosdito.ph/',
# Why: #4164 in Alexa global
'http://www.gmx.at/',
# Why: #4165 in Alexa global
'http://www.123greetings.com/',
# Why: #4166 in Alexa global
'http://www.metafilter.com/',
# Why: #4167 in Alexa global
'http://www.g9g.com/',
# Why: #4168 in Alexa global
'http://www.searchnfind.org/',
# Why: #4169 in Alexa global
'http://www.pcgamer.com/',
# Why: #4170 in Alexa global
'http://economia.uol.com.br/',
# Why: #4171 in Alexa global
'http://www.on.cc/',
# Why: #4172 in Alexa global
'http://www.rentalcars.com/',
# Why: #4173 in Alexa global
'http://www.mail2web.com/',
# Why: #4174 in Alexa global
'http://www.zalando.it/',
# Why: #4175 in Alexa global
'http://www.freevideo.cz/',
# Why: #4176 in Alexa global
'http://www.source-wave.com/',
# Why: #4177 in Alexa global
'http://www.iranjib.ir/',
# Why: #4178 in Alexa global
'http://www.societe.com/',
# Why: #4179 in Alexa global
'http://www.160by2.com/',
# Why: #4180 in Alexa global
'http://www.berooztarinha.com/',
# Why: #4181 in Alexa global
'http://www.popmog.com/',
# Why: #4182 in Alexa global
'http://www.fantasy8.com/',
# Why: #4183 in Alexa global
'http://www.motortrend.com/',
# Why: #4184 in Alexa global
'http://www.huffingtonpost.ca/',
# Why: #4185 in Alexa global
'http://51test.net/',
# Why: #4186 in Alexa global
'http://www.ringtonematcher.com/',
# Why: #4187 in Alexa global
'http://www.ourtime.com/',
# Why: #4188 in Alexa global
'http://www.standardchartered.co.in/',
# Why: #4189 in Alexa global
'http://www.rdio.com/',
# Why: #4190 in Alexa global
'http://www.parsiblog.com/',
# Why: #4191 in Alexa global
'http://www.btvguide.com/',
# Why: #4192 in Alexa global
'http://www.sport.ro/',
# Why: #4193 in Alexa global
'http://www.freep.com/',
# Why: #4194 in Alexa global
'http://www.gismeteo.ua/',
# Why: #4195 in Alexa global
'http://www.rojadirecta.me/',
# Why: #4196 in Alexa global
'http://www.babol.pl/',
# Why: #4198 in Alexa global
'http://www.lun.com/',
# Why: #4199 in Alexa global
'http://www.epicurious.com/',
# Why: #4200 in Alexa global
'http://www.fetishok.com/',
# Why: #4201 in Alexa global
'http://www.mystart.com/',
# Why: #4202 in Alexa global
'http://www.wn.com/',
# Why: #4203 in Alexa global
'http://www.nationalrail.co.uk/',
# Why: #4204 in Alexa global
'http://www.feedsportal.com/',
# Why: #4205 in Alexa global
'http://www.rai.it/',
# Why: #4206 in Alexa global
'http://www.sportlemon.tv/',
# Why: #4207 in Alexa global
'http://www.groupon.com.br/',
# Why: #4208 in Alexa global
'http://www.ebay.at/',
# Why: #4209 in Alexa global
'http://www.yourdictionary.com/',
# Why: #4210 in Alexa global
'http://www.360safe.com/',
# Why: #4211 in Alexa global
'http://www.statefarm.com/',
# Why: #4212 in Alexa global
'http://www.desjardins.com/',
# Why: #4213 in Alexa global
'http://www.biblehub.com/',
# Why: #4214 in Alexa global
'http://www.mercadolibre.cl/',
# Why: #4215 in Alexa global
'http://www.eluniversal.com/',
# Why: #4216 in Alexa global
'http://www.lrytas.lt/',
# Why: #4217 in Alexa global
'http://www.youboy.com/',
# Why: #4218 in Alexa global
'http://www.gratka.pl/',
# Why: #4219 in Alexa global
'http://etype.com/',
# Why: #4220 in Alexa global
'http://www.reallifecam.com/',
# Why: #4221 in Alexa global
'http://www.imp.free.fr/',
# Why: #4222 in Alexa global
'http://www.jobstreet.co.id/',
# Why: #4223 in Alexa global
'http://www.geenstijl.nl/',
# Why: #4224 in Alexa global
'http://www.aebn.net/',
# Why: #4225 in Alexa global
'http://www.openoffice.org/',
# Why: #4226 in Alexa global
'http://www.diythemes.com/',
# Why: #4227 in Alexa global
'http://www.2gis.ru/',
# Why: #4228 in Alexa global
'http://www.wpmu.org/',
# Why: #4229 in Alexa global
'http://www.scrubtheweb.com/',
# Why: #4230 in Alexa global
'http://www.domain.com.au/',
# Why: #4231 in Alexa global
'http://www.buyma.com/',
# Why: #4232 in Alexa global
'http://www.ccbill.com/',
# Why: #4233 in Alexa global
'http://www.tui18.com/',
# Why: #4234 in Alexa global
'http://www.duga.jp/',
# Why: #4235 in Alexa global
'http://www.goforfiles.com/',
# Why: #4236 in Alexa global
'http://www.billionuploads.com/',
# Why: #4237 in Alexa global
'http://www.blogtalkradio.com/',
# Why: #4238 in Alexa global
'http://www.pipl.com/',
# Why: #4239 in Alexa global
'http://www.wallpaperswide.com/',
# Why: #4240 in Alexa global
'http://www.tuttosport.com/',
# Why: #4241 in Alexa global
'http://www.astucecherry.com/',
# Why: #4242 in Alexa global
'http://www.tradingfornewbies.com/',
# Why: #4243 in Alexa global
'http://www.umn.edu/',
# Why: #4244 in Alexa global
'http://www.rj.gov.br/',
# Why: #4245 in Alexa global
'http://www.mlive.com/',
# Why: #4246 in Alexa global
'http://www.justfab.com/',
# Why: #4247 in Alexa global
'http://www.ijreview.com/',
# Why: #4248 in Alexa global
'http://www.daniweb.com/',
# Why: #4249 in Alexa global
'http://www.quickmeme.com/',
# Why: #4250 in Alexa global
'http://www.safeway.com/',
# Why: #4251 in Alexa global
'http://www.virtualedge.com/',
# Why: #4252 in Alexa global
'http://www.saudiairlines.com/',
# Why: #4253 in Alexa global
'http://www.elbotola.com/',
# Why: #4254 in Alexa global
'http://www.holtgames.com/',
# Why: #4255 in Alexa global
'http://www.boots.com/',
# Why: #4256 in Alexa global
'http://www.potterybarn.com/',
# Why: #4257 in Alexa global
'http://www.mediamarkt.de/',
# Why: #4258 in Alexa global
'http://www.mangastream.com/',
# Why: #4259 in Alexa global
'http://www.mypoints.com/',
# Why: #4260 in Alexa global
'http://www.torrentdownloads.me/',
# Why: #4261 in Alexa global
'http://www.subtitleseeker.com/',
# Why: #4262 in Alexa global
'http://www.idlebrain.com/',
# Why: #4263 in Alexa global
'http://www.ekantipur.com/',
# Why: #4264 in Alexa global
'http://www.nowgamez.com/',
# Why: #4265 in Alexa global
'http://www.neoseeker.com/',
# Why: #4266 in Alexa global
'http://www.christianpost.com/',
# Why: #4267 in Alexa global
'http://www.joystiq.com/',
# Why: #4268 in Alexa global
'http://acesso.uol.com.br/',
# Why: #4269 in Alexa global
'http://www.bakufu.jp/',
# Why: #4270 in Alexa global
'http://www.iphone-winners.info/',
# Why: #4271 in Alexa global
'http://www.quizlet.com/',
# Why: #4272 in Alexa global
'http://www.prosport.ro/',
# Why: #4273 in Alexa global
'http://www.quanjing.com/',
# Why: #4274 in Alexa global
'http://autov.com.cn/',
# Why: #4275 in Alexa global
'http://www.gamechit.com/',
# Why: #4276 in Alexa global
'http://www.teleshow.pl/',
# Why: #4277 in Alexa global
'http://www.corrieredellosport.it/',
# Why: #4278 in Alexa global
'http://www.yoo7.com/',
# Why: #4279 in Alexa global
'http://fotocasa.es/',
# Why: #4280 in Alexa global
'http://www.attracta.com/',
# Why: #4281 in Alexa global
'http://www.hyatt.com/',
# Why: #4282 in Alexa global
'http://www.confirmit.com/',
# Why: #4283 in Alexa global
'http://www.xyu.tv/',
# Why: #4284 in Alexa global
'http://www.yoolplay.com/',
# Why: #4285 in Alexa global
'http://www.active.com/',
# Why: #4286 in Alexa global
'http://www.gizmag.com/',
# Why: #4287 in Alexa global
'http://www.hostelworld.com/',
# Why: #4288 in Alexa global
'http://www.pc6.com/',
# Why: #4289 in Alexa global
'http://www.lacentrale.fr/',
# Why: #4290 in Alexa global
'http://www.megasesso.com/',
# Why: #4291 in Alexa global
'http://www.thairath.co.th/',
# Why: #4292 in Alexa global
'http://www.thinkprogress.org/',
# Why: #4293 in Alexa global
'http://www.400gb.com/',
# Why: #4294 in Alexa global
'http://www.manageflitter.com/',
# Why: #4295 in Alexa global
'http://www.pronto.com/',
# Why: #4296 in Alexa global
'http://www.erotube.org/',
# Why: #4297 in Alexa global
'http://luxtarget.com/',
# Why: #4298 in Alexa global
'http://www.vui.vn/',
# Why: #4299 in Alexa global
'http://www.screenrant.com/',
# Why: #4300 in Alexa global
'http://www.nationalreview.com/',
# Why: #4301 in Alexa global
'http://www.ikman.lk/',
# Why: #4302 in Alexa global
'http://www.aboutus.org/',
# Why: #4303 in Alexa global
'http://www.booloo.com/',
# Why: #4304 in Alexa global
'http://www.klm.com/',
# Why: #4305 in Alexa global
'http://www.aukro.ua/',
# Why: #4307 in Alexa global
'http://www.skladchik.com/',
# Why: #4308 in Alexa global
'http://alfalfalfa.com/',
# Why: #4309 in Alexa global
'http://www.ghanaweb.com/',
# Why: #4310 in Alexa global
'http://www.cheetahmail.com/',
# Why: #4311 in Alexa global
'http://www.celebritynetworth.com/',
# Why: #4312 in Alexa global
'http://www.honda.com/',
# Why: #4313 in Alexa global
'http://www.regnum.ru/',
# Why: #4314 in Alexa global
'http://www.mediabistro.com/',
# Why: #4315 in Alexa global
'http://www.template-help.com/',
# Why: #4316 in Alexa global
'http://www.elektroda.pl/',
# Why: #4317 in Alexa global
'http://www.howlifeworks.com/',
# Why: #4318 in Alexa global
'http://avjavjav.com/',
# Why: #4319 in Alexa global
'http://www.justunfollow.com/',
# Why: #4320 in Alexa global
'http://www.kindgirls.com/',
# Why: #4321 in Alexa global
'http://www.xrea.com/',
# Why: #4322 in Alexa global
'http://www.songspk.cc/',
# Why: #4323 in Alexa global
'http://www.softbank.jp/',
# Why: #4324 in Alexa global
'http://www.pcstore.com.tw/',
# Why: #4325 in Alexa global
'http://www.impiego24.it/',
# Why: #4326 in Alexa global
'http://www.health.com/',
# Why: #4327 in Alexa global
'http://www.whitehouse.gov/',
# Why: #4328 in Alexa global
'http://www.ulozto.cz/',
# Why: #4329 in Alexa global
'http://www.clickindia.com/',
# Why: #4330 in Alexa global
'http://www.zoosnet.net/',
# Why: #4331 in Alexa global
'http://huihui.cn/',
# Why: #4332 in Alexa global
'http://yingjiesheng.com/',
# Why: #4333 in Alexa global
'http://www.copacet.com/',
# Why: #4334 in Alexa global
'http://www.fluege.de/',
# Why: #4335 in Alexa global
'http://www.uiuc.edu/',
# Why: #4336 in Alexa global
'http://www.funnymama.com/',
# Why: #4337 in Alexa global
'http://www.main.jp/',
# Why: #4338 in Alexa global
'http://www.popsugar.com/',
# Why: #4339 in Alexa global
'http://www.siyahgazete.com/',
# Why: #4340 in Alexa global
'http://www.ligatus.com/',
# Why: #4342 in Alexa global
'http://www.seomastering.com/',
# Why: #4343 in Alexa global
'http://www.nintendo.com/',
# Why: #4344 in Alexa global
'http://www.kuaidi100.com/',
# Why: #4345 in Alexa global
'http://www.motor-talk.de/',
# Why: #4346 in Alexa global
'http://www.p.ht/',
# Why: #4347 in Alexa global
'http://www.care.com/',
# Why: #4348 in Alexa global
'http://www.ttnet.com.tr/',
# Why: #4349 in Alexa global
'http://www.cifraclub.com.br/',
# Why: #4350 in Alexa global
'http://www.yunfile.com/',
# Why: #4351 in Alexa global
'http://www.telechargement-de-ouf.fr/',
# Why: #4352 in Alexa global
'http://www.hotpornshow.com/',
# Why: #4353 in Alexa global
'http://www.jra.go.jp/',
# Why: #4354 in Alexa global
'http://www.upenn.edu/',
# Why: #4355 in Alexa global
'http://www.brg8.com/',
# Why: #4356 in Alexa global
'http://www.techspot.com/',
# Why: #4357 in Alexa global
'http://www.citytalk.tw/',
# Why: #4358 in Alexa global
'http://www.milli.az/',
# Why: #4359 in Alexa global
'http://www.segundamano.mx/',
# Why: #4360 in Alexa global
'http://www.n4g.com/',
# Why: #4361 in Alexa global
'http://www.blogspot.no/',
# Why: #4362 in Alexa global
'http://www.frys.com/',
# Why: #4363 in Alexa global
'http://www.pixhost.org/',
# Why: #4364 in Alexa global
'http://www.washington.edu/',
# Why: #4365 in Alexa global
'http://www.rte.ie/',
# Why: #4366 in Alexa global
'http://www.lockerdome.com/',
# Why: #4367 in Alexa global
'http://www.sblo.jp/',
# Why: #4368 in Alexa global
'http://www.qassimy.com/',
# Why: #4369 in Alexa global
'http://www.signup.wordpress.com/',
# Why: #4370 in Alexa global
'http://www.sochiset.com/',
# Why: #4371 in Alexa global
'http://www.mycokerewards.com/',
# Why: #4372 in Alexa global
'http://www.collegeboard.org/',
# Why: #4373 in Alexa global
'http://www.fengyunzhibo.com/',
# Why: #4374 in Alexa global
'http://www.twickerz.com/',
# Why: #4375 in Alexa global
'http://www.bikroy.com/',
# Why: #4376 in Alexa global
'http://www.apkmania.co/',
# Why: #4378 in Alexa global
'http://www.webrankstats.com/',
# Why: #4379 in Alexa global
'http://www.dl-protect.com/',
# Why: #4380 in Alexa global
'http://www.dr.dk/',
# Why: #4381 in Alexa global
'http://www.emoneyspace.com/',
# Why: #4382 in Alexa global
'http://www.zakzak.co.jp/',
# Why: #4383 in Alexa global
'http://www.rae.es/',
# Why: #4384 in Alexa global
'http://www.theexgirlfriends.com/',
# Why: #4385 in Alexa global
'http://www.gigaom.com/',
# Why: #4386 in Alexa global
'http://www.burmeseclassic.com/',
# Why: #4387 in Alexa global
'http://www.wisc.edu/',
# Why: #4388 in Alexa global
'http://www.ocnk.net/',
# Why: #4389 in Alexa global
'http://www.arcot.com/',
# Why: #4390 in Alexa global
'http://www.paginasamarillas.es/',
# Why: #4391 in Alexa global
'http://www.tunisia-sat.com/',
# Why: #4392 in Alexa global
'http://www.medscape.com/',
# Why: #4393 in Alexa global
'http://www.gameninja.com/',
# Why: #4394 in Alexa global
'http://www.imperiaonline.org/',
# Why: #4395 in Alexa global
'http://www.2ememain.be/',
# Why: #4396 in Alexa global
'http://www.myshopping.com.au/',
# Why: #4397 in Alexa global
'http://www.nvidia.com/',
# Why: #4398 in Alexa global
'http://fanhuan.com/',
# Why: #4399 in Alexa global
'http://www.vista.ir/',
# Why: #4400 in Alexa global
'http://www.dish.com/',
# Why: #4401 in Alexa global
'http://www.cartrade.com/',
# Why: #4402 in Alexa global
'http://www.egopay.com/',
# Why: #4403 in Alexa global
'http://www.sonyentertainmentnetwork.com/',
# Why: #4404 in Alexa global
'http://www.myway.com/',
# Why: #4405 in Alexa global
'http://www.kariyer.net/',
# Why: #4406 in Alexa global
'http://www.thanhnien.com.vn/',
# Why: #4407 in Alexa global
'http://www.gulfnews.com/',
# Why: #4409 in Alexa global
'http://www.flagcounter.com/',
# Why: #4410 in Alexa global
'http://www.yfrog.com/',
# Why: #4411 in Alexa global
'http://www.bigstockphoto.com/',
# Why: #4412 in Alexa global
'http://www.occ.com.mx/',
# Why: #4413 in Alexa global
'http://www.3911.net/',
# Why: #4414 in Alexa global
'http://naszemiasto.pl/',
# Why: #4415 in Alexa global
'http://www.pgatour.com/',
# Why: #4416 in Alexa global
'http://zgjrw.com/',
# Why: #4417 in Alexa global
'http://www.fdj.fr/',
# Why: #4418 in Alexa global
'http://www.motogp.com/',
# Why: #4419 in Alexa global
'http://www.organogold.com/',
# Why: #4420 in Alexa global
'http://www.tamindir.com/',
# Why: #4421 in Alexa global
'http://www.ykb.com/',
# Why: #4422 in Alexa global
'http://www.biglion.ru/',
# Why: #4423 in Alexa global
'http://www.yourfiledownloader.com/',
# Why: #4424 in Alexa global
'http://www.publika.az/',
# Why: #4425 in Alexa global
'http://www.dealnews.com/',
# Why: #4426 in Alexa global
'http://www.warnerbros.com/',
# Why: #4427 in Alexa global
'http://www.ne10.uol.com.br/',
# Why: #4428 in Alexa global
'http://www.wpmudev.org/',
# Why: #4429 in Alexa global
'http://autotimes.com.cn/',
# Why: #4430 in Alexa global
'http://www.pu-results.info/',
# Why: #4431 in Alexa global
'http://www.usajobs.gov/',
# Why: #4432 in Alexa global
'http://www.adsprofitwiz.es/',
# Why: #4433 in Alexa global
'http://www.parallels.com/',
# Why: #4434 in Alexa global
'http://www.thqafawe3lom.com/',
# Why: #4435 in Alexa global
'http://www.xiazaiba.com/',
# Why: #4436 in Alexa global
'http://www.enikos.gr/',
# Why: #4437 in Alexa global
'http://www.m5zn.com/',
# Why: #4438 in Alexa global
'http://www.dir.bg/',
# Why: #4439 in Alexa global
'http://www.ripoffreport.com/',
# Why: #4440 in Alexa global
'http://www.jusbrasil.com.br/',
# Why: #4441 in Alexa global
'http://www.maxifoot.fr/',
# Why: #4442 in Alexa global
'http://www.eva.vn/',
# Why: #4443 in Alexa global
'http://www.dfnhk8.net/',
# Why: #4444 in Alexa global
'http://www.api.ning.com/',
# Why: #4445 in Alexa global
'http://www.ligtv.com.tr/',
# Why: #4446 in Alexa global
'http://www.openrice.com/',
# Why: #4448 in Alexa global
'http://www.999120.net/',
# Why: #4449 in Alexa global
'http://www.pho.to/',
# Why: #4450 in Alexa global
'http://www.indiblogger.in/',
# Why: #4451 in Alexa global
'http://1hai.cn/',
# Why: #4452 in Alexa global
'http://www.jtb.co.jp/',
# Why: #4453 in Alexa global
'http://tfile.me/',
# Why: #4454 in Alexa global
'http://kotak.com/',
# Why: #4455 in Alexa global
'http://www.katproxy.com/',
# Why: #4456 in Alexa global
'http://www.calottery.com/',
# Why: #4457 in Alexa global
'http://www.klmty.net/',
# Why: #4458 in Alexa global
'http://www.endomondo.com/',
# Why: #4459 in Alexa global
'http://www.uploadboy.com/',
# Why: #4460 in Alexa global
'http://www.8tracks.com/',
# Why: #4461 in Alexa global
'http://www.toranoana.jp/',
# Why: #4462 in Alexa global
'http://www.blox.pl/',
# Why: #4463 in Alexa global
'http://www.conrad.de/',
# Why: #4464 in Alexa global
'http://www.sonico.com/',
# Why: #4465 in Alexa global
'http://www.windguru.cz/',
# Why: #4467 in Alexa global
'http://tinhte.vn/',
# Why: #4468 in Alexa global
'http://www.jorudan.co.jp/',
# Why: #4469 in Alexa global
'http://www.grantland.com/',
# Why: #4470 in Alexa global
'http://www.seratnews.ir/',
# Why: #4471 in Alexa global
'http://www.solomono.ru/',
# Why: #4472 in Alexa global
'http://www.foreca.com/',
# Why: #4473 in Alexa global
'http://www.ziprecruiter.com/',
# Why: #4474 in Alexa global
'http://www.chime.in/',
# Why: #4475 in Alexa global
'http://www.intesasanpaolo.com/',
# Why: #4476 in Alexa global
'http://www.softonic.de/',
# Why: #4477 in Alexa global
'http://www.adtech.info/',
# Why: #4478 in Alexa global
'http://www.appgame.com/',
# Why: #4479 in Alexa global
'http://www.opendns.com/',
# Why: #4480 in Alexa global
'http://www.tubekitty.com/',
# Why: #4481 in Alexa global
'http://www.linguee.de/',
# Why: #4482 in Alexa global
'http://www.pepperfry.com/',
# Why: #4483 in Alexa global
'http://www.egou.com/',
# Why: #4484 in Alexa global
'http://www.tweakers.net/',
# Why: #4485 in Alexa global
'http://alfavita.gr/',
# Why: #4486 in Alexa global
'http://www.plusnetwork.com/',
# Why: #4487 in Alexa global
'http://www.timeweb.ru/',
# Why: #4488 in Alexa global
'http://www.maybeporn.com/',
# Why: #4489 in Alexa global
'http://www.gharreh.com/',
# Why: #4490 in Alexa global
'http://www.canoe.ca/',
# Why: #4491 in Alexa global
'http://parsine.com/',
# Why: #4492 in Alexa global
'http://www.yto.net.cn/',
# Why: #4493 in Alexa global
'http://www.ucla.edu/',
# Why: #4494 in Alexa global
'http://www.freeridegames.com/',
# Why: #4495 in Alexa global
'http://www.doctoroz.com/',
# Why: #4496 in Alexa global
'http://www.tradeindia.com/',
# Why: #4497 in Alexa global
'http://www.socialmediabar.com/',
# Why: #4498 in Alexa global
'http://www.yaske.net/',
# Why: #4499 in Alexa global
'http://www.miniih.com/',
# Why: #4500 in Alexa global
'http://www.blog.me/',
# Why: #4501 in Alexa global
'http://www.dn.se/',
# Why: #4502 in Alexa global
'http://www.almos3a.com/',
# Why: #4503 in Alexa global
'http://www.bbvanet.com.mx/',
# Why: #4504 in Alexa global
'http://www.fcbarcelona.com/',
# Why: #4505 in Alexa global
'http://www.web.com/',
# Why: #4506 in Alexa global
'http://www.raaga.com/',
# Why: #4507 in Alexa global
'http://www.yad2.co.il/',
# Why: #4508 in Alexa global
'http://2cto.com/',
# Why: #4509 in Alexa global
'http://www.nx8.com/',
# Why: #4510 in Alexa global
'http://www.modcloth.com/',
# Why: #4511 in Alexa global
'http://www.carsales.com.au/',
# Why: #4512 in Alexa global
'http://www.cooks.com/',
# Why: #4513 in Alexa global
'http://www.fileswap.com/',
# Why: #4514 in Alexa global
'http://www.egyptiansnews.com/',
# Why: #4515 in Alexa global
'http://www.azyya.com/',
# Why: #4516 in Alexa global
'http://www.masreat.com/',
# Why: #4517 in Alexa global
'http://airliners.net/',
# Why: #4518 in Alexa global
'http://www.com-1b.info/',
# Why: #4519 in Alexa global
'http://www.virginmobileusa.com/',
# Why: #4520 in Alexa global
'http://www.pleasantharborrv.com/',
# Why: #4521 in Alexa global
'http://www.gsmhosting.com/',
# Why: #4522 in Alexa global
'http://www.foxbusiness.com/',
# Why: #4523 in Alexa global
'http://www.delfi.lv/',
# Why: #4524 in Alexa global
'http://www.flightaware.com/',
# Why: #4525 in Alexa global
'http://www.ameli.fr/',
# Why: #4526 in Alexa global
'http://fbxtk.com/',
# Why: #4527 in Alexa global
'http://www.purdue.edu/',
# Why: #4528 in Alexa global
'http://www.sbi.co.in/',
# Why: #4529 in Alexa global
'http://www.fotka.pl/',
# Why: #4530 in Alexa global
'http://www.quicksprout.com/',
# Why: #4531 in Alexa global
'http://www.arjwana.com/',
# Why: #4533 in Alexa global
'http://www.affili.net/',
# Why: #4535 in Alexa global
'http://www.5sing.com/',
# Why: #4536 in Alexa global
'http://www.mozilla.com/',
# Why: #4537 in Alexa global
'http://www.apk.tw/',
# Why: #4538 in Alexa global
'http://www.taaza.com/',
# Why: #4539 in Alexa global
'http://www.onetad.com/',
# Why: #4540 in Alexa global
'http://www.vivastreet.it/',
# Why: #4541 in Alexa global
'http://www.leguide.com/',
# Why: #4542 in Alexa global
'http://www.casualclub.com/',
# Why: #4543 in Alexa global
'http://www.wanelo.com/',
# Why: #4544 in Alexa global
'http://www.ipsosinteractive.com/',
# Why: #4545 in Alexa global
'http://www.videohive.net/',
# Why: #4546 in Alexa global
'http://www.fenzhi.com/',
# Why: #4547 in Alexa global
'http://www.lefrecce.it/',
# Why: #4548 in Alexa global
'http://www.bugun.com.tr/',
# Why: #4549 in Alexa global
'http://www.p30world.com/',
# Why: #4550 in Alexa global
'http://www.cuevana.tv/',
# Why: #4551 in Alexa global
'http://www.joins.com/',
# Why: #4552 in Alexa global
'http://www.tvnet.lv/',
# Why: #4553 in Alexa global
'http://aliimg.com/',
# Why: #4554 in Alexa global
'http://www.bellanaija.com/',
# Why: #4555 in Alexa global
'http://www.startpagina.nl/',
# Why: #4556 in Alexa global
'http://www.incometaxindiaefiling.gov.in/',
# Why: #4557 in Alexa global
'http://www.bellemaison.jp/',
# Why: #4558 in Alexa global
'http://www.michigan.gov/',
# Why: #4559 in Alexa global
'http://www.harborfreight.com/',
# Why: #4560 in Alexa global
'http://www.fineartamerica.com/',
# Why: #4561 in Alexa global
'http://www.mysurvey.com/',
# Why: #4562 in Alexa global
'http://www.kapaza.be/',
# Why: #4563 in Alexa global
'http://www.adxpansion.com/',
# Why: #4564 in Alexa global
'http://www.thefind.com/',
# Why: #4565 in Alexa global
'http://www.priyo.com/',
# Why: #4567 in Alexa global
'http://www.burrp.com/',
# Why: #4568 in Alexa global
'http://www.sky.it/',
# Why: #4569 in Alexa global
'http://www.ipad-winners.info/',
# Why: #4570 in Alexa global
'http://www.usgs.gov/',
# Why: #4571 in Alexa global
'http://www.gavick.com/',
# Why: #4572 in Alexa global
'http://www.ellislab.com/',
# Why: #4573 in Alexa global
'http://www.voegol.com.br/',
# Why: #4574 in Alexa global
'http://www.paginebianche.it/',
# Why: #4575 in Alexa global
'http://www.getwebcake.com/',
# Why: #4576 in Alexa global
'http://www.zeroredirect1.com/',
# Why: #4577 in Alexa global
'http://www.gaiaonline.com/',
# Why: #4578 in Alexa global
'http://iqilu.com/',
# Why: #4579 in Alexa global
'http://www.bright.com/',
# Why: #4580 in Alexa global
'http://www.comunidades.net/',
# Why: #4581 in Alexa global
'http://www.webgains.com/',
# Why: #4582 in Alexa global
'http://www.overdrive.com/',
# Why: #4583 in Alexa global
'http://www.bigcommerce.com/',
# Why: #4584 in Alexa global
'http://www.paperpkads.com/',
# Why: #4585 in Alexa global
'http://www.imageporter.com/',
# Why: #4586 in Alexa global
'http://www.lenovo.com.cn/',
# Why: #4587 in Alexa global
'http://www.listal.com/',
# Why: #4588 in Alexa global
'http://www.virgula.uol.com.br/',
# Why: #4589 in Alexa global
'http://www.rbcdaily.ru/',
# Why: #4590 in Alexa global
'http://www.redbus.in/',
# Why: #4591 in Alexa global
'http://www.3bmeteo.com/',
# Why: #4592 in Alexa global
'http://www.earn-on.com/',
# Why: #4593 in Alexa global
'http://www.ae.com/',
# Why: #4594 in Alexa global
'http://www.shoutmeloud.com/',
# Why: #4595 in Alexa global
'http://www.oeeee.com/',
# Why: #4596 in Alexa global
'http://www.usenet.nl/',
# Why: #4597 in Alexa global
'http://www.mediotiempo.com/',
# Why: #4599 in Alexa global
'http://www.prostoporno.net/',
# Why: #4600 in Alexa global
'http://www.bangyoulater.com/',
# Why: #4601 in Alexa global
'http://www.comunio.de/',
# Why: #4602 in Alexa global
'http://www.pureleads.com/',
# Why: #4603 in Alexa global
'http://www.bakeca.it/',
# Why: #4604 in Alexa global
'http://www.trovit.it/',
# Why: #4605 in Alexa global
'http://www.fakku.net/',
# Why: #4606 in Alexa global
'http://www.indeed.fr/',
# Why: #4607 in Alexa global
'http://www.inquisitr.com/',
# Why: #4608 in Alexa global
'http://www.wizards.com/',
# Why: #4609 in Alexa global
'http://www.straightdope.com/',
# Why: #4610 in Alexa global
'http://www.pornpros.com/',
# Why: #4611 in Alexa global
'http://www.s-oman.net/',
# Why: #4612 in Alexa global
'http://www.facilisimo.com/',
# Why: #4613 in Alexa global
'http://www.dostor.org/',
# Why: #4614 in Alexa global
'http://tabloidpulsa.co.id/',
# Why: #4615 in Alexa global
'http://www.shafaf.ir/',
# Why: #4616 in Alexa global
'http://www.bt.dk/',
# Why: #4617 in Alexa global
'http://www.lent.az/',
# Why: #4618 in Alexa global
'http://www.filmaffinity.com/',
# Why: #4619 in Alexa global
'http://www.wjunction.com/',
# Why: #4620 in Alexa global
'http://www.gamefront.com/',
# Why: #4621 in Alexa global
'http://www.photoshelter.com/',
# Why: #4622 in Alexa global
'http://www.cheaptickets.com/',
# Why: #4623 in Alexa global
'http://www.meetic.it/',
# Why: #4624 in Alexa global
'http://www.seochat.com/',
# Why: #4625 in Alexa global
'http://www.livemixtapes.com/',
# Why: #4626 in Alexa global
'http://www.deadline.com/',
# Why: #4627 in Alexa global
'http://www.boingboing.net/',
# Why: #4628 in Alexa global
'http://www.lecai.com/',
# Why: #4629 in Alexa global
'http://www.onetravel.com/',
# Why: #4631 in Alexa global
'http://www.erotictube.me/',
# Why: #4632 in Alexa global
'http://www.svd.se/',
# Why: #4633 in Alexa global
'http://www.pcadvisor.co.uk/',
# Why: #4634 in Alexa global
'http://www.pravda.com.ua/',
# Why: #4636 in Alexa global
'http://www.afisha.ru/',
# Why: #4637 in Alexa global
'http://www.dressupgamesite.com/',
# Why: #4638 in Alexa global
'http://www.mercadopago.com/',
# Why: #4640 in Alexa global
'http://www.bangkokpost.com/',
# Why: #4641 in Alexa global
'http://www.dumpert.nl/',
# Why: #4642 in Alexa global
'http://www.monotaro.com/',
# Why: #4643 in Alexa global
'http://www.bloomingdales.com/',
# Why: #4644 in Alexa global
'http://www.ebayclassifieds.com/',
# Why: #4645 in Alexa global
'http://www.t-online.hu/',
# Why: #4646 in Alexa global
'http://www.2dbook.com/',
# Why: #4647 in Alexa global
'http://www.golfdigest.co.jp/',
# Why: #4648 in Alexa global
'http://www.thekitchn.com/',
# Why: #4649 in Alexa global
'http://www.halifax.co.uk/',
# Why: #4650 in Alexa global
'http://www.tanx.com/',
# Why: #4651 in Alexa global
'http://www.jutarnji.hr/',
# Why: #4652 in Alexa global
'http://www.petardashd.com/',
# Why: #4653 in Alexa global
'http://www.rookee.ru/',
# Why: #4654 in Alexa global
'http://www.showroomprive.com/',
# Why: #4655 in Alexa global
'http://www.sharepoint.com/',
# Why: #4656 in Alexa global
'http://liebiao.com/',
# Why: #4657 in Alexa global
'http://www.miibeian.gov.cn/',
# Why: #4658 in Alexa global
'http://www.pumbaporn.com/',
# Why: #4659 in Alexa global
'http://www.dwnews.com/',
# Why: #4660 in Alexa global
'http://www.sanguosha.com/',
# Why: #4661 in Alexa global
'http://www.pp.cc/',
# Why: #4662 in Alexa global
'http://www.myfc.ir/',
# Why: #4663 in Alexa global
'http://www.alicdn.com/',
# Why: #4664 in Alexa global
'http://www.carmax.com/',
# Why: #4665 in Alexa global
'http://www.defencenet.gr/',
# Why: #4666 in Alexa global
'http://www.cuantarazon.com/',
# Why: #4667 in Alexa global
'http://www.westernunion.com/',
# Why: #4668 in Alexa global
'http://www.links.cn/',
# Why: #4669 in Alexa global
'http://www.natunbarta.com/',
# Why: #4670 in Alexa global
'http://www.sekindo.com/',
# Why: #4671 in Alexa global
'http://78.cn/',
# Why: #4672 in Alexa global
'http://www.edublogs.org/',
# Why: #4673 in Alexa global
'http://www.hotmail.com/',
# Why: #4674 in Alexa global
'http://www.problogger.net/',
# Why: #4675 in Alexa global
'http://www.amardeshonline.com/',
# Why: #4676 in Alexa global
'http://www.gemius.com/',
# Why: #4677 in Alexa global
'http://www.egynews.net/',
# Why: #4678 in Alexa global
'http://www.indiabix.com/',
# Why: #4679 in Alexa global
'http://www.provincial.com/',
# Why: #4680 in Alexa global
'http://www.play.com/',
# Why: #4681 in Alexa global
'http://www.beslist.nl/',
# Why: #4682 in Alexa global
'http://www.nttdocomo.co.jp/',
# Why: #4683 in Alexa global
'http://www.shape.com/',
# Why: #4684 in Alexa global
'http://www.alhilal.com/',
# Why: #4685 in Alexa global
'http://www.irecommend.ru/',
# Why: #4686 in Alexa global
'http://www.cmmnts.com/',
# Why: #4687 in Alexa global
'http://www.1news.az/',
# Why: #4688 in Alexa global
'http://www.kinobanda.net/',
# Why: #4689 in Alexa global
'http://www.banamex.com.mx/',
# Why: #4690 in Alexa global
'http://www.cleanfiles.net/',
# Why: #4691 in Alexa global
'http://www.algeriaforum.net/',
# Why: #4692 in Alexa global
'http://www.zumi.pl/',
# Why: #4693 in Alexa global
'http://www.giallozafferano.it/',
# Why: #4694 in Alexa global
'http://www.news-postseven.com/',
# Why: #4695 in Alexa global
'http://www.firstcry.com/',
# Why: #4696 in Alexa global
'http://www.mhlw.go.jp/',
# Why: #4697 in Alexa global
'http://www.lookforporn.com/',
# Why: #4698 in Alexa global
'http://www.xxsy.net/',
# Why: #4699 in Alexa global
'http://www.scriptmafia.org/',
# Why: #4700 in Alexa global
'http://www.intodns.com/',
# Why: #4701 in Alexa global
'http://www.famitsu.com/',
# Why: #4702 in Alexa global
'http://www.eclipse.org/',
# Why: #4704 in Alexa global
'http://www.net-a-porter.com/',
# Why: #4705 in Alexa global
'http://www.btemplates.com/',
# Why: #4706 in Alexa global
'http://www.topshop.com/',
# Why: #4707 in Alexa global
'http://www.myvidster.com/',
# Why: #4708 in Alexa global
'http://www.calciomercato.com/',
# Why: #4709 in Alexa global
'http://www.arabyonline.com/',
# Why: #4710 in Alexa global
'http://www.lesechos.fr/',
# Why: #4711 in Alexa global
'http://www.empireavenue.com/',
# Why: #4712 in Alexa global
'http://www.damnlol.com/',
# Why: #4713 in Alexa global
'http://www.nukistream.com/',
# Why: #4714 in Alexa global
'http://www.wayport.net/',
# Why: #4715 in Alexa global
'http://www.buienradar.nl/',
# Why: #4716 in Alexa global
'http://www.vivastreet.co.in/',
# Why: #4717 in Alexa global
'http://www.kroger.com/',
# Why: #4718 in Alexa global
'http://www.geocaching.com/',
# Why: #4719 in Alexa global
'http://www.hunantv.com/',
# Why: #4720 in Alexa global
'http://www.fotolog.net/',
# Why: #4721 in Alexa global
'http://www.gunbroker.com/',
# Why: #4722 in Alexa global
'http://www.flalottery.com/',
# Why: #4723 in Alexa global
'http://www.priples.com/',
# Why: #4724 in Alexa global
'http://www.nlayer.net/',
# Why: #4725 in Alexa global
'http://www.trafficshop.com/',
# Why: #4726 in Alexa global
'http://www.standardmedia.co.ke/',
# Why: #4727 in Alexa global
'http://www.finanzen.net/',
# Why: #4728 in Alexa global
'http://www.meta.ua/',
# Why: #4729 in Alexa global
'http://www.gfy.com/',
# Why: #4730 in Alexa global
'http://www.playground.ru/',
# Why: #4731 in Alexa global
'http://www.rp5.ru/',
# Why: #4732 in Alexa global
'http://otnnetwork.net/',
# Why: #4733 in Alexa global
'http://tvmao.com/',
# Why: #4734 in Alexa global
'http://www.hir.ma/',
# Why: #4735 in Alexa global
'http://www.twilightsex.com/',
# Why: #4736 in Alexa global
'http://www.haodou.com/',
# Why: #4737 in Alexa global
'http://www.virgin-atlantic.com/',
# Why: #4738 in Alexa global
'http://www.ankieta-online.pl/',
# Why: #4739 in Alexa global
'http://www.kinkytube.me/',
# Why: #4740 in Alexa global
'http://www.123mplayer.com/',
# Why: #4741 in Alexa global
'http://www.elifting.com/',
# Why: #4742 in Alexa global
'http://www.akiba-online.com/',
# Why: #4743 in Alexa global
'http://www.tcsbank.ru/',
# Why: #4744 in Alexa global
'http://www.gametrailers.com/',
# Why: #4745 in Alexa global
'http://www.dihitt.com/',
# Why: #4746 in Alexa global
'http://www.momoshop.com.tw/',
# Why: #4747 in Alexa global
'http://www.fancy.com/',
# Why: #4748 in Alexa global
'http://admaimai.com/',
# Why: #4749 in Alexa global
'http://www.61.com/',
# Why: #4750 in Alexa global
'http://www.hotchatdirect.com/',
# Why: #4751 in Alexa global
'http://www.penesalud.com/',
# Why: #4752 in Alexa global
'http://www.adsupplyads.com/',
# Why: #4753 in Alexa global
'http://www.robokassa.ru/',
# Why: #4754 in Alexa global
'http://www.brooonzyah.net/',
# Why: #4755 in Alexa global
'http://www.moviesmobile.net/',
# Why: #4756 in Alexa global
'http://www.fuck-mates.com/',
# Why: #4757 in Alexa global
'http://www.ch-news.com/',
# Why: #4758 in Alexa global
'http://www.cwan.com/',
# Why: #4759 in Alexa global
'http://enorth.com.cn/',
# Why: #4760 in Alexa global
'http://www.mec.gov.br/',
# Why: #4761 in Alexa global
'http://www.libertytimes.com.tw/',
# Why: #4762 in Alexa global
'http://www.musiciansfriend.com/',
# Why: #4763 in Alexa global
'http://www.angrybirds.com/',
# Why: #4764 in Alexa global
'http://www.ebrun.com/',
# Why: #4765 in Alexa global
'http://www.kienthuc.net.vn/',
# Why: #4766 in Alexa global
'http://www.morningstar.com/',
# Why: #4767 in Alexa global
'http://www.rasekhoon.net/',
# Why: #4768 in Alexa global
'http://www.techsmith.com/',
# Why: #4769 in Alexa global
'http://www.diy.com/',
# Why: #4770 in Alexa global
'http://www.awwwards.com/',
# Why: #4771 in Alexa global
'http://www.ajc.com/',
# Why: #4772 in Alexa global
'http://www.akismet.com/',
# Why: #4773 in Alexa global
'http://www.itar-tass.com/',
# Why: #4774 in Alexa global
'http://www.60secprofit.com/',
# Why: #4775 in Alexa global
'http://www.videoweed.es/',
# Why: #4776 in Alexa global
'http://www.life.com.tw/',
# Why: #4777 in Alexa global
'http://www.guitarcenter.com/',
# Why: #4778 in Alexa global
'http://www.tv2.dk/',
# Why: #4779 in Alexa global
'http://www.narutom.com/',
# Why: #4780 in Alexa global
'http://www.bittorrent.com/',
# Why: #4781 in Alexa global
'http://www.unionpaysecure.com/',
# Why: #4782 in Alexa global
'http://www.91jm.com/',
# Why: #4783 in Alexa global
'http://www.licindia.in/',
# Why: #4784 in Alexa global
'http://www.bama.ir/',
# Why: #4785 in Alexa global
'http://www.hertz.com/',
# Why: #4786 in Alexa global
'http://www.propertyguru.com.sg/',
# Why: #4787 in Alexa global
'http://city8.com/',
# Why: #4788 in Alexa global
'http://www.blu-ray.com/',
# Why: #4789 in Alexa global
'http://www.abebooks.com/',
# Why: #4790 in Alexa global
'http://www.adidas.com/',
# Why: #4791 in Alexa global
'http://www.weathernews.jp/',
# Why: #4792 in Alexa global
'http://www.sing365.com/',
# Why: #4793 in Alexa global
'http://www.qq163.com/',
# Why: #4794 in Alexa global
'http://www.fashionandyou.com/',
# Why: #4795 in Alexa global
'http://www.lietou.com/',
# Why: #4796 in Alexa global
'http://pia.jp/',
# Why: #4797 in Alexa global
'http://www.eniro.se/',
# Why: #4798 in Alexa global
'http://pengpeng.com/',
# Why: #4799 in Alexa global
'http://haibao.com/',
# Why: #4800 in Alexa global
'http://www.jxedt.com/',
# Why: #4801 in Alexa global
'http://www.crsky.com/',
# Why: #4802 in Alexa global
'http://www.nyu.edu/',
# Why: #4803 in Alexa global
'http://www.minecraftskins.com/',
# Why: #4804 in Alexa global
'http://yangtse.com/',
# Why: #4805 in Alexa global
'http://www.almstba.co/',
# Why: #4806 in Alexa global
'http://parsnews.com/',
# Why: #4807 in Alexa global
'http://www.twiends.com/',
# Why: #4808 in Alexa global
'http://www.dkb.de/',
# Why: #4809 in Alexa global
'http://www.friendscout24.de/',
# Why: #4810 in Alexa global
'http://www.aviny.com/',
# Why: #4811 in Alexa global
'http://www.dig.do/',
# Why: #4812 in Alexa global
'http://www.gamestorrents.com/',
# Why: #4813 in Alexa global
'http://www.guru.com/',
# Why: #4814 in Alexa global
'http://www.bostonglobe.com/',
# Why: #4815 in Alexa global
'http://www.brandalley.fr/',
# Why: #4816 in Alexa global
'http://www.tn.com.ar/',
# Why: #4817 in Alexa global
'http://www.yourwebsite.com/',
# Why: #4818 in Alexa global
'http://www.istgah.com/',
# Why: #4819 in Alexa global
'http://www.cib.com.cn/',
# Why: #4820 in Alexa global
'http://www.e-familynet.com/',
# Why: #4821 in Alexa global
'http://www.hotshame.com/',
# Why: #4822 in Alexa global
'http://www.volkskrant.nl/',
# Why: #4823 in Alexa global
'http://www.karnaval.com/',
# Why: #4824 in Alexa global
'http://www.team-bhp.com/',
# Why: #4825 in Alexa global
'http://www.sinemalar.com/',
# Why: #4826 in Alexa global
'http://www.ipko.pl/',
# Why: #4827 in Alexa global
'http://www.fastcompany.com/',
# Why: #4828 in Alexa global
'http://www.embedupload.com/',
# Why: #4829 in Alexa global
'http://www.gzmama.com/',
# Why: #4830 in Alexa global
'http://www.icicidirect.com/',
# Why: #4831 in Alexa global
'http://www.whatismyip.com/',
# Why: #4832 in Alexa global
'http://www.siasat.pk/',
# Why: #4833 in Alexa global
'http://www.rbi.org.in/',
# Why: #4834 in Alexa global
'http://www.amarillasinternet.com/',
# Why: #4835 in Alexa global
'http://www.netvasco.com.br/',
# Why: #4836 in Alexa global
'http://www.ctvnews.ca/',
# Why: #4837 in Alexa global
'http://www.gad.de/',
# Why: #4838 in Alexa global
'http://www.dailyfx.com/',
# Why: #4839 in Alexa global
'http://www.smartklicks.com/',
# Why: #4840 in Alexa global
'http://www.qoo10.sg/',
# Why: #4841 in Alexa global
'http://www.mlit.go.jp/',
# Why: #4842 in Alexa global
'http://www.cmbc.com.cn/',
# Why: #4843 in Alexa global
'http://www.loc.gov/',
# Why: #4845 in Alexa global
'http://www.playerflv.com/',
# Why: #4846 in Alexa global
'http://www.uta-net.com/',
# Why: #4847 in Alexa global
'http://www.afl.com.au/',
# Why: #4848 in Alexa global
'http://www.mainlink.ru/',
# Why: #4849 in Alexa global
'http://www.pricedekho.com/',
# Why: #4850 in Alexa global
'http://www.wickedfire.com/',
# Why: #4851 in Alexa global
'http://www.rlslog.net/',
# Why: #4852 in Alexa global
'http://www.raiffeisen.at/',
# Why: #4853 in Alexa global
'http://www.easports.com/',
# Why: #4854 in Alexa global
'http://www.groupon.fr/',
# Why: #4855 in Alexa global
'http://www.o2.co.uk/',
# Why: #4856 in Alexa global
'http://www.irangrand.ir/',
# Why: #4857 in Alexa global
'http://www.vuku.tv/',
# Why: #4858 in Alexa global
'http://www.play.pl/',
# Why: #4859 in Alexa global
'http://www.mxtoolbox.com/',
# Why: #4860 in Alexa global
'http://www.promiflash.de/',
# Why: #4861 in Alexa global
'http://www.linode.com/',
# Why: #4862 in Alexa global
'http://www.familysearch.org/',
# Why: #4863 in Alexa global
'http://www.publico.pt/',
# Why: #4864 in Alexa global
'http://www.freepornvideo.me/',
# Why: #4865 in Alexa global
'http://www.uploadbaz.com/',
# Why: #4866 in Alexa global
'http://www.tocmai.ro/',
# Why: #4867 in Alexa global
'http://www.cimbclicks.com.my/',
# Why: #4868 in Alexa global
'http://www.bestporntube.me/',
# Why: #4869 in Alexa global
'http://www.lainformacion.com/',
# Why: #4870 in Alexa global
'http://herschina.com/',
# Why: #4871 in Alexa global
'http://www.fontsquirrel.com/',
# Why: #4872 in Alexa global
'http://www.blip.tv/',
# Why: #4873 in Alexa global
'http://www.caranddriver.com/',
# Why: #4874 in Alexa global
'http://www.qld.gov.au/',
# Why: #4876 in Alexa global
'http://www.pons.eu/',
# Why: #4877 in Alexa global
'http://nascar.com/',
# Why: #4878 in Alexa global
'http://www.hrsmart.com/',
# Why: #4879 in Alexa global
'http://www.tripadvisor.com.au/',
# Why: #4880 in Alexa global
'http://www.hs.fi/',
# Why: #4881 in Alexa global
'http://www.auspost.com.au/',
# Why: #4882 in Alexa global
'http://www.sponsoredreviews.com/',
# Why: #4883 in Alexa global
'http://www.webopedia.com/',
# Why: #4884 in Alexa global
'http://www.sovsport.ru/',
# Why: #4885 in Alexa global
'http://www.firestorage.jp/',
# Why: #4886 in Alexa global
'http://www.bancsabadell.com/',
# Why: #4887 in Alexa global
'http://www.prettyporntube.com/',
# Why: #4888 in Alexa global
'http://www.sodahead.com/',
# Why: #4889 in Alexa global
'http://www.ovi.com/',
# Why: #4890 in Alexa global
'http://www.aleseriale.pl/',
# Why: #4891 in Alexa global
'http://www.mnwan.com/',
# Why: #4892 in Alexa global
'http://www.callofduty.com/',
# Why: #4893 in Alexa global
'http://www.sportskeeda.com/',
# Why: #4894 in Alexa global
'http://cp.cx/',
# Why: #4895 in Alexa global
'http://www.researchgate.net/',
# Why: #4896 in Alexa global
'http://www.michaels.com/',
# Why: #4897 in Alexa global
'http://www.createspace.com/',
# Why: #4898 in Alexa global
'http://www.sprintrade.com/',
# Why: #4899 in Alexa global
'http://www.anonymouse.org/',
# Why: #4900 in Alexa global
'http://www.hautelook.com/',
# Why: #4902 in Alexa global
'http://4gamer.net/',
# Why: #4903 in Alexa global
'http://www.accorhotels.com/',
# Why: #4904 in Alexa global
'http://www.roomkey.com/',
# Why: #4905 in Alexa global
'http://www.guildwars2.com/',
# Why: #4906 in Alexa global
'http://www.poco.cn/',
# Why: #4908 in Alexa global
'http://www.diamond.jp/',
# Why: #4909 in Alexa global
'http://www.cargurus.com/',
# Why: #4910 in Alexa global
'http://www.wpengine.com/',
# Why: #4911 in Alexa global
'http://www.iis.net/',
# Why: #4912 in Alexa global
'http://www.vendaria.com/',
# Why: #4913 in Alexa global
'http://www.argentinawarez.com/',
# Why: #4914 in Alexa global
'http://www.webdesigntunes.com/',
# Why: #4916 in Alexa global
'http://www.allvoices.com/',
# Why: #4917 in Alexa global
'http://www.eprize.com/',
# Why: #4918 in Alexa global
'http://www.pmu.fr/',
# Why: #4919 in Alexa global
'http://www.carrefour.fr/',
# Why: #4922 in Alexa global
'http://www.tax.gov.ir/',
# Why: #4924 in Alexa global
'http://www.ruelala.com/',
# Why: #4925 in Alexa global
'http://www.mainspy.ru/',
# Why: #4926 in Alexa global
'http://www.phpwind.net/',
# Why: #4927 in Alexa global
'http://www.loteriasyapuestas.es/',
# Why: #4928 in Alexa global
'http://www.musavat.com/',
# Why: #4929 in Alexa global
'http://www.lenskart.com/',
# Why: #4930 in Alexa global
'http://www.tv-asahi.co.jp/',
# Why: #4931 in Alexa global
'http://www.refinery29.com/',
# Why: #4932 in Alexa global
'http://www.888poker.es/',
# Why: #4933 in Alexa global
'http://www.denverpost.com/',
# Why: #4934 in Alexa global
'http://www.who.int/',
# Why: #4935 in Alexa global
'http://www.thesims3.com/',
# Why: #4936 in Alexa global
'http://www.jerkhour.com/',
# Why: #4937 in Alexa global
'http://www.lyricsmode.com/',
# Why: #4938 in Alexa global
'http://www.ivillage.com/',
# Why: #4939 in Alexa global
'http://qyer.com/',
# Why: #4940 in Alexa global
'http://www.hktdc.com/',
# Why: #4941 in Alexa global
'http://www.pornoload.com/',
# Why: #4942 in Alexa global
'http://www.bluedart.com/',
# Why: #4943 in Alexa global
'http://www.here.com/',
# Why: #4944 in Alexa global
'http://www.philips.com/',
# Why: #4945 in Alexa global
'http://www.dsebd.org/',
# Why: #4946 in Alexa global
'http://www.tubidy.mobi/',
# Why: #4947 in Alexa global
'http://www.stream.cz/',
# Why: #4948 in Alexa global
'http://www.infojobs.com.br/',
# Why: #4949 in Alexa global
'http://www.soft98.ir/',
# Why: #4950 in Alexa global
'http://www.bolsaparanovatos.com/',
# Why: #4951 in Alexa global
'http://www.mercador.ro/',
# Why: #4952 in Alexa global
'http://www.neogaf.com/',
# Why: #4953 in Alexa global
'http://www.yardbarker.com/',
# Why: #4954 in Alexa global
'http://www.rapidlibrary.com/',
# Why: #4955 in Alexa global
'http://www.xxeronetxx.info/',
# Why: #4956 in Alexa global
'http://www.kaiserpermanente.org/',
# Why: #4957 in Alexa global
'http://www.telstra.com.au/',
# Why: #4958 in Alexa global
'http://www.contra.gr/',
# Why: #4959 in Alexa global
'http://www.laredoute.it/',
# Why: #4960 in Alexa global
'http://www.lipsum.com/',
# Why: #4961 in Alexa global
'http://www.twitlonger.com/',
# Why: #4962 in Alexa global
'http://www.hln.be/',
# Why: #4963 in Alexa global
'http://www.53kf.com/',
# Why: #4964 in Alexa global
'http://www.gofundme.com/',
# Why: #4965 in Alexa global
'http://www.carigold.com/',
# Why: #4966 in Alexa global
'http://www.clips4sale.com/',
# Why: #4967 in Alexa global
'http://www.focalprice.com/',
# Why: #4968 in Alexa global
'http://www.1111.com.tw/',
# Why: #4969 in Alexa global
'http://www.gameaholic.com/',
# Why: #4970 in Alexa global
'http://www.presstv.ir/',
# Why: #4971 in Alexa global
'http://www.puu.sh/',
# Why: #4973 in Alexa global
'http://www.filmlinks4u.net/',
# Why: #4974 in Alexa global
'http://www.traffic-delivery.com/',
# Why: #4975 in Alexa global
'http://www.bebo.com/',
# Why: #4976 in Alexa global
'http://enter.ru/',
# Why: #4977 in Alexa global
'http://www.shufoo.net/',
# Why: #4978 in Alexa global
'http://www.vivo.com.br/',
# Why: #4979 in Alexa global
'http://www.jizzhut.com/',
# Why: #4980 in Alexa global
'http://www.1jux.net/',
# Why: #4981 in Alexa global
'http://www.serebii.net/',
# Why: #4982 in Alexa global
'http://www.translate.ru/',
# Why: #4983 in Alexa global
'http://www.mtv3.fi/',
# Why: #4984 in Alexa global
'http://www.njuskalo.hr/',
# Why: #4985 in Alexa global
'http://www.bell.ca/',
# Why: #4986 in Alexa global
'http://www.myheritage.com/',
# Why: #4987 in Alexa global
'http://www.cic.fr/',
# Why: #4988 in Alexa global
'http://www.mercurynews.com/',
# Why: #4989 in Alexa global
'http://www.alaan.tv/',
# Why: #4990 in Alexa global
'http://www.econsultancy.com/',
# Why: #4991 in Alexa global
'http://www.pornhost.com/',
# Why: #4992 in Alexa global
'http://www.a8.net/',
# Why: #4994 in Alexa global
'http://www.netzero.net/',
# Why: #4995 in Alexa global
'http://www.tracklab101.com/',
# Why: #4996 in Alexa global
'http://www.spanishdict.com/',
# Why: #4997 in Alexa global
'http://www.amctv.com/',
# Why: #4998 in Alexa global
'http://www.erepublik.com/',
# Why: #4999 in Alexa global
'http://www.mk.ru/',
# Why: #5000 in Alexa global
'http://www.publico.es/',
# Why: #5001 in Alexa global
'http://www.newegg.com.cn/',
# Why: #5002 in Alexa global
'http://www.fux.com/',
# Why: #5003 in Alexa global
'http://www.webcamtoy.com/',
# Why: #5004 in Alexa global
'http://www.rahnama.com/',
# Why: #5005 in Alexa global
'http://www.wanyh.com/',
# Why: #5006 in Alexa global
'http://www.ecplaza.net/',
# Why: #5007 in Alexa global
'http://www.mol.gov.sa/',
# Why: #5008 in Alexa global
'http://www.torrentday.com/',
# Why: #5009 in Alexa global
'http://www.hsbc.com.br/',
# Why: #5010 in Alexa global
'http://www.interoperabilitybridges.com/',
# Why: #5011 in Alexa global
'http://www.billmelater.com/',
# Why: #5012 in Alexa global
'http://www.speedanalysis.com/',
# Why: #5013 in Alexa global
'http://www.volusion.com/',
# Why: #5014 in Alexa global
'http://www.mixcloud.com/',
# Why: #5015 in Alexa global
'http://www.weeronline.nl/',
# Why: #5016 in Alexa global
'http://www.tiancity.com/',
# Why: #5017 in Alexa global
'http://www.thehun.com/',
# Why: #5018 in Alexa global
'http://www.comparisons.org/',
# Why: #5019 in Alexa global
'http://www.eurosport.ru/',
# Why: #5020 in Alexa global
'http://www.trendyol.com/',
# Why: #5021 in Alexa global
'http://www.7120.com/',
# Why: #5022 in Alexa global
'http://www.eldiariodeamerica.com/',
# Why: #5023 in Alexa global
'http://www.fap8.com/',
# Why: #5024 in Alexa global
'http://www.joyme.com/',
# Why: #5025 in Alexa global
'http://www.ufl.edu/',
# Why: #5026 in Alexa global
'http://www.cuantocabron.com/',
# Why: #5027 in Alexa global
'http://www.hotmart.com.br/',
# Why: #5028 in Alexa global
'http://www.wolframalpha.com/',
# Why: #5029 in Alexa global
'http://www.cpasbien.com/',
# Why: #5030 in Alexa global
'http://www.sanalpazar.com/',
# Why: #5031 in Alexa global
'http://www.publipt.com/',
# Why: #5032 in Alexa global
'http://www.9ku.com/',
# Why: #5033 in Alexa global
'http://www.officemax.com/',
# Why: #5034 in Alexa global
'http://www.cuny.edu/',
# Why: #5035 in Alexa global
'http://www.gem.pl/',
# Why: #5036 in Alexa global
'http://www.waelelebrashy.com/',
# Why: #5037 in Alexa global
'http://www.coinmill.com/',
# Why: #5038 in Alexa global
'http://www.bet.com/',
# Why: #5039 in Alexa global
'http://www.moskva.fm/',
# Why: #5040 in Alexa global
'http://www.groupalia.com/',
# Why: #5041 in Alexa global
'http://131.com/',
# Why: #5042 in Alexa global
'http://www.pichak.net/',
# Why: #5043 in Alexa global
'http://www.theatlanticwire.com/',
# Why: #5044 in Alexa global
'http://tokyo-sports.co.jp/',
# Why: #5045 in Alexa global
'http://www.laptopmag.com/',
# Why: #5046 in Alexa global
'http://www.worldpay.com/',
# Why: #5047 in Alexa global
'http://www.groupon.pl/',
# Why: #5048 in Alexa global
'http://www.imeimama.com/',
# Why: #5049 in Alexa global
'http://www.torrents.net/',
# Why: #5051 in Alexa global
'http://www.britishcouncil.org/',
# Why: #5052 in Alexa global
'http://www.letsbonus.com/',
# Why: #5053 in Alexa global
'http://www.e-monsite.com/',
# Why: #5054 in Alexa global
'http://www.url.org/',
# Why: #5055 in Alexa global
'http://www.discuz.com/',
# Why: #5056 in Alexa global
'http://www.freepornsite.me/',
# Why: #5057 in Alexa global
'http://www.cheatcc.com/',
# Why: #5058 in Alexa global
'http://www.magicmovies.com/',
# Why: #5059 in Alexa global
'http://www.laterooms.com/',
# Why: #5060 in Alexa global
'http://www.du.ac.in/',
# Why: #5062 in Alexa global
'http://www.uservoice.com/',
# Why: #5063 in Alexa global
'http://www.discas.net/',
# Why: #5064 in Alexa global
'http://www.d1g.com/',
# Why: #5065 in Alexa global
'http://www.explicittube.com/',
# Why: #5066 in Alexa global
'http://www.e-autopay.com/',
# Why: #5067 in Alexa global
'http://3lian.com/',
# Why: #5068 in Alexa global
'http://www.oopsmovs.com/',
# Why: #5069 in Alexa global
'http://www.agenziaentrate.gov.it/',
# Why: #5070 in Alexa global
'http://www.ufc.com/',
# Why: #5071 in Alexa global
'http://www.mooshare.biz/',
# Why: #5072 in Alexa global
'http://www.ankang06.org/',
# Why: #5073 in Alexa global
'http://www.betradar.com/',
# Why: #5074 in Alexa global
'http://www.explosm.net/',
# Why: #5075 in Alexa global
'http://www.silkroad.com/',
# Why: #5076 in Alexa global
'http://www.crackberry.com/',
# Why: #5078 in Alexa global
'http://www.toyota.com/',
# Why: #5079 in Alexa global
'http://www.bongda.com.vn/',
# Why: #5080 in Alexa global
'http://www.europapress.es/',
# Why: #5081 in Alexa global
'http://www.mlxchange.com/',
# Why: #5082 in Alexa global
'http://www.plius.lt/',
# Why: #5083 in Alexa global
'http://www.pitchfork.com/',
# Why: #5084 in Alexa global
'http://www.groupon.de/',
# Why: #5085 in Alexa global
'http://www.hollisterco.com/',
# Why: #5086 in Alexa global
'http://www.hasoffers.com/',
# Why: #5087 in Alexa global
'http://www.miami.com/',
# Why: #5089 in Alexa global
'http://www.dslreports.com/',
# Why: #5090 in Alexa global
'http://www.blinkweb.com/',
# Why: #5091 in Alexa global
'http://www.alamaula.com/',
# Why: #5092 in Alexa global
'http://www.leonardo.it/',
# Why: #5093 in Alexa global
'http://www.very.co.uk/',
# Why: #5094 in Alexa global
'http://www.globalsources.com/',
# Why: #5095 in Alexa global
'http://www.viator.com/',
# Why: #5096 in Alexa global
'http://www.greenwichmeantime.com/',
# Why: #5097 in Alexa global
'http://www.appannie.com/',
# Why: #5099 in Alexa global
'http://www.eldorado.ru/',
# Why: #5100 in Alexa global
'http://www.canadiantire.ca/',
# Why: #5101 in Alexa global
'http://www.enjin.com/',
# Why: #5102 in Alexa global
'http://szhome.com/',
# Why: #5103 in Alexa global
'http://www.news-us.jp/',
# Why: #5104 in Alexa global
'http://www.phim3s.net/',
# Why: #5105 in Alexa global
'http://www.bash.im/',
# Why: #5106 in Alexa global
'http://www.immi.gov.au/',
# Why: #5107 in Alexa global
'http://www.cwb.gov.tw/',
# Why: #5108 in Alexa global
'http://www.enjoydressup.com/',
# Why: #5109 in Alexa global
'http://www.thesuperficial.com/',
# Why: #5110 in Alexa global
'http://www.bunshun.jp/',
# Why: #5111 in Alexa global
'http://www.91mobiles.com/',
# Why: #5112 in Alexa global
'http://www.libertaddigital.com/',
# Why: #5113 in Alexa global
'http://www.po-kaki-to.com/',
# Why: #5114 in Alexa global
'http://www.truelocal.com.au/',
# Why: #5115 in Alexa global
'http://www.centrum24.pl/',
# Why: #5116 in Alexa global
'http://www.zylom.com/',
# Why: #5117 in Alexa global
'http://www.mypornmotion.com/',
# Why: #5118 in Alexa global
'http://www.skybet.com/',
# Why: #5119 in Alexa global
'http://www.soccermanager.com/',
# Why: #5120 in Alexa global
'http://www.styleauto.com.cn/',
# Why: #5121 in Alexa global
'http://www.poriborton.com/',
# Why: #5122 in Alexa global
'http://www.mozzi.com/',
# Why: #5123 in Alexa global
'http://www.eset.com/',
# Why: #5124 in Alexa global
'http://www.chelseafc.com/',
# Why: #5125 in Alexa global
'http://www.amulyam.in/',
# Why: #5126 in Alexa global
'http://www.argaam.com/',
# Why: #5127 in Alexa global
'http://www.mnn.com/',
# Why: #5128 in Alexa global
'http://www.papystreaming.com/',
# Why: #5129 in Alexa global
'http://www.hostelbookers.com/',
# Why: #5130 in Alexa global
'http://www.vatera.hu/',
# Why: #5131 in Alexa global
'http://www.pciconcursos.com.br/',
# Why: #5132 in Alexa global
'http://www.milenio.com/',
# Why: #5133 in Alexa global
'http://www.yellowbook.com/',
# Why: #5134 in Alexa global
'http://www.mobilepriceindia.co.in/',
# Why: #5135 in Alexa global
'http://www.naked.com/',
# Why: #5136 in Alexa global
'http://www.lazada.vn/',
# Why: #5137 in Alexa global
'http://www.70e.com/',
# Why: #5138 in Alexa global
'http://www.mapy.cz/',
# Why: #5139 in Alexa global
'http://www.vodafone.es/',
# Why: #5140 in Alexa global
'http://www.zbiornik.com/',
# Why: #5142 in Alexa global
'http://www.fc2web.com/',
# Why: #5143 in Alexa global
'http://www.rghost.ru/',
# Why: #5144 in Alexa global
'http://www.avvo.com/',
# Why: #5145 in Alexa global
'http://www.fardanews.com/',
# Why: #5146 in Alexa global
'http://www.pcbeta.com/',
# Why: #5147 in Alexa global
'http://www.hibapress.com/',
# Why: #5148 in Alexa global
'http://www.gamehouse.com/',
# Why: #5149 in Alexa global
'http://www.macworld.com/',
# Why: #5150 in Alexa global
'http://www.qantas.com.au/',
# Why: #5151 in Alexa global
'http://www.dba.dk/',
# Why: #5152 in Alexa global
'http://www.inttrax.com/',
# Why: #5153 in Alexa global
'http://www.conejox.com/',
# Why: #5154 in Alexa global
'http://www.immobiliare.it/',
# Why: #5155 in Alexa global
'http://www.sparkasse.at/',
# Why: #5156 in Alexa global
'http://www.udemy.com/',
# Why: #5157 in Alexa global
'http://www.accenture.com/',
# Why: #5158 in Alexa global
'http://www.pokerstrategy.com/',
# Why: #5159 in Alexa global
'http://www.leroymerlin.fr/',
# Why: #5160 in Alexa global
'http://www.sweetkiss.me/',
# Why: #5161 in Alexa global
'http://www.siriusxm.com/',
# Why: #5162 in Alexa global
'http://www.nieuwsblad.be/',
# Why: #5163 in Alexa global
'http://www.blogun.ru/',
# Why: #5164 in Alexa global
'http://www.ojogos.com.br/',
# Why: #5165 in Alexa global
'http://www.lexilogos.com/',
# Why: #5166 in Alexa global
'http://www.c-and-a.com/',
# Why: #5167 in Alexa global
'http://www.authorstream.com/',
# Why: #5168 in Alexa global
'http://www.newser.com/',
# Why: #5169 in Alexa global
'http://www.minube.com/',
# Why: #5170 in Alexa global
'http://www.lawtime.cn/',
# Why: #5171 in Alexa global
'http://www.yellowpages.com.au/',
# Why: #5172 in Alexa global
'http://www.torrentfreak.com/',
# Why: #5173 in Alexa global
'http://www.expatriates.com/',
# Why: #5174 in Alexa global
'http://51credit.com/',
# Why: #5175 in Alexa global
'http://www.rawstory.com/',
# Why: #5176 in Alexa global
'http://www.crictime.com/',
# Why: #5177 in Alexa global
'http://www.ladolcevitae.com/',
# Why: #5178 in Alexa global
'http://www.astro.com/',
# Why: #5179 in Alexa global
'http://www.riverisland.com/',
# Why: #5180 in Alexa global
'http://www.myzamana.com/',
# Why: #5181 in Alexa global
'http://www.xpg.com.br/',
# Why: #5182 in Alexa global
'http://www.svt.se/',
# Why: #5183 in Alexa global
'http://www.ymlp.com/',
# Why: #5184 in Alexa global
'http://www.coupondunia.in/',
# Why: #5185 in Alexa global
'http://www.mymovies.it/',
# Why: #5186 in Alexa global
'http://www.portaleducacao.com.br/',
# Why: #5187 in Alexa global
'http://watchabc.go.com/',
# Why: #5188 in Alexa global
'http://www.scrabblefinder.com/',
# Why: #5189 in Alexa global
'http://www.2hua.com/',
# Why: #5190 in Alexa global
'http://www.guiaconsumidor.com/',
# Why: #5191 in Alexa global
'http://jzpt.com/',
# Why: #5192 in Alexa global
'http://www.jino.ru/',
# Why: #5193 in Alexa global
'http://www.google.tt/',
# Why: #5194 in Alexa global
'http://www.addwallet.com/',
# Why: #5195 in Alexa global
'http://www.enom.com/',
# Why: #5197 in Alexa global
'http://www.searchfreemp3.com/',
# Why: #5198 in Alexa global
'http://www.spox.com/',
# Why: #5199 in Alexa global
'http://www.ename.net/',
# Why: #5200 in Alexa global
'http://www.researchnow.com/',
# Why: #5201 in Alexa global
'http://www.decathlon.fr/',
# Why: #5202 in Alexa global
'http://www.j-cast.com/',
# Why: #5203 in Alexa global
'http://www.updatetube.com/',
# Why: #5204 in Alexa global
'http://www.polo.com/',
# Why: #5205 in Alexa global
'http://www.asiaone.com/',
# Why: #5206 in Alexa global
'http://www.kkiste.to/',
# Why: #5207 in Alexa global
'http://www.frmtr.com/',
# Why: #5208 in Alexa global
'http://www.skai.gr/',
# Why: #5209 in Alexa global
'http://www.zovi.com/',
# Why: #5210 in Alexa global
'http://www.qiwi.ru/',
# Why: #5211 in Alexa global
'http://www.stfucollege.com/',
# Why: #5212 in Alexa global
'http://www.carros.com.br/',
# Why: #5213 in Alexa global
'http://www.privatejobshub.blogspot.in/',
# Why: #5214 in Alexa global
'http://www.englishtown.com/',
# Why: #5215 in Alexa global
'http://www.info.com/',
# Why: #5216 in Alexa global
'http://www.multiclickbrasil.com.br/',
# Why: #5217 in Alexa global
'http://www.gazeteoku.com/',
# Why: #5218 in Alexa global
'http://www.kinghost.com/',
# Why: #5219 in Alexa global
'http://www.izismile.com/',
# Why: #5220 in Alexa global
'http://www.gopro.com/',
# Why: #5221 in Alexa global
'http://www.uspto.gov/',
# Why: #5222 in Alexa global
'http://www.testberichte.de/',
# Why: #5223 in Alexa global
'http://www.fs.to/',
# Why: #5224 in Alexa global
'http://www.sketchtoy.com/',
# Why: #5225 in Alexa global
'http://www.sinarharian.com.my/',
# Why: #5226 in Alexa global
'http://www.stylemode.com/',
# Why: #5227 in Alexa global
'http://www.v7n.com/',
# Why: #5228 in Alexa global
'http://www.livenation.com/',
# Why: #5229 in Alexa global
'http://www.firstrow1.eu/',
# Why: #5230 in Alexa global
'http://www.joomlaforum.ru/',
# Why: #5231 in Alexa global
'http://www.sharecare.com/',
# Why: #5232 in Alexa global
'http://www.vetogate.com/',
# Why: #5233 in Alexa global
'http://www.series.ly/',
# Why: #5234 in Alexa global
'http://www.property24.com/',
# Why: #5235 in Alexa global
'http://www.payamsara.com/',
# Why: #5236 in Alexa global
'http://www.webstarts.com/',
# Why: #5237 in Alexa global
'http://www.renfe.es/',
# Why: #5238 in Alexa global
'http://www.fatcow.com/',
# Why: #5239 in Alexa global
'http://www.24ur.com/',
# Why: #5240 in Alexa global
'http://www.lide.cz/',
# Why: #5241 in Alexa global
'http://www.sabayacafe.com/',
# Why: #5242 in Alexa global
'http://www.prodavalnik.com/',
# Why: #5243 in Alexa global
'http://www.hyves.nl/',
# Why: #5244 in Alexa global
'http://www.groupon.jp/',
# Why: #5245 in Alexa global
'http://www.almaany.com/',
# Why: #5246 in Alexa global
'http://www.xero.com/',
# Why: #5247 in Alexa global
'http://www.celluway.com/',
# Why: #5248 in Alexa global
'http://www.mapbar.com/',
# Why: #5249 in Alexa global
'http://www.vecernji.hr/',
# Why: #5250 in Alexa global
'http://www.konga.com/',
# Why: #5251 in Alexa global
'http://www.fresherslive.com/',
# Why: #5252 in Alexa global
'http://www.nova.cz/',
# Why: #5253 in Alexa global
'http://www.onlinefwd.com/',
# Why: #5254 in Alexa global
'http://www.petco.com/',
# Why: #5255 in Alexa global
'http://www.benisonapparel.com/',
# Why: #5256 in Alexa global
'http://www.jango.com/',
# Why: #5257 in Alexa global
'http://mangocity.com/',
# Why: #5258 in Alexa global
'http://www.gamefly.com/',
# Why: #5259 in Alexa global
'http://www.igma.tv/',
# Why: #5260 in Alexa global
'http://www.21cineplex.com/',
# Why: #5261 in Alexa global
'http://www.fblife.com/',
# Why: #5262 in Alexa global
'http://www.moe.gov.eg/',
# Why: #5263 in Alexa global
'http://www.heydouga.com/',
# Why: #5264 in Alexa global
'http://buildhr.com/',
# Why: #5265 in Alexa global
'http://www.mmo-champion.com/',
# Why: #5266 in Alexa global
'http://www.ithome.com/',
# Why: #5267 in Alexa global
'http://www.krakow.pl/',
# Why: #5268 in Alexa global
'http://www.history.com/',
# Why: #5269 in Alexa global
'http://www.jc001.cn/',
# Why: #5270 in Alexa global
'http://www.privatehomeclips.com/',
# Why: #5271 in Alexa global
'http://www.wasu.cn/',
# Why: #5272 in Alexa global
'http://www.bazos.cz/',
# Why: #5273 in Alexa global
'http://www.appchina.com/',
# Why: #5274 in Alexa global
'http://www.helpster.de/',
# Why: #5275 in Alexa global
'http://www.51hejia.com/',
# Why: #5276 in Alexa global
'http://www.fuckbadbitches.com/',
# Why: #5277 in Alexa global
'http://www.toyota-autocenter.com/',
# Why: #5278 in Alexa global
'http://www.alnaharegypt.com/',
# Why: #5280 in Alexa global
'http://www.eastbay.com/',
# Why: #5281 in Alexa global
'http://www.softonic.com.br/',
# Why: #5282 in Alexa global
'http://www.translit.ru/',
# Why: #5283 in Alexa global
'http://www.justcloud.com/',
# Why: #5284 in Alexa global
'http://www.validclick.net/',
# Why: #5285 in Alexa global
'http://www.seneweb.com/',
# Why: #5286 in Alexa global
'http://www.fsiblog.com/',
# Why: #5287 in Alexa global
'http://www.williamhill.it/',
# Why: #5288 in Alexa global
'http://www.twitchy.com/',
# Why: #5289 in Alexa global
'http://www.y4yy.com/',
# Why: #5290 in Alexa global
'http://www.gouv.qc.ca/',
# Why: #5291 in Alexa global
'http://www.nubiles.net/',
# Why: #5292 in Alexa global
'http://www.marvel.com/',
# Why: #5293 in Alexa global
'http://www.helpmefindyour.info/',
# Why: #5294 in Alexa global
'http://www.tripadvisor.ca/',
# Why: #5295 in Alexa global
'http://www.joomlart.com/',
# Why: #5296 in Alexa global
'http://www.m18.com/',
# Why: #5297 in Alexa global
'http://www.orgasmatrix.com/',
# Why: #5298 in Alexa global
'http://www.bidoo.com/',
# Why: #5299 in Alexa global
'http://www.rogers.com/',
# Why: #5300 in Alexa global
'http://www.informationng.com/',
# Why: #5301 in Alexa global
'http://www.voyage-prive.com/',
# Why: #5302 in Alexa global
'http://www.comingsoon.net/',
# Why: #5303 in Alexa global
'http://www.searchmetrics.com/',
# Why: #5304 in Alexa global
'http://www.jetztspielen.de/',
# Why: #5305 in Alexa global
'http://www.mathxl.com/',
# Why: #5306 in Alexa global
'http://www.telmex.com/',
# Why: #5307 in Alexa global
'http://www.purpleporno.com/',
# Why: #5308 in Alexa global
'http://www.coches.net/',
# Why: #5309 in Alexa global
'http://hamusoku.com/',
# Why: #5310 in Alexa global
'http://www.link-assistant.com/',
# Why: #5311 in Alexa global
'http://www.gosur.com/',
# Why: #5312 in Alexa global
'http://www.torrentcrazy.com/',
# Why: #5313 in Alexa global
'http://www.funny-games.biz/',
# Why: #5314 in Alexa global
'http://www.bseindia.com/',
# Why: #5315 in Alexa global
'http://www.promosite.ru/',
# Why: #5316 in Alexa global
'http://www.google.mn/',
# Why: #5317 in Alexa global
'http://www.cartoonnetworkarabic.com/',
# Why: #5318 in Alexa global
'http://www.icm.edu.pl/',
# Why: #5319 in Alexa global
'http://ttt4.com/',
# Why: #5321 in Alexa global
'http://www.pepperjamnetwork.com/',
# Why: #5322 in Alexa global
'http://www.lolzbook.com/',
# Why: #5323 in Alexa global
'http://www.nationalpost.com/',
# Why: #5324 in Alexa global
'http://www.tukif.com/',
# Why: #5325 in Alexa global
'http://www.club-asteria.com/',
# Why: #5326 in Alexa global
'http://www.7search.com/',
# Why: #5327 in Alexa global
'http://www.kasikornbank.com/',
# Why: #5328 in Alexa global
'http://www.ebay.ie/',
# Why: #5329 in Alexa global
'http://www.sexlunch.com/',
# Why: #5330 in Alexa global
'http://www.qype.com/',
# Why: #5331 in Alexa global
'http://www.sankakucomplex.com/',
# Why: #5333 in Alexa global
'http://www.flashback.org/',
# Why: #5334 in Alexa global
'http://www.streamhunter.eu/',
# Why: #5335 in Alexa global
'http://www.rsb.ru/',
# Why: #5336 in Alexa global
'http://www.royalporntube.com/',
# Why: #5337 in Alexa global
'http://www.diretta.it/',
# Why: #5338 in Alexa global
'http://www.yummly.com/',
# Why: #5339 in Alexa global
'http://www.dom2.ru/',
# Why: #5340 in Alexa global
'http://www.2144.cn/',
# Why: #5341 in Alexa global
'http://www.metoffice.gov.uk/',
# Why: #5342 in Alexa global
'http://www.goodbaby.com/',
# Why: #5343 in Alexa global
'http://www.pornbb.org/',
# Why: #5344 in Alexa global
'http://www.formspring.me/',
# Why: #5345 in Alexa global
'http://www.google.com.cy/',
# Why: #5346 in Alexa global
'http://www.purepeople.com/',
# Why: #5347 in Alexa global
'http://www.epnet.com/',
# Why: #5348 in Alexa global
'http://www.penny-arcade.com/',
# Why: #5349 in Alexa global
'http://www.onlinekhabar.com/',
# Why: #5350 in Alexa global
'http://www.vcommission.com/',
# Why: #5351 in Alexa global
'http://www.zimabdk.com/',
# Why: #5352 in Alexa global
'http://www.car.gr/',
# Why: #5353 in Alexa global
'http://www.wat.tv/',
# Why: #5354 in Alexa global
'http://www.nnn.ru/',
# Why: #5355 in Alexa global
'http://www.arvixe.com/',
# Why: #5356 in Alexa global
'http://www.buxp.org/',
# Why: #5357 in Alexa global
'http://www.shaw.ca/',
# Why: #5358 in Alexa global
'http://cnyes.com/',
# Why: #5359 in Alexa global
'http://www.casa.it/',
# Why: #5360 in Alexa global
'http://233.com/',
# Why: #5361 in Alexa global
'http://www.text.ru/',
# Why: #5362 in Alexa global
'http://www.800notes.com/',
# Why: #5363 in Alexa global
'http://www.banki.ru/',
# Why: #5364 in Alexa global
'http://www.marinetraffic.com/',
# Why: #5365 in Alexa global
'http://www.meteo.gr/',
# Why: #5366 in Alexa global
'http://www.thetrainline.com/',
# Why: #5367 in Alexa global
'http://www.blogspot.ch/',
# Why: #5368 in Alexa global
'http://www.netaffiliation.com/',
# Why: #5370 in Alexa global
'http://www.olx.co.id/',
# Why: #5371 in Alexa global
'http://www.slando.kz/',
# Why: #5372 in Alexa global
'http://www.nordea.se/',
# Why: #5373 in Alexa global
'http://www.xbabe.com/',
# Why: #5374 in Alexa global
'http://www.bibsonomy.org/',
# Why: #5375 in Alexa global
'http://www.moneynews.com/',
# Why: #5376 in Alexa global
'http://265g.com/',
# Why: #5377 in Alexa global
'http://www.horoscope.com/',
# Why: #5378 in Alexa global
'http://www.home.ne.jp/',
# Why: #5379 in Alexa global
'http://www.cztv.com.cn/',
# Why: #5380 in Alexa global
'http://www.yammer.com/',
# Why: #5381 in Alexa global
'http://www.sextgem.com/',
# Why: #5382 in Alexa global
'http://www.tribune.com.pk/',
# Why: #5383 in Alexa global
'http://www.topeuro.biz/',
# Why: #5385 in Alexa global
'http://www.perfectgirls.xxx/',
# Why: #5386 in Alexa global
'http://ssc.nic.in/',
# Why: #5387 in Alexa global
'http://www.8264.com/',
# Why: #5388 in Alexa global
'http://www.flvrunner.com/',
# Why: #5389 in Alexa global
'http://www.gry.pl/',
# Why: #5390 in Alexa global
'http://www.sto.cn/',
# Why: #5391 in Alexa global
'http://www.pravda.ru/',
# Why: #5392 in Alexa global
'http://www.fulltiltpoker.com/',
# Why: #5393 in Alexa global
'http://www.kure.tv/',
# Why: #5394 in Alexa global
'http://www.turbo.az/',
# Why: #5395 in Alexa global
'http://www.ujian.cc/',
# Why: #5396 in Alexa global
'http://www.mustseeindia.com/',
# Why: #5397 in Alexa global
'http://www.thithtoolwin.com/',
# Why: #5398 in Alexa global
'http://www.chiphell.com/',
# Why: #5399 in Alexa global
'http://www.baidu.cn/',
# Why: #5400 in Alexa global
'http://www.spieletipps.de/',
# Why: #5401 in Alexa global
'http://www.portail.free.fr/',
# Why: #5402 in Alexa global
'http://www.hbr.org/',
# Why: #5403 in Alexa global
'http://www.sex-hq.com/',
# Why: #5404 in Alexa global
'http://www.webdeveloper.com/',
# Why: #5405 in Alexa global
'http://www.cloudzer.net/',
# Why: #5406 in Alexa global
'http://www.vagas.com.br/',
# Why: #5407 in Alexa global
'http://www.anspress.com/',
# Why: #5408 in Alexa global
'http://www.beitaichufang.com/',
# Why: #5409 in Alexa global
'http://www.songkick.com/',
# Why: #5410 in Alexa global
'http://www.tsite.jp/',
# Why: #5411 in Alexa global
'http://www.oyunlari.net/',
# Why: #5412 in Alexa global
'http://www.unfollowers.me/',
# Why: #5413 in Alexa global
'http://www.computrabajo.com.mx/',
# Why: #5414 in Alexa global
'http://www.usp.br/',
# Why: #5415 in Alexa global
'http://www.parseek.com/',
# Why: #5416 in Alexa global
'http://www.salary.com/',
# Why: #5417 in Alexa global
'http://www.navyfcu.org/',
# Why: #5418 in Alexa global
'http://www.bigpond.com/',
# Why: #5419 in Alexa global
'http://www.joann.com/',
# Why: #5420 in Alexa global
'http://www.ajansspor.com/',
# Why: #5421 in Alexa global
'http://www.burnews.com/',
# Why: #5422 in Alexa global
'http://www.myrecipes.com/',
# Why: #5423 in Alexa global
'http://www.mt5.com/',
# Why: #5424 in Alexa global
'http://www.webconfs.com/',
# Why: #5425 in Alexa global
'http://www.offcn.com/',
# Why: #5426 in Alexa global
'http://www.travian.com.tr/',
# Why: #5427 in Alexa global
'http://www.animenewsnetwork.com/',
# Why: #5428 in Alexa global
'http://www.smartshopping.com/',
# Why: #5429 in Alexa global
'http://www.twojapogoda.pl/',
# Why: #5430 in Alexa global
'http://www.tigerairways.com/',
# Why: #5431 in Alexa global
'http://www.qoo10.jp/',
# Why: #5432 in Alexa global
'http://www.archiveofourown.org/',
# Why: #5433 in Alexa global
'http://www.qq937.com/',
# Why: #5434 in Alexa global
'http://www.meneame.net/',
# Why: #5436 in Alexa global
'http://www.joyclub.de/',
# Why: #5437 in Alexa global
'http://www.yy.com/',
# Why: #5438 in Alexa global
'http://www.weddingwire.com/',
# Why: #5439 in Alexa global
'http://www.moddb.com/',
# Why: #5440 in Alexa global
'http://www.acervoamador.com/',
# Why: #5441 in Alexa global
'http://www.stgeorge.com.au/',
# Why: #5442 in Alexa global
'http://www.forumhouse.ru/',
# Why: #5443 in Alexa global
'http://www.mp3xd.com/',
# Why: #5444 in Alexa global
'http://www.nomura.co.jp/',
# Why: #5445 in Alexa global
'http://www.lionair.co.id/',
# Why: #5446 in Alexa global
'http://www.needtoporn.com/',
# Why: #5447 in Alexa global
'http://www.playcast.ru/',
# Why: #5448 in Alexa global
'http://www.paheal.net/',
# Why: #5449 in Alexa global
'http://www.finishline.com/',
# Why: #5450 in Alexa global
'http://www.sep.gob.mx/',
# Why: #5451 in Alexa global
'http://www.comenity.net/',
# Why: #5452 in Alexa global
'http://www.tqn.com/',
# Why: #5453 in Alexa global
'http://www.eroticads.com/',
# Why: #5454 in Alexa global
'http://www.svpressa.ru/',
# Why: #5455 in Alexa global
'http://www.dtvideo.com/',
# Why: #5456 in Alexa global
'http://www.mobile.free.fr/',
# Why: #5457 in Alexa global
'http://www.privat24.ua/',
# Why: #5458 in Alexa global
'http://www.mp3sk.net/',
# Why: #5459 in Alexa global
'http://www.atlas.sk/',
# Why: #5460 in Alexa global
'http://www.aib.ie/',
# Why: #5461 in Alexa global
'http://www.shockwave.com/',
# Why: #5462 in Alexa global
'http://www.qatarairways.com/',
# Why: #5463 in Alexa global
'http://www.theladders.com/',
# Why: #5464 in Alexa global
'http://www.dsnetwb.com/',
# Why: #5465 in Alexa global
'http://www.expansiondirecto.com/',
# Why: #5466 in Alexa global
'http://www.povarenok.ru/',
# Why: #5467 in Alexa global
'http://www.moneysupermarket.com/',
# Why: #5468 in Alexa global
'http://www.getchu.com/',
# Why: #5469 in Alexa global
'http://www.gay.com/',
# Why: #5470 in Alexa global
'http://www.hsbc.com.mx/',
# Why: #5471 in Alexa global
'http://www.textsale.ru/',
# Why: #5472 in Alexa global
'http://www.kadinlarkulubu.com/',
# Why: #5473 in Alexa global
'http://www.scientificamerican.com/',
# Why: #5474 in Alexa global
'http://www.hillnews.com/',
# Why: #5475 in Alexa global
'http://www.tori.fi/',
# Why: #5476 in Alexa global
'http://www.6tie.com/',
# Why: #5477 in Alexa global
'http://www.championselect.net/',
# Why: #5478 in Alexa global
'http://gtobal.com/',
# Why: #5479 in Alexa global
'http://www.bangkokbank.com/',
# Why: #5481 in Alexa global
'http://www.akakce.com/',
# Why: #5482 in Alexa global
'http://www.smarter.com/',
# Why: #5483 in Alexa global
'http://www.totalvideoplugin.com/',
# Why: #5484 in Alexa global
'http://www.dmir.ru/',
# Why: #5485 in Alexa global
'http://www.rpp.com.pe/',
# Why: #5486 in Alexa global
'http://www.uhaul.com/',
# Why: #5487 in Alexa global
'http://www.kayako.com/',
# Why: #5488 in Alexa global
'http://www.buyvip.com/',
# Why: #5489 in Alexa global
'http://www.sixrevisions.com/',
# Why: #5490 in Alexa global
'http://www.army.mil/',
# Why: #5491 in Alexa global
'http://www.rediffmail.com/',
# Why: #5492 in Alexa global
'http://www.gsis.gr/',
# Why: #5494 in Alexa global
'http://www.destinia.com/',
# Why: #5495 in Alexa global
'http://www.behindwoods.com/',
# Why: #5496 in Alexa global
'http://www.wearehairy.com/',
# Why: #5497 in Alexa global
'http://www.coqnu.com/',
# Why: #5498 in Alexa global
'http://www.soundclick.com/',
# Why: #5499 in Alexa global
'http://www.drive.ru/',
# Why: #5501 in Alexa global
'http://www.cam4.fr/',
# Why: #5502 in Alexa global
'http://www.jschina.com.cn/',
# Why: #5503 in Alexa global
'http://www.bakusai.com/',
# Why: #5504 in Alexa global
'http://www.thailandtorrent.com/',
# Why: #5505 in Alexa global
'http://www.videosz.com/',
# Why: #5506 in Alexa global
'http://www.eporner.com/',
# Why: #5507 in Alexa global
'http://www.rakuten-sec.co.jp/',
# Why: #5508 in Alexa global
'http://www.stltoday.com/',
# Why: #5509 in Alexa global
'http://www.ilmessaggero.it/',
# Why: #5510 in Alexa global
'http://www.theregister.co.uk/',
# Why: #5511 in Alexa global
'http://www.bloggang.com/',
# Why: #5512 in Alexa global
'http://www.eonet.jp/',
# Why: #5513 in Alexa global
'http://www.nastyvideotube.com/',
# Why: #5514 in Alexa global
'http://www.doityourself.com/',
# Why: #5515 in Alexa global
'http://www.rp-online.de/',
# Why: #5516 in Alexa global
'http://www.wow-impulse.ru/',
# Why: #5517 in Alexa global
'http://www.kar.nic.in/',
# Why: #5518 in Alexa global
'http://www.bershka.com/',
# Why: #5519 in Alexa global
'http://www.neteller.com/',
# Why: #5520 in Alexa global
'http://www.adevarul.ro/',
# Why: #5521 in Alexa global
'http://www.divxtotal.com/',
# Why: #5522 in Alexa global
'http://www.bolshoyvopros.ru/',
# Why: #5523 in Alexa global
'http://www.letudiant.fr/',
# Why: #5524 in Alexa global
'http://www.xinshipu.com/',
# Why: #5525 in Alexa global
'http://www.vh1.com/',
# Why: #5526 in Alexa global
'http://www.excite.com/',
# Why: #5527 in Alexa global
'http://www.somewhereinblog.net/',
# Why: #5529 in Alexa global
'http://www.mcgraw-hill.com/',
# Why: #5530 in Alexa global
'http://www.patheos.com/',
# Why: #5531 in Alexa global
'http://www.webdesignledger.com/',
# Why: #5532 in Alexa global
'http://www.plus28.com/',
# Why: #5533 in Alexa global
'http://www.adultwork.com/',
# Why: #5534 in Alexa global
'http://www.dajuegos.com/',
# Why: #5535 in Alexa global
'http://www.blogs.com/',
# Why: #5536 in Alexa global
'http://www.glopart.ru/',
# Why: #5537 in Alexa global
'http://www.donews.com/',
# Why: #5538 in Alexa global
'http://www.nation.co.ke/',
# Why: #5539 in Alexa global
'http://www.delfi.ee/',
# Why: #5540 in Alexa global
'http://www.lacuerda.net/',
# Why: #5541 in Alexa global
'http://www.jjshouse.com/',
# Why: #5542 in Alexa global
'http://www.megaindex.ru/',
# Why: #5543 in Alexa global
'http://www.darty.com/',
# Why: #5544 in Alexa global
'http://www.maturetube.com/',
# Why: #5545 in Alexa global
'http://www.jokeroo.com/',
# Why: #5546 in Alexa global
'http://www.estekhtam.com/',
# Why: #5547 in Alexa global
'http://www.fnac.es/',
# Why: #5548 in Alexa global
'http://www.ninjakiwi.com/',
# Why: #5549 in Alexa global
'http://www.tovima.gr/',
# Why: #5550 in Alexa global
'http://www.timinternet.it/',
# Why: #5551 in Alexa global
'http://www.citizensbankonline.com/',
# Why: #5552 in Alexa global
'http://www.builtwith.com/',
# Why: #5553 in Alexa global
'http://www.ko499.com/',
# Why: #5554 in Alexa global
'http://www.tastyblacks.com/',
# Why: #5555 in Alexa global
'http://www.currys.co.uk/',
# Why: #5556 in Alexa global
'http://www.jobui.com/',
# Why: #5557 in Alexa global
'http://www.notebookreview.com/',
# Why: #5558 in Alexa global
'http://www.meishij.net/',
# Why: #5559 in Alexa global
'http://www.filerio.in/',
# Why: #5560 in Alexa global
'http://gohappy.com.tw/',
# Why: #5561 in Alexa global
'http://www.cheapflights.co.uk/',
# Why: #5562 in Alexa global
'http://www.puls24.mk/',
# Why: #5563 in Alexa global
'http://www.rumbo.es/',
# Why: #5564 in Alexa global
'http://www.newsbusters.org/',
# Why: #5565 in Alexa global
'http://www.imgdino.com/',
# Why: #5566 in Alexa global
'http://www.oxforddictionaries.com/',
# Why: #5567 in Alexa global
'http://www.ftdownloads.com/',
# Why: #5568 in Alexa global
'http://ciudad.com.ar/',
# Why: #5569 in Alexa global
'http://www.latercera.cl/',
# Why: #5570 in Alexa global
'http://www.lankadeepa.lk/',
# Why: #5571 in Alexa global
'http://www.47news.jp/',
# Why: #5572 in Alexa global
'http://www.bankier.pl/',
# Why: #5573 in Alexa global
'http://www.hawahome.com/',
# Why: #5574 in Alexa global
'http://www.comicvine.com/',
# Why: #5575 in Alexa global
'http://www.cam4.it/',
# Why: #5576 in Alexa global
'http://www.fok.nl/',
# Why: #5577 in Alexa global
'http://www.iknowthatgirl.com/',
# Why: #5578 in Alexa global
'http://www.hizliresim.com/',
# Why: #5579 in Alexa global
'http://www.ebizmba.com/',
# Why: #5580 in Alexa global
'http://www.twistys.com/',
# Why: #5581 in Alexa global
'http://minkchan.com/',
# Why: #5582 in Alexa global
'http://www.dnevnik.hr/',
# Why: #5583 in Alexa global
'http://www.peliculascoco.com/',
# Why: #5584 in Alexa global
'http://www.new-xhamster.com/',
# Why: #5585 in Alexa global
'http://www.freelancer.in/',
# Why: #5586 in Alexa global
'http://www.globalgrind.com/',
# Why: #5587 in Alexa global
'http://www.rbc.cn/',
# Why: #5588 in Alexa global
'http://www.talkgold.com/',
# Why: #5589 in Alexa global
'http://www.p1.cn/',
# Why: #5590 in Alexa global
'http://www.kanui.com.br/',
# Why: #5591 in Alexa global
'http://www.woxikon.de/',
# Why: #5592 in Alexa global
'http://www.cinematoday.jp/',
# Why: #5593 in Alexa global
'http://www.jobstreet.com.my/',
# Why: #5594 in Alexa global
'http://www.job.ru/',
# Why: #5595 in Alexa global
'http://www.wowbiz.ro/',
# Why: #5596 in Alexa global
'http://www.yiyi.cc/',
# Why: #5597 in Alexa global
'http://www.sinoptik.ua/',
# Why: #5598 in Alexa global
'http://www.parents.com/',
# Why: #5599 in Alexa global
'http://www.forblabla.com/',
# Why: #5600 in Alexa global
'http://www.trojmiasto.pl/',
# Why: #5601 in Alexa global
'http://www.anyoption.com/',
# Why: #5602 in Alexa global
'http://www.wplocker.com/',
# Why: #5603 in Alexa global
'http://www.paytm.in/',
# Why: #5604 in Alexa global
'http://www.elespectador.com/',
# Why: #5605 in Alexa global
'http://www.mysitecost.ru/',
# Why: #5606 in Alexa global
'http://www.startribune.com/',
# Why: #5607 in Alexa global
'http://www.cam4.co.uk/',
# Why: #5608 in Alexa global
'http://www.bestcoolmobile.com/',
# Why: #5609 in Alexa global
'http://www.soup.io/',
# Why: #5610 in Alexa global
'http://www.starfall.com/',
# Why: #5611 in Alexa global
'http://www.ixl.com/',
# Why: #5612 in Alexa global
'http://www.oreilly.com/',
# Why: #5613 in Alexa global
'http://www.dansmovies.com/',
# Why: #5614 in Alexa global
'http://www.facemoods.com/',
# Why: #5615 in Alexa global
'http://www.google.ge/',
# Why: #5616 in Alexa global
'http://www.sat.gob.mx/',
# Why: #5617 in Alexa global
'http://www.weatherbug.com/',
# Why: #5618 in Alexa global
'http://www.majorgeeks.com/',
# Why: #5619 in Alexa global
'http://www.llbean.com/',
# Why: #5620 in Alexa global
'http://www.catho.com.br/',
# Why: #5621 in Alexa global
'http://www.gungho.jp/',
# Why: #5622 in Alexa global
'http://www.mk.co.kr/',
# Why: #5623 in Alexa global
'http://www.googlegroups.com/',
# Why: #5624 in Alexa global
'http://www.animoto.com/',
# Why: #5625 in Alexa global
'http://www.alquds.co.uk/',
# Why: #5626 in Alexa global
'http://www.newsday.com/',
# Why: #5627 in Alexa global
'http://www.games2girls.com/',
# Why: #5628 in Alexa global
'http://www.youporngay.com/',
# Why: #5629 in Alexa global
'http://www.spaces.ru/',
# Why: #5630 in Alexa global
'http://www.seriespepito.com/',
# Why: #5631 in Alexa global
'http://www.gelbeseiten.de/',
# Why: #5632 in Alexa global
'http://www.thethirdmedia.com/',
# Why: #5633 in Alexa global
'http://www.watchfomny.com/',
# Why: #5634 in Alexa global
'http://www.freecamsexposed.com/',
# Why: #5635 in Alexa global
'http://www.dinakaran.com/',
# Why: #5636 in Alexa global
'http://www.xxxhost.me/',
# Why: #5637 in Alexa global
'http://www.smartprix.com/',
# Why: #5638 in Alexa global
'http://www.thoughtcatalog.com/',
# Why: #5639 in Alexa global
'http://www.soccersuck.com/',
# Why: #5640 in Alexa global
'http://www.vivanuncios.com/',
# Why: #5641 in Alexa global
'http://www.liba.com/',
# Why: #5642 in Alexa global
'http://www.gog.com/',
# Why: #5643 in Alexa global
'http://www.philstar.com/',
# Why: #5644 in Alexa global
'http://www.cian.ru/',
# Why: #5645 in Alexa global
'http://www.avclub.com/',
# Why: #5646 in Alexa global
'http://www.slon.ru/',
# Why: #5647 in Alexa global
'http://www.stc.com.sa/',
# Why: #5648 in Alexa global
'http://www.jstor.org/',
# Why: #5649 in Alexa global
'http://www.wehkamp.nl/',
# Why: #5650 in Alexa global
'http://www.vodafone.co.uk/',
# Why: #5651 in Alexa global
'http://www.deser.pl/',
# Why: #5652 in Alexa global
'http://www.adscendmedia.com/',
# Why: #5653 in Alexa global
'http://www.getcashforsurveys.com/',
# Why: #5654 in Alexa global
'http://www.glamsham.com/',
# Why: #5655 in Alexa global
'http://www.dressupgames.com/',
# Why: #5656 in Alexa global
'http://www.lifo.gr/',
# Why: #5657 in Alexa global
'http://www.37signals.com/',
# Why: #5658 in Alexa global
'http://www.pdfonline.com/',
# Why: #5659 in Alexa global
'http://www.flipkey.com/',
# Why: #5660 in Alexa global
'http://www.epochtimes.com/',
# Why: #5662 in Alexa global
'http://www.futhead.com/',
# Why: #5663 in Alexa global
'http://www.inlinkz.com/',
# Why: #5664 in Alexa global
'http://www.fx-trend.com/',
# Why: #5665 in Alexa global
'http://www.yasdl.com/',
# Why: #5666 in Alexa global
'http://www.techbang.com/',
# Why: #5667 in Alexa global
'http://www.narenji.ir/',
# Why: #5668 in Alexa global
'http://www.szonline.net/',
# Why: #5669 in Alexa global
'http://www.perfil.com.ar/',
# Why: #5670 in Alexa global
'http://www.mywebface.com/',
# Why: #5671 in Alexa global
'http://www.taknaz.ir/',
# Why: #5672 in Alexa global
'http://www.tradera.com/',
# Why: #5673 in Alexa global
'http://www.golem.de/',
# Why: #5674 in Alexa global
'http://www.its-mo.com/',
# Why: #5675 in Alexa global
'http://www.arabnet5.com/',
# Why: #5676 in Alexa global
'http://www.freerepublic.com/',
# Why: #5677 in Alexa global
'http://www.britannica.com/',
# Why: #5678 in Alexa global
'http://www.deccanchronicle.com/',
# Why: #5679 in Alexa global
'http://www.ohio.gov/',
# Why: #5680 in Alexa global
'http://www.busuu.com/',
# Why: #5681 in Alexa global
'http://www.pricecheck.co.za/',
# Why: #5682 in Alexa global
'http://www.paltalk.com/',
# Why: #5683 in Alexa global
'http://www.sportinglife.com/',
# Why: #5684 in Alexa global
'http://www.google.sn/',
# Why: #5685 in Alexa global
'http://www.meteomedia.com/',
# Why: #5686 in Alexa global
'http://www.push2check.net/',
# Why: #5687 in Alexa global
'http://www.ing-diba.de/',
# Why: #5688 in Alexa global
'http://www.immoweb.be/',
# Why: #5689 in Alexa global
'http://www.oregonlive.com/',
# Why: #5690 in Alexa global
'http://www.ge.tt/',
# Why: #5691 in Alexa global
'http://www.bbspink.com/',
# Why: #5692 in Alexa global
'http://www.business2community.com/',
# Why: #5693 in Alexa global
'http://www.viidii.com/',
# Why: #5694 in Alexa global
'http://www.hrloo.com/',
# Why: #5695 in Alexa global
'http://www.mglradio.com/',
# Why: #5696 in Alexa global
'http://www.cosme.net/',
# Why: #5697 in Alexa global
'http://www.xilu.com/',
# Why: #5698 in Alexa global
'http://www.scbeasy.com/',
# Why: #5699 in Alexa global
'http://www.biglots.com/',
# Why: #5700 in Alexa global
'http://www.dhakatimes24.com/',
# Why: #5701 in Alexa global
'http://www.spankbang.com/',
# Why: #5702 in Alexa global
'http://www.hitleap.com/',
# Why: #5703 in Alexa global
'http://www.proz.com/',
# Why: #5704 in Alexa global
'http://www.php100.com/',
# Why: #5705 in Alexa global
'http://www.tvtoday.de/',
# Why: #5706 in Alexa global
'http://www.funnie.st/',
# Why: #5707 in Alexa global
'http://www.velvet.hu/',
# Why: #5708 in Alexa global
'http://www.dhnet.be/',
# Why: #5709 in Alexa global
'http://www.capital.gr/',
# Why: #5710 in Alexa global
'http://www.inosmi.ru/',
# Why: #5711 in Alexa global
'http://www.healthkart.com/',
# Why: #5712 in Alexa global
'http://www.amway.com/',
# Why: #5713 in Alexa global
'http://www.madmimi.com/',
# Why: #5714 in Alexa global
'http://www.dramafever.com/',
# Why: #5715 in Alexa global
'http://www.oodle.com/',
# Why: #5716 in Alexa global
'http://www.spreadshirt.com/',
# Why: #5717 in Alexa global
'http://www.google.mg/',
# Why: #5718 in Alexa global
'http://www.utarget.ru/',
# Why: #5719 in Alexa global
'http://www.matomy.com/',
# Why: #5720 in Alexa global
'http://www.medhelp.org/',
# Why: #5721 in Alexa global
'http://www.cumlouder.com/',
# Why: #5723 in Alexa global
'http://www.aliorbank.pl/',
# Why: #5724 in Alexa global
'http://www.takepart.com/',
# Why: #5725 in Alexa global
'http://www.myfreshnet.com/',
# Why: #5726 in Alexa global
'http://www.adorama.com/',
# Why: #5727 in Alexa global
'http://www.dhs.gov/',
# Why: #5728 in Alexa global
'http://www.suruga-ya.jp/',
# Why: #5729 in Alexa global
'http://www.mivo.tv/',
# Why: #5730 in Alexa global
'http://www.nchsoftware.com/',
# Why: #5731 in Alexa global
'http://www.gnc.com/',
# Why: #5732 in Alexa global
'http://www.spiceworks.com/',
# Why: #5734 in Alexa global
'http://www.jeu.fr/',
# Why: #5735 in Alexa global
'http://www.tv-tokyo.co.jp/',
# Why: #5736 in Alexa global
'http://www.terra.com/',
# Why: #5737 in Alexa global
'http://www.irishtimes.com/',
# Why: #5738 in Alexa global
'http://www.kleiderkreisel.de/',
# Why: #5739 in Alexa global
'http://www.ebay.be/',
# Why: #5740 in Alexa global
'http://www.rt.ru/',
# Why: #5741 in Alexa global
'http://www.radiofarda.com/',
# Why: #5742 in Alexa global
'http://www.atrapalo.com/',
# Why: #5743 in Alexa global
'http://www.southcn.com/',
# Why: #5744 in Alexa global
'http://www.turkcell.com.tr/',
# Why: #5745 in Alexa global
'http://www.themetapicture.com/',
# Why: #5746 in Alexa global
'http://www.aujourdhui.com/',
# Why: #5747 in Alexa global
'http://www.ato.gov.au/',
# Why: #5748 in Alexa global
'http://www.pelis24.com/',
# Why: #5749 in Alexa global
'http://www.saaid.net/',
# Why: #5750 in Alexa global
'http://www.bradsdeals.com/',
# Why: #5751 in Alexa global
'http://www.pirate101.com/',
# Why: #5752 in Alexa global
'http://www.saturn.de/',
# Why: #5753 in Alexa global
'http://www.thisissouthwales.co.uk/',
# Why: #5754 in Alexa global
'http://www.cyberlink.com/',
# Why: #5755 in Alexa global
'http://www.internationalredirects.com/',
# Why: #5756 in Alexa global
'http://www.radardedescontos.com.br/',
# Why: #5758 in Alexa global
'http://www.rapidcontentwizard.com/',
# Why: #5759 in Alexa global
'http://www.kabum.com.br/',
# Why: #5761 in Alexa global
'http://www.athome.co.jp/',
# Why: #5762 in Alexa global
'http://www.webrankinfo.com/',
# Why: #5763 in Alexa global
'http://www.kiabi.com/',
# Why: #5764 in Alexa global
'http://www.farecompare.com/',
# Why: #5765 in Alexa global
'http://www.xinjunshi.com/',
# Why: #5766 in Alexa global
'http://www.youtube.com/user/SkyDoesMinecraft/',
# Why: #5767 in Alexa global
'http://www.vidxden.com/',
# Why: #5768 in Alexa global
'http://www.pvrcinemas.com/',
# Why: #5769 in Alexa global
'http://chachaba.com/',
# Why: #5770 in Alexa global
'http://www.wanmei.com/',
# Why: #5771 in Alexa global
'http://alternet.org/',
# Why: #5772 in Alexa global
'http://www.rozklad-pkp.pl/',
# Why: #5773 in Alexa global
'http://www.omniture.com/',
# Why: #5774 in Alexa global
'http://www.childrensplace.com/',
# Why: #5775 in Alexa global
'http://www.menards.com/',
# Why: #5776 in Alexa global
'http://www.zhcw.com/',
# Why: #5777 in Alexa global
'http://www.ouest-france.fr/',
# Why: #5778 in Alexa global
'http://www.vitorrent.org/',
# Why: #5779 in Alexa global
'http://www.xanga.com/',
# Why: #5780 in Alexa global
'http://www.zbozi.cz/',
# Why: #5781 in Alexa global
'http://www.dnspod.cn/',
# Why: #5782 in Alexa global
'http://www.radioshack.com/',
# Why: #5783 in Alexa global
'http://www.startv.in/',
# Why: #5784 in Alexa global
'http://www.affiliatewindow.com/',
# Why: #5785 in Alexa global
'http://www.gov.on.ca/',
# Why: #5786 in Alexa global
'http://www.grainger.com/',
# Why: #5787 in Alexa global
'http://www.3rat.com/',
# Why: #5788 in Alexa global
'http://www.indeed.co.za/',
# Why: #5789 in Alexa global
'http://www.rtbf.be/',
# Why: #5790 in Alexa global
'http://www.strava.com/',
# Why: #5791 in Alexa global
'http://www.disneystore.com/',
# Why: #5792 in Alexa global
'http://www.travelagency.travel/',
# Why: #5793 in Alexa global
'http://www.ekitan.com/',
# Why: #5794 in Alexa global
'http://www.66law.cn/',
# Why: #5795 in Alexa global
'http://www.volagratis.com/',
# Why: #5796 in Alexa global
'http://www.yiiframework.com/',
# Why: #5797 in Alexa global
'http://www.dramacrazy.net/',
# Why: #5798 in Alexa global
'http://www.addtoany.com/',
# Why: #5799 in Alexa global
'http://www.uzmantv.com/',
# Why: #5800 in Alexa global
'http://www.uline.com/',
# Why: #5801 in Alexa global
'http://www.fitnessmagazine.com/',
# Why: #5802 in Alexa global
'http://www.khmerload.com/',
# Why: #5803 in Alexa global
'http://www.italiafilm.tv/',
# Why: #5804 in Alexa global
'http://www.baseball-reference.com/',
# Why: #5805 in Alexa global
'http://www.neopets.com/',
# Why: #5806 in Alexa global
'http://www.multiupload.nl/',
# Why: #5807 in Alexa global
'http://www.lakii.com/',
# Why: #5808 in Alexa global
'http://www.downloadmaster.ru/',
# Why: #5809 in Alexa global
'http://www.babbel.com/',
# Why: #5810 in Alexa global
'http://www.gossip-tv.gr/',
# Why: #5811 in Alexa global
'http://www.laban.vn/',
# Why: #5812 in Alexa global
'http://www.computerbase.de/',
# Why: #5813 in Alexa global
'http://www.juyouqu.com/',
# Why: #5814 in Alexa global
'http://www.markt.de/',
# Why: #5815 in Alexa global
'http://www.linuxquestions.org/',
# Why: #5816 in Alexa global
'http://www.giveawayoftheday.com/',
# Why: #5817 in Alexa global
'http://www.176.com/',
# Why: #5818 in Alexa global
'http://www.cs.com.cn/',
# Why: #5819 in Alexa global
'http://www.homemademoviez.com/',
# Why: #5820 in Alexa global
'http://www.huffingtonpost.fr/',
# Why: #5821 in Alexa global
'http://www.movieweb.com/',
# Why: #5822 in Alexa global
'http://www.pornzeus.com/',
# Why: #5823 in Alexa global
'http://www.posta.com.tr/',
# Why: #5824 in Alexa global
'http://www.biography.com/',
# Why: #5825 in Alexa global
'http://www.bukkit.org/',
# Why: #5826 in Alexa global
'http://www.spirit.com/',
# Why: #5827 in Alexa global
'http://www.vemale.com/',
# Why: #5828 in Alexa global
'http://www.elnuevodia.com/',
# Why: #5829 in Alexa global
'http://www.pof.com.br/',
# Why: #5830 in Alexa global
'http://www.iranproud.com/',
# Why: #5831 in Alexa global
'http://www.molodost.bz/',
# Why: #5832 in Alexa global
'http://www.netcarshow.com/',
# Why: #5833 in Alexa global
'http://www.ardmediathek.de/',
# Why: #5834 in Alexa global
'http://www.fabfurnish.com/',
# Why: #5835 in Alexa global
'http://www.myfreeblack.com/',
# Why: #5836 in Alexa global
'http://www.antichat.ru/',
# Why: #5837 in Alexa global
'http://www.crocko.com/',
# Why: #5838 in Alexa global
'http://www.cocacola.co.jp/',
# Why: #5839 in Alexa global
'http://b5m.com/',
# Why: #5840 in Alexa global
'http://www.entrance-exam.net/',
# Why: #5841 in Alexa global
'http://www.benaughty.com/',
# Why: #5842 in Alexa global
'http://www.sierratradingpost.com/',
# Why: #5843 in Alexa global
'http://www.apartmentguide.com/',
# Why: #5844 in Alexa global
'http://www.slimspots.com/',
# Why: #5845 in Alexa global
'http://www.sondakika.com/',
# Why: #5846 in Alexa global
'http://www.glamour.com/',
# Why: #5847 in Alexa global
'http://www.zto.cn/',
# Why: #5848 in Alexa global
'http://www.ilyke.net/',
# Why: #5849 in Alexa global
'http://www.mybroadband.co.za/',
# Why: #5850 in Alexa global
'http://www.alaskaair.com/',
# Why: #5851 in Alexa global
'http://www.virtualtourist.com/',
# Why: #5852 in Alexa global
'http://www.rexxx.com/',
# Why: #5853 in Alexa global
'http://www.fullhdfilmizle.org/',
# Why: #5854 in Alexa global
'http://www.starpulse.com/',
# Why: #5855 in Alexa global
'http://www.winkal.com/',
# Why: #5856 in Alexa global
'http://www.ad-feeds.net/',
# Why: #5857 in Alexa global
'http://www.irannaz.com/',
# Why: #5858 in Alexa global
'http://www.elahmad.com/',
# Why: #5859 in Alexa global
'http://www.dealspl.us/',
# Why: #5860 in Alexa global
'http://www.moikrug.ru/',
# Why: #5861 in Alexa global
'http://www.olx.com.mx/',
# Why: #5862 in Alexa global
'http://www.rd.com/',
# Why: #5863 in Alexa global
'http://www.newone.org/',
# Why: #5864 in Alexa global
'http://www.naijapals.com/',
# Why: #5865 in Alexa global
'http://www.forgifs.com/',
# Why: #5866 in Alexa global
'http://www.fsjgw.com/',
# Why: #5867 in Alexa global
'http://edeng.cn/',
# Why: #5868 in Alexa global
'http://www.nicoviewer.net/',
# Why: #5869 in Alexa global
'http://www.topeleven.com/',
# Why: #5870 in Alexa global
'http://www.peerfly.com/',
# Why: #5871 in Alexa global
'http://www.softportal.com/',
# Why: #5872 in Alexa global
'http://www.clker.com/',
# Why: #5873 in Alexa global
'http://www.tehran98.com/',
# Why: #5874 in Alexa global
'http://weather2umbrella.com/',
# Why: #5875 in Alexa global
'http://www.jreast.co.jp/',
# Why: #5876 in Alexa global
'http://www.kuxun.cn/',
# Why: #5877 in Alexa global
'http://www.lookbook.nu/',
# Why: #5878 in Alexa global
'http://www.futureshop.ca/',
# Why: #5879 in Alexa global
'http://www.blackpeoplemeet.com/',
# Why: #5880 in Alexa global
'http://www.adworkmedia.com/',
# Why: #5881 in Alexa global
'http://www.entire.xxx/',
# Why: #5882 in Alexa global
'http://www.bitbucket.org/',
# Why: #5884 in Alexa global
'http://www.transfermarkt.co.uk/',
# Why: #5885 in Alexa global
'http://www.moshimonsters.com/',
# Why: #5886 in Alexa global
'http://www.4travel.jp/',
# Why: #5887 in Alexa global
'http://www.baimao.com/',
# Why: #5888 in Alexa global
'http://www.khanacademy.org/',
# Why: #5889 in Alexa global
'http://www.2chan.net/',
# Why: #5890 in Alexa global
'http://www.adopteunmec.com/',
# Why: #5891 in Alexa global
'http://www.mochimedia.com/',
# Why: #5892 in Alexa global
'http://www.strawberrynet.com/',
# Why: #5893 in Alexa global
'http://www.gdeivse.com/',
# Why: #5894 in Alexa global
'http://www.speckyboy.com/',
# Why: #5895 in Alexa global
'http://www.radical-foto.ru/',
# Why: #5896 in Alexa global
'http://www.softcoin.com/',
# Why: #5897 in Alexa global
'http://www.cnews.ru/',
# Why: #5898 in Alexa global
'http://www.ubs.com/',
# Why: #5899 in Alexa global
'http://www.lankasri.com/',
# Why: #5900 in Alexa global
'http://www.cylex.de/',
# Why: #5901 in Alexa global
'http://www.imtranslator.net/',
# Why: #5902 in Alexa global
'http://www.homeoffice.gov.uk/',
# Why: #5903 in Alexa global
'http://www.answerbag.com/',
# Why: #5904 in Alexa global
'http://www.chainreactioncycles.com/',
# Why: #5905 in Alexa global
'http://www.sportal.bg/',
# Why: #5906 in Alexa global
'http://www.livemaster.ru/',
# Why: #5907 in Alexa global
'http://www.mercadolibre.com.pe/',
# Why: #5908 in Alexa global
'http://www.mentalfloss.com/',
# Why: #5909 in Alexa global
'http://www.google.am/',
# Why: #5910 in Alexa global
'http://www.mawaly.com/',
# Why: #5911 in Alexa global
'http://www.douban.fm/',
# Why: #5912 in Alexa global
'http://www.abidjan.net/',
# Why: #5913 in Alexa global
'http://www.pricegong.com/',
# Why: #5914 in Alexa global
'http://www.brother.com/',
# Why: #5915 in Alexa global
'http://www.basspro.com/',
# Why: #5916 in Alexa global
'http://popsci.com/',
# Why: #5917 in Alexa global
'http://www.olx.com.ar/',
# Why: #5918 in Alexa global
'http://www.python.org/',
# Why: #5919 in Alexa global
'http://www.voetbalzone.nl/',
# Why: #5920 in Alexa global
'http://www.518.com.tw/',
# Why: #5921 in Alexa global
'http://www.aztecaporno.com/',
# Why: #5922 in Alexa global
'http://www.d-h.st/',
# Why: #5923 in Alexa global
'http://www.voyeurweb.com/',
# Why: #5924 in Alexa global
'http://www.storenvy.com/',
# Why: #5925 in Alexa global
'http://www.aftabir.com/',
# Why: #5926 in Alexa global
'http://www.imgsrc.ru/',
# Why: #5927 in Alexa global
'http://www.peru.com/',
# Why: #5928 in Alexa global
'http://www.mindbodygreen.com/',
# Why: #5929 in Alexa global
'http://www.stereotude.com/',
# Why: #5930 in Alexa global
'http://www.ar15.com/',
# Why: #5931 in Alexa global
'http://www.gogecapital.com/',
# Why: #5932 in Alexa global
'http://xipin.me/',
# Why: #5933 in Alexa global
'http://www.gvt.com.br/',
# Why: #5934 in Alexa global
'http://www.today.it/',
# Why: #5935 in Alexa global
'http://www.mastercard.com.au/',
# Why: #5936 in Alexa global
'http://www.hobbyking.com/',
# Why: #5937 in Alexa global
'http://www.hawkhost.com/',
# Why: #5938 in Alexa global
'http://www.thebump.com/',
# Why: #5939 in Alexa global
'http://www.alpari.ru/',
# Why: #5940 in Alexa global
'http://www.gamma-ic.com/',
# Why: #5941 in Alexa global
'http://www.mundome.com/',
# Why: #5942 in Alexa global
'http://www.televisao.uol.com.br/',
# Why: #5943 in Alexa global
'http://www.quotev.com/',
# Why: #5944 in Alexa global
'http://www.animaljam.com/',
# Why: #5945 in Alexa global
'http://www.ohozaa.com/',
# Why: #5946 in Alexa global
'http://www.sayyac.com/',
# Why: #5947 in Alexa global
'http://www.kobobooks.com/',
# Why: #5948 in Alexa global
'http://www.muslima.com/',
# Why: #5949 in Alexa global
'http://www.digsitesvalue.net/',
# Why: #5950 in Alexa global
'http://www.colourlovers.com/',
# Why: #5951 in Alexa global
'http://www.uludagsozluk.com/',
# Why: #5952 in Alexa global
'http://www.mercadolibre.com.uy/',
# Why: #5953 in Alexa global
'http://www.oem.com.mx/',
# Why: #5954 in Alexa global
'http://www.self.com/',
# Why: #5955 in Alexa global
'http://www.kyohk.net/',
# Why: #5957 in Alexa global
'http://www.dillards.com/',
# Why: #5958 in Alexa global
'http://www.eduu.com/',
# Why: #5959 in Alexa global
'http://www.replays.net/',
# Why: #5960 in Alexa global
'http://www.bnpparibasfortis.be/',
# Why: #5961 in Alexa global
'http://www.express.co.uk/',
# Why: #5962 in Alexa global
'http://www.levelupgames.uol.com.br/',
# Why: #5963 in Alexa global
'http://www.guaixun.com/',
# Why: #5964 in Alexa global
'http://www.750g.com/',
# Why: #5965 in Alexa global
'http://www.craveonline.com/',
# Why: #5966 in Alexa global
'http://www.markafoni.com/',
# Why: #5968 in Alexa global
'http://www.ename.com/',
# Why: #5969 in Alexa global
'http://www.abercrombie.com/',
# Why: #5970 in Alexa global
'http://www.noticiaaldia.com/',
# Why: #5971 in Alexa global
'http://www.seniorpeoplemeet.com/',
# Why: #5972 in Alexa global
'http://www.dhingana.com/',
# Why: #5974 in Alexa global
'http://www.prokerala.com/',
# Why: #5975 in Alexa global
'http://www.iefimerida.gr/',
# Why: #5976 in Alexa global
'http://www.wprazzi.com/',
# Why: #5977 in Alexa global
'http://www.pantipmarket.com/',
# Why: #5978 in Alexa global
'http://www.vueling.com/',
# Why: #5979 in Alexa global
'http://www.newsonlineweekly.com/',
# Why: #5980 in Alexa global
'http://cr173.com/',
# Why: #5981 in Alexa global
'http://www.ecp888.com/',
# Why: #5982 in Alexa global
'http://www.diary.ru/',
# Why: #5983 in Alexa global
'http://www.pervclips.com/',
# Why: #5984 in Alexa global
'http://www.sudaneseonline.com/',
# Why: #5985 in Alexa global
'http://www.personal.com.ar/',
# Why: #5986 in Alexa global
'http://www.articlesnatch.com/',
# Why: #5987 in Alexa global
'http://www.mitbbs.com/',
# Why: #5988 in Alexa global
'http://www.techsupportalert.com/',
# Why: #5989 in Alexa global
'http://www.filepost.com/',
# Why: #5990 in Alexa global
'http://www.unblockyoutube.co.uk/',
# Why: #5991 in Alexa global
'http://www.hasznaltauto.hu/',
# Why: #5992 in Alexa global
'http://www.dmv.org/',
# Why: #5993 in Alexa global
'http://www.port.hu/',
# Why: #5995 in Alexa global
'http://www.anastasiadate.com/',
# Why: #5996 in Alexa global
'http://www.adtgs.com/',
# Why: #5997 in Alexa global
'http://www.namejet.com/',
# Why: #5998 in Alexa global
'http://www.ally.com/',
# Why: #5999 in Alexa global
'http://www.djmaza.com/',
# Why: #6001 in Alexa global
'http://www.asstr.org/',
# Why: #6002 in Alexa global
'http://www.corel.com/',
# Why: #6003 in Alexa global
'http://www.interfax.ru/',
# Why: #6004 in Alexa global
'http://www.rozee.pk/',
# Why: #6005 in Alexa global
'http://www.akinator.com/',
# Why: #6006 in Alexa global
'http://www.dominos.co.in/',
# Why: #6007 in Alexa global
'http://boardgamegeek.com/',
# Why: #6008 in Alexa global
'http://www.teamliquid.net/',
# Why: #6009 in Alexa global
'http://www.sbrf.ru/',
# Why: #6010 in Alexa global
'http://www.l99.com/',
# Why: #6011 in Alexa global
'http://www.eatingwell.com/',
# Why: #6012 in Alexa global
'http://www.mid-day.com/',
# Why: #6013 in Alexa global
'http://www.blinkogold.it/',
# Why: #6014 in Alexa global
'http://www.rosbalt.ru/',
# Why: #6015 in Alexa global
'http://copadomundo.uol.com.br/',
# Why: #6016 in Alexa global
'http://www.islammemo.cc/',
# Why: #6017 in Alexa global
'http://www.bettycrocker.com/',
# Why: #6018 in Alexa global
'http://www.womenshealthmag.com/',
# Why: #6019 in Alexa global
'http://www.asandownload.com/',
# Why: #6020 in Alexa global
'http://www.twitcasting.tv/',
# Why: #6021 in Alexa global
'http://www.10and9.com/',
# Why: #6022 in Alexa global
'http://www.youngleafs.com/',
# Why: #6023 in Alexa global
'http://www.saharareporters.com/',
# Why: #6024 in Alexa global
'http://www.overclock.net/',
# Why: #6025 in Alexa global
'http://www.mapsgalaxy.com/',
# Why: #6026 in Alexa global
'http://www.internetslang.com/',
# Why: #6027 in Alexa global
'http://www.sokmil.com/',
# Why: #6028 in Alexa global
'http://www.yousendit.com/',
# Why: #6029 in Alexa global
'http://www.forex-mmcis.com/',
# Why: #6030 in Alexa global
'http://www.vador.com/',
# Why: #6031 in Alexa global
'http://www.pagewash.com/',
# Why: #6032 in Alexa global
'http://www.pringotrack.com/',
# Why: #6033 in Alexa global
'http://www.cpmstar.com/',
# Why: #6034 in Alexa global
'http://www.yxdown.com/',
# Why: #6035 in Alexa global
'http://www.surfingbird.ru/',
# Why: #6036 in Alexa global
'http://kyodo-d.jp/',
# Why: #6037 in Alexa global
'http://www.identi.li/',
# Why: #6038 in Alexa global
'http://www.n4hr.com/',
# Why: #6039 in Alexa global
'http://www.elitetorrent.net/',
# Why: #6040 in Alexa global
'http://www.livechatinc.com/',
# Why: #6041 in Alexa global
'http://www.anzhi.com/',
# Why: #6042 in Alexa global
'http://www.2checkout.com/',
# Why: #6043 in Alexa global
'http://www.bancoestado.cl/',
# Why: #6044 in Alexa global
'http://www.epson.com/',
# Why: #6045 in Alexa global
'http://www.twodollarclick.com/',
# Why: #6046 in Alexa global
'http://www.okaz.com.sa/',
# Why: #6047 in Alexa global
'http://china-sss.com/',
# Why: #6048 in Alexa global
'http://www.sagawa-exp.co.jp/',
# Why: #6049 in Alexa global
'http://www.xforex.com/',
# Why: #6050 in Alexa global
'http://www.salliemae.com/',
# Why: #6051 in Alexa global
'http://www.acunn.com/',
# Why: #6052 in Alexa global
'http://www.navyfederal.org/',
# Why: #6053 in Alexa global
'http://www.forumactif.com/',
# Why: #6054 in Alexa global
'http://www.affaire.com/',
# Why: #6055 in Alexa global
'http://www.mediatemple.net/',
# Why: #6056 in Alexa global
'http://www.qdmm.com/',
# Why: #6057 in Alexa global
'http://www.urlm.co/',
# Why: #6058 in Alexa global
'http://www.toofab.com/',
# Why: #6059 in Alexa global
'http://www.yola.com/',
# Why: #6060 in Alexa global
'http://www.sheldonsfans.com/',
# Why: #6061 in Alexa global
'http://www.piratestreaming.com/',
# Why: #6062 in Alexa global
'http://www.frontier.com/',
# Why: #6063 in Alexa global
'http://www.jxnews.com.cn/',
# Why: #6064 in Alexa global
'http://www.businesswire.com/',
# Why: #6065 in Alexa global
'http://www.rue89.com/',
# Why: #6066 in Alexa global
'http://www.yenisafak.com.tr/',
# Why: #6067 in Alexa global
'http://www.wikimart.ru/',
# Why: #6068 in Alexa global
'http://www.22.cn/',
# Why: #6069 in Alexa global
'http://www.xpressvids.info/',
# Why: #6070 in Alexa global
'http://www.medicalnewstoday.com/',
# Why: #6071 in Alexa global
'http://www.express.de/',
# Why: #6072 in Alexa global
'http://www.grid.mk/',
# Why: #6073 in Alexa global
'http://www.mass.gov/',
# Why: #6074 in Alexa global
'http://www.onlinefinder.net/',
# Why: #6075 in Alexa global
'http://www.yllix.com/',
# Why: #6076 in Alexa global
'http://www.aksam.com.tr/',
# Why: #6077 in Alexa global
'http://www.telegraf.rs/',
# Why: #6078 in Alexa global
'http://www.templatic.com/',
# Why: #6079 in Alexa global
'http://www.kandao.com/',
# Why: #6080 in Alexa global
'http://www.policymic.com/',
# Why: #6081 in Alexa global
'http://www.farfesh.com/',
# Why: #6082 in Alexa global
'http://www.alza.cz/',
# Why: #6083 in Alexa global
'http://www.judgeporn.com/',
# Why: #6084 in Alexa global
'http://townwork.net/',
# Why: #6085 in Alexa global
'http://3dcartstores.com/',
# Why: #6086 in Alexa global
'http://www.marketingland.com/',
# Why: #6087 in Alexa global
'http://okooo.com/',
# Why: #6088 in Alexa global
'http://www.siteduzero.com/',
# Why: #6089 in Alexa global
'http://www.cellbazaar.com/',
# Why: #6090 in Alexa global
'http://www.omb100.com/',
# Why: #6091 in Alexa global
'http://www.danarimedia.com/',
# Why: #6092 in Alexa global
'http://www.nlcafe.hu/',
# Why: #6093 in Alexa global
'http://www.qz.com/',
# Why: #6094 in Alexa global
'http://www.indiapost.gov.in/',
# Why: #6095 in Alexa global
'http://www.kinogo.net/',
# Why: #6096 in Alexa global
'http://www.neverblue.com/',
# Why: #6097 in Alexa global
'http://www.spyfu.com/',
# Why: #6098 in Alexa global
'http://www.shindanmaker.com/',
# Why: #6099 in Alexa global
'http://bankpasargad.com/',
# Why: #6100 in Alexa global
'http://www.techweb.com.cn/',
# Why: #6101 in Alexa global
'http://internetautoguide.com/',
# Why: #6102 in Alexa global
'http://www.allover30.com/',
# Why: #6103 in Alexa global
'http://www.metric-conversions.org/',
# Why: #6104 in Alexa global
'http://www.carid.com/',
# Why: #6105 in Alexa global
'http://www.mofos.com/',
# Why: #6106 in Alexa global
'http://www.kanald.com.tr/',
# Why: #6107 in Alexa global
'http://www.mobikwik.com/',
# Why: #6108 in Alexa global
'http://www.checkpagerank.net/',
# Why: #6109 in Alexa global
'http://www.hotscripts.com/',
# Why: #6110 in Alexa global
'http://www.hornywife.com/',
# Why: #6111 in Alexa global
'http://www.prixmoinscher.com/',
# Why: #6112 in Alexa global
'http://www.worldbank.org/',
# Why: #6113 in Alexa global
'http://www.wsodownloads.info/',
# Why: #6114 in Alexa global
'http://www.his-j.com/',
# Why: #6115 in Alexa global
'http://www.powned.tv/',
# Why: #6116 in Alexa global
'http://www.redmondpie.com/',
# Why: #6117 in Alexa global
'http://www.molotok.ru/',
# Why: #6118 in Alexa global
'http://www.whatmobile.com.pk/',
# Why: #6119 in Alexa global
'http://www.wiziq.com/',
# Why: #6120 in Alexa global
'http://www.excelsior.com.mx/',
# Why: #6121 in Alexa global
'http://www.tradetang.com/',
# Why: #6122 in Alexa global
'http://www.terra.es/',
# Why: #6123 in Alexa global
'http://www.sdchina.com/',
# Why: #6124 in Alexa global
'http://www.rai.tv/',
# Why: #6125 in Alexa global
'http://www.indiansexstories.net/',
# Why: #6127 in Alexa global
'http://www.upbulk.com/',
# Why: #6128 in Alexa global
'http://www.surveygizmo.com/',
# Why: #6129 in Alexa global
'http://www.ulta.com/',
# Why: #6130 in Alexa global
'http://www.tera-europe.com/',
# Why: #6131 in Alexa global
'http://www.tuoitre.vn/',
# Why: #6132 in Alexa global
'http://www.onedio.com/',
# Why: #6133 in Alexa global
'http://www.jz123.cn/',
# Why: #6134 in Alexa global
'http://www.canon.jp/',
# Why: #6135 in Alexa global
'http://www.favim.com/',
# Why: #6136 in Alexa global
'http://www.seo-fast.ru/',
# Why: #6137 in Alexa global
'http://www.twitterfeed.com/',
# Why: #6138 in Alexa global
'http://www.trustedreviews.com/',
# Why: #6139 in Alexa global
'http://www.ztgame.com/',
# Why: #6140 in Alexa global
'http://www.radiojavan.com/',
# Why: #6141 in Alexa global
'http://fun698.com/',
# Why: #6142 in Alexa global
'http://www.126.net/',
# Why: #6143 in Alexa global
'http://www.indiaglitz.com/',
# Why: #6144 in Alexa global
'http://www.jdouga.com/',
# Why: #6145 in Alexa global
'http://www.lofter.com/',
# Why: #6146 in Alexa global
'http://www.mysavings.com/',
# Why: #6147 in Alexa global
'http://www.snapfish.com/',
# Why: #6148 in Alexa global
'http://www.i-sux.com/',
# Why: #6149 in Alexa global
'http://www.cebbank.com/',
# Why: #6150 in Alexa global
'http://www.ethnos.gr/',
# Why: #6151 in Alexa global
'http://www.desktop2ch.tv/',
# Why: #6152 in Alexa global
'http://www.expedia.ca/',
# Why: #6153 in Alexa global
'http://www.kinja.com/',
# Why: #6154 in Alexa global
'http://www.rusfolder.com/',
# Why: #6155 in Alexa global
'http://www.expat-blog.com/',
# Why: #6156 in Alexa global
'http://www.8teenxxx.com/',
# Why: #6157 in Alexa global
'http://www.variety.com/',
# Why: #6158 in Alexa global
'http://www.natemat.pl/',
# Why: #6159 in Alexa global
'http://www.niazpardaz.com/',
# Why: #6160 in Alexa global
'http://www.gezginler.net/',
# Why: #6161 in Alexa global
'http://www.baur.de/',
# Why: #6162 in Alexa global
'http://www.tv2.no/',
# Why: #6163 in Alexa global
'http://www.realgm.com/',
# Why: #6164 in Alexa global
'http://www.zamzar.com/',
# Why: #6165 in Alexa global
'http://www.freecharge.in/',
# Why: #6166 in Alexa global
'http://www.ahlamontada.com/',
# Why: #6167 in Alexa global
'http://www.salespider.com/',
# Why: #6168 in Alexa global
'http://www.beanfun.com/',
# Why: #6169 in Alexa global
'http://www.cleveland.com/',
# Why: #6173 in Alexa global
'http://www.truecaller.com/',
# Why: #6174 in Alexa global
'http://www.walmart.ca/',
# Why: #6175 in Alexa global
'http://www.fanbox.com/',
# Why: #6176 in Alexa global
'http://www.designmodo.com/',
# Why: #6177 in Alexa global
'http://www.frip.com/',
# Why: #6178 in Alexa global
'http://www.sammobile.com/',
# Why: #6179 in Alexa global
'http://www.minnano-av.com/',
# Why: #6180 in Alexa global
'http://www.bri.co.id/',
# Why: #6181 in Alexa global
'http://www.creativebloq.com/',
# Why: #6182 in Alexa global
'http://www.anthropologie.com/',
# Why: #6183 in Alexa global
'http://www.afpbb.com/',
# Why: #6184 in Alexa global
'http://www.kingsera.ir/',
# Why: #6185 in Alexa global
'http://www.songspk.co/',
# Why: #6186 in Alexa global
'http://www.sexsearch.com/',
# Why: #6187 in Alexa global
'http://www.dailydot.com/',
# Why: #6188 in Alexa global
'http://www.hayah.cc/',
# Why: #6189 in Alexa global
'http://www.angolotesti.it/',
# Why: #6190 in Alexa global
'http://www.si.kz/',
# Why: #6191 in Alexa global
'http://www.allthingsd.com/',
# Why: #6192 in Alexa global
'http://www.paddypower.com/',
# Why: #6193 in Alexa global
'http://www.canadapost.ca/',
# Why: #6194 in Alexa global
'http://www.qq.cc/',
# Why: #6195 in Alexa global
'http://www.amctheatres.com/',
# Why: #6196 in Alexa global
'http://www.alltop.com/',
# Why: #6197 in Alexa global
'http://www.allkpop.com/',
# Why: #6198 in Alexa global
'http://www.nalog.ru/',
# Why: #6199 in Alexa global
'http://www.dynadot.com/',
# Why: #6200 in Alexa global
'http://www.copart.com/',
# Why: #6201 in Alexa global
'http://www.mexat.com/',
# Why: #6202 in Alexa global
'http://www.skelbiu.lt/',
# Why: #6203 in Alexa global
'http://www.kerala.gov.in/',
# Why: #6204 in Alexa global
'http://www.cathaypacific.com/',
# Why: #6205 in Alexa global
'http://www.clip2ni.com/',
# Why: #6206 in Alexa global
'http://www.tribune.com/',
# Why: #6207 in Alexa global
'http://www.acidcow.com/',
# Why: #6208 in Alexa global
'http://www.amkspor.com/',
# Why: #6209 in Alexa global
'http://www.shiksha.com/',
# Why: #6211 in Alexa global
'http://www.180upload.com/',
# Why: #6212 in Alexa global
'http://www.vietgiaitri.com/',
# Why: #6213 in Alexa global
'http://www.sportsauthority.com/',
# Why: #6214 in Alexa global
'http://www.banki.ir/',
# Why: #6215 in Alexa global
'http://www.vancouversun.com/',
# Why: #6216 in Alexa global
'http://www.hackforums.net/',
# Why: #6217 in Alexa global
'http://www.t-mobile.de/',
# Why: #6218 in Alexa global
'http://www.gree.jp/',
# Why: #6219 in Alexa global
'http://www.simplyrecipes.com/',
# Why: #6220 in Alexa global
'http://www.crazyhomesex.com/',
# Why: #6221 in Alexa global
'http://www.thehindubusinessline.com/',
# Why: #6222 in Alexa global
'http://www.kriesi.at/',
# Why: #6223 in Alexa global
'http://deyi.com/',
# Why: #6224 in Alexa global
'http://www.plimus.com/',
# Why: #6225 in Alexa global
'http://www.websyndic.com/',
# Why: #6226 in Alexa global
'http://www.northnews.cn/',
# Why: #6228 in Alexa global
'http://www.express.com/',
# Why: #6229 in Alexa global
'http://www.dougasouko.com/',
# Why: #6230 in Alexa global
'http://www.mmstat.com/',
# Why: #6231 in Alexa global
'http://www.womai.com/',
# Why: #6232 in Alexa global
'http://www.alrajhibank.com.sa/',
# Why: #6233 in Alexa global
'http://www.ice-porn.com/',
# Why: #6234 in Alexa global
'http://www.benchmarkemail.com/',
# Why: #6235 in Alexa global
'http://www.ringcentral.com/',
# Why: #6236 in Alexa global
'http://www.erail.in/',
# Why: #6237 in Alexa global
'http://www.poptropica.com/',
# Why: #6238 in Alexa global
'http://www.search.ch/',
# Why: #6239 in Alexa global
'http://www.meteo.it/',
# Why: #6240 in Alexa global
'http://www.adriver.ru/',
# Why: #6241 in Alexa global
'http://www.ipeen.com.tw/',
# Why: #6242 in Alexa global
'http://www.ratp.fr/',
# Why: #6243 in Alexa global
'http://www.orgasm.com/',
# Why: #6244 in Alexa global
'http://www.pornme.com/',
# Why: #6245 in Alexa global
'http://www.gameinformer.com/',
# Why: #6246 in Alexa global
'http://www.woobox.com/',
# Why: #6247 in Alexa global
'http://www.advertising.com/',
# Why: #6248 in Alexa global
'http://www.flyflv.com/',
# Why: #6249 in Alexa global
'http://www.chinaren.com/',
# Why: #6250 in Alexa global
'http://www.tube2012.com/',
# Why: #6251 in Alexa global
'http://www.ikhwanonline.com/',
# Why: #6252 in Alexa global
'http://www.iwebtool.com/',
# Why: #6253 in Alexa global
'http://www.ucdavis.edu/',
# Why: #6254 in Alexa global
'http://www.boyfriendtv.com/',
# Why: #6255 in Alexa global
'http://www.rurubu.travel/',
# Why: #6256 in Alexa global
'http://www.kabam.com/',
# Why: #6257 in Alexa global
'http://www.talkingpointsmemo.com/',
# Why: #6258 in Alexa global
'http://www.detnews.com/',
# Why: #6259 in Alexa global
'http://www.sibnet.ru/',
# Why: #6260 in Alexa global
'http://www.camztube.net/',
# Why: #6261 in Alexa global
'http://www.madamenoire.com/',
# Why: #6262 in Alexa global
'http://www.evz.ro/',
# Why: #6263 in Alexa global
'http://www.staseraintv.com/',
# Why: #6264 in Alexa global
'http://www.che168.com/',
# Why: #6265 in Alexa global
'http://www.kidshealth.org/',
# Why: #6266 in Alexa global
'http://www.m24.ru/',
# Why: #6267 in Alexa global
'http://www.zenfolio.com/',
# Why: #6268 in Alexa global
'http://www.webtretho.com/',
# Why: #6269 in Alexa global
'http://www.postjung.com/',
# Why: #6270 in Alexa global
'http://www.supersport.com/',
# Why: #6271 in Alexa global
'http://www.cshtracker.com/',
# Why: #6272 in Alexa global
'http://www.jeuxjeuxjeux.fr/',
# Why: #6273 in Alexa global
'http://www.foxtv.es/',
# Why: #6274 in Alexa global
'http://www.postjoint.com/',
# Why: #6275 in Alexa global
'http://www.honda.co.jp/',
# Why: #6276 in Alexa global
'http://www.podnapisi.net/',
# Why: #6277 in Alexa global
'http://www.prav.tv/',
# Why: #6278 in Alexa global
'http://www.realmadrid.com/',
# Why: #6279 in Alexa global
'http://www.mbs-potsdam.de/',
# Why: #6280 in Alexa global
'http://www.tim.it/',
# Why: #6281 in Alexa global
'http://uplus.metroer.com/~content/',
# Why: #6282 in Alexa global
'http://www.esquire.com/',
# Why: #6283 in Alexa global
'http://ooopic.com/',
# Why: #6284 in Alexa global
'http://www.castorama.fr/',
# Why: #6285 in Alexa global
'http://brides.com.cn/',
# Why: #6286 in Alexa global
'http://www.afamily.vn/',
# Why: #6287 in Alexa global
'http://www.findlaw.com/',
# Why: #6288 in Alexa global
'http://www.smartpassiveincome.com/',
# Why: #6289 in Alexa global
'http://www.sa.ae/',
# Why: #6290 in Alexa global
'http://www.hemnet.se/',
# Why: #6291 in Alexa global
'http://www.diytrade.com/',
# Why: #6292 in Alexa global
'http://www.weblancer.net/',
# Why: #6293 in Alexa global
'http://www.zapmeta.de/',
# Why: #6294 in Alexa global
'http://www.bizsugar.com/',
# Why: #6295 in Alexa global
'http://www.banesco.com/',
# Why: #6296 in Alexa global
'http://www.ideeli.com/',
# Why: #6297 in Alexa global
'http://www.lnx.lu/',
# Why: #6298 in Alexa global
'http://www.divxplanet.com/',
# Why: #6299 in Alexa global
'http://www.aircanada.com/',
# Why: #6300 in Alexa global
'http://uzise.com/',
# Why: #6301 in Alexa global
'http://www.sabay.com.kh/',
# Why: #6302 in Alexa global
'http://www.football365.com/',
# Why: #6303 in Alexa global
'http://www.crazydomains.com.au/',
# Why: #6304 in Alexa global
'http://www.qxox.org/',
# Why: #6305 in Alexa global
'http://www.thesmokinggun.com/',
# Why: #6306 in Alexa global
'http://www.w8n3.info/',
# Why: #6307 in Alexa global
'http://www.po.st/',
# Why: #6308 in Alexa global
'http://www.debian.org/',
# Why: #6309 in Alexa global
'http://www.flypgs.com/',
# Why: #6310 in Alexa global
'http://www.craigslist.co.in/',
# Why: #6311 in Alexa global
'http://www.islamway.net/',
# Why: #6312 in Alexa global
'http://www.research-panel.jp/',
# Why: #6313 in Alexa global
'http://www.debate.com.mx/',
# Why: #6314 in Alexa global
'http://www.bitdefender.com/',
# Why: #6315 in Alexa global
'http://www.listindiario.com/',
# Why: #6316 in Alexa global
'http://www.123telugu.com/',
# Why: #6317 in Alexa global
'http://www.ilbe.com/',
# Why: #6318 in Alexa global
'http://www.wordlinx.com/',
# Why: #6319 in Alexa global
'http://www.ebc.com.br/',
# Why: #6320 in Alexa global
'http://www.pr.gov.br/',
# Why: #6321 in Alexa global
'http://www.videoyoum7.com/',
# Why: #6322 in Alexa global
'http://www.ets.org/',
# Why: #6323 in Alexa global
'http://www.exteen.com/',
# Why: #6324 in Alexa global
'http://www.comicbookresources.com/',
# Why: #6325 in Alexa global
'http://www.grammarly.com/',
# Why: #6326 in Alexa global
'http://www.pdapi.com/',
# Why: #6327 in Alexa global
'http://adultflash01.com/',
# Why: #6328 in Alexa global
'http://www.orlandosentinel.com/',
# Why: #6330 in Alexa global
'http://www.24option.com/',
# Why: #6331 in Alexa global
'http://www.moviepilot.de/',
# Why: #6332 in Alexa global
'http://www.rfa.org/',
# Why: #6333 in Alexa global
'http://www.crateandbarrel.com/',
# Why: #6334 in Alexa global
'http://www.srv2trking.com/',
# Why: #6335 in Alexa global
'http://www.mercusuar.info/',
# Why: #6336 in Alexa global
'http://www.dofus.com/',
# Why: #6337 in Alexa global
'http://www.myfxbook.com/',
# Why: #6338 in Alexa global
'http://www.madmovs.com/',
# Why: #6339 in Alexa global
'http://www.myffi.biz/',
# Why: #6340 in Alexa global
'http://www.peru21.pe/',
# Why: #6341 in Alexa global
'http://www.bollywoodlife.com/',
# Why: #6342 in Alexa global
'http://www.gametracker.com/',
# Why: #6343 in Alexa global
'http://www.terra.com.mx/',
# Why: #6344 in Alexa global
'http://www.antenam.info/',
# Why: #6345 in Alexa global
'http://www.ihotelier.com/',
# Why: #6346 in Alexa global
'http://www.hypebeast.com/',
# Why: #6348 in Alexa global
'http://www.dramasonline.com/',
# Why: #6349 in Alexa global
'http://www.wordtracker.com/',
# Why: #6350 in Alexa global
'http://www.11st.co.kr/',
# Why: #6351 in Alexa global
'http://www.thefrisky.com/',
# Why: #6352 in Alexa global
'http://www.meritnation.com/',
# Why: #6353 in Alexa global
'http://www.irna.ir/',
# Why: #6354 in Alexa global
'http://www.trovit.com/',
# Why: #6355 in Alexa global
'http://cngold.org/',
# Why: #6356 in Alexa global
'http://www.optymalizacja.com/',
# Why: #6357 in Alexa global
'http://www.flexmls.com/',
# Why: #6358 in Alexa global
'http://www.softarchive.net/',
# Why: #6359 in Alexa global
'http://www.divxonline.info/',
# Why: #6360 in Alexa global
'http://www.malaysian-inc.com/',
# Why: #6361 in Alexa global
'http://www.dsw.com/',
# Why: #6362 in Alexa global
'http://www.fantastigames.com/',
# Why: #6363 in Alexa global
'http://www.mattcutts.com/',
# Why: #6364 in Alexa global
'http://www.ziprealty.com/',
# Why: #6365 in Alexa global
'http://www.saavn.com/',
# Why: #6366 in Alexa global
'http://www.ruporn.tv/',
# Why: #6367 in Alexa global
'http://www.e-estekhdam.com/',
# Why: #6368 in Alexa global
'http://www.novafile.com/',
# Why: #6369 in Alexa global
'http://tomsguide.fr/',
# Why: #6370 in Alexa global
'http://www.softonic.jp/',
# Why: #6371 in Alexa global
'http://www.tomshardware.co.uk/',
# Why: #6372 in Alexa global
'http://www.crosswalk.com/',
# Why: #6373 in Alexa global
'http://www.businessdictionary.com/',
# Why: #6374 in Alexa global
'http://www.sharesix.com/',
# Why: #6375 in Alexa global
'http://www.ascii.jp/',
# Why: #6376 in Alexa global
'http://www.travian.cl/',
# Why: #6377 in Alexa global
'http://www.indiastudychannel.com/',
# Why: #6378 in Alexa global
'http://www.m7shsh.com/',
# Why: #6379 in Alexa global
'http://www.hbogo.com/',
# Why: #6380 in Alexa global
'http://www.888casino.it/',
# Why: #6381 in Alexa global
'http://www.fm-p.jp/',
# Why: #6382 in Alexa global
'http://www.keywordspy.com/',
# Why: #6383 in Alexa global
'http://www.pureleverage.com/',
# Why: #6384 in Alexa global
'http://www.photodune.net/',
# Why: #6385 in Alexa global
'http://www.foreignpolicy.com/',
# Why: #6386 in Alexa global
'http://www.shiftdelete.net/',
# Why: #6387 in Alexa global
'http://www.living360.net/',
# Why: #6388 in Alexa global
'http://webmasterhome.cn/',
# Why: #6389 in Alexa global
'http://www.paixie.net/',
# Why: #6390 in Alexa global
'http://www.barstoolsports.com/',
# Why: #6391 in Alexa global
'http://www.babyhome.com.tw/',
# Why: #6392 in Alexa global
'http://www.aemet.es/',
# Why: #6393 in Alexa global
'http://www.local.ch/',
# Why: #6394 in Alexa global
'http://www.spermyporn.com/',
# Why: #6395 in Alexa global
'http://www.tasnimnews.com/',
# Why: #6396 in Alexa global
'http://www.imgserve.net/',
# Why: #6397 in Alexa global
'http://www.huawei.com/',
# Why: #6398 in Alexa global
'http://www.pik.ba/',
# Why: #6399 in Alexa global
'http://www.info-dvd.ru/',
# Why: #6400 in Alexa global
'http://www.2domains.ru/',
# Why: #6401 in Alexa global
'http://www.sextube.fm/',
# Why: #6402 in Alexa global
'http://www.searchrocket.info/',
# Why: #6403 in Alexa global
'http://www.dicio.com.br/',
# Why: #6404 in Alexa global
'http://www.ittefaq.com.bd/',
# Why: #6405 in Alexa global
'http://www.fileserve.com/',
# Why: #6406 in Alexa global
'http://www.genteflow.com/',
# Why: #6407 in Alexa global
'http://www.5giay.vn/',
# Why: #6408 in Alexa global
'http://www.elbadil.com/',
# Why: #6409 in Alexa global
'http://www.wizaz.pl/',
# Why: #6410 in Alexa global
'http://www.cyclingnews.com/',
# Why: #6411 in Alexa global
'http://www.southparkstudios.com/',
# Why: #6412 in Alexa global
'http://www.domain.cn/',
# Why: #6413 in Alexa global
'http://www.hangseng.com/',
# Why: #6414 in Alexa global
'http://www.sankeibiz.jp/',
# Why: #6415 in Alexa global
'http://www.mapsofworld.com/',
# Why: #6416 in Alexa global
'http://gaokao.com/',
# Why: #6417 in Alexa global
'http://www.antarvasna.com/',
# Why: #6418 in Alexa global
'http://www.televisa.com/',
# Why: #6419 in Alexa global
'http://www.dressupwho.com/',
# Why: #6420 in Alexa global
'http://www.goldprice.org/',
# Why: #6421 in Alexa global
'http://www.directlyrics.com/',
# Why: #6422 in Alexa global
'http://www.amway.com.cn/',
# Why: #6423 in Alexa global
'http://www.v2cigar.net/',
# Why: #6424 in Alexa global
'http://www.peopleclick.com/',
# Why: #6425 in Alexa global
'http://www.moudamepo.com/',
# Why: #6426 in Alexa global
'http://www.baijob.com/',
# Why: #6427 in Alexa global
'http://www.geni.com/',
# Why: #6428 in Alexa global
'http://huangye88.com/',
# Why: #6429 in Alexa global
'http://www.phun.org/',
# Why: #6430 in Alexa global
'http://www.kasikornbankgroup.com/',
# Why: #6431 in Alexa global
'http://www.angrymovs.com/',
# Why: #6432 in Alexa global
'http://www.bibliocommons.com/',
# Why: #6433 in Alexa global
'http://www.melateiran.com/',
# Why: #6434 in Alexa global
'http://www.gigya.com/',
# Why: #6435 in Alexa global
'http://17ok.com/',
# Why: #6436 in Alexa global
'http://www.ename.cn/',
# Why: #6437 in Alexa global
'http://www.xdowns.com/',
# Why: #6438 in Alexa global
'http://www.tportal.hr/',
# Why: #6439 in Alexa global
'http://www.dreamteammoney.com/',
# Why: #6440 in Alexa global
'http://www.prevention.com/',
# Why: #6441 in Alexa global
'http://www.terra.cl/',
# Why: #6442 in Alexa global
'http://www.blinklist.com/',
# Why: #6443 in Alexa global
'http://www.51seer.com/',
# Why: #6444 in Alexa global
'http://www.ruelsoft.com/',
# Why: #6445 in Alexa global
'http://www.kulichki.net/',
# Why: #6446 in Alexa global
'http://vippers.jp/',
# Why: #6447 in Alexa global
'http://www.tatatele.in/',
# Why: #6448 in Alexa global
'http://www.mybloggertricks.com/',
# Why: #6449 in Alexa global
'http://www.ma-bimbo.com/',
# Why: #6450 in Alexa global
'http://www.ftchinese.com/',
# Why: #6451 in Alexa global
'http://www.sergey-mavrodi-mmm.net/',
# Why: #6452 in Alexa global
'http://www.wp.tv/',
# Why: #6453 in Alexa global
'http://www.chevrolet.com/',
# Why: #6454 in Alexa global
'http://www.razerzone.com/',
# Why: #6455 in Alexa global
'http://www.submanga.com/',
# Why: #6456 in Alexa global
'http://www.thomson.co.uk/',
# Why: #6457 in Alexa global
'http://www.syosetu.org/',
# Why: #6458 in Alexa global
'http://www.olx.com/',
# Why: #6459 in Alexa global
'http://www.vplay.ro/',
# Why: #6460 in Alexa global
'http://www.rtnn.net/',
# Why: #6461 in Alexa global
'http://www.55.la/',
# Why: #6462 in Alexa global
'http://www.instructure.com/',
# Why: #6463 in Alexa global
'http://lvse.com/',
# Why: #6464 in Alexa global
'http://www.hvg.hu/',
# Why: #6465 in Alexa global
'http://www.androidpolice.com/',
# Why: #6466 in Alexa global
'http://www.cookinglight.com/',
# Why: #6467 in Alexa global
'http://www.madadsmedia.com/',
# Why: #6468 in Alexa global
'http://www.inews.gr/',
# Why: #6469 in Alexa global
'http://www.ktxp.com/',
# Why: #6470 in Alexa global
'http://www.socialsecurity.gov/',
# Why: #6471 in Alexa global
'http://www.equifax.com/',
# Why: #6472 in Alexa global
'http://www.ceskatelevize.cz/',
# Why: #6473 in Alexa global
'http://www.gaaks.com/',
# Why: #6474 in Alexa global
'http://www.chillingeffects.org/',
# Why: #6476 in Alexa global
'http://www.komando.com/',
# Why: #6477 in Alexa global
'http://www.nowpublic.com/',
# Why: #6478 in Alexa global
'http://www.khanwars.ae/',
# Why: #6479 in Alexa global
'http://www.berlin.de/',
# Why: #6480 in Alexa global
'http://www.bleepingcomputer.com/',
# Why: #6481 in Alexa global
'http://www.military.com/',
# Why: #6482 in Alexa global
'http://www.zero10.net/',
# Why: #6483 in Alexa global
'http://www.onekingslane.com/',
# Why: #6484 in Alexa global
'http://www.beget.ru/',
# Why: #6486 in Alexa global
'http://www.get-tune.net/',
# Why: #6487 in Alexa global
'http://www.freewebs.com/',
# Why: #6489 in Alexa global
'http://www.591.com.tw/',
# Why: #6490 in Alexa global
'http://www.pcfinancial.ca/',
# Why: #6491 in Alexa global
'http://www.sparknotes.com/',
# Why: #6492 in Alexa global
'http://www.tinychat.com/',
# Why: #6493 in Alexa global
'http://luxup.ru/',
# Why: #6494 in Alexa global
'http://www.geforce.com/',
# Why: #6495 in Alexa global
'http://www.tatts.com.au/',
# Why: #6496 in Alexa global
'http://www.alweeam.com.sa/',
# Why: #6497 in Alexa global
'http://www.123-reg.co.uk/',
# Why: #6498 in Alexa global
'http://www.sexyswingertube.com/',
# Why: #6499 in Alexa global
'http://www.groupon.es/',
# Why: #6500 in Alexa global
'http://www.guardianlv.com/',
# Why: #6501 in Alexa global
'http://www.hypovereinsbank.de/',
# Why: #6502 in Alexa global
'http://www.game2.com.cn/',
# Why: #6503 in Alexa global
'http://www.mofcom.gov.cn/',
# Why: #6504 in Alexa global
'http://www.usc.edu/',
# Why: #6505 in Alexa global
'http://www.ard.de/',
# Why: #6506 in Alexa global
'http://www.hoovers.com/',
# Why: #6507 in Alexa global
'http://www.tdameritrade.com/',
# Why: #6508 in Alexa global
'http://www.userscripts.org/',
# Why: #6509 in Alexa global
'http://app111.com/',
# Why: #6510 in Alexa global
'http://www.al.com/',
# Why: #6511 in Alexa global
'http://www.op.fi/',
# Why: #6512 in Alexa global
'http://www.adbkm.com/',
# Why: #6513 in Alexa global
'http://www.i-part.com.tw/',
# Why: #6514 in Alexa global
'http://www.pivithurutv.info/',
# Why: #6515 in Alexa global
'http://www.haber3.com/',
# Why: #6516 in Alexa global
'http://www.shatel.ir/',
# Why: #6517 in Alexa global
'http://www.camonster.com/',
# Why: #6518 in Alexa global
'http://www.weltbild.de/',
# Why: #6519 in Alexa global
'http://www.pingan.com.cn/',
# Why: #6520 in Alexa global
'http://www.advanceautoparts.com/',
# Why: #6521 in Alexa global
'http://www.mplssaturn.com/',
# Why: #6522 in Alexa global
'http://www.weeklystandard.com/',
# Why: #6523 in Alexa global
'http://www.cna.com.tw/',
# Why: #6524 in Alexa global
'http://www.popscreen.com/',
# Why: #6525 in Alexa global
'http://www.freelifetimefuckbook.com/',
# Why: #6526 in Alexa global
'http://www.peixeurbano.com.br/',
# Why: #6527 in Alexa global
'http://www.2258.com/',
# Why: #6528 in Alexa global
'http://www.proxfree.com/',
# Why: #6529 in Alexa global
'http://www.zend.com/',
# Why: #6530 in Alexa global
'http://www.garena.tw/',
# Why: #6531 in Alexa global
'http://www.citehr.com/',
# Why: #6532 in Alexa global
'http://www.gadyd.com/',
# Why: #6533 in Alexa global
'http://www.tvspielfilm.de/',
# Why: #6534 in Alexa global
'http://www.skapiec.pl/',
# Why: #6535 in Alexa global
'http://www.9see.com/',
# Why: #6536 in Alexa global
'http://cndns.com/',
# Why: #6537 in Alexa global
'http://www.hurriyetemlak.com/',
# Why: #6538 in Alexa global
'http://www.census.gov/',
# Why: #6539 in Alexa global
'http://www.collider.com/',
# Why: #6540 in Alexa global
'http://www.cinaplay.com/',
# Why: #6542 in Alexa global
'http://www.aq.com/',
# Why: #6543 in Alexa global
'http://www.aolsearch.com/',
# Why: #6544 in Alexa global
'http://www.ce4arab.com/',
# Why: #6546 in Alexa global
'http://www.cbi.ir/',
# Why: #6547 in Alexa global
'http://cjol.com/',
# Why: #6548 in Alexa global
'http://www.brandporno.com/',
# Why: #6549 in Alexa global
'http://www.yicheshi.com/',
# Why: #6550 in Alexa global
'http://www.mydealz.de/',
# Why: #6551 in Alexa global
'http://www.xiachufang.com/',
# Why: #6552 in Alexa global
'http://www.sun-sentinel.com/',
# Why: #6553 in Alexa global
'http://www.flashkhor.com/',
# Why: #6554 in Alexa global
'http://www.join.me/',
# Why: #6555 in Alexa global
'http://www.hankyung.com/',
# Why: #6556 in Alexa global
'http://www.oneandone.co.uk/',
# Why: #6557 in Alexa global
'http://www.derwesten.de/',
# Why: #6558 in Alexa global
'http://www.gammae.com/',
# Why: #6559 in Alexa global
'http://www.webadultdating.biz/',
# Why: #6560 in Alexa global
'http://www.pokerstars.com/',
# Why: #6561 in Alexa global
'http://www.fucked-sex.com/',
# Why: #6562 in Alexa global
'http://www.antaranews.com/',
# Why: #6563 in Alexa global
'http://www.banorte.com/',
# Why: #6564 in Alexa global
'http://www.travian.it/',
# Why: #6565 in Alexa global
'http://www.msu.edu/',
# Why: #6566 in Alexa global
'http://www.ozbargain.com.au/',
# Why: #6567 in Alexa global
'http://www.77vcd.com/',
# Why: #6568 in Alexa global
'http://www.bestooxx.com/',
# Why: #6569 in Alexa global
'http://www.siemens.com/',
# Why: #6570 in Alexa global
'http://www.en-japan.com/',
# Why: #6571 in Alexa global
'http://www.akbank.com/',
# Why: #6572 in Alexa global
'http://www.srf.ch/',
# Why: #6573 in Alexa global
'http://www.meijer.com/',
# Why: #6574 in Alexa global
'http://www.htmldrive.net/',
# Why: #6575 in Alexa global
'http://www.peoplestylewatch.com/',
# Why: #6576 in Alexa global
'http://www.4008823823.com.cn/',
# Why: #6577 in Alexa global
'http://www.boards.ie/',
# Why: #6578 in Alexa global
'http://www.zhulong.com/',
# Why: #6579 in Alexa global
'http://www.svyaznoybank.ru/',
# Why: #6580 in Alexa global
'http://www.myfilestore.com/',
# Why: #6581 in Alexa global
'http://www.sucuri.net/',
# Why: #6582 in Alexa global
'http://www.redflagdeals.com/',
# Why: #6583 in Alexa global
'http://www.gxnews.com.cn/',
# Why: #6584 in Alexa global
'http://www.javascriptkit.com/',
# Why: #6585 in Alexa global
'http://www.edreams.fr/',
# Why: #6586 in Alexa global
'http://www.wral.com/',
# Why: #6587 in Alexa global
'http://www.togetter.com/',
# Why: #6588 in Alexa global
'http://www.dmi.dk/',
# Why: #6589 in Alexa global
'http://www.thinkdigit.com/',
# Why: #6590 in Alexa global
'http://www.barclaycard.co.uk/',
# Why: #6591 in Alexa global
'http://www.comm100.com/',
# Why: #6592 in Alexa global
'http://www.christianbook.com/',
# Why: #6593 in Alexa global
'http://www.popularmechanics.com/',
# Why: #6594 in Alexa global
'http://www.taste.com.au/',
# Why: #6595 in Alexa global
'http://www.tripadvisor.ru/',
# Why: #6596 in Alexa global
'http://www.colissimo.fr/',
# Why: #6597 in Alexa global
'http://www.gdposir.info/',
# Why: #6598 in Alexa global
'http://www.rarlab.com/',
# Why: #6599 in Alexa global
'http://www.dcnepalevent.com/',
# Why: #6600 in Alexa global
'http://www.sagepub.com/',
# Why: #6601 in Alexa global
'http://www.markosweb.com/',
# Why: #6602 in Alexa global
'http://www.france3.fr/',
# Why: #6603 in Alexa global
'http://www.mindbodyonline.com/',
# Why: #6604 in Alexa global
'http://www.yapo.cl/',
# Why: #6605 in Alexa global
'http://www.0-6.com/',
# Why: #6606 in Alexa global
'http://www.dilbert.com/',
# Why: #6607 in Alexa global
'http://www.searchqu.com/',
# Why: #6608 in Alexa global
'http://www.usa.gov/',
# Why: #6609 in Alexa global
'http://www.vatandownload.com/',
# Why: #6610 in Alexa global
'http://www.nastymovs.com/',
# Why: #6611 in Alexa global
'http://www.santanderrio.com.ar/',
# Why: #6612 in Alexa global
'http://www.notebookcheck.net/',
# Why: #6613 in Alexa global
'http://www.canalplus.fr/',
# Why: #6614 in Alexa global
'http://www.coocan.jp/',
# Why: #6615 in Alexa global
'http://www.goodreads.com/user/show/',
# Why: #6616 in Alexa global
'http://www.epa.gov/',
# Why: #6617 in Alexa global
'http://www.disp.cc/',
# Why: #6618 in Alexa global
'http://www.hotsales.net/',
# Why: #6619 in Alexa global
'http://www.interpals.net/',
# Why: #6620 in Alexa global
'http://www.vz.ru/',
# Why: #6621 in Alexa global
'http://www.flyertalk.com/',
# Why: #6622 in Alexa global
'http://www.pjmedia.com/',
# Why: #6623 in Alexa global
'http://www.solomid.net/',
# Why: #6624 in Alexa global
'http://www.megaplan.ru/',
# Why: #6625 in Alexa global
'http://www.hatenablog.com/',
# Why: #6626 in Alexa global
'http://www.getsatisfaction.com/',
# Why: #6627 in Alexa global
'http://www.hotline.ua/',
# Why: #6628 in Alexa global
'http://www.alternativeto.net/',
# Why: #6629 in Alexa global
'http://www.hipfile.com/',
# Why: #6630 in Alexa global
'http://www.247sports.com/',
# Why: #6631 in Alexa global
'http://www.phpnuke.org/',
# Why: #6632 in Alexa global
'http://www.indiaresults.com/',
# Why: #6633 in Alexa global
'http://www.prisjakt.nu/',
# Why: #6634 in Alexa global
'http://www.1tvlive.in/',
# Why: #6635 in Alexa global
'http://www.e-mai.net/',
# Why: #6636 in Alexa global
'http://www.trafficg.com/',
# Why: #6637 in Alexa global
'http://www.ojogo.pt/',
# Why: #6638 in Alexa global
'http://www.totaldomination.com/',
# Why: #6639 in Alexa global
'http://www.eroino.net/',
# Why: #6640 in Alexa global
'http://www.network-tools.com/',
# Why: #6641 in Alexa global
'http://www.unibytes.com/',
# Why: #6642 in Alexa global
'http://www.seriouseats.com/',
# Why: #6643 in Alexa global
'http://www.twicsy.com/',
# Why: #6644 in Alexa global
'http://www.smbc-card.com/',
# Why: #6645 in Alexa global
'http://toocle.com/',
# Why: #6646 in Alexa global
'http://www.unbounce.com/',
# Why: #6647 in Alexa global
'http://www.2tu.cc/',
# Why: #6648 in Alexa global
'http://www.computerworld.com/',
# Why: #6649 in Alexa global
'http://www.clicktrackprofit.com/',
# Why: #6650 in Alexa global
'http://www.serialu.net/',
# Why: #6651 in Alexa global
'http://www.realfarmacy.com/',
# Why: #6652 in Alexa global
'http://metrodeal.com/',
# Why: #6653 in Alexa global
'http://www.binzhi.com/',
# Why: #6654 in Alexa global
'http://www.smilebox.com/',
# Why: #6655 in Alexa global
'http://www.coderanch.com/',
# Why: #6656 in Alexa global
'http://www.uptodown.com/',
# Why: #6657 in Alexa global
'http://www.vbulletin.com/',
# Why: #6658 in Alexa global
'http://www.teasernet.com/',
# Why: #6659 in Alexa global
'http://www.hulu.jp/',
# Why: #6660 in Alexa global
'http://www.admob.com/',
# Why: #6661 in Alexa global
'http://www.fingerhut.com/',
# Why: #6662 in Alexa global
'http://www.urlopener.com/',
# Why: #6663 in Alexa global
'http://www.vi.nl/',
# Why: #6664 in Alexa global
'http://www.gamebase.com.tw/',
# Why: #6665 in Alexa global
'http://www.expedia.de/',
# Why: #6666 in Alexa global
'http://www.thekrazycouponlady.com/',
# Why: #6667 in Alexa global
'http://www.linezing.com/',
# Why: #6668 in Alexa global
'http://www.metropcs.com/',
# Why: #6670 in Alexa global
'http://www.draugas.lt/',
# Why: #6671 in Alexa global
'http://www.minecraftdl.com/',
# Why: #6672 in Alexa global
'http://www.airberlin.com/',
# Why: #6673 in Alexa global
'http://www.eelly.com/',
# Why: #6674 in Alexa global
'http://www.siamsport.co.th/',
# Why: #6675 in Alexa global
'http://www.e-junkie.com/',
# Why: #6676 in Alexa global
'http://www.gulte.com/',
# Why: #6677 in Alexa global
'http://www.lazada.com.ph/',
# Why: #6678 in Alexa global
'http://www.cnwnews.com/',
# Why: #6679 in Alexa global
'http://www.tekstowo.pl/',
# Why: #6680 in Alexa global
'http://www.flavorwire.com/',
# Why: #6681 in Alexa global
'http://www.settrade.com/',
# Why: #6682 in Alexa global
'http://www.francetv.fr/',
# Why: #6683 in Alexa global
'http://www.experian.com/',
# Why: #6684 in Alexa global
'http://www.bravenet.com/',
# Why: #6685 in Alexa global
'http://www.mytoys.de/',
# Why: #6686 in Alexa global
'http://www.inkthemes.com/',
# Why: #6687 in Alexa global
'http://www.brobible.com/',
# Why: #6688 in Alexa global
'http://www.sarenza.com/',
# Why: #6689 in Alexa global
'http://www.curse.com/',
# Why: #6690 in Alexa global
'http://www.iresearch.cn/',
# Why: #6691 in Alexa global
'http://www.lohaco.jp/',
# Why: #6692 in Alexa global
'http://www.7sur7.be/',
# Why: #6693 in Alexa global
'http://www.iberia.com/',
# Why: #6694 in Alexa global
'http://www.trovit.es/',
# Why: #6695 in Alexa global
'http://www.eiga.com/',
# Why: #6696 in Alexa global
'http://saga123.cn/',
# Why: #6697 in Alexa global
'http://www.getuploader.com/',
# Why: #6698 in Alexa global
'http://www.sevendollarptc.com/',
# Why: #6699 in Alexa global
'http://www.amadeus.com/',
# Why: #6700 in Alexa global
'http://www.thedailystar.net/',
# Why: #6701 in Alexa global
'http://www.gofuckbiz.com/',
# Why: #6702 in Alexa global
'http://www.codepen.io/',
# Why: #6703 in Alexa global
'http://www.virginia.gov/',
# Why: #6704 in Alexa global
'http://www.linguee.fr/',
# Why: #6705 in Alexa global
'http://www.space.com/',
# Why: #6706 in Alexa global
'http://www.astrology.com/',
# Why: #6707 in Alexa global
'http://www.whmcs.com/',
# Why: #6708 in Alexa global
'http://www.blogher.com/',
# Why: #6709 in Alexa global
'http://www.netpnb.com/',
# Why: #6710 in Alexa global
'http://www.mojo-themes.com/',
# Why: #6711 in Alexa global
'http://www.cam4.es/',
# Why: #6712 in Alexa global
'http://www.bestwestern.com/',
# Why: #6713 in Alexa global
'http://www.gencat.cat/',
# Why: #6714 in Alexa global
'http://www.healthcentral.com/',
# Why: #6715 in Alexa global
'http://www.ru-board.com/',
# Why: #6716 in Alexa global
'http://www.tjsp.jus.br/',
# Why: #6717 in Alexa global
'http://www.scene7.com/',
# Why: #6718 in Alexa global
'http://www.bukalapak.com/',
# Why: #6720 in Alexa global
'http://www.intporn.com/',
# Why: #6721 in Alexa global
'http://www.xe.gr/',
# Why: #6722 in Alexa global
'http://www.leprosorium.ru/',
# Why: #6723 in Alexa global
'http://www.dytt8.net/',
# Why: #6724 in Alexa global
'http://www.wpcentral.com/',
# Why: #6725 in Alexa global
'http://www.fasttrafficformula.com/',
# Why: #6726 in Alexa global
'http://www.hugefiles.net/',
# Why: #6727 in Alexa global
'http://www.you-sex-tube.com/',
# Why: #6728 in Alexa global
'http://www.naukrigulf.com/',
# Why: #6729 in Alexa global
'http://5173.com/',
# Why: #6730 in Alexa global
'http://www.comicvip.com/',
# Why: #6731 in Alexa global
'http://www.jossandmain.com/',
# Why: #6732 in Alexa global
'http://www.motherjones.com/',
# Why: #6733 in Alexa global
'http://www.planet.fr/',
# Why: #6734 in Alexa global
'http://www.thomascook.com/',
# Why: #6735 in Alexa global
'http://www.deseretnews.com/',
# Why: #6736 in Alexa global
'http://www.aawsat.com/',
# Why: #6737 in Alexa global
'http://www.huntington.com/',
# Why: #6738 in Alexa global
'http://www.desimartini.com/',
# Why: #6739 in Alexa global
'http://www.maloumaa.blogspot.com/',
# Why: #6740 in Alexa global
'http://www.rutgers.edu/',
# Why: #6741 in Alexa global
'http://www.gratisjuegos.org/',
# Why: #6742 in Alexa global
'http://www.carsforsale.com/',
# Why: #6743 in Alexa global
'http://www.filestore72.info/',
# Why: #6744 in Alexa global
'http://www.neowin.net/',
# Why: #6745 in Alexa global
'http://www.ilgiornale.it/',
# Why: #6746 in Alexa global
'http://www.download0098.com/',
# Why: #6747 in Alexa global
'http://www.providesupport.com/',
# Why: #6748 in Alexa global
'http://www.postini.com/',
# Why: #6749 in Alexa global
'http://www.sinowaypromo.com/',
# Why: #6750 in Alexa global
'http://www.watchop.com/',
# Why: #6751 in Alexa global
'http://www.docusign.net/',
# Why: #6752 in Alexa global
'http://www.sourcenext.com/',
# Why: #6753 in Alexa global
'http://www.finviz.com/',
# Why: #6754 in Alexa global
'http://www.babyoye.com/',
# Why: #6755 in Alexa global
'http://www.andhrajyothy.com/',
# Why: #6756 in Alexa global
'http://www.gamezer.com/',
# Why: #6757 in Alexa global
'http://www.baozoumanhua.com/',
# Why: #6758 in Alexa global
'http://www.niusnews.com/',
# Why: #6759 in Alexa global
'http://www.yabancidiziizle.net/',
# Why: #6760 in Alexa global
'http://www.fodors.com/',
# Why: #6761 in Alexa global
'http://www.moonsy.com/',
# Why: #6762 in Alexa global
'http://www.lidl.it/',
# Why: #6763 in Alexa global
'http://www.betanews.com/',
# Why: #6764 in Alexa global
'http://www.auone.jp/',
# Why: #6765 in Alexa global
'http://www.escapistmagazine.com/',
# Why: #6766 in Alexa global
'http://www.markethealth.com/',
# Why: #6767 in Alexa global
'http://www.clicksure.com/',
# Why: #6768 in Alexa global
'http://www.aircel.com/',
# Why: #6769 in Alexa global
'http://www.metacrawler.com/',
# Why: #6770 in Alexa global
'http://www.aeat.es/',
# Why: #6771 in Alexa global
'http://www.allafrica.com/',
# Why: #6772 in Alexa global
'http://www.watchseries-online.eu/',
# Why: #6773 in Alexa global
'http://www.adpost.com/',
# Why: #6774 in Alexa global
'http://www.adac.de/',
# Why: #6775 in Alexa global
'http://www.similarweb.com/',
# Why: #6776 in Alexa global
'http://www.offervault.com/',
# Why: #6777 in Alexa global
'http://www.uolhost.com.br/',
# Why: #6778 in Alexa global
'http://www.moviestarplanet.com/',
# Why: #6779 in Alexa global
'http://www.overclockers.ru/',
# Why: #6780 in Alexa global
'http://www.rocketlanguages.com/',
# Why: #6781 in Alexa global
'http://www.finya.de/',
# Why: #6782 in Alexa global
'http://www.shahvani.com/',
# Why: #6783 in Alexa global
'http://www.firmy.cz/',
# Why: #6784 in Alexa global
'http://www.incometaxindia.gov.in/',
# Why: #6785 in Alexa global
'http://www.ecostream.tv/',
# Why: #6786 in Alexa global
'http://www.pcwelt.de/',
# Why: #6787 in Alexa global
'http://www.arcadesafari.com/',
# Why: #6788 in Alexa global
'http://www.shoghlanty.com/',
# Why: #6789 in Alexa global
'http://www.videosection.com/',
# Why: #6790 in Alexa global
'http://www.jcb.co.jp/',
# Why: #6792 in Alexa global
'http://www.centauro.com.br/',
# Why: #6793 in Alexa global
'http://www.eroanimedouga.net/',
# Why: #6794 in Alexa global
'http://www.orientaltrading.com/',
# Why: #6795 in Alexa global
'http://www.tsutaya.co.jp/',
# Why: #6796 in Alexa global
'http://www.ogone.com/',
# Why: #6798 in Alexa global
'http://www.sexlog.com/',
# Why: #6799 in Alexa global
'http://www.hotair.com/',
# Why: #6800 in Alexa global
'http://www.egypt.gov.eg/',
# Why: #6801 in Alexa global
'http://www.thomasnet.com/',
# Why: #6802 in Alexa global
'http://www.virustotal.com/',
# Why: #6803 in Alexa global
'http://www.hayneedle.com/',
# Why: #6804 in Alexa global
'http://www.fatburningfurnace.com/',
# Why: #6805 in Alexa global
'http://www.lovedgames.com/',
# Why: #6806 in Alexa global
'http://www.gov.cn/',
# Why: #6807 in Alexa global
'http://www.23us.com/',
# Why: #6808 in Alexa global
'http://www.trafficcaptain.com/',
# Why: #6810 in Alexa global
'http://www.v2cigs.com/',
# Why: #6811 in Alexa global
'http://www.teknosa.com.tr/',
# Why: #6812 in Alexa global
'http://www.skrill.com/',
# Why: #6813 in Alexa global
'http://www.puritanas.com/',
# Why: #6814 in Alexa global
'http://www.selfgrowth.com/',
# Why: #6815 in Alexa global
'http://www.ikco.com/',
# Why: #6816 in Alexa global
'http://www.saisoncard.co.jp/',
# Why: #6817 in Alexa global
'http://www.cuisineaz.com/',
# Why: #6818 in Alexa global
'http://www.causes.com/',
# Why: #6819 in Alexa global
'http://www.democraticunderground.com/',
# Why: #6820 in Alexa global
'http://www.placesexy.com/',
# Why: #6821 in Alexa global
'http://www.expedia.co.uk/',
# Why: #6822 in Alexa global
'http://www.www-com.co/',
# Why: #6823 in Alexa global
'http://www.topmongol.com/',
# Why: #6824 in Alexa global
'http://www.hikaritube.com/',
# Why: #6825 in Alexa global
'http://www.amakings.com/',
# Why: #6826 in Alexa global
'http://www.fxstreet.com/',
# Why: #6827 in Alexa global
'http://www.consultant.ru/',
# Why: #6828 in Alexa global
'http://www.sacbee.com/',
# Why: #6829 in Alexa global
'http://www.supercheats.com/',
# Why: #6830 in Alexa global
'http://www.sofunnylol.com/',
# Why: #6831 in Alexa global
'http://www.muzy.com/',
# Why: #6832 in Alexa global
'http://www.sparda.de/',
# Why: #6833 in Alexa global
'http://www.caughtoffside.com/',
# Why: #6834 in Alexa global
'http://www.chinawomendating.asia/',
# Why: #6835 in Alexa global
'http://www.xmeeting.com/',
# Why: #6836 in Alexa global
'http://www.google.al/',
# Why: #6837 in Alexa global
'http://www.sovereignbank.com/',
# Why: #6838 in Alexa global
'http://www.animeflv.net/',
# Why: #6839 in Alexa global
'http://www.sky.de/',
# Why: #6840 in Alexa global
'http://www.huatu.com/',
# Why: #6841 in Alexa global
'http://www.payscale.com/',
# Why: #6842 in Alexa global
'http://www.quotidiano.net/',
# Why: #6843 in Alexa global
'http://www.pol.ir/',
# Why: #6844 in Alexa global
'http://www.digital-photography-school.com/',
# Why: #6845 in Alexa global
'http://www.screencrush.com/',
# Why: #6846 in Alexa global
'http://www.battlenet.com.cn/',
# Why: #6847 in Alexa global
'http://www.netgear.com/',
# Why: #6848 in Alexa global
'http://www.thebiglistofporn.com/',
# Why: #6849 in Alexa global
'http://www.similarsitesearch.com/',
# Why: #6850 in Alexa global
'http://www.peb.pl/',
# Why: #6851 in Alexa global
'http://www.lanrentuku.com/',
# Why: #6852 in Alexa global
'http://www.ksu.edu.sa/',
# Why: #6853 in Alexa global
'http://www.tradetracker.com/',
# Why: #6855 in Alexa global
'http://www.d.cn/',
# Why: #6856 in Alexa global
'http://www.avito.ma/',
# Why: #6857 in Alexa global
'http://www.projectfree.tv/',
# Why: #6858 in Alexa global
'http://www.cmu.edu/',
# Why: #6859 in Alexa global
'http://www.imore.com/',
# Why: #6860 in Alexa global
'http://www.tickld.com/',
# Why: #6861 in Alexa global
'http://www.fitday.com/',
# Why: #6862 in Alexa global
'http://www.dulcebank.com/',
# Why: #6863 in Alexa global
'http://www.careerdonkey.com/',
# Why: #6864 in Alexa global
'http://www.pf.pl/',
# Why: #6865 in Alexa global
'http://www.otzovik.com/',
# Why: #6866 in Alexa global
'http://www.baltimoresun.com/',
# Why: #6867 in Alexa global
'http://www.ponpare.jp/',
# Why: #6868 in Alexa global
'http://www.jobvite.com/',
# Why: #6869 in Alexa global
'http://www.ratemyprofessors.com/',
# Why: #6870 in Alexa global
'http://www.bancodevenezuela.com/',
# Why: #6871 in Alexa global
'http://www.linkafarin.com/',
# Why: #6872 in Alexa global
'http://www.ufxmarkets.com/',
# Why: #6873 in Alexa global
'http://www.lavozdegalicia.es/',
# Why: #6874 in Alexa global
'http://www.99bill.com/',
# Why: #6875 in Alexa global
'http://www.punyu.com/',
# Why: #6876 in Alexa global
'http://www.otodom.pl/',
# Why: #6877 in Alexa global
'http://www.entireweb.com/',
# Why: #6878 in Alexa global
'http://www.fastshop.com.br/',
# Why: #6879 in Alexa global
'http://www.imgnip.com/',
# Why: #6880 in Alexa global
'http://www.goodlife.com/',
# Why: #6881 in Alexa global
'http://www.caringbridge.org/',
# Why: #6882 in Alexa global
'http://www.pistonheads.com/',
# Why: #6883 in Alexa global
'http://www.gun.az/',
# Why: #6884 in Alexa global
'http://www.1and1.es/',
# Why: #6885 in Alexa global
'http://www.photofunia.com/',
# Why: #6886 in Alexa global
'http://www.nme.com/',
# Why: #6887 in Alexa global
'http://www.japannetbank.co.jp/',
# Why: #6888 in Alexa global
'http://www.carfax.com/',
# Why: #6889 in Alexa global
'http://www.gutenberg.org/',
# Why: #6890 in Alexa global
'http://www.youxixiazai.org/',
# Why: #6891 in Alexa global
'http://www.webmastersitesi.com/',
# Why: #6892 in Alexa global
'http://www.skynet.be/',
# Why: #6893 in Alexa global
'http://www.afrointroductions.com/',
# Why: #6894 in Alexa global
'http://www.mp3slash.net/',
# Why: #6895 in Alexa global
'http://www.netzwelt.de/',
# Why: #6896 in Alexa global
'http://www.ecrater.com/',
# Why: #6897 in Alexa global
'http://www.livemint.com/',
# Why: #6898 in Alexa global
'http://www.worldwinner.com/',
# Why: #6899 in Alexa global
'http://www.echosign.com/',
# Why: #6900 in Alexa global
'http://www.cromaretail.com/',
# Why: #6901 in Alexa global
'http://www.freewebcamporntube.com/',
# Why: #6902 in Alexa global
'http://www.admin.ch/',
# Why: #6903 in Alexa global
'http://www.allstate.com/',
# Why: #6904 in Alexa global
'http://www.photoscape.org/',
# Why: #6905 in Alexa global
'http://www.cv-library.co.uk/',
# Why: #6906 in Alexa global
'http://www.voici.fr/',
# Why: #6907 in Alexa global
'http://www.wdr.de/',
# Why: #6908 in Alexa global
'http://www.pbase.com/',
# Why: #6909 in Alexa global
'http://www.mycenturylink.com/',
# Why: #6910 in Alexa global
'http://www.sonicomusica.com/',
# Why: #6911 in Alexa global
'http://www.schema.org/',
# Why: #6912 in Alexa global
'http://www.smashwords.com/',
# Why: #6913 in Alexa global
'http://www.al3ab.net/',
# Why: #6914 in Alexa global
'http://muryouav.net/',
# Why: #6915 in Alexa global
'http://www.mocospace.com/',
# Why: #6916 in Alexa global
'http://www.fundsxpress.com/',
# Why: #6917 in Alexa global
'http://www.chrisc.com/',
# Why: #6918 in Alexa global
'http://www.poemhunter.com/',
# Why: #6919 in Alexa global
'http://www.cupid.com/',
# Why: #6920 in Alexa global
'http://www.timescity.com/',
# Why: #6921 in Alexa global
'http://www.banglamail24.com/',
# Why: #6922 in Alexa global
'http://www.motika.com.mk/',
# Why: #6923 in Alexa global
'http://www.sec.gov/',
# Why: #6924 in Alexa global
'http://www.go.cn/',
# Why: #6925 in Alexa global
'http://www.whatculture.com/',
# Why: #6926 in Alexa global
'http://www.namepros.com/',
# Why: #6927 in Alexa global
'http://www.vsemayki.ru/',
# Why: #6928 in Alexa global
'http://www.hip2save.com/',
# Why: #6929 in Alexa global
'http://www.hotnews.ro/',
# Why: #6930 in Alexa global
'http://www.vietbao.vn/',
# Why: #6931 in Alexa global
'http://inazumanews2.com/',
# Why: #6932 in Alexa global
'http://www.irokotv.com/',
# Why: #6933 in Alexa global
'http://www.appthemes.com/',
# Why: #6934 in Alexa global
'http://www.tirerack.com/',
# Why: #6935 in Alexa global
'http://www.maxpark.com/',
# Why: #6936 in Alexa global
'http://wed114.cn/',
# Why: #6937 in Alexa global
'http://www.successfactors.com/',
# Why: #6938 in Alexa global
'http://www.sba.gov/',
# Why: #6939 in Alexa global
'http://www.hk-porno.com/',
# Why: #6940 in Alexa global
'http://www.setlinks.ru/',
# Why: #6941 in Alexa global
'http://www.travel24.com/',
# Why: #6942 in Alexa global
'http://www.qatarliving.com/',
# Why: #6943 in Alexa global
'http://www.hotlog.ru/',
# Why: #6944 in Alexa global
'http://rapmls.com/',
# Why: #6945 in Alexa global
'http://www.qualityhealth.com/',
# Why: #6946 in Alexa global
'http://www.linkcollider.com/',
# Why: #6947 in Alexa global
'http://www.kashtanka.com/',
# Why: #6948 in Alexa global
'http://www.hightail.com/',
# Why: #6949 in Alexa global
'http://www.appszoom.com/',
# Why: #6950 in Alexa global
'http://www.armagedomfilmes.biz/',
# Why: #6951 in Alexa global
'http://www.pnu.ac.ir/',
# Why: #6952 in Alexa global
'http://www.globalbux.net/',
# Why: #6953 in Alexa global
'http://www.ebay.com.hk/',
# Why: #6954 in Alexa global
'http://www.ladenzeile.de/',
# Why: #6955 in Alexa global
'http://www.thedomainfo.com/',
# Why: #6956 in Alexa global
'http://www.naosalvo.com.br/',
# Why: #6957 in Alexa global
'http://www.perfectcamgirls.com/',
# Why: #6958 in Alexa global
'http://www.verticalresponse.com/',
# Why: #6959 in Alexa global
'http://www.khabardehi.com/',
# Why: #6960 in Alexa global
'http://www.oszone.net/',
# Why: #6961 in Alexa global
'http://www.teamtreehouse.com/',
# Why: #6962 in Alexa global
'http://www.youtube.com/user/BlueXephos/',
# Why: #6963 in Alexa global
'http://www.humanservices.gov.au/',
# Why: #6964 in Alexa global
'http://www.bostonherald.com/',
# Why: #6965 in Alexa global
'http://www.kafeteria.pl/',
# Why: #6966 in Alexa global
'http://www.society6.com/',
# Why: #6967 in Alexa global
'http://www.gamevicio.com/',
# Why: #6968 in Alexa global
'http://www.crazyegg.com/',
# Why: #6969 in Alexa global
'http://www.logitravel.com/',
# Why: #6970 in Alexa global
'http://www.williams-sonoma.com/',
# Why: #6972 in Alexa global
'http://www.htmlgoodies.com/',
# Why: #6973 in Alexa global
'http://www.fontanka.ru/',
# Why: #6974 in Alexa global
'http://www.islamuon.com/',
# Why: #6975 in Alexa global
'http://www.tcs.com/',
# Why: #6976 in Alexa global
'http://www.elyrics.net/',
# Why: #6978 in Alexa global
'http://www.vip-prom.net/',
# Why: #6979 in Alexa global
'http://www.jobstreet.com.ph/',
# Why: #6980 in Alexa global
'http://www.designfloat.com/',
# Why: #6981 in Alexa global
'http://www.lavasoft.com/',
# Why: #6982 in Alexa global
'http://www.tianjinwe.com/',
# Why: #6983 in Alexa global
'http://www.telelistas.net/',
# Why: #6984 in Alexa global
'http://www.taglol.com/',
# Why: #6985 in Alexa global
'http://www.jacquieetmicheltv.net/',
# Why: #6986 in Alexa global
'http://www.esprit-online-shop.com/',
# Why: #6987 in Alexa global
'http://www.theeroticreview.com/',
# Why: #6988 in Alexa global
'http://www.boo-box.com/',
# Why: #6989 in Alexa global
'http://www.wandoujia.com/',
# Why: #6990 in Alexa global
'http://www.vgsgaming.com/',
# Why: #6991 in Alexa global
'http://www.yourtango.com/',
# Why: #6992 in Alexa global
'http://www.tianji.com/',
# Why: #6993 in Alexa global
'http://www.jpost.com/',
# Why: #6994 in Alexa global
'http://www.mythemeshop.com/',
# Why: #6995 in Alexa global
'http://www.seattlepi.com/',
# Why: #6996 in Alexa global
'http://www.nintendo.co.jp/',
# Why: #6997 in Alexa global
'http://bultannews.com/',
# Why: #6998 in Alexa global
'http://www.youlikehits.com/',
# Why: #6999 in Alexa global
'http://www.partycity.com/',
# Why: #7000 in Alexa global
'http://www.18qt.com/',
# Why: #7001 in Alexa global
'http://www.yuvutu.com/',
# Why: #7002 in Alexa global
'http://www.gq.com/',
# Why: #7003 in Alexa global
'http://www.wiziwig.tv/',
# Why: #7004 in Alexa global
'http://www.cinejosh.com/',
# Why: #7005 in Alexa global
'http://www.technet.com/',
# Why: #7006 in Alexa global
'http://www.vatanbilgisayar.com/',
# Why: #7007 in Alexa global
'http://www.guangjiela.com/',
# Why: #7008 in Alexa global
'http://www.shooter.com.cn/',
# Why: #7009 in Alexa global
'http://www.siteheart.com/',
# Why: #7010 in Alexa global
'http://www.in.gov/',
# Why: #7011 in Alexa global
'http://www.nulled.cc/',
# Why: #7012 in Alexa global
'http://www.mafiashare.net/',
# Why: #7013 in Alexa global
'http://www.tizag.com/',
# Why: #7014 in Alexa global
'http://www.hkjc.com/',
# Why: #7015 in Alexa global
'http://www.restaurant.com/',
# Why: #7016 in Alexa global
'http://www.consumersurveygroup.org/',
# Why: #7017 in Alexa global
'http://www.lolipop.jp/',
# Why: #7018 in Alexa global
'http://www.spin.de/',
# Why: #7019 in Alexa global
'http://www.silverlinetrips.com/',
# Why: #7020 in Alexa global
'http://www.triberr.com/',
# Why: #7021 in Alexa global
'http://www.gamesgirl.net/',
# Why: #7022 in Alexa global
'http://www.qqt38.com/',
# Why: #7023 in Alexa global
'http://www.xiaoshuomm.com/',
# Why: #7024 in Alexa global
'http://www.theopen.com/',
# Why: #7025 in Alexa global
'http://www.campograndenews.com.br/',
# Why: #7026 in Alexa global
'http://bshare.cn/',
# Why: #7028 in Alexa global
'http://www.soonnight.com/',
# Why: #7029 in Alexa global
'http://www.safaribooksonline.com/',
# Why: #7030 in Alexa global
'http://www.main-hosting.com/',
# Why: #7031 in Alexa global
'http://www.caclubindia.com/',
# Why: #7032 in Alexa global
'http://www.alibado.com/',
# Why: #7033 in Alexa global
'http://www.autorambler.ru/',
# Why: #7034 in Alexa global
'http://www.kafan.cn/',
# Why: #7035 in Alexa global
'http://www.tnt.com/',
# Why: #7036 in Alexa global
'http://www.chatango.com/',
# Why: #7037 in Alexa global
'http://www.satrk.com/',
# Why: #7039 in Alexa global
'http://www.pagesperso-orange.fr/',
# Why: #7040 in Alexa global
'http://www.cgbchina.com.cn/',
# Why: #7041 in Alexa global
'http://www.houseoffraser.co.uk/',
# Why: #7042 in Alexa global
'http://www.nullrefer.com/',
# Why: #7043 in Alexa global
'http://www.work.ua/',
# Why: #7044 in Alexa global
'http://www.inagist.com/',
# Why: #7045 in Alexa global
'http://www.kaban.tv/',
# Why: #7046 in Alexa global
'http://www.cnxad.com/',
# Why: #7047 in Alexa global
'http://www.tarad.com/',
# Why: #7048 in Alexa global
'http://www.masteetv.com/',
# Why: #7049 in Alexa global
'http://www.noblesamurai.com/',
# Why: #7050 in Alexa global
'http://www.businessweekly.com.tw/',
# Why: #7051 in Alexa global
'http://www.lifehacker.ru/',
# Why: #7052 in Alexa global
'http://www.anakbnet.com/',
# Why: #7053 in Alexa global
'http://www.google.co.ug/',
# Why: #7054 in Alexa global
'http://www.webcamsex.nl/',
# Why: #7055 in Alexa global
'http://kaoyan.com/',
# Why: #7056 in Alexa global
'http://www.ml.com/',
# Why: #7057 in Alexa global
'http://up.nic.in/',
# Why: #7058 in Alexa global
'http://www.bounceme.net/',
# Why: #7059 in Alexa global
'http://www.netfirms.com/',
# Why: #7060 in Alexa global
'http://www.idokep.hu/',
# Why: #7061 in Alexa global
'http://www.wambie.com/',
# Why: #7062 in Alexa global
'http://www.funpatogh.com/',
# Why: #7063 in Alexa global
'http://hmv.co.jp/',
# Why: #7064 in Alexa global
'http://www.bcash.com.br/',
# Why: #7065 in Alexa global
'http://www.sedo.co.uk/',
# Why: #7066 in Alexa global
'http://www.game2.cn/',
# Why: #7067 in Alexa global
'http://www.noupe.com/',
# Why: #7068 in Alexa global
'http://www.mydirtyhobby.com/',
# Why: #7069 in Alexa global
'http://www.neswangy.net/',
# Why: #7070 in Alexa global
'http://www.downloadprovider.me/',
# Why: #7071 in Alexa global
'http://www.utah.gov/',
# Why: #7072 in Alexa global
'http://www.consumerintelligenceusa.com/',
# Why: #7073 in Alexa global
'http://www.itimes.com/',
# Why: #7074 in Alexa global
'http://www.picroma.com/',
# Why: #7075 in Alexa global
'http://www.lustagenten.com/',
# Why: #7076 in Alexa global
'http://www.monex.co.jp/',
# Why: #7077 in Alexa global
'http://www.kemdiknas.go.id/',
# Why: #7078 in Alexa global
'http://www.sitepronews.com/',
# Why: #7079 in Alexa global
'http://www.ruseller.com/',
# Why: #7080 in Alexa global
'http://www.tradecarview.com/',
# Why: #7081 in Alexa global
'http://www.favstar.fm/',
# Why: #7082 in Alexa global
'http://www.bestbuy.ca/',
# Why: #7083 in Alexa global
'http://www.yelp.ca/',
# Why: #7084 in Alexa global
'http://www.stop-sex.com/',
# Why: #7085 in Alexa global
'http://www.rewity.com/',
# Why: #7086 in Alexa global
'http://www.qiqigames.com/',
# Why: #7087 in Alexa global
'http://www.suntimes.com/',
# Why: #7088 in Alexa global
'http://www.hardware.fr/',
# Why: #7089 in Alexa global
'http://www.rxlist.com/',
# Why: #7090 in Alexa global
'http://www.bgr.com/',
# Why: #7091 in Alexa global
'http://www.zalora.co.id/',
# Why: #7092 in Alexa global
'http://www.mandatory.com/',
# Why: #7094 in Alexa global
'http://www.collarme.com/',
# Why: #7095 in Alexa global
'http://www.mycommerce.com/',
# Why: #7096 in Alexa global
'http://www.holidayiq.com/',
# Why: #7097 in Alexa global
'http://www.filecloud.io/',
# Why: #7098 in Alexa global
'http://www.vconnect.com/',
# Why: #7099 in Alexa global
'http://66163.com/',
# Why: #7100 in Alexa global
'http://www.tlen.pl/',
# Why: #7101 in Alexa global
'http://www.mmbang.com/',
# Why: #7102 in Alexa global
'http://7c.com/',
# Why: #7103 in Alexa global
'http://www.digitalriver.com/',
# Why: #7104 in Alexa global
'http://www.24video.net/',
# Why: #7105 in Alexa global
'http://www.worthofweb.com/',
# Why: #7106 in Alexa global
'http://www.clasicooo.com/',
# Why: #7107 in Alexa global
'http://www.greatschools.net/',
# Why: #7108 in Alexa global
'http://www.tagesanzeiger.ch/',
# Why: #7109 in Alexa global
'http://www.video.az/',
# Why: #7110 in Alexa global
'http://www.osu.edu/',
# Why: #7111 in Alexa global
'http://www.careers360.com/',
# Why: #7112 in Alexa global
'http://www.101.ru/',
# Why: #7113 in Alexa global
'http://www.conforama.fr/',
# Why: #7114 in Alexa global
'http://www.apollo.lv/',
# Why: #7115 in Alexa global
'http://www.netcq.net/',
# Why: #7116 in Alexa global
'http://www.jofogas.hu/',
# Why: #7117 in Alexa global
'http://www.niftylink.com/',
# Why: #7118 in Alexa global
'http://www.midwayusa.com/',
# Why: #7119 in Alexa global
'http://www.collegeteensex.net/',
# Why: #7120 in Alexa global
'http://www.search.com/',
# Why: #7121 in Alexa global
'http://www.naftemporiki.gr/',
# Why: #7122 in Alexa global
'http://www.sainsburys.co.uk/',
# Why: #7123 in Alexa global
'http://www.fitsugar.com/',
# Why: #7124 in Alexa global
'http://www.ifixit.com/',
# Why: #7125 in Alexa global
'http://www.uid.me/',
# Why: #7126 in Alexa global
'http://www.malwarebytes.org/',
# Why: #7127 in Alexa global
'http://www.maxbounty.com/',
# Why: #7128 in Alexa global
'http://www.mensfitness.com/',
# Why: #7129 in Alexa global
'http://www.rtl.be/',
# Why: #7130 in Alexa global
'http://www.yidio.com/',
# Why: #7131 in Alexa global
'http://www.dostorasly.com/',
# Why: #7132 in Alexa global
'http://www.abovetopsecret.com/',
# Why: #7133 in Alexa global
'http://www.sm3na.com/',
# Why: #7134 in Alexa global
'http://www.cam.ac.uk/',
# Why: #7135 in Alexa global
'http://www.gamegape.com/',
# Why: #7136 in Alexa global
'http://www.ocioso.com.br/',
# Why: #7138 in Alexa global
'http://www.register.com/',
# Why: #7139 in Alexa global
'http://www.wwitv.com/',
# Why: #7140 in Alexa global
'http://www.ishangman.com/',
# Why: #7141 in Alexa global
'http://www.gry-online.pl/',
# Why: #7142 in Alexa global
'http://www.ogli.org/',
# Why: #7143 in Alexa global
'http://www.redbull.com/',
# Why: #7144 in Alexa global
'http://www.dyn.com/',
# Why: #7145 in Alexa global
'http://www.freeservers.com/',
# Why: #7146 in Alexa global
'http://www.brandsoftheworld.com/',
# Why: #7147 in Alexa global
'http://www.lorddownload.com/',
# Why: #7148 in Alexa global
'http://www.epson.co.jp/',
# Why: #7149 in Alexa global
'http://www.mybet.com/',
# Why: #7150 in Alexa global
'http://www.brothalove.com/',
# Why: #7151 in Alexa global
'http://www.inchallah.com/',
# Why: #7153 in Alexa global
'http://www.lottomatica.it/',
# Why: #7154 in Alexa global
'http://www.indiamp3.com/',
# Why: #7155 in Alexa global
'http://www.qianbao666.com/',
# Why: #7156 in Alexa global
'http://www.zurb.com/',
# Why: #7157 in Alexa global
'http://www.synxis.com/',
# Why: #7158 in Alexa global
'http://www.baskino.com/',
# Why: #7159 in Alexa global
'http://www.swefilmer.com/',
# Why: #7160 in Alexa global
'http://www.hotstartsearch.com/',
# Why: #7161 in Alexa global
'http://www.cloudmoney.info/',
# Why: #7162 in Alexa global
'http://www.polldaddy.com/',
# Why: #7163 in Alexa global
'http://www.moheet.com/',
# Why: #7164 in Alexa global
'http://www.idhostinger.com/',
# Why: #7166 in Alexa global
'http://www.mp3chief.com/',
# Why: #7167 in Alexa global
'http://www.7netshopping.jp/',
# Why: #7168 in Alexa global
'http://www.tao123.com/',
# Why: #7169 in Alexa global
'http://www.channelnewsasia.com/',
# Why: #7170 in Alexa global
'http://www.yahoo-help.jp/',
# Why: #7171 in Alexa global
'http://www.galeon.com/',
# Why: #7172 in Alexa global
'http://www.aviasales.ru/',
# Why: #7173 in Alexa global
'http://www.datafilehost.com/',
# Why: #7174 in Alexa global
'http://www.travian.com.eg/',
# Why: #7175 in Alexa global
'http://www.ebookee.org/',
# Why: #7176 in Alexa global
'http://www.filmstarts.de/',
# Why: #7177 in Alexa global
'http://www.inccel.com/',
# Why: #7178 in Alexa global
'http://www.chatroulette.com/',
# Why: #7179 in Alexa global
'http://www.it-ebooks.info/',
# Why: #7180 in Alexa global
'http://www.sina.com.tw/',
# Why: #7181 in Alexa global
'http://www.nix.ru/',
# Why: #7182 in Alexa global
'http://www.antena3.ro/',
# Why: #7183 in Alexa global
'http://www.mylifetime.com/',
# Why: #7184 in Alexa global
'http://www.desitorrents.com/',
# Why: #7185 in Alexa global
'http://www.mydigitallife.info/',
# Why: #7186 in Alexa global
'http://www.aeropostale.com/',
# Why: #7187 in Alexa global
'http://www.anilos.com/',
# Why: #7188 in Alexa global
'http://www.macadogru.com/',
# Why: #7189 in Alexa global
'http://www.premiere.fr/',
# Why: #7190 in Alexa global
'http://www.estorebuilder.com/',
# Why: #7191 in Alexa global
'http://www.eventim.de/',
# Why: #7192 in Alexa global
'http://www.expert-offers.com/',
# Why: #7193 in Alexa global
'http://www.deloitte.com/',
# Why: #7194 in Alexa global
'http://www.thetimenow.com/',
# Why: #7195 in Alexa global
'http://www.spicybigbutt.com/',
# Why: #7196 in Alexa global
'http://www.gistmania.com/',
# Why: #7197 in Alexa global
'http://www.pekao24.pl/',
# Why: #7198 in Alexa global
'http://www.mbok.jp/',
# Why: #7199 in Alexa global
'http://www.linkfeed.ru/',
# Why: #7200 in Alexa global
'http://www.carnival.com/',
# Why: #7201 in Alexa global
'http://www.apherald.com/',
# Why: #7202 in Alexa global
'http://www.choicehotels.com/',
# Why: #7203 in Alexa global
'http://www.revolvermaps.com/',
# Why: #7204 in Alexa global
'http://digu.com/',
# Why: #7205 in Alexa global
'http://www.yekmobile.com/',
# Why: #7206 in Alexa global
'http://www.barbarianmovies.com/',
# Why: #7207 in Alexa global
'http://www.jogos.uol.com.br/',
# Why: #7208 in Alexa global
'http://www.poyopara.com/',
# Why: #7209 in Alexa global
'http://www.vse.kz/',
# Why: #7210 in Alexa global
'http://www.socialspark.com/',
# Why: #7211 in Alexa global
'http://www.deutschepost.de/',
# Why: #7212 in Alexa global
'http://www.nokaut.pl/',
# Why: #7214 in Alexa global
'http://www.farpost.ru/',
# Why: #7215 in Alexa global
'http://www.shoebuy.com/',
# Why: #7216 in Alexa global
'http://www.1c-bitrix.ru/',
# Why: #7217 in Alexa global
'http://www.pimproll.com/',
# Why: #7218 in Alexa global
'http://www.startxchange.com/',
# Why: #7219 in Alexa global
'http://www.seocentro.com/',
# Why: #7220 in Alexa global
'http://www.kporno.com/',
# Why: #7221 in Alexa global
'http://www.izvestia.ru/',
# Why: #7222 in Alexa global
'http://www.bathandbodyworks.com/',
# Why: #7223 in Alexa global
'http://www.allhyipmonitors.com/',
# Why: #7224 in Alexa global
'http://www.europe1.fr/',
# Why: #7225 in Alexa global
'http://www.charter.com/',
# Why: #7226 in Alexa global
'http://www.sixflags.com/',
# Why: #7227 in Alexa global
'http://www.abcjuegos.net/',
# Why: #7228 in Alexa global
'http://www.wind.it/',
# Why: #7229 in Alexa global
'http://www.femjoy.com/',
# Why: #7230 in Alexa global
'http://www.humanmetrics.com/',
# Why: #7231 in Alexa global
'http://www.myrealgames.com/',
# Why: #7232 in Alexa global
'http://www.cosmiq.de/',
# Why: #7233 in Alexa global
'http://www.bangbrosteenporn.com/',
# Why: #7234 in Alexa global
'http://www.kir.jp/',
# Why: #7235 in Alexa global
'http://www.thepetitionsite.com/',
# Why: #7236 in Alexa global
'http://laprensa.com.ni/',
# Why: #7237 in Alexa global
'http://www.investors.com/',
# Why: #7238 in Alexa global
'http://www.techpowerup.com/',
# Why: #7239 in Alexa global
'http://www.prosperityteam.com/',
# Why: #7240 in Alexa global
'http://www.autogidas.lt/',
# Why: #7241 in Alexa global
'http://www.state.ny.us/',
# Why: #7242 in Alexa global
'http://www.techbargains.com/',
# Why: #7243 in Alexa global
'http://www.takvim.com.tr/',
# Why: #7244 in Alexa global
'http://www.kko-appli.com/',
# Why: #7245 in Alexa global
'http://www.liex.ru/',
# Why: #7246 in Alexa global
'http://www.cafe24.com/',
# Why: #7247 in Alexa global
'http://www.definebabe.com/',
# Why: #7248 in Alexa global
'http://www.egirlgames.net/',
# Why: #7249 in Alexa global
'http://www.avangard.ru/',
# Why: #7250 in Alexa global
'http://www.sina.com.hk/',
# Why: #7251 in Alexa global
'http://www.freexcafe.com/',
# Why: #7252 in Alexa global
'http://www.vesti.bg/',
# Why: #7253 in Alexa global
'http://www.francetvinfo.fr/',
# Why: #7254 in Alexa global
'http://www.mathsisfun.com/',
# Why: #7255 in Alexa global
'http://www.easymobilerecharge.com/',
# Why: #7256 in Alexa global
'http://www.dapink.com/',
# Why: #7257 in Alexa global
'http://www.propellerads.com/',
# Why: #7258 in Alexa global
'http://www.devshed.com/',
# Why: #7259 in Alexa global
'http://www.clip.vn/',
# Why: #7260 in Alexa global
'http://www.vidivodo.com/',
# Why: #7262 in Alexa global
'http://www.blogspot.dk/',
# Why: #7263 in Alexa global
'http://www.foxnewsinsider.com/',
# Why: #7264 in Alexa global
'http://www.instapaper.com/',
# Why: #7265 in Alexa global
'http://www.premierleague.com/',
# Why: #7266 in Alexa global
'http://www.elo7.com.br/',
# Why: #7267 in Alexa global
'http://www.teenee.com/',
# Why: #7268 in Alexa global
'http://www.clien.net/',
# Why: #7269 in Alexa global
'http://www.computrabajo.com.co/',
# Why: #7270 in Alexa global
'http://www.komputronik.pl/',
# Why: #7271 in Alexa global
'http://www.livesurf.ru/',
# Why: #7272 in Alexa global
'http://www.123cha.com/',
# Why: #7273 in Alexa global
'http://www.cgg.gov.in/',
# Why: #7274 in Alexa global
'http://www.leadimpact.com/',
# Why: #7275 in Alexa global
'http://www.socialmonkee.com/',
# Why: #7276 in Alexa global
'http://www.speeddate.com/',
# Why: #7277 in Alexa global
'http://www.bet-at-home.com/',
# Why: #7278 in Alexa global
'http://www.todaoferta.uol.com.br/',
# Why: #7279 in Alexa global
'http://www.huanqiuauto.com/',
# Why: #7280 in Alexa global
'http://www.tadawul.com.sa/',
# Why: #7281 in Alexa global
'http://www.ucsd.edu/',
# Why: #7282 in Alexa global
'http://www.fda.gov/',
# Why: #7283 in Alexa global
'http://www.asahi-net.or.jp/',
# Why: #7284 in Alexa global
'http://www.cint.com/',
# Why: #7285 in Alexa global
'http://www.homedepot.ca/',
# Why: #7286 in Alexa global
'http://www.webcars.com.cn/',
# Why: #7288 in Alexa global
'http://www.ciao.de/',
# Why: #7289 in Alexa global
'http://www.gigglesglore.com/',
# Why: #7290 in Alexa global
'http://www.warframe.com/',
# Why: #7291 in Alexa global
'http://www.mulher.uol.com.br/',
# Why: #7292 in Alexa global
'http://www.prosieben.de/',
# Why: #7293 in Alexa global
'http://www.vistaprint.in/',
# Why: #7294 in Alexa global
'http://www.mapple.net/',
# Why: #7295 in Alexa global
'http://www.usafis.org/',
# Why: #7296 in Alexa global
'http://www.kuaipan.cn/',
# Why: #7297 in Alexa global
'http://www.truelife.com/',
# Why: #7298 in Alexa global
'http://1o26.com/',
# Why: #7299 in Alexa global
'http://www.boldsky.com/',
# Why: #7300 in Alexa global
'http://www.freeforums.org/',
# Why: #7301 in Alexa global
'http://www.lolnexus.com/',
# Why: #7302 in Alexa global
'http://ti-da.net/',
# Why: #7303 in Alexa global
'http://www.handelsbanken.se/',
# Why: #7304 in Alexa global
'http://www.khamsat.com/',
# Why: #7305 in Alexa global
'http://www.futbol24.com/',
# Why: #7306 in Alexa global
'http://www.wikifeet.com/',
# Why: #7307 in Alexa global
'http://www.dev-point.com/',
# Why: #7308 in Alexa global
'http://www.ibotoolbox.com/',
# Why: #7309 in Alexa global
'http://www.indeed.de/',
# Why: #7310 in Alexa global
'http://www.ct10000.com/',
# Why: #7311 in Alexa global
'http://www.appleinsider.com/',
# Why: #7312 in Alexa global
'http://www.lyoness.net/',
# Why: #7313 in Alexa global
'http://www.vodafone.com.eg/',
# Why: #7314 in Alexa global
'http://www.aifang.com/',
# Why: #7315 in Alexa global
'http://www.tripadvisor.com.br/',
# Why: #7316 in Alexa global
'http://www.hbo.com/',
# Why: #7317 in Alexa global
'http://www.pricerunner.com/',
# Why: #7318 in Alexa global
'http://www.4everproxy.com/',
# Why: #7319 in Alexa global
'http://www.fc-perspolis.com/',
# Why: #7320 in Alexa global
'http://www.themobileindian.com/',
# Why: #7321 in Alexa global
'http://www.gimp.org/',
# Why: #7322 in Alexa global
'http://www.novayagazeta.ru/',
# Why: #7323 in Alexa global
'http://www.dnfight.com/',
# Why: #7324 in Alexa global
'http://www.coco.fr/',
# Why: #7325 in Alexa global
'http://www.thestudentroom.co.uk/',
# Why: #7326 in Alexa global
'http://www.tiin.vn/',
# Why: #7327 in Alexa global
'http://www.dailystar.co.uk/',
# Why: #7328 in Alexa global
'http://www.empowernetwork.com/commissionloophole.php/',
# Why: #7329 in Alexa global
'http://www.unfollowed.me/',
# Why: #7330 in Alexa global
'http://www.wanfangdata.com.cn/',
# Why: #7331 in Alexa global
'http://www.aljazeerasport.net/',
# Why: #7332 in Alexa global
'http://www.nasygnale.pl/',
# Why: #7333 in Alexa global
'http://www.somethingawful.com/',
# Why: #7334 in Alexa global
'http://www.ddo.jp/',
# Why: #7335 in Alexa global
'http://www.scamadviser.com/',
# Why: #7336 in Alexa global
'http://www.mcanime.net/',
# Why: #7337 in Alexa global
'http://www.9stock.com/',
# Why: #7338 in Alexa global
'http://www.boostmobile.com/',
# Why: #7339 in Alexa global
'http://www.oyunkolu.com/',
# Why: #7340 in Alexa global
'http://www.beliefnet.com/',
# Why: #7341 in Alexa global
'http://www.lyrics007.com/',
# Why: #7342 in Alexa global
'http://www.rtv.net/',
# Why: #7343 in Alexa global
'http://www.hasbro.com/',
# Why: #7344 in Alexa global
'http://www.vcp.ir/',
# Why: #7345 in Alexa global
'http://www.fj-p.com/',
# Why: #7346 in Alexa global
'http://www.jetbrains.com/',
# Why: #7347 in Alexa global
'http://www.empowernetwork.com/almostasecret.php/',
# Why: #7348 in Alexa global
'http://www.cpalead.com/',
# Why: #7349 in Alexa global
'http://www.zetaboards.com/',
# Why: #7350 in Alexa global
'http://www.sbobet.com/',
# Why: #7351 in Alexa global
'http://www.v2ex.com/',
# Why: #7352 in Alexa global
'http://xsrv.jp/',
# Why: #7353 in Alexa global
'http://www.toggle.com/',
# Why: #7354 in Alexa global
'http://www.lanebryant.com/',
# Why: #7355 in Alexa global
'http://www.girlgames4u.com/',
# Why: #7356 in Alexa global
'http://www.amadershomoy1.com/',
# Why: #7357 in Alexa global
'http://www.planalto.gov.br/',
# Why: #7358 in Alexa global
'http://news-choice.net/',
# Why: #7359 in Alexa global
'http://sarkarinaukriblog.com/',
# Why: #7360 in Alexa global
'http://www.sudouest.fr/',
# Why: #7361 in Alexa global
'http://www.zdomo.com/',
# Why: #7362 in Alexa global
'http://www.egy-nn.com/',
# Why: #7363 in Alexa global
'http://www.pizzaplot.com/',
# Why: #7364 in Alexa global
'http://www.topgear.com/',
# Why: #7365 in Alexa global
'http://www.sony.co.in/',
# Why: #7366 in Alexa global
'http://www.nosv.org/',
# Why: #7367 in Alexa global
'http://www.beppegrillo.it/',
# Why: #7368 in Alexa global
'http://www.sakshieducation.com/',
# Why: #7370 in Alexa global
'http://www.temagay.com/',
# Why: #7371 in Alexa global
'http://www.stepashka.com/',
# Why: #7372 in Alexa global
'http://www.tmart.com/',
# Why: #7373 in Alexa global
'http://www.readwrite.com/',
# Why: #7374 in Alexa global
'http://www.tudiscoverykids.com/',
# Why: #7375 in Alexa global
'http://www.belfius.be/',
# Why: #7376 in Alexa global
'http://www.submitexpress.com/',
# Why: #7377 in Alexa global
'http://www.autoscout24.ch/',
# Why: #7378 in Alexa global
'http://www.aetna.com/',
# Why: #7379 in Alexa global
'http://www.torrent-anime.com/',
# Why: #7380 in Alexa global
'http://www.superhqporn.com/',
# Why: #7381 in Alexa global
'http://www.kaufda.de/',
# Why: #7382 in Alexa global
'http://www.adorocinema.com/',
# Why: #7383 in Alexa global
'http://www.burning-seri.es/',
# Why: #7384 in Alexa global
'http://www.rlsbb.com/',
# Why: #7385 in Alexa global
'http://www.lativ.com.tw/',
# Why: #7386 in Alexa global
'http://www.housing.co.in/',
# Why: #7387 in Alexa global
'http://www.taiwanlottery.com.tw/',
# Why: #7388 in Alexa global
'http://www.invisionfree.com/',
# Why: #7389 in Alexa global
'http://www.istruzione.it/',
# Why: #7390 in Alexa global
'http://www.desk.com/',
# Why: #7391 in Alexa global
'http://www.lyricsmint.com/',
# Why: #7392 in Alexa global
'http://www.taohuopu.com/',
# Why: #7393 in Alexa global
'http://www.silverdaddies.com/',
# Why: #7394 in Alexa global
'http://www.gov.cl/',
# Why: #7395 in Alexa global
'http://www.vtc.vn/',
# Why: #7397 in Alexa global
'http://www.tanea.gr/',
# Why: #7398 in Alexa global
'http://www.labirint.ru/',
# Why: #7399 in Alexa global
'http://www.sns104.com/',
# Why: #7400 in Alexa global
'http://www.plu.cn/',
# Why: #7401 in Alexa global
'http://www.bigpicture.ru/',
# Why: #7402 in Alexa global
'http://www.marketo.com/',
# Why: #7403 in Alexa global
'http://www.ismmagic.com/',
# Why: #7404 in Alexa global
'http://www.c-sharpcorner.com/',
# Why: #7405 in Alexa global
'http://www.synacor.com/',
# Why: #7406 in Alexa global
'http://www.answered-questions.com/',
# Why: #7407 in Alexa global
'http://www.prlog.ru/',
# Why: #7408 in Alexa global
'http://www.vodafone.com.tr/',
# Why: #7409 in Alexa global
'http://www.yofoto.cn/',
# Why: #7410 in Alexa global
'http://www.thenews.com.pk/',
# Why: #7411 in Alexa global
'http://www.galaxygiftcard.com/',
# Why: #7412 in Alexa global
'http://www.job-search-engine.com/',
# Why: #7413 in Alexa global
'http://www.se.pl/',
# Why: #7414 in Alexa global
'http://www.consumercomplaints.in/',
# Why: #7415 in Alexa global
'http://www.265.com/',
# Why: #7416 in Alexa global
'http://www.cba.pl/',
# Why: #7417 in Alexa global
'http://www.humoron.com/',
# Why: #7418 in Alexa global
'http://www.uscourts.gov/',
# Why: #7419 in Alexa global
'http://www.blog.pl/',
# Why: #7421 in Alexa global
'http://youtu.be/',
# Why: #7422 in Alexa global
'http://www.play4free.com/',
# Why: #7423 in Alexa global
'http://www.blizko.ru/',
# Why: #7424 in Alexa global
'http://www.uswebproxy.com/',
# Why: #7425 in Alexa global
'http://www.housefun.com.tw/',
# Why: #7426 in Alexa global
'http://www.winning-play.com/',
# Why: #7427 in Alexa global
'http://www.yourstory.in/',
# Why: #7428 in Alexa global
'http://www.tinmoi.vn/',
# Why: #7429 in Alexa global
'http://www.yongchuntang.net/',
# Why: #7430 in Alexa global
'http://www.artofmanliness.com/',
# Why: #7431 in Alexa global
'http://www.nadaguides.com/',
# Why: #7432 in Alexa global
'http://www.ndr.de/',
# Why: #7433 in Alexa global
'http://www.kuidle.com/',
# Why: #7434 in Alexa global
'http://www.hopy.com/',
# Why: #7435 in Alexa global
'http://www.roi.ru/',
# Why: #7436 in Alexa global
'http://www.sdpnoticias.com/',
# Why: #7437 in Alexa global
'http://www.nation.com/',
# Why: #7438 in Alexa global
'http://www.gnu.org/',
# Why: #7439 in Alexa global
'http://www.vogue.co.uk/',
# Why: #7440 in Alexa global
'http://www.letsebuy.com/',
# Why: #7441 in Alexa global
'http://www.preloved.co.uk/',
# Why: #7442 in Alexa global
'http://www.yatedo.com/',
# Why: #7443 in Alexa global
'http://www.rs-online.com/',
# Why: #7444 in Alexa global
'http://www.kino-teatr.ru/',
# Why: #7445 in Alexa global
'http://www.meeticaffinity.fr/',
# Why: #7446 in Alexa global
'http://www.clip.dj/',
# Why: #7447 in Alexa global
'http://www.j-sen.jp/',
# Why: #7448 in Alexa global
'http://www.compete.com/',
# Why: #7449 in Alexa global
'http://pravda.sk/',
# Why: #7450 in Alexa global
'http://www.oursogo.com/',
# Why: #7451 in Alexa global
'http://www.designyourway.net/',
# Why: #7452 in Alexa global
'http://www.elcorreo.com/',
# Why: #7453 in Alexa global
'http://www.williamhill.es/',
# Why: #7454 in Alexa global
'http://www.lavenir.net/',
# Why: #7455 in Alexa global
'http://www.voyage-prive.es/',
# Why: #7456 in Alexa global
'http://www.teambeachbody.com/',
# Why: #7457 in Alexa global
'http://www.sportdog.gr/',
# Why: #7458 in Alexa global
'http://www.klicktel.de/',
# Why: #7459 in Alexa global
'http://www.ktonanovenkogo.ru/',
# Why: #7460 in Alexa global
'http://www.sbwire.com/',
# Why: #7461 in Alexa global
'http://www.pearsoncmg.com/',
# Why: #7462 in Alexa global
'http://www.bankifsccode.com/',
# Why: #7463 in Alexa global
'http://www.thenationonlineng.net/',
# Why: #7464 in Alexa global
'http://www.itp.ne.jp/',
# Why: #7465 in Alexa global
'http://www.bangbros1.com/',
# Why: #7466 in Alexa global
'http://www.tarot.com/',
# Why: #7467 in Alexa global
'http://www.acdsee.com/',
# Why: #7468 in Alexa global
'http://www.blogos.com/',
# Why: #7469 in Alexa global
'http://www.dinnerwithmariah.com/',
# Why: #7470 in Alexa global
'http://www.japan-women-dating.com/',
# Why: #7471 in Alexa global
'http://www.sarzamindownload.com/',
# Why: #7472 in Alexa global
'http://www.timesonline.co.uk/',
# Why: #7473 in Alexa global
'http://okbuy.com/',
# Why: #7474 in Alexa global
'http://www.sbb.ch/',
# Why: #7475 in Alexa global
'http://www.mundogaturro.com/',
# Why: #7476 in Alexa global
'http://www.meinvz.net/',
# Why: #7477 in Alexa global
'http://www.trafficadbar.com/',
# Why: #7478 in Alexa global
'http://www.9minecraft.net/',
# Why: #7479 in Alexa global
'http://www.suntory.co.jp/',
# Why: #7480 in Alexa global
'http://www.nextbigwhat.com/',
# Why: #7481 in Alexa global
'http://www.eshetab.com/',
# Why: #7482 in Alexa global
'http://www.meristation.com/',
# Why: #7483 in Alexa global
'http://www.kalahari.com/',
# Why: #7484 in Alexa global
'http://www.pimpandhost.com/',
# Why: #7485 in Alexa global
'http://www.pbworks.com/',
# Why: #7486 in Alexa global
'http://www.peopledaily.com.cn/',
# Why: #7487 in Alexa global
'http://www.bokee.net/',
# Why: #7488 in Alexa global
'http://www.google.ps/',
# Why: #7489 in Alexa global
'http://www.seccionamarilla.com.mx/',
# Why: #7490 in Alexa global
'http://www.foroactivo.com/',
# Why: #7491 in Alexa global
'http://www.gizmodo.jp/',
# Why: #7492 in Alexa global
'http://www.kalaydo.de/',
# Why: #7493 in Alexa global
'http://www.gomaji.com/',
# Why: #7494 in Alexa global
'http://www.exactseek.com/',
# Why: #7495 in Alexa global
'http://www.cashtaller.ru/',
# Why: #7496 in Alexa global
'http://www.blogspot.co.nz/',
# Why: #7497 in Alexa global
'http://www.volvocars.com/',
# Why: #7498 in Alexa global
'http://www.marathonbet.com/',
# Why: #7499 in Alexa global
'http://www.cityhouse.cn/',
# Why: #7500 in Alexa global
'http://www.hk-pub.com/',
# Why: #7501 in Alexa global
'http://www.seriouslyfacts.me/',
# Why: #7502 in Alexa global
'http://www.streetdirectory.com/',
# Why: #7504 in Alexa global
'http://www.mediamasr.tv/',
# Why: #7505 in Alexa global
'http://www.straitstimes.com/',
# Why: #7506 in Alexa global
'http://www.promodj.com/',
# Why: #7507 in Alexa global
'http://www.3dwwwgame.com/',
# Why: #7508 in Alexa global
'http://www.autovit.ro/',
# Why: #7509 in Alexa global
'http://www.ahlalhdeeth.com/',
# Why: #7510 in Alexa global
'http://www.forum-auto.com/',
# Why: #7511 in Alexa global
'http://www.stooorage.com/',
# Why: #7512 in Alexa global
'http://www.mobilism.org/',
# Why: #7513 in Alexa global
'http://www.hideref.org/',
# Why: #7514 in Alexa global
'http://www.mn66.com/',
# Why: #7515 in Alexa global
'http://www.internations.org/',
# Why: #7516 in Alexa global
'http://www.dhc.co.jp/',
# Why: #7517 in Alexa global
'http://www.sbicard.com/',
# Why: #7518 in Alexa global
'http://www.dayoo.com/',
# Why: #7519 in Alexa global
'http://biquge.com/',
# Why: #7520 in Alexa global
'http://www.theme.wordpress.com/',
# Why: #7521 in Alexa global
'http://www.mrdoob.com/',
# Why: #7522 in Alexa global
'http://www.vpls.net/',
# Why: #7523 in Alexa global
'http://www.alquma-a.com/',
# Why: #7524 in Alexa global
'http://www.bankmillennium.pl/',
# Why: #7525 in Alexa global
'http://www.mitele.es/',
# Why: #7526 in Alexa global
'http://www.tro-ma-ktiko.blogspot.gr/',
# Why: #7527 in Alexa global
'http://www.bookmark4you.com/',
# Why: #7530 in Alexa global
'http://www.tencent.com/',
# Why: #7531 in Alexa global
'http://www.bsi.ir/',
# Why: #7532 in Alexa global
'http://t.cn/',
# Why: #7533 in Alexa global
'http://www.fox.com/',
# Why: #7534 in Alexa global
'http://www.payback.de/',
# Why: #7535 in Alexa global
'http://www.tubepornfilm.com/',
# Why: #7536 in Alexa global
'http://www.herold.at/',
# Why: #7537 in Alexa global
'http://www.elperiodico.com/',
# Why: #7538 in Alexa global
'http://www.lolesports.com/',
# Why: #7539 in Alexa global
'http://www.hrs.de/',
# Why: #7540 in Alexa global
'http://www.trustlink.ru/',
# Why: #7541 in Alexa global
'http://www.pricemachine.com/',
# Why: #7542 in Alexa global
'http://www.zombie.jp/',
# Why: #7543 in Alexa global
'http://www.socialadr.com/',
# Why: #7544 in Alexa global
'http://www.anandabazar.com/',
# Why: #7545 in Alexa global
'http://www.jacquieetmicheltv2.net/',
# Why: #7546 in Alexa global
'http://www.monster.de/',
# Why: #7547 in Alexa global
'http://www.allposters.com/',
# Why: #7548 in Alexa global
'http://www.blog.ir/',
# Why: #7549 in Alexa global
'http://www.ad4game.com/',
# Why: #7550 in Alexa global
'http://www.alkislarlayasiyorum.com/',
# Why: #7551 in Alexa global
'http://www.ptcsolution.com/',
# Why: #7552 in Alexa global
'http://www.moviepilot.com/',
# Why: #7553 in Alexa global
'http://www.ddizi.org/',
# Why: #7554 in Alexa global
'http://dmzj.com/',
# Why: #7555 in Alexa global
'http://www.onvasortir.com/',
# Why: #7556 in Alexa global
'http://www.ferronetwork.com/',
# Why: #7557 in Alexa global
'http://www.seagate.com/',
# Why: #7558 in Alexa global
'http://www.starmedia.com/',
# Why: #7559 in Alexa global
'http://www.topit.me/',
# Why: #7560 in Alexa global
'http://www.alexa.cn/',
# Why: #7561 in Alexa global
'http://www.developpez.net/',
# Why: #7562 in Alexa global
'http://www.papajogos.com.br/',
# Why: #7563 in Alexa global
'http://www.btalah.com/',
# Why: #7564 in Alexa global
'http://www.gateway.gov.uk/',
# Why: #7565 in Alexa global
'http://www.fotki.com/',
# Why: #7566 in Alexa global
'http://www.holidaylettings.co.uk/',
# Why: #7567 in Alexa global
'http://www.rzeczpospolita.pl/',
# Why: #7569 in Alexa global
'http://www.charter97.org/',
# Why: #7570 in Alexa global
'http://www.robtex.com/',
# Why: #7571 in Alexa global
'http://bestadbid.com/',
# Why: #7572 in Alexa global
'http://www.unblog.fr/',
# Why: #7573 in Alexa global
'http://www.archive.is/',
# Why: #7574 in Alexa global
'http://www.microworkers.com/',
# Why: #7575 in Alexa global
'http://www.vbulletin.org/',
# Why: #7576 in Alexa global
'http://www.jetswap.com/',
# Why: #7577 in Alexa global
'http://www.badoink.com/',
# Why: #7578 in Alexa global
'http://www.adobeconnect.com/',
# Why: #7579 in Alexa global
'http://www.cutt.us/',
# Why: #7580 in Alexa global
'http://lovemake.biz/',
# Why: #7581 in Alexa global
'http://www.xpress.com/',
# Why: #7582 in Alexa global
'http://www.di.se/',
# Why: #7583 in Alexa global
'http://www.ppomppu.co.kr/',
# Why: #7584 in Alexa global
'http://www.jacquielawson.com/',
# Why: #7585 in Alexa global
'http://www.sat1.de/',
# Why: #7586 in Alexa global
'http://www.adshuffle.com/',
# Why: #7587 in Alexa global
'http://www.homepage.com.tr/',
# Why: #7588 in Alexa global
'http://www.treehugger.com/',
# Why: #7589 in Alexa global
'http://www.selectornews.com/',
# Why: #7590 in Alexa global
'http://www.dap-news.com/',
# Why: #7591 in Alexa global
'http://www.tvline.com/',
# Why: #7592 in Alexa global
'http://www.co188.com/',
# Why: #7593 in Alexa global
'http://www.bfmtv.com/',
# Why: #7594 in Alexa global
'http://www.nastygal.com/',
# Why: #7595 in Alexa global
'http://www.cebupacificair.com/',
# Why: #7596 in Alexa global
'http://www.spr.ru/',
# Why: #7597 in Alexa global
'http://www.vazeh.com/',
# Why: #7598 in Alexa global
'http://www.worldmarket.com/',
# Why: #7599 in Alexa global
'http://www.americanlivewire.com/',
# Why: #7600 in Alexa global
'http://www.befunky.com/',
# Why: #7601 in Alexa global
'http://www.movie2k.tl/',
# Why: #7602 in Alexa global
'http://www.coach.com/',
# Why: #7603 in Alexa global
'http://www.whattoexpect.com/',
# Why: #7604 in Alexa global
'http://www.share-online.biz/',
# Why: #7605 in Alexa global
'http://www.fishwrapper.com/',
# Why: #7606 in Alexa global
'http://www.aktifhaber.com/',
# Why: #7607 in Alexa global
'http://www.downxsoft.com/',
# Why: #7608 in Alexa global
'http://www.websurf.ru/',
# Why: #7609 in Alexa global
'http://www.belluna.jp/',
# Why: #7610 in Alexa global
'http://www.bbcgoodfood.com/',
# Why: #7611 in Alexa global
'http://www.france2.fr/',
# Why: #7612 in Alexa global
'http://www.gyakorikerdesek.hu/',
# Why: #7614 in Alexa global
'http://www.lidovky.cz/',
# Why: #7615 in Alexa global
'http://www.thithtoolwin.info/',
# Why: #7616 in Alexa global
'http://www.psbc.com/',
# Why: #7617 in Alexa global
'http://www.766.com/',
# Why: #7618 in Alexa global
'http://www.co-operativebank.co.uk/',
# Why: #7619 in Alexa global
'http://www.iwriter.com/',
# Why: #7620 in Alexa global
'http://www.bravotv.com/',
# Why: #7621 in Alexa global
'http://www.e23.cn/',
# Why: #7622 in Alexa global
'http://www.empowernetwork.com/ublQXbhzgWgGAF9/',
# Why: #7623 in Alexa global
'http://www.sbs.com.au/',
# Why: #7624 in Alexa global
'http://www.dtiserv2.com/',
# Why: #7625 in Alexa global
'http://www.watchever.de/',
# Why: #7626 in Alexa global
'http://www.playhub.com/',
# Why: #7627 in Alexa global
'http://www.globovision.com/',
# Why: #7628 in Alexa global
'http://www.intereconomia.com/',
# Why: #7629 in Alexa global
'http://www.poznan.pl/',
# Why: #7630 in Alexa global
'http://www.comicbookmovie.com/',
# Why: #7632 in Alexa global
'http://www.ocomico.net/',
# Why: #7634 in Alexa global
'http://www.housetrip.com/',
# Why: #7635 in Alexa global
'http://www.freewebsubmission.com/',
# Why: #7636 in Alexa global
'http://www.karmaloop.com/',
# Why: #7637 in Alexa global
'http://www.savevid.com/',
# Why: #7638 in Alexa global
'http://www.lastpass.com/',
# Why: #7639 in Alexa global
'http://yougou.com/',
# Why: #7640 in Alexa global
'http://www.iafd.com/',
# Why: #7641 in Alexa global
'http://www.casertex.com/',
# Why: #7642 in Alexa global
'http://www.gmail.com/',
# Why: #7643 in Alexa global
'http://www.modhoster.de/',
# Why: #7644 in Alexa global
'http://www.post-gazette.com/',
# Why: #7645 in Alexa global
'http://www.digikey.com/',
# Why: #7646 in Alexa global
'http://www.torrentleech.org/',
# Why: #7647 in Alexa global
'http://www.stamps.com/',
# Why: #7648 in Alexa global
'http://www.lifestyleinsights.org/',
# Why: #7649 in Alexa global
'http://www.pandawill.com/',
# Why: #7650 in Alexa global
'http://www.wm-panel.com/',
# Why: #7651 in Alexa global
'http://www.um-per.com/',
# Why: #7652 in Alexa global
'http://www.straighttalk.com/',
# Why: #7653 in Alexa global
'http://www.xpersonals.com/',
# Why: #7655 in Alexa global
'http://www.bondfaro.com.br/',
# Why: #7656 in Alexa global
'http://www.tvrage.com/',
# Why: #7657 in Alexa global
'http://www.rockongags.com/',
# Why: #7658 in Alexa global
'http://www.4jok.com/',
# Why: #7659 in Alexa global
'http://www.zoom.com.br/',
# Why: #7660 in Alexa global
'http://www.cnn.co.jp/',
# Why: #7661 in Alexa global
'http://www.pixabay.com/',
# Why: #7662 in Alexa global
'http://www.path.com/',
# Why: #7663 in Alexa global
'http://www.hiphopdx.com/',
# Why: #7664 in Alexa global
'http://www.ptbus.com/',
# Why: #7665 in Alexa global
'http://www.fussball.de/',
# Why: #7666 in Alexa global
'http://www.windows.net/',
# Why: #7667 in Alexa global
'http://www.adweek.com/',
# Why: #7668 in Alexa global
'http://www.kraftrecipes.com/',
# Why: #7669 in Alexa global
'http://www.redtram.com/',
# Why: #7670 in Alexa global
'http://www.youravon.com/',
# Why: #7671 in Alexa global
'http://www.ladepeche.fr/',
# Why: #7672 in Alexa global
'http://www.jiwu.com/',
# Why: #7673 in Alexa global
'http://www.hobbylobby.com/',
# Why: #7674 in Alexa global
'http://www.otzyv.ru/',
# Why: #7675 in Alexa global
'http://www.sky-fire.com/',
# Why: #7676 in Alexa global
'http://www.fileguru.com/',
# Why: #7677 in Alexa global
'http://www.vandal.net/',
# Why: #7678 in Alexa global
'http://www.haozu.com/',
# Why: #7679 in Alexa global
'http://www.syd.com.cn/',
# Why: #7680 in Alexa global
'http://www.laxteams.net/',
# Why: #7681 in Alexa global
'http://www.cpvtrack202.com/',
# Why: #7682 in Alexa global
'http://www.libraryreserve.com/',
# Why: #7683 in Alexa global
'http://www.tvigle.ru/',
# Why: #7684 in Alexa global
'http://www.hoopshype.com/',
# Why: #7685 in Alexa global
'http://www.worldcat.org/',
# Why: #7686 in Alexa global
'http://www.eventful.com/',
# Why: #7687 in Alexa global
'http://www.nettiauto.com/',
# Why: #7688 in Alexa global
'http://www.generalfiles.org/',
# Why: #7689 in Alexa global
'http://www.ojooo.com/',
# Why: #7690 in Alexa global
'http://www.thatisnotasport.com/',
# Why: #7691 in Alexa global
'http://www.thepioneerwoman.com/',
# Why: #7692 in Alexa global
'http://www.social-bookmarking.net/',
# Why: #7693 in Alexa global
'http://www.lookforithere.info/',
# Why: #7694 in Alexa global
'http://www.americanapparel.net/',
# Why: #7695 in Alexa global
'http://www.protv.ro/',
# Why: #7696 in Alexa global
'http://www.jeux-gratuits.com/',
# Why: #7697 in Alexa global
'http://www.tomoson.com/',
# Why: #7698 in Alexa global
'http://www.jpn.org/',
# Why: #7699 in Alexa global
'http://www.cpz.to/',
# Why: #7700 in Alexa global
'http://www.vrisko.gr/',
# Why: #7701 in Alexa global
'http://www.cbox.ws/',
# Why: #7702 in Alexa global
'http://www.vandelaydesign.com/',
# Why: #7703 in Alexa global
'http://www.macmillandictionary.com/',
# Why: #7704 in Alexa global
'http://www.eventure.com/',
# Why: #7705 in Alexa global
'http://www.niniweblog.com/',
# Why: #7706 in Alexa global
'http://www.ecwid.com/',
# Why: #7708 in Alexa global
'http://www.garuda-indonesia.com/',
# Why: #7709 in Alexa global
'http://www.education.com/',
# Why: #7710 in Alexa global
'http://www.natalie.mu/',
# Why: #7711 in Alexa global
'http://www.gigsandfestivals.co.uk/',
# Why: #7712 in Alexa global
'http://www.onlainfilm.ucoz.ua/',
# Why: #7713 in Alexa global
'http://www.hotwords.com/',
# Why: #7714 in Alexa global
'http://www.jagobd.com/',
# Why: #7715 in Alexa global
'http://www.pageset.com/',
# Why: #7716 in Alexa global
'http://www.sagepay.com/',
# Why: #7717 in Alexa global
'http://www.runkeeper.com/',
# Why: #7718 in Alexa global
'http://www.beeztube.com/',
# Why: #7719 in Alexa global
'http://www.pinla.com/',
# Why: #7720 in Alexa global
'http://www.blizzard.com/',
# Why: #7721 in Alexa global
'http://www.unc.edu/',
# Why: #7722 in Alexa global
'http://www.makememarvellous.com/',
# Why: #7723 in Alexa global
'http://www.wer-weiss-was.de/',
# Why: #7724 in Alexa global
'http://www.ubc.ca/',
# Why: #7725 in Alexa global
'http://www.utoronto.ca/',
# Why: #7726 in Alexa global
'http://www.avsforum.com/',
# Why: #7727 in Alexa global
'http://www.newrelic.com/',
# Why: #7728 in Alexa global
'http://www.orkut.co.in/',
# Why: #7729 in Alexa global
'http://www.wawa-mania.ec/',
# Why: #7730 in Alexa global
'http://www.tvuol.uol.com.br/',
# Why: #7731 in Alexa global
'http://www.ncsu.edu/',
# Why: #7732 in Alexa global
'http://www.ne.jp/',
# Why: #7733 in Alexa global
'http://www.redhat.com/',
# Why: #7734 in Alexa global
'http://www.toyota.jp/',
# Why: #7735 in Alexa global
'http://www.nsdl.co.in/',
# Why: #7736 in Alexa global
'http://www.lavoz.com.ar/',
# Why: #7737 in Alexa global
'http://www.navy.mil/',
# Why: #7738 in Alexa global
'http://www.mg.gov.br/',
# Why: #7739 in Alexa global
'http://gizmodo.uol.com.br/',
# Why: #7740 in Alexa global
'http://www.psychcentral.com/',
# Why: #7741 in Alexa global
'http://www.ultipro.com/',
# Why: #7742 in Alexa global
'http://www.unisa.ac.za/',
# Why: #7743 in Alexa global
'http://www.sooperarticles.com/',
# Why: #7744 in Alexa global
'http://www.wondershare.com/',
# Why: #7745 in Alexa global
'http://www.wholefoodsmarket.com/',
# Why: #7746 in Alexa global
'http://www.dumpaday.com/',
# Why: #7747 in Alexa global
'http://www.littlewoods.com/',
# Why: #7748 in Alexa global
'http://www.carscom.net/',
# Why: #7749 in Alexa global
'http://www.meitu.com/',
# Why: #7750 in Alexa global
'http://www.9lwan.com/',
# Why: #7751 in Alexa global
'http://www.emailmeform.com/',
# Why: #7752 in Alexa global
'http://www.arte.tv/',
# Why: #7753 in Alexa global
'http://www.tribalfootball.com/',
# Why: #7754 in Alexa global
'http://www.howtoforge.com/',
# Why: #7755 in Alexa global
'http://www.cvent.com/',
# Why: #7756 in Alexa global
'http://www.fujitsu.com/',
# Why: #7757 in Alexa global
'http://www.silvergames.com/',
# Why: #7758 in Alexa global
'http://www.tp-link.com.cn/',
# Why: #7759 in Alexa global
'http://www.fatlossfactor.com/',
# Why: #7760 in Alexa global
'http://www.nusport.nl/',
# Why: #7761 in Alexa global
'http://www.todo1.com/',
# Why: #7762 in Alexa global
'http://www.see-tube.com/',
# Why: #7763 in Alexa global
'http://www.lolspots.com/',
# Why: #7764 in Alexa global
'http://www.sucksex.com/',
# Why: #7765 in Alexa global
'http://www.encontreinarede.com/',
# Why: #7766 in Alexa global
'http://www.myarabylinks.com/',
# Why: #7767 in Alexa global
'http://www.v-39.net/',
# Why: #7769 in Alexa global
'http://www.soompi.com/',
# Why: #7770 in Alexa global
'http://www.mltdb.com/',
# Why: #7771 in Alexa global
'http://www.websitetonight.com/',
# Why: #7772 in Alexa global
'http://www.bu.edu/',
# Why: #7773 in Alexa global
'http://www.lazada.co.th/',
# Why: #7774 in Alexa global
'http://www.mature-money.com/',
# Why: #7775 in Alexa global
'http://www.simplemachines.org/',
# Why: #7776 in Alexa global
'http://www.tnt-online.ru/',
# Why: #7777 in Alexa global
'http://www.disput.az/',
# Why: #7779 in Alexa global
'http://www.flirtcafe.de/',
# Why: #7780 in Alexa global
'http://www.d1net.com/',
# Why: #7781 in Alexa global
'http://www.infoplease.com/',
# Why: #7782 in Alexa global
'http://www.unseenimages.co.in/',
# Why: #7783 in Alexa global
'http://www.downloadatoz.com/',
# Why: #7784 in Alexa global
'http://www.norwegian.com/',
# Why: #7785 in Alexa global
'http://www.youtradefx.com/',
# Why: #7786 in Alexa global
'http://www.petapixel.com/',
# Why: #7787 in Alexa global
'http://www.bytes.com/',
# Why: #7788 in Alexa global
'http://ht.ly/',
# Why: #7789 in Alexa global
'http://www.jobberman.com/',
# Why: #7790 in Alexa global
'http://www.xenforo.com/',
# Why: #7791 in Alexa global
'http://www.pomponik.pl/',
# Why: #7792 in Alexa global
'http://www.siambit.org/',
# Why: #7793 in Alexa global
'http://www.twoplustwo.com/',
# Why: #7794 in Alexa global
'http://www.videoslasher.com/',
# Why: #7795 in Alexa global
'http://www.onvista.de/',
# Why: #7796 in Alexa global
'http://www.shopping-search.jp/',
# Why: #7797 in Alexa global
'http://www.canstockphoto.com/',
# Why: #7798 in Alexa global
'http://www.cash4flirt.com/',
# Why: #7799 in Alexa global
'http://www.flashgames.it/',
# Why: #7800 in Alexa global
'http://www.xxxdessert.com/',
# Why: #7801 in Alexa global
'http://www.cda.pl/',
# Why: #7803 in Alexa global
'http://www.costco.ca/',
# Why: #7804 in Alexa global
'http://www.elnuevodiario.com.ni/',
# Why: #7805 in Alexa global
'http://www.svtplay.se/',
# Why: #7806 in Alexa global
'http://www.ftc.gov/',
# Why: #7807 in Alexa global
'http://www.supersonicads.com/',
# Why: #7808 in Alexa global
'http://www.openstreetmap.org/',
# Why: #7809 in Alexa global
'http://www.chinamobile.com/',
# Why: #7810 in Alexa global
'http://www.fastspring.com/',
# Why: #7811 in Alexa global
'http://www.eprice.com.tw/',
# Why: #7813 in Alexa global
'http://www.mcdonalds.com/',
# Why: #7814 in Alexa global
'http://www.egloos.com/',
# Why: #7815 in Alexa global
'http://www.mouser.com/',
# Why: #7816 in Alexa global
'http://livemook.com/',
# Why: #7817 in Alexa global
'http://www.woxiu.com/',
# Why: #7818 in Alexa global
'http://www.pingler.com/',
# Why: #7819 in Alexa global
'http://www.ruelsoft.org/',
# Why: #7820 in Alexa global
'http://www.krone.at/',
# Why: #7821 in Alexa global
'http://www.internetbookshop.it/',
# Why: #7822 in Alexa global
'http://www.alibaba-inc.com/',
# Why: #7823 in Alexa global
'http://www.kimsufi.com/',
# Why: #7824 in Alexa global
'http://www.summitracing.com/',
# Why: #7826 in Alexa global
'http://www.parsfootball.com/',
# Why: #7827 in Alexa global
'http://www.standard.co.uk/',
# Why: #7828 in Alexa global
'http://www.photoblog.pl/',
# Why: #7829 in Alexa global
'http://www.bicaps.com/',
# Why: #7830 in Alexa global
'http://www.digitalplayground.com/',
# Why: #7831 in Alexa global
'http://www.zerochan.net/',
# Why: #7832 in Alexa global
'http://www.whosay.com/',
# Why: #7833 in Alexa global
'http://www.qualityseek.org/',
# Why: #7834 in Alexa global
'http://www.say7.info/',
# Why: #7835 in Alexa global
'http://www.rs.gov.br/',
# Why: #7836 in Alexa global
'http://www.wps.cn/',
# Why: #7837 in Alexa global
'http://www.google.co.mz/',
# Why: #7838 in Alexa global
'http://www.yourlustmovies.com/',
# Why: #7839 in Alexa global
'http://www.zalando.nl/',
# Why: #7840 in Alexa global
'http://www.jn.pt/',
# Why: #7841 in Alexa global
'http://www.homebase.co.uk/',
# Why: #7842 in Alexa global
'http://www.avis.com/',
# Why: #7843 in Alexa global
'http://www.healthboards.com/',
# Why: #7844 in Alexa global
'http://www.filmizlesene.com.tr/',
# Why: #7845 in Alexa global
'http://www.shoutcast.com/',
# Why: #7846 in Alexa global
'http://www.konami.jp/',
# Why: #7847 in Alexa global
'http://www.indiafreestuff.in/',
# Why: #7848 in Alexa global
'http://www.avval.ir/',
# Why: #7849 in Alexa global
'http://www.gamingwonderland.com/',
# Why: #7850 in Alexa global
'http://www.adage.com/',
# Why: #7851 in Alexa global
'http://www.asu.edu/',
# Why: #7852 in Alexa global
'http://www.froma.com/',
# Why: #7853 in Alexa global
'http://www.bezuzyteczna.pl/',
# Why: #7854 in Alexa global
'http://www.workopolis.com/',
# Why: #7855 in Alexa global
'http://extranetinvestment.com/',
# Why: #7856 in Alexa global
'http://www.lablue.de/',
# Why: #7857 in Alexa global
'http://www.geotauaisay.com/',
# Why: #7858 in Alexa global
'http://www.bestchange.ru/',
# Why: #7859 in Alexa global
'http://www.ptp22.com/',
# Why: #7860 in Alexa global
'http://www.tehparadox.com/',
# Why: #7861 in Alexa global
'http://www.ox.ac.uk/',
# Why: #7862 in Alexa global
'http://www.radaris.com/',
# Why: #7863 in Alexa global
'http://www.domdigger.com/',
# Why: #7864 in Alexa global
'http://www.lizads.com/',
# Why: #7865 in Alexa global
'http://www.chatvl.com/',
# Why: #7866 in Alexa global
'http://www.elle.com/',
# Why: #7867 in Alexa global
'http://www.soloaqui.es/',
# Why: #7868 in Alexa global
'http://www.tubejuggs.com/',
# Why: #7869 in Alexa global
'http://www.jsonline.com/',
# Why: #7870 in Alexa global
'http://www.ut.ac.ir/',
# Why: #7871 in Alexa global
'http://www.iitv.info/',
# Why: #7872 in Alexa global
'http://www.runetki.tv/',
# Why: #7873 in Alexa global
'http://www.hyundai.com/',
# Why: #7874 in Alexa global
'http://www.turkiye.gov.tr/',
# Why: #7875 in Alexa global
'http://www.jobstreet.com.sg/',
# Why: #7877 in Alexa global
'http://www.jp-sex.com/',
# Why: #7878 in Alexa global
'http://www.soccer.ru/',
# Why: #7879 in Alexa global
'http://www.slashfilm.com/',
# Why: #7880 in Alexa global
'http://www.couchtuner.eu/',
# Why: #7881 in Alexa global
'http://quanfan.com/',
# Why: #7882 in Alexa global
'http://www.porsche.com/',
# Why: #7883 in Alexa global
'http://www.craftsy.com/',
# Why: #7884 in Alexa global
'http://www.geizhals.at/',
# Why: #7885 in Alexa global
'http://www.spartoo.it/',
# Why: #7886 in Alexa global
'http://yxku.com/',
# Why: #7887 in Alexa global
'http://www.vodonet.net/',
# Why: #7888 in Alexa global
'http://www.photo.net/',
# Why: #7889 in Alexa global
'http://www.raiffeisen.ru/',
# Why: #7890 in Alexa global
'http://www.tablotala.com/',
# Why: #7891 in Alexa global
'http://www.theaa.com/',
# Why: #7892 in Alexa global
'http://www.idownloadblog.com/',
# Why: #7894 in Alexa global
'http://www.rodfile.com/',
# Why: #7895 in Alexa global
'http://www.alabout.com/',
# Why: #7896 in Alexa global
'http://www.f1news.ru/',
# Why: #7897 in Alexa global
'http://www.divxstage.eu/',
# Why: #7898 in Alexa global
'http://www.itusozluk.com/',
# Why: #7899 in Alexa global
'http://www.tokyodisneyresort.co.jp/',
# Why: #7900 in Alexa global
'http://www.hicdma.com/',
# Why: #7901 in Alexa global
'http://www.dota2lounge.com/',
# Why: #7902 in Alexa global
'http://www.meizu.cn/',
# Why: #7903 in Alexa global
'http://www.greensmut.com/',
# Why: #7904 in Alexa global
'http://www.bharatiyamobile.com/',
# Why: #7905 in Alexa global
'http://www.handycafe.com/',
# Why: #7906 in Alexa global
'http://www.regarder-film-gratuit.com/',
# Why: #7907 in Alexa global
'http://www.adultgeek.net/',
# Why: #7908 in Alexa global
'http://www.yintai.com/',
# Why: #7909 in Alexa global
'http://www.brasilescola.com/',
# Why: #7910 in Alexa global
'http://www.verisign.com/',
# Why: #7911 in Alexa global
'http://www.dnslink.com/',
# Why: #7912 in Alexa global
'http://www.standaard.be/',
# Why: #7913 in Alexa global
'http://www.cbengine.com/',
# Why: #7914 in Alexa global
'http://www.pchealthboost.com/',
# Why: #7915 in Alexa global
'http://www.dealdey.com/',
# Why: #7916 in Alexa global
'http://www.cnnturk.com/',
# Why: #7917 in Alexa global
'http://www.trutv.com/',
# Why: #7918 in Alexa global
'http://www.tahrirnews.com/',
# Why: #7919 in Alexa global
'http://www.getit.in/',
# Why: #7920 in Alexa global
'http://www.jquerymobile.com/',
# Why: #7921 in Alexa global
'http://www.girlgames.com/',
# Why: #7922 in Alexa global
'http://www.alhayat.com/',
# Why: #7923 in Alexa global
'http://www.ilpvideo.com/',
# Why: #7924 in Alexa global
'http://www.stihi.ru/',
# Why: #7925 in Alexa global
'http://www.skyscanner.ru/',
# Why: #7926 in Alexa global
'http://www.jamejamonline.ir/',
# Why: #7927 in Alexa global
'http://www.t3n.de/',
# Why: #7928 in Alexa global
'http://www.rent.com/',
# Why: #7929 in Alexa global
'http://www.telerik.com/',
# Why: #7930 in Alexa global
'http://www.tandfonline.com/',
# Why: #7931 in Alexa global
'http://www.argonas.com/',
# Why: #7932 in Alexa global
'http://www.ludokado.com/',
# Why: #7933 in Alexa global
'http://www.luvgag.com/',
# Why: #7934 in Alexa global
'http://www.myspongebob.ru/',
# Why: #7935 in Alexa global
'http://www.z5x.net/',
# Why: #7936 in Alexa global
'http://www.allhyipmon.ru/',
# Why: #7937 in Alexa global
'http://www.fanswong.com/',
# Why: #7939 in Alexa global
'http://www.oddee.com/',
# Why: #7940 in Alexa global
'http://guoli.com/',
# Why: #7942 in Alexa global
'http://www.wpzoom.com/',
# Why: #7943 in Alexa global
'http://www.2gheroon.com/',
# Why: #7944 in Alexa global
'http://www.artisteer.com/',
# Why: #7945 in Alexa global
'http://www.share-links.biz/',
# Why: #7946 in Alexa global
'http://www.flightstats.com/',
# Why: #7947 in Alexa global
'http://www.wisegeek.org/',
# Why: #7948 in Alexa global
'http://www.shuangtv.net/',
# Why: #7949 in Alexa global
'http://www.mylikes.com/',
# Why: #7950 in Alexa global
'http://www.0zz0.com/',
# Why: #7951 in Alexa global
'http://www.xiu.com/',
# Why: #7952 in Alexa global
'http://www.pornizle69.com/',
# Why: #7953 in Alexa global
'http://www.sendgrid.com/',
# Why: #7954 in Alexa global
'http://theweek.com/',
# Why: #7955 in Alexa global
'http://www.veetle.com/',
# Why: #7956 in Alexa global
'http://www.theanimalrescuesite.com/',
# Why: #7957 in Alexa global
'http://www.sears.ca/',
# Why: #7958 in Alexa global
'http://www.tianpin.com/',
# Why: #7959 in Alexa global
'http://www.thisdaylive.com/',
# Why: #7960 in Alexa global
'http://www.myfunlife.com/',
# Why: #7961 in Alexa global
'http://www.furaffinity.net/',
# Why: #7962 in Alexa global
'http://www.politiken.dk/',
# Why: #7963 in Alexa global
'http://www.youwatch.org/',
# Why: #7965 in Alexa global
'http://www.lesoir.be/',
# Why: #7966 in Alexa global
'http://www.toyokeizai.net/',
# Why: #7967 in Alexa global
'http://www.centos.org/',
# Why: #7968 in Alexa global
'http://www.sunnyplayer.com/',
# Why: #7969 in Alexa global
'http://www.knuddels.de/',
# Why: #7970 in Alexa global
'http://www.mturk.com/',
# Why: #7971 in Alexa global
'http://www.egymodern.com/',
# Why: #7972 in Alexa global
'http://www.semprot.com/',
# Why: #7973 in Alexa global
'http://www.monsterhigh.com/',
# Why: #7974 in Alexa global
'http://www.kompass.com/',
# Why: #7975 in Alexa global
'http://www.olx.com.ve/',
# Why: #7976 in Alexa global
'http://www.hq-xnxx.com/',
# Why: #7977 in Alexa global
'http://www.whorush.com/',
# Why: #7978 in Alexa global
'http://www.bongdaso.com/',
# Why: #7979 in Alexa global
'http://www.centrelink.gov.au/',
# Why: #7980 in Alexa global
'http://www.folha.com.br/',
# Why: #7981 in Alexa global
'http://www.getjetso.com/',
# Why: #7982 in Alexa global
'http://www.ycombinator.com/',
# Why: #7983 in Alexa global
'http://www.chouti.com/',
# Why: #7984 in Alexa global
'http://www.33lc.com/',
# Why: #7985 in Alexa global
'http://www.empowernetwork.com/+LO9YhVOjRPGiarC7uA9iA==/',
# Why: #7986 in Alexa global
'http://www.hostgator.com.br/',
# Why: #7987 in Alexa global
'http://www.emirates247.com/',
# Why: #7988 in Alexa global
'http://www.itpub.net/',
# Why: #7989 in Alexa global
'http://www.fsymbols.com/',
# Why: #7990 in Alexa global
'http://www.bestproducttesters.com/',
# Why: #7991 in Alexa global
'http://daodao.com/',
# Why: #7992 in Alexa global
'http://www.virtuemart.net/',
# Why: #7993 in Alexa global
'http://www.hindilinks4u.net/',
# Why: #7994 in Alexa global
'http://www.nnm.me/',
# Why: #7995 in Alexa global
'http://www.xplocial.com/',
# Why: #7996 in Alexa global
'http://www.apartments.com/',
# Why: #7997 in Alexa global
'http://www.ekolay.net/',
# Why: #7998 in Alexa global
'http://www.doviz.com/',
# Why: #7999 in Alexa global
'http://www.flixya.com/',
# Why: #8000 in Alexa global
'http://www.3almthqafa.com/',
# Why: #8001 in Alexa global
'http://www.zamalekfans.com/',
# Why: #8002 in Alexa global
'http://www.imeigu.com/',
# Why: #8003 in Alexa global
'http://www.wikibit.net/',
# Why: #8004 in Alexa global
'http://www.windstream.net/',
# Why: #8005 in Alexa global
'http://www.matichon.co.th/',
# Why: #8006 in Alexa global
'http://www.appshopper.com/',
# Why: #8007 in Alexa global
'http://www.socialbakers.com/',
# Why: #8008 in Alexa global
'http://www.1popov.ru/',
# Why: #8009 in Alexa global
'http://www.blikk.hu/',
# Why: #8010 in Alexa global
'http://www.bdr130.net/',
# Why: #8011 in Alexa global
'http://www.arizona.edu/',
# Why: #8012 in Alexa global
'http://www.madhyamam.com/',
# Why: #8013 in Alexa global
'http://www.mweb.co.za/',
# Why: #8014 in Alexa global
'http://www.affiliates.de/',
# Why: #8015 in Alexa global
'http://www.ebs.in/',
# Why: #8016 in Alexa global
'http://www.bestgfx.com/',
# Why: #8017 in Alexa global
'http://www.share-games.com/',
# Why: #8018 in Alexa global
'http://www.informador.com.mx/',
# Why: #8019 in Alexa global
'http://www.jobsite.co.uk/',
# Why: #8020 in Alexa global
'http://www.carters.com/',
# Why: #8021 in Alexa global
'http://www.kinghost.net/',
# Why: #8022 in Alexa global
'http://www.us1.com/',
# Why: #8024 in Alexa global
'http://www.archives.com/',
# Why: #8025 in Alexa global
'http://www.forosdelweb.com/',
# Why: #8026 in Alexa global
'http://www.siteslike.com/',
# Why: #8027 in Alexa global
'http://www.thedailyshow.com/',
# Why: #8028 in Alexa global
'http://www.68design.net/',
# Why: #8029 in Alexa global
'http://www.imtalk.org/',
# Why: #8030 in Alexa global
'http://www.visualwebsiteoptimizer.com/',
# Why: #8031 in Alexa global
'http://www.glarysoft.com/',
# Why: #8032 in Alexa global
'http://xhby.net/',
# Why: #8033 in Alexa global
'http://www.cosp.jp/',
# Why: #8034 in Alexa global
'http://www.email.cz/',
# Why: #8035 in Alexa global
'http://www.amateurs-gone-wild.com/',
# Why: #8036 in Alexa global
'http://www.davidwalsh.name/',
# Why: #8037 in Alexa global
'http://www.finalfantasyxiv.com/',
# Why: #8038 in Alexa global
'http://www.aa.com.tr/',
# Why: #8039 in Alexa global
'http://www.legalzoom.com/',
# Why: #8040 in Alexa global
'http://www.lifehack.org/',
# Why: #8041 in Alexa global
'http://www.mca.gov.in/',
# Why: #8042 in Alexa global
'http://www.hidrvids.com/',
# Why: #8043 in Alexa global
'http://netaatoz.jp/',
# Why: #8044 in Alexa global
'http://www.key.com/',
# Why: #8045 in Alexa global
'http://www.thumbtack.com/',
# Why: #8046 in Alexa global
'http://www.nujij.nl/',
# Why: #8047 in Alexa global
'http://www.cinetux.org/',
# Why: #8048 in Alexa global
'http://www.hmetro.com.my/',
# Why: #8049 in Alexa global
'http://www.ignou.ac.in/',
# Why: #8051 in Alexa global
'http://www.affilorama.com/',
# Why: #8052 in Alexa global
'http://www.pokemon.com/',
# Why: #8053 in Alexa global
'http://www.sportsnewsinternational.com/',
# Why: #8054 in Alexa global
'http://www.geek.com/',
# Why: #8055 in Alexa global
'http://www.larepublica.pe/',
# Why: #8056 in Alexa global
'http://www.europacasino.com/',
# Why: #8058 in Alexa global
'http://www.ok-porn.com/',
# Why: #8059 in Alexa global
'http://www.tutorialzine.com/',
# Why: #8060 in Alexa global
'http://www.google.com.bn/',
# Why: #8061 in Alexa global
'http://www.site5.com/',
# Why: #8062 in Alexa global
'http://www.trafficjunky.net/',
# Why: #8063 in Alexa global
'http://www.xueqiu.com/',
# Why: #8064 in Alexa global
'http://www.yournewscorner.com/',
# Why: #8065 in Alexa global
'http://www.metrotvnews.com/',
# Why: #8066 in Alexa global
'http://www.nichegalz.com/',
# Why: #8067 in Alexa global
'http://www.job.com/',
# Why: #8068 in Alexa global
'http://www.koimoi.com/',
# Why: #8069 in Alexa global
'http://www.questionablecontent.net/',
# Why: #8070 in Alexa global
'http://www.volaris.mx/',
# Why: #8071 in Alexa global
'http://www.rakuten.de/',
# Why: #8072 in Alexa global
'http://www.cyworld.com/',
# Why: #8073 in Alexa global
'http://www.yudu.com/',
# Why: #8074 in Alexa global
'http://www.zakon.kz/',
# Why: #8075 in Alexa global
'http://www.msi.com/',
# Why: #8076 in Alexa global
'http://www.darkxxxtube.com/',
# Why: #8077 in Alexa global
'http://www.samakal.net/',
# Why: #8078 in Alexa global
'http://www.appstorm.net/',
# Why: #8079 in Alexa global
'http://www.vulture.com/',
# Why: #8080 in Alexa global
'http://www.lswb.com.cn/',
# Why: #8081 in Alexa global
'http://www.racingpost.com/',
# Why: #8082 in Alexa global
'http://www.classicrummy.com/',
# Why: #8083 in Alexa global
'http://www.iegallery.com/',
# Why: #8084 in Alexa global
'http://www.cinemagia.ro/',
# Why: #8085 in Alexa global
'http://nullpoantenna.com/',
# Why: #8086 in Alexa global
'http://www.ihned.cz/',
# Why: #8087 in Alexa global
'http://vdolady.com/',
# Why: #8088 in Alexa global
'http://www.babes.com/',
# Why: #8089 in Alexa global
'http://www.komli.com/',
# Why: #8090 in Alexa global
'http://www.asianbeauties.com/',
# Why: #8091 in Alexa global
'http://www.onedate.com/',
# Why: #8092 in Alexa global
'http://www.adhitz.com/',
# Why: #8093 in Alexa global
'http://www.jjgirls.com/',
# Why: #8094 in Alexa global
'http://www.dot.tk/',
# Why: #8095 in Alexa global
'http://caras.uol.com.br/',
# Why: #8096 in Alexa global
'http://www.autobild.de/',
# Why: #8097 in Alexa global
'http://www.jobs-to-careers.com/',
# Why: #8098 in Alexa global
'http://movietickets.com/',
# Why: #8099 in Alexa global
'http://www.net4.in/',
# Why: #8100 in Alexa global
'http://www.crutchfield.com/',
# Why: #8101 in Alexa global
'http://www.subdivx.com/',
# Why: #8102 in Alexa global
'http://www.damai.cn/',
# Why: #8103 in Alexa global
'http://www.sirarcade.com/',
# Why: #8104 in Alexa global
'http://sitescoutadserver.com/',
# Why: #8105 in Alexa global
'http://www.fantasy-rivals.com/',
# Why: #8106 in Alexa global
'http://www.chegg.com/',
# Why: #8107 in Alexa global
'http://www.sportsmansguide.com/',
# Why: #8108 in Alexa global
'http://www.extremetech.com/',
# Why: #8109 in Alexa global
'http://www.loft.com/',
# Why: #8110 in Alexa global
'http://www.dirtyamateurtube.com/',
# Why: #8111 in Alexa global
'http://painelhost.uol.com.br/',
# Why: #8112 in Alexa global
'http://www.socialsex.biz/',
# Why: #8113 in Alexa global
'http://www.opensubtitles.us/',
# Why: #8114 in Alexa global
'http://www.infomoney.com.br/',
# Why: #8115 in Alexa global
'http://www.openstat.ru/',
# Why: #8116 in Alexa global
'http://www.adlandpro.com/',
# Why: #8117 in Alexa global
'http://www.trivago.de/',
# Why: #8118 in Alexa global
'http://feiren.com/',
# Why: #8119 in Alexa global
'http://www.lespac.com/',
# Why: #8120 in Alexa global
'http://www.icook.tw/',
# Why: #8121 in Alexa global
'http://www.iceporn.com/',
# Why: #8122 in Alexa global
'http://www.animehere.com/',
# Why: #8123 in Alexa global
'http://www.klix.ba/',
# Why: #8124 in Alexa global
'http://www.elitepvpers.com/',
# Why: #8125 in Alexa global
'http://www.mrconservative.com/',
# Why: #8126 in Alexa global
'http://www.tamu.edu/',
# Why: #8127 in Alexa global
'http://www.startv.com.tr/',
# Why: #8128 in Alexa global
'http://www.haber1903.com/',
# Why: #8129 in Alexa global
'http://www.apa.tv/',
# Why: #8130 in Alexa global
'http://uc.cn/',
# Why: #8131 in Alexa global
'http://www.idbi.com/',
# Why: #8132 in Alexa global
'http://www.golfchannel.com/',
# Why: #8133 in Alexa global
'http://www.pep.ph/',
# Why: #8134 in Alexa global
'http://www.toukoucity.to/',
# Why: #8135 in Alexa global
'http://www.empiremoney.com/',
# Why: #8136 in Alexa global
'http://www.androidauthority.com/',
# Why: #8137 in Alexa global
'http://www.ref4bux.com/',
# Why: #8138 in Alexa global
'http://www.digitaljournal.com/',
# Why: #8139 in Alexa global
'http://www.sporcle.com/',
# Why: #8141 in Alexa global
'http://www.183.com.cn/',
# Why: #8142 in Alexa global
'http://www.bzwbk.pl/',
# Why: #8143 in Alexa global
'http://lalamao.com/',
# Why: #8144 in Alexa global
'http://www.ziare.com/',
# Why: #8145 in Alexa global
'http://www.cliti.com/',
# Why: #8146 in Alexa global
'http://www.thatguywiththeglasses.com/',
# Why: #8147 in Alexa global
'http://www.vodu.ch/',
# Why: #8148 in Alexa global
'http://www.ycwb.com/',
# Why: #8149 in Alexa global
'http://www.bls.gov/',
# Why: #8150 in Alexa global
'http://www.matsui.co.jp/',
# Why: #8151 in Alexa global
'http://xmrc.com.cn/',
# Why: #8152 in Alexa global
'http://1tubenews.com/',
# Why: #8153 in Alexa global
'http://www.cl.ly/',
# Why: #8154 in Alexa global
'http://www.ing.be/',
# Why: #8155 in Alexa global
'http://www.bitterstrawberry.com/',
# Why: #8156 in Alexa global
'http://www.fubar.com/',
# Why: #8157 in Alexa global
'http://www.arabic-keyboard.org/',
# Why: #8158 in Alexa global
'http://www.mejortorrent.com/',
# Why: #8159 in Alexa global
'http://www.trendmicro.com/',
# Why: #8160 in Alexa global
'http://www.ap7am.com/',
# Why: #8161 in Alexa global
'http://www.windowsazure.com/',
# Why: #8162 in Alexa global
'http://www.q8yat.com/',
# Why: #8163 in Alexa global
'http://www.yyv.co/',
# Why: #8164 in Alexa global
'http://www.tvoy-start.com/',
# Why: #8165 in Alexa global
'http://www.creativetoolbars.com/',
# Why: #8166 in Alexa global
'http://www.forrent.com/',
# Why: #8167 in Alexa global
'http://www.mlstatic.com/',
# Why: #8168 in Alexa global
'http://www.like4like.org/',
# Why: #8169 in Alexa global
'http://www.alpha.gr/',
# Why: #8170 in Alexa global
'http://www.amkey.net/',
# Why: #8172 in Alexa global
'http://www.iwiw.hu/',
# Why: #8173 in Alexa global
'http://www.routard.com/',
# Why: #8174 in Alexa global
'http://www.teacherspayteachers.com/',
# Why: #8175 in Alexa global
'http://www.ahashare.com/',
# Why: #8176 in Alexa global
'http://www.ultoo.com/',
# Why: #8177 in Alexa global
'http://www.oakley.com/',
# Why: #8178 in Alexa global
'http://www.upforit.com/',
# Why: #8179 in Alexa global
'http://www.trafficbee.com/',
# Why: #8180 in Alexa global
'http://www.monster.co.uk/',
# Why: #8181 in Alexa global
'http://www.boulanger.fr/',
# Why: #8182 in Alexa global
'http://www.bloglines.com/',
# Why: #8183 in Alexa global
'http://www.wdc.com/',
# Why: #8184 in Alexa global
'http://www.backpackers.com.tw/',
# Why: #8185 in Alexa global
'http://www.el-nacional.com/',
# Why: #8186 in Alexa global
'http://www.bloggertipstricks.com/',
# Why: #8187 in Alexa global
'http://www.oreillyauto.com/',
# Why: #8188 in Alexa global
'http://www.hotpads.com/',
# Why: #8189 in Alexa global
'http://www.tubexvideo.com/',
# Why: #8190 in Alexa global
'http://www.mudainodocument.com/',
# Why: #8191 in Alexa global
'http://www.17car.com.cn/',
# Why: #8192 in Alexa global
'http://www.discoverpedia.info/',
# Why: #8193 in Alexa global
'http://www.noobteens.com/',
# Why: #8194 in Alexa global
'http://www.shockmansion.com/',
# Why: #8195 in Alexa global
'http://www.qudsonline.ir/',
# Why: #8196 in Alexa global
'http://www.mec.es/',
# Why: #8197 in Alexa global
'http://www.vt.edu/',
# Why: #8198 in Alexa global
'http://www.akelite.com/',
# Why: #8199 in Alexa global
'http://www.travelandleisure.com/',
# Why: #8200 in Alexa global
'http://www.sunnewsonline.com/',
# Why: #8201 in Alexa global
'http://www.tok2.com/',
# Why: #8202 in Alexa global
'http://www.truste.org/',
# Why: #8203 in Alexa global
'http://www.2dehands.be/',
# Why: #8204 in Alexa global
'http://www.hf365.com/',
# Why: #8205 in Alexa global
'http://www.westelm.com/',
# Why: #8206 in Alexa global
'http://www.radiko.jp/',
# Why: #8207 in Alexa global
'http://www.real.gr/',
# Why: #8208 in Alexa global
'http://www.blogcms.jp/',
# Why: #8209 in Alexa global
'http://www.downloadming.me/',
# Why: #8210 in Alexa global
'http://www.citromail.hu/',
# Why: #8211 in Alexa global
'http://www.fotocommunity.de/',
# Why: #8212 in Alexa global
'http://www.zapjuegos.com/',
# Why: #8213 in Alexa global
'http://www.aastocks.com/',
# Why: #8214 in Alexa global
'http://www.unb.br/',
# Why: #8215 in Alexa global
'http://www.adchakra.net/',
# Why: #8216 in Alexa global
'http://www.check24.de/',
# Why: #8217 in Alexa global
'http://www.vidto.me/',
# Why: #8218 in Alexa global
'http://www.peekyou.com/',
# Why: #8219 in Alexa global
'http://www.urssaf.fr/',
# Why: #8220 in Alexa global
'http://www.alixixi.com/',
# Why: #8221 in Alexa global
'http://www.winamp.com/',
# Why: #8222 in Alexa global
'http://www.xianguo.com/',
# Why: #8223 in Alexa global
'http://www.indiasextube.net/',
# Why: #8224 in Alexa global
'http://www.fitnea.com/',
# Why: #8225 in Alexa global
'http://www.telemundo.com/',
# Why: #8226 in Alexa global
'http://www.webnode.cz/',
# Why: #8227 in Alexa global
'http://www.kliksaya.com/',
# Why: #8228 in Alexa global
'http://www.wikileaks.org/',
# Why: #8229 in Alexa global
'http://www.myblog.it/',
# Why: #8231 in Alexa global
'http://www.99wed.com/',
# Why: #8232 in Alexa global
'http://www.adorika.com/',
# Why: #8233 in Alexa global
'http://www.siliconrus.com/',
# Why: #8235 in Alexa global
'http://www.dealmoon.com/',
# Why: #8236 in Alexa global
'http://www.ricanadfunds.com/',
# Why: #8237 in Alexa global
'http://www.vietcombank.com.vn/',
# Why: #8238 in Alexa global
'http://www.chemistry.com/',
# Why: #8239 in Alexa global
'http://www.reisen.de/',
# Why: #8240 in Alexa global
'http://www.torlock.com/',
# Why: #8241 in Alexa global
'http://www.wsop.com/',
# Why: #8242 in Alexa global
'http://www.travian.co.id/',
# Why: #8243 in Alexa global
'http://www.ipoll.com/',
# Why: #8244 in Alexa global
'http://www.bpiexpressonline.com/',
# Why: #8245 in Alexa global
'http://www.neeu.com/',
# Why: #8246 in Alexa global
'http://www.atmarkit.co.jp/',
# Why: #8247 in Alexa global
'http://www.beyondtherack.com/',
# Why: #8248 in Alexa global
'http://blueidea.com/',
# Why: #8249 in Alexa global
'http://www.tedata.net/',
# Why: #8250 in Alexa global
'http://www.gamesradar.com/',
# Why: #8251 in Alexa global
'http://www.big.az/',
# Why: #8252 in Alexa global
'http://www.h-douga.net/',
# Why: #8253 in Alexa global
'http://www.runnersworld.com/',
# Why: #8254 in Alexa global
'http://www.lumfile.com/',
# Why: #8255 in Alexa global
'http://ccoo.cn/',
# Why: #8256 in Alexa global
'http://www.u17.com/',
# Why: #8257 in Alexa global
'http://www.badjojo.com/',
# Why: #8259 in Alexa global
'http://eplus.jp/',
# Why: #8260 in Alexa global
'http://www.nginx.org/',
# Why: #8261 in Alexa global
'http://www.filmfanatic.com/',
# Why: #8262 in Alexa global
'http://www.filmey.com/',
# Why: #8263 in Alexa global
'http://www.mousebreaker.com/',
# Why: #8264 in Alexa global
'http://www.mihanstore.net/',
# Why: #8265 in Alexa global
'http://www.sharebuilder.com/',
# Why: #8266 in Alexa global
'http://cnhan.com/',
# Why: #8267 in Alexa global
'http://www.partnerwithtom.com/',
# Why: #8268 in Alexa global
'http://www.synonym.com/',
# Why: #8269 in Alexa global
'http://www.areaconnect.com/',
# Why: #8271 in Alexa global
'http://www.one.lt/',
# Why: #8272 in Alexa global
'http://www.mp3quran.net/',
# Why: #8273 in Alexa global
'http://www.anz.co.nz/',
# Why: #8274 in Alexa global
'http://www.buyincoins.com/',
# Why: #8275 in Alexa global
'http://www.surfline.com/',
# Why: #8276 in Alexa global
'http://www.packtpub.com/',
# Why: #8277 in Alexa global
'http://www.informe21.com/',
# Why: #8278 in Alexa global
'http://www.d4000.com/',
# Why: #8279 in Alexa global
'http://www.blog.cz/',
# Why: #8280 in Alexa global
'http://www.myredbook.com/',
# Why: #8281 in Alexa global
'http://www.seslisozluk.net/',
# Why: #8282 in Alexa global
'http://www.simple2advertise.com/',
# Why: #8283 in Alexa global
'http://www.bookit.com/',
# Why: #8284 in Alexa global
'http://www.eranico.com/',
# Why: #8285 in Alexa global
'http://www.pakwheels.com/',
# Why: #8286 in Alexa global
'http://www.x-rates.com/',
# Why: #8287 in Alexa global
'http://www.ilmatieteenlaitos.fi/',
# Why: #8288 in Alexa global
'http://www.vozforums.com/',
# Why: #8289 in Alexa global
'http://www.galerieslafayette.com/',
# Why: #8290 in Alexa global
'http://www.trafficswirl.com/',
# Why: #8291 in Alexa global
'http://www.mql4.com/',
# Why: #8292 in Alexa global
'http://www.torontosun.com/',
# Why: #8293 in Alexa global
'http://www.channel.or.jp/',
# Why: #8295 in Alexa global
'http://www.lebuteur.com/',
# Why: #8296 in Alexa global
'http://www.cruisecritic.com/',
# Why: #8297 in Alexa global
'http://www.rateyourmusic.com/',
# Why: #8298 in Alexa global
'http://www.binsearch.info/',
# Why: #8299 in Alexa global
'http://www.nrj.fr/',
# Why: #8300 in Alexa global
'http://www.megaflix.net/',
# Why: #8301 in Alexa global
'http://www.dosug.cz/',
# Why: #8302 in Alexa global
'http://www.spdb.com.cn/',
# Why: #8303 in Alexa global
'http://www.stop55.com/',
# Why: #8304 in Alexa global
'http://www.qqnz.com/',
# Why: #8305 in Alexa global
'http://ibuonline.com/',
# Why: #8306 in Alexa global
'http://www.jobego.com/',
# Why: #8307 in Alexa global
'http://www.euro.com.pl/',
# Why: #8308 in Alexa global
'http://www.quran.com/',
# Why: #8309 in Alexa global
'http://www.ad1.ru/',
# Why: #8310 in Alexa global
'http://www.avaz.ba/',
# Why: #8311 in Alexa global
'http://www.eloqua.com/',
# Why: #8312 in Alexa global
'http://www.educationconnection.com/',
# Why: #8313 in Alexa global
'http://www.dbank.com/',
# Why: #8314 in Alexa global
'http://www.whois.sc/',
# Why: #8315 in Alexa global
'http://www.youmob.com/',
# Why: #8316 in Alexa global
'http://www.101greatgoals.com/',
# Why: #8317 in Alexa global
'http://www.livefyre.com/',
# Why: #8318 in Alexa global
'http://www.sextubebox.com/',
# Why: #8319 in Alexa global
'http://www.shooshtime.com/',
# Why: #8320 in Alexa global
'http://www.tapuz.co.il/',
# Why: #8321 in Alexa global
'http://www.auchan.fr/',
# Why: #8322 in Alexa global
'http://www.pinkvilla.com/',
# Why: #8323 in Alexa global
'http://www.perspolisnews.com/',
# Why: #8324 in Alexa global
'http://www.scholastic.com/',
# Why: #8325 in Alexa global
'http://www.google.mu/',
# Why: #8326 in Alexa global
'http://www.forex4you.org/',
# Why: #8327 in Alexa global
'http://www.mandtbank.com/',
# Why: #8328 in Alexa global
'http://www.gnezdo.ru/',
# Why: #8329 in Alexa global
'http://www.lulu.com/',
# Why: #8330 in Alexa global
'http://www.anniezhang.com/',
# Why: #8331 in Alexa global
'http://www.bharian.com.my/',
# Why: #8332 in Alexa global
'http://www.comprafacil.com.br/',
# Why: #8333 in Alexa global
'http://www.mmafighting.com/',
# Why: #8334 in Alexa global
'http://www.autotrader.ca/',
# Why: #8335 in Alexa global
'http://www.vectorstock.com/',
# Why: #8336 in Alexa global
'http://www.convio.com/',
# Why: #8337 in Alexa global
'http://www.ktunnel.com/',
# Why: #8338 in Alexa global
'http://www.hbs.edu/',
# Why: #8339 in Alexa global
'http://www.mindspark.com/',
# Why: #8340 in Alexa global
'http://www.trovit.com.mx/',
# Why: #8341 in Alexa global
'http://www.thomsonreuters.com/',
# Why: #8342 in Alexa global
'http://www.yupptv.com/',
# Why: #8343 in Alexa global
'http://www.fullsail.edu/',
# Why: #8344 in Alexa global
'http://www.perfectworld.eu/',
# Why: #8345 in Alexa global
'http://www.ju51.com/',
# Why: #8346 in Alexa global
'http://www.newssnip.com/',
# Why: #8347 in Alexa global
'http://www.livemocha.com/',
# Why: #8348 in Alexa global
'http://www.nespresso.com/',
# Why: #8349 in Alexa global
'http://www.uinvest.com.ua/',
# Why: #8350 in Alexa global
'http://www.yazete.com/',
# Why: #8351 in Alexa global
'http://www.malaysiaairlines.com/',
# Why: #8352 in Alexa global
'http://www.clikseguro.com/',
# Why: #8353 in Alexa global
'http://www.marksdailyapple.com/',
# Why: #8354 in Alexa global
'http://www.topnewsquick.com/',
# Why: #8355 in Alexa global
'http://www.ikyu.com/',
# Why: #8356 in Alexa global
'http://www.mydocomo.com/',
# Why: #8357 in Alexa global
'http://www.tampabay.com/',
# Why: #8358 in Alexa global
'http://www.mo.gov/',
# Why: #8359 in Alexa global
'http://www.daiwa.co.jp/',
# Why: #8360 in Alexa global
'http://www.amiami.jp/',
# Why: #8361 in Alexa global
'http://www.oxfordjournals.org/',
# Why: #8362 in Alexa global
'http://www.manageyourloans.com/',
# Why: #8363 in Alexa global
'http://www.couponcabin.com/',
# Why: #8364 in Alexa global
'http://www.qmnnk.blog.163.com/',
# Why: #8365 in Alexa global
'http://www.mrmlsmatrix.com/',
# Why: #8366 in Alexa global
'http://www.knowd.com/',
# Why: #8367 in Alexa global
'http://www.ladbrokes.com/',
# Why: #8368 in Alexa global
'http://www.ikoo.com/',
# Why: #8369 in Alexa global
'http://www.devhub.com/',
# Why: #8370 in Alexa global
'http://www.dropjack.com/',
# Why: #8371 in Alexa global
'http://www.sadistic.pl/',
# Why: #8372 in Alexa global
'http://www.8comic.com/',
# Why: #8373 in Alexa global
'http://www.optimizepress.com/',
# Why: #8374 in Alexa global
'http://ofweek.com/',
# Why: #8375 in Alexa global
'http://www.msn.com.tw/',
# Why: #8376 in Alexa global
'http://www.donya-e-eqtesad.com/',
# Why: #8377 in Alexa global
'http://www.arabam.com/',
# Why: #8378 in Alexa global
'http://www.playtv.fr/',
# Why: #8379 in Alexa global
'http://www.yourtv.com.au/',
# Why: #8380 in Alexa global
'http://www.teamtalk.com/',
# Why: #8381 in Alexa global
'http://www.createsend.com/',
# Why: #8382 in Alexa global
'http://www.bitcointalk.org/',
# Why: #8383 in Alexa global
'http://www.microcenter.com/',
# Why: #8384 in Alexa global
'http://www.arcadeprehacks.com/',
# Why: #8385 in Alexa global
'http://www.sublimetext.com/',
# Why: #8386 in Alexa global
'http://www.posindonesia.co.id/',
# Why: #8387 in Alexa global
'http://www.paymaster.ru/',
# Why: #8388 in Alexa global
'http://www.ncore.cc/',
# Why: #8390 in Alexa global
'http://www.wikisource.org/',
# Why: #8391 in Alexa global
'http://www.wowgame.jp/',
# Why: #8392 in Alexa global
'http://www.notebooksbilliger.de/',
# Why: #8393 in Alexa global
'http://www.nayakhabar.com/',
# Why: #8394 in Alexa global
'http://www.tim.com.br/',
# Why: #8395 in Alexa global
'http://www.leggo.it/',
# Why: #8396 in Alexa global
'http://www.swoodoo.com/',
# Why: #8397 in Alexa global
'http://www.perfectgirls.es/',
# Why: #8398 in Alexa global
'http://www.beautystyleliving.com/',
# Why: #8399 in Alexa global
'http://www.xmaduras.com/',
# Why: #8400 in Alexa global
'http://www.e-shop.gr/',
# Why: #8401 in Alexa global
'http://www.k8.cn/',
# Why: #8402 in Alexa global
'http://www.27.cn/',
# Why: #8403 in Alexa global
'http://www.belastingdienst.nl/',
# Why: #8404 in Alexa global
'http://www.urbia.de/',
# Why: #8405 in Alexa global
'http://www.lovoo.net/',
# Why: #8406 in Alexa global
'http://www.citizensbank.com/',
# Why: #8407 in Alexa global
'http://www.gulesider.no/',
# Why: #8408 in Alexa global
'http://zhongsou.net/',
# Why: #8409 in Alexa global
'http://www.cinemablend.com/',
# Why: #8410 in Alexa global
'http://www.joydownload.com/',
# Why: #8411 in Alexa global
'http://www.cncmax.cn/',
# Why: #8412 in Alexa global
'http://www.telkom.co.id/',
# Why: #8413 in Alexa global
'http://www.nangaspace.com/',
# Why: #8414 in Alexa global
'http://www.panerabread.com/',
# Why: #8415 in Alexa global
'http://www.cinechest.com/',
# Why: #8416 in Alexa global
'http://www.flixjunky.com/',
# Why: #8417 in Alexa global
'http://www.berlin1.de/',
# Why: #8418 in Alexa global
'http://www.tabonito.pt/',
# Why: #8419 in Alexa global
'http://www.snob.ru/',
# Why: #8420 in Alexa global
'http://www.audiovkontakte.ru/',
# Why: #8421 in Alexa global
'http://www.linuxmint.com/',
# Why: #8422 in Alexa global
'http://www.freshdesk.com/',
# Why: #8423 in Alexa global
'http://www.professionali.ru/',
# Why: #8425 in Alexa global
'http://www.primelocation.com/',
# Why: #8426 in Alexa global
'http://www.femina.hu/',
# Why: #8427 in Alexa global
'http://www.jecontacte.com/',
# Why: #8428 in Alexa global
'http://www.celebritytoob.com/',
# Why: #8429 in Alexa global
'http://www.streamiz-filmze.com/',
# Why: #8430 in Alexa global
'http://l-tike.com/',
# Why: #8431 in Alexa global
'http://www.collegeconfidential.com/',
# Why: #8432 in Alexa global
'http://hafiz.gov.sa/',
# Why: #8433 in Alexa global
'http://www.mega-porno.ru/',
# Why: #8434 in Alexa global
'http://www.ivoox.com/',
# Why: #8435 in Alexa global
'http://www.lmgtfy.com/',
# Why: #8436 in Alexa global
'http://www.pclab.pl/',
# Why: #8437 in Alexa global
'http://www.preisvergleich.de/',
# Why: #8438 in Alexa global
'http://www.weeb.tv/',
# Why: #8439 in Alexa global
'http://www.80018.cn/',
# Why: #8440 in Alexa global
'http://www.tnews.ir/',
# Why: #8441 in Alexa global
'http://www.johnnys-net.jp/',
# Why: #8442 in Alexa global
'http://www.wwtdd.com/',
# Why: #8444 in Alexa global
'http://www.totalfilm.com/',
# Why: #8445 in Alexa global
'http://www.girlfriendvideos.com/',
# Why: #8446 in Alexa global
'http://www.wgt.com/',
# Why: #8447 in Alexa global
'http://www.iu.edu/',
# Why: #8448 in Alexa global
'http://www.topictorch.com/',
# Why: #8449 in Alexa global
'http://www.wenweipo.com/',
# Why: #8450 in Alexa global
'http://duitang.com/',
# Why: #8452 in Alexa global
'http://www.madrid.org/',
# Why: #8453 in Alexa global
'http://www.retrogamer.com/',
# Why: #8454 in Alexa global
'http://www.pantheranetwork.com/',
# Why: #8455 in Alexa global
'http://www.someecards.com/',
# Why: #8456 in Alexa global
'http://www.visafone.com.ng/',
# Why: #8457 in Alexa global
'http://www.infopraca.pl/',
# Why: #8458 in Alexa global
'http://www.nrelate.com/',
# Why: #8459 in Alexa global
'http://www.sia.az/',
# Why: #8460 in Alexa global
'http://www.wallbase.cc/',
# Why: #8461 in Alexa global
'http://www.shareflare.net/',
# Why: #8462 in Alexa global
'http://www.sammydress.com/',
# Why: #8463 in Alexa global
'http://www.goldesel.to/',
# Why: #8464 in Alexa global
'http://www.thefiscaltimes.com/',
# Why: #8465 in Alexa global
'http://www.freelogoservices.com/',
# Why: #8467 in Alexa global
'http://www.dealigg.com/',
# Why: #8468 in Alexa global
'http://www.babypips.com/',
# Why: #8469 in Alexa global
'http://www.diynetwork.com/',
# Why: #8470 in Alexa global
'http://www.porn99.net/',
# Why: #8471 in Alexa global
'http://www.skynewsarabia.com/',
# Why: #8472 in Alexa global
'http://www.eweb4.com/',
# Why: #8473 in Alexa global
'http://www.fedoraproject.org/',
# Why: #8474 in Alexa global
'http://www.nolo.com/',
# Why: #8475 in Alexa global
'http://www.homelink.com.cn/',
# Why: #8476 in Alexa global
'http://www.megabus.com/',
# Why: #8477 in Alexa global
'http://www.fao.org/',
# Why: #8478 in Alexa global
'http://www.am.ru/',
# Why: #8479 in Alexa global
'http://www.sportowefakty.pl/',
# Why: #8481 in Alexa global
'http://www.kidstaff.com.ua/',
# Why: #8482 in Alexa global
'http://www.jhu.edu/',
# Why: #8483 in Alexa global
'http://www.which.co.uk/',
# Why: #8484 in Alexa global
'http://www.sextubehd.xxx/',
# Why: #8485 in Alexa global
'http://www.swansonvitamins.com/',
# Why: #8486 in Alexa global
'http://www.iran-eng.com/',
# Why: #8487 in Alexa global
'http://www.fakenamegenerator.com/',
# Why: #8488 in Alexa global
'http://www.gosong.net/',
# Why: #8489 in Alexa global
'http://www.pep.com.cn/',
# Why: #8490 in Alexa global
'http://www.24open.ru/',
# Why: #8491 in Alexa global
'http://www.123sdfsdfsdfsd.ru/',
# Why: #8492 in Alexa global
'http://www.gotgayporn.com/',
# Why: #8493 in Alexa global
'http://www.zaq.ne.jp/',
# Why: #8494 in Alexa global
'http://www.casadellibro.com/',
# Why: #8495 in Alexa global
'http://www.ixwebhosting.com/',
# Why: #8496 in Alexa global
'http://www.buyorbury.com/',
# Why: #8497 in Alexa global
'http://www.getglue.com/',
# Why: #8498 in Alexa global
'http://www.864321.com/',
# Why: #8499 in Alexa global
'http://www.alivv.com/',
# Why: #8500 in Alexa global
'http://www.4.cn/',
# Why: #8501 in Alexa global
'http://www.competitor.com/',
# Why: #8502 in Alexa global
'http://www.iheima.com/',
# Why: #8503 in Alexa global
'http://www.submarinoviagens.com.br/',
# Why: #8504 in Alexa global
'http://emailsrvr.com/',
# Why: #8505 in Alexa global
'http://www.udacity.com/',
# Why: #8506 in Alexa global
'http://www.mcafeesecure.com/',
# Why: #8507 in Alexa global
'http://www.laposte.fr/',
# Why: #8508 in Alexa global
'http://olhardigital.uol.com.br/',
# Why: #8509 in Alexa global
'http://ppy.sh/',
# Why: #8510 in Alexa global
'http://www.rumah.com/',
# Why: #8511 in Alexa global
'http://www.pullbear.com/',
# Why: #8512 in Alexa global
'http://www.pkt.pl/',
# Why: #8513 in Alexa global
'http://www.jayde.com/',
# Why: #8514 in Alexa global
'http://www.myjoyonline.com/',
# Why: #8515 in Alexa global
'http://www.locopengu.com/',
# Why: #8516 in Alexa global
'http://www.vsnl.net.in/',
# Why: #8517 in Alexa global
'http://www.hornbunny.com/',
# Why: #8518 in Alexa global
'http://www.royalcaribbean.com/',
# Why: #8520 in Alexa global
'http://www.football.ua/',
# Why: #8521 in Alexa global
'http://www.thaifriendly.com/',
# Why: #8522 in Alexa global
'http://www.bankofthewest.com/',
# Why: #8523 in Alexa global
'http://www.indianprice.com/',
# Why: #8524 in Alexa global
'http://www.chodientu.vn/',
# Why: #8525 in Alexa global
'http://www.alison.com/',
# Why: #8526 in Alexa global
'http://www.eveonline.com/',
# Why: #8527 in Alexa global
'http://www.blogg.se/',
# Why: #8528 in Alexa global
'http://www.jetairways.com/',
# Why: #8529 in Alexa global
'http://www.larousse.fr/',
# Why: #8530 in Alexa global
'http://www.noticierodigital.com/',
# Why: #8531 in Alexa global
'http://mkfst.com/',
# Why: #8532 in Alexa global
'http://www.anyfiledownloader.com/',
# Why: #8533 in Alexa global
'http://www.tiramillas.net/',
# Why: #8534 in Alexa global
'http://www.telus.com/',
# Why: #8535 in Alexa global
'http://www.paperblog.com/',
# Why: #8536 in Alexa global
'http://www.songsterr.com/',
# Why: #8537 in Alexa global
'http://www.entremujeres.com/',
# Why: #8538 in Alexa global
'http://www.startsiden.no/',
# Why: #8539 in Alexa global
'http://www.hotspotshield.com/',
# Why: #8540 in Alexa global
'http://www.hosteurope.de/',
# Why: #8541 in Alexa global
'http://www.ebags.com/',
# Why: #8542 in Alexa global
'http://www.eenadupratibha.net/',
# Why: #8543 in Alexa global
'http://www.uppit.com/',
# Why: #8544 in Alexa global
'http://www.piaohua.com/',
# Why: #8545 in Alexa global
'http://www.xxxymovies.com/',
# Why: #8546 in Alexa global
'http://www.netbarg.com/',
# Why: #8547 in Alexa global
'http://www.chip.com.tr/',
# Why: #8548 in Alexa global
'http://xl.co.id/',
# Why: #8549 in Alexa global
'http://www.kowalskypage.com/',
# Why: #8550 in Alexa global
'http://www.afterdawn.com/',
# Why: #8551 in Alexa global
'http://www.locanto.com/',
# Why: #8552 in Alexa global
'http://www.liilas.com/',
# Why: #8553 in Alexa global
'http://www.superboy.com/',
# Why: #8554 in Alexa global
'http://www.indiavisiontv.com/',
# Why: #8555 in Alexa global
'http://www.ixquick.com/',
# Why: #8556 in Alexa global
'http://www.hotelium.com/',
# Why: #8557 in Alexa global
'http://www.twsela.com/',
# Why: #8558 in Alexa global
'http://www.newsmeback.com/',
# Why: #8559 in Alexa global
'http://www.perfectliving.com/',
# Why: #8560 in Alexa global
'http://www.laughingsquid.com/',
# Why: #8561 in Alexa global
'http://www.designboom.com/',
# Why: #8562 in Alexa global
'http://www.zigil.ir/',
# Why: #8563 in Alexa global
'http://www.coachfactory.com/',
# Why: #8564 in Alexa global
'http://www.wst.cn/',
# Why: #8565 in Alexa global
'http://www.kaboodle.com/',
# Why: #8566 in Alexa global
'http://www.fastmail.fm/',
# Why: #8567 in Alexa global
'http://www.threadless.com/',
# Why: #8568 in Alexa global
'http://www.wiseconvert.com/',
# Why: #8569 in Alexa global
'http://www.br.de/',
# Why: #8570 in Alexa global
'http://www.promovacances.com/',
# Why: #8572 in Alexa global
'http://www.wrzuta.pl/',
# Why: #8573 in Alexa global
'http://www.fromdoctopdf.com/',
# Why: #8574 in Alexa global
'http://www.ono.es/',
# Why: #8575 in Alexa global
'http://www.zinio.com/',
# Why: #8576 in Alexa global
'http://netcoc.com/',
# Why: #8577 in Alexa global
'http://www.eanswers.com/',
# Why: #8578 in Alexa global
'http://www.wallst.com/',
# Why: #8579 in Alexa global
'http://www.ipiccy.com/',
# Why: #8580 in Alexa global
'http://www.fastweb.it/',
# Why: #8581 in Alexa global
'http://www.kaufmich.com/',
# Why: #8582 in Alexa global
'http://www.groupon.co.za/',
# Why: #8583 in Alexa global
'http://www.cyzo.com/',
# Why: #8584 in Alexa global
'http://www.addic7ed.com/',
# Why: #8585 in Alexa global
'http://www.liuliangbao.cn/',
# Why: #8586 in Alexa global
'http://www.alintibaha.net/',
# Why: #8587 in Alexa global
'http://www.indiewire.com/',
# Why: #8588 in Alexa global
'http://www.needforspeed.com/',
# Why: #8590 in Alexa global
'http://www.e24.no/',
# Why: #8591 in Alexa global
'http://www.hupso.com/',
# Why: #8592 in Alexa global
'http://www.kathimerini.gr/',
# Why: #8593 in Alexa global
'http://www.worldoffiles.net/',
# Why: #8594 in Alexa global
'http://www.express.pk/',
# Why: #8595 in Alexa global
'http://www.wieszjak.pl/',
# Why: #8597 in Alexa global
'http://www.mobile.bg/',
# Why: #8598 in Alexa global
'http://www.subway.com/',
# Why: #8599 in Alexa global
'http://www.akhbarelyom.com/',
# Why: #8600 in Alexa global
'http://www.thisoldhouse.com/',
# Why: #8601 in Alexa global
'http://www.autoevolution.com/',
# Why: #8602 in Alexa global
'http://www.public-api.wordpress.com/',
# Why: #8603 in Alexa global
'http://www.airarabia.com/',
# Why: #8604 in Alexa global
'http://www.powerball.com/',
# Why: #8605 in Alexa global
'http://www.mais.uol.com.br/',
# Why: #8606 in Alexa global
'http://www.visa.com/',
# Why: #8607 in Alexa global
'http://www.gendai.net/',
# Why: #8608 in Alexa global
'http://www.gymboree.com/',
# Why: #8609 in Alexa global
'http://www.tvp.pl/',
# Why: #8610 in Alexa global
'http://www.sinhayasocialreader.com/',
# Why: #8611 in Alexa global
'http://a963.com/',
# Why: #8612 in Alexa global
'http://www.gamgos.ae/',
# Why: #8613 in Alexa global
'http://www.fx678.com/',
# Why: #8614 in Alexa global
'http://www.mp3round.com/',
# Why: #8615 in Alexa global
'http://www.komonews.com/',
# Why: #8616 in Alexa global
'http://www.contactcars.com/',
# Why: #8617 in Alexa global
'http://www.pdftoword.com/',
# Why: #8618 in Alexa global
'http://www.songtaste.com/',
# Why: #8620 in Alexa global
'http://www.squareup.com/',
# Why: #8621 in Alexa global
'http://www.newsevent24.com/',
# Why: #8622 in Alexa global
'http://www.dti.ne.jp/',
# Why: #8623 in Alexa global
'http://www.livestation.com/',
# Why: #8624 in Alexa global
'http://www.oldertube.com/',
# Why: #8625 in Alexa global
'http://www.rtl.fr/',
# Why: #8626 in Alexa global
'http://www.gather.com/',
# Why: #8627 in Alexa global
'http://www.liderendeportes.com/',
# Why: #8628 in Alexa global
'http://www.thewrap.com/',
# Why: #8629 in Alexa global
'http://www.viber.com/',
# Why: #8630 in Alexa global
'http://www.reklama5.mk/',
# Why: #8631 in Alexa global
'http://www.fonts.com/',
# Why: #8632 in Alexa global
'http://www.hrsaccount.com/',
# Why: #8633 in Alexa global
'http://www.bizcommunity.com/',
# Why: #8634 in Alexa global
'http://www.favicon.cc/',
# Why: #8635 in Alexa global
'http://www.totalping.com/',
# Why: #8636 in Alexa global
'http://www.live365.com/',
# Why: #8637 in Alexa global
'http://www.tlife.gr/',
# Why: #8638 in Alexa global
'http://www.imasters.com.br/',
# Why: #8639 in Alexa global
'http://www.n11.com/',
# Why: #8640 in Alexa global
'http://www.iam.ma/',
# Why: #8641 in Alexa global
'http://www.qq5.com/',
# Why: #8642 in Alexa global
'http://www.tvboxnow.com/',
# Why: #8643 in Alexa global
'http://www.limetorrents.com/',
# Why: #8644 in Alexa global
'http://www.bancopopular.es/',
# Why: #8645 in Alexa global
'http://www.ray-ban.com/',
# Why: #8646 in Alexa global
'http://www.drweb.com/',
# Why: #8647 in Alexa global
'http://www.hushmail.com/',
# Why: #8648 in Alexa global
'http://www.resuelvetudeuda.com/',
# Why: #8649 in Alexa global
'http://www.sharpnews.ru/',
# Why: #8650 in Alexa global
'http://www.hellocoton.fr/',
# Why: #8651 in Alexa global
'http://buysub.com/',
# Why: #8652 in Alexa global
'http://www.homemoviestube.com/',
# Why: #8653 in Alexa global
'http://www.utsandiego.com/',
# Why: #8654 in Alexa global
'http://www.learn4good.com/',
# Why: #8655 in Alexa global
'http://www.nii.ac.jp/',
# Why: #8656 in Alexa global
'http://www.girlsgogames.ru/',
# Why: #8657 in Alexa global
'http://www.talksport.co.uk/',
# Why: #8658 in Alexa global
'http://fap.to/',
# Why: #8659 in Alexa global
'http://www.teennick.com/',
# Why: #8660 in Alexa global
'http://www.seitwert.de/',
# Why: #8661 in Alexa global
'http://www.celebritymoviearchive.com/',
# Why: #8662 in Alexa global
'http://www.sukar.com/',
# Why: #8663 in Alexa global
'http://www.astromeridian.ru/',
# Why: #8664 in Alexa global
'http://www.zen-cart.com/',
# Why: #8665 in Alexa global
'http://www.1phads.com/',
# Why: #8666 in Alexa global
'http://www.plaisio.gr/',
# Why: #8667 in Alexa global
'http://www.photozou.jp/',
# Why: #8668 in Alexa global
'http://www.cplusplus.com/',
# Why: #8669 in Alexa global
'http://www.ewebse.com/',
# Why: #8670 in Alexa global
'http://6eat.com/',
# Why: #8672 in Alexa global
'http://www.payless.com/',
# Why: #8673 in Alexa global
'http://www.subaonet.com/',
# Why: #8674 in Alexa global
'http://www.dlisted.com/',
# Why: #8675 in Alexa global
'http://www.kia.com/',
# Why: #8676 in Alexa global
'http://www.lankahotnews.net/',
# Why: #8677 in Alexa global
'http://www.vg247.com/',
# Why: #8678 in Alexa global
'http://www.formstack.com/',
# Why: #8679 in Alexa global
'http://www.jobs.net/',
# Why: #8680 in Alexa global
'http://www.coolchaser.com/',
# Why: #8681 in Alexa global
'http://www.blackplanet.com/',
# Why: #8682 in Alexa global
'http://www.unionbank.com/',
# Why: #8683 in Alexa global
'http://www.record.com.mx/',
# Why: #8684 in Alexa global
'http://www.121ware.com/',
# Why: #8685 in Alexa global
'http://www.inkfrog.com/',
# Why: #8686 in Alexa global
'http://cnstock.com/',
# Why: #8687 in Alexa global
'http://www.marineaquariumfree.com/',
# Why: #8688 in Alexa global
'http://www.encuentra24.com/',
# Why: #8689 in Alexa global
'http://www.mixturecloud.com/',
# Why: #8690 in Alexa global
'http://www.yninfo.com/',
# Why: #8691 in Alexa global
'http://www.lesnumeriques.com/',
# Why: #8692 in Alexa global
'http://www.autopartswarehouse.com/',
# Why: #8693 in Alexa global
'http://www.lijit.com/',
# Why: #8694 in Alexa global
'http://www.ti.com/',
# Why: #8695 in Alexa global
'http://www.umd.edu/',
# Why: #8696 in Alexa global
'http://www.zdnet.co.uk/',
# Why: #8697 in Alexa global
'http://www.begin-download.com/',
# Why: #8698 in Alexa global
'http://www.showsiteinfo.us/',
# Why: #8699 in Alexa global
'http://www.uchicago.edu/',
# Why: #8700 in Alexa global
'http://www.whatsmyserp.com/',
# Why: #8701 in Alexa global
'http://www.asos.fr/',
# Why: #8702 in Alexa global
'http://www.ibosocial.com/',
# Why: #8703 in Alexa global
'http://www.amorenlinea.com/',
# Why: #8704 in Alexa global
'http://www.videopremium.tv/',
# Why: #8705 in Alexa global
'http://www.trkjmp.com/',
# Why: #8706 in Alexa global
'http://www.creativecow.net/',
# Why: #8707 in Alexa global
'http://www.webartex.ru/',
# Why: #8708 in Alexa global
'http://www.olx.com.ng/',
# Why: #8709 in Alexa global
'http://www.overclockzone.com/',
# Why: #8710 in Alexa global
'http://www.rongbay.com/',
# Why: #8711 in Alexa global
'http://www.maximustube.com/',
# Why: #8712 in Alexa global
'http://www.priberam.pt/',
# Why: #8713 in Alexa global
'http://www.comsenz.com/',
# Why: #8714 in Alexa global
'http://www.prensaescrita.com/',
# Why: #8715 in Alexa global
'http://www.gameslist.com/',
# Why: #8716 in Alexa global
'http://www.lingualeo.com/',
# Why: #8717 in Alexa global
'http://www.epfoservices.in/',
# Why: #8718 in Alexa global
'http://www.webbirga.net/',
# Why: #8719 in Alexa global
'http://www.pb.com/',
# Why: #8720 in Alexa global
'http://www.fineco.it/',
# Why: #8721 in Alexa global
'http://www.highrisehq.com/',
# Why: #8722 in Alexa global
'http://www.hotgoo.com/',
# Why: #8723 in Alexa global
'http://www.netdoctor.co.uk/',
# Why: #8725 in Alexa global
'http://domain.com/',
# Why: #8726 in Alexa global
'http://www.aramex.com/',
# Why: #8727 in Alexa global
'http://www.google.co.uz/',
# Why: #8728 in Alexa global
'http://www.savings.com/',
# Why: #8729 in Alexa global
'http://www.airtelbroadband.in/',
# Why: #8730 in Alexa global
'http://www.postimees.ee/',
# Why: #8731 in Alexa global
'http://www.wallsave.com/',
# Why: #8732 in Alexa global
'http://www.df.gob.mx/',
# Why: #8733 in Alexa global
'http://www.flashgames247.com/',
# Why: #8735 in Alexa global
'http://www.libsyn.com/',
# Why: #8736 in Alexa global
'http://www.goobike.com/',
# Why: #8737 in Alexa global
'http://www.trivago.com/',
# Why: #8738 in Alexa global
'http://www.mt.co.kr/',
# Why: #8739 in Alexa global
'http://www.android-hilfe.de/',
# Why: #8740 in Alexa global
'http://www.anquan.org/',
# Why: #8741 in Alexa global
'http://www.dota2.com/',
# Why: #8742 in Alexa global
'http://www.vladtv.com/',
# Why: #8743 in Alexa global
'http://www.oovoo.com/',
# Why: #8744 in Alexa global
'http://www.mybrowsercash.com/',
# Why: #8745 in Alexa global
'http://www.stafaband.info/',
# Why: #8746 in Alexa global
'http://www.vsao.vn/',
# Why: #8747 in Alexa global
'http://www.smithsonianmag.com/',
# Why: #8748 in Alexa global
'http://www.feedblitz.com/',
# Why: #8749 in Alexa global
'http://www.kibeloco.com.br/',
# Why: #8750 in Alexa global
'http://www.burningcamel.com/',
# Why: #8751 in Alexa global
'http://www.northwestern.edu/',
# Why: #8752 in Alexa global
'http://www.tucows.com/',
# Why: #8753 in Alexa global
'http://www.porn-granny-tube.com/',
# Why: #8754 in Alexa global
'http://www.linksys.com/',
# Why: #8755 in Alexa global
'http://www.avea.com.tr/',
# Why: #8756 in Alexa global
'http://www.ams.se/',
# Why: #8757 in Alexa global
'http://www.canadanepalvid.com/',
# Why: #8758 in Alexa global
'http://www.venmobulo.com/',
# Why: #8759 in Alexa global
'http://www.levi.com/',
# Why: #8760 in Alexa global
'http://www.freshome.com/',
# Why: #8761 in Alexa global
'http://www.loja2.com.br/',
# Why: #8762 in Alexa global
'http://www.gameduell.de/',
# Why: #8763 in Alexa global
'http://www.reserveamerica.com/',
# Why: #8764 in Alexa global
'http://www.fakings.com/',
# Why: #8765 in Alexa global
'http://www.akb48newstimes.jp/',
# Why: #8766 in Alexa global
'http://www.polygon.com/',
# Why: #8767 in Alexa global
'http://www.mtwebcenters.com.tw/',
# Why: #8768 in Alexa global
'http://www.news.mn/',
# Why: #8769 in Alexa global
'http://www.addictinginfo.org/',
# Why: #8770 in Alexa global
'http://www.bonanza.com/',
# Why: #8771 in Alexa global
'http://www.adlock.in/',
# Why: #8772 in Alexa global
'http://www.apni.tv/',
# Why: #8773 in Alexa global
'http://www.3m.com/',
# Why: #8774 in Alexa global
'http://www.gendama.jp/',
# Why: #8775 in Alexa global
'http://www.usingenglish.com/',
# Why: #8776 in Alexa global
'http://www.sammsoft.com/',
# Why: #8777 in Alexa global
'http://www.pedaily.cn/',
# Why: #8778 in Alexa global
'http://www.thevault.bz/',
# Why: #8779 in Alexa global
'http://www.groupon.my/',
# Why: #8780 in Alexa global
'http://www.banamex.com/',
# Why: #8781 in Alexa global
'http://hualongxiang.com/',
# Why: #8782 in Alexa global
'http://www.bodis.com/',
# Why: #8783 in Alexa global
'http://www.dqx.jp/',
# Why: #8784 in Alexa global
'http://www.io.ua/',
# Why: #8785 in Alexa global
'http://joy.cn/',
# Why: #8786 in Alexa global
'http://www.minglebox.com/',
# Why: #8787 in Alexa global
'http://www.forumspecialoffers.com/',
# Why: #8788 in Alexa global
'http://www.remax.com/',
# Why: #8789 in Alexa global
'http://www.makaan.com/',
# Why: #8790 in Alexa global
'http://www.voglioporno.com/',
# Why: #8791 in Alexa global
'http://www.chinaluxus.com/',
# Why: #8792 in Alexa global
'http://www.parenting.com/',
# Why: #8793 in Alexa global
'http://www.superdownloads.com.br/',
# Why: #8794 in Alexa global
'http://www.aeon.co.jp/',
# Why: #8795 in Alexa global
'http://www.nettavisen.no/',
# Why: #8796 in Alexa global
'http://www.21cbh.com/',
# Why: #8797 in Alexa global
'http://www.mobilestan.net/',
# Why: #8798 in Alexa global
'http://www.cheathappens.com/',
# Why: #8799 in Alexa global
'http://www.azxeber.com/',
# Why: #8800 in Alexa global
'http://www.foodgawker.com/',
# Why: #8801 in Alexa global
'http://www.miitbeian.gov.cn/',
# Why: #8802 in Alexa global
'http://www.eb80.com/',
# Why: #8803 in Alexa global
'http://www.dudamobile.com/',
# Why: #8804 in Alexa global
'http://www.sahafah.net/',
# Why: #8805 in Alexa global
'http://www.ait-themes.com/',
# Why: #8806 in Alexa global
'http://www.house.gov/',
# Why: #8807 in Alexa global
'http://www.ffffound.com/',
# Why: #8808 in Alexa global
'http://sssc.cn/',
# Why: #8809 in Alexa global
'http://www.khanwars.ir/',
# Why: #8810 in Alexa global
'http://www.wowslider.com/',
# Why: #8811 in Alexa global
'http://www.fashionara.com/',
# Why: #8812 in Alexa global
'http://www.pornxxxhub.com/',
# Why: #8813 in Alexa global
'http://www.minhavida.com.br/',
# Why: #8814 in Alexa global
'http://www.senzapudore.it/',
# Why: #8815 in Alexa global
'http://www.extra.cz/',
# Why: #8816 in Alexa global
'http://www.cinemark.com/',
# Why: #8817 in Alexa global
'http://www.career.ru/',
# Why: #8818 in Alexa global
'http://www.realself.com/',
# Why: #8819 in Alexa global
'http://www.i4455.com/',
# Why: #8820 in Alexa global
'http://www.ntlworld.com/',
# Why: #8821 in Alexa global
'http://chinaw3.com/',
# Why: #8822 in Alexa global
'http://www.berliner-sparkasse.de/',
# Why: #8823 in Alexa global
'http://www.autoscout24.be/',
# Why: #8824 in Alexa global
'http://www.heureka.sk/',
# Why: #8825 in Alexa global
'http://tienphong.vn/',
# Why: #8826 in Alexa global
'http://www.1001freefonts.com/',
# Why: #8827 in Alexa global
'http://www.bluestacks.com/',
# Why: #8828 in Alexa global
'http://www.livesports.pl/',
# Why: #8829 in Alexa global
'http://www.bd-pratidin.com/',
# Why: #8831 in Alexa global
'http://www.es.tl/',
# Why: #8832 in Alexa global
'http://www.backcountry.com/',
# Why: #8833 in Alexa global
'http://www.fourhourworkweek.com/',
# Why: #8834 in Alexa global
'http://ebay.cn/',
# Why: #8835 in Alexa global
'http://www.pointclicktrack.com/',
# Why: #8836 in Alexa global
'http://www.joomlacode.org/',
# Why: #8837 in Alexa global
'http://www.fantage.com/',
# Why: #8838 in Alexa global
'http://www.seowizard.ru/',
# Why: #8839 in Alexa global
'http://military38.com/',
# Why: #8840 in Alexa global
'http://www.wenkang.cn/',
# Why: #8842 in Alexa global
'http://www.swedbank.lt/',
# Why: #8843 in Alexa global
'http://www.govoyages.com/',
# Why: #8844 in Alexa global
'http://www.fgov.be/',
# Why: #8845 in Alexa global
'http://www.dengeki.com/',
# Why: #8846 in Alexa global
'http://www.3773.com.cn/',
# Why: #8847 in Alexa global
'http://www.ed4.net/',
# Why: #8848 in Alexa global
'http://www.mql5.com/',
# Why: #8849 in Alexa global
'http://www.gottabemobile.com/',
# Why: #8850 in Alexa global
'http://www.kdslife.com/',
# Why: #8851 in Alexa global
'http://5yi.com/',
# Why: #8852 in Alexa global
'http://www.bforex.com/',
# Why: #8853 in Alexa global
'http://www.eurogamer.net/',
# Why: #8854 in Alexa global
'http://www.az.pl/',
# Why: #8855 in Alexa global
'http://www.partypoker.com/',
# Why: #8856 in Alexa global
'http://www.cinapalace.com/',
# Why: #8857 in Alexa global
'http://www.sbt.com.br/',
# Why: #8858 in Alexa global
'http://www.nanos.jp/',
# Why: #8859 in Alexa global
'http://www.phpcms.cn/',
# Why: #8860 in Alexa global
'http://www.weatherzone.com.au/',
# Why: #8861 in Alexa global
'http://www.cutv.com/',
# Why: #8862 in Alexa global
'http://www.sweetwater.com/',
# Why: #8863 in Alexa global
'http://www.vodacom.co.za/',
# Why: #8864 in Alexa global
'http://www.hostgator.in/',
# Why: #8865 in Alexa global
'http://www.mojim.com/',
# Why: #8866 in Alexa global
'http://www.getnews.jp/',
# Why: #8868 in Alexa global
'http://www.eklablog.com/',
# Why: #8869 in Alexa global
'http://www.divaina.com/',
# Why: #8870 in Alexa global
'http://www.acces-charme.com/',
# Why: #8871 in Alexa global
'http://www.airfrance.fr/',
# Why: #8872 in Alexa global
'http://www.widgeo.net/',
# Why: #8873 in Alexa global
'http://www.whosdatedwho.com/',
# Why: #8874 in Alexa global
'http://www.funtrivia.com/',
# Why: #8875 in Alexa global
'http://www.servis24.cz/',
# Why: #8876 in Alexa global
'http://www.emagister.com/',
# Why: #8877 in Alexa global
'http://www.torrentkitty.com/',
# Why: #8878 in Alexa global
'http://www.abc.com.py/',
# Why: #8879 in Alexa global
'http://www.farfetch.com/',
# Why: #8880 in Alexa global
'http://www.gamestar.de/',
# Why: #8881 in Alexa global
'http://www.careers24.com/',
# Why: #8882 in Alexa global
'http://www.styleblazer.com/',
# Why: #8883 in Alexa global
'http://www.ibtesama.com/',
# Why: #8884 in Alexa global
'http://ifunny.mobi/',
# Why: #8885 in Alexa global
'http://www.antpedia.com/',
# Why: #8886 in Alexa global
'http://www.fivb.org/',
# Why: #8887 in Alexa global
'http://www.littleone.ru/',
# Why: #8888 in Alexa global
'http://www.rainbowdressup.com/',
# Why: #8889 in Alexa global
'http://www.zerozero.pt/',
# Why: #8890 in Alexa global
'http://www.edreams.com/',
# Why: #8891 in Alexa global
'http://www.whoishostingthis.com/',
# Why: #8892 in Alexa global
'http://www.gucci.com/',
# Why: #8893 in Alexa global
'http://www.animeplus.tv/',
# Why: #8894 in Alexa global
'http://www.five.tv/',
# Why: #8895 in Alexa global
'http://www.vacationstogo.com/',
# Why: #8896 in Alexa global
'http://www.dikaiologitika.gr/',
# Why: #8897 in Alexa global
'http://www.mmorpg.com/',
# Why: #8898 in Alexa global
'http://www.jcwhitney.com/',
# Why: #8899 in Alexa global
'http://www.russiandatingbeauties.com/',
# Why: #8900 in Alexa global
'http://www.xrstats.com/',
# Why: #8901 in Alexa global
'http://www.gm99.com/',
# Why: #8902 in Alexa global
'http://www.megashares.com/',
# Why: #8903 in Alexa global
'http://www.oscaro.com/',
# Why: #8904 in Alexa global
'http://www.yezizhu.com/',
# Why: #8905 in Alexa global
'http://www.get2ch.net/',
# Why: #8906 in Alexa global
'http://www.cheaperthandirt.com/',
# Why: #8907 in Alexa global
'http://www.telcel.com/',
# Why: #8908 in Alexa global
'http://www.themefuse.com/',
# Why: #8909 in Alexa global
'http://www.addictivetips.com/',
# Why: #8910 in Alexa global
'http://www.designshack.net/',
# Why: #8911 in Alexa global
'http://www.eurobank.gr/',
# Why: #8912 in Alexa global
'http://www.nexon.net/',
# Why: #8913 in Alexa global
'http://www.rakuya.com.tw/',
# Why: #8914 in Alexa global
'http://www.fulltiltpoker.eu/',
# Why: #8915 in Alexa global
'http://www.pimei.com/',
# Why: #8916 in Alexa global
'http://www.photoshop.com/',
# Why: #8917 in Alexa global
'http://www.domainnamesales.com/',
# Why: #8918 in Alexa global
'http://www.sky.fm/',
# Why: #8919 in Alexa global
'http://www.yasni.de/',
# Why: #8920 in Alexa global
'http://www.travian.ru/',
# Why: #8921 in Alexa global
'http://www.stickpage.com/',
# Why: #8922 in Alexa global
'http://www.joomla-master.org/',
# Why: #8923 in Alexa global
'http://www.sarkari-naukri.in/',
# Why: #8924 in Alexa global
'http://www.iphones.ru/',
# Why: #8925 in Alexa global
'http://www.foto.ru/',
# Why: #8927 in Alexa global
'http://www.smude.edu.in/',
# Why: #8928 in Alexa global
'http://www.gothamist.com/',
# Why: #8929 in Alexa global
'http://www.teslamotors.com/',
# Why: #8930 in Alexa global
'http://www.seobudget.ru/',
# Why: #8931 in Alexa global
'http://www.tiantian.com/',
# Why: #8932 in Alexa global
'http://www.smarter.co.jp/',
# Why: #8933 in Alexa global
'http://www.videohelp.com/',
# Why: #8934 in Alexa global
'http://www.textbroker.com/',
# Why: #8935 in Alexa global
'http://www.garena.com/',
# Why: #8936 in Alexa global
'http://www.patient.co.uk/',
# Why: #8937 in Alexa global
'http://www.20minutepayday.com/',
# Why: #8938 in Alexa global
'http://www.bgames.com/',
# Why: #8939 in Alexa global
'http://www.superherohype.com/',
# Why: #8940 in Alexa global
'http://www.sephora.com.br/',
# Why: #8941 in Alexa global
'http://www.interest.me/',
# Why: #8942 in Alexa global
'http://www.inhabitat.com/',
# Why: #8943 in Alexa global
'http://www.downloads.nl/',
# Why: #8944 in Alexa global
'http://www.rusnovosti.ru/',
# Why: #8945 in Alexa global
'http://www.mr-guangdong.com/',
# Why: #8946 in Alexa global
'http://www.greyhound.com/',
# Why: #8947 in Alexa global
'http://www.qd8.com.cn/',
# Why: #8948 in Alexa global
'http://www.okpay.com/',
# Why: #8949 in Alexa global
'http://www.amateurcommunity.com/',
# Why: #8950 in Alexa global
'http://www.jeunesseglobal.com/',
# Why: #8951 in Alexa global
'http://www.nigma.ru/',
# Why: #8952 in Alexa global
'http://www.brightcove.com/',
# Why: #8953 in Alexa global
'http://www.wabei.cn/',
# Why: #8954 in Alexa global
'http://www.safesearch.net/',
# Why: #8955 in Alexa global
'http://www.teluguone.com/',
# Why: #8956 in Alexa global
'http://www.custojusto.pt/',
# Why: #8957 in Alexa global
'http://www.telebank.ru/',
# Why: #8958 in Alexa global
'http://www.kuwait.tt/',
# Why: #8959 in Alexa global
'http://www.acs.org/',
# Why: #8960 in Alexa global
'http://www.sverigesradio.se/',
# Why: #8961 in Alexa global
'http://www.mps.it/',
# Why: #8963 in Alexa global
'http://www.utanbaby.com/',
# Why: #8964 in Alexa global
'http://www.junocloud.me/',
# Why: #8965 in Alexa global
'http://www.expedia.co.in/',
# Why: #8966 in Alexa global
'http://www.rosnet.ru/',
# Why: #8967 in Alexa global
'http://www.kanoon.ir/',
# Why: #8968 in Alexa global
'http://www.website.ws/',
# Why: #8969 in Alexa global
'http://www.bagittoday.com/',
# Why: #8970 in Alexa global
'http://www.gooya.com/',
# Why: #8971 in Alexa global
'http://www.travelchannel.com/',
# Why: #8972 in Alexa global
'http://www.chooseauto.com.cn/',
# Why: #8973 in Alexa global
'http://www.flix247.com/',
# Why: #8974 in Alexa global
'http://www.momsbangteens.com/',
# Why: #8975 in Alexa global
'http://www.photofacefun.com/',
# Why: #8976 in Alexa global
'http://www.vistaprint.fr/',
# Why: #8977 in Alexa global
'http://www.vidbux.com/',
# Why: #8978 in Alexa global
'http://www.edu.ro/',
# Why: #8979 in Alexa global
'http://www.hd-xvideos.com/',
# Why: #8980 in Alexa global
'http://www.woodworking4home.com/',
# Why: #8981 in Alexa global
'http://www.reformal.ru/',
# Why: #8982 in Alexa global
'http://www.morodora.com/',
# Why: #8983 in Alexa global
'http://www.gelbooru.com/',
# Why: #8984 in Alexa global
'http://www.porntalk.com/',
# Why: #8985 in Alexa global
'http://www.assurland.com/',
# Why: #8986 in Alexa global
'http://www.amalgama-lab.com/',
# Why: #8987 in Alexa global
'http://www.showtime.jp/',
# Why: #8988 in Alexa global
'http://www.9to5mac.com/',
# Why: #8989 in Alexa global
'http://www.linux.org.ru/',
# Why: #8990 in Alexa global
'http://www.dolartoday.com/',
# Why: #8991 in Alexa global
'http://www.theme-junkie.com/',
# Why: #8992 in Alexa global
'http://www.seolib.ru/',
# Why: #8993 in Alexa global
'http://www.unesco.org/',
# Why: #8994 in Alexa global
'http://www.porncontrol.com/',
# Why: #8995 in Alexa global
'http://www.topdocumentaryfilms.com/',
# Why: #8996 in Alexa global
'http://www.tvmovie.de/',
# Why: #8997 in Alexa global
'http://adsl.free.fr/',
# Why: #8998 in Alexa global
'http://www.sprinthost.ru/',
# Why: #8999 in Alexa global
'http://www.reason.com/',
# Why: #9000 in Alexa global
'http://www.morazzia.com/',
# Why: #9001 in Alexa global
'http://www.yellowmoxie.com/',
# Why: #9002 in Alexa global
'http://www.banggood.com/',
# Why: #9003 in Alexa global
'http://www.pex.jp/',
# Why: #9004 in Alexa global
'http://www.espn.com.br/',
# Why: #9005 in Alexa global
'http://www.memedad.com/',
# Why: #9006 in Alexa global
'http://www.lovebuddyhookup.com/',
# Why: #9007 in Alexa global
'http://www.scmp.com/',
# Why: #9008 in Alexa global
'http://www.kjendis.no/',
# Why: #9010 in Alexa global
'http://www.metro-cc.ru/',
# Why: #9011 in Alexa global
'http://www.disdus.com/',
# Why: #9012 in Alexa global
'http://www.nola.com/',
# Why: #9013 in Alexa global
'http://www.tubesplash.com/',
# Why: #9014 in Alexa global
'http://crx7601.com/',
# Why: #9015 in Alexa global
'http://www.iana.org/',
# Why: #9016 in Alexa global
'http://www.howrse.com/',
# Why: #9017 in Alexa global
'http://www.anime-sharing.com/',
# Why: #9018 in Alexa global
'http://www.geny.com/',
# Why: #9019 in Alexa global
'http://www.carrefour.es/',
# Why: #9020 in Alexa global
'http://www.kemalistgazete.net/',
# Why: #9021 in Alexa global
'http://www.freedirectory-list.com/',
# Why: #9022 in Alexa global
'http://www.girlgamey.com/',
# Why: #9023 in Alexa global
'http://www.blogbus.com/',
# Why: #9024 in Alexa global
'http://www.funlolx.com/',
# Why: #9025 in Alexa global
'http://www.zyue.com/',
# Why: #9026 in Alexa global
'http://www.freepeople.com/',
# Why: #9027 in Alexa global
'http://www.tgareed.com/',
# Why: #9028 in Alexa global
'http://www.lifestreetmedia.com/',
# Why: #9029 in Alexa global
'http://www.fybersearch.com/',
# Why: #9030 in Alexa global
'http://www.livefreefun.org/',
# Why: #9031 in Alexa global
'http://www.cairodar.com/',
# Why: #9032 in Alexa global
'http://www.suite101.com/',
# Why: #9033 in Alexa global
'http://www.elcinema.com/',
# Why: #9034 in Alexa global
'http://leiting001.com/',
# Why: #9035 in Alexa global
'http://www.ifttt.com/',
# Why: #9036 in Alexa global
'http://www.google.com.mm/',
# Why: #9037 in Alexa global
'http://www.gizbot.com/',
# Why: #9038 in Alexa global
'http://www.games2win.com/',
# Why: #9040 in Alexa global
'http://www.stiforp.com/',
# Why: #9041 in Alexa global
'http://www.nrc.nl/',
# Why: #9042 in Alexa global
'http://www.slashgear.com/',
# Why: #9043 in Alexa global
'http://www.girlsgames123.com/',
# Why: #9044 in Alexa global
'http://www.mmajunkie.com/',
# Why: #9045 in Alexa global
'http://www.cadenaser.com/',
# Why: #9046 in Alexa global
'http://www.frombar.com/',
# Why: #9047 in Alexa global
'http://www.katmirror.com/',
# Why: #9048 in Alexa global
'http://www.cnsnews.com/',
# Why: #9049 in Alexa global
'http://www.duolingo.com/',
# Why: #9050 in Alexa global
'http://www.afterbuy.de/',
# Why: #9051 in Alexa global
'http://www.jpc.com/',
# Why: #9052 in Alexa global
'http://www.publix.com/',
# Why: #9053 in Alexa global
'http://www.ehealthforum.com/',
# Why: #9054 in Alexa global
'http://www.budget.com/',
# Why: #9055 in Alexa global
'http://www.ipma.pt/',
# Why: #9056 in Alexa global
'http://www.meetladies.me/',
# Why: #9057 in Alexa global
'http://www.adroll.com/',
# Why: #9058 in Alexa global
'http://www.renxo.com/',
# Why: #9059 in Alexa global
'http://www.empireonline.com/',
# Why: #9060 in Alexa global
'http://www.modareb.com/',
# Why: #9061 in Alexa global
'http://www.gamedesign.jp/',
# Why: #9062 in Alexa global
'http://www.topmoviesdirect.com/',
# Why: #9063 in Alexa global
'http://www.mforos.com/',
# Why: #9064 in Alexa global
'http://www.pubarticles.com/',
# Why: #9065 in Alexa global
'http://www.primeshare.tv/',
# Why: #9066 in Alexa global
'http://www.flycell.com.tr/',
# Why: #9067 in Alexa global
'http://www.rapidvidz.com/',
# Why: #9068 in Alexa global
'http://www.kouclo.com/',
# Why: #9069 in Alexa global
'http://www.photography-on-the.net/',
# Why: #9070 in Alexa global
'http://www.tsn.ua/',
# Why: #9071 in Alexa global
'http://www.dreamamateurs.com/',
# Why: #9072 in Alexa global
'http://www.avenues.info/',
# Why: #9073 in Alexa global
'http://www.coolmath.com/',
# Why: #9074 in Alexa global
'http://www.pegast.ru/',
# Why: #9075 in Alexa global
'http://www.myplayyard.com/',
# Why: #9076 in Alexa global
'http://www.myscore.ru/',
# Why: #9077 in Alexa global
'http://www.theync.com/',
# Why: #9078 in Alexa global
'http://www.ducktoursoftampabay.com/',
# Why: #9079 in Alexa global
'http://www.marunadanmalayali.com/',
# Why: #9080 in Alexa global
'http://www.tribune.com.ng/',
# Why: #9081 in Alexa global
'http://www.83suncity.com/',
# Why: #9082 in Alexa global
'http://www.nissanusa.com/',
# Why: #9083 in Alexa global
'http://www.radio.de/',
# Why: #9084 in Alexa global
'http://www.diapers.com/',
# Why: #9086 in Alexa global
'http://myherbalife.com/',
# Why: #9087 in Alexa global
'http://www.flibusta.net/',
# Why: #9088 in Alexa global
'http://www.daft.ie/',
# Why: #9089 in Alexa global
'http://www.buycheapr.com/',
# Why: #9090 in Alexa global
'http://www.sportmaster.ru/',
# Why: #9091 in Alexa global
'http://www.wordhippo.com/',
# Why: #9092 in Alexa global
'http://www.gva.es/',
# Why: #9093 in Alexa global
'http://www.sport24.co.za/',
# Why: #9094 in Alexa global
'http://www.putariabrasileira.com/',
# Why: #9095 in Alexa global
'http://www.suddenlink.net/',
# Why: #9096 in Alexa global
'http://www.bangbrosnetwork.com/',
# Why: #9097 in Alexa global
'http://www.creaders.net/',
# Why: #9098 in Alexa global
'http://www.dailysteals.com/',
# Why: #9099 in Alexa global
'http://www.karakartal.com/',
# Why: #9100 in Alexa global
'http://www.tv-series.me/',
# Why: #9101 in Alexa global
'http://www.bongdaplus.vn/',
# Why: #9102 in Alexa global
'http://www.one.co.il/',
# Why: #9103 in Alexa global
'http://www.giga.de/',
# Why: #9104 in Alexa global
'http://www.contactmusic.com/',
# Why: #9105 in Alexa global
'http://www.informationweek.com/',
# Why: #9106 in Alexa global
'http://www.iqbank.ru/',
# Why: #9107 in Alexa global
'http://www.duapp.com/',
# Why: #9108 in Alexa global
'http://www.cgd.pt/',
# Why: #9109 in Alexa global
'http://www.yepporn.com/',
# Why: #9110 in Alexa global
'http://www.sharekhan.com/',
# Why: #9111 in Alexa global
'http://www.365online.com/',
# Why: #9112 in Alexa global
'http://www.thedailymeal.com/',
# Why: #9113 in Alexa global
'http://www.ag.ru/',
# Why: #9114 in Alexa global
'http://www.claro.com.ar/',
# Why: #9115 in Alexa global
'http://www.mediaworld.it/',
# Why: #9116 in Alexa global
'http://www.bestgore.com/',
# Why: #9117 in Alexa global
'http://www.mohajerist.com/',
# Why: #9118 in Alexa global
'http://www.passion-hd.com/',
# Why: #9119 in Alexa global
'http://www.smallbiztrends.com/',
# Why: #9120 in Alexa global
'http://www.vitals.com/',
# Why: #9121 in Alexa global
'http://www.rocketlawyer.com/',
# Why: #9122 in Alexa global
'http://www.vr-zone.com/',
# Why: #9123 in Alexa global
'http://www.doridro.com/',
# Why: #9124 in Alexa global
'http://www.expedia.it/',
# Why: #9125 in Alexa global
'http://www.aflam4you.tv/',
# Why: #9126 in Alexa global
'http://www.wisconsin.gov/',
# Why: #9127 in Alexa global
'http://www.chinavasion.com/',
# Why: #9128 in Alexa global
'http://www.bigpara.com/',
# Why: #9129 in Alexa global
'http://www.hightrafficacademy.com/',
# Why: #9130 in Alexa global
'http://www.novaposhta.ua/',
# Why: #9131 in Alexa global
'http://www.pearl.de/',
# Why: #9133 in Alexa global
'http://www.boobpedia.com/',
# Why: #9134 in Alexa global
'http://www.mycmapp.com/',
# Why: #9135 in Alexa global
'http://www.89.com/',
# Why: #9136 in Alexa global
'http://www.foxsportsla.com/',
# Why: #9137 in Alexa global
'http://www.annauniv.edu/',
# Why: #9138 in Alexa global
'http://www.tri.co.id/',
# Why: #9139 in Alexa global
'http://www.browsershots.org/',
# Why: #9140 in Alexa global
'http://www.newindianexpress.com/',
# Why: #9141 in Alexa global
'http://www.washingtonexaminer.com/',
# Why: #9142 in Alexa global
'http://www.mozillazine.org/',
# Why: #9143 in Alexa global
'http://www.mg.co.za/',
# Why: #9144 in Alexa global
'http://www.newalbumreleases.net/',
# Why: #9145 in Alexa global
'http://www.trombi.com/',
# Why: #9146 in Alexa global
'http://www.pimsleurapproach.com/',
# Why: #9147 in Alexa global
'http://www.decathlon.es/',
# Why: #9149 in Alexa global
'http://www.shopmania.ro/',
# Why: #9150 in Alexa global
'http://www.brokenlinkcheck.com/',
# Why: #9151 in Alexa global
'http://www.forumeiros.com/',
# Why: #9152 in Alexa global
'http://www.moreniche.com/',
# Why: #9153 in Alexa global
'http://www.falabella.com/',
# Why: #9154 in Alexa global
'http://www.turner.com/',
# Why: #9155 in Alexa global
'http://vogue.com.cn/',
# Why: #9156 in Alexa global
'http://www.reachlocal.net/',
# Why: #9157 in Alexa global
'http://www.upsc.gov.in/',
# Why: #9158 in Alexa global
'http://www.allday2.com/',
# Why: #9159 in Alexa global
'http://www.dtiserv.com/',
# Why: #9160 in Alexa global
'http://www.singaporeair.com/',
# Why: #9161 in Alexa global
'http://www.patoghu.com/',
# Why: #9162 in Alexa global
'http://www.intercambiosvirtuales.org/',
# Why: #9163 in Alexa global
'http://www.bored.com/',
# Why: #9164 in Alexa global
'http://www.nn.ru/',
# Why: #9165 in Alexa global
'http://www.24smi.org/',
# Why: #9166 in Alexa global
'http://www.mobile-review.com/',
# Why: #9167 in Alexa global
'http://www.rbs.co.uk/',
# Why: #9168 in Alexa global
'http://www.westeros.org/',
# Why: #9169 in Alexa global
'http://www.dragonfable.com/',
# Why: #9170 in Alexa global
'http://www.wg-gesucht.de/',
# Why: #9171 in Alexa global
'http://www.ebaypartnernetwork.com/',
# Why: #9172 in Alexa global
'http://www.smartsheet.com/',
# Why: #9173 in Alexa global
'http://www.askul.co.jp/',
# Why: #9174 in Alexa global
'http://www.filmai.in/',
# Why: #9175 in Alexa global
'http://www.iranianuk.com/',
# Why: #9176 in Alexa global
'http://www.zhulang.com/',
# Why: #9177 in Alexa global
'http://www.game-game.com.ua/',
# Why: #9178 in Alexa global
'http://www.jigzone.com/',
# Why: #9179 in Alexa global
'http://www.vidbull.com/',
# Why: #9180 in Alexa global
'http://www.trustpilot.com/',
# Why: #9181 in Alexa global
'http://www.baodatviet.vn/',
# Why: #9182 in Alexa global
'http://www.haaretz.com/',
# Why: #9183 in Alexa global
'http://careerbuilder.co.in/',
# Why: #9184 in Alexa global
'http://www.veikkaus.fi/',
# Why: #9185 in Alexa global
'http://www.bmw.com.cn/',
# Why: #9186 in Alexa global
'http://www.potterybarnkids.com/',
# Why: #9187 in Alexa global
'http://www.freegamelot.com/',
# Why: #9188 in Alexa global
'http://www.worldtimeserver.com/',
# Why: #9189 in Alexa global
'http://www.jigsy.com/',
# Why: #9190 in Alexa global
'http://www.widgetbox.com/',
# Why: #9191 in Alexa global
'http://www.lasexta.com/',
# Why: #9192 in Alexa global
'http://www.mediav.com/',
# Why: #9193 in Alexa global
'http://www.aintitcool.com/',
# Why: #9194 in Alexa global
'http://www.youwillfind.info/',
# Why: #9195 in Alexa global
'http://www.bharatmatrimony.com/',
# Why: #9196 in Alexa global
'http://www.translated.net/',
# Why: #9197 in Alexa global
'http://www.virginia.edu/',
# Why: #9198 in Alexa global
'http://www.5566.net/',
# Why: #9199 in Alexa global
'http://www.questionmarket.com/',
# Why: #9200 in Alexa global
'http://www.587766.com/',
# Why: #9201 in Alexa global
'http://newspickup.com/',
# Why: #9202 in Alexa global
'http://www.womansday.com/',
# Why: #9203 in Alexa global
'http://www.segodnya.ua/',
# Why: #9204 in Alexa global
'http://www.reagancoalition.com/',
# Why: #9206 in Alexa global
'http://www.trafficswarm.com/',
# Why: #9207 in Alexa global
'http://www.orbitdownloader.com/',
# Why: #9208 in Alexa global
'http://www.filmehd.net/',
# Why: #9209 in Alexa global
'http://www.porn-star.com/',
# Why: #9210 in Alexa global
'http://www.lawyers.com/',
# Why: #9211 in Alexa global
'http://www.life.hu/',
# Why: #9212 in Alexa global
'http://www.listenonrepeat.com/',
# Why: #9213 in Alexa global
'http://www.phpfox.com/',
# Why: #9214 in Alexa global
'http://www.campusexplorer.com/',
# Why: #9215 in Alexa global
'http://www.eprothomalo.com/',
# Why: #9216 in Alexa global
'http://www.linekong.com/',
# Why: #9217 in Alexa global
'http://www.blogjava.net/',
# Why: #9218 in Alexa global
'http://www.qzone.cc/',
# Why: #9219 in Alexa global
'http://www.gamespassport.com/',
# Why: #9220 in Alexa global
'http://www.bet365.es/',
# Why: #9221 in Alexa global
'http://www.bikeradar.com/',
# Why: #9222 in Alexa global
'http://www.allmonitors.net/',
# Why: #9223 in Alexa global
'http://xwh.cn/',
# Why: #9224 in Alexa global
'http://www.naijaloaded.com/',
# Why: #9225 in Alexa global
'http://www.chazidian.com/',
# Why: #9226 in Alexa global
'http://www.channeladvisor.com/',
# Why: #9227 in Alexa global
'http://www.arenabg.com/',
# Why: #9228 in Alexa global
'http://www.briian.com/',
# Why: #9230 in Alexa global
'http://www.cucirca.eu/',
# Why: #9231 in Alexa global
'http://www.mamsy.ru/',
# Why: #9232 in Alexa global
'http://www.dl4all.com/',
# Why: #9233 in Alexa global
'http://www.wethreegreens.com/',
# Why: #9234 in Alexa global
'http://www.hsbc.co.in/',
# Why: #9235 in Alexa global
'http://www.squirt.org/',
# Why: #9236 in Alexa global
'http://www.sisal.it/',
# Why: #9237 in Alexa global
'http://www.bonprix.ru/',
# Why: #9238 in Alexa global
'http://www.odn.ne.jp/',
# Why: #9239 in Alexa global
'http://www.awd.ru/',
# Why: #9240 in Alexa global
'http://www.a-q-f.com/',
# Why: #9241 in Alexa global
'http://www.4game.com/',
# Why: #9242 in Alexa global
'http://www.24timezones.com/',
# Why: #9243 in Alexa global
'http://www.fgv.br/',
# Why: #9244 in Alexa global
'http://www.topnews.in/',
# Why: #9245 in Alexa global
'http://www.roku.com/',
# Why: #9246 in Alexa global
'http://www.ulub.pl/',
# Why: #9247 in Alexa global
'http://www.launchpad.net/',
# Why: #9248 in Alexa global
'http://www.simplyhired.co.in/',
# Why: #9249 in Alexa global
'http://www.response.jp/',
# Why: #9250 in Alexa global
'http://click.ro/',
# Why: #9251 in Alexa global
'http://www.thisis50.com/',
# Why: #9252 in Alexa global
'http://www.horoscopofree.com/',
# Why: #9253 in Alexa global
'http://www.comoeumesintoquando.tumblr.com/',
# Why: #9254 in Alexa global
'http://www.dlvr.it/',
# Why: #9255 in Alexa global
'http://www.4umf.com/',
# Why: #9256 in Alexa global
'http://www.picresize.com/',
# Why: #9257 in Alexa global
'http://www.aleqt.com/',
# Why: #9258 in Alexa global
'http://www.correos.es/',
# Why: #9259 in Alexa global
'http://www.pog.com/',
# Why: #9260 in Alexa global
'http://www.dlsoftware.org/',
# Why: #9261 in Alexa global
'http://www.primekhobor.com/',
# Why: #9262 in Alexa global
'http://www.dicionarioinformal.com.br/',
# Why: #9263 in Alexa global
'http://www.flixxy.com/',
# Why: #9264 in Alexa global
'http://www.hotklix.com/',
# Why: #9265 in Alexa global
'http://www.mglclub.com/',
# Why: #9266 in Alexa global
'http://www.airdroid.com/',
# Why: #9267 in Alexa global
'http://www.9281.net/',
# Why: #9268 in Alexa global
'http://faxingw.cn/',
# Why: #9269 in Alexa global
'http://www.satu.kz/',
# Why: #9270 in Alexa global
'http://www.carambatv.ru/',
# Why: #9271 in Alexa global
'http://www.autonews.ru/',
# Why: #9272 in Alexa global
'http://www.playerinstaller.com/',
# Why: #9273 in Alexa global
'http://www.swedbank.lv/',
# Why: #9274 in Alexa global
'http://www.enladisco.com/',
# Why: #9275 in Alexa global
'http://www.lib.ru/',
# Why: #9276 in Alexa global
'http://www.revolveclothing.com/',
# Why: #9277 in Alexa global
'http://www.aftermarket.pl/',
# Why: #9278 in Alexa global
'http://www.copy.com/',
# Why: #9279 in Alexa global
'http://www.muchgames.com/',
# Why: #9280 in Alexa global
'http://www.brigitte.de/',
# Why: #9281 in Alexa global
'http://www.ticketmaster.co.uk/',
# Why: #9282 in Alexa global
'http://www.cultofmac.com/',
# Why: #9283 in Alexa global
'http://www.bankontraffic.com/',
# Why: #9284 in Alexa global
'http://www.cnnamador.com/',
# Why: #9285 in Alexa global
'http://www.dwayir.com/',
# Why: #9286 in Alexa global
'http://www.davidicke.com/',
# Why: #9287 in Alexa global
'http://www.autosport.com/',
# Why: #9288 in Alexa global
'http://www.file.org/',
# Why: #9289 in Alexa global
'http://www.subtlepatterns.com/',
# Why: #9290 in Alexa global
'http://www.playmillion.com/',
# Why: #9291 in Alexa global
'http://www.gexing.com/',
# Why: #9292 in Alexa global
'http://www.thinkphp.cn/',
# Why: #9293 in Alexa global
'http://www.zum.com/',
# Why: #9294 in Alexa global
'http://www.eskimotube.com/',
# Why: #9295 in Alexa global
'http://www.guenstiger.de/',
# Why: #9296 in Alexa global
'http://www.diesiedleronline.de/',
# Why: #9297 in Alexa global
'http://www.nelly.com/',
# Why: #9298 in Alexa global
'http://www.press24.mk/',
# Why: #9299 in Alexa global
'http://www.psdgraphics.com/',
# Why: #9300 in Alexa global
'http://www.makeupalley.com/',
# Why: #9301 in Alexa global
'http://www.cloudify.cc/',
# Why: #9302 in Alexa global
'http://www.3a6aayer.com/',
# Why: #9303 in Alexa global
'http://www.apspsc.gov.in/',
# Why: #9304 in Alexa global
'http://www.dxy.cn/',
# Why: #9305 in Alexa global
'http://www.hotnews25.com/',
# Why: #9306 in Alexa global
'http://www.symbaloo.com/',
# Why: #9307 in Alexa global
'http://www.hiroimono.org/',
# Why: #9308 in Alexa global
'http://www.enbac.com/',
# Why: #9309 in Alexa global
'http://www.pornravage.com/',
# Why: #9310 in Alexa global
'http://abcfamily.go.com/',
# Why: #9311 in Alexa global
'http://www.fewo-direkt.de/',
# Why: #9312 in Alexa global
'http://www.elog-ch.net/',
# Why: #9313 in Alexa global
'http://www.n24.de/',
# Why: #9314 in Alexa global
'http://www.englishclub.com/',
# Why: #9315 in Alexa global
'http://www.ibicn.com/',
# Why: #9316 in Alexa global
'http://www.anibis.ch/',
# Why: #9317 in Alexa global
'http://www.tehran.ir/',
# Why: #9318 in Alexa global
'http://www.streamsex.com/',
# Why: #9319 in Alexa global
'http://www.drjays.com/',
# Why: #9320 in Alexa global
'http://www.islamqa.info/',
# Why: #9321 in Alexa global
'http://www.techandgaming247.com/',
# Why: #9322 in Alexa global
'http://www.apunkachoice.com/',
# Why: #9323 in Alexa global
'http://16888.com/',
# Why: #9324 in Alexa global
'http://www.morguefile.com/',
# Why: #9325 in Alexa global
'http://www.dalealplay.com/',
# Why: #9326 in Alexa global
'http://www.spinrewriter.com/',
# Why: #9327 in Alexa global
'http://www.newsmaxhealth.com/',
# Why: #9328 in Alexa global
'http://www.myvi.ru/',
# Why: #9329 in Alexa global
'http://www.moneysavingmom.com/',
# Why: #9331 in Alexa global
'http://www.jeux-fille-gratuit.com/',
# Why: #9332 in Alexa global
'http://www.swiki.jp/',
# Why: #9333 in Alexa global
'http://nowec.com/',
# Why: #9334 in Alexa global
'http://www.opn.com/',
# Why: #9335 in Alexa global
'http://www.idiva.com/',
# Why: #9336 in Alexa global
'http://www.bnc.ca/',
# Why: #9337 in Alexa global
'http://www.eater.com/',
# Why: #9338 in Alexa global
'http://www.designcrowd.com/',
# Why: #9339 in Alexa global
'http://www.jkforum.net/',
# Why: #9340 in Alexa global
'http://www.netkeiba.com/',
# Why: #9341 in Alexa global
'http://www.practicalecommerce.com/',
# Why: #9342 in Alexa global
'http://www.genuineptr.com/',
# Why: #9343 in Alexa global
'http://www.bloog.pl/',
# Why: #9344 in Alexa global
'http://www.ladunliadi.blogspot.com/',
# Why: #9345 in Alexa global
'http://www.stclick.ir/',
# Why: #9346 in Alexa global
'http://www.anwb.nl/',
# Why: #9347 in Alexa global
'http://www.mkyong.com/',
# Why: #9348 in Alexa global
'http://www.lavoixdunord.fr/',
# Why: #9349 in Alexa global
'http://www.top-inspector.ru/',
# Why: #9350 in Alexa global
'http://www.pornicom.com/',
# Why: #9351 in Alexa global
'http://www.yithemes.com/',
# Why: #9352 in Alexa global
'http://www.canada411.ca/',
# Why: #9353 in Alexa global
'http://www.mos.ru/',
# Why: #9354 in Alexa global
'http://www.somuch.com/',
# Why: #9355 in Alexa global
'http://www.nen.com.cn/',
# Why: #9356 in Alexa global
'http://www.runtastic.com/',
# Why: #9357 in Alexa global
'http://www.cadoinpiedi.it/',
# Why: #9358 in Alexa global
'http://www.google.co.bw/',
# Why: #9359 in Alexa global
'http://www.shkolazhizni.ru/',
# Why: #9360 in Alexa global
'http://www.heroku.com/',
# Why: #9361 in Alexa global
'http://www.net114.com/',
# Why: #9362 in Alexa global
'http://www.proprofs.com/',
# Why: #9363 in Alexa global
'http://www.banathi.com/',
# Why: #9364 in Alexa global
'http://www.bunte.de/',
# Why: #9365 in Alexa global
'http://pso2.jp/',
# Why: #9366 in Alexa global
'http://www.ncsecu.org/',
# Why: #9367 in Alexa global
'http://www.globalpost.com/',
# Why: #9368 in Alexa global
'http://www.comscore.com/',
# Why: #9370 in Alexa global
'http://www.wrapbootstrap.com/',
# Why: #9371 in Alexa global
'http://www.directupload.net/',
# Why: #9372 in Alexa global
'http://www.gpotato.eu/',
# Why: #9373 in Alexa global
'http://vipsister23.com/',
# Why: #9374 in Alexa global
'http://www.shopatron.com/',
# Why: #9375 in Alexa global
'http://www.aeroflot.ru/',
# Why: #9376 in Alexa global
'http://www.asiandatingbeauties.com/',
# Why: #9377 in Alexa global
'http://www.egooad.com/',
# Why: #9378 in Alexa global
'http://www.annunci69.it/',
# Why: #9379 in Alexa global
'http://www.yext.com/',
# Why: #9380 in Alexa global
'http://www.gruenderszene.de/',
# Why: #9382 in Alexa global
'http://www.veengle.com/',
# Why: #9383 in Alexa global
'http://www.reelzhot.com/',
# Why: #9384 in Alexa global
'http://www.enstage.com/',
# Why: #9385 in Alexa global
'http://www.icnetwork.co.uk/',
# Why: #9386 in Alexa global
'http://www.scarlet-clicks.info/',
# Why: #9388 in Alexa global
'http://www.brands4friends.de/',
# Why: #9389 in Alexa global
'http://www.watchersweb.com/',
# Why: #9390 in Alexa global
'http://www.music-clips.net/',
# Why: #9391 in Alexa global
'http://www.pornyeah.com/',
# Why: #9392 in Alexa global
'http://www.thehollywoodgossip.com/',
# Why: #9393 in Alexa global
'http://www.e5.ru/',
# Why: #9394 in Alexa global
'http://www.boldchat.com/',
# Why: #9395 in Alexa global
'http://www.maskolis.com/',
# Why: #9396 in Alexa global
'http://www.ba-k.com/',
# Why: #9397 in Alexa global
'http://www.monoprice.com/',
# Why: #9398 in Alexa global
'http://www.lacoste.com/',
# Why: #9399 in Alexa global
'http://www.byu.edu/',
# Why: #9400 in Alexa global
'http://www.zqgame.com/',
# Why: #9401 in Alexa global
'http://www.mofosex.com/',
# Why: #9402 in Alexa global
'http://www.roboxchange.com/',
# Why: #9403 in Alexa global
'http://www.elnuevoherald.com/',
# Why: #9404 in Alexa global
'http://www.joblo.com/',
# Why: #9405 in Alexa global
'http://www.songtexte.com/',
# Why: #9406 in Alexa global
'http://www.goodsearch.com/',
# Why: #9407 in Alexa global
'http://www.dnevnik.bg/',
# Why: #9408 in Alexa global
'http://www.tv.nu/',
# Why: #9409 in Alexa global
'http://www.movies.com/',
# Why: #9410 in Alexa global
'http://www.ganeshaspeaks.com/',
# Why: #9411 in Alexa global
'http://www.vonage.com/',
# Why: #9412 in Alexa global
'http://www.dawhois.com/',
# Why: #9413 in Alexa global
'http://www.companieshouse.gov.uk/',
# Why: #9414 in Alexa global
'http://www.ofertix.com/',
# Why: #9415 in Alexa global
'http://www.amaderforum.com/',
# Why: #9416 in Alexa global
'http://www.directorycritic.com/',
# Why: #9417 in Alexa global
'http://www.quickfilmz.com/',
# Why: #9418 in Alexa global
'http://www.youpornos.info/',
# Why: #9419 in Alexa global
'http://www.animeultima.tv/',
# Why: #9420 in Alexa global
'http://www.php.su/',
# Why: #9421 in Alexa global
'http://www.inciswf.com/',
# Why: #9422 in Alexa global
'http://www.bayern.de/',
# Why: #9423 in Alexa global
'http://www.hotarabchat.com/',
# Why: #9424 in Alexa global
'http://www.goodlayers.com/',
# Why: #9425 in Alexa global
'http://www.billiger.de/',
# Why: #9426 in Alexa global
'http://www.ponparemall.com/',
# Why: #9427 in Alexa global
'http://www.portaltvto.com/',
# Why: #9428 in Alexa global
'http://www.filesend.to/',
# Why: #9429 in Alexa global
'http://www.isimtescil.net/',
# Why: #9430 in Alexa global
'http://www.animeid.tv/',
# Why: #9431 in Alexa global
'http://www.trivago.es/',
# Why: #9433 in Alexa global
'http://www.17u.net/',
# Why: #9434 in Alexa global
'http://www.enekas.info/',
# Why: #9435 in Alexa global
'http://www.trendsonline.mobi/',
# Why: #9436 in Alexa global
'http://www.hostinger.ru/',
# Why: #9437 in Alexa global
'http://www.navad.net/',
# Why: #9438 in Alexa global
'http://www.mysupermarket.co.uk/',
# Why: #9440 in Alexa global
'http://www.webkinz.com/',
# Why: #9441 in Alexa global
'http://askfrank.net/',
# Why: #9442 in Alexa global
'http://www.pokernews.com/',
# Why: #9443 in Alexa global
'http://www.lyricsmania.com/',
# Why: #9444 in Alexa global
'http://www.chronicle.com/',
# Why: #9446 in Alexa global
'http://www.ns.nl/',
# Why: #9447 in Alexa global
'http://www.gaopeng.com/',
# Why: #9449 in Alexa global
'http://www.lifehacker.jp/',
# Why: #9450 in Alexa global
'http://www.96down.com/',
# Why: #9451 in Alexa global
'http://www.2500sz.com/',
# Why: #9453 in Alexa global
'http://www.paginasamarillas.com/',
# Why: #9454 in Alexa global
'http://www.kproxy.com/',
# Why: #9455 in Alexa global
'http://www.irantvto.ir/',
# Why: #9456 in Alexa global
'http://www.stuffgate.com/',
# Why: #9457 in Alexa global
'http://www.exler.ru/',
# Why: #9458 in Alexa global
'http://www.disney.es/',
# Why: #9459 in Alexa global
'http://www.turbocashsurfin.com/',
# Why: #9460 in Alexa global
'http://www.xmbs.jp/',
# Why: #9461 in Alexa global
'http://www.steadyhealth.com/',
# Why: #9462 in Alexa global
'http://www.thebotnet.com/',
# Why: #9463 in Alexa global
'http://www.newscientist.com/',
# Why: #9464 in Alexa global
'http://www.ampnetzwerk.de/',
# Why: #9465 in Alexa global
'http://www.htcmania.com/',
# Why: #9466 in Alexa global
'http://www.proceso.com.mx/',
# Why: #9468 in Alexa global
'http://www.teenport.com/',
# Why: #9469 in Alexa global
'http://www.tfilm.tv/',
# Why: #9470 in Alexa global
'http://www.trck.me/',
# Why: #9471 in Alexa global
'http://www.lifestartsat21.com/',
# Why: #9472 in Alexa global
'http://www.9show.com/',
# Why: #9473 in Alexa global
'http://www.expert.ru/',
# Why: #9474 in Alexa global
'http://www.mangalam.com/',
# Why: #9475 in Alexa global
'http://beyebe.com/',
# Why: #9476 in Alexa global
'http://www.ctrls.in/',
# Why: #9477 in Alexa global
'http://www.despegar.com.mx/',
# Why: #9478 in Alexa global
'http://www.bazingamob.com/',
# Why: #9479 in Alexa global
'http://www.netmagazine.com/',
# Why: #9480 in Alexa global
'http://www.sportssnip.com/',
# Why: #9481 in Alexa global
'http://www.lik.cl/',
# Why: #9483 in Alexa global
'http://www.targobank.de/',
# Why: #9484 in Alexa global
'http://www.hamsterporn.tv/',
# Why: #9485 in Alexa global
'http://www.lastfm.ru/',
# Why: #9486 in Alexa global
'http://www.wallinside.com/',
# Why: #9487 in Alexa global
'http://www.alawar.ru/',
# Why: #9488 in Alexa global
'http://www.ogame.org/',
# Why: #9489 in Alexa global
'http://www.guardiannews.com/',
# Why: #9490 in Alexa global
'http://www.intensedebate.com/',
# Why: #9491 in Alexa global
'http://www.citrix.com/',
# Why: #9492 in Alexa global
'http://www.ppt.cc/',
# Why: #9493 in Alexa global
'http://www.kavanga.ru/',
# Why: #9494 in Alexa global
'http://www.wotif.com/',
# Why: #9495 in Alexa global
'http://www.terapeak.com/',
# Why: #9496 in Alexa global
'http://www.swalif.com/',
# Why: #9497 in Alexa global
'http://www.demotivation.me/',
# Why: #9498 in Alexa global
'http://www.liquidweb.com/',
# Why: #9499 in Alexa global
'http://www.whydontyoutrythis.com/',
# Why: #9500 in Alexa global
'http://www.techhive.com/',
# Why: #9501 in Alexa global
'http://www.stylelist.com/',
# Why: #9502 in Alexa global
'http://www.shoppersstop.com/',
# Why: #9503 in Alexa global
'http://www.muare.vn/',
# Why: #9504 in Alexa global
'http://www.filezilla-project.org/',
# Why: #9505 in Alexa global
'http://www.wowwiki.com/',
# Why: #9506 in Alexa global
'http://www.ucm.es/',
# Why: #9507 in Alexa global
'http://www.plus.pl/',
# Why: #9509 in Alexa global
'http://www.goclips.tv/',
# Why: #9510 in Alexa global
'http://www.jeddahbikers.com/',
# Why: #9511 in Alexa global
'http://www.themalaysianinsider.com/',
# Why: #9512 in Alexa global
'http://www.buzznet.com/',
# Why: #9513 in Alexa global
'http://www.moonfruit.com/',
# Why: #9514 in Alexa global
'http://www.zivame.com/',
# Why: #9515 in Alexa global
'http://www.sproutsocial.com/',
# Why: #9516 in Alexa global
'http://www.evony.com/',
# Why: #9517 in Alexa global
'http://www.valuecommerce.com/',
# Why: #9518 in Alexa global
'http://www.cecile.co.jp/',
# Why: #9519 in Alexa global
'http://www.onlineconversion.com/',
# Why: #9520 in Alexa global
'http://www.adbooth.com/',
# Why: #9521 in Alexa global
'http://www.clubpartners.ru/',
# Why: #9522 in Alexa global
'http://www.rumah123.com/',
# Why: #9523 in Alexa global
'http://www.searspartsdirect.com/',
# Why: #9524 in Alexa global
'http://www.hollywood.com/',
# Why: #9525 in Alexa global
'http://www.divx.com/',
# Why: #9526 in Alexa global
'http://www.adverts.ie/',
# Why: #9527 in Alexa global
'http://www.filfan.com/',
# Why: #9528 in Alexa global
'http://www.t3.com/',
# Why: #9529 in Alexa global
'http://www.123vidz.com/',
# Why: #9530 in Alexa global
'http://www.technicpack.net/',
# Why: #9531 in Alexa global
'http://www.mightydeals.com/',
# Why: #9532 in Alexa global
'http://www.techgig.com/',
# Why: #9533 in Alexa global
'http://www.business.gov.au/',
# Why: #9534 in Alexa global
'http://www.phys.org/',
# Why: #9535 in Alexa global
'http://www.tweepi.com/',
# Why: #9536 in Alexa global
'http://www.bobfilm.net/',
# Why: #9537 in Alexa global
'http://www.phandroid.com/',
# Why: #9538 in Alexa global
'http://www.obozrevatel.com/',
# Why: #9539 in Alexa global
'http://www.elitedaily.com/',
# Why: #9540 in Alexa global
'http://www.tcfexpress.com/',
# Why: #9541 in Alexa global
'http://www.softaculous.com/',
# Why: #9542 in Alexa global
'http://www.xo.gr/',
# Why: #9543 in Alexa global
'http://www.cargocollective.com/',
# Why: #9544 in Alexa global
'http://www.airchina.com.cn/',
# Why: #9545 in Alexa global
'http://www.epicgameads.com/',
# Why: #9546 in Alexa global
'http://www.billigfluege.de/',
# Why: #9547 in Alexa global
'http://www.google.co.zm/',
# Why: #9548 in Alexa global
'http://www.flamingtext.com/',
# Why: #9549 in Alexa global
'http://www.mediatraffic.com/',
# Why: #9550 in Alexa global
'http://www.redboxinstant.com/',
# Why: #9551 in Alexa global
'http://www.tvquran.com/',
# Why: #9552 in Alexa global
'http://www.mstaml.com/',
# Why: #9553 in Alexa global
'http://www.polskieradio.pl/',
# Why: #9554 in Alexa global
'http://www.ipower.com/',
# Why: #9555 in Alexa global
'http://www.magicjack.com/',
# Why: #9556 in Alexa global
'http://www.linuxidc.com/',
# Why: #9557 in Alexa global
'http://www.audiojungle.net/',
# Why: #9558 in Alexa global
'http://www.zoomit.ir/',
# Why: #9559 in Alexa global
'http://www.celebritygossiplive.com/',
# Why: #9560 in Alexa global
'http://www.entheosweb.com/',
# Why: #9561 in Alexa global
'http://www.duke.edu/',
# Why: #9562 in Alexa global
'http://www.lamchame.com/',
# Why: #9563 in Alexa global
'http://www.trinixy.ru/',
# Why: #9564 in Alexa global
'http://www.heroeswm.ru/',
# Why: #9565 in Alexa global
'http://www.leovegas.com/',
# Why: #9566 in Alexa global
'http://www.redvak.com/',
# Why: #9567 in Alexa global
'http://www.wpexplorer.com/',
# Why: #9568 in Alexa global
'http://www.pornosexxxtits.com/',
# Why: #9569 in Alexa global
'http://www.thatrendsystem.com/',
# Why: #9570 in Alexa global
'http://www.minutouno.com/',
# Why: #9571 in Alexa global
'http://www.dnes.bg/',
# Why: #9572 in Alexa global
'http://www.raqq.com/',
# Why: #9573 in Alexa global
'http://www.misr5.com/',
# Why: #9574 in Alexa global
'http://www.m6replay.fr/',
# Why: #9575 in Alexa global
'http://www.ciao.es/',
# Why: #9576 in Alexa global
'http://www.indiatvnews.com/',
# Why: #9577 in Alexa global
'http://www.transunion.com/',
# Why: #9578 in Alexa global
'http://www.mha.nic.in/',
# Why: #9579 in Alexa global
'http://www.listia.com/',
# Why: #9580 in Alexa global
'http://www.duba.net/',
# Why: #9581 in Alexa global
'http://www.apec.fr/',
# Why: #9582 in Alexa global
'http://www.dexknows.com/',
# Why: #9583 in Alexa global
'http://www.americangirl.com/',
# Why: #9584 in Alexa global
'http://www.seekbang.com/',
# Why: #9585 in Alexa global
'http://www.greenmangaming.com/',
# Why: #9586 in Alexa global
'http://www.ptfish.com/',
# Why: #9587 in Alexa global
'http://www.myjob.com.cn/',
# Why: #9588 in Alexa global
'http://www.mistrzowie.org/',
# Why: #9589 in Alexa global
'http://www.chinatrust.com.tw/',
# Why: #9590 in Alexa global
'http://kongfz.com/',
# Why: #9591 in Alexa global
'http://www.finam.ru/',
# Why: #9592 in Alexa global
'http://www.tapiture.com/',
# Why: #9593 in Alexa global
'http://www.beon.ru/',
# Why: #9594 in Alexa global
'http://www.redsurf.ru/',
# Why: #9595 in Alexa global
'http://www.jamiiforums.com/',
# Why: #9596 in Alexa global
'http://www.grannysextubez.com/',
# Why: #9597 in Alexa global
'http://www.adlux.com/',
# Why: #9598 in Alexa global
'http://www.just-eat.co.uk/',
# Why: #9599 in Alexa global
'http://www.live24.gr/',
# Why: #9600 in Alexa global
'http://www.moip.com.br/',
# Why: #9601 in Alexa global
'http://www.chanel.com/',
# Why: #9602 in Alexa global
'http://www.sbs.co.kr/',
# Why: #9603 in Alexa global
'http://www.screwfix.com/',
# Why: #9604 in Alexa global
'http://www.trivago.it/',
# Why: #9605 in Alexa global
'http://airw.net/',
# Why: #9606 in Alexa global
'http://www.dietnavi.com/',
# Why: #9607 in Alexa global
'http://www.spartoo.es/',
# Why: #9608 in Alexa global
'http://www.game-debate.com/',
# Why: #9609 in Alexa global
'http://www.rotahaber.com/',
# Why: #9611 in Alexa global
'http://www.google.md/',
# Why: #9612 in Alexa global
'http://www.pornsex69.com/',
# Why: #9613 in Alexa global
'http://tmgonlinemedia.nl/',
# Why: #9614 in Alexa global
'http://www.myvoffice.com/',
# Why: #9615 in Alexa global
'http://www.wroclaw.pl/',
# Why: #9616 in Alexa global
'http://www.finansbank.com.tr/',
# Why: #9617 in Alexa global
'http://www.govdelivery.com/',
# Why: #9618 in Alexa global
'http://www.gamesbox.com/',
# Why: #9619 in Alexa global
'http://37wan.com/',
# Why: #9620 in Alexa global
'http://www.portableapps.com/',
# Why: #9621 in Alexa global
'http://www.dateinasia.com/',
# Why: #9623 in Alexa global
'http://www.northerntool.com/',
# Why: #9624 in Alexa global
'http://www.51pinwei.com/',
# Why: #9625 in Alexa global
'http://www.ocregister.com/',
# Why: #9626 in Alexa global
'http://www.noelshack.com/',
# Why: #9627 in Alexa global
'http://www.ipanelonline.com/',
# Why: #9628 in Alexa global
'http://www.klart.se/',
# Why: #9629 in Alexa global
'http://www.ismedia.jp/',
# Why: #9630 in Alexa global
'http://hqew.com/',
# Why: #9631 in Alexa global
'http://www.moodle.org/',
# Why: #9632 in Alexa global
'http://www.westernunion.fr/',
# Why: #9633 in Alexa global
'http://www.medindia.net/',
# Why: #9634 in Alexa global
'http://www.sencha.com/',
# Why: #9635 in Alexa global
'http://www.moveon.org/',
# Why: #9636 in Alexa global
'http://www.sipeliculas.com/',
# Why: #9637 in Alexa global
'http://www.beachbody.com/',
# Why: #9639 in Alexa global
'http://www.experts-exchange.com/',
# Why: #9640 in Alexa global
'http://www.davidsbridal.com/',
# Why: #9641 in Alexa global
'http://www.apotheken-umschau.de/',
# Why: #9642 in Alexa global
'http://www.melaleuca.com/',
# Why: #9643 in Alexa global
'http://www.cdbaby.com/',
# Why: #9644 in Alexa global
'http://www.humblebundle.com/',
# Why: #9645 in Alexa global
'http://www.telenet.be/',
# Why: #9646 in Alexa global
'http://www.labaq.com/',
# Why: #9647 in Alexa global
'http://www.smartaddons.com/',
# Why: #9648 in Alexa global
'http://www.vukajlija.com/',
# Why: #9649 in Alexa global
'http://www.zalando.es/',
# Why: #9650 in Alexa global
'http://www.articlerich.com/',
# Why: #9651 in Alexa global
'http://www.dm456.com/',
# Why: #9652 in Alexa global
'http://www.global-adsopt.com/',
# Why: #9653 in Alexa global
'http://www.forumophilia.com/',
# Why: #9654 in Alexa global
'http://www.dafiti.com.mx/',
# Why: #9655 in Alexa global
'http://www.funnystuff247.org/',
# Why: #9656 in Alexa global
'http://www.300mbfilms.com/',
# Why: #9657 in Alexa global
'http://www.xvideospornogratis.com/',
# Why: #9658 in Alexa global
'http://www.readnovel.com/',
# Why: #9659 in Alexa global
'http://www.khmer-news.org/',
# Why: #9660 in Alexa global
'http://www.media970.com/',
# Why: #9661 in Alexa global
'http://www.zwinky.com/',
# Why: #9662 in Alexa global
'http://www.newsbullet.in/',
# Why: #9663 in Alexa global
'http://www.pingfarm.com/',
# Why: #9664 in Alexa global
'http://www.lovetoknow.com/',
# Why: #9665 in Alexa global
'http://www.dntx.com/',
# Why: #9666 in Alexa global
'http://www.dip.jp/',
# Why: #9667 in Alexa global
'http://www.pap.fr/',
# Why: #9668 in Alexa global
'http://www.dizzcloud.com/',
# Why: #9669 in Alexa global
'http://www.nav.no/',
# Why: #9670 in Alexa global
'http://www.lotto.pl/',
# Why: #9671 in Alexa global
'http://www.freemp3whale.com/',
# Why: #9672 in Alexa global
'http://www.smartadserver.com/',
# Why: #9673 in Alexa global
'http://www.westpac.co.nz/',
# Why: #9674 in Alexa global
'http://www.kenrockwell.com/',
# Why: #9675 in Alexa global
'http://www.hongkongpost.com/',
# Why: #9676 in Alexa global
'http://www.delish.com/',
# Why: #9677 in Alexa global
'http://www.islam-lovers.com/',
# Why: #9678 in Alexa global
'http://www.edis.at/',
# Why: #9679 in Alexa global
'http://www.avery.com/',
# Why: #9680 in Alexa global
'http://www.giaitri.com/',
# Why: #9681 in Alexa global
'http://www.linksmanagement.com/',
# Why: #9682 in Alexa global
'http://www.beruby.com/',
# Why: #9683 in Alexa global
'http://www.1stwebgame.com/',
# Why: #9684 in Alexa global
'http://www.whocallsme.com/',
# Why: #9685 in Alexa global
'http://www.westwood.com/',
# Why: #9686 in Alexa global
'http://www.lmaohub.com/',
# Why: #9687 in Alexa global
'http://www.theresumator.com/',
# Why: #9688 in Alexa global
'http://www.nude.tv/',
# Why: #9689 in Alexa global
'http://www.nvrcp.com/',
# Why: #9690 in Alexa global
'http://www.bebinin.com/',
# Why: #9691 in Alexa global
'http://www.buddypress.org/',
# Why: #9693 in Alexa global
'http://www.uitzendinggemist.nl/',
# Why: #9694 in Alexa global
'http://www.majorleaguegaming.com/',
# Why: #9695 in Alexa global
'http://www.phpclasses.org/',
# Why: #9696 in Alexa global
'http://www.inteligo.pl/',
# Why: #9697 in Alexa global
'http://www.pinkbike.com/',
# Why: #9698 in Alexa global
'http://www.songlyrics.com/',
# Why: #9699 in Alexa global
'http://www.ct.gov/',
# Why: #9700 in Alexa global
'http://www.timeslive.co.za/',
# Why: #9701 in Alexa global
'http://www.snapwidget.com/',
# Why: #9702 in Alexa global
'http://www.watchkart.com/',
# Why: #9703 in Alexa global
'http://www.col3negoriginalcom.com/',
# Why: #9704 in Alexa global
'http://www.bronto.com/',
# Why: #9705 in Alexa global
'http://www.coasttocoastam.com/',
# Why: #9706 in Alexa global
'http://www.theladbible.com/',
# Why: #9707 in Alexa global
'http://narkive.com/',
# Why: #9708 in Alexa global
'http://www.the-village.ru/',
# Why: #9709 in Alexa global
'http://www.roem.ru/',
# Why: #9710 in Alexa global
'http://www.hi-pda.com/',
# Why: #9711 in Alexa global
'http://www.411.info/',
# Why: #9712 in Alexa global
'http://www.likesasap.com/',
# Why: #9713 in Alexa global
'http://www.blitz.bg/',
# Why: #9714 in Alexa global
'http://www.goodfon.ru/',
# Why: #9715 in Alexa global
'http://www.desktopnexus.com/',
# Why: #9716 in Alexa global
'http://www.demis.ru/',
# Why: #9717 in Alexa global
'http://www.begun.ru/',
# Why: #9718 in Alexa global
'http://www.ekikara.jp/',
# Why: #9719 in Alexa global
'http://www.linktech.cn/',
# Why: #9720 in Alexa global
'http://www.tezaktrafficpower.com/',
# Why: #9721 in Alexa global
'http://www.videos.com/',
# Why: #9722 in Alexa global
'http://www.pnet.co.za/',
# Why: #9723 in Alexa global
'http://www.rds.ca/',
# Why: #9724 in Alexa global
'http://www.dlink.com/',
# Why: #9725 in Alexa global
'http://www.ispajuegos.com/',
# Why: #9726 in Alexa global
'http://www.foxsportsasia.com/',
# Why: #9727 in Alexa global
'http://www.lexisnexis.com/',
# Why: #9728 in Alexa global
'http://www.ddproperty.com/',
# Why: #9729 in Alexa global
'http://www.1channelmovie.com/',
# Why: #9731 in Alexa global
'http://www.postimage.org/',
# Why: #9732 in Alexa global
'http://www.rahedaneshjou.ir/',
# Why: #9733 in Alexa global
'http://www.modern.az/',
# Why: #9734 in Alexa global
'http://www.givemegay.com/',
# Why: #9735 in Alexa global
'http://www.tejaratbank.net/',
# Why: #9736 in Alexa global
'http://www.rockpapershotgun.com/',
# Why: #9737 in Alexa global
'http://www.infogue.com/',
# Why: #9738 in Alexa global
'http://www.sfora.pl/',
# Why: #9739 in Alexa global
'http://www.liberoquotidiano.it/',
# Why: #9740 in Alexa global
'http://www.forumok.com/',
# Why: #9741 in Alexa global
'http://www.infonavit.org.mx/',
# Why: #9742 in Alexa global
'http://www.bankwest.com.au/',
# Why: #9743 in Alexa global
'http://www.al-mashhad.com/',
# Why: #9744 in Alexa global
'http://www.ogame.de/',
# Why: #9745 in Alexa global
'http://www.triviatoday.com/',
# Why: #9746 in Alexa global
'http://www.topspeed.com/',
# Why: #9747 in Alexa global
'http://www.kuku123.com/',
# Why: #9748 in Alexa global
'http://www.gayforit.eu/',
# Why: #9749 in Alexa global
'http://www.alahlionline.com/',
# Why: #9750 in Alexa global
'http://www.phonegap.com/',
# Why: #9752 in Alexa global
'http://www.superhry.cz/',
# Why: #9753 in Alexa global
'http://www.sweepstakes.com/',
# Why: #9754 in Alexa global
'http://www.australianbusinessgroup.net/',
# Why: #9755 in Alexa global
'http://www.nacion.com/',
# Why: #9756 in Alexa global
'http://www.futura-sciences.com/',
# Why: #9757 in Alexa global
'http://www.education.gouv.fr/',
# Why: #9758 in Alexa global
'http://www.haott.com/',
# Why: #9759 in Alexa global
'http://www.ey.com/',
# Why: #9760 in Alexa global
'http://www.roksa.pl/',
# Why: #9761 in Alexa global
'http://www.manoramanews.com/',
# Why: #9762 in Alexa global
'http://www.secretsearchenginelabs.com/',
# Why: #9763 in Alexa global
'http://www.alitui.com/',
# Why: #9764 in Alexa global
'http://www.depor.pe/',
# Why: #9765 in Alexa global
'http://www.rbc.com/',
# Why: #9766 in Alexa global
'http://www.tvaguuco.blogspot.se/',
# Why: #9767 in Alexa global
'http://www.mediaturf.net/',
# Why: #9768 in Alexa global
'http://www.mobilemoneycode.com/',
# Why: #9769 in Alexa global
'http://www.radio-canada.ca/',
# Why: #9770 in Alexa global
'http://www.shijue.me/',
# Why: #9771 in Alexa global
'http://www.upyim.com/',
# Why: #9772 in Alexa global
'http://www.indeed.com.br/',
# Why: #9773 in Alexa global
'http://www.indianrailways.gov.in/',
# Why: #9774 in Alexa global
'http://www.myfreepaysite.com/',
# Why: #9775 in Alexa global
'http://www.adchiever.com/',
# Why: #9776 in Alexa global
'http://www.xonei.com/',
# Why: #9777 in Alexa global
'http://www.kingworldnews.com/',
# Why: #9779 in Alexa global
'http://www.twenga.fr/',
# Why: #9780 in Alexa global
'http://www.oknation.net/',
# Why: #9782 in Alexa global
'http://www.zj4v.info/',
# Why: #9783 in Alexa global
'http://www.usanetwork.com/',
# Why: #9784 in Alexa global
'http://www.carphonewarehouse.com/',
# Why: #9785 in Alexa global
'http://www.impactradius.com/',
# Why: #9786 in Alexa global
'http://www.cinepolis.com/',
# Why: #9787 in Alexa global
'http://www.tvfun.ma/',
# Why: #9788 in Alexa global
'http://www.secureupload.eu/',
# Why: #9789 in Alexa global
'http://www.sarsefiling.co.za/',
# Why: #9790 in Alexa global
'http://www.flvmplayer.com/',
# Why: #9791 in Alexa global
'http://www.gemius.com.tr/',
# Why: #9792 in Alexa global
'http://www.alibris.com/',
# Why: #9793 in Alexa global
'http://www.insomniagamer.com/',
# Why: #9795 in Alexa global
'http://www.osxdaily.com/',
# Why: #9796 in Alexa global
'http://www.novasdodia.com/',
# Why: #9797 in Alexa global
'http://www.ayuwage.com/',
# Why: #9798 in Alexa global
'http://www.c-date.it/',
# Why: #9799 in Alexa global
'http://www.meetic.es/',
# Why: #9800 in Alexa global
'http://www.cineplex.com/',
# Why: #9801 in Alexa global
'http://www.mugshots.com/',
# Why: #9802 in Alexa global
'http://www.allabolag.se/',
# Why: #9803 in Alexa global
'http://www.parentsconnect.com/',
# Why: #9804 in Alexa global
'http://www.sina.cn/',
# Why: #9805 in Alexa global
'http://www.ibis.com/',
# Why: #9806 in Alexa global
'http://find.blog.co.uk/',
# Why: #9807 in Alexa global
'http://www.findcheaters.com/',
# Why: #9808 in Alexa global
'http://www.telly.com/',
# Why: #9809 in Alexa global
'http://www.alphacoders.com/',
# Why: #9810 in Alexa global
'http://www.sciencenet.cn/',
# Why: #9811 in Alexa global
'http://www.sreality.cz/',
# Why: #9812 in Alexa global
'http://www.wall-street-exposed.com/',
# Why: #9813 in Alexa global
'http://www.mizhe.com/',
# Why: #9814 in Alexa global
'http://www.telugumatrimony.com/',
# Why: #9815 in Alexa global
'http://www.220tube.com/',
# Why: #9816 in Alexa global
'http://www.gboxapp.com/',
# Why: #9817 in Alexa global
'http://www.activeden.net/',
# Why: #9818 in Alexa global
'http://www.worldsex.com/',
# Why: #9819 in Alexa global
'http://www.tdscpc.gov.in/',
# Why: #9821 in Alexa global
'http://www.mlbtraderumors.com/',
# Why: #9822 in Alexa global
'http://www.top-channel.tv/',
# Why: #9823 in Alexa global
'http://www.publiekeomroep.nl/',
# Why: #9824 in Alexa global
'http://www.flvs.net/',
# Why: #9825 in Alexa global
'http://www.inwi.ma/',
# Why: #9826 in Alexa global
'http://www.web-ip.ru/',
# Why: #9827 in Alexa global
'http://www.er7mne.com/',
# Why: #9828 in Alexa global
'http://www.valueclickmedia.com/',
# Why: #9829 in Alexa global
'http://www.1pondo.tv/',
# Why: #9830 in Alexa global
'http://www.capcom.co.jp/',
# Why: #9831 in Alexa global
'http://www.covers.com/',
# Why: #9832 in Alexa global
'http://www.be2.it/',
# Why: #9833 in Alexa global
'http://www.e-cigarette-forum.com/',
# Why: #9834 in Alexa global
'http://www.himarin.net/',
# Why: #9835 in Alexa global
'http://www.indiainfoline.com/',
# Why: #9836 in Alexa global
'http://www.51gxqm.com/',
# Why: #9837 in Alexa global
'http://www.sebank.se/',
# Why: #9838 in Alexa global
'http://www.18inhd.com/',
# Why: #9839 in Alexa global
'http://www.unionbankonline.co.in/',
# Why: #9840 in Alexa global
'http://www.filetram.com/',
# Why: #9841 in Alexa global
'http://www.santasporngirls.com/',
# Why: #9842 in Alexa global
'http://www.drupal.ru/',
# Why: #9843 in Alexa global
'http://www.tokfm.pl/',
# Why: #9844 in Alexa global
'http://www.steamgifts.com/',
# Why: #9845 in Alexa global
'http://www.residentadvisor.net/',
# Why: #9846 in Alexa global
'http://www.magento.com/',
# Why: #9847 in Alexa global
'http://www.28.com/',
# Why: #9848 in Alexa global
'http://www.style.com/',
# Why: #9849 in Alexa global
'http://www.nikkei.co.jp/',
# Why: #9850 in Alexa global
'http://www.alitalia.com/',
# Why: #9851 in Alexa global
'http://www.vudu.com/',
# Why: #9852 in Alexa global
'http://www.underarmour.com/',
# Why: #9853 in Alexa global
'http://www.wine-searcher.com/',
# Why: #9854 in Alexa global
'http://www.indiaproperty.com/',
# Why: #9855 in Alexa global
'http://www.bet365affiliates.com/',
# Why: #9856 in Alexa global
'http://www.cnnewmusic.com/',
# Why: #9857 in Alexa global
'http://www.longdo.com/',
# Why: #9858 in Alexa global
'http://www.destructoid.com/',
# Why: #9859 in Alexa global
'http://diyifanwen.com/',
# Why: #9860 in Alexa global
'http://www.logic-immo.com/',
# Why: #9861 in Alexa global
'http://www.mate1.com/',
# Why: #9862 in Alexa global
'http://www.pissedconsumer.com/',
# Why: #9863 in Alexa global
'http://www.blocked-website.com/',
# Why: #9864 in Alexa global
'http://www.cremonamostre.it/',
# Why: #9865 in Alexa global
'http://www.sayidaty.net/',
# Why: #9866 in Alexa global
'http://www.globalewallet.com/',
# Why: #9867 in Alexa global
'http://www.maxgames.com/',
# Why: #9868 in Alexa global
'http://www.auctionzip.com/',
# Why: #9870 in Alexa global
'http://www.aldaniti.net/',
# Why: #9871 in Alexa global
'http://www.workle.ru/',
# Why: #9872 in Alexa global
'http://www.arduino.cc/',
# Why: #9873 in Alexa global
'http://www.buenosaires.gob.ar/',
# Why: #9874 in Alexa global
'http://www.overtenreps.com/',
# Why: #9876 in Alexa global
'http://www.enalquiler.com/',
# Why: #9877 in Alexa global
'http://www.gazetadopovo.com.br/',
# Why: #9878 in Alexa global
'http://www.hftogo.com/',
# Why: #9879 in Alexa global
'http://www.usana.com/',
# Why: #9880 in Alexa global
'http://www.bancochile.cl/',
# Why: #9881 in Alexa global
'http://www.on24.com/',
# Why: #9882 in Alexa global
'http://www.samenblog.com/',
# Why: #9883 in Alexa global
'http://www.goindigo.in/',
# Why: #9884 in Alexa global
'http://www.iranvij.ir/',
# Why: #9885 in Alexa global
'http://www.postfinance.ch/',
# Why: #9886 in Alexa global
'http://www.grupobancolombia.com/',
# Why: #9887 in Alexa global
'http://www.flycell.pe/',
# Why: #9888 in Alexa global
'http://www.sobesednik.ru/',
# Why: #9889 in Alexa global
'http://www.banglalionwimax.com/',
# Why: #9890 in Alexa global
'http://www.yasni.com/',
# Why: #9891 in Alexa global
'http://www.diziizle.net/',
# Why: #9892 in Alexa global
'http://www.publichd.se/',
# Why: #9893 in Alexa global
'http://www.socialsurveycenter.com/',
# Why: #9894 in Alexa global
'http://www.blockbuster.com/',
# Why: #9895 in Alexa global
'http://www.el-ahly.com/',
# Why: #9896 in Alexa global
'http://www.1gb.ru/',
# Why: #9897 in Alexa global
'http://www.utah.edu/',
# Why: #9898 in Alexa global
'http://www.dziennik.pl/',
# Why: #9899 in Alexa global
'http://www.tizerads.com/',
# Why: #9901 in Alexa global
'http://www.global-free-classified-ads.com/',
# Why: #9902 in Alexa global
'http://www.afp.com/',
# Why: #9903 in Alexa global
'http://www.tiberiumalliances.com/',
# Why: #9904 in Alexa global
'http://www.worldstaruncut.com/',
# Why: #9905 in Alexa global
'http://www.watchfreeinhd.com/',
# Why: #9906 in Alexa global
'http://www.5278.cc/',
# Why: #9907 in Alexa global
'http://www.azdrama.info/',
# Why: #9908 in Alexa global
'http://fjsen.com/',
# Why: #9909 in Alexa global
'http://www.fandongxi.com/',
# Why: #9910 in Alexa global
'http://www.spicytranny.com/',
# Why: #9911 in Alexa global
'http://www.parsonline.net/',
# Why: #9912 in Alexa global
'http://www.libreoffice.org/',
# Why: #9913 in Alexa global
'http://www.atlassian.com/',
# Why: #9914 in Alexa global
'http://www.europeantour.com/',
# Why: #9915 in Alexa global
'http://www.smartsource.com/',
# Why: #9916 in Alexa global
'http://www.ashford.edu/',
# Why: #9917 in Alexa global
'http://www.moo.com/',
# Why: #9918 in Alexa global
'http://www.bplaced.net/',
# Why: #9919 in Alexa global
'http://www.themify.me/',
# Why: #9920 in Alexa global
'http://www.holidaypromo.info/',
# Why: #9921 in Alexa global
'http://www.nta.go.jp/',
# Why: #9922 in Alexa global
'http://www.kanglu.com/',
# Why: #9923 in Alexa global
'http://www.yicai.com/',
# Why: #9924 in Alexa global
'http://www.classesusa.com/',
# Why: #9925 in Alexa global
'http://www.huoche.net/',
# Why: #9926 in Alexa global
'http://www.linkomanija.net/',
# Why: #9927 in Alexa global
'http://www.blog.de/',
# Why: #9928 in Alexa global
'http://www.vw.com.tr/',
# Why: #9929 in Alexa global
'http://www.worldgmn.com/',
# Why: #9930 in Alexa global
'http://www.tommy.com/',
# Why: #9931 in Alexa global
'http://www.100bt.com/',
# Why: #9932 in Alexa global
'http://www.springsource.org/',
# Why: #9933 in Alexa global
'http://www.betfairinvest.com/',
# Why: #9934 in Alexa global
'http://www.broker.to/',
# Why: #9935 in Alexa global
'http://www.islamstory.com/',
# Why: #9937 in Alexa global
'http://www.sparebank1.no/',
# Why: #9938 in Alexa global
'http://www.towleroad.com/',
# Why: #9939 in Alexa global
'http://www.jetcost.com/',
# Why: #9940 in Alexa global
'http://www.pinping.com/',
# Why: #9941 in Alexa global
'http://www.millenniumbcp.pt/',
# Why: #9942 in Alexa global
'http://www.vikatan.com/',
# Why: #9943 in Alexa global
'http://www.dorkly.com/',
# Why: #9944 in Alexa global
'http://www.clubedohardware.com.br/',
# Why: #9945 in Alexa global
'http://www.fclub.cn/',
# Why: #9946 in Alexa global
'http://www.any.gs/',
# Why: #9947 in Alexa global
'http://www.danskebank.dk/',
# Why: #9948 in Alexa global
'http://www.tvmongol.com/',
# Why: #9949 in Alexa global
'http://www.ahnegao.com.br/',
# Why: #9950 in Alexa global
'http://www.filipinocupid.com/',
# Why: #9951 in Alexa global
'http://www.casacinemas.com/',
# Why: #9952 in Alexa global
'http://www.standvirtual.com/',
# Why: #9953 in Alexa global
'http://www.nbg.gr/',
# Why: #9954 in Alexa global
'http://www.onlywire.com/',
# Why: #9955 in Alexa global
'http://www.megacurioso.com.br/',
# Why: #9956 in Alexa global
'http://www.elaph.com/',
# Why: #9957 in Alexa global
'http://www.xvideos-field5.com/',
# Why: #9958 in Alexa global
'http://www.base.de/',
# Why: #9959 in Alexa global
'http://www.zzstream.li/',
# Why: #9960 in Alexa global
'http://www.qype.co.uk/',
# Why: #9961 in Alexa global
'http://www.ubergizmo.com/',
# Why: #9963 in Alexa global
'http://www.habervaktim.com/',
# Why: #9965 in Alexa global
'http://www.nationaljournal.com/',
# Why: #9966 in Alexa global
'http://www.fanslave.com/',
# Why: #9967 in Alexa global
'http://www.agreementfind.com/',
# Why: #9968 in Alexa global
'http://www.unionbankph.com/',
# Why: #9969 in Alexa global
'http://www.hometalk.com/',
# Why: #9970 in Alexa global
'http://www.hotnigerianjobs.com/',
# Why: #9971 in Alexa global
'http://www.infoq.com/',
# Why: #9972 in Alexa global
'http://www.matalan.co.uk/',
# Why: #9973 in Alexa global
'http://www.hottopic.com/',
# Why: #9974 in Alexa global
'http://www.hammihan.com/',
# Why: #9976 in Alexa global
'http://www.stsoftware.biz/',
# Why: #9977 in Alexa global
'http://www.elimparcial.com/',
# Why: #9978 in Alexa global
'http://www.lingualeo.ru/',
# Why: #9979 in Alexa global
'http://www.firstdirect.com/',
# Why: #9980 in Alexa global
'http://www.linkprosperity.com/',
# Why: #9982 in Alexa global
'http://www.ele.me/',
# Why: #9983 in Alexa global
'http://www.beep.com/',
# Why: #9984 in Alexa global
'http://w-t-f.jp/',
# Why: #9985 in Alexa global
'http://www.netcombo.com.br/',
# Why: #9986 in Alexa global
'http://www.meme.li/',
# Why: #9987 in Alexa global
'http://www.privateproperty.co.za/',
# Why: #9988 in Alexa global
'http://www.wunderlist.com/',
# Why: #9989 in Alexa global
'http://www.designyoutrust.com/',
# Why: #9990 in Alexa global
'http://century21.com/',
# Why: #9991 in Alexa global
'http://www.huuto.net/',
# Why: #9992 in Alexa global
'http://www.adsoftheworld.com/',
# Why: #9993 in Alexa global
'http://www.kabu.co.jp/',
# Why: #9994 in Alexa global
'http://www.vouchercodes.co.uk/',
# Why: #9995 in Alexa global
'http://www.allyou.com/',
# Why: #9996 in Alexa global
'http://www.mastemplate.com/',
# Why: #9997 in Alexa global
'http://www.bolha.com/',
# Why: #9998 in Alexa global
'http://www.tastyplay.com/',
# Why: #9999 in Alexa global
'http://www.busuk.org/']
for url in urls_list:
self.AddPage(Alexa1To10000Page(url, self))
|
bsd-3-clause
|
[
3,
1898,
6927,
710,
12051,
6642,
14,
2900,
4481,
4644,
14,
199,
3,
3645,
402,
642,
1350,
1233,
365,
10413,
701,
282,
6289,
13,
2487,
4190,
626,
883,
506,
199,
3,
1911,
315,
314,
5113,
570,
14,
199,
504,
17298,
14,
1606,
14,
1606,
63,
409,
492,
10331,
1084,
199,
504,
17298,
14,
1606,
14,
1606,
492,
10331,
421,
199,
533,
7235,
17,
1378,
9943,
3276,
8,
3276,
304,
819,
347,
636,
826,
721,
277,
12,
1166,
12,
2034,
63,
409,
304,
272,
1613,
8,
33,
274,
1800,
17,
1378,
9943,
3276,
12,
291,
2843,
826,
721,
633,
29,
633,
12,
2034,
63,
409,
29,
1606,
63,
409,
9,
272,
291,
14,
1875,
63,
9554,
63,
30709,
275,
715,
819,
347,
3378,
51,
11607,
4171,
8,
277,
12,
1595,
63,
5933,
304,
272,
18752,
275,
1595,
63,
5933,
14,
5595,
39,
597,
608,
31900,
8,
267,
283,
13127,
3310,
297,
365,
63,
19169,
29,
549,
9,
272,
1595,
63,
5933,
14,
13127,
3276,
342,
272,
18752,
14,
3005,
342,
421,
199,
533,
7235,
17,
1378,
9943,
3276,
1084,
8,
3276,
1084,
304,
523,
408,
14132,
413,
13,
9943,
7235,
2288,
14,
489,
17065,
641,
6171,
13,
1643,
13,
1644,
4944,
26,
1427,
26,
2481,
14,
28976,
7362,
701,
519,
2664,
27723,
1808,
489,
1218,
63,
1606,
63,
409,
14,
647,
14,
523,
408,
819,
347,
636,
826,
721,
277,
304,
272,
1613,
8,
33,
274,
1800,
17,
1378,
9943,
3276,
1084,
12,
291,
2843,
826,
721,
267,
1852,
63,
9554,
63,
30709,
29,
549,
12,
267,
922,
63,
4054,
63,
466,
534,
14487,
358,
339,
8187,
63,
513,
275,
359,
489,
327,
6827,
26,
327,
17,
315,
7235,
2288,
489,
283,
1014,
921,
1544,
14,
16652,
14,
957,
3678,
489,
327,
6827,
26,
327,
18,
315,
7235,
2288,
489,
283,
1014,
921,
1544,
14,
3098,
14,
957,
3678,
489,
327,
6827,
26,
327,
19,
315,
7235,
2288,
489,
283,
1014,
921,
1544,
14,
9788,
14,
957,
3678,
489,
327,
6827,
26,
327,
20,
315,
7235,
2288,
489,
283,
1014,
921,
1544,
14,
27231,
14,
957,
3678,
489,
327,
6827,
26,
327,
21,
315,
7235,
2288,
489,
283,
1014,
921,
2470,
344,
85,
14,
957,
3678,
489,
327,
6827,
26,
327,
22,
315,
7235,
2288,
489,
283,
1014,
921,
1544,
14,
15144,
14,
957,
3678,
489,
327,
6827,
26,
327,
23,
315,
7235,
2288,
489,
283,
1014,
921,
1544,
14,
13961,
14,
1308,
3678,
489,
327,
6827,
26,
327,
24,
315,
7235,
2288,
489,
283,
1014,
921,
1544,
14,
16672,
14,
957,
3678,
489,
327,
6827,
26,
327,
25,
315,
7235,
2288,
489,
283,
1014,
921,
1544,
14,
6442,
14,
957,
3678,
489,
327,
6827,
26,
327,
709,
315,
7235,
2288,
489,
283,
1014,
921,
1544,
14,
502,
79,
2470,
79,
14,
957,
3678,
489,
327,
6827,
26,
327,
845,
315,
7235,
2288,
489,
283,
1014,
921,
1544,
14,
3098,
14,
331,
14,
262,
3678,
489,
327,
6827,
26,
327,
713,
315,
7235,
2288,
489,
283,
1014,
921,
1544,
14,
13746,
14,
957,
3678,
489,
327,
6827,
26,
327,
969,
315,
7235,
2288,
489,
283,
1014,
921,
1544,
14,
66,
7270,
14173,
14,
957,
3678,
489,
327,
6827,
26,
327,
1079,
315,
7235,
2288,
489,
283,
1014,
921,
1544,
14,
12751,
262,
14,
957,
3678,
489,
327,
6827,
26,
327,
1046,
315,
7235,
2288,
489,
283,
1014,
921,
1544,
14,
27231,
14,
331,
14,
11538,
3678,
489,
327,
6827,
26,
327,
975,
315,
7235,
2288,
489,
283,
1014,
921,
1544,
14,
10911,
14,
957,
3678,
489,
327,
6827,
26,
327,
1196,
315,
7235,
2288,
489,
283,
1014,
921,
5911,
65,
14,
957,
14,
6413,
3678,
489,
327,
6827,
26,
327,
1085,
315,
7235,
2288,
489,
283,
1014,
921,
1544,
14,
89,
290,
731,
14,
6558,
3678,
489,
327,
6827,
26,
327,
1167,
315,
7235,
2288,
489,
283,
1014,
921,
1544,
14,
21405,
14,
957,
3678,
489,
327,
6827,
26,
327,
1165,
315,
7235,
2288,
489,
283,
1014,
921,
1544,
14,
813,
14,
957,
3678,
489,
327,
6827,
26,
327,
2025,
315,
7235,
2288,
489,
283,
1014,
921,
1544,
14,
2871,
1187,
14,
957,
3678,
489,
327,
6827,
26,
327,
1081,
315,
7235,
2288,
489,
283,
1014,
921,
1544,
14,
1027,
2915,
14,
957,
3678,
489,
327,
6827,
26,
327,
1789,
315,
7235,
2288,
489,
283,
1014,
921,
1544,
14,
3098,
14,
271,
3678,
489,
327,
6827,
26,
327,
1194,
315,
7235,
2288,
489,
283,
1014,
921,
1544,
14,
706,
78,
14,
957,
3678,
489,
327,
6827,
26,
327,
821,
315,
7235,
2288,
489,
283,
1014,
921,
1544,
14,
84,
453,
3345,
82,
14,
957,
3678,
489,
327,
6827,
26,
327,
1479,
315,
7235,
2288,
489,
283,
1014,
921,
11931,
14,
957,
3678,
489,
327,
6827,
26,
327,
1465,
315,
7235,
2288,
489,
283,
1014,
921,
1544,
14,
3098,
14,
957,
14,
21557,
3678,
489,
327,
6827,
26,
327,
1651,
315,
7235,
2288,
489,
283,
1014,
921,
1544,
14,
1198,
14,
6558,
3678,
489,
327,
6827,
26,
327,
1398,
315,
7235,
2288,
489,
283,
1014,
921,
1544,
14,
3098,
14,
331,
14,
3210,
3678,
489,
327,
6827,
26,
327,
1216,
315,
7235,
2288,
489,
283,
1014,
921,
2411,
79,
4288,
14,
957,
3678,
489,
327,
6827,
26,
327,
2192,
315,
7235,
2288,
489,
283,
1014,
921,
1544,
14,
3098,
14,
957,
14,
3289,
3678,
489,
327,
6827,
26,
327,
708,
315,
7235,
2288,
489,
283,
1014,
921,
1544,
14,
15144,
14,
331,
14,
11538,
3678,
489,
327,
6827,
26,
327,
1153,
315,
7235,
2288,
489,
283,
1014,
921,
1544,
14,
21431,
656,
14,
957,
3678,
489,
327,
6827,
26,
327,
1082,
315,
7235,
2288,
489,
283,
1014,
921,
1544,
14,
88,
11418,
14,
957,
3678,
489,
327,
6827,
26,
327,
1276,
315,
7235,
2288,
489,
283,
1014,
921,
1544,
14,
3098,
14,
331,
14,
11538,
3678,
489,
327,
6827,
26,
327,
1344,
315,
7235,
2288,
489,
283,
1014,
921,
1544,
14,
17040,
14,
957,
3678,
489,
327,
6827,
26,
327,
1703,
315,
7235,
2288,
489,
283,
1014,
921,
1544,
14,
3136,
13,
1733,
14,
957,
3678,
489,
327,
6827,
26,
327,
1355,
315,
7235,
2288,
489,
283,
1014,
921,
1544,
14,
3098,
14,
4391,
3678,
489
] |
[
1898,
6927,
710,
12051,
6642,
14,
2900,
4481,
4644,
14,
199,
3,
3645,
402,
642,
1350,
1233,
365,
10413,
701,
282,
6289,
13,
2487,
4190,
626,
883,
506,
199,
3,
1911,
315,
314,
5113,
570,
14,
199,
504,
17298,
14,
1606,
14,
1606,
63,
409,
492,
10331,
1084,
199,
504,
17298,
14,
1606,
14,
1606,
492,
10331,
421,
199,
533,
7235,
17,
1378,
9943,
3276,
8,
3276,
304,
819,
347,
636,
826,
721,
277,
12,
1166,
12,
2034,
63,
409,
304,
272,
1613,
8,
33,
274,
1800,
17,
1378,
9943,
3276,
12,
291,
2843,
826,
721,
633,
29,
633,
12,
2034,
63,
409,
29,
1606,
63,
409,
9,
272,
291,
14,
1875,
63,
9554,
63,
30709,
275,
715,
819,
347,
3378,
51,
11607,
4171,
8,
277,
12,
1595,
63,
5933,
304,
272,
18752,
275,
1595,
63,
5933,
14,
5595,
39,
597,
608,
31900,
8,
267,
283,
13127,
3310,
297,
365,
63,
19169,
29,
549,
9,
272,
1595,
63,
5933,
14,
13127,
3276,
342,
272,
18752,
14,
3005,
342,
421,
199,
533,
7235,
17,
1378,
9943,
3276,
1084,
8,
3276,
1084,
304,
523,
408,
14132,
413,
13,
9943,
7235,
2288,
14,
489,
17065,
641,
6171,
13,
1643,
13,
1644,
4944,
26,
1427,
26,
2481,
14,
28976,
7362,
701,
519,
2664,
27723,
1808,
489,
1218,
63,
1606,
63,
409,
14,
647,
14,
523,
408,
819,
347,
636,
826,
721,
277,
304,
272,
1613,
8,
33,
274,
1800,
17,
1378,
9943,
3276,
1084,
12,
291,
2843,
826,
721,
267,
1852,
63,
9554,
63,
30709,
29,
549,
12,
267,
922,
63,
4054,
63,
466,
534,
14487,
358,
339,
8187,
63,
513,
275,
359,
489,
327,
6827,
26,
327,
17,
315,
7235,
2288,
489,
283,
1014,
921,
1544,
14,
16652,
14,
957,
3678,
489,
327,
6827,
26,
327,
18,
315,
7235,
2288,
489,
283,
1014,
921,
1544,
14,
3098,
14,
957,
3678,
489,
327,
6827,
26,
327,
19,
315,
7235,
2288,
489,
283,
1014,
921,
1544,
14,
9788,
14,
957,
3678,
489,
327,
6827,
26,
327,
20,
315,
7235,
2288,
489,
283,
1014,
921,
1544,
14,
27231,
14,
957,
3678,
489,
327,
6827,
26,
327,
21,
315,
7235,
2288,
489,
283,
1014,
921,
2470,
344,
85,
14,
957,
3678,
489,
327,
6827,
26,
327,
22,
315,
7235,
2288,
489,
283,
1014,
921,
1544,
14,
15144,
14,
957,
3678,
489,
327,
6827,
26,
327,
23,
315,
7235,
2288,
489,
283,
1014,
921,
1544,
14,
13961,
14,
1308,
3678,
489,
327,
6827,
26,
327,
24,
315,
7235,
2288,
489,
283,
1014,
921,
1544,
14,
16672,
14,
957,
3678,
489,
327,
6827,
26,
327,
25,
315,
7235,
2288,
489,
283,
1014,
921,
1544,
14,
6442,
14,
957,
3678,
489,
327,
6827,
26,
327,
709,
315,
7235,
2288,
489,
283,
1014,
921,
1544,
14,
502,
79,
2470,
79,
14,
957,
3678,
489,
327,
6827,
26,
327,
845,
315,
7235,
2288,
489,
283,
1014,
921,
1544,
14,
3098,
14,
331,
14,
262,
3678,
489,
327,
6827,
26,
327,
713,
315,
7235,
2288,
489,
283,
1014,
921,
1544,
14,
13746,
14,
957,
3678,
489,
327,
6827,
26,
327,
969,
315,
7235,
2288,
489,
283,
1014,
921,
1544,
14,
66,
7270,
14173,
14,
957,
3678,
489,
327,
6827,
26,
327,
1079,
315,
7235,
2288,
489,
283,
1014,
921,
1544,
14,
12751,
262,
14,
957,
3678,
489,
327,
6827,
26,
327,
1046,
315,
7235,
2288,
489,
283,
1014,
921,
1544,
14,
27231,
14,
331,
14,
11538,
3678,
489,
327,
6827,
26,
327,
975,
315,
7235,
2288,
489,
283,
1014,
921,
1544,
14,
10911,
14,
957,
3678,
489,
327,
6827,
26,
327,
1196,
315,
7235,
2288,
489,
283,
1014,
921,
5911,
65,
14,
957,
14,
6413,
3678,
489,
327,
6827,
26,
327,
1085,
315,
7235,
2288,
489,
283,
1014,
921,
1544,
14,
89,
290,
731,
14,
6558,
3678,
489,
327,
6827,
26,
327,
1167,
315,
7235,
2288,
489,
283,
1014,
921,
1544,
14,
21405,
14,
957,
3678,
489,
327,
6827,
26,
327,
1165,
315,
7235,
2288,
489,
283,
1014,
921,
1544,
14,
813,
14,
957,
3678,
489,
327,
6827,
26,
327,
2025,
315,
7235,
2288,
489,
283,
1014,
921,
1544,
14,
2871,
1187,
14,
957,
3678,
489,
327,
6827,
26,
327,
1081,
315,
7235,
2288,
489,
283,
1014,
921,
1544,
14,
1027,
2915,
14,
957,
3678,
489,
327,
6827,
26,
327,
1789,
315,
7235,
2288,
489,
283,
1014,
921,
1544,
14,
3098,
14,
271,
3678,
489,
327,
6827,
26,
327,
1194,
315,
7235,
2288,
489,
283,
1014,
921,
1544,
14,
706,
78,
14,
957,
3678,
489,
327,
6827,
26,
327,
821,
315,
7235,
2288,
489,
283,
1014,
921,
1544,
14,
84,
453,
3345,
82,
14,
957,
3678,
489,
327,
6827,
26,
327,
1479,
315,
7235,
2288,
489,
283,
1014,
921,
11931,
14,
957,
3678,
489,
327,
6827,
26,
327,
1465,
315,
7235,
2288,
489,
283,
1014,
921,
1544,
14,
3098,
14,
957,
14,
21557,
3678,
489,
327,
6827,
26,
327,
1651,
315,
7235,
2288,
489,
283,
1014,
921,
1544,
14,
1198,
14,
6558,
3678,
489,
327,
6827,
26,
327,
1398,
315,
7235,
2288,
489,
283,
1014,
921,
1544,
14,
3098,
14,
331,
14,
3210,
3678,
489,
327,
6827,
26,
327,
1216,
315,
7235,
2288,
489,
283,
1014,
921,
2411,
79,
4288,
14,
957,
3678,
489,
327,
6827,
26,
327,
2192,
315,
7235,
2288,
489,
283,
1014,
921,
1544,
14,
3098,
14,
957,
14,
3289,
3678,
489,
327,
6827,
26,
327,
708,
315,
7235,
2288,
489,
283,
1014,
921,
1544,
14,
15144,
14,
331,
14,
11538,
3678,
489,
327,
6827,
26,
327,
1153,
315,
7235,
2288,
489,
283,
1014,
921,
1544,
14,
21431,
656,
14,
957,
3678,
489,
327,
6827,
26,
327,
1082,
315,
7235,
2288,
489,
283,
1014,
921,
1544,
14,
88,
11418,
14,
957,
3678,
489,
327,
6827,
26,
327,
1276,
315,
7235,
2288,
489,
283,
1014,
921,
1544,
14,
3098,
14,
331,
14,
11538,
3678,
489,
327,
6827,
26,
327,
1344,
315,
7235,
2288,
489,
283,
1014,
921,
1544,
14,
17040,
14,
957,
3678,
489,
327,
6827,
26,
327,
1703,
315,
7235,
2288,
489,
283,
1014,
921,
1544,
14,
3136,
13,
1733,
14,
957,
3678,
489,
327,
6827,
26,
327,
1355,
315,
7235,
2288,
489,
283,
1014,
921,
1544,
14,
3098,
14,
4391,
3678,
489,
0
] |
[
1,
1,
1,
1,
1,
1,
1,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auth1/rfc5849/endpoints/test_base.py
|
27
|
16073
|
from __future__ import unicode_literals, absolute_import
from mock import MagicMock
from re import sub
from ....unittest import TestCase
from oauthlib.common import safe_string_equals
from oauthlib.oauth1 import Client, RequestValidator
from oauthlib.oauth1.rfc5849 import errors, SIGNATURE_RSA, SIGNATURE_HMAC
from oauthlib.oauth1.rfc5849 import SIGNATURE_PLAINTEXT
from oauthlib.oauth1.rfc5849.endpoints import RequestTokenEndpoint, BaseEndpoint
URLENCODED = {"Content-Type": "application/x-www-form-urlencoded"}
class BaseEndpointTest(TestCase):
def setUp(self):
self.validator = MagicMock(spec=RequestValidator)
self.validator.allowed_signature_methods = ['HMAC-SHA1']
self.validator.timestamp_lifetime = 600
self.endpoint = RequestTokenEndpoint(self.validator)
self.client = Client('foo', callback_uri='https://c.b/cb')
self.uri, self.headers, self.body = self.client.sign(
'https://i.b/request_token')
def test_ssl_enforcement(self):
uri, headers, _ = self.client.sign('http://i.b/request_token')
h, b, s = self.endpoint.create_request_token_response(
uri, headers=headers)
self.assertEqual(s, 400)
self.assertIn('insecure_transport_protocol', b)
def test_missing_parameters(self):
h, b, s = self.endpoint.create_request_token_response(self.uri)
self.assertEqual(s, 400)
self.assertIn('invalid_request', b)
def test_signature_methods(self):
headers = {}
headers['Authorization'] = self.headers['Authorization'].replace(
'HMAC', 'RSA')
h, b, s = self.endpoint.create_request_token_response(
self.uri, headers=headers)
self.assertEqual(s, 400)
self.assertIn('invalid_signature_method', b)
def test_invalid_version(self):
headers = {}
headers['Authorization'] = self.headers['Authorization'].replace(
'1.0', '2.0')
h, b, s = self.endpoint.create_request_token_response(
self.uri, headers=headers)
self.assertEqual(s, 400)
self.assertIn('invalid_request', b)
def test_expired_timestamp(self):
headers = {}
for pattern in ('12345678901', '4567890123', '123456789K'):
headers['Authorization'] = sub('timestamp="\d*k?"',
'timestamp="%s"' % pattern,
self.headers['Authorization'])
h, b, s = self.endpoint.create_request_token_response(
self.uri, headers=headers)
self.assertEqual(s, 400)
self.assertIn('invalid_request', b)
def test_client_key_check(self):
self.validator.check_client_key.return_value = False
h, b, s = self.endpoint.create_request_token_response(
self.uri, headers=self.headers)
self.assertEqual(s, 400)
self.assertIn('invalid_request', b)
def test_noncecheck(self):
self.validator.check_nonce.return_value = False
h, b, s = self.endpoint.create_request_token_response(
self.uri, headers=self.headers)
self.assertEqual(s, 400)
self.assertIn('invalid_request', b)
def test_enforce_ssl(self):
"""Ensure SSL is enforced by default."""
v = RequestValidator()
e = BaseEndpoint(v)
c = Client('foo')
u, h, b = c.sign('http://example.com')
r = e._create_request(u, 'GET', b, h)
self.assertRaises(errors.InsecureTransportError,
e._check_transport_security, r)
def test_multiple_source_params(self):
"""Check for duplicate params"""
v = RequestValidator()
e = BaseEndpoint(v)
self.assertRaises(errors.InvalidRequestError, e._create_request,
'https://a.b/?oauth_signature_method=HMAC-SHA1',
'GET', 'oauth_version=foo', URLENCODED)
headers = {'Authorization': 'OAuth oauth_signature="foo"'}
headers.update(URLENCODED)
self.assertRaises(errors.InvalidRequestError, e._create_request,
'https://a.b/?oauth_signature_method=HMAC-SHA1',
'GET',
'oauth_version=foo',
headers)
headers = {'Authorization': 'OAuth oauth_signature_method="foo"'}
headers.update(URLENCODED)
self.assertRaises(errors.InvalidRequestError, e._create_request,
'https://a.b/',
'GET',
'oauth_signature=foo',
headers)
def test_duplicate_params(self):
"""Ensure params are only supplied once"""
v = RequestValidator()
e = BaseEndpoint(v)
self.assertRaises(errors.InvalidRequestError, e._create_request,
'https://a.b/?oauth_version=a&oauth_version=b',
'GET', None, URLENCODED)
self.assertRaises(errors.InvalidRequestError, e._create_request,
'https://a.b/', 'GET', 'oauth_version=a&oauth_version=b',
URLENCODED)
def test_mandated_params(self):
"""Ensure all mandatory params are present."""
v = RequestValidator()
e = BaseEndpoint(v)
r = e._create_request('https://a.b/', 'GET',
'oauth_signature=a&oauth_consumer_key=b&oauth_nonce',
URLENCODED)
self.assertRaises(errors.InvalidRequestError,
e._check_mandatory_parameters, r)
def test_oauth_version(self):
"""OAuth version must be 1.0 if present."""
v = RequestValidator()
e = BaseEndpoint(v)
r = e._create_request('https://a.b/', 'GET',
('oauth_signature=a&oauth_consumer_key=b&oauth_nonce=c&'
'oauth_timestamp=a&oauth_signature_method=RSA-SHA1&'
'oauth_version=2.0'),
URLENCODED)
self.assertRaises(errors.InvalidRequestError,
e._check_mandatory_parameters, r)
def test_oauth_timestamp(self):
"""Check for a valid UNIX timestamp."""
v = RequestValidator()
e = BaseEndpoint(v)
# Invalid timestamp length, must be 10
r = e._create_request('https://a.b/', 'GET',
('oauth_signature=a&oauth_consumer_key=b&oauth_nonce=c&'
'oauth_version=1.0&oauth_signature_method=RSA-SHA1&'
'oauth_timestamp=123456789'),
URLENCODED)
self.assertRaises(errors.InvalidRequestError,
e._check_mandatory_parameters, r)
# Invalid timestamp age, must be younger than 10 minutes
r = e._create_request('https://a.b/', 'GET',
('oauth_signature=a&oauth_consumer_key=b&oauth_nonce=c&'
'oauth_version=1.0&oauth_signature_method=RSA-SHA1&'
'oauth_timestamp=1234567890'),
URLENCODED)
self.assertRaises(errors.InvalidRequestError,
e._check_mandatory_parameters, r)
# Timestamp must be an integer
r = e._create_request('https://a.b/', 'GET',
('oauth_signature=a&oauth_consumer_key=b&oauth_nonce=c&'
'oauth_version=1.0&oauth_signature_method=RSA-SHA1&'
'oauth_timestamp=123456789a'),
URLENCODED)
self.assertRaises(errors.InvalidRequestError,
e._check_mandatory_parameters, r)
def test_signature_method_validation(self):
"""Ensure valid signature method is used."""
body = ('oauth_signature=a&oauth_consumer_key=b&oauth_nonce=c&'
'oauth_version=1.0&oauth_signature_method=%s&'
'oauth_timestamp=1234567890')
uri = 'https://example.com/'
class HMACValidator(RequestValidator):
@property
def allowed_signature_methods(self):
return (SIGNATURE_HMAC,)
v = HMACValidator()
e = BaseEndpoint(v)
r = e._create_request(uri, 'GET', body % 'RSA-SHA1', URLENCODED)
self.assertRaises(errors.InvalidSignatureMethodError,
e._check_mandatory_parameters, r)
r = e._create_request(uri, 'GET', body % 'PLAINTEXT', URLENCODED)
self.assertRaises(errors.InvalidSignatureMethodError,
e._check_mandatory_parameters, r)
r = e._create_request(uri, 'GET', body % 'shibboleth', URLENCODED)
self.assertRaises(errors.InvalidSignatureMethodError,
e._check_mandatory_parameters, r)
class RSAValidator(RequestValidator):
@property
def allowed_signature_methods(self):
return (SIGNATURE_RSA,)
v = RSAValidator()
e = BaseEndpoint(v)
r = e._create_request(uri, 'GET', body % 'HMAC-SHA1', URLENCODED)
self.assertRaises(errors.InvalidSignatureMethodError,
e._check_mandatory_parameters, r)
r = e._create_request(uri, 'GET', body % 'PLAINTEXT', URLENCODED)
self.assertRaises(errors.InvalidSignatureMethodError,
e._check_mandatory_parameters, r)
r = e._create_request(uri, 'GET', body % 'shibboleth', URLENCODED)
self.assertRaises(errors.InvalidSignatureMethodError,
e._check_mandatory_parameters, r)
class PlainValidator(RequestValidator):
@property
def allowed_signature_methods(self):
return (SIGNATURE_PLAINTEXT,)
v = PlainValidator()
e = BaseEndpoint(v)
r = e._create_request(uri, 'GET', body % 'HMAC-SHA1', URLENCODED)
self.assertRaises(errors.InvalidSignatureMethodError,
e._check_mandatory_parameters, r)
r = e._create_request(uri, 'GET', body % 'RSA-SHA1', URLENCODED)
self.assertRaises(errors.InvalidSignatureMethodError,
e._check_mandatory_parameters, r)
r = e._create_request(uri, 'GET', body % 'shibboleth', URLENCODED)
self.assertRaises(errors.InvalidSignatureMethodError,
e._check_mandatory_parameters, r)
class ClientValidator(RequestValidator):
clients = ['foo']
nonces = [('foo', 'once', '1234567891', 'fez')]
owners = {'foo': ['abcdefghijklmnopqrstuvxyz', 'fez']}
assigned_realms = {('foo', 'abcdefghijklmnopqrstuvxyz'): 'photos'}
verifiers = {('foo', 'fez'): 'shibboleth'}
@property
def client_key_length(self):
return 1, 30
@property
def request_token_length(self):
return 1, 30
@property
def access_token_length(self):
return 1, 30
@property
def nonce_length(self):
return 2, 30
@property
def verifier_length(self):
return 2, 30
@property
def realms(self):
return ['photos']
@property
def timestamp_lifetime(self):
# Disabled check to allow hardcoded verification signatures
return 1000000000
@property
def dummy_client(self):
return 'dummy'
@property
def dummy_request_token(self):
return 'dumbo'
@property
def dummy_access_token(self):
return 'dumbo'
def validate_timestamp_and_nonce(self, client_key, timestamp, nonce,
request, request_token=None, access_token=None):
resource_owner_key = request_token if request_token else access_token
return not (client_key, nonce, timestamp, resource_owner_key) in self.nonces
def validate_client_key(self, client_key):
return client_key in self.clients
def validate_access_token(self, client_key, access_token, request):
return (self.owners.get(client_key) and
access_token in self.owners.get(client_key))
def validate_request_token(self, client_key, request_token, request):
return (self.owners.get(client_key) and
request_token in self.owners.get(client_key))
def validate_requested_realm(self, client_key, realm, request):
return True
def validate_realm(self, client_key, access_token, request, uri=None,
required_realm=None):
return (client_key, access_token) in self.assigned_realms
def validate_verifier(self, client_key, request_token, verifier,
request):
return ((client_key, request_token) in self.verifiers and
safe_string_equals(verifier, self.verifiers.get(
(client_key, request_token))))
def validate_redirect_uri(self, client_key, redirect_uri, request):
return redirect_uri.startswith('http://client.example.com/')
def get_client_secret(self, client_key, request):
return 'super secret'
def get_access_token_secret(self, client_key, access_token, request):
return 'even more secret'
def get_request_token_secret(self, client_key, request_token, request):
return 'even more secret'
def get_rsa_key(self, client_key, request):
return ("-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNA"
"DCBiQKBgQDVLQCATX8iK+aZuGVdkGb6uiar\nLi/jqFwL1dYj0JLIsdQc"
"KaMWtPC06K0+vI+RRZcjKc6sNB9/7kJcKN9Ekc9BUxyT\n/D09Cz47cmC"
"YsUoiW7G8NSqbE4wPiVpGkJRzFAxaCWwOSSQ+lpC9vwxnvVQfOoZ1\nnp"
"mWbCdA0iTxsMahwQIDAQAB\n-----END PUBLIC KEY-----")
class SignatureVerificationTest(TestCase):
def setUp(self):
v = ClientValidator()
self.e = BaseEndpoint(v)
self.uri = 'https://example.com/'
self.sig = ('oauth_signature=%s&'
'oauth_timestamp=1234567890&'
'oauth_nonce=abcdefghijklmnopqrstuvwxyz&'
'oauth_version=1.0&'
'oauth_signature_method=%s&'
'oauth_token=abcdefghijklmnopqrstuvxyz&'
'oauth_consumer_key=foo')
def test_signature_too_short(self):
short_sig = ('oauth_signature=fmrXnTF4lO4o%2BD0%2FlZaJHP%2FXqEY&'
'oauth_timestamp=1234567890&'
'oauth_nonce=abcdefghijklmnopqrstuvwxyz&'
'oauth_version=1.0&oauth_signature_method=HMAC-SHA1&'
'oauth_token=abcdefghijklmnopqrstuvxyz&'
'oauth_consumer_key=foo')
r = self.e._create_request(self.uri, 'GET', short_sig, URLENCODED)
self.assertFalse(self.e._check_signature(r))
plain = ('oauth_signature=correctlengthbutthewrongcontent1111&'
'oauth_timestamp=1234567890&'
'oauth_nonce=abcdefghijklmnopqrstuvwxyz&'
'oauth_version=1.0&oauth_signature_method=PLAINTEXT&'
'oauth_token=abcdefghijklmnopqrstuvxyz&'
'oauth_consumer_key=foo')
r = self.e._create_request(self.uri, 'GET', plain, URLENCODED)
self.assertFalse(self.e._check_signature(r))
def test_hmac_signature(self):
hmac_sig = "fmrXnTF4lO4o%2BD0%2FlZaJHP%2FXqEY%3D"
sig = self.sig % (hmac_sig, "HMAC-SHA1")
r = self.e._create_request(self.uri, 'GET', sig, URLENCODED)
self.assertTrue(self.e._check_signature(r))
def test_rsa_signature(self):
rsa_sig = ("fxFvCx33oKlR9wDquJ%2FPsndFzJphyBa3RFPPIKi3flqK%2BJ7yIrMVbH"
"YTM%2FLHPc7NChWz4F4%2FzRA%2BDN1k08xgYGSBoWJUOW6VvOQ6fbYhMA"
"FkOGYbuGDbje487XMzsAcv6ZjqZHCROSCk5vofgLk2SN7RZ3OrgrFzf4in"
"xetClqA%3D")
sig = self.sig % (rsa_sig, "RSA-SHA1")
r = self.e._create_request(self.uri, 'GET', sig, URLENCODED)
self.assertTrue(self.e._check_signature(r))
def test_plaintext_signature(self):
plain_sig = "super%252520secret%26even%252520more%252520secret"
sig = self.sig % (plain_sig, "PLAINTEXT")
r = self.e._create_request(self.uri, 'GET', sig, URLENCODED)
self.assertTrue(self.e._check_signature(r))
|
bsd-3-clause
|
[
504,
636,
2443,
363,
492,
2649,
63,
5955,
12,
3679,
63,
646,
199,
199,
504,
1683,
492,
10079,
199,
504,
295,
492,
1007,
199,
504,
29222,
2796,
492,
7640,
199,
199,
504,
9725,
773,
14,
2330,
492,
5048,
63,
875,
63,
11332,
199,
504,
9725,
773,
14,
6126,
17,
492,
6810,
12,
4784,
8640,
199,
504,
9725,
773,
14,
6126,
17,
14,
8973,
12248,
25,
492,
2552,
12,
5056,
13214,
63,
12115,
12,
5056,
13214,
63,
23034,
199,
504,
9725,
773,
14,
6126,
17,
14,
8973,
12248,
25,
492,
5056,
13214,
63,
2749,
33,
2919,
2472,
199,
504,
9725,
773,
14,
6126,
17,
14,
8973,
12248,
25,
14,
14461,
492,
4784,
3264,
11442,
12,
3523,
11442,
421,
199,
2632,
742,
6012,
36,
275,
2420,
2714,
13,
804,
582,
298,
3578,
15,
88,
13,
1544,
13,
964,
13,
21886,
3570,
421,
199,
533,
3523,
11442,
774,
8,
1746,
304,
339,
347,
3613,
8,
277,
304,
267,
291,
14,
11034,
275,
10079,
8,
1650,
29,
2017,
8640,
9,
267,
291,
14,
11034,
14,
6541,
63,
5233,
63,
2474,
275,
788,
23034,
13,
8461,
17,
418,
267,
291,
14,
11034,
14,
3954,
63,
27674,
275,
11624,
267,
291,
14,
6520,
275,
4784,
3264,
11442,
8,
277,
14,
11034,
9,
267,
291,
14,
1258,
275,
6810,
360,
1421,
297,
3233,
63,
2302,
534,
2859,
921,
67,
14,
66,
15,
2894,
358,
267,
291,
14,
2302,
12,
291,
14,
2139,
12,
291,
14,
2030,
275,
291,
14,
1258,
14,
1037,
8,
355,
283,
2859,
921,
73,
14,
66,
15,
1069,
63,
1418,
358,
339,
347,
511,
63,
4266,
63,
19817,
434,
8,
277,
304,
267,
5108,
12,
2323,
12,
485,
275,
291,
14,
1258,
14,
1037,
360,
1014,
921,
73,
14,
66,
15,
1069,
63,
1418,
358,
267,
394,
12,
330,
12,
308,
275,
291,
14,
6520,
14,
981,
63,
1069,
63,
1418,
63,
1310,
8,
355,
5108,
12,
2323,
29,
2139,
9,
267,
291,
14,
629,
8,
83,
12,
8290,
9,
267,
291,
14,
4080,
360,
24824,
63,
5545,
63,
3922,
297,
330,
9,
339,
347,
511,
63,
4752,
63,
3214,
8,
277,
304,
267,
394,
12,
330,
12,
308,
275,
291,
14,
6520,
14,
981,
63,
1069,
63,
1418,
63,
1310,
8,
277,
14,
2302,
9,
267,
291,
14,
629,
8,
83,
12,
8290,
9,
267,
291,
14,
4080,
360,
3197,
63,
1069,
297,
330,
9,
339,
347,
511,
63,
5233,
63,
2474,
8,
277,
304,
267,
2323,
275,
1052,
267,
2323,
459,
11626,
418,
275,
291,
14,
2139,
459,
11626,
2278,
1814,
8,
355,
283,
23034,
297,
283,
12115,
358,
267,
394,
12,
330,
12,
308,
275,
291,
14,
6520,
14,
981,
63,
1069,
63,
1418,
63,
1310,
8,
355,
291,
14,
2302,
12,
2323,
29,
2139,
9,
267,
291,
14,
629,
8,
83,
12,
8290,
9,
267,
291,
14,
4080,
360,
3197,
63,
5233,
63,
765,
297,
330,
9,
339,
347,
511,
63,
3197,
63,
1023,
8,
277,
304,
267,
2323,
275,
1052,
267,
2323,
459,
11626,
418,
275,
291,
14,
2139,
459,
11626,
2278,
1814,
8,
355,
283,
17,
14,
16,
297,
283,
18,
14,
16,
358,
267,
394,
12,
330,
12,
308,
275,
291,
14,
6520,
14,
981,
63,
1069,
63,
1418,
63,
1310,
8,
355,
291,
14,
2302,
12,
2323,
29,
2139,
9,
267,
291,
14,
629,
8,
83,
12,
8290,
9,
267,
291,
14,
4080,
360,
3197,
63,
1069,
297,
330,
9,
339,
347,
511,
63,
16340,
63,
3954,
8,
277,
304,
267,
2323,
275,
1052,
267,
367,
3851,
315,
661,
11272,
614,
297,
283,
20,
6690,
29555,
297,
283,
11272,
43,
735,
288,
2323,
459,
11626,
418,
275,
1007,
360,
3954,
21024,
68,
10,
75,
31,
6949,
490,
283,
3954,
5961,
83,
4507,
450,
3851,
12,
2151,
291,
14,
2139,
459,
11626,
1105,
288,
394,
12,
330,
12,
308,
275,
291,
14,
6520,
14,
981,
63,
1069,
63,
1418,
63,
1310,
8,
490,
291,
14,
2302,
12,
2323,
29,
2139,
9,
288,
291,
14,
629,
8,
83,
12,
8290,
9,
288,
291,
14,
4080,
360,
3197,
63,
1069,
297,
330,
9,
339,
347,
511,
63,
1258,
63,
498,
63,
1074,
8,
277,
304,
267,
291,
14,
11034,
14,
1074,
63,
1258,
63,
498,
14,
1107,
63,
585,
275,
756,
267,
394,
12,
330,
12,
308,
275,
291,
14,
6520,
14,
981,
63,
1069,
63,
1418,
63,
1310,
8,
355,
291,
14,
2302,
12,
2323,
29,
277,
14,
2139,
9,
267,
291,
14,
629,
8,
83,
12,
8290,
9,
267,
291,
14,
4080,
360,
3197,
63,
1069,
297,
330,
9,
339,
347,
511,
63,
10667,
1074,
8,
277,
304,
267,
291,
14,
11034,
14,
1074,
63,
10667,
14,
1107,
63,
585,
275,
756,
267,
394,
12,
330,
12,
308,
275,
291,
14,
6520,
14,
981,
63,
1069,
63,
1418,
63,
1310,
8,
355,
291,
14,
2302,
12,
2323,
29,
277,
14,
2139,
9,
267,
291,
14,
629,
8,
83,
12,
8290,
9,
267,
291,
14,
4080,
360,
3197,
63,
1069,
297,
330,
9,
339,
347,
511,
63,
19817,
63,
4266,
8,
277,
304,
267,
408,
13913,
7799,
365,
30163,
701,
849,
1041,
267,
373,
275,
4784,
8640,
342,
267,
325,
275,
3523,
11442,
8,
86,
9,
267,
286,
275,
6810,
360,
1421,
358,
267,
399,
12,
394,
12,
330,
275,
286,
14,
1037,
360,
1014,
921,
2694,
14,
957,
358,
267,
519,
275,
325,
423,
981,
63,
1069,
8,
85,
12,
283,
2970,
297,
330,
12,
394,
9,
267,
291,
14,
1855,
8,
2550,
14,
607,
7817,
7836,
547,
12,
355,
325,
423,
1074,
63,
5545,
63,
4416,
12,
519,
9,
339,
347,
511,
63,
6048,
63,
1365,
63,
1162,
8,
277,
304,
267,
408,
1799,
367,
9250,
1862,
624,
267,
373,
275,
4784,
8640,
342,
267,
325,
275,
3523,
11442,
8,
86,
9,
267,
291,
14,
1855,
8,
2550,
14,
26585,
12,
325,
423,
981,
63,
1069,
12,
355,
283,
2859,
921,
65,
14,
66,
10197,
6126,
63,
5233,
63,
765,
29,
23034,
13,
8461,
17,
297,
355,
283,
2970,
297,
283,
6126,
63,
1023,
29,
1421,
297,
2851,
742,
6012,
36,
9,
267,
2323,
275,
791,
11626,
356,
283,
12906,
9725,
63,
5233,
628,
1421,
2,
936,
267,
2323
] |
[
636,
2443,
363,
492,
2649,
63,
5955,
12,
3679,
63,
646,
199,
199,
504,
1683,
492,
10079,
199,
504,
295,
492,
1007,
199,
504,
29222,
2796,
492,
7640,
199,
199,
504,
9725,
773,
14,
2330,
492,
5048,
63,
875,
63,
11332,
199,
504,
9725,
773,
14,
6126,
17,
492,
6810,
12,
4784,
8640,
199,
504,
9725,
773,
14,
6126,
17,
14,
8973,
12248,
25,
492,
2552,
12,
5056,
13214,
63,
12115,
12,
5056,
13214,
63,
23034,
199,
504,
9725,
773,
14,
6126,
17,
14,
8973,
12248,
25,
492,
5056,
13214,
63,
2749,
33,
2919,
2472,
199,
504,
9725,
773,
14,
6126,
17,
14,
8973,
12248,
25,
14,
14461,
492,
4784,
3264,
11442,
12,
3523,
11442,
421,
199,
2632,
742,
6012,
36,
275,
2420,
2714,
13,
804,
582,
298,
3578,
15,
88,
13,
1544,
13,
964,
13,
21886,
3570,
421,
199,
533,
3523,
11442,
774,
8,
1746,
304,
339,
347,
3613,
8,
277,
304,
267,
291,
14,
11034,
275,
10079,
8,
1650,
29,
2017,
8640,
9,
267,
291,
14,
11034,
14,
6541,
63,
5233,
63,
2474,
275,
788,
23034,
13,
8461,
17,
418,
267,
291,
14,
11034,
14,
3954,
63,
27674,
275,
11624,
267,
291,
14,
6520,
275,
4784,
3264,
11442,
8,
277,
14,
11034,
9,
267,
291,
14,
1258,
275,
6810,
360,
1421,
297,
3233,
63,
2302,
534,
2859,
921,
67,
14,
66,
15,
2894,
358,
267,
291,
14,
2302,
12,
291,
14,
2139,
12,
291,
14,
2030,
275,
291,
14,
1258,
14,
1037,
8,
355,
283,
2859,
921,
73,
14,
66,
15,
1069,
63,
1418,
358,
339,
347,
511,
63,
4266,
63,
19817,
434,
8,
277,
304,
267,
5108,
12,
2323,
12,
485,
275,
291,
14,
1258,
14,
1037,
360,
1014,
921,
73,
14,
66,
15,
1069,
63,
1418,
358,
267,
394,
12,
330,
12,
308,
275,
291,
14,
6520,
14,
981,
63,
1069,
63,
1418,
63,
1310,
8,
355,
5108,
12,
2323,
29,
2139,
9,
267,
291,
14,
629,
8,
83,
12,
8290,
9,
267,
291,
14,
4080,
360,
24824,
63,
5545,
63,
3922,
297,
330,
9,
339,
347,
511,
63,
4752,
63,
3214,
8,
277,
304,
267,
394,
12,
330,
12,
308,
275,
291,
14,
6520,
14,
981,
63,
1069,
63,
1418,
63,
1310,
8,
277,
14,
2302,
9,
267,
291,
14,
629,
8,
83,
12,
8290,
9,
267,
291,
14,
4080,
360,
3197,
63,
1069,
297,
330,
9,
339,
347,
511,
63,
5233,
63,
2474,
8,
277,
304,
267,
2323,
275,
1052,
267,
2323,
459,
11626,
418,
275,
291,
14,
2139,
459,
11626,
2278,
1814,
8,
355,
283,
23034,
297,
283,
12115,
358,
267,
394,
12,
330,
12,
308,
275,
291,
14,
6520,
14,
981,
63,
1069,
63,
1418,
63,
1310,
8,
355,
291,
14,
2302,
12,
2323,
29,
2139,
9,
267,
291,
14,
629,
8,
83,
12,
8290,
9,
267,
291,
14,
4080,
360,
3197,
63,
5233,
63,
765,
297,
330,
9,
339,
347,
511,
63,
3197,
63,
1023,
8,
277,
304,
267,
2323,
275,
1052,
267,
2323,
459,
11626,
418,
275,
291,
14,
2139,
459,
11626,
2278,
1814,
8,
355,
283,
17,
14,
16,
297,
283,
18,
14,
16,
358,
267,
394,
12,
330,
12,
308,
275,
291,
14,
6520,
14,
981,
63,
1069,
63,
1418,
63,
1310,
8,
355,
291,
14,
2302,
12,
2323,
29,
2139,
9,
267,
291,
14,
629,
8,
83,
12,
8290,
9,
267,
291,
14,
4080,
360,
3197,
63,
1069,
297,
330,
9,
339,
347,
511,
63,
16340,
63,
3954,
8,
277,
304,
267,
2323,
275,
1052,
267,
367,
3851,
315,
661,
11272,
614,
297,
283,
20,
6690,
29555,
297,
283,
11272,
43,
735,
288,
2323,
459,
11626,
418,
275,
1007,
360,
3954,
21024,
68,
10,
75,
31,
6949,
490,
283,
3954,
5961,
83,
4507,
450,
3851,
12,
2151,
291,
14,
2139,
459,
11626,
1105,
288,
394,
12,
330,
12,
308,
275,
291,
14,
6520,
14,
981,
63,
1069,
63,
1418,
63,
1310,
8,
490,
291,
14,
2302,
12,
2323,
29,
2139,
9,
288,
291,
14,
629,
8,
83,
12,
8290,
9,
288,
291,
14,
4080,
360,
3197,
63,
1069,
297,
330,
9,
339,
347,
511,
63,
1258,
63,
498,
63,
1074,
8,
277,
304,
267,
291,
14,
11034,
14,
1074,
63,
1258,
63,
498,
14,
1107,
63,
585,
275,
756,
267,
394,
12,
330,
12,
308,
275,
291,
14,
6520,
14,
981,
63,
1069,
63,
1418,
63,
1310,
8,
355,
291,
14,
2302,
12,
2323,
29,
277,
14,
2139,
9,
267,
291,
14,
629,
8,
83,
12,
8290,
9,
267,
291,
14,
4080,
360,
3197,
63,
1069,
297,
330,
9,
339,
347,
511,
63,
10667,
1074,
8,
277,
304,
267,
291,
14,
11034,
14,
1074,
63,
10667,
14,
1107,
63,
585,
275,
756,
267,
394,
12,
330,
12,
308,
275,
291,
14,
6520,
14,
981,
63,
1069,
63,
1418,
63,
1310,
8,
355,
291,
14,
2302,
12,
2323,
29,
277,
14,
2139,
9,
267,
291,
14,
629,
8,
83,
12,
8290,
9,
267,
291,
14,
4080,
360,
3197,
63,
1069,
297,
330,
9,
339,
347,
511,
63,
19817,
63,
4266,
8,
277,
304,
267,
408,
13913,
7799,
365,
30163,
701,
849,
1041,
267,
373,
275,
4784,
8640,
342,
267,
325,
275,
3523,
11442,
8,
86,
9,
267,
286,
275,
6810,
360,
1421,
358,
267,
399,
12,
394,
12,
330,
275,
286,
14,
1037,
360,
1014,
921,
2694,
14,
957,
358,
267,
519,
275,
325,
423,
981,
63,
1069,
8,
85,
12,
283,
2970,
297,
330,
12,
394,
9,
267,
291,
14,
1855,
8,
2550,
14,
607,
7817,
7836,
547,
12,
355,
325,
423,
1074,
63,
5545,
63,
4416,
12,
519,
9,
339,
347,
511,
63,
6048,
63,
1365,
63,
1162,
8,
277,
304,
267,
408,
1799,
367,
9250,
1862,
624,
267,
373,
275,
4784,
8640,
342,
267,
325,
275,
3523,
11442,
8,
86,
9,
267,
291,
14,
1855,
8,
2550,
14,
26585,
12,
325,
423,
981,
63,
1069,
12,
355,
283,
2859,
921,
65,
14,
66,
10197,
6126,
63,
5233,
63,
765,
29,
23034,
13,
8461,
17,
297,
355,
283,
2970,
297,
283,
6126,
63,
1023,
29,
1421,
297,
2851,
742,
6012,
36,
9,
267,
2323,
275,
791,
11626,
356,
283,
12906,
9725,
63,
5233,
628,
1421,
2,
936,
267,
2323,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
felipebetancur/omim
|
data/benchmarks/cmd_results_viewer.py
|
53
|
2305
|
import math
import sys
f1 = open(sys.argv[2], "r")
lns1 = f1.readlines()
lns1 = [l.split(" ") for l in lns1]
bench_cfg = {}
for l in lns1:
c_name = l[1]
is_country = (len(l) == 3)
bench_cfg[l[1]] = []
bench_cfg[l[1]].append(is_country)
if len(l) > 0:
if not is_country:
bench_cfg[c_name].append(float(l[2]))
bench_cfg[c_name].append(float(l[3]))
bench_cfg[c_name].append(float(l[4]))
bench_cfg[c_name].append(float(l[5]))
bench_cfg[c_name].append(int(l[6]))
else:
bench_cfg[c_name].append(int(l[2]))
f = open(sys.argv[1], "r")
lns = f.readlines()
def scale_level(r):
dx = 360.0 / (r[2] - r[0])
dy = 360.0 / (r[3] - r[1])
v = (dx + dy) / 2.0
l = math.log(v) / math.log(2.0) + 1
if l > 17:
l = 17
if l < 0:
return 0
else:
return math.floor(l + 0.5)
lns = [l.split(" ") for l in lns]
rev = {}
for l in lns:
rev_name = l[1]
start_time = l[2]
bench_name = l[3]
rect = [float(l[4]), float(l[5]), float(l[6]), float(l[7])]
dur = float(l[8])
if not rev.has_key(rev_name):
rev[rev_name] = {}
if not rev[rev_name].has_key(start_time):
rev[rev_name][start_time] = {}
if not rev[rev_name][start_time].has_key(bench_name):
rev[rev_name][start_time][bench_name] = {}
scale = scale_level(rect)
if not rev[rev_name][start_time][bench_name].has_key(scale):
rev[rev_name][start_time][bench_name][scale] = 0
rev[rev_name][start_time][bench_name][scale] += dur
for rev_name in rev.keys():
print rev_name
for start_time in rev[rev_name].keys():
print "\t", start_time
for bench_name in rev[rev_name][start_time].keys():
cfg_info = bench_cfg[bench_name]
if not cfg_info[0]:
print "\t\t", bench_name, "[", cfg_info[1], cfg_info[2], cfg_info[3], cfg_info[4], "]", "endScale=", cfg_info[5]
else:
print "\t\t", bench_name, "endScale=", cfg_info[1]
k = rev[rev_name][start_time][bench_name].keys()
k.sort()
for scale_level in k:
print "\t\t\t scale: ", scale_level, ", duration: " , rev[rev_name][start_time][bench_name][scale_level]
|
apache-2.0
|
[
646,
3473,
199,
646,
984,
421,
199,
70,
17,
275,
1551,
8,
1274,
14,
3020,
59,
18,
467,
298,
82,
531,
199,
76,
561,
17,
275,
289,
17,
14,
9684,
342,
199,
76,
561,
17,
275,
359,
76,
14,
1294,
480,
6099,
367,
634,
315,
634,
561,
17,
61,
199,
199,
16571,
63,
4128,
275,
1052,
199,
199,
509,
634,
315,
634,
561,
17,
26,
272,
286,
63,
354,
275,
634,
59,
17,
61,
272,
365,
63,
6063,
275,
334,
552,
8,
76,
9,
508,
650,
9,
272,
26456,
63,
4128,
59,
76,
59,
17,
2677,
275,
942,
272,
26456,
63,
4128,
59,
76,
59,
17,
20230,
740,
8,
374,
63,
6063,
9,
5591,
340,
822,
8,
76,
9,
690,
378,
26,
267,
340,
440,
365,
63,
6063,
26,
288,
26456,
63,
4128,
59,
67,
63,
354,
1055,
740,
8,
1609,
8,
76,
59,
18,
2459,
288,
26456,
63,
4128,
59,
67,
63,
354,
1055,
740,
8,
1609,
8,
76,
59,
19,
2459,
288,
26456,
63,
4128,
59,
67,
63,
354,
1055,
740,
8,
1609,
8,
76,
59,
20,
2459,
288,
26456,
63,
4128,
59,
67,
63,
354,
1055,
740,
8,
1609,
8,
76,
59,
21,
2459,
288,
26456,
63,
4128,
59,
67,
63,
354,
1055,
740,
8,
442,
8,
76,
59,
22,
2459,
267,
587,
26,
288,
26456,
63,
4128,
59,
67,
63,
354,
1055,
740,
8,
442,
8,
76,
59,
18,
2459,
199,
199,
70,
275,
1551,
8,
1274,
14,
3020,
59,
17,
467,
298,
82,
531,
199,
76,
561,
275,
289,
14,
9684,
342,
199,
199,
318,
4666,
63,
1896,
8,
82,
304,
272,
11868,
275,
19434,
14,
16,
1182,
334,
82,
59,
18,
61,
446,
519,
59,
16,
566,
272,
13119,
275,
19434,
14,
16,
1182,
334,
82,
59,
19,
61,
446,
519,
59,
17,
566,
339,
373,
275,
334,
8373,
435,
13119,
9,
1182,
499,
14,
16,
339,
634,
275,
3473,
14,
793,
8,
86,
9,
1182,
3473,
14,
793,
8,
18,
14,
16,
9,
435,
413,
272,
340,
634,
690,
5557,
26,
267,
634,
275,
5557,
272,
340,
634,
665,
378,
26,
267,
372,
378,
272,
587,
26,
267,
372,
3473,
14,
11289,
8,
76,
435,
378,
14,
21,
9,
199,
199,
76,
561,
275,
359,
76,
14,
1294,
480,
6099,
367,
634,
315,
634,
561,
61,
199,
199,
4964,
275,
1052,
199,
199,
509,
634,
315,
634,
561,
26,
272,
6822,
63,
354,
275,
634,
59,
17,
61,
272,
1343,
63,
521,
275,
634,
59,
18,
61,
272,
26456,
63,
354,
275,
634,
59,
19,
61,
339,
8626,
275,
359,
1609,
8,
76,
59,
20,
2522,
2069,
8,
76,
59,
21,
2522,
2069,
8,
76,
59,
22,
2522,
2069,
8,
76,
59,
23,
12457,
272,
366,
300,
275,
2069,
8,
76,
59,
24,
566,
272,
340,
440,
6822,
14,
1989,
63,
498,
8,
4964,
63,
354,
304,
267,
6822,
59,
4964,
63,
354,
61,
275,
1052,
272,
340,
440,
6822,
59,
4964,
63,
354,
1055,
1989,
63,
498,
8,
928,
63,
521,
304,
267,
6822,
59,
4964,
63,
354,
1527,
928,
63,
521,
61,
275,
1052,
272,
340,
440,
6822,
59,
4964,
63,
354,
1527,
928,
63,
521,
1055,
1989,
63,
498,
8,
16571,
63,
354,
304,
267,
6822,
59,
4964,
63,
354,
1527,
928,
63,
521,
1527,
16571,
63,
354,
61,
275,
1052,
339,
4666,
275,
4666,
63,
1896,
8,
1201,
9,
339,
340,
440,
6822,
59,
4964,
63,
354,
1527,
928,
63,
521,
1527,
16571,
63,
354,
1055,
1989,
63,
498,
8,
3467,
304,
267,
6822,
59,
4964,
63,
354,
1527,
928,
63,
521,
1527,
16571,
63,
354,
1527,
3467,
61,
275,
378,
339,
6822,
59,
4964,
63,
354,
1527,
928,
63,
521,
1527,
16571,
63,
354,
1527,
3467,
61,
847,
366,
300,
199,
199,
509,
6822,
63,
354,
315,
6822,
14,
1612,
837,
272,
870,
6822,
63,
354,
272,
367,
1343,
63,
521,
315,
6822,
59,
4964,
63,
354,
1055,
1612,
837,
267,
870,
1867,
84,
401,
1343,
63,
521,
267,
367,
26456,
63,
354,
315,
6822,
59,
4964,
63,
354,
1527,
928,
63,
521,
1055,
1612,
837,
953,
4810,
63,
815,
275,
26456,
63,
4128,
59,
16571,
63,
354,
61,
288,
340,
440,
4810,
63,
815,
59,
16,
2189,
355,
870,
1867,
84,
60,
84,
401,
26456,
63,
354,
12,
7369,
401,
4810,
63,
815,
59,
17,
467,
4810,
63,
815,
59,
18,
467,
4810,
63,
815,
59,
19,
467,
4810,
63,
815,
59,
20,
467,
298,
11472,
298,
500,
9944,
11107,
4810,
63,
815,
59,
21,
61,
288,
587,
26,
355,
870,
1867,
84,
60,
84,
401,
26456,
63,
354,
12,
298,
500,
9944,
11107,
4810,
63,
815,
59,
17,
61,
288,
1022,
275,
6822,
59,
4964,
63,
354,
1527,
928,
63,
521,
1527,
16571,
63,
354,
1055,
1612,
342,
288,
1022,
14,
3191,
342,
288,
367,
4666,
63,
1896,
315,
1022,
26,
355,
870,
1867,
84,
60,
84,
60,
84,
4666,
26,
3872,
4666,
63,
1896,
12,
3872,
7373,
26,
298,
2360,
6822,
59,
4964,
63,
354,
1527,
928,
63,
521,
1527,
16571,
63,
354,
1527,
3467,
63,
1896,
61,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
3473,
199,
646,
984,
421,
199,
70,
17,
275,
1551,
8,
1274,
14,
3020,
59,
18,
467,
298,
82,
531,
199,
76,
561,
17,
275,
289,
17,
14,
9684,
342,
199,
76,
561,
17,
275,
359,
76,
14,
1294,
480,
6099,
367,
634,
315,
634,
561,
17,
61,
199,
199,
16571,
63,
4128,
275,
1052,
199,
199,
509,
634,
315,
634,
561,
17,
26,
272,
286,
63,
354,
275,
634,
59,
17,
61,
272,
365,
63,
6063,
275,
334,
552,
8,
76,
9,
508,
650,
9,
272,
26456,
63,
4128,
59,
76,
59,
17,
2677,
275,
942,
272,
26456,
63,
4128,
59,
76,
59,
17,
20230,
740,
8,
374,
63,
6063,
9,
5591,
340,
822,
8,
76,
9,
690,
378,
26,
267,
340,
440,
365,
63,
6063,
26,
288,
26456,
63,
4128,
59,
67,
63,
354,
1055,
740,
8,
1609,
8,
76,
59,
18,
2459,
288,
26456,
63,
4128,
59,
67,
63,
354,
1055,
740,
8,
1609,
8,
76,
59,
19,
2459,
288,
26456,
63,
4128,
59,
67,
63,
354,
1055,
740,
8,
1609,
8,
76,
59,
20,
2459,
288,
26456,
63,
4128,
59,
67,
63,
354,
1055,
740,
8,
1609,
8,
76,
59,
21,
2459,
288,
26456,
63,
4128,
59,
67,
63,
354,
1055,
740,
8,
442,
8,
76,
59,
22,
2459,
267,
587,
26,
288,
26456,
63,
4128,
59,
67,
63,
354,
1055,
740,
8,
442,
8,
76,
59,
18,
2459,
199,
199,
70,
275,
1551,
8,
1274,
14,
3020,
59,
17,
467,
298,
82,
531,
199,
76,
561,
275,
289,
14,
9684,
342,
199,
199,
318,
4666,
63,
1896,
8,
82,
304,
272,
11868,
275,
19434,
14,
16,
1182,
334,
82,
59,
18,
61,
446,
519,
59,
16,
566,
272,
13119,
275,
19434,
14,
16,
1182,
334,
82,
59,
19,
61,
446,
519,
59,
17,
566,
339,
373,
275,
334,
8373,
435,
13119,
9,
1182,
499,
14,
16,
339,
634,
275,
3473,
14,
793,
8,
86,
9,
1182,
3473,
14,
793,
8,
18,
14,
16,
9,
435,
413,
272,
340,
634,
690,
5557,
26,
267,
634,
275,
5557,
272,
340,
634,
665,
378,
26,
267,
372,
378,
272,
587,
26,
267,
372,
3473,
14,
11289,
8,
76,
435,
378,
14,
21,
9,
199,
199,
76,
561,
275,
359,
76,
14,
1294,
480,
6099,
367,
634,
315,
634,
561,
61,
199,
199,
4964,
275,
1052,
199,
199,
509,
634,
315,
634,
561,
26,
272,
6822,
63,
354,
275,
634,
59,
17,
61,
272,
1343,
63,
521,
275,
634,
59,
18,
61,
272,
26456,
63,
354,
275,
634,
59,
19,
61,
339,
8626,
275,
359,
1609,
8,
76,
59,
20,
2522,
2069,
8,
76,
59,
21,
2522,
2069,
8,
76,
59,
22,
2522,
2069,
8,
76,
59,
23,
12457,
272,
366,
300,
275,
2069,
8,
76,
59,
24,
566,
272,
340,
440,
6822,
14,
1989,
63,
498,
8,
4964,
63,
354,
304,
267,
6822,
59,
4964,
63,
354,
61,
275,
1052,
272,
340,
440,
6822,
59,
4964,
63,
354,
1055,
1989,
63,
498,
8,
928,
63,
521,
304,
267,
6822,
59,
4964,
63,
354,
1527,
928,
63,
521,
61,
275,
1052,
272,
340,
440,
6822,
59,
4964,
63,
354,
1527,
928,
63,
521,
1055,
1989,
63,
498,
8,
16571,
63,
354,
304,
267,
6822,
59,
4964,
63,
354,
1527,
928,
63,
521,
1527,
16571,
63,
354,
61,
275,
1052,
339,
4666,
275,
4666,
63,
1896,
8,
1201,
9,
339,
340,
440,
6822,
59,
4964,
63,
354,
1527,
928,
63,
521,
1527,
16571,
63,
354,
1055,
1989,
63,
498,
8,
3467,
304,
267,
6822,
59,
4964,
63,
354,
1527,
928,
63,
521,
1527,
16571,
63,
354,
1527,
3467,
61,
275,
378,
339,
6822,
59,
4964,
63,
354,
1527,
928,
63,
521,
1527,
16571,
63,
354,
1527,
3467,
61,
847,
366,
300,
199,
199,
509,
6822,
63,
354,
315,
6822,
14,
1612,
837,
272,
870,
6822,
63,
354,
272,
367,
1343,
63,
521,
315,
6822,
59,
4964,
63,
354,
1055,
1612,
837,
267,
870,
1867,
84,
401,
1343,
63,
521,
267,
367,
26456,
63,
354,
315,
6822,
59,
4964,
63,
354,
1527,
928,
63,
521,
1055,
1612,
837,
953,
4810,
63,
815,
275,
26456,
63,
4128,
59,
16571,
63,
354,
61,
288,
340,
440,
4810,
63,
815,
59,
16,
2189,
355,
870,
1867,
84,
60,
84,
401,
26456,
63,
354,
12,
7369,
401,
4810,
63,
815,
59,
17,
467,
4810,
63,
815,
59,
18,
467,
4810,
63,
815,
59,
19,
467,
4810,
63,
815,
59,
20,
467,
298,
11472,
298,
500,
9944,
11107,
4810,
63,
815,
59,
21,
61,
288,
587,
26,
355,
870,
1867,
84,
60,
84,
401,
26456,
63,
354,
12,
298,
500,
9944,
11107,
4810,
63,
815,
59,
17,
61,
288,
1022,
275,
6822,
59,
4964,
63,
354,
1527,
928,
63,
521,
1527,
16571,
63,
354,
1055,
1612,
342,
288,
1022,
14,
3191,
342,
288,
367,
4666,
63,
1896,
315,
1022,
26,
355,
870,
1867,
84,
60,
84,
60,
84,
4666,
26,
3872,
4666,
63,
1896,
12,
3872,
7373,
26,
298,
2360,
6822,
59,
4964,
63,
354,
1527,
928,
63,
521,
1527,
16571,
63,
354,
1527,
3467,
63,
1896,
61,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
CongSmile/avocado-vt
|
virttest/step_editor.py
|
4
|
50724
|
#!/usr/bin/python
"""
Step file creator/editor.
:copyright: Red Hat Inc 2009
:author: mgoldish@redhat.com (Michael Goldish)
"""
import os
import glob
import shutil
import sys
import logging
import pygtk
import gtk
import ppm_utils
pygtk.require('2.0')
# General utilities
def corner_and_size_clipped(startpoint, endpoint, limits):
c0 = startpoint[:]
c1 = endpoint[:]
if c0[0] < 0:
c0[0] = 0
if c0[1] < 0:
c0[1] = 0
if c1[0] < 0:
c1[0] = 0
if c1[1] < 0:
c1[1] = 0
if c0[0] > limits[0] - 1:
c0[0] = limits[0] - 1
if c0[1] > limits[1] - 1:
c0[1] = limits[1] - 1
if c1[0] > limits[0] - 1:
c1[0] = limits[0] - 1
if c1[1] > limits[1] - 1:
c1[1] = limits[1] - 1
return ([min(c0[0], c1[0]),
min(c0[1], c1[1])],
[abs(c1[0] - c0[0]) + 1,
abs(c1[1] - c0[1]) + 1])
def key_event_to_qemu_string(event):
keymap = gtk.gdk.keymap_get_default()
keyvals = keymap.get_entries_for_keycode(event.hardware_keycode)
keyval = keyvals[0][0]
keyname = gtk.gdk.keyval_name(keyval)
keymap = {"Return": "ret",
"Tab": "tab",
"space": "spc",
"Left": "left",
"Right": "right",
"Up": "up",
"Down": "down",
"F1": "f1",
"F2": "f2",
"F3": "f3",
"F4": "f4",
"F5": "f5",
"F6": "f6",
"F7": "f7",
"F8": "f8",
"F9": "f9",
"F10": "f10",
"F11": "f11",
"F12": "f12",
"Escape": "esc",
"minus": "minus",
"equal": "equal",
"BackSpace": "backspace",
"comma": "comma",
"period": "dot",
"slash": "slash",
"Insert": "insert",
"Delete": "delete",
"Home": "home",
"End": "end",
"Page_Up": "pgup",
"Page_Down": "pgdn",
"Menu": "menu",
"semicolon": "0x27",
"backslash": "0x2b",
"apostrophe": "0x28",
"grave": "0x29",
"less": "0x2b",
"bracketleft": "0x1a",
"bracketright": "0x1b",
"Super_L": "0xdc",
"Super_R": "0xdb",
}
if ord('a') <= keyval <= ord('z') or ord('0') <= keyval <= ord('9'):
sr = keyname
elif keyname in keymap.keys():
sr = keymap[keyname]
else:
return ""
if event.state & gtk.gdk.CONTROL_MASK:
sr = "ctrl-" + str
if event.state & gtk.gdk.MOD1_MASK:
sr = "alt-" + str
if event.state & gtk.gdk.SHIFT_MASK:
sr = "shift-" + str
return sr
class StepMakerWindow(object):
def __init__(self):
# Window
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.window.set_title("Step Maker Window")
self.window.connect("delete-event", self.delete_event)
self.window.connect("destroy", self.destroy)
self.window.set_default_size(600, 800)
# Main box (inside a frame which is inside a VBox)
self.menu_vbox = gtk.VBox()
self.window.add(self.menu_vbox)
self.menu_vbox.show()
frame = gtk.Frame()
frame.set_border_width(10)
frame.set_shadow_type(gtk.SHADOW_NONE)
self.menu_vbox.pack_end(frame)
frame.show()
self.main_vbox = gtk.VBox(spacing=10)
frame.add(self.main_vbox)
self.main_vbox.show()
# EventBox
self.scrolledwindow = gtk.ScrolledWindow()
self.scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC,
gtk.POLICY_AUTOMATIC)
self.scrolledwindow.set_shadow_type(gtk.SHADOW_NONE)
self.main_vbox.pack_start(self.scrolledwindow)
self.scrolledwindow.show()
table = gtk.Table(1, 1)
self.scrolledwindow.add_with_viewport(table)
table.show()
table.realize()
self.event_box = gtk.EventBox()
table.attach(self.event_box, 0, 1, 0, 1, gtk.EXPAND, gtk.EXPAND)
self.event_box.show()
self.event_box.realize()
# Image
self.image = gtk.Image()
self.event_box.add(self.image)
self.image.show()
# Data VBox
self.data_vbox = gtk.VBox(spacing=10)
self.main_vbox.pack_start(self.data_vbox, expand=False)
self.data_vbox.show()
# User VBox
self.user_vbox = gtk.VBox(spacing=10)
self.main_vbox.pack_start(self.user_vbox, expand=False)
self.user_vbox.show()
# Screendump ID HBox
box = gtk.HBox(spacing=10)
self.data_vbox.pack_start(box)
box.show()
label = gtk.Label("Screendump ID:")
box.pack_start(label, False)
label.show()
self.entry_screendump = gtk.Entry()
self.entry_screendump.set_editable(False)
box.pack_start(self.entry_screendump)
self.entry_screendump.show()
label = gtk.Label("Time:")
box.pack_start(label, False)
label.show()
self.entry_time = gtk.Entry()
self.entry_time.set_editable(False)
self.entry_time.set_width_chars(10)
box.pack_start(self.entry_time, False)
self.entry_time.show()
# Comment HBox
box = gtk.HBox(spacing=10)
self.data_vbox.pack_start(box)
box.show()
label = gtk.Label("Comment:")
box.pack_start(label, False)
label.show()
self.entry_comment = gtk.Entry()
box.pack_start(self.entry_comment)
self.entry_comment.show()
# Sleep HBox
box = gtk.HBox(spacing=10)
self.data_vbox.pack_start(box)
box.show()
self.check_sleep = gtk.CheckButton("Sleep:")
self.check_sleep.connect("toggled", self.event_check_sleep_toggled)
box.pack_start(self.check_sleep, False)
self.check_sleep.show()
self.spin_sleep = gtk.SpinButton(gtk.Adjustment(0, 0, 50000, 1, 10, 0),
climb_rate=0.0)
box.pack_start(self.spin_sleep, False)
self.spin_sleep.show()
# Barrier HBox
box = gtk.HBox(spacing=10)
self.data_vbox.pack_start(box)
box.show()
self.check_barrier = gtk.CheckButton("Barrier:")
self.check_barrier.connect("toggled", self.event_check_barrier_toggled)
box.pack_start(self.check_barrier, False)
self.check_barrier.show()
vbox = gtk.VBox()
box.pack_start(vbox)
vbox.show()
self.label_barrier_region = gtk.Label("Region:")
self.label_barrier_region.set_alignment(0, 0.5)
vbox.pack_start(self.label_barrier_region)
self.label_barrier_region.show()
self.label_barrier_md5sum = gtk.Label("MD5:")
self.label_barrier_md5sum.set_alignment(0, 0.5)
vbox.pack_start(self.label_barrier_md5sum)
self.label_barrier_md5sum.show()
self.label_barrier_timeout = gtk.Label("Timeout:")
box.pack_start(self.label_barrier_timeout, False)
self.label_barrier_timeout.show()
self.spin_barrier_timeout = gtk.SpinButton(gtk.Adjustment(0, 0, 50000,
1, 10, 0),
climb_rate=0.0)
box.pack_start(self.spin_barrier_timeout, False)
self.spin_barrier_timeout.show()
self.check_barrier_optional = gtk.CheckButton("Optional")
box.pack_start(self.check_barrier_optional, False)
self.check_barrier_optional.show()
# Keystrokes HBox
box = gtk.HBox(spacing=10)
self.data_vbox.pack_start(box)
box.show()
label = gtk.Label("Keystrokes:")
box.pack_start(label, False)
label.show()
frame = gtk.Frame()
frame.set_shadow_type(gtk.SHADOW_IN)
box.pack_start(frame)
frame.show()
self.text_buffer = gtk.TextBuffer()
self.entry_keys = gtk.TextView(self.text_buffer)
self.entry_keys.set_wrap_mode(gtk.WRAP_WORD)
self.entry_keys.connect("key-press-event", self.event_key_press)
frame.add(self.entry_keys)
self.entry_keys.show()
self.check_manual = gtk.CheckButton("Manual")
self.check_manual.connect("toggled", self.event_manual_toggled)
box.pack_start(self.check_manual, False)
self.check_manual.show()
button = gtk.Button("Clear")
button.connect("clicked", self.event_clear_clicked)
box.pack_start(button, False)
button.show()
# Mouse click HBox
box = gtk.HBox(spacing=10)
self.data_vbox.pack_start(box)
box.show()
label = gtk.Label("Mouse action:")
box.pack_start(label, False)
label.show()
self.button_capture = gtk.Button("Capture")
box.pack_start(self.button_capture, False)
self.button_capture.show()
self.check_mousemove = gtk.CheckButton("Move: ...")
box.pack_start(self.check_mousemove, False)
self.check_mousemove.show()
self.check_mouseclick = gtk.CheckButton("Click: ...")
box.pack_start(self.check_mouseclick, False)
self.check_mouseclick.show()
self.spin_sensitivity = gtk.SpinButton(gtk.Adjustment(1, 1, 100, 1, 10,
0),
climb_rate=0.0)
box.pack_end(self.spin_sensitivity, False)
self.spin_sensitivity.show()
label = gtk.Label("Sensitivity:")
box.pack_end(label, False)
label.show()
self.spin_latency = gtk.SpinButton(
gtk.Adjustment(10, 1, 500, 1, 10, 0),
climb_rate=0.0)
box.pack_end(self.spin_latency, False)
self.spin_latency.show()
label = gtk.Label("Latency:")
box.pack_end(label, False)
label.show()
self.handler_event_box_press = None
self.handler_event_box_release = None
self.handler_event_box_scroll = None
self.handler_event_box_motion = None
self.handler_event_box_expose = None
self.window.realize()
self.window.show()
self.clear_state()
# Utilities
def message(self, text, title):
dlg = gtk.MessageDialog(self.window,
gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
gtk.MESSAGE_INFO,
gtk.BUTTONS_CLOSE,
title)
dlg.set_title(title)
dlg.format_secondary_text(text)
dlg.run()
dlg.destroy()
def question_yes_no(self, text, title):
dlg = gtk.MessageDialog(self.window,
gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
gtk.MESSAGE_QUESTION,
gtk.BUTTONS_YES_NO,
title)
dlg.set_title(title)
dlg.format_secondary_text(text)
response = dlg.run()
dlg.destroy()
if response == gtk.RESPONSE_YES:
return True
return False
def inputdialog(self, text, title, default_response=""):
# Define a little helper function
def inputdialog_entry_activated(entry):
dlg.response(gtk.RESPONSE_OK)
# Create the dialog
dlg = gtk.MessageDialog(self.window,
gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
gtk.MESSAGE_QUESTION,
gtk.BUTTONS_OK_CANCEL,
title)
dlg.set_title(title)
dlg.format_secondary_text(text)
# Create an entry widget
entry = gtk.Entry()
entry.set_text(default_response)
entry.connect("activate", inputdialog_entry_activated)
dlg.vbox.pack_start(entry)
entry.show()
# Run the dialog
response = dlg.run()
dlg.destroy()
if response == gtk.RESPONSE_OK:
return entry.get_text()
return None
def filedialog(self, title=None, default_filename=None):
chooser = gtk.FileChooserDialog(title=title, parent=self.window,
action=gtk.FILE_CHOOSER_ACTION_OPEN,
buttons=(
gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN,
gtk.RESPONSE_OK))
chooser.resize(700, 500)
if default_filename:
chooser.set_filename(os.path.abspath(default_filename))
filename = None
response = chooser.run()
if response == gtk.RESPONSE_OK:
filename = chooser.get_filename()
chooser.destroy()
return filename
def redirect_event_box_input(self, press=None, release=None, scroll=None,
motion=None, expose=None):
if self.handler_event_box_press is not None:
self.event_box.disconnect(self.handler_event_box_press)
if self.handler_event_box_release is not None:
self.event_box.disconnect(self.handler_event_box_release)
if self.handler_event_box_scroll is not None:
self.event_box.disconnect(self.handler_event_box_scroll)
if self.handler_event_box_motion is not None:
self.event_box.disconnect(self.handler_event_box_motion)
if self.handler_event_box_expose is not None:
self.event_box.disconnect(self.handler_event_box_expose)
self.handler_event_box_press = None
self.handler_event_box_release = None
self.handler_event_box_scroll = None
self.handler_event_box_motion = None
self.handler_event_box_expose = None
if press is not None:
self.handler_event_box_press = (
self.event_box.connect("button-press-event", press))
if release is not None:
self.handler_event_box_release = (
self.event_box.connect("button-release-event", release))
if scroll is not None:
self.handler_event_box_scroll = (
self.event_box.connect("scroll-event", scroll))
if motion is not None:
self.handler_event_box_motion = (
self.event_box.connect("motion-notify-event", motion))
if expose is not None:
self.handler_event_box_expose = (
self.event_box.connect_after("expose-event", expose))
def get_keys(self):
return self.text_buffer.get_text(
self.text_buffer.get_start_iter(),
self.text_buffer.get_end_iter())
def add_key(self, key):
text = self.get_keys()
if len(text) > 0 and text[-1] != ' ':
text += " "
text += key
self.text_buffer.set_text(text)
def clear_keys(self):
self.text_buffer.set_text("")
def update_barrier_info(self):
if self.barrier_selected:
self.label_barrier_region.set_text("Selected region: Corner: " +
str(tuple(self.barrier_corner)) +
" Size: " +
str(tuple(self.barrier_size)))
else:
self.label_barrier_region.set_text("No region selected.")
self.label_barrier_md5sum.set_text("MD5: " + self.barrier_md5sum)
def update_mouse_click_info(self):
if self.mouse_click_captured:
self.check_mousemove.set_label("Move: " +
str(tuple(self.mouse_click_coords)))
self.check_mouseclick.set_label("Click: button %d" %
self.mouse_click_button)
else:
self.check_mousemove.set_label("Move: ...")
self.check_mouseclick.set_label("Click: ...")
def clear_state(self, clear_screendump=True):
# Recording time
self.entry_time.set_text("unknown")
if clear_screendump:
# Screendump
self.clear_image()
# Screendump ID
self.entry_screendump.set_text("")
# Comment
self.entry_comment.set_text("")
# Sleep
self.check_sleep.set_active(True)
self.check_sleep.set_active(False)
self.spin_sleep.set_value(10)
# Barrier
self.clear_barrier_state()
# Keystrokes
self.check_manual.set_active(False)
self.clear_keys()
# Mouse actions
self.check_mousemove.set_sensitive(False)
self.check_mouseclick.set_sensitive(False)
self.check_mousemove.set_active(False)
self.check_mouseclick.set_active(False)
self.mouse_click_captured = False
self.mouse_click_coords = [0, 0]
self.mouse_click_button = 0
self.update_mouse_click_info()
def clear_barrier_state(self):
self.check_barrier.set_active(True)
self.check_barrier.set_active(False)
self.check_barrier_optional.set_active(False)
self.spin_barrier_timeout.set_value(10)
self.barrier_selection_started = False
self.barrier_selected = False
self.barrier_corner0 = [0, 0]
self.barrier_corner1 = [0, 0]
self.barrier_corner = [0, 0]
self.barrier_size = [0, 0]
self.barrier_md5sum = ""
self.update_barrier_info()
def set_image(self, w, h, data):
(self.image_width, self.image_height, self.image_data) = (w, h, data)
self.image.set_from_pixbuf(gtk.gdk.pixbuf_new_from_data(
data, gtk.gdk.COLORSPACE_RGB, False, 8,
w, h, w * 3))
hscrollbar = self.scrolledwindow.get_hscrollbar()
hscrollbar.set_range(0, w)
vscrollbar = self.scrolledwindow.get_vscrollbar()
vscrollbar.set_range(0, h)
def set_image_from_file(self, filename):
if not ppm_utils.image_verify_ppm_file(filename):
logging.warning("set_image_from_file: Warning: received invalid"
"screendump file")
return self.clear_image()
(w, h, data) = ppm_utils.image_read_from_ppm_file(filename)
self.set_image(w, h, data)
def clear_image(self):
self.image.clear()
self.image_width = 0
self.image_height = 0
self.image_data = ""
def update_screendump_id(self, data_dir):
if not self.image_data:
return
# Find a proper ID for the screendump
scrdump_md5sum = ppm_utils.image_md5sum(self.image_width,
self.image_height,
self.image_data)
scrdump_id = ppm_utils.find_id_for_screendump(scrdump_md5sum, data_dir)
if not scrdump_id:
# Not found; generate one
scrdump_id = ppm_utils.generate_id_for_screendump(scrdump_md5sum,
data_dir)
self.entry_screendump.set_text(scrdump_id)
def get_step_lines(self, data_dir=None):
if self.check_barrier.get_active() and not self.barrier_selected:
self.message("No barrier region selected.", "Error")
return
sr = "step"
# Add step recording time
if self.entry_time.get_text():
sr += " " + self.entry_time.get_text()
sr += "\n"
# Add screendump line
if self.image_data:
sr += "screendump %s\n" % self.entry_screendump.get_text()
# Add comment
if self.entry_comment.get_text():
sr += "# %s\n" % self.entry_comment.get_text()
# Add sleep line
if self.check_sleep.get_active():
sr += "sleep %d\n" % self.spin_sleep.get_value()
# Add barrier_2 line
if self.check_barrier.get_active():
sr += "barrier_2 %d %d %d %d %s %d" % (
self.barrier_size[0], self.barrier_size[1],
self.barrier_corner[0], self.barrier_corner[1],
self.barrier_md5sum, self.spin_barrier_timeout.get_value())
if self.check_barrier_optional.get_active():
sr += " optional"
sr += "\n"
# Add "Sending keys" comment
keys_to_send = self.get_keys().split()
if keys_to_send:
sr += "# Sending keys: %s\n" % self.get_keys()
# Add key and var lines
for key in keys_to_send:
if key.startswith("$"):
varname = key[1:]
sr += "var %s\n" % varname
else:
sr += "key %s\n" % key
# Add mousemove line
if self.check_mousemove.get_active():
sr += "mousemove %d %d\n" % (self.mouse_click_coords[0],
self.mouse_click_coords[1])
# Add mouseclick line
if self.check_mouseclick.get_active():
mapping = {1: 1,
2: 2,
3: 4}
sr += "mouseclick %d\n" % mapping[self.mouse_click_button]
# Write screendump and cropped screendump image files
if data_dir and self.image_data:
# Create the data dir if it doesn't exist
if not os.path.exists(data_dir):
os.makedirs(data_dir)
# Get the full screendump filename
scrdump_filename = os.path.join(data_dir,
self.entry_screendump.get_text())
# Write screendump file if it doesn't exist
if not os.path.exists(scrdump_filename):
try:
ppm_utils.image_write_to_ppm_file(scrdump_filename,
self.image_width,
self.image_height,
self.image_data)
except IOError:
self.message("Could not write screendump file.", "Error")
return sr
def set_state_from_step_lines(self, sr, data_dir, warn=True):
self.clear_state()
for line in sr.splitlines():
words = line.split()
if not words:
continue
if (line.startswith("#") and not
self.entry_comment.get_text() and not
line.startswith("# Sending keys:") and not
line.startswith("# ----")):
self.entry_comment.set_text(line.strip("#").strip())
elif words[0] == "step":
if len(words) >= 2:
self.entry_time.set_text(words[1])
elif words[0] == "screendump":
self.entry_screendump.set_text(words[1])
self.set_image_from_file(os.path.join(data_dir, words[1]))
elif words[0] == "sleep":
self.spin_sleep.set_value(int(words[1]))
self.check_sleep.set_active(True)
elif words[0] == "key":
self.add_key(words[1])
elif words[0] == "var":
self.add_key("$%s" % words[1])
elif words[0] == "mousemove":
self.mouse_click_captured = True
self.mouse_click_coords = [int(words[1]), int(words[2])]
self.update_mouse_click_info()
elif words[0] == "mouseclick":
self.mouse_click_captured = True
self.mouse_click_button = int(words[1])
self.update_mouse_click_info()
elif words[0] == "barrier_2":
# Get region corner and size from step lines
self.barrier_corner = [int(words[3]), int(words[4])]
self.barrier_size = [int(words[1]), int(words[2])]
# Get corner0 and corner1 from step lines
self.barrier_corner0 = self.barrier_corner
self.barrier_corner1 = [self.barrier_corner[0] +
self.barrier_size[0] - 1,
self.barrier_corner[1] +
self.barrier_size[1] - 1]
# Get the md5sum
self.barrier_md5sum = words[5]
# Pretend the user selected the region with the mouse
self.barrier_selection_started = True
self.barrier_selected = True
# Update label widgets according to region information
self.update_barrier_info()
# Check the barrier checkbutton
self.check_barrier.set_active(True)
# Set timeout value
self.spin_barrier_timeout.set_value(int(words[6]))
# Set 'optional' checkbutton state
self.check_barrier_optional.set_active(words[-1] == "optional")
# Update the image widget
self.event_box.queue_draw()
if warn:
# See if the computed md5sum matches the one recorded in
# the file
computed_md5sum = ppm_utils.get_region_md5sum(
self.image_width, self.image_height,
self.image_data, self.barrier_corner[0],
self.barrier_corner[1], self.barrier_size[0],
self.barrier_size[1])
if computed_md5sum != self.barrier_md5sum:
self.message("Computed MD5 sum (%s) differs from MD5"
" sum recorded in steps file (%s)" %
(computed_md5sum, self.barrier_md5sum),
"Warning")
# Events
def delete_event(self, widget, event):
pass
def destroy(self, widget):
gtk.main_quit()
def event_check_barrier_toggled(self, widget):
if self.check_barrier.get_active():
self.redirect_event_box_input(
self.event_button_press,
self.event_button_release,
None,
None,
self.event_expose)
self.event_box.queue_draw()
self.event_box.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.CROSSHAIR))
self.label_barrier_region.set_sensitive(True)
self.label_barrier_md5sum.set_sensitive(True)
self.label_barrier_timeout.set_sensitive(True)
self.spin_barrier_timeout.set_sensitive(True)
self.check_barrier_optional.set_sensitive(True)
else:
self.redirect_event_box_input()
self.event_box.queue_draw()
self.event_box.window.set_cursor(None)
self.label_barrier_region.set_sensitive(False)
self.label_barrier_md5sum.set_sensitive(False)
self.label_barrier_timeout.set_sensitive(False)
self.spin_barrier_timeout.set_sensitive(False)
self.check_barrier_optional.set_sensitive(False)
def event_check_sleep_toggled(self, widget):
if self.check_sleep.get_active():
self.spin_sleep.set_sensitive(True)
else:
self.spin_sleep.set_sensitive(False)
def event_manual_toggled(self, widget):
self.entry_keys.grab_focus()
def event_clear_clicked(self, widget):
self.clear_keys()
self.entry_keys.grab_focus()
def event_expose(self, widget, event):
if not self.barrier_selection_started:
return
(corner, size) = corner_and_size_clipped(self.barrier_corner0,
self.barrier_corner1,
self.event_box.size_request())
gc = self.event_box.window.new_gc(line_style=gtk.gdk.LINE_DOUBLE_DASH,
line_width=1)
gc.set_foreground(gc.get_colormap().alloc_color("red"))
gc.set_background(gc.get_colormap().alloc_color("dark red"))
gc.set_dashes(0, (4, 4))
self.event_box.window.draw_rectangle(
gc, False,
corner[0], corner[1],
size[0] - 1, size[1] - 1)
def event_drag_motion(self, widget, event):
old_corner1 = self.barrier_corner1
self.barrier_corner1 = [int(event.x), int(event.y)]
(corner, size) = corner_and_size_clipped(self.barrier_corner0,
self.barrier_corner1,
self.event_box.size_request())
(old_corner, old_size) = corner_and_size_clipped(self.barrier_corner0,
old_corner1,
self.event_box.size_request())
corner0 = [
min(corner[0], old_corner[0]), min(corner[1], old_corner[1])]
corner1 = [max(corner[0] + size[0], old_corner[0] + old_size[0]),
max(corner[1] + size[1], old_corner[1] + old_size[1])]
size = [corner1[0] - corner0[0] + 1,
corner1[1] - corner0[1] + 1]
self.event_box.queue_draw_area(
corner0[0], corner0[1], size[0], size[1])
def event_button_press(self, widget, event):
(corner, size) = corner_and_size_clipped(self.barrier_corner0,
self.barrier_corner1,
self.event_box.size_request())
self.event_box.queue_draw_area(corner[0], corner[1], size[0], size[1])
self.barrier_corner0 = [int(event.x), int(event.y)]
self.barrier_corner1 = [int(event.x), int(event.y)]
self.redirect_event_box_input(
self.event_button_press,
self.event_button_release,
None,
self.event_drag_motion,
self.event_expose)
self.barrier_selection_started = True
def event_button_release(self, widget, event):
self.redirect_event_box_input(
self.event_button_press,
self.event_button_release,
None,
None,
self.event_expose)
(self.barrier_corner, self.barrier_size) = \
corner_and_size_clipped(self.barrier_corner0, self.barrier_corner1,
self.event_box.size_request())
self.barrier_md5sum = ppm_utils.get_region_md5sum(
self.image_width, self.image_height, self.image_data,
self.barrier_corner[0], self.barrier_corner[1],
self.barrier_size[0], self.barrier_size[1])
self.barrier_selected = True
self.update_barrier_info()
def event_key_press(self, widget, event):
if self.check_manual.get_active():
return False
sr = key_event_to_qemu_string(event)
self.add_key(sr)
return True
class StepEditor(StepMakerWindow):
ui = '''<ui>
<menubar name="MenuBar">
<menu action="File">
<menuitem action="Open"/>
<separator/>
<menuitem action="Quit"/>
</menu>
<menu action="Edit">
<menuitem action="CopyStep"/>
<menuitem action="DeleteStep"/>
</menu>
<menu action="Insert">
<menuitem action="InsertNewBefore"/>
<menuitem action="InsertNewAfter"/>
<separator/>
<menuitem action="InsertStepsBefore"/>
<menuitem action="InsertStepsAfter"/>
</menu>
<menu action="Tools">
<menuitem action="CleanUp"/>
</menu>
</menubar>
</ui>'''
# Constructor
def __init__(self, filename=None):
StepMakerWindow.__init__(self)
self.steps_filename = None
self.steps = []
# Create a UIManager instance
uimanager = gtk.UIManager()
# Add the accelerator group to the toplevel window
accelgroup = uimanager.get_accel_group()
self.window.add_accel_group(accelgroup)
# Create an ActionGroup
actiongroup = gtk.ActionGroup('StepEditor')
# Create actions
actiongroup.add_actions([
('Quit', gtk.STOCK_QUIT, '_Quit', None, 'Quit the Program',
self.quit),
('Open', gtk.STOCK_OPEN, '_Open', None, 'Open steps file',
self.open_steps_file),
('CopyStep', gtk.STOCK_COPY, '_Copy current step...', "",
'Copy current step to user specified position', self.copy_step),
('DeleteStep', gtk.STOCK_DELETE, '_Delete current step', "",
'Delete current step', self.event_remove_clicked),
('InsertNewBefore', gtk.STOCK_ADD, '_New step before current', "",
'Insert new step before current step', self.insert_before),
('InsertNewAfter', gtk.STOCK_ADD, 'N_ew step after current', "",
'Insert new step after current step', self.insert_after),
('InsertStepsBefore', gtk.STOCK_ADD, '_Steps before current...',
"", 'Insert steps (from file) before current step',
self.insert_steps_before),
('InsertStepsAfter', gtk.STOCK_ADD, 'Steps _after current...', "",
'Insert steps (from file) after current step',
self.insert_steps_after),
('CleanUp', gtk.STOCK_DELETE, '_Clean up data directory', "",
'Move unused PPM files to a backup directory', self.cleanup),
('File', None, '_File'),
('Edit', None, '_Edit'),
('Insert', None, '_Insert'),
('Tools', None, '_Tools')
])
def create_shortcut(name, callback, keyname):
# Create an action
action = gtk.Action(name, None, None, None)
# Connect a callback to the action
action.connect("activate", callback)
actiongroup.add_action_with_accel(action, keyname)
# Have the action use accelgroup
action.set_accel_group(accelgroup)
# Connect the accelerator to the action
action.connect_accelerator()
create_shortcut("Next", self.event_next_clicked, "Page_Down")
create_shortcut("Previous", self.event_prev_clicked, "Page_Up")
# Add the actiongroup to the uimanager
uimanager.insert_action_group(actiongroup, 0)
# Add a UI description
uimanager.add_ui_from_string(self.ui)
# Create a MenuBar
menubar = uimanager.get_widget('/MenuBar')
self.menu_vbox.pack_start(menubar, False)
# Remember the Edit menu bar for future reference
self.menu_edit = uimanager.get_widget('/MenuBar/Edit')
self.menu_edit.set_sensitive(False)
# Remember the Insert menu bar for future reference
self.menu_insert = uimanager.get_widget('/MenuBar/Insert')
self.menu_insert.set_sensitive(False)
# Remember the Tools menu bar for future reference
self.menu_tools = uimanager.get_widget('/MenuBar/Tools')
self.menu_tools.set_sensitive(False)
# Next/Previous HBox
hbox = gtk.HBox(spacing=10)
self.user_vbox.pack_start(hbox)
hbox.show()
self.button_first = gtk.Button(stock=gtk.STOCK_GOTO_FIRST)
self.button_first.connect("clicked", self.event_first_clicked)
hbox.pack_start(self.button_first)
self.button_first.show()
#self.button_prev = gtk.Button("<< Previous")
self.button_prev = gtk.Button(stock=gtk.STOCK_GO_BACK)
self.button_prev.connect("clicked", self.event_prev_clicked)
hbox.pack_start(self.button_prev)
self.button_prev.show()
self.label_step = gtk.Label("Step:")
hbox.pack_start(self.label_step, False)
self.label_step.show()
self.entry_step_num = gtk.Entry()
self.entry_step_num.connect(
"activate", self.event_entry_step_activated)
self.entry_step_num.set_width_chars(3)
hbox.pack_start(self.entry_step_num, False)
self.entry_step_num.show()
#self.button_next = gtk.Button("Next >>")
self.button_next = gtk.Button(stock=gtk.STOCK_GO_FORWARD)
self.button_next.connect("clicked", self.event_next_clicked)
hbox.pack_start(self.button_next)
self.button_next.show()
self.button_last = gtk.Button(stock=gtk.STOCK_GOTO_LAST)
self.button_last.connect("clicked", self.event_last_clicked)
hbox.pack_start(self.button_last)
self.button_last.show()
# Save HBox
hbox = gtk.HBox(spacing=10)
self.user_vbox.pack_start(hbox)
hbox.show()
self.button_save = gtk.Button("_Save current step")
self.button_save.connect("clicked", self.event_save_clicked)
hbox.pack_start(self.button_save)
self.button_save.show()
self.button_remove = gtk.Button("_Delete current step")
self.button_remove.connect("clicked", self.event_remove_clicked)
hbox.pack_start(self.button_remove)
self.button_remove.show()
self.button_replace = gtk.Button("_Replace screendump")
self.button_replace.connect("clicked", self.event_replace_clicked)
hbox.pack_start(self.button_replace)
self.button_replace.show()
# Disable unused widgets
self.button_capture.set_sensitive(False)
self.spin_latency.set_sensitive(False)
self.spin_sensitivity.set_sensitive(False)
# Disable main vbox because no steps file is loaded
self.main_vbox.set_sensitive(False)
# Set title
self.window.set_title("Step Editor")
# Events
def delete_event(self, widget, event):
# Make sure the step is saved (if the user wants it to be)
self.verify_save()
def event_first_clicked(self, widget):
if not self.steps:
return
# Make sure the step is saved (if the user wants it to be)
self.verify_save()
# Go to first step
self.set_step(0)
def event_last_clicked(self, widget):
if not self.steps:
return
# Make sure the step is saved (if the user wants it to be)
self.verify_save()
# Go to last step
self.set_step(len(self.steps) - 1)
def event_prev_clicked(self, widget):
if not self.steps:
return
# Make sure the step is saved (if the user wants it to be)
self.verify_save()
# Go to previous step
index = self.current_step_index - 1
if self.steps:
index = index % len(self.steps)
self.set_step(index)
def event_next_clicked(self, widget):
if not self.steps:
return
# Make sure the step is saved (if the user wants it to be)
self.verify_save()
# Go to next step
index = self.current_step_index + 1
if self.steps:
index = index % len(self.steps)
self.set_step(index)
def event_entry_step_activated(self, widget):
if not self.steps:
return
step_index = self.entry_step_num.get_text()
if not step_index.isdigit():
return
step_index = int(step_index) - 1
if step_index == self.current_step_index:
return
self.verify_save()
self.set_step(step_index)
def event_save_clicked(self, widget):
if not self.steps:
return
self.save_step()
def event_remove_clicked(self, widget):
if not self.steps:
return
if not self.question_yes_no("This will modify the steps file."
" Are you sure?", "Remove step?"):
return
# Remove step
del self.steps[self.current_step_index]
# Write changes to file
self.write_steps_file(self.steps_filename)
# Move to previous step
self.set_step(self.current_step_index)
def event_replace_clicked(self, widget):
if not self.steps:
return
# Let the user choose a screendump file
current_filename = os.path.join(self.steps_data_dir,
self.entry_screendump.get_text())
filename = self.filedialog("Choose PPM image file",
default_filename=current_filename)
if not filename:
return
if not ppm_utils.image_verify_ppm_file(filename):
self.message("Not a valid PPM image file.", "Error")
return
self.clear_image()
self.clear_barrier_state()
self.set_image_from_file(filename)
self.update_screendump_id(self.steps_data_dir)
# Menu actions
def open_steps_file(self, action):
# Make sure the step is saved (if the user wants it to be)
self.verify_save()
# Let the user choose a steps file
current_filename = self.steps_filename
filename = self.filedialog("Open steps file",
default_filename=current_filename)
if not filename:
return
self.set_steps_file(filename)
def quit(self, action):
# Make sure the step is saved (if the user wants it to be)
self.verify_save()
# Quit
gtk.main_quit()
def copy_step(self, action):
if not self.steps:
return
self.verify_save()
self.set_step(self.current_step_index)
# Get the desired position
step_index = self.inputdialog("Copy step to position:",
"Copy step",
str(self.current_step_index + 2))
if not step_index:
return
step_index = int(step_index) - 1
# Get the lines of the current step
step = self.steps[self.current_step_index]
# Insert new step at position step_index
self.steps.insert(step_index, step)
# Go to new step
self.set_step(step_index)
# Write changes to disk
self.write_steps_file(self.steps_filename)
def insert_before(self, action):
if not self.steps_filename:
return
if not self.question_yes_no("This will modify the steps file."
" Are you sure?", "Insert new step?"):
return
self.verify_save()
step_index = self.current_step_index
# Get the lines of a blank step
self.clear_state()
step = self.get_step_lines()
# Insert new step at position step_index
self.steps.insert(step_index, step)
# Go to new step
self.set_step(step_index)
# Write changes to disk
self.write_steps_file(self.steps_filename)
def insert_after(self, action):
if not self.steps_filename:
return
if not self.question_yes_no("This will modify the steps file."
" Are you sure?", "Insert new step?"):
return
self.verify_save()
step_index = self.current_step_index + 1
# Get the lines of a blank step
self.clear_state()
step = self.get_step_lines()
# Insert new step at position step_index
self.steps.insert(step_index, step)
# Go to new step
self.set_step(step_index)
# Write changes to disk
self.write_steps_file(self.steps_filename)
def insert_steps(self, filename, index):
# Read the steps file
(steps, _) = self.read_steps_file(filename)
data_dir = ppm_utils.get_data_dir(filename)
for step in steps:
self.set_state_from_step_lines(step, data_dir, warn=False)
step = self.get_step_lines(self.steps_data_dir)
# Insert steps into self.steps
self.steps[index:index] = steps
# Write changes to disk
self.write_steps_file(self.steps_filename)
def insert_steps_before(self, action):
if not self.steps_filename:
return
# Let the user choose a steps file
current_filename = self.steps_filename
filename = self.filedialog("Choose steps file",
default_filename=current_filename)
if not filename:
return
self.verify_save()
step_index = self.current_step_index
# Insert steps at position step_index
self.insert_steps(filename, step_index)
# Go to new steps
self.set_step(step_index)
def insert_steps_after(self, action):
if not self.steps_filename:
return
# Let the user choose a steps file
current_filename = self.steps_filename
filename = self.filedialog("Choose steps file",
default_filename=current_filename)
if not filename:
return
self.verify_save()
step_index = self.current_step_index + 1
# Insert new steps at position step_index
self.insert_steps(filename, step_index)
# Go to new steps
self.set_step(step_index)
def cleanup(self, action):
if not self.steps_filename:
return
if not self.question_yes_no("All unused PPM files will be moved to a"
" backup directory. Are you sure?",
"Clean up data directory?"):
return
# Remember the current step index
current_step_index = self.current_step_index
# Get the backup dir
backup_dir = os.path.join(self.steps_data_dir, "backup")
# Create it if it doesn't exist
if not os.path.exists(backup_dir):
os.makedirs(backup_dir)
# Move all files to the backup dir
for filename in glob.glob(os.path.join(self.steps_data_dir,
"*.[Pp][Pp][Mm]")):
shutil.move(filename, backup_dir)
# Get the used files back
for step in self.steps:
self.set_state_from_step_lines(step, backup_dir, warn=False)
self.get_step_lines(self.steps_data_dir)
# Remove the used files from the backup dir
used_files = os.listdir(self.steps_data_dir)
for filename in os.listdir(backup_dir):
if filename in used_files:
os.unlink(os.path.join(backup_dir, filename))
# Restore step index
self.set_step(current_step_index)
# Inform the user
self.message("All unused PPM files may be found at %s." %
os.path.abspath(backup_dir),
"Clean up data directory")
# Methods
def read_steps_file(self, filename):
steps = []
header = ""
fileobj = open(filename, "r")
for line in fileobj.readlines():
words = line.split()
if not words:
continue
if line.startswith("# ----"):
continue
if words[0] == "step":
steps.append("")
if steps:
steps[-1] += line
else:
header += line
fileobj.close()
return (steps, header)
def set_steps_file(self, filename):
try:
(self.steps, self.header) = self.read_steps_file(filename)
except (TypeError, IOError):
self.message("Cannot read file %s." % filename, "Error")
return
self.steps_filename = filename
self.steps_data_dir = ppm_utils.get_data_dir(filename)
# Go to step 0
self.set_step(0)
def set_step(self, index):
# Limit index to legal boundaries
if index < 0:
index = 0
if index > len(self.steps) - 1:
index = len(self.steps) - 1
# Enable the menus
self.menu_edit.set_sensitive(True)
self.menu_insert.set_sensitive(True)
self.menu_tools.set_sensitive(True)
# If no steps exist...
if self.steps == []:
self.current_step_index = index
self.current_step = None
# Set window title
self.window.set_title("Step Editor -- %s" %
os.path.basename(self.steps_filename))
# Set step entry widget text
self.entry_step_num.set_text("")
# Clear the state of all widgets
self.clear_state()
# Disable the main vbox
self.main_vbox.set_sensitive(False)
return
self.current_step_index = index
self.current_step = self.steps[index]
# Set window title
self.window.set_title("Step Editor -- %s -- step %d" %
(os.path.basename(self.steps_filename),
index + 1))
# Set step entry widget text
self.entry_step_num.set_text(str(self.current_step_index + 1))
# Load the state from the step lines
self.set_state_from_step_lines(self.current_step, self.steps_data_dir)
# Enable the main vbox
self.main_vbox.set_sensitive(True)
# Make sure the step lines in self.current_step are identical to the
# output of self.get_step_lines
self.current_step = self.get_step_lines()
def verify_save(self):
if not self.steps:
return
# See if the user changed anything
if self.get_step_lines() != self.current_step:
if self.question_yes_no("Step contents have been modified."
" Save step?", "Save changes?"):
self.save_step()
def save_step(self):
lines = self.get_step_lines(self.steps_data_dir)
if lines is not None:
self.steps[self.current_step_index] = lines
self.current_step = lines
self.write_steps_file(self.steps_filename)
def write_steps_file(self, filename):
fileobj = open(filename, "w")
fileobj.write(self.header)
for step in self.steps:
fileobj.write("# " + "-" * 32 + "\n")
fileobj.write(step)
fileobj.close()
if __name__ == "__main__":
se = StepEditor()
if len(sys.argv) > 1:
se.set_steps_file(sys.argv[1])
gtk.main()
|
gpl-2.0
|
[
3381,
2647,
15,
1393,
15,
1548,
199,
624,
199,
7801,
570,
14875,
15,
7515,
14,
199,
199,
26,
7307,
26,
9572,
13002,
3277,
8937,
199,
26,
2502,
26,
32581,
393,
29159,
32,
17164,
14,
957,
334,
45,
11781,
598,
393,
29159,
9,
199,
624,
199,
199,
646,
747,
199,
646,
5739,
199,
646,
5145,
199,
646,
984,
199,
646,
2050,
199,
199,
646,
1134,
12275,
199,
646,
8116,
199,
199,
646,
299,
7073,
63,
1208,
199,
199,
647,
12275,
14,
4365,
360,
18,
14,
16,
358,
421,
199,
3,
1696,
15841,
199,
199,
318,
17703,
63,
460,
63,
890,
63,
7548,
1915,
8,
928,
1403,
12,
6037,
12,
10976,
304,
272,
286,
16,
275,
1343,
1403,
5873,
272,
286,
17,
275,
6037,
5873,
272,
340,
286,
16,
59,
16,
61,
665,
378,
26,
267,
286,
16,
59,
16,
61,
275,
378,
272,
340,
286,
16,
59,
17,
61,
665,
378,
26,
267,
286,
16,
59,
17,
61,
275,
378,
272,
340,
286,
17,
59,
16,
61,
665,
378,
26,
267,
286,
17,
59,
16,
61,
275,
378,
272,
340,
286,
17,
59,
17,
61,
665,
378,
26,
267,
286,
17,
59,
17,
61,
275,
378,
272,
340,
286,
16,
59,
16,
61,
690,
10976,
59,
16,
61,
446,
413,
26,
267,
286,
16,
59,
16,
61,
275,
10976,
59,
16,
61,
446,
413,
272,
340,
286,
16,
59,
17,
61,
690,
10976,
59,
17,
61,
446,
413,
26,
267,
286,
16,
59,
17,
61,
275,
10976,
59,
17,
61,
446,
413,
272,
340,
286,
17,
59,
16,
61,
690,
10976,
59,
16,
61,
446,
413,
26,
267,
286,
17,
59,
16,
61,
275,
10976,
59,
16,
61,
446,
413,
272,
340,
286,
17,
59,
17,
61,
690,
10976,
59,
17,
61,
446,
413,
26,
267,
286,
17,
59,
17,
61,
275,
10976,
59,
17,
61,
446,
413,
272,
372,
7287,
827,
8,
67,
16,
59,
16,
467,
286,
17,
59,
16,
2522,
1467,
1748,
8,
67,
16,
59,
17,
467,
286,
17,
59,
17,
27520,
288,
359,
2101,
8,
67,
17,
59,
16,
61,
446,
286,
16,
59,
16,
566,
435,
413,
12,
1467,
2853,
8,
67,
17,
59,
17,
61,
446,
286,
16,
59,
17,
566,
435,
413,
566,
421,
199,
318,
790,
63,
1430,
63,
475,
63,
19839,
63,
875,
8,
1430,
304,
272,
790,
1130,
275,
8116,
14,
24697,
14,
19624,
63,
362,
63,
885,
342,
272,
790,
3643,
275,
790,
1130,
14,
362,
63,
3189,
63,
509,
63,
498,
600,
8,
1430,
14,
16529,
63,
498,
600,
9,
272,
790,
637,
275,
790,
3643,
59,
16,
1527,
16,
61,
272,
790,
354,
275,
8116,
14,
24697,
14,
31217,
63,
354,
8,
31217,
9,
339,
790,
1130,
275,
2420,
1767,
582,
298,
3292,
401,
1598,
298,
7690,
582,
298,
2902,
401,
1598,
298,
2638,
582,
298,
681,
67,
401,
1598,
298,
8185,
582,
298,
3039,
401,
1598,
298,
9121,
582,
298,
1019,
401,
1598,
298,
1721,
582,
298,
384,
401,
1598,
298,
3514,
582,
298,
2110,
401,
1598,
298,
38,
17,
582,
298,
70,
17,
401,
1598,
298,
38,
18,
582,
298,
70,
18,
401,
1598,
298,
38,
19,
582,
298,
70,
19,
401,
1598,
298,
38,
20,
582,
298,
70,
20,
401,
1598,
298,
38,
21,
582,
298,
70,
21,
401,
1598,
298,
38,
22,
582,
298,
70,
22,
401,
1598,
298,
38,
23,
582,
298,
70,
23,
401,
1598,
298,
38,
24,
582,
298,
70,
24,
401,
1598,
298,
38,
25,
582,
298,
70,
25,
401,
1598,
298,
38,
709,
582,
298,
70,
709,
401,
1598,
298,
38,
845,
582,
298,
70,
845,
401,
1598,
298,
38,
713,
582,
298,
70,
713,
401,
1598,
298,
10260,
582,
298,
19303,
401,
1598,
298,
13084,
582,
298,
13084,
401,
1598,
298,
1452,
582,
298,
1452,
401,
1598,
298,
4540,
7643,
582,
298,
894,
2638,
401,
1598,
298,
13184,
582,
298,
13184,
401,
1598,
298,
5191,
582,
298,
3287,
401,
1598,
298,
7001,
582,
298,
7001,
401,
1598,
298,
9971,
582,
298,
3176,
401,
1598,
298,
5392,
582,
298,
1807,
401,
1598,
298,
12054,
582,
298,
4219,
401,
1598,
298,
3005,
582,
298,
500,
401,
1598,
298,
3276,
63,
1721,
582,
298,
4198,
384,
401,
1598,
298,
3276,
63,
3514,
582,
298,
4198,
4272,
401,
1598,
298,
5977,
582,
298,
4470,
401,
1598,
298,
19290,
12167,
582,
298,
16,
88,
1465,
401,
1598,
298,
21509,
582,
298,
16,
88,
18,
66,
401,
1598,
298,
439,
941,
2675,
426,
582,
298,
16,
88,
1651,
401,
1598,
298,
19612,
582,
298,
16,
88,
1398,
401,
1598,
298,
2003,
582,
298,
16,
88,
18,
66,
401,
1598,
298,
14594,
3039,
582,
298,
16,
88,
17,
65,
401,
1598,
298,
14594,
1019,
582,
298,
16,
88,
17,
66,
401,
1598,
298,
11823,
63,
44,
582,
298,
16,
10550,
401,
1598,
298,
11823,
63,
50,
582,
298,
16,
10719,
401,
1598,
789,
339,
340,
6206,
360,
65,
358,
2695,
790,
637,
2695,
6206,
360,
90,
358,
503,
6206,
360,
16,
358,
2695,
790,
637,
2695,
6206,
360,
25,
735,
267,
11483,
275,
790,
354,
272,
916,
790,
354,
315,
790,
1130,
14,
1612,
837,
267,
11483,
275,
790,
1130,
59,
30499,
61,
272,
587,
26,
267,
372,
3087,
339,
340,
1566,
14,
929,
1253,
8116,
14,
24697,
14,
13060,
63,
12880,
26,
267,
11483,
275,
298,
12476,
23245,
435,
620,
272,
340,
1566,
14,
929,
1253,
8116,
14,
24697,
14,
8816,
17,
63,
12880,
26,
267,
11483,
275,
298,
4478,
23245,
435,
620,
272,
340,
1566,
14,
929,
1253,
8116,
14,
24697,
14,
18013,
63,
12880,
26,
267,
11483,
275,
298,
4723,
23245,
435,
620,
339,
372,
11483,
421,
199,
533,
13382,
23560,
4301,
8,
785,
304,
339,
347,
636,
826,
721,
277,
304,
267,
327,
15689,
267,
291,
14,
3806,
275,
8116,
14,
4301,
8,
12275,
14,
15480,
63,
11422,
11817,
9,
267,
291,
14,
3806,
14,
409,
63,
1213,
480,
7801,
603,
12630,
15689,
531,
267,
291,
14,
3806,
14,
2242,
480,
1807,
13,
1430,
401,
291,
14,
1807,
63,
1430,
9,
267,
291,
14,
3806,
14,
2242,
480,
7237,
401,
291,
14,
7237,
9,
267,
291,
14,
3806,
14,
409,
63,
885,
63,
890
] |
[
2647,
15,
1393,
15,
1548,
199,
624,
199,
7801,
570,
14875,
15,
7515,
14,
199,
199,
26,
7307,
26,
9572,
13002,
3277,
8937,
199,
26,
2502,
26,
32581,
393,
29159,
32,
17164,
14,
957,
334,
45,
11781,
598,
393,
29159,
9,
199,
624,
199,
199,
646,
747,
199,
646,
5739,
199,
646,
5145,
199,
646,
984,
199,
646,
2050,
199,
199,
646,
1134,
12275,
199,
646,
8116,
199,
199,
646,
299,
7073,
63,
1208,
199,
199,
647,
12275,
14,
4365,
360,
18,
14,
16,
358,
421,
199,
3,
1696,
15841,
199,
199,
318,
17703,
63,
460,
63,
890,
63,
7548,
1915,
8,
928,
1403,
12,
6037,
12,
10976,
304,
272,
286,
16,
275,
1343,
1403,
5873,
272,
286,
17,
275,
6037,
5873,
272,
340,
286,
16,
59,
16,
61,
665,
378,
26,
267,
286,
16,
59,
16,
61,
275,
378,
272,
340,
286,
16,
59,
17,
61,
665,
378,
26,
267,
286,
16,
59,
17,
61,
275,
378,
272,
340,
286,
17,
59,
16,
61,
665,
378,
26,
267,
286,
17,
59,
16,
61,
275,
378,
272,
340,
286,
17,
59,
17,
61,
665,
378,
26,
267,
286,
17,
59,
17,
61,
275,
378,
272,
340,
286,
16,
59,
16,
61,
690,
10976,
59,
16,
61,
446,
413,
26,
267,
286,
16,
59,
16,
61,
275,
10976,
59,
16,
61,
446,
413,
272,
340,
286,
16,
59,
17,
61,
690,
10976,
59,
17,
61,
446,
413,
26,
267,
286,
16,
59,
17,
61,
275,
10976,
59,
17,
61,
446,
413,
272,
340,
286,
17,
59,
16,
61,
690,
10976,
59,
16,
61,
446,
413,
26,
267,
286,
17,
59,
16,
61,
275,
10976,
59,
16,
61,
446,
413,
272,
340,
286,
17,
59,
17,
61,
690,
10976,
59,
17,
61,
446,
413,
26,
267,
286,
17,
59,
17,
61,
275,
10976,
59,
17,
61,
446,
413,
272,
372,
7287,
827,
8,
67,
16,
59,
16,
467,
286,
17,
59,
16,
2522,
1467,
1748,
8,
67,
16,
59,
17,
467,
286,
17,
59,
17,
27520,
288,
359,
2101,
8,
67,
17,
59,
16,
61,
446,
286,
16,
59,
16,
566,
435,
413,
12,
1467,
2853,
8,
67,
17,
59,
17,
61,
446,
286,
16,
59,
17,
566,
435,
413,
566,
421,
199,
318,
790,
63,
1430,
63,
475,
63,
19839,
63,
875,
8,
1430,
304,
272,
790,
1130,
275,
8116,
14,
24697,
14,
19624,
63,
362,
63,
885,
342,
272,
790,
3643,
275,
790,
1130,
14,
362,
63,
3189,
63,
509,
63,
498,
600,
8,
1430,
14,
16529,
63,
498,
600,
9,
272,
790,
637,
275,
790,
3643,
59,
16,
1527,
16,
61,
272,
790,
354,
275,
8116,
14,
24697,
14,
31217,
63,
354,
8,
31217,
9,
339,
790,
1130,
275,
2420,
1767,
582,
298,
3292,
401,
1598,
298,
7690,
582,
298,
2902,
401,
1598,
298,
2638,
582,
298,
681,
67,
401,
1598,
298,
8185,
582,
298,
3039,
401,
1598,
298,
9121,
582,
298,
1019,
401,
1598,
298,
1721,
582,
298,
384,
401,
1598,
298,
3514,
582,
298,
2110,
401,
1598,
298,
38,
17,
582,
298,
70,
17,
401,
1598,
298,
38,
18,
582,
298,
70,
18,
401,
1598,
298,
38,
19,
582,
298,
70,
19,
401,
1598,
298,
38,
20,
582,
298,
70,
20,
401,
1598,
298,
38,
21,
582,
298,
70,
21,
401,
1598,
298,
38,
22,
582,
298,
70,
22,
401,
1598,
298,
38,
23,
582,
298,
70,
23,
401,
1598,
298,
38,
24,
582,
298,
70,
24,
401,
1598,
298,
38,
25,
582,
298,
70,
25,
401,
1598,
298,
38,
709,
582,
298,
70,
709,
401,
1598,
298,
38,
845,
582,
298,
70,
845,
401,
1598,
298,
38,
713,
582,
298,
70,
713,
401,
1598,
298,
10260,
582,
298,
19303,
401,
1598,
298,
13084,
582,
298,
13084,
401,
1598,
298,
1452,
582,
298,
1452,
401,
1598,
298,
4540,
7643,
582,
298,
894,
2638,
401,
1598,
298,
13184,
582,
298,
13184,
401,
1598,
298,
5191,
582,
298,
3287,
401,
1598,
298,
7001,
582,
298,
7001,
401,
1598,
298,
9971,
582,
298,
3176,
401,
1598,
298,
5392,
582,
298,
1807,
401,
1598,
298,
12054,
582,
298,
4219,
401,
1598,
298,
3005,
582,
298,
500,
401,
1598,
298,
3276,
63,
1721,
582,
298,
4198,
384,
401,
1598,
298,
3276,
63,
3514,
582,
298,
4198,
4272,
401,
1598,
298,
5977,
582,
298,
4470,
401,
1598,
298,
19290,
12167,
582,
298,
16,
88,
1465,
401,
1598,
298,
21509,
582,
298,
16,
88,
18,
66,
401,
1598,
298,
439,
941,
2675,
426,
582,
298,
16,
88,
1651,
401,
1598,
298,
19612,
582,
298,
16,
88,
1398,
401,
1598,
298,
2003,
582,
298,
16,
88,
18,
66,
401,
1598,
298,
14594,
3039,
582,
298,
16,
88,
17,
65,
401,
1598,
298,
14594,
1019,
582,
298,
16,
88,
17,
66,
401,
1598,
298,
11823,
63,
44,
582,
298,
16,
10550,
401,
1598,
298,
11823,
63,
50,
582,
298,
16,
10719,
401,
1598,
789,
339,
340,
6206,
360,
65,
358,
2695,
790,
637,
2695,
6206,
360,
90,
358,
503,
6206,
360,
16,
358,
2695,
790,
637,
2695,
6206,
360,
25,
735,
267,
11483,
275,
790,
354,
272,
916,
790,
354,
315,
790,
1130,
14,
1612,
837,
267,
11483,
275,
790,
1130,
59,
30499,
61,
272,
587,
26,
267,
372,
3087,
339,
340,
1566,
14,
929,
1253,
8116,
14,
24697,
14,
13060,
63,
12880,
26,
267,
11483,
275,
298,
12476,
23245,
435,
620,
272,
340,
1566,
14,
929,
1253,
8116,
14,
24697,
14,
8816,
17,
63,
12880,
26,
267,
11483,
275,
298,
4478,
23245,
435,
620,
272,
340,
1566,
14,
929,
1253,
8116,
14,
24697,
14,
18013,
63,
12880,
26,
267,
11483,
275,
298,
4723,
23245,
435,
620,
339,
372,
11483,
421,
199,
533,
13382,
23560,
4301,
8,
785,
304,
339,
347,
636,
826,
721,
277,
304,
267,
327,
15689,
267,
291,
14,
3806,
275,
8116,
14,
4301,
8,
12275,
14,
15480,
63,
11422,
11817,
9,
267,
291,
14,
3806,
14,
409,
63,
1213,
480,
7801,
603,
12630,
15689,
531,
267,
291,
14,
3806,
14,
2242,
480,
1807,
13,
1430,
401,
291,
14,
1807,
63,
1430,
9,
267,
291,
14,
3806,
14,
2242,
480,
7237,
401,
291,
14,
7237,
9,
267,
291,
14,
3806,
14,
409,
63,
885,
63,
890,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
credativUK/OCB
|
openerp/report/pyPdf/utils.py
|
123
|
3979
|
# vim: sw=4:expandtab:foldmethod=marker
#
# Copyright (c) 2006, Mathieu Fenniak
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * The name of the author may not be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
"""
Utility functions for PDF library.
"""
__author__ = "Mathieu Fenniak"
__author_email__ = "biziqe@mathieu.fenniak.net"
#ENABLE_PSYCO = False
#if ENABLE_PSYCO:
# try:
# import psyco
# except ImportError:
# ENABLE_PSYCO = False
#
#if not ENABLE_PSYCO:
# class psyco:
# def proxy(func):
# return func
# proxy = staticmethod(proxy)
def readUntilWhitespace(stream, maxchars=None):
txt = ""
while True:
tok = stream.read(1)
if tok.isspace() or not tok:
break
txt += tok
if len(txt) == maxchars:
break
return txt
def readNonWhitespace(stream):
tok = ' '
while tok == '\n' or tok == '\r' or tok == ' ' or tok == '\t':
tok = stream.read(1)
return tok
class ConvertFunctionsToVirtualList(object):
def __init__(self, lengthFunction, getFunction):
self.lengthFunction = lengthFunction
self.getFunction = getFunction
def __len__(self):
return self.lengthFunction()
def __getitem__(self, index):
if not isinstance(index, int):
raise TypeError, "sequence indices must be integers"
len_self = len(self)
if index < 0:
# support negative indexes
index += len_self
if index < 0 or index >= len_self:
raise IndexError, "sequence index out of range"
return self.getFunction(index)
def RC4_encrypt(key, plaintext):
S = [i for i in range(256)]
j = 0
for i in range(256):
j = (j + S[i] + ord(key[i % len(key)])) % 256
S[i], S[j] = S[j], S[i]
i, j = 0, 0
retval = ""
for x in range(len(plaintext)):
i = (i + 1) % 256
j = (j + S[i]) % 256
S[i], S[j] = S[j], S[i]
t = S[(S[i] + S[j]) % 256]
retval += chr(ord(plaintext[x]) ^ t)
return retval
def matrixMultiply(a, b):
return [[sum([float(i)*float(j)
for i, j in zip(row, col)]
) for col in zip(*b)]
for row in a]
class PyPdfError(Exception):
pass
class PdfReadError(PyPdfError):
pass
class PageSizeNotDefinedError(PyPdfError):
pass
if __name__ == "__main__":
# test RC4
out = RC4_encrypt("Key", "Plaintext")
print repr(out)
pt = RC4_encrypt("Key", out)
print repr(pt)
|
agpl-3.0
|
[
3,
6695,
26,
5584,
29,
20,
26,
10379,
26,
14011,
765,
29,
4211,
202,
199,
3,
202,
199,
3,
1898,
334,
67,
9,
8315,
12,
21066,
29364,
481,
287,
8445,
1151,
202,
199,
3,
2900,
4481,
4644,
14,
202,
199,
3,
202,
199,
3,
10114,
436,
675,
315,
1350,
436,
3366,
4513,
12,
543,
503,
1928,
202,
199,
3,
7100,
12,
787,
8211,
2741,
626,
314,
2569,
3704,
787,
202,
199,
3,
7647,
26,
202,
199,
3,
202,
199,
3,
627,
6823,
402,
1350,
1233,
1471,
8074,
314,
3432,
4248,
4245,
12,
202,
199,
3,
642,
769,
402,
3704,
436,
314,
2569,
6450,
14,
202,
199,
3,
627,
6823,
315,
3366,
1824,
1471,
9172,
314,
3432,
4248,
4245,
12,
202,
199,
3,
642,
769,
402,
3704,
436,
314,
2569,
6450,
315,
314,
3794,
202,
199,
3,
436,
15,
269,
1163,
8418,
2741,
543,
314,
4084,
14,
202,
199,
3,
627,
710,
536,
402,
314,
4132,
1443,
440,
506,
1202,
370,
10692,
503,
10016,
7585,
202,
199,
3,
7131,
687,
642,
2032,
1928,
2488,
6791,
5313,
4983,
14,
202,
199,
3,
202,
199,
3,
5749,
4141,
2281,
7049,
6515,
2334,
5877,
8164,
2401,
6483,
298,
1179,
2281,
2,
202,
199,
3,
2401,
1821,
7168,
1549,
5292,
2990,
12,
6931,
12,
5400,
2845,
5471,
2296,
12,
2334,
202,
199,
3,
5292,
2990,
1634,
3169,
2401,
3092,
2381,
437,
3115,
3104,
202,
199,
3,
9315,
9706,
14,
1621,
4825,
6461,
7000,
2334,
5877,
11489,
1549,
6483,
6262,
202,
199,
3,
7024,
2381,
1821,
8703,
12,
9168,
12,
9716,
12,
8820,
12,
9836,
12,
1549,
202,
199,
3,
9110,
6736,
334,
6446,
12,
5400,
2845,
5471,
2296,
12,
9838,
1634,
202,
199,
3,
9103,
9764,
1549,
9714,
27,
9102,
1634,
4815,
12,
7126,
12,
1549,
9206,
27,
1549,
9748,
202,
199,
3,
9831,
9,
9802,
9817,
2401,
5258,
1821,
9815,
1634,
5603,
12,
7061,
1621,
202,
199,
3,
7066,
12,
9644,
5603,
12,
1549,
7056,
334,
6446,
9254,
1549,
7334,
9,
202,
199,
3,
7043,
1621,
1821,
9683,
5738,
1634,
2334,
4815,
1634,
5749,
4141,
12,
9704,
8036,
9691,
1634,
2334,
202,
199,
3,
9726,
1634,
9712,
9784,
14,
8065,
199,
624,
202,
199,
17505,
3423,
367,
15537,
3555,
14,
202,
199,
624,
202,
199,
363,
2502,
363,
275,
298,
18568,
29364,
481,
287,
8445,
1151,
2,
202,
199,
363,
2502,
63,
2123,
363,
275,
298,
66,
565,
9962,
69,
32,
3442,
29364,
14,
70,
287,
8445,
1151,
14,
846,
2,
2999,
199,
3,
8898,
63,
48,
4669,
1439,
275,
756,
202,
199,
3,
692,
27926,
63,
48,
4669,
1439,
26,
202,
199,
3,
259,
862,
26,
202,
199,
3,
263,
492,
14177,
331,
202,
199,
3,
259,
871,
3545,
26,
202,
199,
3,
263,
27926,
63,
48,
4669,
1439,
275,
756,
202,
199,
3,
202,
199,
3,
692,
440,
27926,
63,
48,
4669,
1439,
26,
202,
199,
3,
259,
1021,
14177,
331,
26,
202,
199,
3,
263,
347,
4566,
8,
1532,
304,
202,
199,
3,
3322,
372,
2562,
202,
199,
3,
263,
4566,
275,
12822,
8,
3280,
9,
2999,
199,
318,
1586,
18667,
16552,
8,
1745,
12,
1390,
6574,
29,
403,
304,
1128,
9444,
275,
3087,
1128,
1830,
715,
26,
1039,
8431,
275,
2547,
14,
739,
8,
17,
9,
1039,
340,
8431,
14,
23360,
342,
503,
440,
8431,
26,
1675,
2059,
1039,
9444,
847,
8431,
1039,
340,
822,
8,
2424,
9,
508,
1390,
6574,
26,
1675,
2059,
1128,
372,
9444,
2999,
199,
318,
1586,
6932,
16552,
8,
1745,
304,
1128,
8431,
275,
283,
283,
1128,
1830,
8431,
508,
1557,
78,
7,
503,
8431,
508,
1557,
82,
7,
503,
8431,
508,
283,
283,
503,
8431,
508,
1557,
84,
356,
1039,
8431,
275,
2547,
14,
739,
8,
17,
9,
1128,
372,
8431,
2999,
199,
533,
7905,
13967,
1378,
8735,
1296,
8,
785,
304,
1128,
347,
636,
826,
721,
277,
12,
2582,
3481,
12,
664,
3481,
304,
1039,
291,
14,
1267,
3481,
275,
2582,
3481,
1039,
291,
14,
362,
3481,
275,
664,
3481,
2958,
347,
636,
552,
721,
277,
304,
1039,
372,
291,
14,
1267,
3481,
342,
2958,
347,
636,
6095,
721,
277,
12,
1478,
304,
1039,
340,
440,
1228,
8,
1080,
12,
1109,
304,
1675,
746,
3146,
12,
298,
4041,
4918,
1471,
506,
9446,
2,
1039,
822,
63,
277,
275,
822,
8,
277,
9,
1039,
340,
1478,
665,
378,
26,
1675,
327,
2291,
6946,
10507,
1675,
1478,
847,
822,
63,
277,
1039,
340,
1478,
665,
378,
503,
1478,
2356,
822,
63,
277,
26,
1675,
746,
7888,
12,
298,
4041,
1478,
734,
402,
1425,
2,
1039,
372,
291,
14,
362,
3481,
8,
1080,
9,
2999,
199,
318,
29256,
20,
63,
11929,
8,
498,
12,
18577,
304,
1128,
428,
275,
359,
73,
367,
284,
315,
1425,
8,
3912,
1874,
1128,
1335,
275,
378,
1128,
367,
284,
315,
1425,
8,
3912,
304,
1039,
1335,
275,
334,
74,
435,
428,
59,
73,
61,
435,
6206,
8,
498,
59,
73,
450,
822,
8,
498,
19563,
450,
7633,
1039,
428,
59,
73,
467,
428,
59,
74,
61,
275,
428,
59,
74,
467,
428,
59,
73,
61,
1128,
284,
12,
1335,
275,
378,
12,
378,
1128,
9151,
275,
3087,
1128,
367,
671,
315,
1425,
8,
552,
8,
17426,
2298,
1039,
284,
275,
334,
73,
435,
413,
9,
450,
7633,
1039,
1335,
275,
334,
74,
435,
428,
59,
73,
566,
450,
7633,
1039,
428,
59,
73,
467,
428,
59,
74,
61,
275,
428,
59,
74,
467,
428,
59,
73,
61,
1039,
307,
275,
428,
7528,
51,
59,
73,
61,
435,
428,
59,
74,
566,
450,
7633,
61,
1039,
9151,
847,
8678,
8,
2181,
8,
17426,
59,
88,
566,
7167,
307,
9,
1128,
372,
9151,
2999,
199,
318,
3634,
25314,
590,
8,
65,
12,
330,
304,
1128,
372,
3474,
1838,
779,
1609,
8,
73,
3342,
1609,
8,
74,
9,
28086,
367,
284,
12,
1335,
315,
3482,
8,
1143,
12,
1048,
1874,
2628,
776,
367,
1048,
315,
3482,
2031,
66,
1874,
1675,
367,
1962,
315,
282,
61,
2999,
199,
533,
1611,
48,
1587,
547,
8,
1726,
304,
1128,
986,
2999,
199,
533,
510,
1587,
3284,
547,
8,
2713,
48,
1587,
547,
304,
1128,
986,
2999,
199,
533,
10331,
2320,
1763,
18718,
547,
8,
2713,
48,
1587,
547,
304,
1128
] |
[
6695,
26,
5584,
29,
20,
26,
10379,
26,
14011,
765,
29,
4211,
202,
199,
3,
202,
199,
3,
1898,
334,
67,
9,
8315,
12,
21066,
29364,
481,
287,
8445,
1151,
202,
199,
3,
2900,
4481,
4644,
14,
202,
199,
3,
202,
199,
3,
10114,
436,
675,
315,
1350,
436,
3366,
4513,
12,
543,
503,
1928,
202,
199,
3,
7100,
12,
787,
8211,
2741,
626,
314,
2569,
3704,
787,
202,
199,
3,
7647,
26,
202,
199,
3,
202,
199,
3,
627,
6823,
402,
1350,
1233,
1471,
8074,
314,
3432,
4248,
4245,
12,
202,
199,
3,
642,
769,
402,
3704,
436,
314,
2569,
6450,
14,
202,
199,
3,
627,
6823,
315,
3366,
1824,
1471,
9172,
314,
3432,
4248,
4245,
12,
202,
199,
3,
642,
769,
402,
3704,
436,
314,
2569,
6450,
315,
314,
3794,
202,
199,
3,
436,
15,
269,
1163,
8418,
2741,
543,
314,
4084,
14,
202,
199,
3,
627,
710,
536,
402,
314,
4132,
1443,
440,
506,
1202,
370,
10692,
503,
10016,
7585,
202,
199,
3,
7131,
687,
642,
2032,
1928,
2488,
6791,
5313,
4983,
14,
202,
199,
3,
202,
199,
3,
5749,
4141,
2281,
7049,
6515,
2334,
5877,
8164,
2401,
6483,
298,
1179,
2281,
2,
202,
199,
3,
2401,
1821,
7168,
1549,
5292,
2990,
12,
6931,
12,
5400,
2845,
5471,
2296,
12,
2334,
202,
199,
3,
5292,
2990,
1634,
3169,
2401,
3092,
2381,
437,
3115,
3104,
202,
199,
3,
9315,
9706,
14,
1621,
4825,
6461,
7000,
2334,
5877,
11489,
1549,
6483,
6262,
202,
199,
3,
7024,
2381,
1821,
8703,
12,
9168,
12,
9716,
12,
8820,
12,
9836,
12,
1549,
202,
199,
3,
9110,
6736,
334,
6446,
12,
5400,
2845,
5471,
2296,
12,
9838,
1634,
202,
199,
3,
9103,
9764,
1549,
9714,
27,
9102,
1634,
4815,
12,
7126,
12,
1549,
9206,
27,
1549,
9748,
202,
199,
3,
9831,
9,
9802,
9817,
2401,
5258,
1821,
9815,
1634,
5603,
12,
7061,
1621,
202,
199,
3,
7066,
12,
9644,
5603,
12,
1549,
7056,
334,
6446,
9254,
1549,
7334,
9,
202,
199,
3,
7043,
1621,
1821,
9683,
5738,
1634,
2334,
4815,
1634,
5749,
4141,
12,
9704,
8036,
9691,
1634,
2334,
202,
199,
3,
9726,
1634,
9712,
9784,
14,
8065,
199,
624,
202,
199,
17505,
3423,
367,
15537,
3555,
14,
202,
199,
624,
202,
199,
363,
2502,
363,
275,
298,
18568,
29364,
481,
287,
8445,
1151,
2,
202,
199,
363,
2502,
63,
2123,
363,
275,
298,
66,
565,
9962,
69,
32,
3442,
29364,
14,
70,
287,
8445,
1151,
14,
846,
2,
2999,
199,
3,
8898,
63,
48,
4669,
1439,
275,
756,
202,
199,
3,
692,
27926,
63,
48,
4669,
1439,
26,
202,
199,
3,
259,
862,
26,
202,
199,
3,
263,
492,
14177,
331,
202,
199,
3,
259,
871,
3545,
26,
202,
199,
3,
263,
27926,
63,
48,
4669,
1439,
275,
756,
202,
199,
3,
202,
199,
3,
692,
440,
27926,
63,
48,
4669,
1439,
26,
202,
199,
3,
259,
1021,
14177,
331,
26,
202,
199,
3,
263,
347,
4566,
8,
1532,
304,
202,
199,
3,
3322,
372,
2562,
202,
199,
3,
263,
4566,
275,
12822,
8,
3280,
9,
2999,
199,
318,
1586,
18667,
16552,
8,
1745,
12,
1390,
6574,
29,
403,
304,
1128,
9444,
275,
3087,
1128,
1830,
715,
26,
1039,
8431,
275,
2547,
14,
739,
8,
17,
9,
1039,
340,
8431,
14,
23360,
342,
503,
440,
8431,
26,
1675,
2059,
1039,
9444,
847,
8431,
1039,
340,
822,
8,
2424,
9,
508,
1390,
6574,
26,
1675,
2059,
1128,
372,
9444,
2999,
199,
318,
1586,
6932,
16552,
8,
1745,
304,
1128,
8431,
275,
283,
283,
1128,
1830,
8431,
508,
1557,
78,
7,
503,
8431,
508,
1557,
82,
7,
503,
8431,
508,
283,
283,
503,
8431,
508,
1557,
84,
356,
1039,
8431,
275,
2547,
14,
739,
8,
17,
9,
1128,
372,
8431,
2999,
199,
533,
7905,
13967,
1378,
8735,
1296,
8,
785,
304,
1128,
347,
636,
826,
721,
277,
12,
2582,
3481,
12,
664,
3481,
304,
1039,
291,
14,
1267,
3481,
275,
2582,
3481,
1039,
291,
14,
362,
3481,
275,
664,
3481,
2958,
347,
636,
552,
721,
277,
304,
1039,
372,
291,
14,
1267,
3481,
342,
2958,
347,
636,
6095,
721,
277,
12,
1478,
304,
1039,
340,
440,
1228,
8,
1080,
12,
1109,
304,
1675,
746,
3146,
12,
298,
4041,
4918,
1471,
506,
9446,
2,
1039,
822,
63,
277,
275,
822,
8,
277,
9,
1039,
340,
1478,
665,
378,
26,
1675,
327,
2291,
6946,
10507,
1675,
1478,
847,
822,
63,
277,
1039,
340,
1478,
665,
378,
503,
1478,
2356,
822,
63,
277,
26,
1675,
746,
7888,
12,
298,
4041,
1478,
734,
402,
1425,
2,
1039,
372,
291,
14,
362,
3481,
8,
1080,
9,
2999,
199,
318,
29256,
20,
63,
11929,
8,
498,
12,
18577,
304,
1128,
428,
275,
359,
73,
367,
284,
315,
1425,
8,
3912,
1874,
1128,
1335,
275,
378,
1128,
367,
284,
315,
1425,
8,
3912,
304,
1039,
1335,
275,
334,
74,
435,
428,
59,
73,
61,
435,
6206,
8,
498,
59,
73,
450,
822,
8,
498,
19563,
450,
7633,
1039,
428,
59,
73,
467,
428,
59,
74,
61,
275,
428,
59,
74,
467,
428,
59,
73,
61,
1128,
284,
12,
1335,
275,
378,
12,
378,
1128,
9151,
275,
3087,
1128,
367,
671,
315,
1425,
8,
552,
8,
17426,
2298,
1039,
284,
275,
334,
73,
435,
413,
9,
450,
7633,
1039,
1335,
275,
334,
74,
435,
428,
59,
73,
566,
450,
7633,
1039,
428,
59,
73,
467,
428,
59,
74,
61,
275,
428,
59,
74,
467,
428,
59,
73,
61,
1039,
307,
275,
428,
7528,
51,
59,
73,
61,
435,
428,
59,
74,
566,
450,
7633,
61,
1039,
9151,
847,
8678,
8,
2181,
8,
17426,
59,
88,
566,
7167,
307,
9,
1128,
372,
9151,
2999,
199,
318,
3634,
25314,
590,
8,
65,
12,
330,
304,
1128,
372,
3474,
1838,
779,
1609,
8,
73,
3342,
1609,
8,
74,
9,
28086,
367,
284,
12,
1335,
315,
3482,
8,
1143,
12,
1048,
1874,
2628,
776,
367,
1048,
315,
3482,
2031,
66,
1874,
1675,
367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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
mhogg/pyvct
|
pyvct/pyvCT_plugin.py
|
1
|
11088
|
# -*- coding: utf-8 -*-
# Copyright (C) 2015 Michael Hogg
# This file is part of pyvCT - See LICENSE.txt for information on usage and redistribution
from abaqusGui import *
from abaqusConstants import ALL, CARTESIAN, SCALAR, INTEGRATION_POINT, CENTROID, ELEMENT_NODAL
from pyvCT_version import version as __version__
# Required to ensure the CSYS list is up to date
from kernelAccess import session
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class PyvCT_plugin(AFXForm):
def __init__(self, owner):
# Construct the base class
AFXForm.__init__(self, owner)
self.odb = None
self.csysList = None
self.stepList = None
self.elementSets = None
self.scalarList = None
self.sliceRes = ['256 x 256', '512 x 512']
self.suppLocs = [INTEGRATION_POINT, CENTROID, ELEMENT_NODAL]
# Keyword definitions
self.cmd = AFXGuiCommand(mode=self, method='createVirtualCT',objectName='virtualCTs', registerQuery=False)
self.odbNameKw = AFXStringKeyword(self.cmd, 'odbName', True, '')
self.bSetNameKw = AFXStringKeyword(self.cmd, 'bRegionSetName', True, '')
self.BMDfonameKw = AFXStringKeyword(self.cmd, 'BMDfoname', True, '')
self.showImplantKw = AFXBoolKeyword(self.cmd, 'showImplant', AFXBoolKeyword.TRUE_FALSE, True, False)
self.iSetNameKw = AFXStringKeyword(self.cmd, 'iRegionSetName', True, '')
self.iDensityKw = AFXFloatKeyword(self.cmd, 'iDensity', True, 4500)
self.stepNumberKw = AFXStringKeyword(self.cmd, 'stepNumber', True, '')
self.csysNameKw = AFXStringKeyword(self.cmd, 'csysName', True, '')
self.sliceResolutionKw = AFXStringKeyword(self.cmd, 'sliceResolution', True, self.sliceRes[0])
self.sliceSpacingKw = AFXFloatKeyword(self.cmd, 'sliceSpacing', True, 2.0)
self.subDirNameKw = AFXStringKeyword(self.cmd, 'newSubDirName', True, 'pyvCT')
#self.preferredXraySizeKw = AFXIntKeyword(self.cmd, 'preferredXraySize', True, 800)
#self.imageFormatKw = AFXStringKeyword(self.cmd, 'imageFormat', True, self.imageFormats[-1])
#self.smoothKw = AFXBoolKeyword(self.cmd, 'smooth', AFXBoolKeyword.TRUE_FALSE, True, True)
#self.manualScalingKw = AFXBoolKeyword(self.cmd, 'manualImageScaling', AFXBoolKeyword.TRUE_FALSE, True, False)
def getOdbList(self):
"""Get a list of all available odbs in session"""
self.odbList = session.odbs.keys()
def getFirstOdb(self):
"""Set first odb in first Dialog Box"""
if self.odbList==None or len(self.odbList)==0: return
self.setOdb(self.odbList[0])
def setOdb(self,odbName):
"""Set odb from name"""
if odbName=='': return
self.odb = session.odbs[odbName]
def getElementSetList(self):
"""Get list of all element sets in the current odb"""
self.elementSets=[]
if self.odb==None: return
# Check part instances
for instName,inst in self.odb.rootAssembly.instances.items():
self.elementSets.append('.'.join([instName,'ALL']))
for setName in inst.elementSets.keys():
self.elementSets.append('.'.join([instName,setName]))
# Check assembly
for setName in self.odb.rootAssembly.elementSets.keys():
self.elementSets.append(setName)
self.elementSets.sort()
def getCsyses(self):
"""Get list of all available csyses"""
# Check scratch odb csyses
self.csysList = {'Session':[], 'ODB':[]}
for k,v in session.scratchOdbs.items():
for csysName,csys in v.rootAssembly.datumCsyses.items():
if csys.type==CARTESIAN:
self.csysList['Session'].append(csysName)
# Check odb csyses if an odb is open in the current viewport
if self.odb != None:
for csysName,csys in self.odb.rootAssembly.datumCsyses.items():
if csys.type==CARTESIAN:
self.csysList['ODB'].append(csysName)
def getSteps(self):
"""Get list of all available steps"""
self.stepList=[]
if self.odb==None: return
for stepName in self.odb.steps.keys():
stepNumber = stepName.split('-')[-1]
self.stepList.append(stepNumber)
return
def getScalarList(self):
"""Get list of available scalars. Check last frame in all steps"""
self.scalarList=[]
if self.odb==None: return
includeList={}; excludeList={}
for step in self.odb.steps.values():
frame = step.frames[-1]
for k in frame.fieldOutputs.keys():
if excludeList.has_key(k) or includeList.has_key(k): continue
v = frame.fieldOutputs[k]
loc = [True for loc in v.locations if loc.position in self.suppLocs]
if any(loc) and v.type==SCALAR: includeList[k]=1
else: excludeList[k]=1
self.scalarList = includeList.keys()
self.scalarList.sort()
def getFirstDialog(self):
"""Create the dialog box"""
# Get odb information to populate the dialog box
self.getOdbList()
self.getFirstOdb()
self.getElementSetList()
self.getCsyses()
self.getSteps()
self.getScalarList()
# Create dialog box
import pyvCTDB
return pyvCTDB.PyvCTDB(self)
def doCustomChecks(self):
"""Define empty class function doCustomChecks to check user inputs"""
# Check that odb exists
self.getOdbList()
if self.odbNameKw.getValue() not in self.odbList:
showAFXErrorDialog(self.getCurrentDialog(), 'Error: Odb %s does not exist' % self.modelNameKw.getValue())
return False
# Check that bone region exists in model
self.getElementSetList()
if self.bSetNameKw.getValue() not in self.elementSets:
showAFXErrorDialog(self.getCurrentDialog(), 'Error: Bone region %s does not exist' % self.bSetNameKw.getValue())
return False
# If implant is requested, check implant inputs
if self.showImplantKw.getValue():
# Check implant region
self.getElementSetList()
if self.iSetNameKw.getValue() not in self.elementSets:
showAFXErrorDialog(self.getCurrentDialog(), 'Error: Implant region %s does not exist' % self.iSetNameKw.getValue())
return False
# Check input density
iDensity = self.iDensityKw.getValue()
try: float(iDensity)
except:
showAFXErrorDialog(self.getCurrentDialog(), 'Error: Implant density value is not a valid number')
return False
if iDensity<0:
showAFXErrorDialog(self.getCurrentDialog(), 'Error: Implant density must be greater than 0')
return False
# Check that values in stepList are valid
stepList = self.stepNumberKw.getValue()
try:
stepList = [int(s) for s in stepList.replace(',',' ').split()]
except:
showAFXErrorDialog(self.getCurrentDialog(), 'Error: Cannot convert step list values to integers')
return False
stepList.sort()
# Check that all steps in step list exist and that density variable exists in all steps (last frame)
BMDfoname = self.BMDfonameKw.getValue()
stepInfo = {}
for stepName,step in self.odb.steps.items():
stepNumber = int(stepName.split('-')[-1])
stepInfo[stepNumber] = step.frames[-1].fieldOutputs.keys()
for stepNumber in stepList:
if stepNumber not in stepInfo:
showAFXErrorDialog(self.getCurrentDialog(), 'Error: Step number %i is not available in odb' % stepNumber)
return False
if BMDfoname not in stepInfo[stepNumber]:
showAFXErrorDialog(self.getCurrentDialog(), 'Error: Density variable %s is not available in Step number %i' % (BMDfoname,stepNumber))
return False
"""
# Check mapping resolution, resGrid
resGrid = self.resGridKw.getValue()
try: resGrid = float(resGrid)
except:
showAFXErrorDialog(self.getCurrentDialog(), 'Error: "Inputs: Mapping resolution" value not valid')
return False
# Check preferred size of images
preferredXraySize = self.preferredXraySizeKw.getValue()
try: preferredXraySize = int(preferredXraySize)
except:
showAFXErrorDialog(self.getCurrentDialog(), 'Error: "X-ray Settings: Approx size of x-ray" value not valid')
return False
minXraySize = 100
if preferredXraySize < minXraySize:
showAFXErrorDialog(self.getCurrentDialog(), 'Error: Minimum virtual x-ray image size is %i pixels' % minXraySize)
return False
"""
# Check for Abaqus version >= 6.11
majorNumber, minorNumber, updateNumber = getAFXApp().getVersionNumbers()
if majorNumber==6 and minorNumber < 11:
showAFXErrorDialog( self.getCurrentDialog(), 'Error: ABAQUS 6.11 and above is required' )
return False
return True
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Register the plug-in
desc = 'An ABAQUS plugin used to generate a virtual CT from the output of a bone remodelling analysis.\n\n' + \
'The resulting images can be used to analyse the change in bone density over time in a number of regions of interest or "Gruen Zones", ' + \
'typically due to changes in loading following insertion of an orthopaedic implant. Associated tool BMDanalyse, available on PyPi, was ' + \
'created for this sole purpose.\n\nRequires an odb file to be open within the current viewport which has a fieldoutput representing ' + \
'bone density. Works by mapping the bone density fieldoutput onto a regular 3D grid and then projecting the values onto the three ' + \
'orthogonal planes. Currently only models with C3D4 or C3D10 elements are supported.'
toolset = getAFXApp().getAFXMainWindow().getPluginToolset()
toolset.registerGuiMenuButton(
buttonText='pyvCT|Create a virtual CT',
object=PyvCT_plugin(toolset),
messageId=AFXMode.ID_ACTIVATE,
icon=None,
kernelInitString='import virtualCTs',
applicableModules=ALL,
version=__version__,
author='Michael Hogg',
description=desc,
helpUrl='https://github.com/mhogg/pyvct'
)
|
mit
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
3,
1898,
334,
35,
9,
6900,
16922,
869,
24798,
199,
199,
3,
961,
570,
365,
1777,
402,
1134,
86,
1028,
446,
1666,
5113,
14,
2424,
367,
2556,
641,
4503,
436,
295,
4972,
199,
199,
504,
2236,
65,
392,
83,
4324,
492,
627,
199,
504,
2236,
65,
392,
83,
22185,
492,
11727,
12,
445,
2294,
654,
23273,
12,
12075,
748,
689,
12,
14985,
3975,
2594,
63,
7217,
12,
445,
1309,
22045,
12,
662,
10320,
63,
2826,
10741,
199,
504,
1134,
86,
1028,
63,
1023,
492,
1015,
465,
636,
1023,
363,
199,
3,
11105,
370,
4868,
314,
445,
13326,
769,
365,
1536,
370,
1434,
199,
504,
5114,
3946,
492,
2351,
257,
199,
199,
3,
30642,
30642,
2878,
1714,
199,
199,
533,
1611,
86,
1028,
63,
2718,
8,
5699,
56,
2821,
304,
339,
347,
636,
826,
721,
277,
12,
5771,
304,
2728,
327,
9215,
314,
1300,
1021,
4960,
20089,
56,
2821,
855,
826,
721,
277,
12,
5771,
9,
398,
291,
14,
13152,
3515,
275,
488,
27144,
291,
14,
1259,
588,
1296,
258,
275,
488,
3515,
267,
291,
14,
2926,
1296,
258,
275,
488,
267,
291,
14,
2108,
9899,
221,
275,
488,
267,
291,
14,
7033,
1296,
257,
275,
488,
267,
291,
14,
5224,
1322,
258,
275,
788,
3912,
671,
7633,
297,
283,
7736,
671,
10574,
418,
267,
291,
14,
8621,
3040,
83,
258,
275,
359,
2919,
37,
3975,
2594,
63,
7217,
12,
445,
1309,
22045,
12,
662,
10320,
63,
2826,
10741,
61,
2728,
327,
6431,
10269,
267,
291,
14,
1760,
463,
275,
20089,
56,
4324,
3110,
8,
632,
29,
277,
12,
1083,
534,
981,
8735,
1028,
297,
785,
985,
534,
2065,
1028,
83,
297,
2274,
3227,
29,
797,
9,
267,
291,
14,
13152,
985,
26643,
3698,
275,
20089,
56,
1558,
10650,
8,
277,
14,
1760,
12,
283,
13152,
985,
297,
715,
12,
4074,
267,
291,
14,
66,
1084,
985,
26643,
3515,
275,
20089,
56,
1558,
10650,
8,
277,
14,
1760,
12,
283,
66,
10708,
1084,
985,
297,
715,
12,
4074,
267,
291,
14,
34,
5127,
70,
32203,
26643,
260,
275,
20089,
56,
1558,
10650,
8,
277,
14,
1760,
12,
283,
34,
5127,
70,
32203,
297,
715,
12,
4074,
267,
291,
14,
2384,
4748,
867,
26643,
755,
275,
20089,
56,
10349,
10650,
8,
277,
14,
1760,
12,
257,
283,
2384,
4748,
867,
297,
20089,
56,
10349,
10650,
14,
15064,
63,
19823,
12,
715,
12,
756,
9,
267,
291,
14,
73,
1084,
985,
26643,
3515,
275,
20089,
56,
1558,
10650,
8,
277,
14,
1760,
12,
283,
73,
10708,
1084,
985,
297,
715,
12,
4074,
267,
291,
14,
73,
26211,
26643,
3515,
275,
20089,
56,
5136,
10650,
8,
277,
14,
1760,
12,
221,
283,
73,
26211,
297,
715,
12,
841,
5783,
9,
267,
291,
14,
2926,
3259,
26643,
263,
275,
20089,
56,
1558,
10650,
8,
277,
14,
1760,
12,
283,
2926,
3259,
297,
715,
12,
4074,
267,
291,
14,
1259,
588,
985,
26643,
3515,
275,
20089,
56,
1558,
10650,
8,
277,
14,
1760,
12,
283,
1259,
588,
985,
297,
715,
12,
4074,
18418,
291,
14,
5224,
18508,
26643,
257,
275,
20089,
56,
1558,
10650,
8,
277,
14,
1760,
12,
283,
5224,
18508,
297,
715,
12,
291,
14,
5224,
1322,
59,
16,
566,
267,
291,
14,
5224,
24052,
26643,
420,
275,
20089,
56,
5136,
10650,
8,
277,
14,
1760,
12,
221,
283,
5224,
24052,
297,
715,
12,
499,
14,
16,
9,
267,
291,
14,
954,
3567,
985,
26643,
263,
275,
20089,
56,
1558,
10650,
8,
277,
14,
1760,
12,
283,
1222,
2610,
3567,
985,
297,
715,
12,
283,
647,
86,
1028,
358,
267,
327,
277,
14,
17477,
56,
803,
2320,
26643,
275,
20089,
56,
3241,
10650,
8,
277,
14,
1760,
12,
259,
283,
17477,
56,
803,
2320,
297,
715,
12,
23466,
9,
267,
327,
277,
14,
1569,
3484,
26643,
755,
275,
20089,
56,
1558,
10650,
8,
277,
14,
1760,
12,
283,
1569,
3484,
297,
715,
12,
291,
14,
1569,
29717,
1988,
17,
566,
267,
327,
277,
14,
19169,
26643,
3322,
275,
20089,
56,
10349,
10650,
8,
277,
14,
1760,
12,
257,
283,
19169,
297,
20089,
56,
10349,
10650,
14,
15064,
63,
19823,
12,
715,
12,
715,
9,
267,
327,
277,
14,
9285,
26416,
26643,
258,
275,
20089,
56,
10349,
10650,
8,
277,
14,
1760,
12,
257,
283,
9285,
3491,
26416,
297,
20089,
56,
10349,
10650,
14,
15064,
63,
19823,
12,
715,
12,
756,
9,
490,
272,
347,
664,
47,
697,
1296,
8,
277,
304,
267,
408,
1002,
282,
769,
402,
1006,
2808,
312,
30764,
315,
2351,
624,
267,
291,
14,
13152,
1296,
275,
2351,
14,
364,
1533,
14,
1612,
342,
5493,
347,
664,
7147,
47,
697,
8,
277,
304,
267,
408,
1084,
1642,
312,
697,
315,
1642,
30631,
20783,
624,
267,
340,
291,
14,
13152,
1296,
389,
403,
503,
822,
8,
277,
14,
13152,
1296,
12694,
16,
26,
372,
267,
291,
14,
409,
47,
697,
8,
277,
14,
13152,
1296,
59,
16,
566,
339,
347,
663,
47,
697,
8,
277,
12,
13152,
985,
304,
267,
408,
1084,
312,
697,
687,
536,
624,
267,
340,
312,
697,
985,
6803,
356,
372,
267,
291,
14,
13152,
275,
2351,
14,
364,
1533,
59,
13152,
985,
61,
259,
339,
347,
664,
2162,
1084,
1296,
8,
277,
304,
267,
408,
1002,
769,
402,
1006,
1819,
5951,
315,
314,
1453,
312,
697,
624,
267,
291,
14,
2108,
9899,
9811,
267,
340,
291,
14,
13152,
389,
403,
26,
372,
267,
327,
2670,
1777,
4454,
267,
367,
2727,
985,
12,
3615,
315,
291,
14,
13152,
14,
1231,
16489,
14,
5990,
14,
1744,
837,
288,
291,
14,
2108,
9899,
14,
740,
5175,
1370,
904,
779,
3615,
985,
2584,
1761,
5156,
288,
367,
663,
985,
315,
2727,
14,
2108,
9899,
14,
1612,
837,
355,
291,
14,
2108,
9899,
14,
740,
5175,
1370,
904,
779,
3615,
985,
12,
18347,
2459,
267,
327,
2670,
24869,
3777,
267,
367,
663,
985,
315,
291,
14,
13152,
14,
1231,
16489,
14,
2108,
9899,
14,
1612,
837,
288,
291,
14,
2108,
9899,
14,
740,
8,
18347,
9,
267,
291,
14,
2108,
9899,
14,
3191,
342,
3515,
5493,
347,
664,
35,
1786,
874,
8,
277,
304,
4960,
408,
1002,
769,
402,
1006,
2808,
286,
1786,
874,
624,
267
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
3,
1898,
334,
35,
9,
6900,
16922,
869,
24798,
199,
199,
3,
961,
570,
365,
1777,
402,
1134,
86,
1028,
446,
1666,
5113,
14,
2424,
367,
2556,
641,
4503,
436,
295,
4972,
199,
199,
504,
2236,
65,
392,
83,
4324,
492,
627,
199,
504,
2236,
65,
392,
83,
22185,
492,
11727,
12,
445,
2294,
654,
23273,
12,
12075,
748,
689,
12,
14985,
3975,
2594,
63,
7217,
12,
445,
1309,
22045,
12,
662,
10320,
63,
2826,
10741,
199,
504,
1134,
86,
1028,
63,
1023,
492,
1015,
465,
636,
1023,
363,
199,
3,
11105,
370,
4868,
314,
445,
13326,
769,
365,
1536,
370,
1434,
199,
504,
5114,
3946,
492,
2351,
257,
199,
199,
3,
30642,
30642,
2878,
1714,
199,
199,
533,
1611,
86,
1028,
63,
2718,
8,
5699,
56,
2821,
304,
339,
347,
636,
826,
721,
277,
12,
5771,
304,
2728,
327,
9215,
314,
1300,
1021,
4960,
20089,
56,
2821,
855,
826,
721,
277,
12,
5771,
9,
398,
291,
14,
13152,
3515,
275,
488,
27144,
291,
14,
1259,
588,
1296,
258,
275,
488,
3515,
267,
291,
14,
2926,
1296,
258,
275,
488,
267,
291,
14,
2108,
9899,
221,
275,
488,
267,
291,
14,
7033,
1296,
257,
275,
488,
267,
291,
14,
5224,
1322,
258,
275,
788,
3912,
671,
7633,
297,
283,
7736,
671,
10574,
418,
267,
291,
14,
8621,
3040,
83,
258,
275,
359,
2919,
37,
3975,
2594,
63,
7217,
12,
445,
1309,
22045,
12,
662,
10320,
63,
2826,
10741,
61,
2728,
327,
6431,
10269,
267,
291,
14,
1760,
463,
275,
20089,
56,
4324,
3110,
8,
632,
29,
277,
12,
1083,
534,
981,
8735,
1028,
297,
785,
985,
534,
2065,
1028,
83,
297,
2274,
3227,
29,
797,
9,
267,
291,
14,
13152,
985,
26643,
3698,
275,
20089,
56,
1558,
10650,
8,
277,
14,
1760,
12,
283,
13152,
985,
297,
715,
12,
4074,
267,
291,
14,
66,
1084,
985,
26643,
3515,
275,
20089,
56,
1558,
10650,
8,
277,
14,
1760,
12,
283,
66,
10708,
1084,
985,
297,
715,
12,
4074,
267,
291,
14,
34,
5127,
70,
32203,
26643,
260,
275,
20089,
56,
1558,
10650,
8,
277,
14,
1760,
12,
283,
34,
5127,
70,
32203,
297,
715,
12,
4074,
267,
291,
14,
2384,
4748,
867,
26643,
755,
275,
20089,
56,
10349,
10650,
8,
277,
14,
1760,
12,
257,
283,
2384,
4748,
867,
297,
20089,
56,
10349,
10650,
14,
15064,
63,
19823,
12,
715,
12,
756,
9,
267,
291,
14,
73,
1084,
985,
26643,
3515,
275,
20089,
56,
1558,
10650,
8,
277,
14,
1760,
12,
283,
73,
10708,
1084,
985,
297,
715,
12,
4074,
267,
291,
14,
73,
26211,
26643,
3515,
275,
20089,
56,
5136,
10650,
8,
277,
14,
1760,
12,
221,
283,
73,
26211,
297,
715,
12,
841,
5783,
9,
267,
291,
14,
2926,
3259,
26643,
263,
275,
20089,
56,
1558,
10650,
8,
277,
14,
1760,
12,
283,
2926,
3259,
297,
715,
12,
4074,
267,
291,
14,
1259,
588,
985,
26643,
3515,
275,
20089,
56,
1558,
10650,
8,
277,
14,
1760,
12,
283,
1259,
588,
985,
297,
715,
12,
4074,
18418,
291,
14,
5224,
18508,
26643,
257,
275,
20089,
56,
1558,
10650,
8,
277,
14,
1760,
12,
283,
5224,
18508,
297,
715,
12,
291,
14,
5224,
1322,
59,
16,
566,
267,
291,
14,
5224,
24052,
26643,
420,
275,
20089,
56,
5136,
10650,
8,
277,
14,
1760,
12,
221,
283,
5224,
24052,
297,
715,
12,
499,
14,
16,
9,
267,
291,
14,
954,
3567,
985,
26643,
263,
275,
20089,
56,
1558,
10650,
8,
277,
14,
1760,
12,
283,
1222,
2610,
3567,
985,
297,
715,
12,
283,
647,
86,
1028,
358,
267,
327,
277,
14,
17477,
56,
803,
2320,
26643,
275,
20089,
56,
3241,
10650,
8,
277,
14,
1760,
12,
259,
283,
17477,
56,
803,
2320,
297,
715,
12,
23466,
9,
267,
327,
277,
14,
1569,
3484,
26643,
755,
275,
20089,
56,
1558,
10650,
8,
277,
14,
1760,
12,
283,
1569,
3484,
297,
715,
12,
291,
14,
1569,
29717,
1988,
17,
566,
267,
327,
277,
14,
19169,
26643,
3322,
275,
20089,
56,
10349,
10650,
8,
277,
14,
1760,
12,
257,
283,
19169,
297,
20089,
56,
10349,
10650,
14,
15064,
63,
19823,
12,
715,
12,
715,
9,
267,
327,
277,
14,
9285,
26416,
26643,
258,
275,
20089,
56,
10349,
10650,
8,
277,
14,
1760,
12,
257,
283,
9285,
3491,
26416,
297,
20089,
56,
10349,
10650,
14,
15064,
63,
19823,
12,
715,
12,
756,
9,
490,
272,
347,
664,
47,
697,
1296,
8,
277,
304,
267,
408,
1002,
282,
769,
402,
1006,
2808,
312,
30764,
315,
2351,
624,
267,
291,
14,
13152,
1296,
275,
2351,
14,
364,
1533,
14,
1612,
342,
5493,
347,
664,
7147,
47,
697,
8,
277,
304,
267,
408,
1084,
1642,
312,
697,
315,
1642,
30631,
20783,
624,
267,
340,
291,
14,
13152,
1296,
389,
403,
503,
822,
8,
277,
14,
13152,
1296,
12694,
16,
26,
372,
267,
291,
14,
409,
47,
697,
8,
277,
14,
13152,
1296,
59,
16,
566,
339,
347,
663,
47,
697,
8,
277,
12,
13152,
985,
304,
267,
408,
1084,
312,
697,
687,
536,
624,
267,
340,
312,
697,
985,
6803,
356,
372,
267,
291,
14,
13152,
275,
2351,
14,
364,
1533,
59,
13152,
985,
61,
259,
339,
347,
664,
2162,
1084,
1296,
8,
277,
304,
267,
408,
1002,
769,
402,
1006,
1819,
5951,
315,
314,
1453,
312,
697,
624,
267,
291,
14,
2108,
9899,
9811,
267,
340,
291,
14,
13152,
389,
403,
26,
372,
267,
327,
2670,
1777,
4454,
267,
367,
2727,
985,
12,
3615,
315,
291,
14,
13152,
14,
1231,
16489,
14,
5990,
14,
1744,
837,
288,
291,
14,
2108,
9899,
14,
740,
5175,
1370,
904,
779,
3615,
985,
2584,
1761,
5156,
288,
367,
663,
985,
315,
2727,
14,
2108,
9899,
14,
1612,
837,
355,
291,
14,
2108,
9899,
14,
740,
5175,
1370,
904,
779,
3615,
985,
12,
18347,
2459,
267,
327,
2670,
24869,
3777,
267,
367,
663,
985,
315,
291,
14,
13152,
14,
1231,
16489,
14,
2108,
9899,
14,
1612,
837,
288,
291,
14,
2108,
9899,
14,
740,
8,
18347,
9,
267,
291,
14,
2108,
9899,
14,
3191,
342,
3515,
5493,
347,
664,
35,
1786,
874,
8,
277,
304,
4960,
408,
1002,
769,
402,
1006,
2808,
286,
1786,
874,
624,
267,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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-ruby-tests.py
|
829
|
3042
|
#!/usr/bin/env python
# - * - coding: UTF-8 - * -
"""
This script generates tests text-emphasis-ruby-001 ~ 004 which tests
emphasis marks with ruby in four directions. It outputs a list of all
tests it generated in the format of Mozilla reftest.list to the stdout.
"""
from __future__ import unicode_literals
TEST_FILE = 'text-emphasis-ruby-{:03}{}.html'
TEST_TEMPLATE = '''<!DOCTYPE html>
<meta charset="utf-8">
<title>CSS Test: text-emphasis and ruby, {wm}, {pos}</title>
<link rel="author" title="Xidorn Quan" href="https://www.upsuper.org">
<link rel="author" title="Mozilla" href="https://www.mozilla.org">
<link rel="help" href="https://drafts.csswg.org/css-text-decor-3/#text-emphasis-position-property">
<meta name="assert" content="emphasis marks are drawn outside the ruby">
<link rel="match" href="text-emphasis-ruby-{index:03}-ref.html">
<p>Pass if the emphasis marks are outside the ruby:</p>
<div style="line-height: 5; writing-mode: {wm}; ruby-position: {ruby_pos}; text-emphasis-position: {posval}">ルビ<span style="text-emphasis: circle">と<ruby>圏<rt>けん</rt>点<rt>てん</rt></ruby>を</span>同時</div>
'''
REF_FILE = 'text-emphasis-ruby-{:03}-ref.html'
REF_TEMPLATE = '''<!DOCTYPE html>
<meta charset="utf-8">
<title>CSS Reference: text-emphasis and ruby, {wm}, {pos}</title>
<link rel="author" title="Xidorn Quan" href="https://www.upsuper.org">
<link rel="author" title="Mozilla" href="https://www.mozilla.org">
<style> rtc {{ font-variant-east-asian: inherit; }} </style>
<p>Pass if the emphasis marks are outside the ruby:</p>
<div style="line-height: 5; writing-mode: {wm}; ruby-position: {posval}">ルビ<ruby>と<rtc>●</rtc>圏<rt>けん</rt><rtc>●</rtc>点<rt>てん</rt><rtc>●</rtc>を<rtc>●</rtc></ruby>同時</div>
'''
TEST_CASES = [
('top', 'horizontal-tb', 'over', [
('horizontal-tb', 'over right')]),
('bottom', 'horizontal-tb', 'under', [
('horizontal-tb', 'under right')]),
('right', 'vertical-rl', 'over', [
('vertical-rl', 'over right'),
('vertical-lr', 'over right')]),
('left', 'vertical-rl', 'under', [
('vertical-rl', 'over left'),
('vertical-lr', 'over left')]),
]
SUFFIXES = ['', 'a']
def write_file(filename, content):
with open(filename, 'wb') as f:
f.write(content.encode('UTF-8'))
print("# START tests from {}".format(__file__))
idx = 0
for pos, ref_wm, ruby_pos, subtests in TEST_CASES:
idx += 1
ref_file = REF_FILE.format(idx)
ref_content = REF_TEMPLATE.format(pos=pos, wm=ref_wm, posval=ruby_pos)
write_file(ref_file, ref_content)
suffix = iter(SUFFIXES)
for wm, posval in subtests:
test_file = TEST_FILE.format(idx, next(suffix))
test_content = TEST_TEMPLATE.format(
wm=wm, pos=pos, index=idx, ruby_pos=ruby_pos, posval=posval)
write_file(test_file, test_content)
print("== {} {}".format(test_file, ref_file))
print("# END tests from {}".format(__file__))
|
mpl-2.0
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
3,
446,
627,
446,
2803,
26,
9094,
13,
24,
446,
627,
446,
199,
199,
624,
199,
2765,
2884,
12821,
2295,
1318,
13,
28907,
13,
21952,
13,
4587,
6146,
378,
966,
1314,
2295,
199,
28907,
17370,
543,
31855,
315,
11648,
28820,
14,
2779,
4704,
282,
769,
402,
1006,
199,
2219,
652,
4046,
315,
314,
1475,
402,
17728,
2984,
396,
14,
513,
370,
314,
3839,
14,
199,
624,
199,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
2864,
63,
3817,
275,
283,
505,
13,
28907,
13,
21952,
24185,
26,
1644,
93,
31270,
1360,
7,
199,
2864,
63,
7433,
275,
1449,
11230,
16556,
3517,
30,
199,
28,
2024,
5960,
628,
1624,
13,
24,
1743,
199,
28,
1213,
30,
14391,
1379,
26,
1318,
13,
28907,
436,
31855,
12,
469,
16240,
1386,
469,
1712,
17890,
1213,
30,
199,
28,
1073,
4668,
628,
2502,
2,
2538,
628,
56,
344,
6161,
5843,
290,
2,
4369,
628,
2859,
921,
1544,
14,
384,
4792,
14,
1308,
1743,
199,
28,
1073,
4668,
628,
2502,
2,
2538,
628,
22285,
2,
4369,
628,
2859,
921,
1544,
14,
12102,
14,
1308,
1743,
199,
28,
1073,
4668,
628,
3437,
2,
4369,
628,
2859,
921,
7185,
83,
14,
3919,
23596,
14,
1308,
15,
3919,
13,
505,
13,
6518,
13,
19,
12645,
505,
13,
28907,
13,
3124,
13,
1829,
1743,
199,
28,
2024,
536,
628,
479,
2,
1564,
628,
28907,
17370,
787,
19341,
9682,
314,
31855,
1743,
199,
28,
1073,
4668,
628,
1431,
2,
4369,
628,
505,
13,
28907,
13,
21952,
24185,
1080,
26,
1644,
17063,
1121,
14,
1360,
1743,
199,
28,
80,
30,
4986,
340,
314,
9052,
24059,
17370,
787,
9682,
314,
31855,
9919,
80,
30,
199,
28,
3015,
3449,
628,
604,
13,
3333,
26,
959,
27,
3575,
13,
632,
26,
469,
16240,
12084,
31855,
13,
3124,
26,
469,
21952,
63,
1712,
12084,
1318,
13,
28907,
13,
3124,
26,
469,
1712,
637,
93,
1743,
29910,
5692,
242,
28,
3751,
3449,
628,
505,
13,
28907,
26,
17990,
1743,
29472,
28,
21952,
30,
11987,
238,
28,
2591,
30,
4197,
240,
5573,
242,
1108,
2591,
30,
164,
225,
118,
28,
2591,
30,
4197,
100,
5573,
242,
1108,
2591,
2957,
21952,
30,
17593,
1108,
3751,
30,
28956,
163,
248,
225,
1108,
3015,
30,
199,
2344,
199,
199,
8279,
63,
3817,
275,
283,
505,
13,
28907,
13,
21952,
24185,
26,
1644,
17063,
1121,
14,
1360,
7,
199,
8279,
63,
7433,
275,
1449,
11230,
16556,
3517,
30,
199,
28,
2024,
5960,
628,
1624,
13,
24,
1743,
199,
28,
1213,
30,
14391,
10944,
26,
1318,
13,
28907,
436,
31855,
12,
469,
16240,
1386,
469,
1712,
17890,
1213,
30,
199,
28,
1073,
4668,
628,
2502,
2,
2538,
628,
56,
344,
6161,
5843,
290,
2,
4369,
628,
2859,
921,
1544,
14,
384,
4792,
14,
1308,
1743,
199,
28,
1073,
4668,
628,
2502,
2,
2538,
628,
22285,
2,
4369,
628,
2859,
921,
1544,
14,
12102,
14,
1308,
1743,
199,
28,
2487,
30,
519,
3641,
8448,
5023,
13,
8759,
13,
14346,
13,
305,
5653,
26,
8287,
27,
3586,
3068,
2487,
30,
199,
28,
80,
30,
4986,
340,
314,
9052,
24059,
17370,
787,
9682,
314,
31855,
9919,
80,
30,
199,
28,
3015,
3449,
628,
604,
13,
3333,
26,
959,
27,
3575,
13,
632,
26,
469,
16240,
12084,
31855,
13,
3124,
26,
469,
1712,
637,
93,
1743,
29910,
5692,
242,
28,
21952,
30,
29472,
28,
23392,
30,
7997,
88,
821,
5487,
12279,
23392,
30,
11987,
238,
28,
2591,
30,
4197,
240,
5573,
242,
1108,
2591,
2535,
23392,
30,
7997,
88,
821,
5487,
12279,
23392,
30,
164,
225,
118,
28,
2591,
30,
4197,
100,
5573,
242,
1108,
2591,
2535,
23392,
30,
7997,
88,
821,
5487,
12279,
23392,
30,
17593,
28,
23392,
30,
7997,
88,
821,
5487,
12279,
23392,
2957,
21952,
30,
28956,
163,
248,
225,
1108,
3015,
30,
199,
2344,
199,
199,
2864,
63,
9777,
654,
275,
359,
267,
661,
2119,
297,
283,
11392,
13,
5842,
297,
283,
1883,
297,
359,
288,
661,
11392,
13,
5842,
297,
283,
1883,
2451,
22864,
267,
661,
8305,
297,
283,
11392,
13,
5842,
297,
283,
7138,
297,
359,
288,
661,
11392,
13,
5842,
297,
283,
7138,
2451,
22864,
267,
661,
1019,
297,
283,
7870,
13,
4308,
297,
283,
1883,
297,
359,
288,
661,
7870,
13,
4308,
297,
283,
1883,
2451,
659,
288,
661,
7870,
13,
7493,
297,
283,
1883,
2451,
22864,
267,
661,
3039,
297,
283,
7870,
13,
4308,
297,
283,
7138,
297,
359,
288,
661,
7870,
13,
4308,
297,
283,
1883,
3602,
659,
288,
661,
7870,
13,
7493,
297,
283,
1883,
3602,
22864,
272,
1622,
199,
199,
12273,
654,
275,
18179,
283,
65,
418,
199,
199,
318,
2218,
63,
493,
8,
1501,
12,
1564,
304,
272,
543,
1551,
8,
1501,
12,
283,
6603,
358,
465,
289,
26,
267,
289,
14,
952,
8,
1317,
14,
2143,
360,
6610,
13,
24,
1333,
199,
199,
1361,
10064,
13910,
2295,
687,
8352,
908,
3460,
493,
8964,
199,
2996,
275,
378,
199,
509,
2086,
12,
2984,
63,
16240,
12,
31855,
63,
1712,
12,
1007,
2219,
315,
7393,
63,
9777,
654,
26,
272,
4280,
847,
413,
272,
2984,
63,
493,
275,
5363,
38,
63,
3817,
14,
908,
8,
2996,
9,
272,
2984,
63,
1317,
275,
5363,
38,
63,
7433,
14,
908,
8,
1712,
29,
1712,
12,
29835,
29,
1121,
63,
16240,
12,
2086,
637,
29,
21952,
63,
1712,
9,
272,
2218,
63,
493,
8,
1121,
63,
493,
12,
2984,
63,
1317,
9,
272,
4739,
275,
2740,
8,
12273,
654,
9,
272,
367,
29835,
12,
2086,
637,
315,
1007,
2219,
26,
267,
511,
63,
493,
275,
7393,
63,
3817,
14,
908,
8,
2996,
12,
2163,
8,
4511,
430,
267,
511,
63,
1317,
275,
7393,
63,
7433,
14,
908,
8,
288,
29835,
29,
16240,
12,
2086,
29,
1712,
12,
1478,
29,
2996,
12,
31855,
63,
1712,
29,
21952,
63,
1712,
12,
2086,
637,
29,
1712,
637,
9,
267,
2218,
63,
493,
8,
396,
63,
493,
12,
511,
63,
1317,
9,
267,
870,
480,
389,
1052,
8352,
908,
8,
396,
63,
493,
12,
2984,
63,
493,
430,
199,
1361,
10064,
7729,
2295,
687,
8352,
908,
3460,
493,
8964,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
3,
446,
627,
446,
2803,
26,
9094,
13,
24,
446,
627,
446,
199,
199,
624,
199,
2765,
2884,
12821,
2295,
1318,
13,
28907,
13,
21952,
13,
4587,
6146,
378,
966,
1314,
2295,
199,
28907,
17370,
543,
31855,
315,
11648,
28820,
14,
2779,
4704,
282,
769,
402,
1006,
199,
2219,
652,
4046,
315,
314,
1475,
402,
17728,
2984,
396,
14,
513,
370,
314,
3839,
14,
199,
624,
199,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
2864,
63,
3817,
275,
283,
505,
13,
28907,
13,
21952,
24185,
26,
1644,
93,
31270,
1360,
7,
199,
2864,
63,
7433,
275,
1449,
11230,
16556,
3517,
30,
199,
28,
2024,
5960,
628,
1624,
13,
24,
1743,
199,
28,
1213,
30,
14391,
1379,
26,
1318,
13,
28907,
436,
31855,
12,
469,
16240,
1386,
469,
1712,
17890,
1213,
30,
199,
28,
1073,
4668,
628,
2502,
2,
2538,
628,
56,
344,
6161,
5843,
290,
2,
4369,
628,
2859,
921,
1544,
14,
384,
4792,
14,
1308,
1743,
199,
28,
1073,
4668,
628,
2502,
2,
2538,
628,
22285,
2,
4369,
628,
2859,
921,
1544,
14,
12102,
14,
1308,
1743,
199,
28,
1073,
4668,
628,
3437,
2,
4369,
628,
2859,
921,
7185,
83,
14,
3919,
23596,
14,
1308,
15,
3919,
13,
505,
13,
6518,
13,
19,
12645,
505,
13,
28907,
13,
3124,
13,
1829,
1743,
199,
28,
2024,
536,
628,
479,
2,
1564,
628,
28907,
17370,
787,
19341,
9682,
314,
31855,
1743,
199,
28,
1073,
4668,
628,
1431,
2,
4369,
628,
505,
13,
28907,
13,
21952,
24185,
1080,
26,
1644,
17063,
1121,
14,
1360,
1743,
199,
28,
80,
30,
4986,
340,
314,
9052,
24059,
17370,
787,
9682,
314,
31855,
9919,
80,
30,
199,
28,
3015,
3449,
628,
604,
13,
3333,
26,
959,
27,
3575,
13,
632,
26,
469,
16240,
12084,
31855,
13,
3124,
26,
469,
21952,
63,
1712,
12084,
1318,
13,
28907,
13,
3124,
26,
469,
1712,
637,
93,
1743,
29910,
5692,
242,
28,
3751,
3449,
628,
505,
13,
28907,
26,
17990,
1743,
29472,
28,
21952,
30,
11987,
238,
28,
2591,
30,
4197,
240,
5573,
242,
1108,
2591,
30,
164,
225,
118,
28,
2591,
30,
4197,
100,
5573,
242,
1108,
2591,
2957,
21952,
30,
17593,
1108,
3751,
30,
28956,
163,
248,
225,
1108,
3015,
30,
199,
2344,
199,
199,
8279,
63,
3817,
275,
283,
505,
13,
28907,
13,
21952,
24185,
26,
1644,
17063,
1121,
14,
1360,
7,
199,
8279,
63,
7433,
275,
1449,
11230,
16556,
3517,
30,
199,
28,
2024,
5960,
628,
1624,
13,
24,
1743,
199,
28,
1213,
30,
14391,
10944,
26,
1318,
13,
28907,
436,
31855,
12,
469,
16240,
1386,
469,
1712,
17890,
1213,
30,
199,
28,
1073,
4668,
628,
2502,
2,
2538,
628,
56,
344,
6161,
5843,
290,
2,
4369,
628,
2859,
921,
1544,
14,
384,
4792,
14,
1308,
1743,
199,
28,
1073,
4668,
628,
2502,
2,
2538,
628,
22285,
2,
4369,
628,
2859,
921,
1544,
14,
12102,
14,
1308,
1743,
199,
28,
2487,
30,
519,
3641,
8448,
5023,
13,
8759,
13,
14346,
13,
305,
5653,
26,
8287,
27,
3586,
3068,
2487,
30,
199,
28,
80,
30,
4986,
340,
314,
9052,
24059,
17370,
787,
9682,
314,
31855,
9919,
80,
30,
199,
28,
3015,
3449,
628,
604,
13,
3333,
26,
959,
27,
3575,
13,
632,
26,
469,
16240,
12084,
31855,
13,
3124,
26,
469,
1712,
637,
93,
1743,
29910,
5692,
242,
28,
21952,
30,
29472,
28,
23392,
30,
7997,
88,
821,
5487,
12279,
23392,
30,
11987,
238,
28,
2591,
30,
4197,
240,
5573,
242,
1108,
2591,
2535,
23392,
30,
7997,
88,
821,
5487,
12279,
23392,
30,
164,
225,
118,
28,
2591,
30,
4197,
100,
5573,
242,
1108,
2591,
2535,
23392,
30,
7997,
88,
821,
5487,
12279,
23392,
30,
17593,
28,
23392,
30,
7997,
88,
821,
5487,
12279,
23392,
2957,
21952,
30,
28956,
163,
248,
225,
1108,
3015,
30,
199,
2344,
199,
199,
2864,
63,
9777,
654,
275,
359,
267,
661,
2119,
297,
283,
11392,
13,
5842,
297,
283,
1883,
297,
359,
288,
661,
11392,
13,
5842,
297,
283,
1883,
2451,
22864,
267,
661,
8305,
297,
283,
11392,
13,
5842,
297,
283,
7138,
297,
359,
288,
661,
11392,
13,
5842,
297,
283,
7138,
2451,
22864,
267,
661,
1019,
297,
283,
7870,
13,
4308,
297,
283,
1883,
297,
359,
288,
661,
7870,
13,
4308,
297,
283,
1883,
2451,
659,
288,
661,
7870,
13,
7493,
297,
283,
1883,
2451,
22864,
267,
661,
3039,
297,
283,
7870,
13,
4308,
297,
283,
7138,
297,
359,
288,
661,
7870,
13,
4308,
297,
283,
1883,
3602,
659,
288,
661,
7870,
13,
7493,
297,
283,
1883,
3602,
22864,
272,
1622,
199,
199,
12273,
654,
275,
18179,
283,
65,
418,
199,
199,
318,
2218,
63,
493,
8,
1501,
12,
1564,
304,
272,
543,
1551,
8,
1501,
12,
283,
6603,
358,
465,
289,
26,
267,
289,
14,
952,
8,
1317,
14,
2143,
360,
6610,
13,
24,
1333,
199,
199,
1361,
10064,
13910,
2295,
687,
8352,
908,
3460,
493,
8964,
199,
2996,
275,
378,
199,
509,
2086,
12,
2984,
63,
16240,
12,
31855,
63,
1712,
12,
1007,
2219,
315,
7393,
63,
9777,
654,
26,
272,
4280,
847,
413,
272,
2984,
63,
493,
275,
5363,
38,
63,
3817,
14,
908,
8,
2996,
9,
272,
2984,
63,
1317,
275,
5363,
38,
63,
7433,
14,
908,
8,
1712,
29,
1712,
12,
29835,
29,
1121,
63,
16240,
12,
2086,
637,
29,
21952,
63,
1712,
9,
272,
2218,
63,
493,
8,
1121,
63,
493,
12,
2984,
63,
1317,
9,
272,
4739,
275,
2740,
8,
12273,
654,
9,
272,
367,
29835,
12,
2086,
637,
315,
1007,
2219,
26,
267,
511,
63,
493,
275,
7393,
63,
3817,
14,
908,
8,
2996,
12,
2163,
8,
4511,
430,
267,
511,
63,
1317,
275,
7393,
63,
7433,
14,
908,
8,
288,
29835,
29,
16240,
12,
2086,
29,
1712,
12,
1478,
29,
2996,
12,
31855,
63,
1712,
29,
21952,
63,
1712,
12,
2086,
637,
29,
1712,
637,
9,
267,
2218,
63,
493,
8,
396,
63,
493,
12,
511,
63,
1317,
9,
267,
870,
480,
389,
1052,
8352,
908,
8,
396,
63,
493,
12,
2984,
63,
493,
430,
199,
1361,
10064,
7729,
2295,
687,
8352,
908,
3460,
493,
8964,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
mogoweb/chromium-crosswalk
|
tools/deep_memory_profiler/lib/policy.py
|
48
|
12592
|
# Copyright 2013 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import json
import logging
import os
import re
LOGGER = logging.getLogger('dmprof')
BASE_PATH = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
POLICIES_JSON_PATH = os.path.join(BASE_PATH, 'policies.json')
# Heap Profile Policy versions
# POLICY_DEEP_1 DOES NOT include allocation_type columns.
# mmap regions are distincted w/ mmap frames in the pattern column.
POLICY_DEEP_1 = 'POLICY_DEEP_1'
# POLICY_DEEP_2 DOES include allocation_type columns.
# mmap regions are distincted w/ the allocation_type column.
POLICY_DEEP_2 = 'POLICY_DEEP_2'
# POLICY_DEEP_3 is in JSON format.
POLICY_DEEP_3 = 'POLICY_DEEP_3'
# POLICY_DEEP_3 contains typeinfo.
POLICY_DEEP_4 = 'POLICY_DEEP_4'
class Rule(object):
"""Represents one matching rule in a policy file."""
def __init__(self,
name,
allocator_type,
stackfunction_pattern=None,
stacksourcefile_pattern=None,
typeinfo_pattern=None,
mappedpathname_pattern=None,
mappedpermission_pattern=None,
sharedwith=None):
self._name = name
self._allocator_type = allocator_type
self._stackfunction_pattern = None
if stackfunction_pattern:
self._stackfunction_pattern = re.compile(
stackfunction_pattern + r'\Z')
self._stacksourcefile_pattern = None
if stacksourcefile_pattern:
self._stacksourcefile_pattern = re.compile(
stacksourcefile_pattern + r'\Z')
self._typeinfo_pattern = None
if typeinfo_pattern:
self._typeinfo_pattern = re.compile(typeinfo_pattern + r'\Z')
self._mappedpathname_pattern = None
if mappedpathname_pattern:
self._mappedpathname_pattern = re.compile(mappedpathname_pattern + r'\Z')
self._mappedpermission_pattern = None
if mappedpermission_pattern:
self._mappedpermission_pattern = re.compile(
mappedpermission_pattern + r'\Z')
self._sharedwith = []
if sharedwith:
self._sharedwith = sharedwith
@property
def name(self):
return self._name
@property
def allocator_type(self):
return self._allocator_type
@property
def stackfunction_pattern(self):
return self._stackfunction_pattern
@property
def stacksourcefile_pattern(self):
return self._stacksourcefile_pattern
@property
def typeinfo_pattern(self):
return self._typeinfo_pattern
@property
def mappedpathname_pattern(self):
return self._mappedpathname_pattern
@property
def mappedpermission_pattern(self):
return self._mappedpermission_pattern
@property
def sharedwith(self):
return self._sharedwith
class Policy(object):
"""Represents a policy, a content of a policy file."""
def __init__(self, rules, version, components):
self._rules = rules
self._version = version
self._components = components
@property
def rules(self):
return self._rules
@property
def version(self):
return self._version
@property
def components(self):
return self._components
def find_rule(self, component_name):
"""Finds a rule whose name is |component_name|. """
for rule in self._rules:
if rule.name == component_name:
return rule
return None
def find_malloc(self, bucket):
"""Finds a matching component name which a given |bucket| belongs to.
Args:
bucket: A Bucket object to be searched for.
Returns:
A string representing a component name.
"""
assert not bucket or bucket.allocator_type == 'malloc'
if not bucket:
return 'no-bucket'
if bucket.component_cache:
return bucket.component_cache
stackfunction = bucket.symbolized_joined_stackfunction
stacksourcefile = bucket.symbolized_joined_stacksourcefile
typeinfo = bucket.symbolized_typeinfo
if typeinfo.startswith('0x'):
typeinfo = bucket.typeinfo_name
for rule in self._rules:
if (rule.allocator_type == 'malloc' and
(not rule.stackfunction_pattern or
rule.stackfunction_pattern.match(stackfunction)) and
(not rule.stacksourcefile_pattern or
rule.stacksourcefile_pattern.match(stacksourcefile)) and
(not rule.typeinfo_pattern or rule.typeinfo_pattern.match(typeinfo))):
bucket.component_cache = rule.name
return rule.name
assert False
def find_mmap(self, region, bucket_set,
pageframe=None, group_pfn_counts=None):
"""Finds a matching component which a given mmap |region| belongs to.
It uses |bucket_set| to match with backtraces. If |pageframe| is given,
it considers memory sharing among processes.
NOTE: Don't use Bucket's |component_cache| for mmap regions because they're
classified not only with bucket information (mappedpathname for example).
Args:
region: A tuple representing a memory region.
bucket_set: A BucketSet object to look up backtraces.
pageframe: A PageFrame object representing a pageframe maybe including
a pagecount.
group_pfn_counts: A dict mapping a PFN to the number of times the
the pageframe is mapped by the known "group (Chrome)" processes.
Returns:
A string representing a component name.
"""
assert region[0] == 'hooked'
bucket = bucket_set.get(region[1]['bucket_id'])
assert not bucket or bucket.allocator_type == 'mmap'
if not bucket:
return 'no-bucket', None
stackfunction = bucket.symbolized_joined_stackfunction
stacksourcefile = bucket.symbolized_joined_stacksourcefile
sharedwith = self._categorize_pageframe(pageframe, group_pfn_counts)
for rule in self._rules:
if (rule.allocator_type == 'mmap' and
(not rule.stackfunction_pattern or
rule.stackfunction_pattern.match(stackfunction)) and
(not rule.stacksourcefile_pattern or
rule.stacksourcefile_pattern.match(stacksourcefile)) and
(not rule.mappedpathname_pattern or
rule.mappedpathname_pattern.match(region[1]['vma']['name'])) and
(not rule.mappedpermission_pattern or
rule.mappedpermission_pattern.match(
region[1]['vma']['readable'] +
region[1]['vma']['writable'] +
region[1]['vma']['executable'] +
region[1]['vma']['private'])) and
(not rule.sharedwith or
not pageframe or sharedwith in rule.sharedwith)):
return rule.name, bucket
assert False
def find_unhooked(self, region, pageframe=None, group_pfn_counts=None):
"""Finds a matching component which a given unhooked |region| belongs to.
If |pageframe| is given, it considers memory sharing among processes.
Args:
region: A tuple representing a memory region.
pageframe: A PageFrame object representing a pageframe maybe including
a pagecount.
group_pfn_counts: A dict mapping a PFN to the number of times the
the pageframe is mapped by the known "group (Chrome)" processes.
Returns:
A string representing a component name.
"""
assert region[0] == 'unhooked'
sharedwith = self._categorize_pageframe(pageframe, group_pfn_counts)
for rule in self._rules:
if (rule.allocator_type == 'unhooked' and
(not rule.mappedpathname_pattern or
rule.mappedpathname_pattern.match(region[1]['vma']['name'])) and
(not rule.mappedpermission_pattern or
rule.mappedpermission_pattern.match(
region[1]['vma']['readable'] +
region[1]['vma']['writable'] +
region[1]['vma']['executable'] +
region[1]['vma']['private'])) and
(not rule.sharedwith or
not pageframe or sharedwith in rule.sharedwith)):
return rule.name
assert False
@staticmethod
def load(filename, filetype):
"""Loads a policy file of |filename| in a |format|.
Args:
filename: A filename to be loaded.
filetype: A string to specify a type of the file. Only 'json' is
supported for now.
Returns:
A loaded Policy object.
"""
with open(os.path.join(BASE_PATH, filename)) as policy_f:
return Policy.parse(policy_f, filetype)
@staticmethod
def parse(policy_f, filetype):
"""Parses a policy file content in a |format|.
Args:
policy_f: An IO object to be loaded.
filetype: A string to specify a type of the file. Only 'json' is
supported for now.
Returns:
A loaded Policy object.
"""
if filetype == 'json':
return Policy._parse_json(policy_f)
else:
return None
@staticmethod
def _parse_json(policy_f):
"""Parses policy file in json format.
A policy file contains component's names and their stacktrace pattern
written in regular expression. Those patterns are matched against each
symbols of each stacktraces in the order written in the policy file
Args:
policy_f: A File/IO object to read.
Returns:
A loaded policy object.
"""
policy = json.load(policy_f)
rules = []
for rule in policy['rules']:
stackfunction = rule.get('stackfunction') or rule.get('stacktrace')
stacksourcefile = rule.get('stacksourcefile')
rules.append(Rule(
rule['name'],
rule['allocator'], # allocator_type
stackfunction,
stacksourcefile,
rule['typeinfo'] if 'typeinfo' in rule else None,
rule.get('mappedpathname'),
rule.get('mappedpermission'),
rule.get('sharedwith')))
return Policy(rules, policy['version'], policy['components'])
@staticmethod
def _categorize_pageframe(pageframe, group_pfn_counts):
"""Categorizes a pageframe based on its sharing status.
Returns:
'private' if |pageframe| is not shared with other processes. 'group'
if |pageframe| is shared only with group (Chrome-related) processes.
'others' if |pageframe| is shared with non-group processes.
"""
if not pageframe:
return 'private'
if pageframe.pagecount:
if pageframe.pagecount == 1:
return 'private'
elif pageframe.pagecount <= group_pfn_counts.get(pageframe.pfn, 0) + 1:
return 'group'
else:
return 'others'
else:
if pageframe.pfn in group_pfn_counts:
return 'group'
else:
return 'private'
class PolicySet(object):
"""Represents a set of policies."""
def __init__(self, policy_directory):
self._policy_directory = policy_directory
@staticmethod
def load(labels=None):
"""Loads a set of policies via the "default policy directory".
The "default policy directory" contains pairs of policies and their labels.
For example, a policy "policy.l0.json" is labeled "l0" in the default
policy directory "policies.json".
All policies in the directory are loaded by default. Policies can be
limited by |labels|.
Args:
labels: An array that contains policy labels to be loaded.
Returns:
A PolicySet object.
"""
default_policy_directory = PolicySet._load_default_policy_directory()
if labels:
specified_policy_directory = {}
for label in labels:
if label in default_policy_directory:
specified_policy_directory[label] = default_policy_directory[label]
# TODO(dmikurube): Load an un-labeled policy file.
return PolicySet._load_policies(specified_policy_directory)
else:
return PolicySet._load_policies(default_policy_directory)
def __len__(self):
return len(self._policy_directory)
def __iter__(self):
for label in self._policy_directory:
yield label
def __getitem__(self, label):
return self._policy_directory[label]
@staticmethod
def _load_default_policy_directory():
with open(POLICIES_JSON_PATH, mode='r') as policies_f:
default_policy_directory = json.load(policies_f)
return default_policy_directory
@staticmethod
def _load_policies(directory):
LOGGER.info('Loading policy files.')
policies = {}
for label in directory:
LOGGER.info(' %s: %s' % (label, directory[label]['file']))
loaded = Policy.load(directory[label]['file'], directory[label]['format'])
if loaded:
policies[label] = loaded
return PolicySet(policies)
|
bsd-3-clause
|
[
3,
1898,
6171,
710,
12051,
6642,
14,
2900,
4481,
4644,
14,
199,
3,
3645,
402,
642,
1350,
1233,
365,
10413,
701,
282,
6289,
13,
2487,
4190,
626,
883,
506,
199,
3,
1911,
315,
314,
5113,
570,
14,
199,
199,
646,
2022,
199,
646,
2050,
199,
646,
747,
199,
646,
295,
421,
199,
10186,
275,
2050,
14,
5572,
360,
10930,
293,
70,
358,
199,
199,
5825,
63,
3243,
275,
747,
14,
515,
14,
3475,
8,
736,
14,
515,
14,
3475,
8,
736,
14,
515,
14,
4832,
3460,
493,
29658,
199,
15304,
2563,
63,
6243,
63,
3243,
275,
747,
14,
515,
14,
904,
8,
5825,
63,
3243,
12,
283,
11767,
14,
1001,
358,
199,
199,
3,
5311,
439,
14386,
18141,
5459,
199,
199,
3,
25480,
948,
57,
63,
1093,
6102,
63,
17,
3506,
654,
2845,
2387,
18723,
63,
466,
4362,
14,
199,
3,
21991,
16150,
787,
2917,
262,
1522,
336,
15,
21991,
11223,
315,
314,
3851,
2763,
14,
199,
15976,
63,
1093,
6102,
63,
17,
275,
283,
15976,
63,
1093,
6102,
63,
17,
7,
199,
199,
3,
25480,
948,
57,
63,
1093,
6102,
63,
18,
3506,
654,
2387,
18723,
63,
466,
4362,
14,
199,
3,
21991,
16150,
787,
2917,
262,
1522,
336,
15,
314,
18723,
63,
466,
2763,
14,
199,
15976,
63,
1093,
6102,
63,
18,
275,
283,
15976,
63,
1093,
6102,
63,
18,
7,
199,
199,
3,
25480,
948,
57,
63,
1093,
6102,
63,
19,
365,
315,
4840,
1475,
14,
199,
15976,
63,
1093,
6102,
63,
19,
275,
283,
15976,
63,
1093,
6102,
63,
19,
7,
199,
199,
3,
25480,
948,
57,
63,
1093,
6102,
63,
19,
3509,
730,
815,
14,
199,
15976,
63,
1093,
6102,
63,
20,
275,
283,
15976,
63,
1093,
6102,
63,
20,
7,
421,
199,
533,
11949,
8,
785,
304,
523,
408,
18089,
1373,
4877,
2332,
315,
282,
4592,
570,
1041,
819,
347,
636,
826,
721,
277,
12,
2049,
536,
12,
2049,
741,
6354,
63,
466,
12,
2049,
3464,
1593,
63,
3401,
29,
403,
12,
2049,
3464,
32666,
63,
3401,
29,
403,
12,
2049,
730,
815,
63,
3401,
29,
403,
12,
2049,
9994,
12445,
63,
3401,
29,
403,
12,
2049,
9994,
5693,
63,
3401,
29,
403,
12,
2049,
5709,
1045,
29,
403,
304,
272,
291,
423,
354,
275,
536,
272,
291,
423,
14228,
63,
466,
275,
741,
6354,
63,
466,
339,
291,
423,
2340,
1593,
63,
3401,
275,
488,
272,
340,
3464,
1593,
63,
3401,
26,
489,
291,
423,
2340,
1593,
63,
3401,
275,
295,
14,
2014,
8,
881,
3464,
1593,
63,
3401,
435,
519,
1154,
58,
358,
339,
291,
423,
2340,
32666,
63,
3401,
275,
488,
272,
340,
3464,
32666,
63,
3401,
26,
489,
291,
423,
2340,
32666,
63,
3401,
275,
295,
14,
2014,
8,
881,
3464,
32666,
63,
3401,
435,
519,
1154,
58,
358,
339,
291,
423,
466,
815,
63,
3401,
275,
488,
272,
340,
730,
815,
63,
3401,
26,
489,
291,
423,
466,
815,
63,
3401,
275,
295,
14,
2014,
8,
466,
815,
63,
3401,
435,
519,
1154,
58,
358,
339,
291,
423,
11663,
12445,
63,
3401,
275,
488,
272,
340,
9994,
12445,
63,
3401,
26,
489,
291,
423,
11663,
12445,
63,
3401,
275,
295,
14,
2014,
8,
11663,
12445,
63,
3401,
435,
519,
1154,
58,
358,
339,
291,
423,
11663,
5693,
63,
3401,
275,
488,
272,
340,
9994,
5693,
63,
3401,
26,
489,
291,
423,
11663,
5693,
63,
3401,
275,
295,
14,
2014,
8,
881,
9994,
5693,
63,
3401,
435,
519,
1154,
58,
358,
339,
291,
423,
5555,
1045,
275,
942,
272,
340,
5709,
1045,
26,
489,
291,
423,
5555,
1045,
275,
5709,
1045,
819,
768,
1829,
523,
347,
536,
8,
277,
304,
272,
372,
291,
423,
354,
819,
768,
1829,
523,
347,
741,
6354,
63,
466,
8,
277,
304,
272,
372,
291,
423,
14228,
63,
466,
819,
768,
1829,
523,
347,
3464,
1593,
63,
3401,
8,
277,
304,
272,
372,
291,
423,
2340,
1593,
63,
3401,
819,
768,
1829,
523,
347,
3464,
32666,
63,
3401,
8,
277,
304,
272,
372,
291,
423,
2340,
32666,
63,
3401,
819,
768,
1829,
523,
347,
730,
815,
63,
3401,
8,
277,
304,
272,
372,
291,
423,
466,
815,
63,
3401,
819,
768,
1829,
523,
347,
9994,
12445,
63,
3401,
8,
277,
304,
272,
372,
291,
423,
11663,
12445,
63,
3401,
819,
768,
1829,
523,
347,
9994,
5693,
63,
3401,
8,
277,
304,
272,
372,
291,
423,
11663,
5693,
63,
3401,
819,
768,
1829,
523,
347,
5709,
1045,
8,
277,
304,
272,
372,
291,
423,
5555,
1045,
421,
199,
533,
18141,
8,
785,
304,
523,
408,
18089,
282,
4592,
12,
282,
1564,
402,
282,
4592,
570,
1041,
819,
347,
636,
826,
721,
277,
12,
4713,
12,
1015,
12,
7323,
304,
272,
291,
423,
4423,
275,
4713,
272,
291,
423,
1023,
275,
1015,
272,
291,
423,
4608,
275,
7323,
819,
768,
1829,
523,
347,
4713,
8,
277,
304,
272,
372,
291,
423,
4423,
819,
768,
1829,
523,
347,
1015,
8,
277,
304,
272,
372,
291,
423,
1023,
819,
768,
1829,
523,
347,
7323,
8,
277,
304,
272,
372,
291,
423,
4608,
819,
347,
2342,
63,
2200,
8,
277,
12,
3931,
63,
354,
304,
272,
408,
30344,
282,
2332,
7447,
536,
365,
1204,
3173,
63,
354,
18257,
408,
272,
367,
2332,
315,
291,
423,
4423,
26,
489,
340,
2332,
14,
354,
508,
3931,
63,
354,
26,
267,
372,
2332,
272,
372,
488,
819,
347,
2342,
63,
23981,
8,
277,
12,
5315,
304,
272,
408,
30344,
282,
4877,
3931,
536,
1314,
282,
1627,
1204,
4623,
92,
15006,
370,
14,
339,
3033,
26,
267,
5315,
26,
437,
31479,
909,
370,
506,
17543,
367,
14,
339,
1803,
26,
267,
437,
1059,
6144,
282,
3931,
536,
14,
272,
408,
272,
702,
440,
5315,
503,
5315,
14,
14228,
63,
466,
508,
283,
23981,
7,
339,
340,
440,
5315,
26,
489,
372,
283,
889,
13,
4623,
7,
272,
340,
5315,
14,
3173,
63,
1637,
26,
489,
372,
5315,
14,
3173,
63,
1637,
339,
3464,
1593,
275,
5315,
14,
3840,
656,
317,
7068,
63,
11806,
63,
2340,
1593,
272,
3464,
32666,
275,
5315,
14,
3840,
656,
317,
7068,
63,
11806,
63,
2340,
32666,
272,
730,
815,
275,
5315,
14,
3840,
656,
317,
7068,
63,
466,
815,
272,
340,
730,
815
] |
[
1898,
6171,
710,
12051,
6642,
14,
2900,
4481,
4644,
14,
199,
3,
3645,
402,
642,
1350,
1233,
365,
10413,
701,
282,
6289,
13,
2487,
4190,
626,
883,
506,
199,
3,
1911,
315,
314,
5113,
570,
14,
199,
199,
646,
2022,
199,
646,
2050,
199,
646,
747,
199,
646,
295,
421,
199,
10186,
275,
2050,
14,
5572,
360,
10930,
293,
70,
358,
199,
199,
5825,
63,
3243,
275,
747,
14,
515,
14,
3475,
8,
736,
14,
515,
14,
3475,
8,
736,
14,
515,
14,
4832,
3460,
493,
29658,
199,
15304,
2563,
63,
6243,
63,
3243,
275,
747,
14,
515,
14,
904,
8,
5825,
63,
3243,
12,
283,
11767,
14,
1001,
358,
199,
199,
3,
5311,
439,
14386,
18141,
5459,
199,
199,
3,
25480,
948,
57,
63,
1093,
6102,
63,
17,
3506,
654,
2845,
2387,
18723,
63,
466,
4362,
14,
199,
3,
21991,
16150,
787,
2917,
262,
1522,
336,
15,
21991,
11223,
315,
314,
3851,
2763,
14,
199,
15976,
63,
1093,
6102,
63,
17,
275,
283,
15976,
63,
1093,
6102,
63,
17,
7,
199,
199,
3,
25480,
948,
57,
63,
1093,
6102,
63,
18,
3506,
654,
2387,
18723,
63,
466,
4362,
14,
199,
3,
21991,
16150,
787,
2917,
262,
1522,
336,
15,
314,
18723,
63,
466,
2763,
14,
199,
15976,
63,
1093,
6102,
63,
18,
275,
283,
15976,
63,
1093,
6102,
63,
18,
7,
199,
199,
3,
25480,
948,
57,
63,
1093,
6102,
63,
19,
365,
315,
4840,
1475,
14,
199,
15976,
63,
1093,
6102,
63,
19,
275,
283,
15976,
63,
1093,
6102,
63,
19,
7,
199,
199,
3,
25480,
948,
57,
63,
1093,
6102,
63,
19,
3509,
730,
815,
14,
199,
15976,
63,
1093,
6102,
63,
20,
275,
283,
15976,
63,
1093,
6102,
63,
20,
7,
421,
199,
533,
11949,
8,
785,
304,
523,
408,
18089,
1373,
4877,
2332,
315,
282,
4592,
570,
1041,
819,
347,
636,
826,
721,
277,
12,
2049,
536,
12,
2049,
741,
6354,
63,
466,
12,
2049,
3464,
1593,
63,
3401,
29,
403,
12,
2049,
3464,
32666,
63,
3401,
29,
403,
12,
2049,
730,
815,
63,
3401,
29,
403,
12,
2049,
9994,
12445,
63,
3401,
29,
403,
12,
2049,
9994,
5693,
63,
3401,
29,
403,
12,
2049,
5709,
1045,
29,
403,
304,
272,
291,
423,
354,
275,
536,
272,
291,
423,
14228,
63,
466,
275,
741,
6354,
63,
466,
339,
291,
423,
2340,
1593,
63,
3401,
275,
488,
272,
340,
3464,
1593,
63,
3401,
26,
489,
291,
423,
2340,
1593,
63,
3401,
275,
295,
14,
2014,
8,
881,
3464,
1593,
63,
3401,
435,
519,
1154,
58,
358,
339,
291,
423,
2340,
32666,
63,
3401,
275,
488,
272,
340,
3464,
32666,
63,
3401,
26,
489,
291,
423,
2340,
32666,
63,
3401,
275,
295,
14,
2014,
8,
881,
3464,
32666,
63,
3401,
435,
519,
1154,
58,
358,
339,
291,
423,
466,
815,
63,
3401,
275,
488,
272,
340,
730,
815,
63,
3401,
26,
489,
291,
423,
466,
815,
63,
3401,
275,
295,
14,
2014,
8,
466,
815,
63,
3401,
435,
519,
1154,
58,
358,
339,
291,
423,
11663,
12445,
63,
3401,
275,
488,
272,
340,
9994,
12445,
63,
3401,
26,
489,
291,
423,
11663,
12445,
63,
3401,
275,
295,
14,
2014,
8,
11663,
12445,
63,
3401,
435,
519,
1154,
58,
358,
339,
291,
423,
11663,
5693,
63,
3401,
275,
488,
272,
340,
9994,
5693,
63,
3401,
26,
489,
291,
423,
11663,
5693,
63,
3401,
275,
295,
14,
2014,
8,
881,
9994,
5693,
63,
3401,
435,
519,
1154,
58,
358,
339,
291,
423,
5555,
1045,
275,
942,
272,
340,
5709,
1045,
26,
489,
291,
423,
5555,
1045,
275,
5709,
1045,
819,
768,
1829,
523,
347,
536,
8,
277,
304,
272,
372,
291,
423,
354,
819,
768,
1829,
523,
347,
741,
6354,
63,
466,
8,
277,
304,
272,
372,
291,
423,
14228,
63,
466,
819,
768,
1829,
523,
347,
3464,
1593,
63,
3401,
8,
277,
304,
272,
372,
291,
423,
2340,
1593,
63,
3401,
819,
768,
1829,
523,
347,
3464,
32666,
63,
3401,
8,
277,
304,
272,
372,
291,
423,
2340,
32666,
63,
3401,
819,
768,
1829,
523,
347,
730,
815,
63,
3401,
8,
277,
304,
272,
372,
291,
423,
466,
815,
63,
3401,
819,
768,
1829,
523,
347,
9994,
12445,
63,
3401,
8,
277,
304,
272,
372,
291,
423,
11663,
12445,
63,
3401,
819,
768,
1829,
523,
347,
9994,
5693,
63,
3401,
8,
277,
304,
272,
372,
291,
423,
11663,
5693,
63,
3401,
819,
768,
1829,
523,
347,
5709,
1045,
8,
277,
304,
272,
372,
291,
423,
5555,
1045,
421,
199,
533,
18141,
8,
785,
304,
523,
408,
18089,
282,
4592,
12,
282,
1564,
402,
282,
4592,
570,
1041,
819,
347,
636,
826,
721,
277,
12,
4713,
12,
1015,
12,
7323,
304,
272,
291,
423,
4423,
275,
4713,
272,
291,
423,
1023,
275,
1015,
272,
291,
423,
4608,
275,
7323,
819,
768,
1829,
523,
347,
4713,
8,
277,
304,
272,
372,
291,
423,
4423,
819,
768,
1829,
523,
347,
1015,
8,
277,
304,
272,
372,
291,
423,
1023,
819,
768,
1829,
523,
347,
7323,
8,
277,
304,
272,
372,
291,
423,
4608,
819,
347,
2342,
63,
2200,
8,
277,
12,
3931,
63,
354,
304,
272,
408,
30344,
282,
2332,
7447,
536,
365,
1204,
3173,
63,
354,
18257,
408,
272,
367,
2332,
315,
291,
423,
4423,
26,
489,
340,
2332,
14,
354,
508,
3931,
63,
354,
26,
267,
372,
2332,
272,
372,
488,
819,
347,
2342,
63,
23981,
8,
277,
12,
5315,
304,
272,
408,
30344,
282,
4877,
3931,
536,
1314,
282,
1627,
1204,
4623,
92,
15006,
370,
14,
339,
3033,
26,
267,
5315,
26,
437,
31479,
909,
370,
506,
17543,
367,
14,
339,
1803,
26,
267,
437,
1059,
6144,
282,
3931,
536,
14,
272,
408,
272,
702,
440,
5315,
503,
5315,
14,
14228,
63,
466,
508,
283,
23981,
7,
339,
340,
440,
5315,
26,
489,
372,
283,
889,
13,
4623,
7,
272,
340,
5315,
14,
3173,
63,
1637,
26,
489,
372,
5315,
14,
3173,
63,
1637,
339,
3464,
1593,
275,
5315,
14,
3840,
656,
317,
7068,
63,
11806,
63,
2340,
1593,
272,
3464,
32666,
275,
5315,
14,
3840,
656,
317,
7068,
63,
11806,
63,
2340,
32666,
272,
730,
815,
275,
5315,
14,
3840,
656,
317,
7068,
63,
466,
815,
272,
340,
730,
815,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
xiamike/stanford-ctc
|
ctc/runNNet.py
|
2
|
5741
|
import optparse
import numpy as np
import gnumpy as gp
import cPickle as pickle
import sgd
import nnet, rnnet
import dataLoader as dl
#gp.board_id_to_use = 0
def run(args=None):
usage = "usage : %prog [options]"
parser = optparse.OptionParser(usage=usage)
parser.add_option("--test",action="store_true",dest="test",default=False)
# Architecture
parser.add_option("--layers",dest="layers",type="string",
default="100,100",help="layer1size,layer2size,...,layernsize")
parser.add_option("--temporal_layer",dest="temporalLayer",type="int",default=-1)
# Optimization
parser.add_option("--optimizer",dest="optimizer",type="string",
default="momentum")
parser.add_option("--momentum",dest="momentum",type="float",
default=0.9)
parser.add_option("--epochs",dest="epochs",type="int",default=1)
parser.add_option("--step",dest="step",type="float",default=1e-4)
parser.add_option("--anneal",dest="anneal",type="float",default=1,
help="Sets (learning rate := learning rate / anneal) after each epoch.")
# Data
parser.add_option("--dataDir",dest="dataDir",type="string",
default="/scail/group/deeplearning/speech/awni/kaldi-stanford/kaldi-trunk/egs/swbd/s5b/exp/train_ctc/")
parser.add_option("--numFiles",dest="numFiles",type="int",default=384)
parser.add_option("--inputDim",dest="inputDim",type="int",default=41*15)
parser.add_option("--rawDim",dest="rawDim",type="int",default=41*15)
parser.add_option("--outputDim",dest="outputDim",type="int",default=34)
parser.add_option("--outFile",dest="outFile",type="string",
default="models/test.bin")
parser.add_option("--inFile",dest="inFile",type="string",
default=None)
(opts,args)=parser.parse_args(args)
opts.layers = [int(l) for l in opts.layers.split(',')]
# Testing
if opts.test:
test(opts)
return
loader = dl.DataLoader(opts.dataDir,opts.rawDim,opts.inputDim)
#NOTE at some point we need to unify the nnet and rnnet modules
nn = None
if opts.temporalLayer > 0:
nn = rnnet.RNNet(opts.inputDim,opts.outputDim,opts.layers, opts.temporalLayer)
else:
nn = nnet.NNet(opts.inputDim,opts.outputDim,opts.layers)
nn.initParams()
# Load model if exists
if opts.inFile is not None:
with open(opts.inFile,'r') as fid:
_ = pickle.load(fid)
_ = pickle.load(fid)
_ = pickle.load(fid)
nn.fromFile(fid)
SGD = sgd.SGD(nn,alpha=opts.step,optimizer=opts.optimizer,
momentum=opts.momentum)
# Setup some random keys for tracing
with open('randKeys.bin','r') as fid:
traceK = pickle.load(fid)
for k in traceK:
nn.hist[k] = []
# write initial model to disk
with open(opts.outFile,'w') as fid:
pickle.dump(opts,fid)
pickle.dump(SGD.costt,fid)
pickle.dump(nn.hist,fid)
nn.toFile(fid)
# Training
import time
for _ in range(opts.epochs):
for i in np.random.permutation(opts.numFiles)+1:
start = time.time()
data_dict,alis,keys,sizes = loader.loadDataFileDict(i)
SGD.run_seq(data_dict,alis,keys,sizes)
end = time.time()
print "File time %f"%(end-start)
# Save anneal after epoch
SGD.alpha = SGD.alpha / opts.anneal
with open(opts.outFile,'w') as fid:
pickle.dump(opts,fid)
pickle.dump(SGD.costt,fid)
pickle.dump(nn.hist,fid)
nn.toFile(fid)
def test(opts):
import editDistance as ed
print "Testing model %s"%opts.inFile
phone_map = get_phone_map_swbd()
with open(opts.inFile,'r') as fid:
old_opts = pickle.load(fid)
_ = pickle.load(fid)
_ = pickle.load(fid)
loader = dl.DataLoader(opts.dataDir,old_opts.rawDim,old_opts.inputDim)
if 'layers' not in dir(old_opts):
old_opts.layers = [old_opts.layerSize]*old_opts.numLayers
nn = nnet.NNet(old_opts.inputDim,old_opts.outputDim,old_opts.layers,train=False)
nn.initParams()
nn.fromFile(fid)
totdist = numphones = 0
fid = open('hyp.txt','w')
for i in range(1,opts.numFiles+1):
data_dict,alis,keys,sizes = loader.loadDataFileDict(i)
for k in keys:
gp.free_reuse_cache()
hyp = nn.costAndGrad(data_dict[k])
hyp = [phone_map[h] for h in hyp]
ref = [phone_map[int(r)] for r in alis[k]]
dist,ins,dels,subs,corr = ed.edit_distance(ref,hyp)
print "Distance %d/%d"%(dist,len(ref))
fid.write(k+' '+' '.join(hyp)+'\n')
totdist += dist
numphones += len(alis[k])
fid.close()
print "PER : %f"%(100*totdist/float(numphones))
def get_phone_map_swbd():
kaldi_base = "/deep/group/speech/awni/kaldi-stanford/kaldi-trunk/egs/swbd/s5b/"
with open(kaldi_base+'ctc-utils/chars.txt','r') as fid:
labels = [l.strip().split() for l in fid.readlines()]
labels = dict((int(k),v) for v,k in labels)
return labels
def get_phone_map_timit():
kaldi_base = "/scail/group/deeplearning/speech/awni/kaldi-stanford/kaldi-trunk/egs/timit/s5/"
with open(kaldi_base+'data/lang/phones/sets61.txt','r') as fid:
sets_txt = [l.strip().split()[0] for l in fid.readlines()]
with open(kaldi_base+'data/lang/phones/sets61.int','r') as fid:
sets_int = [int(l.strip().split()[0]) for l in fid.readlines()]
int_to_p61 = dict(zip(sets_int,sets_txt))
p61_p39 = {}
with open(kaldi_base+'conf/phones.60-48-39.map','r') as fid:
k_v = [l.strip().split() for l in fid.readlines()]
for p in k_v:
if len(p)==3:
p61_p39[p[0]]=p[-1]
else:
p61_p39[p[0]]='' # e.g. q maps to nothing
phone_map = dict((k,p61_p39[int_to_p61[k]]) for k in int_to_p61.keys())
return phone_map
if __name__=='__main__':
run()
|
apache-2.0
|
[
646,
8691,
199,
646,
2680,
465,
980,
199,
646,
486,
4714,
465,
15852,
199,
646,
17572,
465,
5927,
199,
199,
646,
308,
7136,
199,
646,
302,
846,
12,
519,
78,
846,
199,
646,
666,
5455,
465,
15396,
199,
199,
3,
4927,
14,
3576,
63,
344,
63,
475,
63,
1180,
275,
378,
199,
199,
318,
1255,
8,
589,
29,
403,
304,
272,
4503,
275,
298,
3807,
520,
450,
6595,
359,
1419,
8480,
272,
1798,
275,
8691,
14,
14553,
8,
3807,
29,
3807,
9,
339,
1798,
14,
525,
63,
1422,
6739,
396,
401,
1287,
628,
1617,
63,
2052,
401,
2614,
628,
396,
401,
885,
29,
797,
9,
339,
327,
19521,
10497,
272,
1798,
14,
525,
63,
1422,
6739,
4359,
401,
2614,
628,
4359,
401,
466,
628,
875,
401,
6722,
849,
628,
1960,
12,
1960,
401,
3437,
628,
1897,
17,
890,
12,
1897,
18,
890,
32699,
1897,
78,
890,
531,
272,
1798,
14,
525,
63,
1422,
6739,
30574,
63,
1897,
401,
2614,
628,
30574,
5003,
401,
466,
628,
442,
401,
885,
4022,
17,
9,
339,
327,
19246,
2072,
272,
1798,
14,
525,
63,
1422,
6739,
12290,
401,
2614,
628,
12290,
401,
466,
628,
875,
401,
6722,
849,
628,
25710,
531,
272,
1798,
14,
525,
63,
1422,
6739,
25710,
401,
2614,
628,
25710,
401,
466,
628,
1609,
401,
6722,
849,
29,
16,
14,
25,
9,
272,
1798,
14,
525,
63,
1422,
6739,
13161,
401,
2614,
628,
13161,
401,
466,
628,
442,
401,
885,
29,
17,
9,
272,
1798,
14,
525,
63,
1422,
6739,
2926,
401,
2614,
628,
2926,
401,
466,
628,
1609,
401,
885,
29,
17,
69,
13,
20,
9,
272,
1798,
14,
525,
63,
1422,
6739,
290,
685,
279,
401,
2614,
628,
290,
685,
279,
401,
466,
628,
1609,
401,
885,
29,
17,
12,
6722,
1720,
628,
9899,
334,
10546,
6634,
12952,
9328,
6634,
1182,
376,
685,
279,
9,
2410,
1924,
9463,
2685,
339,
327,
3918,
272,
1798,
14,
525,
63,
1422,
6739,
576,
3567,
401,
2614,
628,
576,
3567,
401,
466,
628,
875,
401,
6722,
849,
9555,
551,
1054,
15,
923,
15,
16131,
10546,
15,
23660,
15,
65,
3501,
73,
15,
26446,
328,
13,
9746,
18090,
15,
26446,
328,
13,
13409,
15,
69,
458,
15,
3519,
3691,
15,
83,
21,
66,
15,
1474,
15,
2834,
63,
319,
67,
13589,
272,
1798,
14,
525,
63,
1422,
6739,
1507,
5535,
401,
2614,
628,
1507,
5535,
401,
466,
628,
442,
401,
885,
29,
8188,
9,
272,
1798,
14,
525,
63,
1422,
6739,
1210,
19156,
401,
2614,
628,
1210,
19156,
401,
466,
628,
442,
401,
885,
29,
2953,
10,
1046,
9,
272,
1798,
14,
525,
63,
1422,
6739,
1773,
19156,
401,
2614,
628,
1773,
19156,
401,
466,
628,
442,
401,
885,
29,
2953,
10,
1046,
9,
272,
1798,
14,
525,
63,
1422,
6739,
1199,
19156,
401,
2614,
628,
1199,
19156,
401,
466,
628,
442,
401,
885,
29,
1082,
9,
339,
1798,
14,
525,
63,
1422,
6739,
548,
1173,
401,
2614,
628,
548,
1173,
401,
466,
628,
875,
401,
6722,
849,
628,
992,
15,
396,
14,
1393,
531,
272,
1798,
14,
525,
63,
1422,
6739,
262,
1173,
401,
2614,
628,
262,
1173,
401,
466,
628,
875,
401,
6722,
849,
29,
403,
9,
339,
334,
3291,
12,
589,
23397,
2087,
14,
1122,
63,
589,
8,
589,
9,
272,
3999,
14,
4359,
275,
359,
442,
8,
76,
9,
367,
634,
315,
3999,
14,
4359,
14,
1294,
29972,
339,
327,
11940,
272,
340,
3999,
14,
396,
26,
199,
198,
396,
8,
3291,
9,
199,
198,
1107,
507,
272,
5077,
275,
15396,
14,
1451,
5455,
8,
3291,
14,
576,
3567,
12,
3291,
14,
1773,
19156,
12,
3291,
14,
1210,
19156,
9,
272,
327,
19855,
737,
2005,
2376,
781,
1929,
370,
625,
2021,
314,
302,
846,
436,
519,
78,
846,
4621,
272,
11542,
275,
488,
272,
340,
3999,
14,
30574,
5003,
690,
378,
26,
267,
11542,
275,
519,
78,
846,
14,
15303,
2480,
8,
3291,
14,
1210,
19156,
12,
3291,
14,
1199,
19156,
12,
3291,
14,
4359,
12,
3999,
14,
30574,
5003,
9,
272,
587,
26,
267,
11542,
275,
302,
846,
14,
25643,
8,
3291,
14,
1210,
19156,
12,
3291,
14,
1199,
19156,
12,
3291,
14,
4359,
9,
339,
11542,
14,
826,
6007,
342,
339,
327,
7190,
1402,
340,
3495,
272,
340,
3999,
14,
262,
1173,
365,
440,
488,
26,
267,
543,
1551,
8,
3291,
14,
262,
1173,
2584,
82,
358,
465,
8289,
26,
288,
485,
275,
5927,
14,
912,
8,
9430,
9,
288,
485,
275,
5927,
14,
912,
8,
9430,
9,
288,
485,
275,
5927,
14,
912,
8,
9430,
9,
288,
11542,
14,
504,
1173,
8,
9430,
9,
339,
18868,
36,
275,
308,
7136,
14,
4254,
36,
8,
4411,
12,
4468,
29,
3291,
14,
2926,
12,
12290,
29,
3291,
14,
12290,
12,
29294,
23887,
29,
3291,
14,
25710,
9,
339,
327,
12439,
2005,
2196,
2883,
367,
23465,
272,
543,
1551,
360,
3759,
6340,
14,
1393,
1673,
82,
358,
465,
8289,
26,
199,
198,
3446,
43,
275,
5927,
14,
912,
8,
9430,
9,
272,
367,
1022,
315,
3307,
43,
26,
199,
198,
4411,
14,
11141,
59,
75,
61,
275,
942,
339,
327,
2218,
2536,
1402,
370,
4543,
272,
543,
1551,
8,
3291,
14,
548,
1173,
2584,
87,
358,
465,
8289,
26,
267,
5927,
14,
2724,
8,
3291,
12,
9430,
9,
267,
5927,
14,
2724,
8,
4254,
36,
14,
6336,
84,
12,
9430,
9,
267,
5927,
14,
2724,
8,
4411,
14,
11141,
12,
9430,
9,
267,
11542,
14,
475,
1173,
8,
9430,
9,
339,
327,
22859,
272,
492,
900,
272,
367,
485,
315,
1425,
8,
3291,
14,
13161,
304,
199,
198,
509,
284,
315,
980,
14,
2355,
14,
23832,
8,
3291,
14,
1507,
5535,
6393,
17,
26,
288,
1343,
275,
900,
14,
521,
342,
6722,
666,
63,
807,
12,
279,
374,
12,
1612,
12,
7723,
275,
5077,
14,
912,
1451,
1173,
2141,
8,
73,
9,
6722,
18868,
36,
14,
1065,
63,
3610,
8,
576,
63,
807,
12,
279,
374,
12,
1612,
12,
7723,
9,
288,
1284,
275,
900,
14,
521,
342,
288,
870,
298,
1173,
900,
450,
70,
14007,
500,
13,
928,
9,
398,
327,
11063,
376,
685,
279,
2410,
9463,
267,
18868,
36,
14,
4468,
275,
18868,
36,
14,
4468,
1182,
3999,
14,
290,
685,
279
] |
[
8691,
199,
646,
2680,
465,
980,
199,
646,
486,
4714,
465,
15852,
199,
646,
17572,
465,
5927,
199,
199,
646,
308,
7136,
199,
646,
302,
846,
12,
519,
78,
846,
199,
646,
666,
5455,
465,
15396,
199,
199,
3,
4927,
14,
3576,
63,
344,
63,
475,
63,
1180,
275,
378,
199,
199,
318,
1255,
8,
589,
29,
403,
304,
272,
4503,
275,
298,
3807,
520,
450,
6595,
359,
1419,
8480,
272,
1798,
275,
8691,
14,
14553,
8,
3807,
29,
3807,
9,
339,
1798,
14,
525,
63,
1422,
6739,
396,
401,
1287,
628,
1617,
63,
2052,
401,
2614,
628,
396,
401,
885,
29,
797,
9,
339,
327,
19521,
10497,
272,
1798,
14,
525,
63,
1422,
6739,
4359,
401,
2614,
628,
4359,
401,
466,
628,
875,
401,
6722,
849,
628,
1960,
12,
1960,
401,
3437,
628,
1897,
17,
890,
12,
1897,
18,
890,
32699,
1897,
78,
890,
531,
272,
1798,
14,
525,
63,
1422,
6739,
30574,
63,
1897,
401,
2614,
628,
30574,
5003,
401,
466,
628,
442,
401,
885,
4022,
17,
9,
339,
327,
19246,
2072,
272,
1798,
14,
525,
63,
1422,
6739,
12290,
401,
2614,
628,
12290,
401,
466,
628,
875,
401,
6722,
849,
628,
25710,
531,
272,
1798,
14,
525,
63,
1422,
6739,
25710,
401,
2614,
628,
25710,
401,
466,
628,
1609,
401,
6722,
849,
29,
16,
14,
25,
9,
272,
1798,
14,
525,
63,
1422,
6739,
13161,
401,
2614,
628,
13161,
401,
466,
628,
442,
401,
885,
29,
17,
9,
272,
1798,
14,
525,
63,
1422,
6739,
2926,
401,
2614,
628,
2926,
401,
466,
628,
1609,
401,
885,
29,
17,
69,
13,
20,
9,
272,
1798,
14,
525,
63,
1422,
6739,
290,
685,
279,
401,
2614,
628,
290,
685,
279,
401,
466,
628,
1609,
401,
885,
29,
17,
12,
6722,
1720,
628,
9899,
334,
10546,
6634,
12952,
9328,
6634,
1182,
376,
685,
279,
9,
2410,
1924,
9463,
2685,
339,
327,
3918,
272,
1798,
14,
525,
63,
1422,
6739,
576,
3567,
401,
2614,
628,
576,
3567,
401,
466,
628,
875,
401,
6722,
849,
9555,
551,
1054,
15,
923,
15,
16131,
10546,
15,
23660,
15,
65,
3501,
73,
15,
26446,
328,
13,
9746,
18090,
15,
26446,
328,
13,
13409,
15,
69,
458,
15,
3519,
3691,
15,
83,
21,
66,
15,
1474,
15,
2834,
63,
319,
67,
13589,
272,
1798,
14,
525,
63,
1422,
6739,
1507,
5535,
401,
2614,
628,
1507,
5535,
401,
466,
628,
442,
401,
885,
29,
8188,
9,
272,
1798,
14,
525,
63,
1422,
6739,
1210,
19156,
401,
2614,
628,
1210,
19156,
401,
466,
628,
442,
401,
885,
29,
2953,
10,
1046,
9,
272,
1798,
14,
525,
63,
1422,
6739,
1773,
19156,
401,
2614,
628,
1773,
19156,
401,
466,
628,
442,
401,
885,
29,
2953,
10,
1046,
9,
272,
1798,
14,
525,
63,
1422,
6739,
1199,
19156,
401,
2614,
628,
1199,
19156,
401,
466,
628,
442,
401,
885,
29,
1082,
9,
339,
1798,
14,
525,
63,
1422,
6739,
548,
1173,
401,
2614,
628,
548,
1173,
401,
466,
628,
875,
401,
6722,
849,
628,
992,
15,
396,
14,
1393,
531,
272,
1798,
14,
525,
63,
1422,
6739,
262,
1173,
401,
2614,
628,
262,
1173,
401,
466,
628,
875,
401,
6722,
849,
29,
403,
9,
339,
334,
3291,
12,
589,
23397,
2087,
14,
1122,
63,
589,
8,
589,
9,
272,
3999,
14,
4359,
275,
359,
442,
8,
76,
9,
367,
634,
315,
3999,
14,
4359,
14,
1294,
29972,
339,
327,
11940,
272,
340,
3999,
14,
396,
26,
199,
198,
396,
8,
3291,
9,
199,
198,
1107,
507,
272,
5077,
275,
15396,
14,
1451,
5455,
8,
3291,
14,
576,
3567,
12,
3291,
14,
1773,
19156,
12,
3291,
14,
1210,
19156,
9,
272,
327,
19855,
737,
2005,
2376,
781,
1929,
370,
625,
2021,
314,
302,
846,
436,
519,
78,
846,
4621,
272,
11542,
275,
488,
272,
340,
3999,
14,
30574,
5003,
690,
378,
26,
267,
11542,
275,
519,
78,
846,
14,
15303,
2480,
8,
3291,
14,
1210,
19156,
12,
3291,
14,
1199,
19156,
12,
3291,
14,
4359,
12,
3999,
14,
30574,
5003,
9,
272,
587,
26,
267,
11542,
275,
302,
846,
14,
25643,
8,
3291,
14,
1210,
19156,
12,
3291,
14,
1199,
19156,
12,
3291,
14,
4359,
9,
339,
11542,
14,
826,
6007,
342,
339,
327,
7190,
1402,
340,
3495,
272,
340,
3999,
14,
262,
1173,
365,
440,
488,
26,
267,
543,
1551,
8,
3291,
14,
262,
1173,
2584,
82,
358,
465,
8289,
26,
288,
485,
275,
5927,
14,
912,
8,
9430,
9,
288,
485,
275,
5927,
14,
912,
8,
9430,
9,
288,
485,
275,
5927,
14,
912,
8,
9430,
9,
288,
11542,
14,
504,
1173,
8,
9430,
9,
339,
18868,
36,
275,
308,
7136,
14,
4254,
36,
8,
4411,
12,
4468,
29,
3291,
14,
2926,
12,
12290,
29,
3291,
14,
12290,
12,
29294,
23887,
29,
3291,
14,
25710,
9,
339,
327,
12439,
2005,
2196,
2883,
367,
23465,
272,
543,
1551,
360,
3759,
6340,
14,
1393,
1673,
82,
358,
465,
8289,
26,
199,
198,
3446,
43,
275,
5927,
14,
912,
8,
9430,
9,
272,
367,
1022,
315,
3307,
43,
26,
199,
198,
4411,
14,
11141,
59,
75,
61,
275,
942,
339,
327,
2218,
2536,
1402,
370,
4543,
272,
543,
1551,
8,
3291,
14,
548,
1173,
2584,
87,
358,
465,
8289,
26,
267,
5927,
14,
2724,
8,
3291,
12,
9430,
9,
267,
5927,
14,
2724,
8,
4254,
36,
14,
6336,
84,
12,
9430,
9,
267,
5927,
14,
2724,
8,
4411,
14,
11141,
12,
9430,
9,
267,
11542,
14,
475,
1173,
8,
9430,
9,
339,
327,
22859,
272,
492,
900,
272,
367,
485,
315,
1425,
8,
3291,
14,
13161,
304,
199,
198,
509,
284,
315,
980,
14,
2355,
14,
23832,
8,
3291,
14,
1507,
5535,
6393,
17,
26,
288,
1343,
275,
900,
14,
521,
342,
6722,
666,
63,
807,
12,
279,
374,
12,
1612,
12,
7723,
275,
5077,
14,
912,
1451,
1173,
2141,
8,
73,
9,
6722,
18868,
36,
14,
1065,
63,
3610,
8,
576,
63,
807,
12,
279,
374,
12,
1612,
12,
7723,
9,
288,
1284,
275,
900,
14,
521,
342,
288,
870,
298,
1173,
900,
450,
70,
14007,
500,
13,
928,
9,
398,
327,
11063,
376,
685,
279,
2410,
9463,
267,
18868,
36,
14,
4468,
275,
18868,
36,
14,
4468,
1182,
3999,
14,
290,
685,
279,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
pixbuffer/django-cms
|
cms/plugins/video/models.py
|
12
|
2880
|
from django.db import models
from django.utils.translation import ugettext_lazy as _
from cms.models import CMSPlugin
from cms.plugins.video import settings
from os.path import basename
class Video(CMSPlugin):
# player settings
movie = models.FileField(_('movie file'), upload_to=CMSPlugin.get_media_path, help_text=_('use .flv file or h264 encoded video file'), blank=True, null=True)
movie_url = models.CharField(_('movie url'), max_length=255, help_text=_('vimeo or youtube video url. Example: http://www.youtube.com/watch?v=-iJ7bs4mTUY'), blank=True, null=True)
image = models.ImageField(_('image'), upload_to=CMSPlugin.get_media_path, help_text=_('preview image file'), null=True, blank=True)
width = models.PositiveSmallIntegerField(_('width'))
height = models.PositiveSmallIntegerField(_('height'))
auto_play = models.BooleanField(_('auto play'), default=settings.VIDEO_AUTOPLAY)
auto_hide = models.BooleanField(_('auto hide'), default=settings.VIDEO_AUTOHIDE)
fullscreen = models.BooleanField(_('fullscreen'), default=settings.VIDEO_FULLSCREEN)
loop = models.BooleanField(_('loop'), default=settings.VIDEO_LOOP)
# plugin settings
bgcolor = models.CharField(_('background color'), max_length=6, default=settings.VIDEO_BG_COLOR, help_text=_('Hexadecimal, eg ff00cc'))
textcolor = models.CharField(_('text color'), max_length=6, default=settings.VIDEO_TEXT_COLOR, help_text=_('Hexadecimal, eg ff00cc'))
seekbarcolor = models.CharField(_('seekbar color'), max_length=6, default=settings.VIDEO_SEEKBAR_COLOR, help_text=_('Hexadecimal, eg ff00cc'))
seekbarbgcolor = models.CharField(_('seekbar bg color'), max_length=6, default=settings.VIDEO_SEEKBARBG_COLOR, help_text=_('Hexadecimal, eg ff00cc'))
loadingbarcolor = models.CharField(_('loadingbar color'), max_length=6, default=settings.VIDEO_LOADINGBAR_COLOR, help_text=_('Hexadecimal, eg ff00cc'))
buttonoutcolor = models.CharField(_('button out color'), max_length=6, default=settings.VIDEO_BUTTON_OUT_COLOR, help_text=_('Hexadecimal, eg ff00cc'))
buttonovercolor = models.CharField(_('button over color'), max_length=6, default=settings.VIDEO_BUTTON_OVER_COLOR, help_text=_('Hexadecimal, eg ff00cc'))
buttonhighlightcolor = models.CharField(_('button highlight color'), max_length=6, default=settings.VIDEO_BUTTON_HIGHLIGHT_COLOR, help_text=_('Hexadecimal, eg ff00cc'))
def __unicode__(self):
if self.movie:
name = self.movie.path
else:
name = self.movie_url
return u"%s" % basename(name)
def get_height(self):
return "%s" % (self.height)
def get_width(self):
return "%s" % (self.width)
def get_movie(self):
if self.movie:
return self.movie.url
else:
return self.movie_url
|
bsd-3-clause
|
[
504,
1639,
14,
697,
492,
1709,
199,
504,
1639,
14,
1208,
14,
6893,
492,
10366,
63,
6395,
465,
485,
199,
504,
19240,
14,
992,
492,
29554,
5061,
199,
504,
19240,
14,
5265,
14,
3722,
492,
2202,
199,
504,
747,
14,
515,
492,
9593,
199,
199,
533,
15709,
8,
17834,
5061,
304,
272,
327,
7748,
2202,
272,
14360,
275,
1709,
14,
23252,
6723,
10888,
570,
659,
5802,
63,
475,
29,
17834,
5061,
14,
362,
63,
4603,
63,
515,
12,
1720,
63,
505,
12397,
1180,
1275,
22753,
570,
503,
394,
9408,
5737,
3991,
570,
659,
4596,
29,
549,
12,
2973,
29,
549,
9,
272,
14360,
63,
633,
275,
1709,
14,
2183,
6723,
10888,
1166,
659,
1390,
63,
1267,
29,
2299,
12,
1720,
63,
505,
12397,
433,
278,
79,
503,
22378,
3991,
1166,
14,
5679,
26,
1455,
921,
1544,
14,
9788,
14,
957,
15,
6821,
31,
86,
4022,
73,
42,
23,
1533,
20,
77,
21364,
57,
659,
4596,
29,
549,
12,
2973,
29,
549,
9,
272,
1834,
275,
1709,
14,
21910,
6723,
1569,
659,
5802,
63,
475,
29,
17834,
5061,
14,
362,
63,
4603,
63,
515,
12,
1720,
63,
505,
12397,
7780,
1834,
570,
659,
2973,
29,
549,
12,
4596,
29,
549,
9,
2286,
3462,
275,
1709,
14,
25197,
6723,
2063,
1333,
272,
4569,
275,
1709,
14,
25197,
6723,
3333,
1333,
2286,
2599,
63,
2802,
275,
1709,
14,
5036,
6723,
2495,
5232,
659,
849,
29,
1751,
14,
20142,
63,
10774,
1938,
16897,
9,
272,
2599,
63,
8191,
275,
1709,
14,
5036,
6723,
2495,
13714,
659,
849,
29,
1751,
14,
20142,
63,
13883,
40,
11259,
9,
272,
289,
13072,
4463,
275,
1709,
14,
5036,
6723,
28418,
4463,
659,
849,
29,
1751,
14,
20142,
63,
14742,
25070,
9,
272,
4438,
275,
1709,
14,
5036,
6723,
3813,
659,
849,
29,
1751,
14,
20142,
63,
26573,
9,
2286,
327,
3589,
2202,
272,
12994,
2326,
275,
1709,
14,
2183,
6723,
7451,
3164,
659,
1390,
63,
1267,
29,
22,
12,
849,
29,
1751,
14,
20142,
63,
18998,
63,
7134,
12,
1720,
63,
505,
12397,
10373,
19423,
12,
11837,
16328,
383,
2055,
1333,
272,
1318,
2326,
275,
1709,
14,
2183,
6723,
505,
3164,
659,
1390,
63,
1267,
29,
22,
12,
849,
29,
1751,
14,
20142,
63,
3876,
63,
7134,
12,
1720,
63,
505,
12397,
10373,
19423,
12,
11837,
16328,
383,
2055,
1333,
272,
12005,
1700,
2326,
275,
1709,
14,
2183,
6723,
5507,
1700,
3164,
659,
1390,
63,
1267,
29,
22,
12,
849,
29,
1751,
14,
20142,
63,
18439,
13895,
63,
7134,
12,
1720,
63,
505,
12397,
10373,
19423,
12,
11837,
16328,
383,
2055,
1333,
272,
12005,
1700,
28710,
275,
1709,
14,
2183,
6723,
5507,
1700,
12994,
3164,
659,
1390,
63,
1267,
29,
22,
12,
849,
29,
1751,
14,
20142,
63,
18439,
34,
8611,
39,
63,
7134,
12,
1720,
63,
505,
12397,
10373,
19423,
12,
11837,
16328,
383,
2055,
1333,
272,
8697,
1700,
2326,
275,
1709,
14,
2183,
6723,
8786,
1700,
3164,
659,
1390,
63,
1267,
29,
22,
12,
849,
29,
1751,
14,
20142,
63,
7405,
1206,
13895,
63,
7134,
12,
1720,
63,
505,
12397,
10373,
19423,
12,
11837,
16328,
383,
2055,
1333,
272,
5528,
548,
2326,
275,
1709,
14,
2183,
6723,
3887,
734,
3164,
659,
1390,
63,
1267,
29,
22,
12,
849,
29,
1751,
14,
20142,
63,
13272,
63,
1877,
63,
7134,
12,
1720,
63,
505,
12397,
10373,
19423,
12,
11837,
16328,
383,
2055,
1333,
272,
5528,
1883,
2326,
275,
1709,
14,
2183,
6723,
3887,
1806,
3164,
659,
1390,
63,
1267,
29,
22,
12,
849,
29,
1751,
14,
20142,
63,
13272,
63,
14336,
63,
7134,
12,
1720,
63,
505,
12397,
10373,
19423,
12,
11837,
16328,
383,
2055,
1333,
260,
272,
5528,
14337,
2326,
275,
1709,
14,
2183,
6723,
3887,
11850,
3164,
659,
1390,
63,
1267,
29,
22,
12,
849,
29,
1751,
14,
20142,
63,
13272,
63,
17624,
21613,
63,
7134,
12,
1720,
63,
505,
12397,
10373,
19423,
12,
11837,
16328,
383,
2055,
1333,
1362,
5493,
347,
636,
2975,
721,
277,
304,
267,
340,
291,
14,
10888,
26,
288,
536,
275,
291,
14,
10888,
14,
515,
267,
587,
26,
288,
536,
275,
291,
14,
10888,
63,
633,
267,
372,
399,
6808,
83,
2,
450,
9593,
8,
354,
9,
339,
347,
664,
63,
3333,
8,
277,
304,
267,
372,
2071,
83,
2,
450,
334,
277,
14,
3333,
9,
2286,
347,
664,
63,
2063,
8,
277,
304,
267,
372,
2071,
83,
2,
450,
334,
277,
14,
2063,
9,
258,
2286,
347,
664,
63,
10888,
8,
277,
304,
267,
340,
291,
14,
10888,
26,
288,
372,
291,
14,
10888,
14,
633,
267,
587,
26,
288,
372,
291,
14,
10888,
63,
633,
421,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1639,
14,
697,
492,
1709,
199,
504,
1639,
14,
1208,
14,
6893,
492,
10366,
63,
6395,
465,
485,
199,
504,
19240,
14,
992,
492,
29554,
5061,
199,
504,
19240,
14,
5265,
14,
3722,
492,
2202,
199,
504,
747,
14,
515,
492,
9593,
199,
199,
533,
15709,
8,
17834,
5061,
304,
272,
327,
7748,
2202,
272,
14360,
275,
1709,
14,
23252,
6723,
10888,
570,
659,
5802,
63,
475,
29,
17834,
5061,
14,
362,
63,
4603,
63,
515,
12,
1720,
63,
505,
12397,
1180,
1275,
22753,
570,
503,
394,
9408,
5737,
3991,
570,
659,
4596,
29,
549,
12,
2973,
29,
549,
9,
272,
14360,
63,
633,
275,
1709,
14,
2183,
6723,
10888,
1166,
659,
1390,
63,
1267,
29,
2299,
12,
1720,
63,
505,
12397,
433,
278,
79,
503,
22378,
3991,
1166,
14,
5679,
26,
1455,
921,
1544,
14,
9788,
14,
957,
15,
6821,
31,
86,
4022,
73,
42,
23,
1533,
20,
77,
21364,
57,
659,
4596,
29,
549,
12,
2973,
29,
549,
9,
272,
1834,
275,
1709,
14,
21910,
6723,
1569,
659,
5802,
63,
475,
29,
17834,
5061,
14,
362,
63,
4603,
63,
515,
12,
1720,
63,
505,
12397,
7780,
1834,
570,
659,
2973,
29,
549,
12,
4596,
29,
549,
9,
2286,
3462,
275,
1709,
14,
25197,
6723,
2063,
1333,
272,
4569,
275,
1709,
14,
25197,
6723,
3333,
1333,
2286,
2599,
63,
2802,
275,
1709,
14,
5036,
6723,
2495,
5232,
659,
849,
29,
1751,
14,
20142,
63,
10774,
1938,
16897,
9,
272,
2599,
63,
8191,
275,
1709,
14,
5036,
6723,
2495,
13714,
659,
849,
29,
1751,
14,
20142,
63,
13883,
40,
11259,
9,
272,
289,
13072,
4463,
275,
1709,
14,
5036,
6723,
28418,
4463,
659,
849,
29,
1751,
14,
20142,
63,
14742,
25070,
9,
272,
4438,
275,
1709,
14,
5036,
6723,
3813,
659,
849,
29,
1751,
14,
20142,
63,
26573,
9,
2286,
327,
3589,
2202,
272,
12994,
2326,
275,
1709,
14,
2183,
6723,
7451,
3164,
659,
1390,
63,
1267,
29,
22,
12,
849,
29,
1751,
14,
20142,
63,
18998,
63,
7134,
12,
1720,
63,
505,
12397,
10373,
19423,
12,
11837,
16328,
383,
2055,
1333,
272,
1318,
2326,
275,
1709,
14,
2183,
6723,
505,
3164,
659,
1390,
63,
1267,
29,
22,
12,
849,
29,
1751,
14,
20142,
63,
3876,
63,
7134,
12,
1720,
63,
505,
12397,
10373,
19423,
12,
11837,
16328,
383,
2055,
1333,
272,
12005,
1700,
2326,
275,
1709,
14,
2183,
6723,
5507,
1700,
3164,
659,
1390,
63,
1267,
29,
22,
12,
849,
29,
1751,
14,
20142,
63,
18439,
13895,
63,
7134,
12,
1720,
63,
505,
12397,
10373,
19423,
12,
11837,
16328,
383,
2055,
1333,
272,
12005,
1700,
28710,
275,
1709,
14,
2183,
6723,
5507,
1700,
12994,
3164,
659,
1390,
63,
1267,
29,
22,
12,
849,
29,
1751,
14,
20142,
63,
18439,
34,
8611,
39,
63,
7134,
12,
1720,
63,
505,
12397,
10373,
19423,
12,
11837,
16328,
383,
2055,
1333,
272,
8697,
1700,
2326,
275,
1709,
14,
2183,
6723,
8786,
1700,
3164,
659,
1390,
63,
1267,
29,
22,
12,
849,
29,
1751,
14,
20142,
63,
7405,
1206,
13895,
63,
7134,
12,
1720,
63,
505,
12397,
10373,
19423,
12,
11837,
16328,
383,
2055,
1333,
272,
5528,
548,
2326,
275,
1709,
14,
2183,
6723,
3887,
734,
3164,
659,
1390,
63,
1267,
29,
22,
12,
849,
29,
1751,
14,
20142,
63,
13272,
63,
1877,
63,
7134,
12,
1720,
63,
505,
12397,
10373,
19423,
12,
11837,
16328,
383,
2055,
1333,
272,
5528,
1883,
2326,
275,
1709,
14,
2183,
6723,
3887,
1806,
3164,
659,
1390,
63,
1267,
29,
22,
12,
849,
29,
1751,
14,
20142,
63,
13272,
63,
14336,
63,
7134,
12,
1720,
63,
505,
12397,
10373,
19423,
12,
11837,
16328,
383,
2055,
1333,
260,
272,
5528,
14337,
2326,
275,
1709,
14,
2183,
6723,
3887,
11850,
3164,
659,
1390,
63,
1267,
29,
22,
12,
849,
29,
1751,
14,
20142,
63,
13272,
63,
17624,
21613,
63,
7134,
12,
1720,
63,
505,
12397,
10373,
19423,
12,
11837,
16328,
383,
2055,
1333,
1362,
5493,
347,
636,
2975,
721,
277,
304,
267,
340,
291,
14,
10888,
26,
288,
536,
275,
291,
14,
10888,
14,
515,
267,
587,
26,
288,
536,
275,
291,
14,
10888,
63,
633,
267,
372,
399,
6808,
83,
2,
450,
9593,
8,
354,
9,
339,
347,
664,
63,
3333,
8,
277,
304,
267,
372,
2071,
83,
2,
450,
334,
277,
14,
3333,
9,
2286,
347,
664,
63,
2063,
8,
277,
304,
267,
372,
2071,
83,
2,
450,
334,
277,
14,
2063,
9,
258,
2286,
347,
664,
63,
10888,
8,
277,
304,
267,
340,
291,
14,
10888,
26,
288,
372,
291,
14,
10888,
14,
633,
267,
587,
26,
288,
372,
291,
14,
10888,
63,
633,
421,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
ArthurGarnier/SickRage
|
lib/urllib3/util/ssl_.py
|
87
|
12208
|
from __future__ import absolute_import
import errno
import warnings
import hmac
from binascii import hexlify, unhexlify
from hashlib import md5, sha1, sha256
from ..exceptions import SSLError, InsecurePlatformWarning, SNIMissingWarning
SSLContext = None
HAS_SNI = False
IS_PYOPENSSL = False
IS_SECURETRANSPORT = False
# Maps the length of a digest to a possible hash function producing this digest
HASHFUNC_MAP = {
32: md5,
40: sha1,
64: sha256,
}
def _const_compare_digest_backport(a, b):
"""
Compare two digests of equal length in constant time.
The digests must be of type str/bytes.
Returns True if the digests match, and False otherwise.
"""
result = abs(len(a) - len(b))
for l, r in zip(bytearray(a), bytearray(b)):
result |= l ^ r
return result == 0
_const_compare_digest = getattr(hmac, 'compare_digest',
_const_compare_digest_backport)
try: # Test for SSL features
import ssl
from ssl import wrap_socket, CERT_NONE, PROTOCOL_SSLv23
from ssl import HAS_SNI # Has SNI?
except ImportError:
pass
try:
from ssl import OP_NO_SSLv2, OP_NO_SSLv3, OP_NO_COMPRESSION
except ImportError:
OP_NO_SSLv2, OP_NO_SSLv3 = 0x1000000, 0x2000000
OP_NO_COMPRESSION = 0x20000
# A secure default.
# Sources for more information on TLS ciphers:
#
# - https://wiki.mozilla.org/Security/Server_Side_TLS
# - https://www.ssllabs.com/projects/best-practices/index.html
# - https://hynek.me/articles/hardening-your-web-servers-ssl-ciphers/
#
# The general intent is:
# - Prefer TLS 1.3 cipher suites
# - prefer cipher suites that offer perfect forward secrecy (DHE/ECDHE),
# - prefer ECDHE over DHE for better performance,
# - prefer any AES-GCM and ChaCha20 over any AES-CBC for better performance and
# security,
# - prefer AES-GCM over ChaCha20 because hardware-accelerated AES is common,
# - disable NULL authentication, MD5 MACs and DSS for security reasons.
DEFAULT_CIPHERS = ':'.join([
'TLS13-AES-256-GCM-SHA384',
'TLS13-CHACHA20-POLY1305-SHA256',
'TLS13-AES-128-GCM-SHA256',
'ECDH+AESGCM',
'ECDH+CHACHA20',
'DH+AESGCM',
'DH+CHACHA20',
'ECDH+AES256',
'DH+AES256',
'ECDH+AES128',
'DH+AES',
'RSA+AESGCM',
'RSA+AES',
'!aNULL',
'!eNULL',
'!MD5',
])
try:
from ssl import SSLContext # Modern SSL?
except ImportError:
import sys
class SSLContext(object): # Platform-specific: Python 2 & 3.1
supports_set_ciphers = ((2, 7) <= sys.version_info < (3,) or
(3, 2) <= sys.version_info)
def __init__(self, protocol_version):
self.protocol = protocol_version
# Use default values from a real SSLContext
self.check_hostname = False
self.verify_mode = ssl.CERT_NONE
self.ca_certs = None
self.options = 0
self.certfile = None
self.keyfile = None
self.ciphers = None
def load_cert_chain(self, certfile, keyfile):
self.certfile = certfile
self.keyfile = keyfile
def load_verify_locations(self, cafile=None, capath=None):
self.ca_certs = cafile
if capath is not None:
raise SSLError("CA directories not supported in older Pythons")
def set_ciphers(self, cipher_suite):
if not self.supports_set_ciphers:
raise TypeError(
'Your version of Python does not support setting '
'a custom cipher suite. Please upgrade to Python '
'2.7, 3.2, or later if you need this functionality.'
)
self.ciphers = cipher_suite
def wrap_socket(self, socket, server_hostname=None, server_side=False):
warnings.warn(
'A true SSLContext object is not available. This prevents '
'urllib3 from configuring SSL appropriately and may cause '
'certain SSL connections to fail. You can upgrade to a newer '
'version of Python to solve this. For more information, see '
'https://urllib3.readthedocs.io/en/latest/advanced-usage.html'
'#ssl-warnings',
InsecurePlatformWarning
)
kwargs = {
'keyfile': self.keyfile,
'certfile': self.certfile,
'ca_certs': self.ca_certs,
'cert_reqs': self.verify_mode,
'ssl_version': self.protocol,
'server_side': server_side,
}
if self.supports_set_ciphers: # Platform-specific: Python 2.7+
return wrap_socket(socket, ciphers=self.ciphers, **kwargs)
else: # Platform-specific: Python 2.6
return wrap_socket(socket, **kwargs)
def assert_fingerprint(cert, fingerprint):
"""
Checks if given fingerprint matches the supplied certificate.
:param cert:
Certificate as bytes object.
:param fingerprint:
Fingerprint as string of hexdigits, can be interspersed by colons.
"""
fingerprint = fingerprint.replace(':', '').lower()
digest_length = len(fingerprint)
hashfunc = HASHFUNC_MAP.get(digest_length)
if not hashfunc:
raise SSLError(
'Fingerprint of invalid length: {0}'.format(fingerprint))
# We need encode() here for py32; works on py2 and p33.
fingerprint_bytes = unhexlify(fingerprint.encode())
cert_digest = hashfunc(cert).digest()
if not _const_compare_digest(cert_digest, fingerprint_bytes):
raise SSLError('Fingerprints did not match. Expected "{0}", got "{1}".'
.format(fingerprint, hexlify(cert_digest)))
def resolve_cert_reqs(candidate):
"""
Resolves the argument to a numeric constant, which can be passed to
the wrap_socket function/method from the ssl module.
Defaults to :data:`ssl.CERT_NONE`.
If given a string it is assumed to be the name of the constant in the
:mod:`ssl` module or its abbrevation.
(So you can specify `REQUIRED` instead of `CERT_REQUIRED`.
If it's neither `None` nor a string we assume it is already the numeric
constant which can directly be passed to wrap_socket.
"""
if candidate is None:
return CERT_NONE
if isinstance(candidate, str):
res = getattr(ssl, candidate, None)
if res is None:
res = getattr(ssl, 'CERT_' + candidate)
return res
return candidate
def resolve_ssl_version(candidate):
"""
like resolve_cert_reqs
"""
if candidate is None:
return PROTOCOL_SSLv23
if isinstance(candidate, str):
res = getattr(ssl, candidate, None)
if res is None:
res = getattr(ssl, 'PROTOCOL_' + candidate)
return res
return candidate
def create_urllib3_context(ssl_version=None, cert_reqs=None,
options=None, ciphers=None):
"""All arguments have the same meaning as ``ssl_wrap_socket``.
By default, this function does a lot of the same work that
``ssl.create_default_context`` does on Python 3.4+. It:
- Disables SSLv2, SSLv3, and compression
- Sets a restricted set of server ciphers
If you wish to enable SSLv3, you can do::
from urllib3.util import ssl_
context = ssl_.create_urllib3_context()
context.options &= ~ssl_.OP_NO_SSLv3
You can do the same to enable compression (substituting ``COMPRESSION``
for ``SSLv3`` in the last line above).
:param ssl_version:
The desired protocol version to use. This will default to
PROTOCOL_SSLv23 which will negotiate the highest protocol that both
the server and your installation of OpenSSL support.
:param cert_reqs:
Whether to require the certificate verification. This defaults to
``ssl.CERT_REQUIRED``.
:param options:
Specific OpenSSL options. These default to ``ssl.OP_NO_SSLv2``,
``ssl.OP_NO_SSLv3``, ``ssl.OP_NO_COMPRESSION``.
:param ciphers:
Which cipher suites to allow the server to select.
:returns:
Constructed SSLContext object with specified options
:rtype: SSLContext
"""
context = SSLContext(ssl_version or ssl.PROTOCOL_SSLv23)
# Setting the default here, as we may have no ssl module on import
cert_reqs = ssl.CERT_REQUIRED if cert_reqs is None else cert_reqs
if options is None:
options = 0
# SSLv2 is easily broken and is considered harmful and dangerous
options |= OP_NO_SSLv2
# SSLv3 has several problems and is now dangerous
options |= OP_NO_SSLv3
# Disable compression to prevent CRIME attacks for OpenSSL 1.0+
# (issue #309)
options |= OP_NO_COMPRESSION
context.options |= options
if getattr(context, 'supports_set_ciphers', True): # Platform-specific: Python 2.6
context.set_ciphers(ciphers or DEFAULT_CIPHERS)
context.verify_mode = cert_reqs
if getattr(context, 'check_hostname', None) is not None: # Platform-specific: Python 3.2
# We do our own verification, including fingerprints and alternative
# hostnames. So disable it here
context.check_hostname = False
return context
def ssl_wrap_socket(sock, keyfile=None, certfile=None, cert_reqs=None,
ca_certs=None, server_hostname=None,
ssl_version=None, ciphers=None, ssl_context=None,
ca_cert_dir=None):
"""
All arguments except for server_hostname, ssl_context, and ca_cert_dir have
the same meaning as they do when using :func:`ssl.wrap_socket`.
:param server_hostname:
When SNI is supported, the expected hostname of the certificate
:param ssl_context:
A pre-made :class:`SSLContext` object. If none is provided, one will
be created using :func:`create_urllib3_context`.
:param ciphers:
A string of ciphers we wish the client to support. This is not
supported on Python 2.6 as the ssl module does not support it.
:param ca_cert_dir:
A directory containing CA certificates in multiple separate files, as
supported by OpenSSL's -CApath flag or the capath argument to
SSLContext.load_verify_locations().
"""
context = ssl_context
if context is None:
# Note: This branch of code and all the variables in it are no longer
# used by urllib3 itself. We should consider deprecating and removing
# this code.
context = create_urllib3_context(ssl_version, cert_reqs,
ciphers=ciphers)
if ca_certs or ca_cert_dir:
try:
context.load_verify_locations(ca_certs, ca_cert_dir)
except IOError as e: # Platform-specific: Python 2.6, 2.7, 3.2
raise SSLError(e)
# Py33 raises FileNotFoundError which subclasses OSError
# These are not equivalent unless we check the errno attribute
except OSError as e: # Platform-specific: Python 3.3 and beyond
if e.errno == errno.ENOENT:
raise SSLError(e)
raise
elif getattr(context, 'load_default_certs', None) is not None:
# try to load OS default certs; works well on Windows (require Python3.4+)
context.load_default_certs()
if certfile:
context.load_cert_chain(certfile, keyfile)
if HAS_SNI: # Platform-specific: OpenSSL with enabled SNI
return context.wrap_socket(sock, server_hostname=server_hostname)
warnings.warn(
'An HTTPS request has been made, but the SNI (Subject Name '
'Indication) extension to TLS is not available on this platform. '
'This may cause the server to present an incorrect TLS '
'certificate, which can cause validation failures. You can upgrade to '
'a newer version of Python to solve this. For more information, see '
'https://urllib3.readthedocs.io/en/latest/advanced-usage.html'
'#ssl-warnings',
SNIMissingWarning
)
return context.wrap_socket(sock)
|
gpl-3.0
|
[
504,
636,
2443,
363,
492,
3679,
63,
646,
199,
646,
7554,
199,
646,
3598,
199,
646,
20330,
199,
199,
504,
14755,
492,
6318,
8209,
12,
625,
20677,
199,
504,
8337,
492,
6128,
21,
12,
7793,
17,
12,
7793,
3912,
199,
199,
504,
2508,
3924,
492,
7799,
547,
12,
1010,
7817,
10397,
3849,
12,
428,
46,
1469,
374,
1044,
3849,
421,
199,
5413,
2998,
275,
488,
199,
13533,
63,
8199,
41,
275,
756,
199,
1311,
63,
4521,
9935,
5413,
275,
756,
199,
1311,
63,
13478,
775,
50,
5622,
3657,
275,
756,
199,
199,
3,
23673,
314,
2582,
402,
282,
10017,
370,
282,
3962,
2631,
805,
27955,
642,
10017,
199,
14395,
19587,
63,
5443,
275,
469,
272,
4337,
26,
6128,
21,
12,
272,
6335,
26,
7793,
17,
12,
272,
5049,
26,
7793,
3912,
12,
199,
93,
421,
199,
318,
485,
1297,
63,
5785,
63,
5671,
63,
894,
719,
8,
65,
12,
330,
304,
272,
408,
272,
18955,
2877,
10017,
83,
402,
4472,
2582,
315,
4413,
900,
14,
339,
710,
10017,
83,
1471,
506,
402,
730,
620,
15,
2394,
14,
272,
1803,
715,
340,
314,
10017,
83,
1336,
12,
436,
756,
4257,
14,
272,
408,
272,
754,
275,
2853,
8,
552,
8,
65,
9,
446,
822,
8,
66,
430,
272,
367,
634,
12,
519,
315,
3482,
8,
20108,
8,
65,
395,
11640,
8,
66,
2298,
267,
754,
8901,
634,
7167,
519,
272,
372,
754,
508,
378,
421,
199,
63,
1297,
63,
5785,
63,
5671,
275,
2519,
8,
18537,
12,
283,
5785,
63,
5671,
297,
1816,
485,
1297,
63,
5785,
63,
5671,
63,
894,
719,
9,
421,
199,
893,
26,
221,
327,
1379,
367,
7799,
4534,
272,
492,
6149,
272,
687,
6149,
492,
4816,
63,
3450,
12,
28313,
63,
9185,
12,
3611,
2566,
3978,
63,
21082,
1789,
272,
687,
6149,
492,
7509,
63,
8199,
41,
221,
327,
13481,
428,
16730,
31,
199,
2590,
3545,
26,
272,
986,
421,
199,
893,
26,
272,
687,
6149,
492,
9827,
63,
2826,
63,
21082,
18,
12,
9827,
63,
2826,
63,
21082,
19,
12,
9827,
63,
2826,
63,
30193,
199,
2590,
3545,
26,
272,
9827,
63,
2826,
63,
21082,
18,
12,
9827,
63,
2826,
63,
21082,
19,
275,
378,
88,
22589,
12,
378,
88,
18,
3273,
272,
9827,
63,
2826,
63,
30193,
275,
378,
88,
27140,
199,
199,
3,
437,
11153,
849,
14,
199,
3,
5800,
83,
367,
1655,
2556,
641,
12213,
30377,
26,
199,
3,
199,
3,
446,
4178,
921,
6797,
14,
12102,
14,
1308,
15,
7676,
15,
3120,
63,
15414,
63,
10224,
199,
3,
446,
4178,
921,
1544,
14,
385,
914,
2101,
14,
957,
15,
6776,
15,
7010,
13,
80,
6457,
7724,
15,
1080,
14,
1360,
199,
3,
446,
4178,
921,
3577,
685,
75,
14,
278,
15,
19813,
15,
8210,
848,
316,
13,
12695,
13,
2520,
13,
5871,
13,
4266,
13,
27426,
15,
199,
3,
199,
3,
710,
8605,
21020,
365,
26,
199,
3,
446,
510,
21928,
12213,
413,
14,
19,
10830,
24203,
199,
3,
446,
16602,
10830,
24203,
626,
19793,
23668,
7568,
542,
1353,
1480,
334,
23520,
15,
4220,
23520,
395,
199,
3,
446,
16602,
662,
7695,
1645,
1806,
577,
1645,
367,
8034,
10238,
12,
199,
3,
446,
16602,
1263,
19093,
13,
29009,
436,
445,
2411,
1049,
65,
1165,
1806,
1263,
19093,
13,
18255,
367,
8034,
10238,
436,
199,
3,
257,
6391,
12,
199,
3,
446,
16602,
19093,
13,
29009,
1806,
445,
2411,
1049,
65,
1165,
2952,
14991,
13,
645,
15730,
19093,
365,
2863,
12,
199,
3,
446,
3507,
5962,
6299,
12,
15830,
21,
13347,
83,
436,
577,
2300,
367,
6391,
14872,
14,
199,
3472,
63,
35,
1772,
31700,
275,
29010,
904,
779,
272,
283,
10224,
969,
13,
14494,
13,
3912,
13,
29009,
13,
8461,
8188,
297,
272,
283,
10224,
969,
13,
26363,
26363,
1165,
13,
19869,
969,
1717,
13,
8461,
3912,
297,
272,
283,
10224,
969,
13,
14494,
13,
3933,
13,
29009,
13,
8461,
3912,
297,
272,
283,
4220,
13860,
11,
14494,
29009,
297,
272,
283,
4220,
13860,
11,
26363,
26363,
1165,
297,
272,
283,
13860,
11,
14494,
29009,
297,
272,
283,
13860,
11,
26363,
26363,
1165,
297,
272,
283,
4220,
13860,
11,
14494,
3912,
297,
272,
283,
13860,
11,
14494,
3912,
297,
272,
283,
4220,
13860,
11,
14494,
3933,
297,
272,
283,
13860,
11,
14494,
297,
272,
283,
12115,
11,
14494,
29009,
297,
272,
283,
12115,
11,
14494,
297,
272,
14597,
65,
8084,
297,
272,
14597,
69,
8084,
297,
272,
14597,
5127,
21,
297,
199,
566,
199,
199,
893,
26,
272,
687,
6149,
492,
7799,
2998,
221,
327,
4900,
11641,
7799,
31,
199,
2590,
3545,
26,
272,
492,
984,
339,
1021,
7799,
2998,
8,
785,
304,
221,
327,
16078,
13,
6100,
26,
2018,
499,
1253,
650,
14,
17,
267,
5171,
63,
409,
63,
27426,
275,
3666,
18,
12,
1520,
9,
2695,
984,
14,
1023,
63,
815,
665,
334,
19,
4258,
503,
1816,
334,
19,
12,
499,
9,
2695,
984,
14,
1023,
63,
815,
9,
398,
347,
636,
826,
721,
277,
12,
4113,
63,
1023,
304,
288,
291,
14,
3922,
275,
4113,
63,
1023,
288,
327,
3645,
849,
1338,
687,
282,
3363,
7799,
2998,
288,
291,
14,
1074,
63,
4269,
275,
756,
288,
291,
14,
4712,
63,
632,
275,
6149,
14,
11163,
63,
9185,
288,
291,
14,
696,
63,
8356,
275,
488,
288,
291,
14,
1419,
275,
378,
288,
291,
14,
28340,
275,
488,
288,
291,
14,
21856,
275,
488,
288,
291,
14,
27426,
275,
488,
398,
347,
2248,
63,
4736,
63,
4429,
8,
277,
12,
27660,
12,
25776,
304,
288,
291,
14,
28340,
275,
27660,
288,
291,
14,
21856,
275,
25776,
398,
347,
2248,
63,
4712,
63,
8022,
8,
277,
12,
1704,
493,
29,
403,
12,
1704,
515,
29,
403,
304,
288,
291,
14,
696,
63,
8356,
275,
1704,
493,
953,
340,
1704,
515,
365,
440,
488,
26,
355,
746,
7799,
547,
480,
3263,
6602,
440,
3748,
315,
12731,
2018,
83,
531,
398,
347,
663,
63,
27426,
8,
277,
12,
10830,
63,
5768,
304,
288,
340,
440,
291,
14,
9823,
63,
409,
63,
27426,
26,
355,
746,
3146,
8,
490,
283,
14398,
1015,
402,
2018,
1630,
440,
2291,
4260,
283,
490,
283,
65,
3537,
10830,
5241,
14,
7754,
10754,
370,
2018,
283,
490,
283,
18,
14,
23,
12
] |
[
636,
2443,
363,
492,
3679,
63,
646,
199,
646,
7554,
199,
646,
3598,
199,
646,
20330,
199,
199,
504,
14755,
492,
6318,
8209,
12,
625,
20677,
199,
504,
8337,
492,
6128,
21,
12,
7793,
17,
12,
7793,
3912,
199,
199,
504,
2508,
3924,
492,
7799,
547,
12,
1010,
7817,
10397,
3849,
12,
428,
46,
1469,
374,
1044,
3849,
421,
199,
5413,
2998,
275,
488,
199,
13533,
63,
8199,
41,
275,
756,
199,
1311,
63,
4521,
9935,
5413,
275,
756,
199,
1311,
63,
13478,
775,
50,
5622,
3657,
275,
756,
199,
199,
3,
23673,
314,
2582,
402,
282,
10017,
370,
282,
3962,
2631,
805,
27955,
642,
10017,
199,
14395,
19587,
63,
5443,
275,
469,
272,
4337,
26,
6128,
21,
12,
272,
6335,
26,
7793,
17,
12,
272,
5049,
26,
7793,
3912,
12,
199,
93,
421,
199,
318,
485,
1297,
63,
5785,
63,
5671,
63,
894,
719,
8,
65,
12,
330,
304,
272,
408,
272,
18955,
2877,
10017,
83,
402,
4472,
2582,
315,
4413,
900,
14,
339,
710,
10017,
83,
1471,
506,
402,
730,
620,
15,
2394,
14,
272,
1803,
715,
340,
314,
10017,
83,
1336,
12,
436,
756,
4257,
14,
272,
408,
272,
754,
275,
2853,
8,
552,
8,
65,
9,
446,
822,
8,
66,
430,
272,
367,
634,
12,
519,
315,
3482,
8,
20108,
8,
65,
395,
11640,
8,
66,
2298,
267,
754,
8901,
634,
7167,
519,
272,
372,
754,
508,
378,
421,
199,
63,
1297,
63,
5785,
63,
5671,
275,
2519,
8,
18537,
12,
283,
5785,
63,
5671,
297,
1816,
485,
1297,
63,
5785,
63,
5671,
63,
894,
719,
9,
421,
199,
893,
26,
221,
327,
1379,
367,
7799,
4534,
272,
492,
6149,
272,
687,
6149,
492,
4816,
63,
3450,
12,
28313,
63,
9185,
12,
3611,
2566,
3978,
63,
21082,
1789,
272,
687,
6149,
492,
7509,
63,
8199,
41,
221,
327,
13481,
428,
16730,
31,
199,
2590,
3545,
26,
272,
986,
421,
199,
893,
26,
272,
687,
6149,
492,
9827,
63,
2826,
63,
21082,
18,
12,
9827,
63,
2826,
63,
21082,
19,
12,
9827,
63,
2826,
63,
30193,
199,
2590,
3545,
26,
272,
9827,
63,
2826,
63,
21082,
18,
12,
9827,
63,
2826,
63,
21082,
19,
275,
378,
88,
22589,
12,
378,
88,
18,
3273,
272,
9827,
63,
2826,
63,
30193,
275,
378,
88,
27140,
199,
199,
3,
437,
11153,
849,
14,
199,
3,
5800,
83,
367,
1655,
2556,
641,
12213,
30377,
26,
199,
3,
199,
3,
446,
4178,
921,
6797,
14,
12102,
14,
1308,
15,
7676,
15,
3120,
63,
15414,
63,
10224,
199,
3,
446,
4178,
921,
1544,
14,
385,
914,
2101,
14,
957,
15,
6776,
15,
7010,
13,
80,
6457,
7724,
15,
1080,
14,
1360,
199,
3,
446,
4178,
921,
3577,
685,
75,
14,
278,
15,
19813,
15,
8210,
848,
316,
13,
12695,
13,
2520,
13,
5871,
13,
4266,
13,
27426,
15,
199,
3,
199,
3,
710,
8605,
21020,
365,
26,
199,
3,
446,
510,
21928,
12213,
413,
14,
19,
10830,
24203,
199,
3,
446,
16602,
10830,
24203,
626,
19793,
23668,
7568,
542,
1353,
1480,
334,
23520,
15,
4220,
23520,
395,
199,
3,
446,
16602,
662,
7695,
1645,
1806,
577,
1645,
367,
8034,
10238,
12,
199,
3,
446,
16602,
1263,
19093,
13,
29009,
436,
445,
2411,
1049,
65,
1165,
1806,
1263,
19093,
13,
18255,
367,
8034,
10238,
436,
199,
3,
257,
6391,
12,
199,
3,
446,
16602,
19093,
13,
29009,
1806,
445,
2411,
1049,
65,
1165,
2952,
14991,
13,
645,
15730,
19093,
365,
2863,
12,
199,
3,
446,
3507,
5962,
6299,
12,
15830,
21,
13347,
83,
436,
577,
2300,
367,
6391,
14872,
14,
199,
3472,
63,
35,
1772,
31700,
275,
29010,
904,
779,
272,
283,
10224,
969,
13,
14494,
13,
3912,
13,
29009,
13,
8461,
8188,
297,
272,
283,
10224,
969,
13,
26363,
26363,
1165,
13,
19869,
969,
1717,
13,
8461,
3912,
297,
272,
283,
10224,
969,
13,
14494,
13,
3933,
13,
29009,
13,
8461,
3912,
297,
272,
283,
4220,
13860,
11,
14494,
29009,
297,
272,
283,
4220,
13860,
11,
26363,
26363,
1165,
297,
272,
283,
13860,
11,
14494,
29009,
297,
272,
283,
13860,
11,
26363,
26363,
1165,
297,
272,
283,
4220,
13860,
11,
14494,
3912,
297,
272,
283,
13860,
11,
14494,
3912,
297,
272,
283,
4220,
13860,
11,
14494,
3933,
297,
272,
283,
13860,
11,
14494,
297,
272,
283,
12115,
11,
14494,
29009,
297,
272,
283,
12115,
11,
14494,
297,
272,
14597,
65,
8084,
297,
272,
14597,
69,
8084,
297,
272,
14597,
5127,
21,
297,
199,
566,
199,
199,
893,
26,
272,
687,
6149,
492,
7799,
2998,
221,
327,
4900,
11641,
7799,
31,
199,
2590,
3545,
26,
272,
492,
984,
339,
1021,
7799,
2998,
8,
785,
304,
221,
327,
16078,
13,
6100,
26,
2018,
499,
1253,
650,
14,
17,
267,
5171,
63,
409,
63,
27426,
275,
3666,
18,
12,
1520,
9,
2695,
984,
14,
1023,
63,
815,
665,
334,
19,
4258,
503,
1816,
334,
19,
12,
499,
9,
2695,
984,
14,
1023,
63,
815,
9,
398,
347,
636,
826,
721,
277,
12,
4113,
63,
1023,
304,
288,
291,
14,
3922,
275,
4113,
63,
1023,
288,
327,
3645,
849,
1338,
687,
282,
3363,
7799,
2998,
288,
291,
14,
1074,
63,
4269,
275,
756,
288,
291,
14,
4712,
63,
632,
275,
6149,
14,
11163,
63,
9185,
288,
291,
14,
696,
63,
8356,
275,
488,
288,
291,
14,
1419,
275,
378,
288,
291,
14,
28340,
275,
488,
288,
291,
14,
21856,
275,
488,
288,
291,
14,
27426,
275,
488,
398,
347,
2248,
63,
4736,
63,
4429,
8,
277,
12,
27660,
12,
25776,
304,
288,
291,
14,
28340,
275,
27660,
288,
291,
14,
21856,
275,
25776,
398,
347,
2248,
63,
4712,
63,
8022,
8,
277,
12,
1704,
493,
29,
403,
12,
1704,
515,
29,
403,
304,
288,
291,
14,
696,
63,
8356,
275,
1704,
493,
953,
340,
1704,
515,
365,
440,
488,
26,
355,
746,
7799,
547,
480,
3263,
6602,
440,
3748,
315,
12731,
2018,
83,
531,
398,
347,
663,
63,
27426,
8,
277,
12,
10830,
63,
5768,
304,
288,
340,
440,
291,
14,
9823,
63,
409,
63,
27426,
26,
355,
746,
3146,
8,
490,
283,
14398,
1015,
402,
2018,
1630,
440,
2291,
4260,
283,
490,
283,
65,
3537,
10830,
5241,
14,
7754,
10754,
370,
2018,
283,
490,
283,
18,
14,
23,
12,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
MyKings/xunfeng
|
vulscan/vuldb/smb/base.py
|
3
|
143498
|
import logging, binascii, time, hmac
from datetime import datetime
from smb_constants import *
from smb2_constants import *
from smb_structs import *
from smb2_structs import *
from nmb.base import NMBSession
from utils import convertFILETIMEtoEpoch
import ntlm, securityblob
try:
import hashlib
sha256 = hashlib.sha256
except ImportError:
from utils import sha256
class NotReadyError(Exception):
"""Raised when SMB connection is not ready (i.e. not authenticated or authentication failed)"""
pass
class NotConnectedError(Exception):
"""Raised when underlying SMB connection has been disconnected or not connected yet"""
pass
class SMBTimeout(Exception):
"""Raised when a timeout has occurred while waiting for a response or for a SMB/CIFS operation to complete."""
pass
def _convert_to_unicode(string):
if not isinstance(string, unicode):
string = unicode(string, "utf-8")
return string
class SMB(NMBSession):
"""
This class represents a "connection" to the remote SMB/CIFS server.
It is not meant to be used directly in an application as it does not have any network transport implementations.
For application use, please refer to
- L{SMBProtocol.SMBProtocolFactory<smb.SMBProtocol>} if you are using Twisted framework
In [MS-CIFS], this class will contain attributes of Client, Client.Connection and Client.Session abstract data models.
References:
===========
- [MS-CIFS]: 3.2.1
"""
log = logging.getLogger('SMB.SMB')
SIGN_NEVER = 0
SIGN_WHEN_SUPPORTED = 1
SIGN_WHEN_REQUIRED = 2
def __init__(self, username, password, my_name, remote_name, domain = '', use_ntlm_v2 = True, sign_options = SIGN_WHEN_REQUIRED, is_direct_tcp = False):
NMBSession.__init__(self, my_name, remote_name, is_direct_tcp = is_direct_tcp)
self.username = _convert_to_unicode(username)
self.password = _convert_to_unicode(password)
self.domain = _convert_to_unicode(domain)
self.sign_options = sign_options
self.is_direct_tcp = is_direct_tcp
self.use_ntlm_v2 = use_ntlm_v2 #: Similar to LMAuthenticationPolicy and NTAuthenticationPolicy as described in [MS-CIFS] 3.2.1.1
self.smb_message = SMBMessage()
self.is_using_smb2 = False #: Are we communicating using SMB2 protocol? self.smb_message will be a SMB2Message instance if this flag is True
self.pending_requests = { } #: MID mapped to _PendingRequest instance
self.connected_trees = { } #: Share name mapped to TID
self.next_rpc_call_id = 1 #: Next RPC callID value. Not used directly in SMB message. Usually encapsulated in sub-commands under SMB_COM_TRANSACTION or SMB_COM_TRANSACTION2 messages
self.has_negotiated = False
self.has_authenticated = False
self.is_signing_active = False #: True if the remote server accepts message signing. All outgoing messages will be signed. Simiar to IsSigningActive as described in [MS-CIFS] 3.2.1.2
self.signing_session_key = None #: Session key for signing packets, if signing is active. Similar to SigningSessionKey as described in [MS-CIFS] 3.2.1.2
self.signing_challenge_response = None #: Contains the challenge response for signing, if signing is active. Similar to SigningChallengeResponse as described in [MS-CIFS] 3.2.1.2
self.mid = 0
self.uid = 0
self.next_signing_id = 2 #: Similar to ClientNextSendSequenceNumber as described in [MS-CIFS] 3.2.1.2
# SMB1 and SMB2 attributes
# Note that the interpretations of the values may differ between SMB1 and SMB2 protocols
self.capabilities = 0
self.security_mode = 0 #: Initialized from the SecurityMode field of the SMB_COM_NEGOTIATE message
# SMB1 attributes
# Most of the following attributes will be initialized upon receipt of SMB_COM_NEGOTIATE message from server (via self._updateServerInfo_SMB1 method)
self.use_plaintext_authentication = False #: Similar to PlaintextAuthenticationPolicy in in [MS-CIFS] 3.2.1.1
self.max_raw_size = 0
self.max_buffer_size = 0 #: Similar to MaxBufferSize as described in [MS-CIFS] 3.2.1.1
self.max_mpx_count = 0 #: Similar to MaxMpxCount as described in [MS-CIFS] 3.2.1.1
# SMB2 attributes
self.max_read_size = 0 #: Similar to MaxReadSize as described in [MS-SMB2] 2.2.4
self.max_write_size = 0 #: Similar to MaxWriteSize as described in [MS-SMB2] 2.2.4
self.max_transact_size = 0 #: Similar to MaxTransactSize as described in [MS-SMB2] 2.2.4
self.session_id = 0 #: Similar to SessionID as described in [MS-SMB2] 2.2.4. This will be set in _updateState_SMB2 method
self._setupSMB1Methods()
self.log.info('Authentication with remote machine "%s" for user "%s" will be using NTLM %s authentication (%s extended security)',
self.remote_name, self.username,
(self.use_ntlm_v2 and 'v2') or 'v1',
(SUPPORT_EXTENDED_SECURITY and 'with') or 'without')
#
# NMBSession Methods
#
def onNMBSessionOK(self):
self._sendSMBMessage(SMBMessage(ComNegotiateRequest()))
def onNMBSessionFailed(self):
pass
def onNMBSessionMessage(self, flags, data):
while True:
try:
i = self.smb_message.decode(data)
except SMB2ProtocolHeaderError:
self.log.info('Now switching over to SMB2 protocol communication')
self.is_using_smb2 = True
self.mid = 0 # Must reset messageID counter, or else remote SMB2 server will disconnect
self._setupSMB2Methods()
self.smb_message = self._klassSMBMessage()
i = self.smb_message.decode(data)
next_message_offset = 0
if self.is_using_smb2:
next_message_offset = self.smb_message.next_command_offset
if i > 0:
if not self.is_using_smb2:
self.log.debug('Received SMB message "%s" (command:0x%2X flags:0x%02X flags2:0x%04X TID:%d UID:%d)',
SMB_COMMAND_NAMES.get(self.smb_message.command, '<unknown>'),
self.smb_message.command, self.smb_message.flags, self.smb_message.flags2, self.smb_message.tid, self.smb_message.uid)
else:
self.log.debug('Received SMB2 message "%s" (command:0x%04X flags:0x%04x)',
SMB2_COMMAND_NAMES.get(self.smb_message.command, '<unknown>'),
self.smb_message.command, self.smb_message.flags)
if self._updateState(self.smb_message):
# We need to create a new instance instead of calling reset() because the instance could be captured in the message history.
self.smb_message = self._klassSMBMessage()
if next_message_offset > 0:
data = data[next_message_offset:]
else:
break
#
# Public Methods for Overriding in Subclasses
#
def onAuthOK(self):
pass
def onAuthFailed(self):
pass
#
# Protected Methods
#
def _setupSMB1Methods(self):
self._klassSMBMessage = SMBMessage
self._updateState = self._updateState_SMB1
self._updateServerInfo = self._updateServerInfo_SMB1
self._handleNegotiateResponse = self._handleNegotiateResponse_SMB1
self._sendSMBMessage = self._sendSMBMessage_SMB1
self._handleSessionChallenge = self._handleSessionChallenge_SMB1
self._listShares = self._listShares_SMB1
self._listPath = self._listPath_SMB1
self._listSnapshots = self._listSnapshots_SMB1
self._getAttributes = self._getAttributes_SMB1
self._retrieveFile = self._retrieveFile_SMB1
self._retrieveFileFromOffset = self._retrieveFileFromOffset_SMB1
self._storeFile = self._storeFile_SMB1
self._storeFileFromOffset = self._storeFileFromOffset_SMB1
self._deleteFiles = self._deleteFiles_SMB1
self._resetFileAttributes = self._resetFileAttributes_SMB1
self._createDirectory = self._createDirectory_SMB1
self._deleteDirectory = self._deleteDirectory_SMB1
self._rename = self._rename_SMB1
self._echo = self._echo_SMB1
def _setupSMB2Methods(self):
self._klassSMBMessage = SMB2Message
self._updateState = self._updateState_SMB2
self._updateServerInfo = self._updateServerInfo_SMB2
self._handleNegotiateResponse = self._handleNegotiateResponse_SMB2
self._sendSMBMessage = self._sendSMBMessage_SMB2
self._handleSessionChallenge = self._handleSessionChallenge_SMB2
self._listShares = self._listShares_SMB2
self._listPath = self._listPath_SMB2
self._listSnapshots = self._listSnapshots_SMB2
self._getAttributes = self._getAttributes_SMB2
self._retrieveFile = self._retrieveFile_SMB2
self._retrieveFileFromOffset = self._retrieveFileFromOffset_SMB2
self._storeFile = self._storeFile_SMB2
self._storeFileFromOffset = self._storeFileFromOffset_SMB2
self._deleteFiles = self._deleteFiles_SMB2
self._resetFileAttributes = self._resetFileAttributes_SMB2
self._createDirectory = self._createDirectory_SMB2
self._deleteDirectory = self._deleteDirectory_SMB2
self._rename = self._rename_SMB2
self._echo = self._echo_SMB2
def _getNextRPCCallID(self):
self.next_rpc_call_id += 1
return self.next_rpc_call_id
#
# SMB2 Methods Family
#
def _sendSMBMessage_SMB2(self, smb_message):
if smb_message.mid == 0:
smb_message.mid = self._getNextMID_SMB2()
if smb_message.command != SMB2_COM_NEGOTIATE and smb_message.command != SMB2_COM_ECHO:
smb_message.session_id = self.session_id
if self.is_signing_active:
smb_message.flags |= SMB2_FLAGS_SIGNED
raw_data = smb_message.encode()
smb_message.signature = hmac.new(self.signing_session_key, raw_data, sha256).digest()[:16]
smb_message.raw_data = smb_message.encode()
self.log.debug('MID is %d. Signature is %s. Total raw message is %d bytes', smb_message.mid, binascii.hexlify(smb_message.signature), len(smb_message.raw_data))
else:
smb_message.raw_data = smb_message.encode()
self.sendNMBMessage(smb_message.raw_data)
def _getNextMID_SMB2(self):
self.mid += 1
return self.mid
def _updateState_SMB2(self, message):
if message.isReply:
if message.command == SMB2_COM_NEGOTIATE:
if message.status == 0:
self.has_negotiated = True
self.log.info('SMB2 dialect negotiation successful')
self._updateServerInfo(message.payload)
self._handleNegotiateResponse(message)
else:
raise ProtocolError('Unknown status value (0x%08X) in SMB2_COM_NEGOTIATE' % message.status,
message.raw_data, message)
elif message.command == SMB2_COM_SESSION_SETUP:
if message.status == 0:
self.session_id = message.session_id
try:
result = securityblob.decodeAuthResponseSecurityBlob(message.payload.security_blob)
if result == securityblob.RESULT_ACCEPT_COMPLETED:
self.has_authenticated = True
self.log.info('Authentication (on SMB2) successful!')
self.onAuthOK()
else:
raise ProtocolError('SMB2_COM_SESSION_SETUP status is 0 but security blob negResult value is %d' % result, message.raw_data, message)
except securityblob.BadSecurityBlobError, ex:
raise ProtocolError(str(ex), message.raw_data, message)
elif message.status == 0xc0000016: # STATUS_MORE_PROCESSING_REQUIRED
self.session_id = message.session_id
try:
result, ntlm_token = securityblob.decodeChallengeSecurityBlob(message.payload.security_blob)
if result == securityblob.RESULT_ACCEPT_INCOMPLETE:
self._handleSessionChallenge(message, ntlm_token)
except ( securityblob.BadSecurityBlobError, securityblob.UnsupportedSecurityProvider ), ex:
raise ProtocolError(str(ex), message.raw_data, message)
elif message.status == 0xc000006d: # STATUS_LOGON_FAILURE
self.has_authenticated = False
self.log.info('Authentication (on SMB2) failed. Please check username and password.')
self.onAuthFailed()
else:
raise ProtocolError('Unknown status value (0x%08X) in SMB_COM_SESSION_SETUP_ANDX (with extended security)' % message.status,
message.raw_data, message)
req = self.pending_requests.pop(message.mid, None)
if req:
req.callback(message, **req.kwargs)
return True
def _updateServerInfo_SMB2(self, payload):
self.capabilities = payload.capabilities
self.security_mode = payload.security_mode
self.max_transact_size = payload.max_transact_size
self.max_read_size = payload.max_read_size
self.max_write_size = payload.max_write_size
self.use_plaintext_authentication = False # SMB2 never allows plaintext authentication
def _handleNegotiateResponse_SMB2(self, message):
ntlm_data = ntlm.generateNegotiateMessage()
blob = securityblob.generateNegotiateSecurityBlob(ntlm_data)
self._sendSMBMessage(SMB2Message(SMB2SessionSetupRequest(blob)))
def _handleSessionChallenge_SMB2(self, message, ntlm_token):
server_challenge, server_flags, server_info = ntlm.decodeChallengeMessage(ntlm_token)
self.log.info('Performing NTLMv2 authentication (on SMB2) with server challenge "%s"', binascii.hexlify(server_challenge))
if self.use_ntlm_v2:
self.log.info('Performing NTLMv2 authentication (on SMB2) with server challenge "%s"', binascii.hexlify(server_challenge))
nt_challenge_response, lm_challenge_response, session_key = ntlm.generateChallengeResponseV2(self.password,
self.username,
server_challenge,
server_info,
self.domain)
else:
self.log.info('Performing NTLMv1 authentication (on SMB2) with server challenge "%s"', binascii.hexlify(server_challenge))
nt_challenge_response, lm_challenge_response, session_key = ntlm.generateChallengeResponseV1(self.password, server_challenge, True)
ntlm_data = ntlm.generateAuthenticateMessage(server_flags,
nt_challenge_response,
lm_challenge_response,
session_key,
self.username,
self.domain)
if self.log.isEnabledFor(logging.DEBUG):
self.log.debug('NT challenge response is "%s" (%d bytes)', binascii.hexlify(nt_challenge_response), len(nt_challenge_response))
self.log.debug('LM challenge response is "%s" (%d bytes)', binascii.hexlify(lm_challenge_response), len(lm_challenge_response))
blob = securityblob.generateAuthSecurityBlob(ntlm_data)
self._sendSMBMessage(SMB2Message(SMB2SessionSetupRequest(blob)))
if self.security_mode & SMB2_NEGOTIATE_SIGNING_REQUIRED:
self.log.info('Server requires all SMB messages to be signed')
self.is_signing_active = (self.sign_options != SMB.SIGN_NEVER)
elif self.security_mode & SMB2_NEGOTIATE_SIGNING_ENABLED:
self.log.info('Server supports SMB signing')
self.is_signing_active = (self.sign_options == SMB.SIGN_WHEN_SUPPORTED)
else:
self.is_signing_active = False
if self.is_signing_active:
self.log.info("SMB signing activated. All SMB messages will be signed.")
self.signing_session_key = (session_key + '\0'*16)[:16]
if self.capabilities & CAP_EXTENDED_SECURITY:
self.signing_challenge_response = None
else:
self.signing_challenge_response = blob
else:
self.log.info("SMB signing deactivated. SMB messages will NOT be signed.")
def _listShares_SMB2(self, callback, errback, timeout = 30):
if not self.has_authenticated:
raise NotReadyError('SMB connection not authenticated')
expiry_time = time.time() + timeout
path = 'IPC$'
messages_history = [ ]
def connectSrvSvc(tid):
m = SMB2Message(SMB2CreateRequest('srvsvc',
file_attributes = 0,
access_mask = FILE_READ_DATA | FILE_WRITE_DATA | FILE_APPEND_DATA | FILE_READ_EA | FILE_WRITE_EA | READ_CONTROL | FILE_READ_ATTRIBUTES | FILE_WRITE_ATTRIBUTES | SYNCHRONIZE,
share_access = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
oplock = SMB2_OPLOCK_LEVEL_NONE,
impersonation = SEC_IMPERSONATE,
create_options = FILE_NON_DIRECTORY_FILE | FILE_OPEN_NO_RECALL,
create_disp = FILE_OPEN))
m.tid = tid
self._sendSMBMessage(m)
self.pending_requests[m.mid] = _PendingRequest(m.mid, expiry_time, connectSrvSvcCB, errback)
messages_history.append(m)
def connectSrvSvcCB(create_message, **kwargs):
messages_history.append(create_message)
if create_message.status == 0:
call_id = self._getNextRPCCallID()
# The data_bytes are binding call to Server Service RPC using DCE v1.1 RPC over SMB. See [MS-SRVS] and [C706]
# If you wish to understand the meanings of the byte stream, I would suggest you use a recent version of WireShark to packet capture the stream
data_bytes = \
binascii.unhexlify("""05 00 0b 03 10 00 00 00 74 00 00 00""".replace(' ', '')) + \
struct.pack('<I', call_id) + \
binascii.unhexlify("""
b8 10 b8 10 00 00 00 00 02 00 00 00 00 00 01 00
c8 4f 32 4b 70 16 d3 01 12 78 5a 47 bf 6e e1 88
03 00 00 00 04 5d 88 8a eb 1c c9 11 9f e8 08 00
2b 10 48 60 02 00 00 00 01 00 01 00 c8 4f 32 4b
70 16 d3 01 12 78 5a 47 bf 6e e1 88 03 00 00 00
2c 1c b7 6c 12 98 40 45 03 00 00 00 00 00 00 00
01 00 00 00
""".replace(' ', '').replace('\n', ''))
m = SMB2Message(SMB2WriteRequest(create_message.payload.fid, data_bytes, 0))
m.tid = create_message.tid
self._sendSMBMessage(m)
self.pending_requests[m.mid] = _PendingRequest(m.mid, expiry_time, rpcBindCB, errback, fid = create_message.payload.fid)
messages_history.append(m)
else:
errback(OperationFailure('Failed to list shares: Unable to locate Server Service RPC endpoint', messages_history))
def rpcBindCB(trans_message, **kwargs):
messages_history.append(trans_message)
if trans_message.status == 0:
m = SMB2Message(SMB2ReadRequest(kwargs['fid'], read_len = 1024, read_offset = 0))
m.tid = trans_message.tid
self._sendSMBMessage(m)
self.pending_requests[m.mid] = _PendingRequest(m.mid, expiry_time, rpcReadCB, errback, fid = kwargs['fid'])
messages_history.append(m)
else:
closeFid(trans_message.tid, kwargs['fid'], error = 'Failed to list shares: Unable to read from Server Service RPC endpoint')
def rpcReadCB(read_message, **kwargs):
messages_history.append(read_message)
if read_message.status == 0:
call_id = self._getNextRPCCallID()
padding = ''
remote_name = '\\\\' + self.remote_name
server_len = len(remote_name) + 1
server_bytes_len = server_len * 2
if server_len % 2 != 0:
padding = '\0\0'
server_bytes_len += 2
# The data bytes are the RPC call to NetrShareEnum (Opnum 15) at Server Service RPC.
# If you wish to understand the meanings of the byte stream, I would suggest you use a recent version of WireShark to packet capture the stream
data_bytes = \
binascii.unhexlify("""05 00 00 03 10 00 00 00""".replace(' ', '')) + \
struct.pack('<HHI', 72+server_bytes_len, 0, call_id) + \
binascii.unhexlify("""4c 00 00 00 00 00 0f 00 00 00 02 00""".replace(' ', '')) + \
struct.pack('<III', server_len, 0, server_len) + \
(remote_name + '\0').encode('UTF-16LE') + padding + \
binascii.unhexlify("""
01 00 00 00 01 00 00 00 04 00 02 00 00 00 00 00
00 00 00 00 ff ff ff ff 08 00 02 00 00 00 00 00
""".replace(' ', '').replace('\n', ''))
m = SMB2Message(SMB2IoctlRequest(kwargs['fid'], 0x0011C017, flags = 0x01, max_out_size = 8196, in_data = data_bytes))
m.tid = read_message.tid
self._sendSMBMessage(m)
self.pending_requests[m.mid] = _PendingRequest(m.mid, expiry_time, listShareResultsCB, errback, fid = kwargs['fid'])
messages_history.append(m)
else:
closeFid(read_message.tid, kwargs['fid'], error = 'Failed to list shares: Unable to bind to Server Service RPC endpoint')
def listShareResultsCB(result_message, **kwargs):
messages_history.append(result_message)
if result_message.status == 0:
# The payload.data_bytes will contain the results of the RPC call to NetrShareEnum (Opnum 15) at Server Service RPC.
data_bytes = result_message.payload.out_data
if ord(data_bytes[3]) & 0x02 == 0:
sendReadRequest(result_message.tid, kwargs['fid'], data_bytes)
else:
decodeResults(result_message.tid, kwargs['fid'], data_bytes)
elif result_message.status == 0x0103: # STATUS_PENDING
self.pending_requests[result_message.mid] = _PendingRequest(result_message.mid, expiry_time, listShareResultsCB, errback, fid = kwargs['fid'])
else:
closeFid(result_message.tid, kwargs['fid'])
errback(OperationFailure('Failed to list shares: Unable to retrieve shared device list', messages_history))
def decodeResults(tid, fid, data_bytes):
shares_count = struct.unpack('<I', data_bytes[36:40])[0]
results = [ ] # A list of SharedDevice instances
offset = 36 + 12 # You need to study the byte stream to understand the meaning of these constants
for i in range(0, shares_count):
results.append(SharedDevice(struct.unpack('<I', data_bytes[offset+4:offset+8])[0], None, None))
offset += 12
for i in range(0, shares_count):
max_length, _, length = struct.unpack('<III', data_bytes[offset:offset+12])
offset += 12
results[i].name = unicode(data_bytes[offset:offset+length*2-2], 'UTF-16LE')
if length % 2 != 0:
offset += (length * 2 + 2)
else:
offset += (length * 2)
max_length, _, length = struct.unpack('<III', data_bytes[offset:offset+12])
offset += 12
results[i].comments = unicode(data_bytes[offset:offset+length*2-2], 'UTF-16LE')
if length % 2 != 0:
offset += (length * 2 + 2)
else:
offset += (length * 2)
closeFid(tid, fid)
callback(results)
def sendReadRequest(tid, fid, data_bytes):
read_count = min(4280, self.max_read_size)
m = SMB2Message(SMB2ReadRequest(fid, 0, read_count))
m.tid = tid
self._sendSMBMessage(m)
self.pending_requests[m.mid] = _PendingRequest(m.mid, int(time.time()) + timeout, readCB, errback,
fid = fid, data_bytes = data_bytes)
def readCB(read_message, **kwargs):
messages_history.append(read_message)
if read_message.status == 0:
data_len = read_message.payload.data_length
data_bytes = read_message.payload.data
if ord(data_bytes[3]) & 0x02 == 0:
sendReadRequest(read_message.tid, kwargs['fid'], kwargs['data_bytes'] + data_bytes[24:data_len-24])
else:
decodeResults(read_message.tid, kwargs['fid'], kwargs['data_bytes'] + data_bytes[24:data_len-24])
else:
closeFid(read_message.tid, kwargs['fid'])
errback(OperationFailure('Failed to list shares: Unable to retrieve shared device list', messages_history))
def closeFid(tid, fid, results = None, error = None):
m = SMB2Message(SMB2CloseRequest(fid))
m.tid = tid
self._sendSMBMessage(m)
self.pending_requests[m.mid] = _PendingRequest(m.mid, expiry_time, closeCB, errback, results = results, error = error)
messages_history.append(m)
def closeCB(close_message, **kwargs):
if kwargs['results'] is not None:
callback(kwargs['results'])
elif kwargs['error'] is not None:
errback(OperationFailure(kwargs['error'], messages_history))
if not self.connected_trees.has_key(path):
def connectCB(connect_message, **kwargs):
messages_history.append(connect_message)
if connect_message.status == 0:
self.connected_trees[path] = connect_message.tid
connectSrvSvc(connect_message.tid)
else:
errback(OperationFailure('Failed to list shares: Unable to connect to IPC$', messages_history))
m = SMB2Message(SMB2TreeConnectRequest(r'\\%s\%s' % ( self.remote_name.upper(), path )))
self._sendSMBMessage(m)
self.pending_requests[m.mid] = _PendingRequest(m.mid, expiry_time, connectCB, errback, path = path)
messages_history.append(m)
else:
connectSrvSvc(self.connected_trees[path])
def _listPath_SMB2(self, service_name, path, callback, errback, search, pattern, timeout = 30):
if not self.has_authenticated:
raise NotReadyError('SMB connection not authenticated')
expiry_time = time.time() + timeout
path = path.replace('/', '\\')
if path.startswith('\\'):
path = path[1:]
if path.endswith('\\'):
path = path[:-1]
messages_history = [ ]
results = [ ]
def sendCreate(tid):
create_context_data = binascii.unhexlify("""
28 00 00 00 10 00 04 00 00 00 18 00 10 00 00 00
44 48 6e 51 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 18 00 00 00 10 00 04 00
00 00 18 00 00 00 00 00 4d 78 41 63 00 00 00 00
00 00 00 00 10 00 04 00 00 00 18 00 00 00 00 00
51 46 69 64 00 00 00 00
""".replace(' ', '').replace('\n', ''))
m = SMB2Message(SMB2CreateRequest(path,
file_attributes = 0,
access_mask = FILE_READ_DATA | FILE_READ_EA | FILE_READ_ATTRIBUTES | SYNCHRONIZE,
share_access = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
oplock = SMB2_OPLOCK_LEVEL_NONE,
impersonation = SEC_IMPERSONATE,
create_options = FILE_DIRECTORY_FILE,
create_disp = FILE_OPEN,
create_context_data = create_context_data))
m.tid = tid
self._sendSMBMessage(m)
self.pending_requests[m.mid] = _PendingRequest(m.mid, expiry_time, createCB, errback)
messages_history.append(m)
def createCB(create_message, **kwargs):
messages_history.append(create_message)
if create_message.status == 0:
sendQuery(create_message.tid, create_message.payload.fid, '')
else:
errback(OperationFailure('Failed to list %s on %s: Unable to open directory' % ( path, service_name ), messages_history))
def sendQuery(tid, fid, data_buf):
m = SMB2Message(SMB2QueryDirectoryRequest(fid, pattern,
info_class = 0x03, # FileBothDirectoryInformation
flags = 0,
output_buf_len = self.max_transact_size))
m.tid = tid
self._sendSMBMessage(m)
self.pending_requests[m.mid] = _PendingRequest(m.mid, expiry_time, queryCB, errback, fid = fid, data_buf = data_buf)
messages_history.append(m)
def queryCB(query_message, **kwargs):
messages_history.append(query_message)
if query_message.status == 0:
data_buf = decodeQueryStruct(kwargs['data_buf'] + query_message.payload.data)
sendQuery(query_message.tid, kwargs['fid'], data_buf)
elif query_message.status == 0x80000006L: # STATUS_NO_MORE_FILES
closeFid(query_message.tid, kwargs['fid'], results = results)
else:
closeFid(query_message.tid, kwargs['fid'], error = query_message.status)
def decodeQueryStruct(data_bytes):
# SMB_FIND_FILE_BOTH_DIRECTORY_INFO structure. See [MS-CIFS]: 2.2.8.1.7 and [MS-SMB]: 2.2.8.1.1
info_format = '<IIQQQQQQIIIBB24s'
info_size = struct.calcsize(info_format)
data_length = len(data_bytes)
offset = 0
while offset < data_length:
if offset + info_size > data_length:
return data_bytes[offset:]
next_offset, _, \
create_time, last_access_time, last_write_time, last_attr_change_time, \
file_size, alloc_size, file_attributes, filename_length, ea_size, \
short_name_length, _, short_name = struct.unpack(info_format, data_bytes[offset:offset+info_size])
offset2 = offset + info_size
if offset2 + filename_length > data_length:
return data_bytes[offset:]
filename = data_bytes[offset2:offset2+filename_length].decode('UTF-16LE')
short_name = short_name.decode('UTF-16LE')
results.append(SharedFile(convertFILETIMEtoEpoch(create_time), convertFILETIMEtoEpoch(last_access_time),
convertFILETIMEtoEpoch(last_write_time), convertFILETIMEtoEpoch(last_attr_change_time),
file_size, alloc_size, file_attributes, short_name, filename))
if next_offset:
offset += next_offset
else:
break
return ''
def closeFid(tid, fid, results = None, error = None):
m = SMB2Message(SMB2CloseRequest(fid))
m.tid = tid
self._sendSMBMessage(m)
self.pending_requests[m.mid] = _PendingRequest(m.mid, expiry_time, closeCB, errback, results = results, error = error)
messages_history.append(m)
def closeCB(close_message, **kwargs):
if kwargs['results'] is not None:
callback(kwargs['results'])
elif kwargs['error'] is not None:
errback(OperationFailure('Failed to list %s on %s: Query failed with errorcode 0x%08x' % ( path, service_name, kwargs['error'] ), messages_history))
if not self.connected_trees.has_key(service_name):
def connectCB(connect_message, **kwargs):
messages_history.append(connect_message)
if connect_message.status == 0:
self.connected_trees[service_name] = connect_message.tid
sendCreate(connect_message.tid)
else:
errback(OperationFailure('Failed to list %s on %s: Unable to connect to shared device' % ( path, service_name ), messages_history))
m = SMB2Message(SMB2TreeConnectRequest(r'\\%s\%s' % ( self.remote_name.upper(), service_name )))
self._sendSMBMessage(m)
self.pending_requests[m.mid] = _PendingRequest(m.mid, expiry_time, connectCB, errback, path = service_name)
messages_history.append(m)
else:
sendCreate(self.connected_trees[service_name])
def _getAttributes_SMB2(self, service_name, path, callback, errback, timeout = 30):
if not self.has_authenticated:
raise NotReadyError('SMB connection not authenticated')
expiry_time = time.time() + timeout
path = path.replace('/', '\\')
if path.startswith('\\'):
path = path[1:]
if path.endswith('\\'):
path = path[:-1]
messages_history = [ ]
def sendCreate(tid):
create_context_data = binascii.unhexlify("""
28 00 00 00 10 00 04 00 00 00 18 00 10 00 00 00
44 48 6e 51 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 18 00 00 00 10 00 04 00
00 00 18 00 00 00 00 00 4d 78 41 63 00 00 00 00
00 00 00 00 10 00 04 00 00 00 18 00 00 00 00 00
51 46 69 64 00 00 00 00
""".replace(' ', '').replace('\n', ''))
m = SMB2Message(SMB2CreateRequest(path,
file_attributes = 0,
access_mask = FILE_READ_DATA | FILE_READ_EA | FILE_READ_ATTRIBUTES | SYNCHRONIZE,
share_access = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
oplock = SMB2_OPLOCK_LEVEL_NONE,
impersonation = SEC_IMPERSONATE,
create_options = 0,
create_disp = FILE_OPEN,
create_context_data = create_context_data))
m.tid = tid
self._sendSMBMessage(m)
self.pending_requests[m.mid] = _PendingRequest(m.mid, expiry_time, createCB, errback)
messages_history.append(m)
def createCB(create_message, **kwargs):
messages_history.append(create_message)
if create_message.status == 0:
p = create_message.payload
info = SharedFile(p.create_time, p.lastaccess_time, p.lastwrite_time, p.change_time,
p.file_size, p.allocation_size, p.file_attributes,
unicode(path), unicode(path))
closeFid(create_message.tid, p.fid, info = info)
else:
errback(OperationFailure('Failed to get attributes for %s on %s: Unable to open remote file object' % ( path, service_name ), messages_history))
def closeFid(tid, fid, info = None, error = None):
m = SMB2Message(SMB2CloseRequest(fid))
m.tid = tid
self._sendSMBMessage(m)
self.pending_requests[m.mid] = _PendingRequest(m.mid, expiry_time, closeCB, errback, info = info, error = error)
messages_history.append(m)
def closeCB(close_message, **kwargs):
if kwargs['info'] is not None:
callback(kwargs['info'])
elif kwargs['error'] is not None:
errback(OperationFailure('Failed to get attributes for %s on %s: Query failed with errorcode 0x%08x' % ( path, service_name, kwargs['error'] ), messages_history))
if not self.connected_trees.has_key(service_name):
def connectCB(connect_message, **kwargs):
messages_history.append(connect_message)
if connect_message.status == 0:
self.connected_trees[service_name] = connect_message.tid
sendCreate(connect_message.tid)
else:
errback(OperationFailure('Failed to get attributes for %s on %s: Unable to connect to shared device' % ( path, service_name ), messages_history))
m = SMB2Message(SMB2TreeConnectRequest(r'\\%s\%s' % ( self.remote_name.upper(), service_name )))
self._sendSMBMessage(m)
self.pending_requests[m.mid] = _PendingRequest(m.mid, expiry_time, connectCB, errback, path = service_name)
messages_history.append(m)
else:
sendCreate(self.connected_trees[service_name])
def _retrieveFile_SMB2(self, service_name, path, file_obj, callback, errback, timeout = 30):
return self._retrieveFileFromOffset(service_name, path, file_obj, callback, errback, 0L, -1L, timeout)
def _retrieveFileFromOffset_SMB2(self, service_name, path, file_obj, callback, errback, starting_offset, max_length, timeout = 30):
if not self.has_authenticated:
raise NotReadyError('SMB connection not authenticated')
expiry_time = time.time() + timeout
path = path.replace('/', '\\')
if path.startswith('\\'):
path = path[1:]
if path.endswith('\\'):
path = path[:-1]
messages_history = [ ]
results = [ ]
def sendCreate(tid):
create_context_data = binascii.unhexlify("""
28 00 00 00 10 00 04 00 00 00 18 00 10 00 00 00
44 48 6e 51 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 18 00 00 00 10 00 04 00
00 00 18 00 00 00 00 00 4d 78 41 63 00 00 00 00
00 00 00 00 10 00 04 00 00 00 18 00 00 00 00 00
51 46 69 64 00 00 00 00
""".replace(' ', '').replace('\n', ''))
m = SMB2Message(SMB2CreateRequest(path,
file_attributes = 0,
access_mask = FILE_READ_DATA | FILE_READ_EA | FILE_READ_ATTRIBUTES | READ_CONTROL | SYNCHRONIZE,
share_access = FILE_SHARE_READ,
oplock = SMB2_OPLOCK_LEVEL_NONE,
impersonation = SEC_IMPERSONATE,
create_options = FILE_SEQUENTIAL_ONLY | FILE_NON_DIRECTORY_FILE,
create_disp = FILE_OPEN,
create_context_data = create_context_data))
m.tid = tid
self._sendSMBMessage(m)
self.pending_requests[m.mid] = _PendingRequest(m.mid, expiry_time, createCB, errback, tid = tid)
messages_history.append(m)
def createCB(create_message, **kwargs):
messages_history.append(create_message)
if create_message.status == 0:
m = SMB2Message(SMB2QueryInfoRequest(create_message.payload.fid,
flags = 0,
additional_info = 0,
info_type = SMB2_INFO_FILE,
file_info_class = 0x16, # FileStreamInformation [MS-FSCC] 2.4
input_buf = '',
output_buf_len = 4096))
m.tid = create_message.tid
self._sendSMBMessage(m)
self.pending_requests[m.mid] = _PendingRequest(m.mid, expiry_time, infoCB, errback,
fid = create_message.payload.fid, file_attributes = create_message.payload.file_attributes)
messages_history.append(m)
else:
errback(OperationFailure('Failed to list %s on %s: Unable to open file' % ( path, service_name ), messages_history))
def infoCB(info_message, **kwargs):
messages_history.append(info_message)
if info_message.status == 0:
file_len = struct.unpack('<Q', info_message.payload.data[8:16])[0]
if max_length == 0 or starting_offset > file_len:
closeFid(info_message.tid, kwargs['fid'])
callback(( file_obj, kwargs['file_attributes'], 0 )) # Note that this is a tuple of 3-elements
else:
remaining_len = max_length
if remaining_len < 0:
remaining_len = file_len
if starting_offset + remaining_len > file_len:
remaining_len = file_len - starting_offset
sendRead(info_message.tid, kwargs['fid'], starting_offset, remaining_len, 0, kwargs['file_attributes'])
else:
errback(OperationFailure('Failed to list %s on %s: Unable to retrieve information on file' % ( path, service_name ), messages_history))
def sendRead(tid, fid, offset, remaining_len, read_len, file_attributes):
read_count = min(self.max_read_size, remaining_len)
m = SMB2Message(SMB2ReadRequest(fid, offset, read_count))
m.tid = tid
self._sendSMBMessage(m)
self.pending_requests[m.mid] = _PendingRequest(m.mid, int(time.time()) + timeout, readCB, errback,
fid = fid, offset = offset,
remaining_len = remaining_len,
read_len = read_len,
file_attributes = file_attributes)
def readCB(read_message, **kwargs):
# To avoid crazy memory usage when retrieving large files, we do not save every read_message in messages_history.
if read_message.status == 0:
data_len = read_message.payload.data_length
file_obj.write(read_message.payload.data)
remaining_len = kwargs['remaining_len'] - data_len
if remaining_len > 0:
sendRead(read_message.tid, kwargs['fid'], kwargs['offset'] + data_len, remaining_len, kwargs['read_len'] + data_len, kwargs['file_attributes'])
else:
closeFid(read_message.tid, kwargs['fid'], ret = ( file_obj, kwargs['file_attributes'], kwargs['read_len'] + data_len ))
else:
messages_history.append(read_message)
closeFid(read_message.tid, kwargs['fid'], error = read_message.status)
def closeFid(tid, fid, ret = None, error = None):
m = SMB2Message(SMB2CloseRequest(fid))
m.tid = tid
self._sendSMBMessage(m)
self.pending_requests[m.mid] = _PendingRequest(m.mid, expiry_time, closeCB, errback, ret = ret, error = error)
messages_history.append(m)
def closeCB(close_message, **kwargs):
if kwargs['ret'] is not None:
callback(kwargs['ret'])
elif kwargs['error'] is not None:
errback(OperationFailure('Failed to retrieve %s on %s: Read failed' % ( path, service_name ), messages_history))
if not self.connected_trees.has_key(service_name):
def connectCB(connect_message, **kwargs):
messages_history.append(connect_message)
if connect_message.status == 0:
self.connected_trees[service_name] = connect_message.tid
sendCreate(connect_message.tid)
else:
errback(OperationFailure('Failed to retrieve %s on %s: Unable to connect to shared device' % ( path, service_name ), messages_history))
m = SMB2Message(SMB2TreeConnectRequest(r'\\%s\%s' % ( self.remote_name.upper(), service_name )))
self._sendSMBMessage(m)
self.pending_requests[m.mid] = _PendingRequest(m.mid, expiry_time, connectCB, errback, path = service_name)
messages_history.append(m)
else:
sendCreate(self.connected_trees[service_name])
def _storeFile_SMB2(self, service_name, path, file_obj, callback, errback, timeout = 30):
self._storeFileFromOffset_SMB2(service_name, path, file_obj, callback, errback, 0L, True, timeout)
def _storeFileFromOffset_SMB2(self, service_name, path, file_obj, callback, errback, starting_offset, truncate = False, timeout = 30):
if not self.has_authenticated:
raise NotReadyError('SMB connection not authenticated')
path = path.replace('/', '\\')
if path.startswith('\\'):
path = path[1:]
if path.endswith('\\'):
path = path[:-1]
messages_history = [ ]
def sendCreate(tid):
create_context_data = binascii.unhexlify("""
28 00 00 00 10 00 04 00 00 00 18 00 10 00 00 00
44 48 6e 51 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 20 00 00 00 10 00 04 00
00 00 18 00 08 00 00 00 41 6c 53 69 00 00 00 00
85 62 00 00 00 00 00 00 18 00 00 00 10 00 04 00
00 00 18 00 00 00 00 00 4d 78 41 63 00 00 00 00
00 00 00 00 10 00 04 00 00 00 18 00 00 00 00 00
51 46 69 64 00 00 00 00
""".replace(' ', '').replace('\n', ''))
m = SMB2Message(SMB2CreateRequest(path,
file_attributes = ATTR_ARCHIVE,
access_mask = FILE_READ_DATA | FILE_WRITE_DATA | FILE_APPEND_DATA | FILE_READ_ATTRIBUTES | FILE_WRITE_ATTRIBUTES | FILE_READ_EA | FILE_WRITE_EA | READ_CONTROL | SYNCHRONIZE,
share_access = 0,
oplock = SMB2_OPLOCK_LEVEL_NONE,
impersonation = SEC_IMPERSONATE,
create_options = FILE_SEQUENTIAL_ONLY | FILE_NON_DIRECTORY_FILE,
create_disp = FILE_OVERWRITE_IF if truncate else FILE_OPEN_IF,
create_context_data = create_context_data))
m.tid = tid
self._sendSMBMessage(m)
self.pending_requests[m.mid] = _PendingRequest(m.mid, int(time.time()) + timeout, createCB, errback, tid = tid)
messages_history.append(m)
def createCB(create_message, **kwargs):
messages_history.append(create_message)
if create_message.status == 0:
sendWrite(create_message.tid, create_message.payload.fid, starting_offset)
else:
errback(OperationFailure('Failed to store %s on %s: Unable to open file' % ( path, service_name ), messages_history))
def sendWrite(tid, fid, offset):
write_count = self.max_write_size
data = file_obj.read(write_count)
data_len = len(data)
if data_len > 0:
m = SMB2Message(SMB2WriteRequest(fid, data, offset))
m.tid = tid
self._sendSMBMessage(m)
self.pending_requests[m.mid] = _PendingRequest(m.mid, int(time.time()) + timeout, writeCB, errback, fid = fid, offset = offset+data_len)
else:
closeFid(tid, fid, offset = offset)
def writeCB(write_message, **kwargs):
# To avoid crazy memory usage when saving large files, we do not save every write_message in messages_history.
if write_message.status == 0:
sendWrite(write_message.tid, kwargs['fid'], kwargs['offset'])
else:
messages_history.append(write_message)
closeFid(write_message.tid, kwargs['fid'])
errback(OperationFailure('Failed to store %s on %s: Write failed' % ( path, service_name ), messages_history))
def closeFid(tid, fid, error = None, offset = None):
m = SMB2Message(SMB2CloseRequest(fid))
m.tid = tid
self._sendSMBMessage(m)
self.pending_requests[m.mid] = _PendingRequest(m.mid, int(time.time()) + timeout, closeCB, errback, fid = fid, offset = offset, error = error)
messages_history.append(m)
def closeCB(close_message, **kwargs):
if kwargs['offset'] is not None:
callback(( file_obj, kwargs['offset'] )) # Note that this is a tuple of 2-elements
elif kwargs['error'] is not None:
errback(OperationFailure('Failed to store %s on %s: Write failed' % ( path, service_name ), messages_history))
if not self.connected_trees.has_key(service_name):
def connectCB(connect_message, **kwargs):
messages_history.append(connect_message)
if connect_message.status == 0:
self.connected_trees[service_name] = connect_message.tid
sendCreate(connect_message.tid)
else:
errback(OperationFailure('Failed to store %s on %s: Unable to connect to shared device' % ( path, service_name ), messages_history))
m = SMB2Message(SMB2TreeConnectRequest(r'\\%s\%s' % ( self.remote_name.upper(), service_name )))
self._sendSMBMessage(m)
self.pending_requests[m.mid] = _PendingRequest(m.mid, int(time.time()) + timeout, connectCB, errback, path = service_name)
messages_history.append(m)
else:
sendCreate(self.connected_trees[service_name])
def _deleteFiles_SMB2(self, service_name, path_file_pattern, callback, errback, timeout = 30):
if not self.has_authenticated:
raise NotReadyError('SMB connection not authenticated')
expiry_time = time.time() + timeout
path = path_file_pattern.replace('/', '\\')
if path.startswith('\\'):
path = path[1:]
if path.endswith('\\'):
path = path[:-1]
messages_history = [ ]
def sendCreate(tid):
create_context_data = binascii.unhexlify("""
28 00 00 00 10 00 04 00 00 00 18 00 10 00 00 00
44 48 6e 51 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 18 00 00 00 10 00 04 00
00 00 18 00 00 00 00 00 4d 78 41 63 00 00 00 00
00 00 00 00 10 00 04 00 00 00 18 00 00 00 00 00
51 46 69 64 00 00 00 00
""".replace(' ', '').replace('\n', ''))
m = SMB2Message(SMB2CreateRequest(path,
file_attributes = 0,
access_mask = DELETE | FILE_READ_ATTRIBUTES,
share_access = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
oplock = SMB2_OPLOCK_LEVEL_NONE,
impersonation = SEC_IMPERSONATE,
create_options = FILE_NON_DIRECTORY_FILE,
create_disp = FILE_OPEN,
create_context_data = create_context_data))
m.tid = tid
self._sendSMBMessage(m)
self.pending_requests[m.mid] = _PendingRequest(m.mid, int(time.time()) + timeout, createCB, errback, tid = tid)
messages_history.append(m)
def createCB(open_message, **kwargs):
messages_history.append(open_message)
if open_message.status == 0:
sendDelete(open_message.tid, open_message.payload.fid)
else:
errback(OperationFailure('Failed to delete %s on %s: Unable to open file' % ( path, service_name ), messages_history))
def sendDelete(tid, fid):
m = SMB2Message(SMB2SetInfoRequest(fid,
additional_info = 0,
info_type = SMB2_INFO_FILE,
file_info_class = 0x0d, # SMB2_FILE_DISPOSITION_INFO
data = '\x01'))
'''
Resources:
https://msdn.microsoft.com/en-us/library/cc246560.aspx
https://msdn.microsoft.com/en-us/library/cc232098.aspx
'''
m.tid = tid
self._sendSMBMessage(m)
self.pending_requests[m.mid] = _PendingRequest(m.mid, int(time.time()) + timeout, deleteCB, errback, fid = fid)
messages_history.append(m)
def deleteCB(delete_message, **kwargs):
messages_history.append(delete_message)
if delete_message.status == 0:
closeFid(delete_message.tid, kwargs['fid'], status = 0)
else:
closeFid(delete_message.tid, kwargs['fid'], status = delete_message.status)
def closeFid(tid, fid, status = None):
m = SMB2Message(SMB2CloseRequest(fid))
m.tid = tid
self._sendSMBMessage(m)
self.pending_requests[m.mid] = _PendingRequest(m.mid, int(time.time()) + timeout, closeCB, errback, status = status)
messages_history.append(m)
def closeCB(close_message, **kwargs):
if kwargs['status'] == 0:
callback(path_file_pattern)
else:
errback(OperationFailure('Failed to delete %s on %s: Delete failed' % ( path, service_name ), messages_history))
if not self.connected_trees.has_key(service_name):
def connectCB(connect_message, **kwargs):
messages_history.append(connect_message)
if connect_message.status == 0:
self.connected_trees[service_name] = connect_message.tid
sendCreate(connect_message.tid)
else:
errback(OperationFailure('Failed to delete %s on %s: Unable to connect to shared device' % ( path, service_name ), messages_history))
m = SMB2Message(SMB2TreeConnectRequest(r'\\%s\%s' % ( self.remote_name.upper(), service_name )))
self._sendSMBMessage(m)
self.pending_requests[m.mid] = _PendingRequest(m.mid, expiry_time, connectCB, errback, path = service_name)
messages_history.append(m)
else:
sendCreate(self.connected_trees[service_name])
def _resetFileAttributes_SMB2(self, service_name, path_file_pattern, callback, errback, timeout = 30):
if not self.has_authenticated:
raise NotReadyError('SMB connection not authenticated')
expiry_time = time.time() + timeout
path = path_file_pattern.replace('/', '\\')
if path.startswith('\\'):
path = path[1:]
if path.endswith('\\'):
path = path[:-1]
messages_history = [ ]
def sendCreate(tid):
create_context_data = binascii.unhexlify("""
28 00 00 00 10 00 04 00 00 00 18 00 10 00 00 00
44 48 6e 51 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 18 00 00 00 10 00 04 00
00 00 18 00 00 00 00 00 4d 78 41 63 00 00 00 00
00 00 00 00 10 00 04 00 00 00 18 00 00 00 00 00
51 46 69 64 00 00 00 00
""".replace(' ', '').replace('\n', ''))
m = SMB2Message(SMB2CreateRequest(path,
file_attributes = 0,
access_mask = FILE_WRITE_ATTRIBUTES,
share_access = FILE_SHARE_READ | FILE_SHARE_WRITE,
oplock = SMB2_OPLOCK_LEVEL_NONE,
impersonation = SEC_IMPERSONATE,
create_options = 0,
create_disp = FILE_OPEN,
create_context_data = create_context_data))
m.tid = tid
self._sendSMBMessage(m)
self.pending_requests[m.mid] = _PendingRequest(m.mid, int(time.time()) + timeout, createCB, errback, tid = tid)
messages_history.append(m)
def createCB(open_message, **kwargs):
messages_history.append(open_message)
if open_message.status == 0:
sendReset(open_message.tid, open_message.payload.fid)
else:
errback(OperationFailure('Failed to reset attributes of %s on %s: Unable to open file' % ( path, service_name ), messages_history))
def sendReset(tid, fid):
m = SMB2Message(SMB2SetInfoRequest(fid,
additional_info = 0,
info_type = SMB2_INFO_FILE,
file_info_class = 4, # FileBasicInformation
data = struct.pack('qqqqii',0,0,0,0,0x80,0))) # FILE_ATTRIBUTE_NORMAL
'''
Resources:
https://msdn.microsoft.com/en-us/library/cc246560.aspx
https://msdn.microsoft.com/en-us/library/cc232064.aspx
https://msdn.microsoft.com/en-us/library/cc232094.aspx
https://msdn.microsoft.com/en-us/library/cc232110.aspx
'''
m.tid = tid
self._sendSMBMessage(m)
self.pending_requests[m.mid] = _PendingRequest(m.mid, int(time.time()) + timeout, resetCB, errback, fid = fid)
messages_history.append(m)
def resetCB(reset_message, **kwargs):
messages_history.append(reset_message)
if reset_message.status == 0:
closeFid(reset_message.tid, kwargs['fid'], status = 0)
else:
closeFid(reset_message.tid, kwargs['fid'], status = reset_message.status)
def closeFid(tid, fid, status = None):
m = SMB2Message(SMB2CloseRequest(fid))
m.tid = tid
self._sendSMBMessage(m)
self.pending_requests[m.mid] = _PendingRequest(m.mid, int(time.time()) + timeout, closeCB, errback, status = status)
messages_history.append(m)
def closeCB(close_message, **kwargs):
if kwargs['status'] == 0:
callback(path_file_pattern)
else:
errback(OperationFailure('Failed to reset attributes of %s on %s: Reset failed' % ( path, service_name ), messages_history))
if not self.connected_trees.has_key(service_name):
def connectCB(connect_message, **kwargs):
messages_history.append(connect_message)
if connect_message.status == 0:
self.connected_trees[service_name] = connect_message.tid
sendCreate(connect_message.tid)
else:
errback(OperationFailure('Failed to reset attributes of %s on %s: Unable to connect to shared device' % ( path, service_name ), messages_history))
m = SMB2Message(SMB2TreeConnectRequest(r'\\%s\%s' % ( self.remote_name.upper(), service_name )))
self._sendSMBMessage(m)
self.pending_requests[m.mid] = _PendingRequest(m.mid, expiry_time, connectCB, errback, path = service_name)
messages_history.append(m)
else:
sendCreate(self.connected_trees[service_name])
def _createDirectory_SMB2(self, service_name, path, callback, errback, timeout = 30):
if not self.has_authenticated:
raise NotReadyError('SMB connection not authenticated')
expiry_time = time.time() + timeout
path = path.replace('/', '\\')
if path.startswith('\\'):
path = path[1:]
if path.endswith('\\'):
path = path[:-1]
messages_history = [ ]
def sendCreate(tid):
create_context_data = binascii.unhexlify("""
28 00 00 00 10 00 04 00 00 00 18 00 10 00 00 00
44 48 6e 51 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 18 00 00 00 10 00 04 00
00 00 18 00 00 00 00 00 4d 78 41 63 00 00 00 00
00 00 00 00 10 00 04 00 00 00 18 00 00 00 00 00
51 46 69 64 00 00 00 00
""".replace(' ', '').replace('\n', ''))
m = SMB2Message(SMB2CreateRequest(path,
file_attributes = 0,
access_mask = FILE_READ_DATA | FILE_WRITE_DATA | FILE_READ_EA | FILE_WRITE_EA | FILE_READ_ATTRIBUTES | FILE_WRITE_ATTRIBUTES | READ_CONTROL | DELETE | SYNCHRONIZE,
share_access = 0,
oplock = SMB2_OPLOCK_LEVEL_NONE,
impersonation = SEC_IMPERSONATE,
create_options = FILE_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT,
create_disp = FILE_CREATE,
create_context_data = create_context_data))
m.tid = tid
self._sendSMBMessage(m)
self.pending_requests[m.mid] = _PendingRequest(m.mid, int(time.time()) + timeout, createCB, errback)
messages_history.append(m)
def createCB(create_message, **kwargs):
messages_history.append(create_message)
if create_message.status == 0:
closeFid(create_message.tid, create_message.payload.fid)
else:
errback(OperationFailure('Failed to create directory %s on %s: Create failed' % ( path, service_name ), messages_history))
def closeFid(tid, fid):
m = SMB2Message(SMB2CloseRequest(fid))
m.tid = tid
self._sendSMBMessage(m)
self.pending_requests[m.mid] = _PendingRequest(m.mid, int(time.time()) + timeout, closeCB, errback)
messages_history.append(m)
def closeCB(close_message, **kwargs):
callback(path)
if not self.connected_trees.has_key(service_name):
def connectCB(connect_message, **kwargs):
messages_history.append(connect_message)
if connect_message.status == 0:
self.connected_trees[service_name] = connect_message.tid
sendCreate(connect_message.tid)
else:
errback(OperationFailure('Failed to create directory %s on %s: Unable to connect to shared device' % ( path, service_name ), messages_history))
m = SMB2Message(SMB2TreeConnectRequest(r'\\%s\%s' % ( self.remote_name.upper(), service_name )))
self._sendSMBMessage(m)
self.pending_requests[m.mid] = _PendingRequest(m.mid, expiry_time, connectCB, errback, path = service_name)
messages_history.append(m)
else:
sendCreate(self.connected_trees[service_name])
def _deleteDirectory_SMB2(self, service_name, path, callback, errback, timeout = 30):
if not self.has_authenticated:
raise NotReadyError('SMB connection not authenticated')
expiry_time = time.time() + timeout
path = path.replace('/', '\\')
if path.startswith('\\'):
path = path[1:]
if path.endswith('\\'):
path = path[:-1]
messages_history = [ ]
def sendCreate(tid):
create_context_data = binascii.unhexlify("""
28 00 00 00 10 00 04 00 00 00 18 00 10 00 00 00
44 48 6e 51 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 18 00 00 00 10 00 04 00
00 00 18 00 00 00 00 00 4d 78 41 63 00 00 00 00
00 00 00 00 10 00 04 00 00 00 18 00 00 00 00 00
51 46 69 64 00 00 00 00
""".replace(' ', '').replace('\n', ''))
m = SMB2Message(SMB2CreateRequest(path,
file_attributes = 0,
access_mask = DELETE | FILE_READ_ATTRIBUTES,
share_access = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
oplock = SMB2_OPLOCK_LEVEL_NONE,
impersonation = SEC_IMPERSONATE,
create_options = FILE_DIRECTORY_FILE,
create_disp = FILE_OPEN,
create_context_data = create_context_data))
m.tid = tid
self._sendSMBMessage(m)
self.pending_requests[m.mid] = _PendingRequest(m.mid, int(time.time()) + timeout, createCB, errback, tid = tid)
messages_history.append(m)
def createCB(open_message, **kwargs):
messages_history.append(open_message)
if open_message.status == 0:
sendDelete(open_message.tid, open_message.payload.fid)
else:
errback(OperationFailure('Failed to delete %s on %s: Unable to open directory' % ( path, service_name ), messages_history))
def sendDelete(tid, fid):
m = SMB2Message(SMB2SetInfoRequest(fid,
additional_info = 0,
info_type = SMB2_INFO_FILE,
file_info_class = 0x0d, # SMB2_FILE_DISPOSITION_INFO
data = '\x01'))
m.tid = tid
self._sendSMBMessage(m)
self.pending_requests[m.mid] = _PendingRequest(m.mid, int(time.time()) + timeout, deleteCB, errback, fid = fid)
messages_history.append(m)
def deleteCB(delete_message, **kwargs):
messages_history.append(delete_message)
if delete_message.status == 0:
closeFid(delete_message.tid, kwargs['fid'], status = 0)
else:
closeFid(delete_message.tid, kwargs['fid'], status = delete_message.status)
def closeFid(tid, fid, status = None):
m = SMB2Message(SMB2CloseRequest(fid))
m.tid = tid
self._sendSMBMessage(m)
self.pending_requests[m.mid] = _PendingRequest(m.mid, expiry_time, closeCB, errback, status = status)
messages_history.append(m)
def closeCB(close_message, **kwargs):
if kwargs['status'] == 0:
callback(path)
else:
errback(OperationFailure('Failed to delete %s on %s: Delete failed' % ( path, service_name ), messages_history))
if not self.connected_trees.has_key(service_name):
def connectCB(connect_message, **kwargs):
messages_history.append(connect_message)
if connect_message.status == 0:
self.connected_trees[service_name] = connect_message.tid
sendCreate(connect_message.tid)
else:
errback(OperationFailure('Failed to delete %s on %s: Unable to connect to shared device' % ( path, service_name ), messages_history))
m = SMB2Message(SMB2TreeConnectRequest(r'\\%s\%s' % ( self.remote_name.upper(), service_name )))
self._sendSMBMessage(m)
self.pending_requests[m.mid] = _PendingRequest(m.mid, expiry_time, connectCB, errback, path = service_name)
messages_history.append(m)
else:
sendCreate(self.connected_trees[service_name])
def _rename_SMB2(self, service_name, old_path, new_path, callback, errback, timeout = 30):
if not self.has_authenticated:
raise NotReadyError('SMB connection not authenticated')
expiry_time = time.time() + timeout
messages_history = [ ]
new_path = new_path.replace('/', '\\')
if new_path.startswith('\\'):
new_path = new_path[1:]
if new_path.endswith('\\'):
new_path = new_path[:-1]
old_path = old_path.replace('/', '\\')
if old_path.startswith('\\'):
old_path = old_path[1:]
if old_path.endswith('\\'):
old_path = old_path[:-1]
def sendCreate(tid):
create_context_data = binascii.unhexlify("""
28 00 00 00 10 00 04 00 00 00 18 00 10 00 00 00
44 48 6e 51 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 18 00 00 00 10 00 04 00
00 00 18 00 00 00 00 00 4d 78 41 63 00 00 00 00
00 00 00 00 10 00 04 00 00 00 18 00 00 00 00 00
51 46 69 64 00 00 00 00
""".replace(' ', '').replace('\n', ''))
m = SMB2Message(SMB2CreateRequest(old_path,
file_attributes = 0,
access_mask = DELETE | FILE_READ_ATTRIBUTES | SYNCHRONIZE,
share_access = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
oplock = SMB2_OPLOCK_LEVEL_NONE,
impersonation = SEC_IMPERSONATE,
create_options = FILE_SYNCHRONOUS_IO_NONALERT,
create_disp = FILE_OPEN,
create_context_data = create_context_data))
m.tid = tid
self._sendSMBMessage(m)
self.pending_requests[m.mid] = _PendingRequest(m.mid, int(time.time()) + timeout, createCB, errback, tid = tid)
messages_history.append(m)
def createCB(create_message, **kwargs):
messages_history.append(create_message)
if create_message.status == 0:
sendRename(create_message.tid, create_message.payload.fid)
else:
errback(OperationFailure('Failed to rename %s on %s: Unable to open file/directory' % ( old_path, service_name ), messages_history))
def sendRename(tid, fid):
data = '\x00'*16 + struct.pack('<I', len(new_path)*2) + new_path.encode('UTF-16LE')
m = SMB2Message(SMB2SetInfoRequest(fid,
additional_info = 0,
info_type = SMB2_INFO_FILE,
file_info_class = 0x0a, # SMB2_FILE_RENAME_INFO
data = data))
m.tid = tid
self._sendSMBMessage(m)
self.pending_requests[m.mid] = _PendingRequest(m.mid, int(time.time()) + timeout, renameCB, errback, fid = fid)
messages_history.append(m)
def renameCB(rename_message, **kwargs):
messages_history.append(rename_message)
if rename_message.status == 0:
closeFid(rename_message.tid, kwargs['fid'], status = 0)
else:
closeFid(rename_message.tid, kwargs['fid'], status = rename_message.status)
def closeFid(tid, fid, status = None):
m = SMB2Message(SMB2CloseRequest(fid))
m.tid = tid
self._sendSMBMessage(m)
self.pending_requests[m.mid] = _PendingRequest(m.mid, expiry_time, closeCB, errback, status = status)
messages_history.append(m)
def closeCB(close_message, **kwargs):
if kwargs['status'] == 0:
callback(( old_path, new_path ))
else:
errback(OperationFailure('Failed to rename %s on %s: Rename failed' % ( old_path, service_name ), messages_history))
if not self.connected_trees.has_key(service_name):
def connectCB(connect_message, **kwargs):
messages_history.append(connect_message)
if connect_message.status == 0:
self.connected_trees[service_name] = connect_message.tid
sendCreate(connect_message.tid)
else:
errback(OperationFailure('Failed to rename %s on %s: Unable to connect to shared device' % ( old_path, service_name ), messages_history))
m = SMB2Message(SMB2TreeConnectRequest(r'\\%s\%s' % ( self.remote_name.upper(), service_name )))
self._sendSMBMessage(m)
self.pending_requests[m.mid] = _PendingRequest(m.mid, expiry_time, connectCB, errback, path = service_name)
messages_history.append(m)
else:
sendCreate(self.connected_trees[service_name])
def _listSnapshots_SMB2(self, service_name, path, callback, errback, timeout = 30):
if not self.has_authenticated:
raise NotReadyError('SMB connection not authenticated')
expiry_time = time.time() + timeout
path = path.replace('/', '\\')
if path.startswith('\\'):
path = path[1:]
if path.endswith('\\'):
path = path[:-1]
messages_history = [ ]
def sendCreate(tid):
create_context_data = binascii.unhexlify("""
28 00 00 00 10 00 04 00 00 00 18 00 10 00 00 00
44 48 6e 51 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 10 00 04 00
00 00 18 00 00 00 00 00 4d 78 41 63 00 00 00 00
""".replace(' ', '').replace('\n', ''))
m = SMB2Message(SMB2CreateRequest(path,
file_attributes = 0,
access_mask = FILE_READ_DATA | FILE_READ_ATTRIBUTES | SYNCHRONIZE,
share_access = FILE_SHARE_READ | FILE_SHARE_WRITE,
oplock = SMB2_OPLOCK_LEVEL_NONE,
impersonation = SEC_IMPERSONATE,
create_options = FILE_SYNCHRONOUS_IO_NONALERT,
create_disp = FILE_OPEN,
create_context_data = create_context_data))
m.tid = tid
self._sendSMBMessage(m)
self.pending_requests[m.mid] = _PendingRequest(m.mid, int(time.time()) + timeout, createCB, errback, tid = tid)
messages_history.append(m)
def createCB(create_message, **kwargs):
messages_history.append(create_message)
if create_message.status == 0:
sendEnumSnapshots(create_message.tid, create_message.payload.fid)
else:
errback(OperationFailure('Failed to list snapshots %s on %s: Unable to open file/directory' % ( old_path, service_name ), messages_history))
def sendEnumSnapshots(tid, fid):
m = SMB2Message(SMB2IoctlRequest(fid,
ctlcode = 0x00144064, # FSCTL_SRV_ENUMERATE_SNAPSHOTS
flags = 0x0001,
in_data = ''))
m.tid = tid
self._sendSMBMessage(m)
self.pending_requests[m.mid] = _PendingRequest(m.mid, int(time.time()) + timeout, enumSnapshotsCB, errback, tid = tid, fid = fid)
messages_history.append(m)
def enumSnapshotsCB(enum_message, **kwargs):
messages_history.append(enum_message)
if enum_message.status == 0:
results = [ ]
snapshots_count = struct.unpack('<I', enum_message.payload.out_data[4:8])[0]
for i in range(0, snapshots_count):
s = enum_message.payload.out_data[12+i*50:12+48+i*50].decode('UTF-16LE')
results.append(datetime(*map(int, ( s[5:9], s[10:12], s[13:15], s[16:18], s[19:21], s[22:24] ))))
closeFid(kwargs['tid'], kwargs['fid'], results = results)
else:
closeFid(kwargs['tid'], kwargs['fid'], status = enum_message.status)
def closeFid(tid, fid, status = None, results = None):
m = SMB2Message(SMB2CloseRequest(fid))
m.tid = tid
self._sendSMBMessage(m)
self.pending_requests[m.mid] = _PendingRequest(m.mid, expiry_time, closeCB, errback, status = status, results = results)
messages_history.append(m)
def closeCB(close_message, **kwargs):
if kwargs['results'] is not None:
callback(kwargs['results'])
else:
errback(OperationFailure('Failed to list snapshots %s on %s: List failed' % ( path, service_name ), messages_history))
if not self.connected_trees.has_key(service_name):
def connectCB(connect_message, **kwargs):
messages_history.append(connect_message)
if connect_message.status == 0:
self.connected_trees[service_name] = connect_message.tid
sendCreate(connect_message.tid)
else:
errback(OperationFailure('Failed to list snapshots %s on %s: Unable to connect to shared device' % ( path, service_name ), messages_history))
m = SMB2Message(SMB2TreeConnectRequest(r'\\%s\%s' % ( self.remote_name.upper(), service_name )))
self._sendSMBMessage(m)
self.pending_requests[m.mid] = _PendingRequest(m.mid, expiry_time, connectCB, errback, path = service_name)
messages_history.append(m)
else:
sendCreate(self.connected_trees[service_name])
def _echo_SMB2(self, data, callback, errback, timeout = 30):
messages_history = [ ]
def echoCB(echo_message, **kwargs):
messages_history.append(echo_message)
if echo_message.status == 0:
callback(data)
else:
errback(OperationFailure('Echo failed', messages_history))
m = SMB2Message(SMB2EchoRequest())
self._sendSMBMessage(m)
self.pending_requests[m.mid] = _PendingRequest(m.mid, int(time.time()) + timeout, echoCB, errback)
messages_history.append(m)
#
# SMB1 Methods Family
#
def _sendSMBMessage_SMB1(self, smb_message):
if smb_message.mid == 0:
smb_message.mid = self._getNextMID_SMB1()
if not smb_message.uid:
smb_message.uid = self.uid
if self.is_signing_active:
smb_message.flags2 |= SMB_FLAGS2_SMB_SECURITY_SIGNATURE
# Increment the next_signing_id as described in [MS-CIFS] 3.2.4.1.3
smb_message.security = self.next_signing_id
self.next_signing_id += 2 # All our defined messages currently have responses, so always increment by 2
raw_data = smb_message.encode()
md = ntlm.MD5(self.signing_session_key)
if self.signing_challenge_response:
md.update(self.signing_challenge_response)
md.update(raw_data)
signature = md.digest()[:8]
self.log.debug('MID is %d. Signing ID is %d. Signature is %s. Total raw message is %d bytes', smb_message.mid, smb_message.security, binascii.hexlify(signature), len(raw_data))
smb_message.raw_data = raw_data[:14] + signature + raw_data[22:]
else:
smb_message.raw_data = smb_message.encode()
self.sendNMBMessage(smb_message.raw_data)
def _getNextMID_SMB1(self):
self.mid += 1
if self.mid >= 0xFFFF: # MID cannot be 0xFFFF. [MS-CIFS]: 2.2.1.6.2
# We don't use MID of 0 as MID can be reused for SMB_COM_TRANSACTION2_SECONDARY messages
# where if mid=0, _sendSMBMessage will re-assign new MID values again
self.mid = 1
return self.mid
def _updateState_SMB1(self, message):
if message.isReply:
if message.command == SMB_COM_NEGOTIATE:
if not message.status.hasError:
self.has_negotiated = True
self.log.info('SMB dialect negotiation successful (ExtendedSecurity:%s)', message.hasExtendedSecurity)
self._updateServerInfo(message.payload)
self._handleNegotiateResponse(message)
else:
raise ProtocolError('Unknown status value (0x%08X) in SMB_COM_NEGOTIATE' % message.status.internal_value,
message.raw_data, message)
elif message.command == SMB_COM_SESSION_SETUP_ANDX:
if message.hasExtendedSecurity:
if not message.status.hasError:
try:
result = securityblob.decodeAuthResponseSecurityBlob(message.payload.security_blob)
if result == securityblob.RESULT_ACCEPT_COMPLETED:
self.log.debug('SMB uid is now %d', message.uid)
self.uid = message.uid
self.has_authenticated = True
self.log.info('Authentication (with extended security) successful!')
self.onAuthOK()
else:
raise ProtocolError('SMB_COM_SESSION_SETUP_ANDX status is 0 but security blob negResult value is %d' % result, message.raw_data, message)
except securityblob.BadSecurityBlobError, ex:
raise ProtocolError(str(ex), message.raw_data, message)
elif message.status.internal_value == 0xc0000016: # STATUS_MORE_PROCESSING_REQUIRED
try:
result, ntlm_token = securityblob.decodeChallengeSecurityBlob(message.payload.security_blob)
if result == securityblob.RESULT_ACCEPT_INCOMPLETE:
self._handleSessionChallenge(message, ntlm_token)
except ( securityblob.BadSecurityBlobError, securityblob.UnsupportedSecurityProvider ), ex:
raise ProtocolError(str(ex), message.raw_data, message)
elif message.status.internal_value == 0xc000006d: # STATUS_LOGON_FAILURE
self.has_authenticated = False
self.log.info('Authentication (with extended security) failed. Please check username and password. You may need to enable/disable NTLMv2 authentication.')
self.onAuthFailed()
else:
raise ProtocolError('Unknown status value (0x%08X) in SMB_COM_SESSION_SETUP_ANDX (with extended security)' % message.status.internal_value,
message.raw_data, message)
else:
if message.status.internal_value == 0:
self.log.debug('SMB uid is now %d', message.uid)
self.uid = message.uid
self.has_authenticated = True
self.log.info('Authentication (without extended security) successful!')
self.onAuthOK()
else:
self.has_authenticated = False
self.log.info('Authentication (without extended security) failed. Please check username and password')
self.onAuthFailed()
elif message.command == SMB_COM_TREE_CONNECT_ANDX:
try:
req = self.pending_requests[message.mid]
except KeyError:
pass
else:
if not message.status.hasError:
self.connected_trees[req.kwargs['path']] = message.tid
req = self.pending_requests.pop(message.mid, None)
if req:
req.callback(message, **req.kwargs)
return True
def _updateServerInfo_SMB1(self, payload):
self.capabilities = payload.capabilities
self.security_mode = payload.security_mode
self.max_raw_size = payload.max_raw_size
self.max_buffer_size = payload.max_buffer_size
self.max_mpx_count = payload.max_mpx_count
self.use_plaintext_authentication = not bool(payload.security_mode & NEGOTIATE_ENCRYPT_PASSWORDS)
if self.use_plaintext_authentication:
self.log.warning('Remote server only supports plaintext authentication. Your password can be stolen easily over the network.')
def _handleSessionChallenge_SMB1(self, message, ntlm_token):
assert message.hasExtendedSecurity
if message.uid and not self.uid:
self.uid = message.uid
server_challenge, server_flags, server_info = ntlm.decodeChallengeMessage(ntlm_token)
if self.use_ntlm_v2:
self.log.info('Performing NTLMv2 authentication (with extended security) with server challenge "%s"', binascii.hexlify(server_challenge))
nt_challenge_response, lm_challenge_response, session_key = ntlm.generateChallengeResponseV2(self.password,
self.username,
server_challenge,
server_info,
self.domain)
else:
self.log.info('Performing NTLMv1 authentication (with extended security) with server challenge "%s"', binascii.hexlify(server_challenge))
nt_challenge_response, lm_challenge_response, session_key = ntlm.generateChallengeResponseV1(self.password, server_challenge, True)
ntlm_data = ntlm.generateAuthenticateMessage(server_flags,
nt_challenge_response,
lm_challenge_response,
session_key,
self.username,
self.domain)
if self.log.isEnabledFor(logging.DEBUG):
self.log.debug('NT challenge response is "%s" (%d bytes)', binascii.hexlify(nt_challenge_response), len(nt_challenge_response))
self.log.debug('LM challenge response is "%s" (%d bytes)', binascii.hexlify(lm_challenge_response), len(lm_challenge_response))
blob = securityblob.generateAuthSecurityBlob(ntlm_data)
self._sendSMBMessage(SMBMessage(ComSessionSetupAndxRequest__WithSecurityExtension(0, blob)))
if self.security_mode & NEGOTIATE_SECURITY_SIGNATURES_REQUIRE:
self.log.info('Server requires all SMB messages to be signed')
self.is_signing_active = (self.sign_options != SMB.SIGN_NEVER)
elif self.security_mode & NEGOTIATE_SECURITY_SIGNATURES_ENABLE:
self.log.info('Server supports SMB signing')
self.is_signing_active = (self.sign_options == SMB.SIGN_WHEN_SUPPORTED)
else:
self.is_signing_active = False
if self.is_signing_active:
self.log.info("SMB signing activated. All SMB messages will be signed.")
self.signing_session_key = session_key
if self.capabilities & CAP_EXTENDED_SECURITY:
self.signing_challenge_response = None
else:
self.signing_challenge_response = blob
else:
self.log.info("SMB signing deactivated. SMB messages will NOT be signed.")
def _handleNegotiateResponse_SMB1(self, message):
if message.uid and not self.uid:
self.uid = message.uid
if message.hasExtendedSecurity or message.payload.supportsExtendedSecurity:
ntlm_data = ntlm.generateNegotiateMessage()
blob = securityblob.generateNegotiateSecurityBlob(ntlm_data)
self._sendSMBMessage(SMBMessage(ComSessionSetupAndxRequest__WithSecurityExtension(message.payload.session_key, blob)))
else:
nt_password, _, _ = ntlm.generateChallengeResponseV1(self.password, message.payload.challenge, False)
self.log.info('Performing NTLMv1 authentication (without extended security) with challenge "%s" and hashed password of "%s"',
binascii.hexlify(message.payload.challenge),
binascii.hexlify(nt_password))
self._sendSMBMessage(SMBMessage(ComSessionSetupAndxRequest__NoSecurityExtension(message.payload.session_key,
self.username,
nt_password,
True,
self.domain)))
def _listShares_SMB1(self, callback, errback, timeout = 30):
if not self.has_authenticated:
raise NotReadyError('SMB connection not authenticated')
expiry_time = time.time() + timeout
path = 'IPC$'
messages_history = [ ]
def connectSrvSvc(tid):
m = SMBMessage(ComNTCreateAndxRequest('\\srvsvc',
flags = NT_CREATE_REQUEST_EXTENDED_RESPONSE,
access_mask = READ_CONTROL | FILE_WRITE_ATTRIBUTES | FILE_READ_ATTRIBUTES | FILE_WRITE_EA | FILE_READ_EA | FILE_APPEND_DATA | FILE_WRITE_DATA | FILE_READ_DATA,
share_access = FILE_SHARE_READ | FILE_SHARE_WRITE,
create_disp = FILE_OPEN,
create_options = FILE_OPEN_NO_RECALL | FILE_NON_DIRECTORY_FILE,
impersonation = SEC_IMPERSONATE,
security_flags = 0))
m.tid = tid
self._sendSMBMessage(m)
self.pending_requests[m.mid] = _PendingRequest(m.mid, expiry_time, connectSrvSvcCB, errback)
messages_history.append(m)
def connectSrvSvcCB(create_message, **kwargs):
messages_history.append(create_message)
if not create_message.status.hasError:
call_id = self._getNextRPCCallID()
# See [MS-CIFS]: 2.2.5.6.1 for more information on TRANS_TRANSACT_NMPIPE (0x0026) parameters
setup_bytes = struct.pack('<HH', 0x0026, create_message.payload.fid)
# The data_bytes are binding call to Server Service RPC using DCE v1.1 RPC over SMB. See [MS-SRVS] and [C706]
# If you wish to understand the meanings of the byte stream, I would suggest you use a recent version of WireShark to packet capture the stream
data_bytes = \
binascii.unhexlify("""05 00 0b 03 10 00 00 00 48 00 00 00""".replace(' ', '')) + \
struct.pack('<I', call_id) + \
binascii.unhexlify("""
b8 10 b8 10 00 00 00 00 01 00 00 00 00 00 01 00
c8 4f 32 4b 70 16 d3 01 12 78 5a 47 bf 6e e1 88
03 00 00 00 04 5d 88 8a eb 1c c9 11 9f e8 08 00
2b 10 48 60 02 00 00 00""".replace(' ', '').replace('\n', ''))
m = SMBMessage(ComTransactionRequest(max_params_count = 0,
max_data_count = 4280,
max_setup_count = 0,
data_bytes = data_bytes,
setup_bytes = setup_bytes))
m.tid = create_message.tid
self._sendSMBMessage(m)
self.pending_requests[m.mid] = _PendingRequest(m.mid, expiry_time, rpcBindCB, errback, fid = create_message.payload.fid)
messages_history.append(m)
else:
errback(OperationFailure('Failed to list shares: Unable to locate Server Service RPC endpoint', messages_history))
def rpcBindCB(trans_message, **kwargs):
messages_history.append(trans_message)
if not trans_message.status.hasError:
call_id = self._getNextRPCCallID()
padding = ''
server_len = len(self.remote_name) + 1
server_bytes_len = server_len * 2
if server_len % 2 != 0:
padding = '\0\0'
server_bytes_len += 2
# See [MS-CIFS]: 2.2.5.6.1 for more information on TRANS_TRANSACT_NMPIPE (0x0026) parameters
setup_bytes = struct.pack('<HH', 0x0026, kwargs['fid'])
# The data bytes are the RPC call to NetrShareEnum (Opnum 15) at Server Service RPC.
# If you wish to understand the meanings of the byte stream, I would suggest you use a recent version of WireShark to packet capture the stream
data_bytes = \
binascii.unhexlify("""05 00 00 03 10 00 00 00""".replace(' ', '')) + \
struct.pack('<HHI', 72+server_bytes_len, 0, call_id) + \
binascii.unhexlify("""4c 00 00 00 00 00 0f 00 00 00 02 00""".replace(' ', '')) + \
struct.pack('<III', server_len, 0, server_len) + \
(self.remote_name + '\0').encode('UTF-16LE') + padding + \
binascii.unhexlify("""
01 00 00 00 01 00 00 00 04 00 02 00 00 00 00 00
00 00 00 00 ff ff ff ff 08 00 02 00 00 00 00 00
""".replace(' ', '').replace('\n', ''))
m = SMBMessage(ComTransactionRequest(max_params_count = 0,
max_data_count = 4280,
max_setup_count = 0,
data_bytes = data_bytes,
setup_bytes = setup_bytes))
m.tid = trans_message.tid
self._sendSMBMessage(m)
self.pending_requests[m.mid] = _PendingRequest(m.mid, expiry_time, listShareResultsCB, errback, fid = kwargs['fid'])
messages_history.append(m)
else:
closeFid(trans_message.tid, kwargs['fid'])
errback(OperationFailure('Failed to list shares: Unable to bind to Server Service RPC endpoint', messages_history))
def listShareResultsCB(result_message, **kwargs):
messages_history.append(result_message)
if not result_message.status.hasError:
# The payload.data_bytes will contain the results of the RPC call to NetrShareEnum (Opnum 15) at Server Service RPC.
data_bytes = result_message.payload.data_bytes
if ord(data_bytes[3]) & 0x02 == 0:
sendReadRequest(result_message.tid, kwargs['fid'], data_bytes)
else:
decodeResults(result_message.tid, kwargs['fid'], data_bytes)
else:
closeFid(result_message.tid, kwargs['fid'])
errback(OperationFailure('Failed to list shares: Unable to retrieve shared device list', messages_history))
def decodeResults(tid, fid, data_bytes):
shares_count = struct.unpack('<I', data_bytes[36:40])[0]
results = [ ] # A list of SharedDevice instances
offset = 36 + 12 # You need to study the byte stream to understand the meaning of these constants
for i in range(0, shares_count):
results.append(SharedDevice(struct.unpack('<I', data_bytes[offset+4:offset+8])[0], None, None))
offset += 12
for i in range(0, shares_count):
max_length, _, length = struct.unpack('<III', data_bytes[offset:offset+12])
offset += 12
results[i].name = unicode(data_bytes[offset:offset+length*2-2], 'UTF-16LE')
if length % 2 != 0:
offset += (length * 2 + 2)
else:
offset += (length * 2)
max_length, _, length = struct.unpack('<III', data_bytes[offset:offset+12])
offset += 12
results[i].comments = unicode(data_bytes[offset:offset+length*2-2], 'UTF-16LE')
if length % 2 != 0:
offset += (length * 2 + 2)
else:
offset += (length * 2)
closeFid(tid, fid)
callback(results)
def sendReadRequest(tid, fid, data_bytes):
read_count = min(4280, self.max_raw_size - 2)
m = SMBMessage(ComReadAndxRequest(fid = fid,
offset = 0,
max_return_bytes_count = read_count,
min_return_bytes_count = read_count))
m.tid = tid
self._sendSMBMessage(m)
self.pending_requests[m.mid] = _PendingRequest(m.mid, int(time.time()) + timeout, readCB, errback, fid = fid, data_bytes = data_bytes)
def readCB(read_message, **kwargs):
messages_history.append(read_message)
if not read_message.status.hasError:
data_len = read_message.payload.data_length
data_bytes = read_message.payload.data
if ord(data_bytes[3]) & 0x02 == 0:
sendReadRequest(read_message.tid, kwargs['fid'], kwargs['data_bytes'] + data_bytes[24:data_len-24])
else:
decodeResults(read_message.tid, kwargs['fid'], kwargs['data_bytes'] + data_bytes[24:data_len-24])
else:
closeFid(read_message.tid, kwargs['fid'])
errback(OperationFailure('Failed to list shares: Unable to retrieve shared device list', messages_history))
def closeFid(tid, fid):
m = SMBMessage(ComCloseRequest(fid))
m.tid = tid
self._sendSMBMessage(m)
messages_history.append(m)
def connectCB(connect_message, **kwargs):
messages_history.append(connect_message)
if not connect_message.status.hasError:
self.connected_trees[path] = connect_message.tid
connectSrvSvc(connect_message.tid)
else:
errback(OperationFailure('Failed to list shares: Unable to connect to IPC$', messages_history))
m = SMBMessage(ComTreeConnectAndxRequest(r'\\%s\%s' % ( self.remote_name.upper(), path ), SERVICE_ANY, ''))
self._sendSMBMessage(m)
self.pending_requests[m.mid] = _PendingRequest(m.mid, expiry_time, connectCB, errback, path = path)
messages_history.append(m)
def _listPath_SMB1(self, service_name, path, callback, errback, search, pattern, timeout = 30):
if not self.has_authenticated:
raise NotReadyError('SMB connection not authenticated')
expiry_time = time.time() + timeout
path = path.replace('/', '\\')
if not path.endswith('\\'):
path += '\\'
messages_history = [ ]
results = [ ]
def sendFindFirst(tid, support_dfs=False):
setup_bytes = struct.pack('<H', 0x0001) # TRANS2_FIND_FIRST2 sub-command. See [MS-CIFS]: 2.2.6.2.1
params_bytes = \
struct.pack('<HHHHI',
search, # SearchAttributes
100, # SearchCount
0x0006, # Flags: SMB_FIND_CLOSE_AT_EOS | SMB_FIND_RETURN_RESUME_KEYS
0x0104, # InfoLevel: SMB_FIND_FILE_BOTH_DIRECTORY_INFO
0x0000) # SearchStorageType
if support_dfs:
params_bytes += ("\\" + self.remote_name + "\\" + service_name + path + pattern + '\0').encode('UTF-16LE')
else:
params_bytes += (path + pattern).encode('UTF-16LE')
m = SMBMessage(ComTransaction2Request(max_params_count = 10,
max_data_count = 16644,
max_setup_count = 0,
params_bytes = params_bytes,
setup_bytes = setup_bytes))
m.tid = tid
if support_dfs:
m.flags2 |= SMB_FLAGS2_DFS
self._sendSMBMessage(m)
self.pending_requests[m.mid] = _PendingRequest(m.mid, expiry_time, findFirstCB, errback, support_dfs=support_dfs)
messages_history.append(m)
def decodeFindStruct(data_bytes):
# SMB_FIND_FILE_BOTH_DIRECTORY_INFO structure. See [MS-CIFS]: 2.2.8.1.7 and [MS-SMB]: 2.2.8.1.1
info_format = '<IIQQQQQQIIIBB24s'
info_size = struct.calcsize(info_format)
data_length = len(data_bytes)
offset = 0
while offset < data_length:
if offset + info_size > data_length:
return data_bytes[offset:]
next_offset, _, \
create_time, last_access_time, last_write_time, last_attr_change_time, \
file_size, alloc_size, file_attributes, filename_length, ea_size, \
short_name_length, _, short_name = struct.unpack(info_format, data_bytes[offset:offset+info_size])
offset2 = offset + info_size
if offset2 + filename_length > data_length:
return data_bytes[offset:]
filename = data_bytes[offset2:offset2+filename_length].decode('UTF-16LE')
short_name = short_name.decode('UTF-16LE')
results.append(SharedFile(convertFILETIMEtoEpoch(create_time), convertFILETIMEtoEpoch(last_access_time),
convertFILETIMEtoEpoch(last_write_time), convertFILETIMEtoEpoch(last_attr_change_time),
file_size, alloc_size, file_attributes, short_name, filename))
if next_offset:
offset += next_offset
else:
break
return ''
def findFirstCB(find_message, **kwargs):
messages_history.append(find_message)
if not find_message.status.hasError:
if not kwargs.has_key('total_count'):
# TRANS2_FIND_FIRST2 response. [MS-CIFS]: 2.2.6.2.2
sid, search_count, end_of_search, _, last_name_offset = struct.unpack('<HHHHH', find_message.payload.params_bytes[:10])
kwargs.update({ 'sid': sid, 'end_of_search': end_of_search, 'last_name_offset': last_name_offset, 'data_buf': '' })
else:
sid, end_of_search, last_name_offset = kwargs['sid'], kwargs['end_of_search'], kwargs['last_name_offset']
send_next = True
if find_message.payload.data_bytes:
d = decodeFindStruct(kwargs['data_buf'] + find_message.payload.data_bytes)
if not kwargs.has_key('data_count'):
if len(find_message.payload.data_bytes) != find_message.payload.total_data_count:
kwargs.update({ 'data_count': len(find_message.payload.data_bytes),
'total_count': find_message.payload.total_data_count,
'data_buf': d,
})
send_next = False
else:
kwargs['data_count'] += len(find_message.payload.data_bytes)
kwargs['total_count'] = min(find_message.payload.total_data_count, kwargs['total_count'])
kwargs['data_buf'] = d
if kwargs['data_count'] != kwargs['total_count']:
send_next = False
if not send_next:
self.pending_requests[find_message.mid] = _PendingRequest(find_message.mid, expiry_time, findFirstCB, errback, **kwargs)
elif end_of_search:
callback(results)
else:
sendFindNext(find_message.tid, sid, last_name_offset, kwargs.get('support_dfs', False))
else:
errback(OperationFailure('Failed to list %s on %s: Unable to retrieve file list' % ( path, service_name ), messages_history))
def sendFindNext(tid, sid, resume_key, support_dfs=False):
setup_bytes = struct.pack('<H', 0x0002) # TRANS2_FIND_NEXT2 sub-command. See [MS-CIFS]: 2.2.6.3.1
params_bytes = \
struct.pack('<HHHIH',
sid, # SID
100, # SearchCount
0x0104, # InfoLevel: SMB_FIND_FILE_BOTH_DIRECTORY_INFO
resume_key, # ResumeKey
0x000a) # Flags: SMB_FIND_RETURN_RESUME_KEYS | SMB_FIND_CLOSE_AT_EOS | SMB_FIND_RETURN_RESUME_KEYS
if support_dfs:
params_bytes += ("\\" + self.remote_name + "\\" + service_name + path + pattern + '\0').encode('UTF-16LE')
else:
params_bytes += (path + pattern).encode('UTF-16LE')
m = SMBMessage(ComTransaction2Request(max_params_count = 10,
max_data_count = 16644,
max_setup_count = 0,
params_bytes = params_bytes,
setup_bytes = setup_bytes))
m.tid = tid
if support_dfs:
m.flags2 |= SMB_FLAGS2_DFS
self._sendSMBMessage(m)
self.pending_requests[m.mid] = _PendingRequest(m.mid, expiry_time, findNextCB, errback, sid = sid, support_dfs = support_dfs)
messages_history.append(m)
def findNextCB(find_message, **kwargs):
messages_history.append(find_message)
if not find_message.status.hasError:
if not kwargs.has_key('total_count'):
# TRANS2_FIND_NEXT2 response. [MS-CIFS]: 2.2.6.3.2
search_count, end_of_search, _, last_name_offset = struct.unpack('<HHHH', find_message.payload.params_bytes[:8])
kwargs.update({ 'end_of_search': end_of_search, 'last_name_offset': last_name_offset, 'data_buf': '' })
else:
end_of_search, last_name_offset = kwargs['end_of_search'], kwargs['last_name_offset']
send_next = True
if find_message.payload.data_bytes:
d = decodeFindStruct(kwargs['data_buf'] + find_message.payload.data_bytes)
if not kwargs.has_key('data_count'):
if len(find_message.payload.data_bytes) != find_message.payload.total_data_count:
kwargs.update({ 'data_count': len(find_message.payload.data_bytes),
'total_count': find_message.payload.total_data_count,
'data_buf': d,
})
send_next = False
else:
kwargs['data_count'] += len(find_message.payload.data_bytes)
kwargs['total_count'] = min(find_message.payload.total_data_count, kwargs['total_count'])
kwargs['data_buf'] = d
if kwargs['data_count'] != kwargs['total_count']:
send_next = False
if not send_next:
self.pending_requests[find_message.mid] = _PendingRequest(find_message.mid, expiry_time, findNextCB, errback, **kwargs)
elif end_of_search:
callback(results)
else:
sendFindNext(find_message.tid, kwargs['sid'], last_name_offset, kwargs.get('support_dfs', False))
else:
errback(OperationFailure('Failed to list %s on %s: Unable to retrieve file list' % ( path, service_name ), messages_history))
def sendDFSReferral(tid):
setup_bytes = struct.pack('<H', 0x0010) # TRANS2_GET_DFS_REFERRAL sub-command. See [MS-CIFS]: 2.2.6.16.1
params_bytes = struct.pack('<H', 3) # Max referral level 3
params_bytes += ("\\" + self.remote_name + "\\" + service_name).encode('UTF-16LE')
m = SMBMessage(ComTransaction2Request(max_params_count = 10,
max_data_count = 16644,
max_setup_count = 0,
params_bytes = params_bytes,
setup_bytes = setup_bytes))
m.tid = tid
self._sendSMBMessage(m)
self.pending_requests[m.mid] = _PendingRequest(m.mid, expiry_time, dfsReferralCB, errback)
messages_history.append(m)
def dfsReferralCB(dfs_message, **kwargs):
sendFindFirst(dfs_message.tid, True)
if not self.connected_trees.has_key(service_name):
def connectCB(connect_message, **kwargs):
messages_history.append(connect_message)
if not connect_message.status.hasError:
self.connected_trees[service_name] = connect_message.tid
if connect_message.payload.optional_support & SMB_TREE_CONNECTX_SUPPORT_DFS:
sendDFSReferral(connect_message.tid)
else:
sendFindFirst(connect_message.tid, False)
else:
errback(OperationFailure('Failed to list %s on %s: Unable to connect to shared device' % ( path, service_name ), messages_history))
m = SMBMessage(ComTreeConnectAndxRequest(r'\\%s\%s' % ( self.remote_name.upper(), service_name ), SERVICE_ANY, ''))
self._sendSMBMessage(m)
self.pending_requests[m.mid] = _PendingRequest(m.mid, expiry_time, connectCB, errback, path = service_name)
messages_history.append(m)
else:
sendFindFirst(self.connected_trees[service_name])
def _getAttributes_SMB1(self, service_name, path, callback, errback, timeout = 30):
if not self.has_authenticated:
raise NotReadyError('SMB connection not authenticated')
expiry_time = time.time() + timeout
path = path.replace('/', '\\')
if path.startswith('\\'):
path = path[1:]
if path.endswith('\\'):
path = path[:-1]
messages_history = [ ]
def sendQuery(tid):
setup_bytes = struct.pack('<H', 0x0005) # TRANS2_QUERY_PATH_INFORMATION sub-command. See [MS-CIFS]: 2.2.6.6.1
params_bytes = \
struct.pack('<HI',
0x0107, # SMB_QUERY_FILE_ALL_INFO ([MS-CIFS] 2.2.2.3.3)
0x0000) # Reserved
params_bytes += (path + '\0').encode('UTF-16LE')
m = SMBMessage(ComTransaction2Request(max_params_count = 2,
max_data_count = 65535,
max_setup_count = 0,
params_bytes = params_bytes,
setup_bytes = setup_bytes))
m.tid = tid
self._sendSMBMessage(m)
self.pending_requests[m.mid] = _PendingRequest(m.mid, expiry_time, queryCB, errback)
messages_history.append(m)
def queryCB(query_message, **kwargs):
messages_history.append(query_message)
if not query_message.status.hasError:
info_format = '<QQQQIIQQ'
info_size = struct.calcsize(info_format)
create_time, last_access_time, last_write_time, last_attr_change_time, \
file_attributes, _, alloc_size, file_size = struct.unpack(info_format, query_message.payload.data_bytes[:info_size])
info = SharedFile(create_time, last_access_time, last_write_time, last_attr_change_time,
file_size, alloc_size, file_attributes, unicode(path), unicode(path))
callback(info)
else:
errback(OperationFailure('Failed to get attributes for %s on %s: Read failed' % ( path, service_name ), messages_history))
if not self.connected_trees.has_key(service_name):
def connectCB(connect_message, **kwargs):
messages_history.append(connect_message)
if not connect_message.status.hasError:
self.connected_trees[service_name] = connect_message.tid
sendQuery(connect_message.tid)
else:
errback(OperationFailure('Failed to get attributes for %s on %s: Unable to connect to shared device' % ( path, service_name ), messages_history))
m = SMBMessage(ComTreeConnectAndxRequest(r'\\%s\%s' % ( self.remote_name.upper(), service_name ), SERVICE_ANY, ''))
self._sendSMBMessage(m)
self.pending_requests[m.mid] = _PendingRequest(m.mid, expiry_time, connectCB, errback, path = service_name)
messages_history.append(m)
else:
sendQuery(self.connected_trees[service_name])
def _retrieveFile_SMB1(self, service_name, path, file_obj, callback, errback, timeout = 30):
return self._retrieveFileFromOffset(service_name, path, file_obj, callback, errback, 0L, -1L, timeout)
def _retrieveFileFromOffset_SMB1(self, service_name, path, file_obj, callback, errback, starting_offset, max_length, timeout = 30):
if not self.has_authenticated:
raise NotReadyError('SMB connection not authenticated')
path = path.replace('/', '\\')
messages_history = [ ]
def sendOpen(tid):
m = SMBMessage(ComOpenAndxRequest(filename = path,
access_mode = 0x0040, # Sharing mode: Deny nothing to others
open_mode = 0x0001, # Failed if file does not exist
search_attributes = SMB_FILE_ATTRIBUTE_HIDDEN | SMB_FILE_ATTRIBUTE_SYSTEM,
timeout = timeout * 1000))
m.tid = tid
self._sendSMBMessage(m)
self.pending_requests[m.mid] = _PendingRequest(m.mid, int(time.time()) + timeout, openCB, errback)
messages_history.append(m)
def openCB(open_message, **kwargs):
messages_history.append(open_message)
if not open_message.status.hasError:
if max_length == 0:
closeFid(open_message.tid, open_message.payload.fid)
callback(( file_obj, open_message.payload.file_attributes, 0L ))
else:
sendRead(open_message.tid, open_message.payload.fid, starting_offset, open_message.payload.file_attributes, 0L, max_length)
else:
errback(OperationFailure('Failed to retrieve %s on %s: Unable to open file' % ( path, service_name ), messages_history))
def sendRead(tid, fid, offset, file_attributes, read_len, remaining_len):
read_count = self.max_raw_size - 2
m = SMBMessage(ComReadAndxRequest(fid = fid,
offset = offset,
max_return_bytes_count = read_count,
min_return_bytes_count = min(0xFFFF, read_count)))
m.tid = tid
self._sendSMBMessage(m)
self.pending_requests[m.mid] = _PendingRequest(m.mid, int(time.time()) + timeout, readCB, errback, fid = fid, offset = offset, file_attributes = file_attributes,
read_len = read_len, remaining_len = remaining_len)
def readCB(read_message, **kwargs):
# To avoid crazy memory usage when retrieving large files, we do not save every read_message in messages_history.
if not read_message.status.hasError:
read_len = kwargs['read_len']
remaining_len = kwargs['remaining_len']
data_len = read_message.payload.data_length
if max_length > 0:
if data_len > remaining_len:
file_obj.write(read_message.payload.data[:remaining_len])
read_len += remaining_len
remaining_len = 0
else:
file_obj.write(read_message.payload.data)
remaining_len -= data_len
read_len += data_len
else:
file_obj.write(read_message.payload.data)
read_len += data_len
if (max_length > 0 and remaining_len <= 0) or data_len < (self.max_raw_size - 2):
closeFid(read_message.tid, kwargs['fid'])
callback(( file_obj, kwargs['file_attributes'], read_len )) # Note that this is a tuple of 3-elements
else:
sendRead(read_message.tid, kwargs['fid'], kwargs['offset']+data_len, kwargs['file_attributes'], read_len, remaining_len)
else:
messages_history.append(read_message)
closeFid(read_message.tid, kwargs['fid'])
errback(OperationFailure('Failed to retrieve %s on %s: Read failed' % ( path, service_name ), messages_history))
def closeFid(tid, fid):
m = SMBMessage(ComCloseRequest(fid))
m.tid = tid
self._sendSMBMessage(m)
messages_history.append(m)
if not self.connected_trees.has_key(service_name):
def connectCB(connect_message, **kwargs):
messages_history.append(connect_message)
if not connect_message.status.hasError:
self.connected_trees[service_name] = connect_message.tid
sendOpen(connect_message.tid)
else:
errback(OperationFailure('Failed to retrieve %s on %s: Unable to connect to shared device' % ( path, service_name ), messages_history))
m = SMBMessage(ComTreeConnectAndxRequest(r'\\%s\%s' % ( self.remote_name.upper(), service_name ), SERVICE_ANY, ''))
self._sendSMBMessage(m)
self.pending_requests[m.mid] = _PendingRequest(m.mid, int(time.time()) + timeout, connectCB, errback, path = service_name)
messages_history.append(m)
else:
sendOpen(self.connected_trees[service_name])
def _storeFile_SMB1(self, service_name, path, file_obj, callback, errback, timeout = 30):
self._storeFileFromOffset_SMB1(service_name, path, file_obj, callback, errback, 0L, True, timeout)
def _storeFileFromOffset_SMB1(self, service_name, path, file_obj, callback, errback, starting_offset, truncate = False, timeout = 30):
if not self.has_authenticated:
raise NotReadyError('SMB connection not authenticated')
path = path.replace('/', '\\')
messages_history = [ ]
def sendOpen(tid):
m = SMBMessage(ComOpenAndxRequest(filename = path,
access_mode = 0x0041, # Sharing mode: Deny nothing to others + Open for writing
open_mode = 0x0012 if truncate else 0x0011, # Create file if file does not exist. Overwrite or append depending on truncate parameter.
search_attributes = SMB_FILE_ATTRIBUTE_HIDDEN | SMB_FILE_ATTRIBUTE_SYSTEM,
timeout = timeout * 1000))
m.tid = tid
self._sendSMBMessage(m)
self.pending_requests[m.mid] = _PendingRequest(m.mid, int(time.time()) + timeout, openCB, errback)
messages_history.append(m)
def openCB(open_message, **kwargs):
messages_history.append(open_message)
if not open_message.status.hasError:
sendWrite(open_message.tid, open_message.payload.fid, starting_offset)
else:
errback(OperationFailure('Failed to store %s on %s: Unable to open file' % ( path, service_name ), messages_history))
def sendWrite(tid, fid, offset):
# For message signing, the total SMB message size must be not exceed the max_buffer_size. Non-message signing does not have this limitation
write_count = min((self.is_signing_active and (self.max_buffer_size-64)) or self.max_raw_size, 0xFFFF-1) # Need to minus 1 byte from 0xFFFF because of the first NULL byte in the ComWriteAndxRequest message data
data_bytes = file_obj.read(write_count)
data_len = len(data_bytes)
if data_len > 0:
m = SMBMessage(ComWriteAndxRequest(fid = fid, offset = offset, data_bytes = data_bytes))
m.tid = tid
self._sendSMBMessage(m)
self.pending_requests[m.mid] = _PendingRequest(m.mid, int(time.time()) + timeout, writeCB, errback, fid = fid, offset = offset+data_len)
else:
closeFid(tid, fid)
callback(( file_obj, offset )) # Note that this is a tuple of 2-elements
def writeCB(write_message, **kwargs):
# To avoid crazy memory usage when saving large files, we do not save every write_message in messages_history.
if not write_message.status.hasError:
sendWrite(write_message.tid, kwargs['fid'], kwargs['offset'])
else:
messages_history.append(write_message)
closeFid(write_message.tid, kwargs['fid'])
errback(OperationFailure('Failed to store %s on %s: Write failed' % ( path, service_name ), messages_history))
def closeFid(tid, fid):
m = SMBMessage(ComCloseRequest(fid))
m.tid = tid
self._sendSMBMessage(m)
messages_history.append(m)
if not self.connected_trees.has_key(service_name):
def connectCB(connect_message, **kwargs):
messages_history.append(connect_message)
if not connect_message.status.hasError:
self.connected_trees[service_name] = connect_message.tid
sendOpen(connect_message.tid)
else:
errback(OperationFailure('Failed to store %s on %s: Unable to connect to shared device' % ( path, service_name ), messages_history))
m = SMBMessage(ComTreeConnectAndxRequest(r'\\%s\%s' % ( self.remote_name.upper(), service_name ), SERVICE_ANY, ''))
self._sendSMBMessage(m)
self.pending_requests[m.mid] = _PendingRequest(m.mid, int(time.time()) + timeout, connectCB, errback, path = service_name)
messages_history.append(m)
else:
sendOpen(self.connected_trees[service_name])
def _deleteFiles_SMB1(self, service_name, path_file_pattern, callback, errback, timeout = 30):
if not self.has_authenticated:
raise NotReadyError('SMB connection not authenticated')
path = path_file_pattern.replace('/', '\\')
messages_history = [ ]
def sendDelete(tid):
m = SMBMessage(ComDeleteRequest(filename_pattern = path,
search_attributes = SMB_FILE_ATTRIBUTE_HIDDEN | SMB_FILE_ATTRIBUTE_SYSTEM))
m.tid = tid
self._sendSMBMessage(m)
self.pending_requests[m.mid] = _PendingRequest(m.mid, int(time.time()) + timeout, deleteCB, errback)
messages_history.append(m)
def deleteCB(delete_message, **kwargs):
messages_history.append(delete_message)
if not delete_message.status.hasError:
callback(path_file_pattern)
else:
errback(OperationFailure('Failed to store %s on %s: Delete failed' % ( path, service_name ), messages_history))
if not self.connected_trees.has_key(service_name):
def connectCB(connect_message, **kwargs):
messages_history.append(connect_message)
if not connect_message.status.hasError:
self.connected_trees[service_name] = connect_message.tid
sendDelete(connect_message.tid)
else:
errback(OperationFailure('Failed to delete %s on %s: Unable to connect to shared device' % ( path, service_name ), messages_history))
m = SMBMessage(ComTreeConnectAndxRequest(r'\\%s\%s' % ( self.remote_name.upper(), service_name ), SERVICE_ANY, ''))
self._sendSMBMessage(m)
self.pending_requests[m.mid] = _PendingRequest(m.mid, int(time.time()) + timeout, connectCB, errback, path = service_name)
messages_history.append(m)
else:
sendDelete(self.connected_trees[service_name])
def _resetFileAttributes_SMB1(self, service_name, path_file_pattern, callback, errback, timeout = 30):
raise NotReadyError('resetFileAttributes is not yet implemented for SMB1')
def _createDirectory_SMB1(self, service_name, path, callback, errback, timeout = 30):
if not self.has_authenticated:
raise NotReadyError('SMB connection not authenticated')
path = path.replace('/', '\\')
messages_history = [ ]
def sendCreate(tid):
m = SMBMessage(ComCreateDirectoryRequest(path))
m.tid = tid
self._sendSMBMessage(m)
self.pending_requests[m.mid] = _PendingRequest(m.mid, int(time.time()) + timeout, createCB, errback)
messages_history.append(m)
def createCB(create_message, **kwargs):
messages_history.append(create_message)
if not create_message.status.hasError:
callback(path)
else:
errback(OperationFailure('Failed to create directory %s on %s: Create failed' % ( path, service_name ), messages_history))
if not self.connected_trees.has_key(service_name):
def connectCB(connect_message, **kwargs):
messages_history.append(connect_message)
if not connect_message.status.hasError:
self.connected_trees[service_name] = connect_message.tid
sendCreate(connect_message.tid)
else:
errback(OperationFailure('Failed to create directory %s on %s: Unable to connect to shared device' % ( path, service_name ), messages_history))
m = SMBMessage(ComTreeConnectAndxRequest(r'\\%s\%s' % ( self.remote_name.upper(), service_name ), SERVICE_ANY, ''))
self._sendSMBMessage(m)
self.pending_requests[m.mid] = _PendingRequest(m.mid, int(time.time()) + timeout, connectCB, errback, path = service_name)
messages_history.append(m)
else:
sendCreate(self.connected_trees[service_name])
def _deleteDirectory_SMB1(self, service_name, path, callback, errback, timeout = 30):
if not self.has_authenticated:
raise NotReadyError('SMB connection not authenticated')
path = path.replace('/', '\\')
messages_history = [ ]
def sendDelete(tid):
m = SMBMessage(ComDeleteDirectoryRequest(path))
m.tid = tid
self._sendSMBMessage(m)
self.pending_requests[m.mid] = _PendingRequest(m.mid, int(time.time()) + timeout, deleteCB, errback)
messages_history.append(m)
def deleteCB(delete_message, **kwargs):
messages_history.append(delete_message)
if not delete_message.status.hasError:
callback(path)
else:
errback(OperationFailure('Failed to delete directory %s on %s: Delete failed' % ( path, service_name ), messages_history))
if not self.connected_trees.has_key(service_name):
def connectCB(connect_message, **kwargs):
messages_history.append(connect_message)
if not connect_message.status.hasError:
self.connected_trees[service_name] = connect_message.tid
sendDelete(connect_message.tid)
else:
errback(OperationFailure('Failed to delete %s on %s: Unable to connect to shared device' % ( path, service_name ), messages_history))
m = SMBMessage(ComTreeConnectAndxRequest(r'\\%s\%s' % ( self.remote_name.upper(), service_name ), SERVICE_ANY, ''))
self._sendSMBMessage(m)
self.pending_requests[m.mid] = _PendingRequest(m.mid, int(time.time()) + timeout, connectCB, errback, path = service_name)
messages_history.append(m)
else:
sendDelete(self.connected_trees[service_name])
def _rename_SMB1(self, service_name, old_path, new_path, callback, errback, timeout = 30):
if not self.has_authenticated:
raise NotReadyError('SMB connection not authenticated')
new_path = new_path.replace('/', '\\')
old_path = old_path.replace('/', '\\')
messages_history = [ ]
def sendRename(tid):
m = SMBMessage(ComRenameRequest(old_path = old_path,
new_path = new_path,
search_attributes = SMB_FILE_ATTRIBUTE_HIDDEN | SMB_FILE_ATTRIBUTE_SYSTEM))
m.tid = tid
self._sendSMBMessage(m)
self.pending_requests[m.mid] = _PendingRequest(m.mid, int(time.time()) + timeout, renameCB, errback)
messages_history.append(m)
def renameCB(rename_message, **kwargs):
messages_history.append(rename_message)
if not rename_message.status.hasError:
callback(( old_path, new_path )) # Note that this is a tuple of 2-elements
else:
errback(OperationFailure('Failed to rename %s on %s: Rename failed' % ( old_path, service_name ), messages_history))
if not self.connected_trees.has_key(service_name):
def connectCB(connect_message, **kwargs):
messages_history.append(connect_message)
if not connect_message.status.hasError:
self.connected_trees[service_name] = connect_message.tid
sendRename(connect_message.tid)
else:
errback(OperationFailure('Failed to rename %s on %s: Unable to connect to shared device' % ( old_path, service_name ), messages_history))
m = SMBMessage(ComTreeConnectAndxRequest(r'\\%s\%s' % ( self.remote_name.upper(), service_name ), SERVICE_ANY, ''))
self._sendSMBMessage(m)
self.pending_requests[m.mid] = _PendingRequest(m.mid, int(time.time()) + timeout, connectCB, errback, path = service_name)
messages_history.append(m)
else:
sendRename(self.connected_trees[service_name])
def _listSnapshots_SMB1(self, service_name, path, callback, errback, timeout = 30):
if not self.has_authenticated:
raise NotReadyError('SMB connection not authenticated')
expiry_time = time.time() + timeout
path = path.replace('/', '\\')
if not path.endswith('\\'):
path += '\\'
messages_history = [ ]
results = [ ]
def sendOpen(tid):
m = SMBMessage(ComOpenAndxRequest(filename = path,
access_mode = 0x0040, # Sharing mode: Deny nothing to others
open_mode = 0x0001, # Failed if file does not exist
search_attributes = 0,
timeout = timeout * 1000))
m.tid = tid
self._sendSMBMessage(m)
self.pending_requests[m.mid] = _PendingRequest(m.mid, int(time.time()) + timeout, openCB, errback)
messages_history.append(m)
def openCB(open_message, **kwargs):
messages_history.append(open_message)
if not open_message.status.hasError:
sendEnumSnapshots(open_message.tid, open_message.payload.fid)
else:
errback(OperationFailure('Failed to list snapshots %s on %s: Unable to open path' % ( path, service_name ), messages_history))
def sendEnumSnapshots(tid, fid):
# [MS-CIFS]: 2.2.7.2
# [MS-SMB]: 2.2.7.2.1
setup_bytes = struct.pack('<IHBB',
0x00144064, # [MS-SMB]: 2.2.7.2.1
fid, # FID
0x01, # IsFctl
0) # IsFlags
m = SMBMessage(ComNTTransactRequest(function = 0x0002, # NT_TRANSACT_IOCTL. [MS-CIFS]: 2.2.7.2.1
max_params_count = 0,
max_data_count = 0xFFFF,
max_setup_count = 0,
setup_bytes = setup_bytes))
m.tid = tid
self._sendSMBMessage(m)
self.pending_requests[m.mid] = _PendingRequest(m.mid, expiry_time, enumSnapshotsCB, errback, tid = tid, fid = fid)
messages_history.append(m)
def enumSnapshotsCB(enum_message, **kwargs):
messages_history.append(enum_message)
if not enum_message.status.hasError:
results = [ ]
snapshots_count = struct.unpack('<I', enum_message.payload.data_bytes[4:8])[0]
for i in range(0, snapshots_count):
s = enum_message.payload.data_bytes[12+i*50:12+48+i*50].decode('UTF-16LE')
results.append(datetime(*map(int, ( s[5:9], s[10:12], s[13:15], s[16:18], s[19:21], s[22:24] ))))
closeFid(kwargs['tid'], kwargs['fid'])
callback(results)
else:
closeFid(kwargs['tid'], kwargs['fid'])
errback(OperationFailure('Failed to list snapshots %s on %s: Unable to list snapshots on path' % ( path, service_name ), messages_history))
def closeFid(tid, fid):
m = SMBMessage(ComCloseRequest(fid))
m.tid = tid
self._sendSMBMessage(m)
messages_history.append(m)
if not self.connected_trees.has_key(service_name):
def connectCB(connect_message, **kwargs):
messages_history.append(connect_message)
if not connect_message.status.hasError:
self.connected_trees[service_name] = connect_message.tid
sendOpen(connect_message.tid)
else:
errback(OperationFailure('Failed to list snapshots %s on %s: Unable to connect to shared device' % ( path, service_name ), messages_history))
m = SMBMessage(ComTreeConnectAndxRequest(r'\\%s\%s' % ( self.remote_name.upper(), service_name ), SERVICE_ANY, ''))
self._sendSMBMessage(m)
self.pending_requests[m.mid] = _PendingRequest(m.mid, expiry_time, connectCB, errback, path = service_name)
messages_history.append(m)
else:
sendOpen(self.connected_trees[service_name])
def _echo_SMB1(self, data, callback, errback, timeout = 30):
messages_history = [ ]
def echoCB(echo_message, **kwargs):
messages_history.append(echo_message)
if not echo_message.status.hasError:
callback(echo_message.payload.data)
else:
errback(OperationFailure('Echo failed', messages_history))
m = SMBMessage(ComEchoRequest(echo_data = data))
self._sendSMBMessage(m)
self.pending_requests[m.mid] = _PendingRequest(m.mid, int(time.time()) + timeout, echoCB, errback)
messages_history.append(m)
class SharedDevice:
"""
Contains information about a single shared device on the remote server.
"""
# The following constants are taken from [MS-SRVS]: 2.2.2.4
# They are used to identify the type of shared resource from the results from the NetrShareEnum in Server Service RPC
DISK_TREE = 0x00
PRINT_QUEUE = 0x01
COMM_DEVICE = 0x02
IPC = 0x03
def __init__(self, type, name, comments):
self._type = type
self.name = name #: An unicode string containing the name of the shared device
self.comments = comments #: An unicode string containing the user description of the shared device
@property
def type(self):
"""
Returns one of the following integral constants.
- SharedDevice.DISK_TREE
- SharedDevice.PRINT_QUEUE
- SharedDevice.COMM_DEVICE
- SharedDevice.IPC
"""
return self._type & 0xFFFF
@property
def isSpecial(self):
"""
Returns True if this shared device is a special share reserved for interprocess communication (IPC$)
or remote administration of the server (ADMIN$). Can also refer to administrative shares such as
C$, D$, E$, and so forth
"""
return bool(self._type & 0x80000000)
@property
def isTemporary(self):
"""
Returns True if this is a temporary share that is not persisted for creation each time the file server initializes.
"""
return bool(self._type & 0x40000000)
def __unicode__(self):
return u'Shared device: %s (type:0x%02x comments:%s)' % (self.name, self.type, self.comments )
class SharedFile:
"""
Contain information about a file/folder entry that is shared on the shared device.
As an application developer, you should not need to instantiate a *SharedFile* instance directly in your application.
These *SharedFile* instances are usually returned via a call to *listPath* method in :doc:`smb.SMBProtocol.SMBProtocolFactory<smb_SMBProtocolFactory>`.
If you encounter *SharedFile* instance where its short_name attribute is empty but the filename attribute contains a short name which does not correspond
to any files/folders on your remote shared device, it could be that the original filename on the file/folder entry on the shared device contains
one of these prohibited characters: "\/[]:+|<>=;?,* (see [MS-CIFS]: 2.2.1.1.1 for more details).
"""
def __init__(self, create_time, last_access_time, last_write_time, last_attr_change_time, file_size, alloc_size, file_attributes, short_name, filename):
self.create_time = create_time #: Float value in number of seconds since 1970-01-01 00:00:00 to the time of creation of this file resource on the remote server
self.last_access_time = last_access_time #: Float value in number of seconds since 1970-01-01 00:00:00 to the time of last access of this file resource on the remote server
self.last_write_time = last_write_time #: Float value in number of seconds since 1970-01-01 00:00:00 to the time of last modification of this file resource on the remote server
self.last_attr_change_time = last_attr_change_time #: Float value in number of seconds since 1970-01-01 00:00:00 to the time of last attribute change of this file resource on the remote server
self.file_size = file_size #: File size in number of bytes
self.alloc_size = alloc_size #: Total number of bytes allocated to store this file
self.file_attributes = file_attributes #: A SMB_EXT_FILE_ATTR integer value. See [MS-CIFS]: 2.2.1.2.3
self.short_name = short_name #: Unicode string containing the short name of this file (usually in 8.3 notation)
self.filename = filename #: Unicode string containing the long filename of this file. Each OS has a limit to the length of this file name. On Windows, it is 256 characters.
@property
def isDirectory(self):
"""A convenient property to return True if this file resource is a directory on the remote server"""
return bool(self.file_attributes & ATTR_DIRECTORY)
@property
def isReadOnly(self):
"""A convenient property to return True if this file resource is read-only on the remote server"""
return bool(self.file_attributes & ATTR_READONLY)
def __unicode__(self):
return u'Shared file: %s (FileSize:%d bytes, isDirectory:%s)' % ( self.filename, self.file_size, self.isDirectory )
class _PendingRequest:
def __init__(self, mid, expiry_time, callback, errback, **kwargs):
self.mid = mid
self.expiry_time = expiry_time
self.callback = callback
self.errback = errback
self.kwargs = kwargs
|
gpl-3.0
|
[
199,
646,
2050,
12,
14755,
12,
900,
12,
20330,
199,
504,
2197,
492,
2197,
199,
504,
22717,
63,
5559,
492,
627,
199,
504,
22717,
18,
63,
5559,
492,
627,
199,
504,
22717,
63,
23253,
492,
627,
199,
504,
22717,
18,
63,
23253,
492,
627,
199,
504,
302,
887,
14,
1095,
492,
653,
4567,
4434,
199,
504,
3778,
492,
3957,
5110,
10931,
475,
29322,
199,
646,
302,
5019,
77,
12,
6391,
6582,
199,
199,
893,
26,
272,
492,
8337,
272,
7793,
3912,
275,
8337,
14,
4835,
3912,
199,
2590,
3545,
26,
272,
687,
3778,
492,
7793,
3912,
421,
199,
533,
2832,
17960,
547,
8,
1726,
304,
272,
408,
16894,
1380,
2389,
34,
1950,
365,
440,
10144,
334,
73,
14,
69,
14,
440,
15082,
503,
6299,
3405,
9471,
272,
986,
199,
199,
533,
2832,
16382,
547,
8,
1726,
304,
272,
408,
16894,
1380,
8793,
2389,
34,
1950,
965,
2757,
25602,
503,
440,
8539,
5966,
624,
272,
986,
199,
199,
533,
2389,
34,
6372,
8,
1726,
304,
272,
408,
16894,
1380,
282,
2653,
965,
8920,
1830,
10923,
367,
282,
1177,
503,
367,
282,
2389,
34,
15,
3553,
7079,
3439,
370,
4890,
1041,
272,
986,
421,
199,
318,
485,
3916,
63,
475,
63,
2975,
8,
875,
304,
272,
340,
440,
1228,
8,
875,
12,
2649,
304,
267,
1059,
275,
2649,
8,
875,
12,
298,
1624,
13,
24,
531,
272,
372,
1059,
421,
199,
533,
2389,
34,
8,
46,
4567,
4434,
304,
272,
408,
272,
961,
1021,
8469,
282,
298,
2105,
2,
370,
314,
3982,
2389,
34,
15,
3553,
7079,
1654,
14,
272,
2779,
365,
440,
18329,
370,
506,
1202,
5370,
315,
376,
4223,
465,
652,
1630,
440,
1172,
1263,
2784,
7773,
12591,
14,
339,
2104,
4223,
675,
12,
8749,
10618,
370,
489,
446,
491,
91,
23304,
3658,
14,
23304,
3658,
2927,
28,
23323,
14,
23304,
3658,
23307,
340,
1265,
787,
1808,
17078,
10059,
339,
1010,
359,
3053,
13,
3553,
7079,
467,
642,
1021,
911,
1395,
3004,
402,
6810,
12,
6810,
14,
3225,
436,
6810,
14,
4434,
9006,
666,
1709,
14,
339,
14504,
26,
272,
275,
17575,
489,
446,
359,
3053,
13,
3553,
7079,
2189,
650,
14,
18,
14,
17,
272,
408,
339,
943,
275,
2050,
14,
5572,
360,
23304,
14,
23304,
358,
339,
5056,
63,
6388,
2111,
275,
378,
272,
5056,
63,
9792,
742,
63,
15925,
275,
413,
272,
5056,
63,
9792,
742,
63,
12496,
275,
499,
339,
347,
636,
826,
721,
277,
12,
3434,
12,
2505,
12,
3002,
63,
354,
12,
3982,
63,
354,
12,
2881,
275,
3260,
675,
63,
343,
14344,
63,
86,
18,
275,
715,
12,
2070,
63,
1419,
275,
5056,
63,
9792,
742,
63,
12496,
12,
365,
63,
2275,
63,
8815,
275,
756,
304,
267,
653,
4567,
4434,
855,
826,
721,
277,
12,
3002,
63,
354,
12,
3982,
63,
354,
12,
365,
63,
2275,
63,
8815,
275,
365,
63,
2275,
63,
8815,
9,
267,
291,
14,
2473,
275,
485,
3916,
63,
475,
63,
2975,
8,
2473,
9,
267,
291,
14,
2060,
275,
485,
3916,
63,
475,
63,
2975,
8,
2060,
9,
267,
291,
14,
2261,
275,
485,
3916,
63,
475,
63,
2975,
8,
2261,
9,
267,
291,
14,
1037,
63,
1419,
275,
2070,
63,
1419,
267,
291,
14,
374,
63,
2275,
63,
8815,
275,
365,
63,
2275,
63,
8815,
267,
291,
14,
1180,
63,
343,
14344,
63,
86,
18,
275,
675,
63,
343,
14344,
63,
86,
18,
6079,
20046,
370,
491,
2054,
762,
4101,
4845,
436,
23350,
10348,
4845,
465,
11736,
315,
359,
3053,
13,
3553,
7079,
61,
650,
14,
18,
14,
17,
14,
17,
267,
291,
14,
23323,
63,
1188,
275,
2389,
34,
2209,
342,
267,
291,
14,
374,
63,
4941,
63,
23323,
18,
275,
756,
257,
6079,
23889,
781,
13882,
1958,
1808,
2389,
34,
18,
4113,
31,
291,
14,
23323,
63,
1188,
911,
506,
282,
2389,
34,
18,
2209,
1256,
340,
642,
3305,
365,
715,
267,
291,
14,
6455,
63,
6615,
275,
469,
789,
221,
6079,
603,
998,
9994,
370,
485,
15960,
2017,
1256,
267,
291,
14,
7113,
63,
14635,
275,
469,
789,
257,
6079,
5244,
1530,
536,
9994,
370,
377,
998,
267,
291,
14,
2184,
63,
4354,
63,
1250,
63,
344,
275,
413,
259,
6079,
16840,
11785,
1240,
998,
574,
14,
2832,
1202,
5370,
315,
2389,
34,
1245,
14,
24612,
22667,
8097,
315,
1007,
13,
4405,
1334,
2389,
34,
63,
11265,
63,
12191,
10052,
503,
2389,
34,
63,
11265,
63,
12191,
10052,
18,
3788,
398,
291,
14,
1989,
63,
21961,
972,
275,
756,
267,
291,
14,
1989,
63,
12177,
275,
756,
267,
291,
14,
374,
63,
23238,
63,
2682,
275,
756,
3698,
6079,
715,
340,
314,
3982,
1654,
11479,
1245,
18057,
14,
2900,
21507,
3788,
911,
506,
10514,
14,
10751,
73,
285,
370,
6596,
4940,
316,
7472,
465,
11736,
315,
359,
3053,
13,
3553,
7079,
61,
650,
14,
18,
14,
17,
14,
18,
267,
291,
14,
23238,
63,
1730,
63,
498,
275,
488,
3515,
6079,
8596,
790,
367,
18057,
14593,
12,
340,
18057,
365,
4702,
14,
20046,
370,
6632,
316,
4434,
1197,
465,
11736,
315,
359,
3053,
13,
3553,
7079,
61,
650,
14,
18,
14,
17,
14,
18,
267,
291,
14,
23238,
63,
13911,
63,
1310,
275,
488,
257,
6079,
22493,
314,
14929,
1177,
367,
18057,
12,
340,
18057,
365,
4702,
14,
20046,
370,
6632,
316,
30531,
2364,
465,
11736,
315,
359,
3053,
13,
3553,
7079,
61,
650,
14,
18,
14,
17,
14,
18,
267,
291,
14,
8523,
275,
378,
267,
291,
14,
1535,
275,
378,
267,
291,
14,
2184,
63,
23238,
63,
344,
275,
499,
258,
6079,
20046,
370,
6810,
5765,
6795,
28014,
465,
11736,
315,
359,
3053,
13,
3553,
7079,
61,
650,
14,
18,
14,
17,
14,
18,
398,
327,
2389,
34,
17,
436,
2389,
34,
18,
3004,
267,
327,
3390,
626,
314,
15579,
1298,
402,
314,
1338,
1443,
14460,
3382,
2389,
34,
17,
436,
2389,
34,
18,
19230,
267,
291,
14,
10732,
275,
378,
267,
291,
14,
4416,
63,
632,
275,
378,
258,
6079,
6026,
1759,
687,
314,
13863,
1385,
901,
402,
314,
2389,
34,
63,
11265,
63,
31254,
1387,
41,
1951,
1245,
398,
327,
2389,
34,
17,
3004,
267,
327,
17536,
402,
314,
2569,
3004,
911,
506,
10038,
12188,
31594,
402,
2389,
34,
63,
11265,
63,
31254
] |
[
646,
2050,
12,
14755,
12,
900,
12,
20330,
199,
504,
2197,
492,
2197,
199,
504,
22717,
63,
5559,
492,
627,
199,
504,
22717,
18,
63,
5559,
492,
627,
199,
504,
22717,
63,
23253,
492,
627,
199,
504,
22717,
18,
63,
23253,
492,
627,
199,
504,
302,
887,
14,
1095,
492,
653,
4567,
4434,
199,
504,
3778,
492,
3957,
5110,
10931,
475,
29322,
199,
646,
302,
5019,
77,
12,
6391,
6582,
199,
199,
893,
26,
272,
492,
8337,
272,
7793,
3912,
275,
8337,
14,
4835,
3912,
199,
2590,
3545,
26,
272,
687,
3778,
492,
7793,
3912,
421,
199,
533,
2832,
17960,
547,
8,
1726,
304,
272,
408,
16894,
1380,
2389,
34,
1950,
365,
440,
10144,
334,
73,
14,
69,
14,
440,
15082,
503,
6299,
3405,
9471,
272,
986,
199,
199,
533,
2832,
16382,
547,
8,
1726,
304,
272,
408,
16894,
1380,
8793,
2389,
34,
1950,
965,
2757,
25602,
503,
440,
8539,
5966,
624,
272,
986,
199,
199,
533,
2389,
34,
6372,
8,
1726,
304,
272,
408,
16894,
1380,
282,
2653,
965,
8920,
1830,
10923,
367,
282,
1177,
503,
367,
282,
2389,
34,
15,
3553,
7079,
3439,
370,
4890,
1041,
272,
986,
421,
199,
318,
485,
3916,
63,
475,
63,
2975,
8,
875,
304,
272,
340,
440,
1228,
8,
875,
12,
2649,
304,
267,
1059,
275,
2649,
8,
875,
12,
298,
1624,
13,
24,
531,
272,
372,
1059,
421,
199,
533,
2389,
34,
8,
46,
4567,
4434,
304,
272,
408,
272,
961,
1021,
8469,
282,
298,
2105,
2,
370,
314,
3982,
2389,
34,
15,
3553,
7079,
1654,
14,
272,
2779,
365,
440,
18329,
370,
506,
1202,
5370,
315,
376,
4223,
465,
652,
1630,
440,
1172,
1263,
2784,
7773,
12591,
14,
339,
2104,
4223,
675,
12,
8749,
10618,
370,
489,
446,
491,
91,
23304,
3658,
14,
23304,
3658,
2927,
28,
23323,
14,
23304,
3658,
23307,
340,
1265,
787,
1808,
17078,
10059,
339,
1010,
359,
3053,
13,
3553,
7079,
467,
642,
1021,
911,
1395,
3004,
402,
6810,
12,
6810,
14,
3225,
436,
6810,
14,
4434,
9006,
666,
1709,
14,
339,
14504,
26,
272,
275,
17575,
489,
446,
359,
3053,
13,
3553,
7079,
2189,
650,
14,
18,
14,
17,
272,
408,
339,
943,
275,
2050,
14,
5572,
360,
23304,
14,
23304,
358,
339,
5056,
63,
6388,
2111,
275,
378,
272,
5056,
63,
9792,
742,
63,
15925,
275,
413,
272,
5056,
63,
9792,
742,
63,
12496,
275,
499,
339,
347,
636,
826,
721,
277,
12,
3434,
12,
2505,
12,
3002,
63,
354,
12,
3982,
63,
354,
12,
2881,
275,
3260,
675,
63,
343,
14344,
63,
86,
18,
275,
715,
12,
2070,
63,
1419,
275,
5056,
63,
9792,
742,
63,
12496,
12,
365,
63,
2275,
63,
8815,
275,
756,
304,
267,
653,
4567,
4434,
855,
826,
721,
277,
12,
3002,
63,
354,
12,
3982,
63,
354,
12,
365,
63,
2275,
63,
8815,
275,
365,
63,
2275,
63,
8815,
9,
267,
291,
14,
2473,
275,
485,
3916,
63,
475,
63,
2975,
8,
2473,
9,
267,
291,
14,
2060,
275,
485,
3916,
63,
475,
63,
2975,
8,
2060,
9,
267,
291,
14,
2261,
275,
485,
3916,
63,
475,
63,
2975,
8,
2261,
9,
267,
291,
14,
1037,
63,
1419,
275,
2070,
63,
1419,
267,
291,
14,
374,
63,
2275,
63,
8815,
275,
365,
63,
2275,
63,
8815,
267,
291,
14,
1180,
63,
343,
14344,
63,
86,
18,
275,
675,
63,
343,
14344,
63,
86,
18,
6079,
20046,
370,
491,
2054,
762,
4101,
4845,
436,
23350,
10348,
4845,
465,
11736,
315,
359,
3053,
13,
3553,
7079,
61,
650,
14,
18,
14,
17,
14,
17,
267,
291,
14,
23323,
63,
1188,
275,
2389,
34,
2209,
342,
267,
291,
14,
374,
63,
4941,
63,
23323,
18,
275,
756,
257,
6079,
23889,
781,
13882,
1958,
1808,
2389,
34,
18,
4113,
31,
291,
14,
23323,
63,
1188,
911,
506,
282,
2389,
34,
18,
2209,
1256,
340,
642,
3305,
365,
715,
267,
291,
14,
6455,
63,
6615,
275,
469,
789,
221,
6079,
603,
998,
9994,
370,
485,
15960,
2017,
1256,
267,
291,
14,
7113,
63,
14635,
275,
469,
789,
257,
6079,
5244,
1530,
536,
9994,
370,
377,
998,
267,
291,
14,
2184,
63,
4354,
63,
1250,
63,
344,
275,
413,
259,
6079,
16840,
11785,
1240,
998,
574,
14,
2832,
1202,
5370,
315,
2389,
34,
1245,
14,
24612,
22667,
8097,
315,
1007,
13,
4405,
1334,
2389,
34,
63,
11265,
63,
12191,
10052,
503,
2389,
34,
63,
11265,
63,
12191,
10052,
18,
3788,
398,
291,
14,
1989,
63,
21961,
972,
275,
756,
267,
291,
14,
1989,
63,
12177,
275,
756,
267,
291,
14,
374,
63,
23238,
63,
2682,
275,
756,
3698,
6079,
715,
340,
314,
3982,
1654,
11479,
1245,
18057,
14,
2900,
21507,
3788,
911,
506,
10514,
14,
10751,
73,
285,
370,
6596,
4940,
316,
7472,
465,
11736,
315,
359,
3053,
13,
3553,
7079,
61,
650,
14,
18,
14,
17,
14,
18,
267,
291,
14,
23238,
63,
1730,
63,
498,
275,
488,
3515,
6079,
8596,
790,
367,
18057,
14593,
12,
340,
18057,
365,
4702,
14,
20046,
370,
6632,
316,
4434,
1197,
465,
11736,
315,
359,
3053,
13,
3553,
7079,
61,
650,
14,
18,
14,
17,
14,
18,
267,
291,
14,
23238,
63,
13911,
63,
1310,
275,
488,
257,
6079,
22493,
314,
14929,
1177,
367,
18057,
12,
340,
18057,
365,
4702,
14,
20046,
370,
6632,
316,
30531,
2364,
465,
11736,
315,
359,
3053,
13,
3553,
7079,
61,
650,
14,
18,
14,
17,
14,
18,
267,
291,
14,
8523,
275,
378,
267,
291,
14,
1535,
275,
378,
267,
291,
14,
2184,
63,
23238,
63,
344,
275,
499,
258,
6079,
20046,
370,
6810,
5765,
6795,
28014,
465,
11736,
315,
359,
3053,
13,
3553,
7079,
61,
650,
14,
18,
14,
17,
14,
18,
398,
327,
2389,
34,
17,
436,
2389,
34,
18,
3004,
267,
327,
3390,
626,
314,
15579,
1298,
402,
314,
1338,
1443,
14460,
3382,
2389,
34,
17,
436,
2389,
34,
18,
19230,
267,
291,
14,
10732,
275,
378,
267,
291,
14,
4416,
63,
632,
275,
378,
258,
6079,
6026,
1759,
687,
314,
13863,
1385,
901,
402,
314,
2389,
34,
63,
11265,
63,
31254,
1387,
41,
1951,
1245,
398,
327,
2389,
34,
17,
3004,
267,
327,
17536,
402,
314,
2569,
3004,
911,
506,
10038,
12188,
31594,
402,
2389,
34,
63,
11265,
63,
31254,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
switowski/invenio
|
invenio/legacy/bibcheck/plugins/utf8.py
|
17
|
1177
|
# -*- coding: utf-8 -*-
#
# This file is part of Invenio.
# Copyright (C) 2013 CERN.
#
# Invenio is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# Invenio is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Invenio; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
""" Plugin for valid utf-8 checking """
def check_record(record, fields=["%%%%%%", "%%%%%_"]):
"""
Check that the value of the specified fields can be encoded as utf-8
"""
for position, value in record.iterfields(fields):
try:
value.decode("utf-8")
except UnicodeDecodeError:
record.set_invalid("Invalid utf-8 value in field %s" % (position[0]))
|
gpl-2.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
199,
3,
961,
570,
365,
1777,
402,
12235,
14,
199,
3,
1898,
334,
35,
9,
6171,
24354,
14,
199,
3,
199,
3,
12235,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
199,
3,
2811,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
199,
3,
3267,
701,
314,
2868,
2290,
2752,
27,
1902,
1015,
499,
402,
314,
199,
3,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
12235,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
1325,
199,
3,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
1664,
199,
3,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
3,
3180,
543,
12235,
27,
340,
440,
12,
2218,
370,
314,
2868,
2290,
2752,
12,
3277,
2020,
199,
3,
8155,
15630,
10902,
12,
14453,
13540,
12,
8226,
12,
4828,
15673,
13,
13421,
12,
8217,
14,
199,
199,
624,
11349,
367,
1686,
2774,
13,
24,
7907,
408,
199,
199,
318,
1104,
63,
3059,
8,
3059,
12,
1504,
6270,
8530,
8530,
8530,
401,
2071,
8530,
8530,
63,
21473,
272,
408,
272,
2670,
626,
314,
574,
402,
314,
2013,
1504,
883,
506,
5737,
465,
2774,
13,
24,
272,
408,
272,
367,
3421,
12,
574,
315,
2777,
14,
1661,
955,
8,
955,
304,
267,
862,
26,
288,
574,
14,
2708,
480,
1624,
13,
24,
531,
267,
871,
18965,
26,
288,
2777,
14,
409,
63,
3197,
480,
3364,
2774,
13,
24,
574,
315,
901,
450,
83,
2,
450,
334,
3124,
59,
16,
2459,
421,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
199,
3,
961,
570,
365,
1777,
402,
12235,
14,
199,
3,
1898,
334,
35,
9,
6171,
24354,
14,
199,
3,
199,
3,
12235,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
199,
3,
2811,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
199,
3,
3267,
701,
314,
2868,
2290,
2752,
27,
1902,
1015,
499,
402,
314,
199,
3,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
12235,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
1325,
199,
3,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
1664,
199,
3,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
3,
3180,
543,
12235,
27,
340,
440,
12,
2218,
370,
314,
2868,
2290,
2752,
12,
3277,
2020,
199,
3,
8155,
15630,
10902,
12,
14453,
13540,
12,
8226,
12,
4828,
15673,
13,
13421,
12,
8217,
14,
199,
199,
624,
11349,
367,
1686,
2774,
13,
24,
7907,
408,
199,
199,
318,
1104,
63,
3059,
8,
3059,
12,
1504,
6270,
8530,
8530,
8530,
401,
2071,
8530,
8530,
63,
21473,
272,
408,
272,
2670,
626,
314,
574,
402,
314,
2013,
1504,
883,
506,
5737,
465,
2774,
13,
24,
272,
408,
272,
367,
3421,
12,
574,
315,
2777,
14,
1661,
955,
8,
955,
304,
267,
862,
26,
288,
574,
14,
2708,
480,
1624,
13,
24,
531,
267,
871,
18965,
26,
288,
2777,
14,
409,
63,
3197,
480,
3364,
2774,
13,
24,
574,
315,
901,
450,
83,
2,
450,
334,
3124,
59,
16,
2459,
421,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
rodelrod/putsches
|
askbot/migrations/0062_transplant_question_closed_fields.py
|
17
|
28169
|
# encoding: utf-8
import datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models
class Migration(SchemaMigration):
def forwards(self, orm):
# Adding field 'Thread.closed'
db.add_column('askbot_thread', 'closed', self.gf('django.db.models.fields.BooleanField')(default=False), keep_default=False)
# Adding field 'Thread.closed_by'
db.add_column('askbot_thread', 'closed_by', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['auth.User'], null=True, blank=True), keep_default=False)
# Adding field 'Thread.closed_at'
db.add_column('askbot_thread', 'closed_at', self.gf('django.db.models.fields.DateTimeField')(null=True, blank=True), keep_default=False)
# Adding field 'Thread.close_reason'
db.add_column('askbot_thread', 'close_reason', self.gf('django.db.models.fields.SmallIntegerField')(null=True, blank=True), keep_default=False)
def backwards(self, orm):
# Deleting field 'Thread.closed'
db.delete_column('askbot_thread', 'closed')
# Deleting field 'Thread.closed_by'
db.delete_column('askbot_thread', 'closed_by_id')
# Deleting field 'Thread.closed_at'
db.delete_column('askbot_thread', 'closed_at')
# Deleting field 'Thread.close_reason'
db.delete_column('askbot_thread', 'close_reason')
models = {
'askbot.activity': {
'Meta': {'object_name': 'Activity', 'db_table': "u'activity'"},
'active_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'activity_type': ('django.db.models.fields.SmallIntegerField', [], {}),
'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'is_auditted': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'object_id': ('django.db.models.fields.PositiveIntegerField', [], {}),
'question': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['askbot.Question']", 'null': 'True'}),
'receiving_users': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'received_activity'", 'symmetrical': 'False', 'to': "orm['auth.User']"}),
'recipients': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'incoming_activity'", 'symmetrical': 'False', 'through': "orm['askbot.ActivityAuditStatus']", 'to': "orm['auth.User']"}),
'summary': ('django.db.models.fields.TextField', [], {'default': "''"}),
'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"})
},
'askbot.activityauditstatus': {
'Meta': {'unique_together': "(('user', 'activity'),)", 'object_name': 'ActivityAuditStatus'},
'activity': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['askbot.Activity']"}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'status': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'}),
'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"})
},
'askbot.anonymousanswer': {
'Meta': {'object_name': 'AnonymousAnswer'},
'added_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'author': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']", 'null': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'ip_addr': ('django.db.models.fields.IPAddressField', [], {'max_length': '15'}),
'question': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'anonymous_answers'", 'to': "orm['askbot.Question']"}),
'session_key': ('django.db.models.fields.CharField', [], {'max_length': '40'}),
'summary': ('django.db.models.fields.CharField', [], {'max_length': '180'}),
'text': ('django.db.models.fields.TextField', [], {}),
'wiki': ('django.db.models.fields.BooleanField', [], {'default': 'False'})
},
'askbot.anonymousquestion': {
'Meta': {'object_name': 'AnonymousQuestion'},
'added_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'author': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']", 'null': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'ip_addr': ('django.db.models.fields.IPAddressField', [], {'max_length': '15'}),
'is_anonymous': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'session_key': ('django.db.models.fields.CharField', [], {'max_length': '40'}),
'summary': ('django.db.models.fields.CharField', [], {'max_length': '180'}),
'tagnames': ('django.db.models.fields.CharField', [], {'max_length': '125'}),
'text': ('django.db.models.fields.TextField', [], {}),
'title': ('django.db.models.fields.CharField', [], {'max_length': '300'}),
'wiki': ('django.db.models.fields.BooleanField', [], {'default': 'False'})
},
'askbot.answer': {
'Meta': {'object_name': 'Answer', 'db_table': "u'answer'"},
'accepted': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'accepted_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
'added_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'author': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'answers'", 'to': "orm['auth.User']"}),
'comment_count': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
'deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'deleted_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
'deleted_by': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'deleted_answers'", 'null': 'True', 'to': "orm['auth.User']"}),
'html': ('django.db.models.fields.TextField', [], {'null': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'last_edited_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
'last_edited_by': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'last_edited_answers'", 'null': 'True', 'to': "orm['auth.User']"}),
'locked': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'locked_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
'locked_by': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'locked_answers'", 'null': 'True', 'to': "orm['auth.User']"}),
'offensive_flag_count': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'}),
'question': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'answers'", 'to': "orm['askbot.Question']"}),
'score': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
'text': ('django.db.models.fields.TextField', [], {'null': 'True'}),
'vote_down_count': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
'vote_up_count': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
'wiki': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'wikified_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'})
},
'askbot.award': {
'Meta': {'object_name': 'Award', 'db_table': "u'award'"},
'awarded_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'badge': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'award_badge'", 'to': "orm['askbot.BadgeData']"}),
'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'notified': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'object_id': ('django.db.models.fields.PositiveIntegerField', [], {}),
'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'award_user'", 'to': "orm['auth.User']"})
},
'askbot.badgedata': {
'Meta': {'ordering': "('slug',)", 'object_name': 'BadgeData'},
'awarded_count': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
'awarded_to': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'badges'", 'symmetrical': 'False', 'through': "orm['askbot.Award']", 'to': "orm['auth.User']"}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'slug': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '50', 'db_index': 'True'})
},
'askbot.comment': {
'Meta': {'ordering': "('-added_at',)", 'object_name': 'Comment', 'db_table': "u'comment'"},
'added_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'comment': ('django.db.models.fields.CharField', [], {'max_length': '2048'}),
'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
'html': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '2048'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'object_id': ('django.db.models.fields.PositiveIntegerField', [], {}),
'offensive_flag_count': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
'score': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'comments'", 'to': "orm['auth.User']"})
},
'askbot.emailfeedsetting': {
'Meta': {'object_name': 'EmailFeedSetting'},
'added_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'feed_type': ('django.db.models.fields.CharField', [], {'max_length': '16'}),
'frequency': ('django.db.models.fields.CharField', [], {'default': "'n'", 'max_length': '8'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'reported_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}),
'subscriber': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'notification_subscriptions'", 'to': "orm['auth.User']"})
},
'askbot.favoritequestion': {
'Meta': {'object_name': 'FavoriteQuestion', 'db_table': "u'favorite_question'"},
'added_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'question': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['askbot.Question']"}),
'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'user_favorite_questions'", 'to': "orm['auth.User']"})
},
'askbot.markedtag': {
'Meta': {'object_name': 'MarkedTag'},
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'reason': ('django.db.models.fields.CharField', [], {'max_length': '16'}),
'tag': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'user_selections'", 'to': "orm['askbot.Tag']"}),
'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'tag_selections'", 'to': "orm['auth.User']"})
},
'askbot.postrevision': {
'Meta': {'ordering': "('-revision',)", 'unique_together': "(('answer', 'revision'), ('question', 'revision'))", 'object_name': 'PostRevision'},
'answer': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'revisions'", 'null': 'True', 'to': "orm['askbot.Answer']"}),
'author': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'postrevisions'", 'to': "orm['auth.User']"}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'is_anonymous': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'question': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'revisions'", 'null': 'True', 'to': "orm['askbot.Question']"}),
'revised_at': ('django.db.models.fields.DateTimeField', [], {}),
'revision': ('django.db.models.fields.PositiveIntegerField', [], {}),
'revision_type': ('django.db.models.fields.SmallIntegerField', [], {}),
'summary': ('django.db.models.fields.CharField', [], {'max_length': '300', 'blank': 'True'}),
'tagnames': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '125', 'blank': 'True'}),
'text': ('django.db.models.fields.TextField', [], {}),
'title': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '300', 'blank': 'True'})
},
'askbot.question': {
'Meta': {'object_name': 'Question', 'db_table': "u'question'"},
'added_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'answer_accepted': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'author': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'questions'", 'to': "orm['auth.User']"}),
'close_reason': ('django.db.models.fields.SmallIntegerField', [], {'null': 'True', 'blank': 'True'}),
'closed': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'closed_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
'closed_by': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'closed_questions'", 'null': 'True', 'to': "orm['auth.User']"}),
'comment_count': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
'deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'deleted_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
'deleted_by': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'deleted_questions'", 'null': 'True', 'to': "orm['auth.User']"}),
'favorited_by': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'favorite_questions'", 'symmetrical': 'False', 'through': "orm['askbot.FavoriteQuestion']", 'to': "orm['auth.User']"}),
'followed_by': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'followed_questions'", 'symmetrical': 'False', 'to': "orm['auth.User']"}),
'html': ('django.db.models.fields.TextField', [], {'null': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'is_anonymous': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'last_activity_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'last_activity_by': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'last_active_in_questions'", 'to': "orm['auth.User']"}),
'last_edited_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
'last_edited_by': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'last_edited_questions'", 'null': 'True', 'to': "orm['auth.User']"}),
'locked': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'locked_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
'locked_by': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'locked_questions'", 'null': 'True', 'to': "orm['auth.User']"}),
'offensive_flag_count': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'}),
'score': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
'summary': ('django.db.models.fields.CharField', [], {'max_length': '180'}),
'tagnames': ('django.db.models.fields.CharField', [], {'max_length': '125'}),
'tags': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'questions'", 'symmetrical': 'False', 'to': "orm['askbot.Tag']"}),
'text': ('django.db.models.fields.TextField', [], {'null': 'True'}),
'thread': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'questions'", 'unique': 'True', 'to': "orm['askbot.Thread']"}),
'title': ('django.db.models.fields.CharField', [], {'max_length': '300'}),
'vote_down_count': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
'vote_up_count': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
'wiki': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'wikified_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'})
},
'askbot.questionview': {
'Meta': {'object_name': 'QuestionView'},
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'question': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'viewed'", 'to': "orm['askbot.Question']"}),
'when': ('django.db.models.fields.DateTimeField', [], {}),
'who': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'question_views'", 'to': "orm['auth.User']"})
},
'askbot.repute': {
'Meta': {'object_name': 'Repute', 'db_table': "u'repute'"},
'comment': ('django.db.models.fields.CharField', [], {'max_length': '128', 'null': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'negative': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'}),
'positive': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'}),
'question': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['askbot.Question']", 'null': 'True', 'blank': 'True'}),
'reputation': ('django.db.models.fields.IntegerField', [], {'default': '1'}),
'reputation_type': ('django.db.models.fields.SmallIntegerField', [], {}),
'reputed_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"})
},
'askbot.tag': {
'Meta': {'ordering': "('-used_count', 'name')", 'object_name': 'Tag', 'db_table': "u'tag'"},
'created_by': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'created_tags'", 'to': "orm['auth.User']"}),
'deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'deleted_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
'deleted_by': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'deleted_tags'", 'null': 'True', 'to': "orm['auth.User']"}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
'used_count': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'})
},
'askbot.thread': {
'Meta': {'object_name': 'Thread'},
'answer_count': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
'close_reason': ('django.db.models.fields.SmallIntegerField', [], {'null': 'True', 'blank': 'True'}),
'closed': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'closed_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
'closed_by': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']", 'null': 'True', 'blank': 'True'}),
'favourite_count': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'view_count': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'})
},
'askbot.vote': {
'Meta': {'unique_together': "(('content_type', 'object_id', 'user'),)", 'object_name': 'Vote', 'db_table': "u'vote'"},
'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'object_id': ('django.db.models.fields.PositiveIntegerField', [], {}),
'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'votes'", 'to': "orm['auth.User']"}),
'vote': ('django.db.models.fields.SmallIntegerField', [], {}),
'voted_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'})
},
'auth.group': {
'Meta': {'object_name': 'Group'},
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
},
'auth.permission': {
'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
},
'auth.user': {
'Meta': {'object_name': 'User'},
'about': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
'avatar_type': ('django.db.models.fields.CharField', [], {'default': "'n'", 'max_length': '1'}),
'bronze': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'}),
'consecutive_days_visit_count': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
'country': ('django_countries.fields.CountryField', [], {'max_length': '2', 'blank': 'True'}),
'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'date_of_birth': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}),
'display_tag_filter_strategy': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'}),
'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
'email_isvalid': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'email_key': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True'}),
'email_tag_filter_strategy': ('django.db.models.fields.SmallIntegerField', [], {'default': '1'}),
'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
'gold': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'}),
'gravatar': ('django.db.models.fields.CharField', [], {'max_length': '32'}),
'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'ignored_tags': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
'interesting_tags': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
'last_seen': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'location': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}),
'new_response_count': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
'questions_per_page': ('django.db.models.fields.SmallIntegerField', [], {'default': '10'}),
'real_name': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}),
'reputation': ('django.db.models.fields.PositiveIntegerField', [], {'default': '1'}),
'seen_response_count': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
'show_country': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'silver': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'}),
'status': ('django.db.models.fields.CharField', [], {'default': "'w'", 'max_length': '2'}),
'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}),
'website': ('django.db.models.fields.URLField', [], {'max_length': '200', 'blank': 'True'})
},
'contenttypes.contenttype': {
'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
}
}
complete_apps = ['askbot']
|
gpl-3.0
|
[
3,
2644,
26,
2774,
13,
24,
199,
646,
2197,
199,
504,
12919,
14,
697,
492,
1592,
199,
504,
12919,
14,
86,
18,
492,
24765,
199,
504,
1639,
14,
697,
492,
1709,
199,
199,
533,
12090,
8,
24822,
304,
339,
347,
17465,
8,
277,
12,
9813,
304,
2728,
327,
12934,
901,
283,
4436,
14,
5938,
7,
267,
1592,
14,
525,
63,
2301,
360,
20963,
63,
2671,
297,
283,
5938,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
5036,
7533,
885,
29,
797,
395,
4215,
63,
885,
29,
797,
9,
398,
327,
12934,
901,
283,
4436,
14,
5938,
63,
991,
7,
267,
1592,
14,
525,
63,
2301,
360,
20963,
63,
2671,
297,
283,
5938,
63,
991,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
3190,
7533,
475,
29,
1025,
459,
1178,
14,
1899,
995,
2973,
29,
549,
12,
4596,
29,
549,
395,
4215,
63,
885,
29,
797,
9,
398,
327,
12934,
901,
283,
4436,
14,
5938,
63,
292,
7,
267,
1592,
14,
525,
63,
2301,
360,
20963,
63,
2671,
297,
283,
5938,
63,
292,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
4626,
7533,
2307,
29,
549,
12,
4596,
29,
549,
395,
4215,
63,
885,
29,
797,
9,
398,
327,
12934,
901,
283,
4436,
14,
1600,
63,
5764,
7,
267,
1592,
14,
525,
63,
2301,
360,
20963,
63,
2671,
297,
283,
1600,
63,
5764,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
14640,
7533,
2307,
29,
549,
12,
4596,
29,
549,
395,
4215,
63,
885,
29,
797,
9,
2378,
347,
8552,
8,
277,
12,
9813,
304,
2728,
327,
15920,
901,
283,
4436,
14,
5938,
7,
267,
1592,
14,
1807,
63,
2301,
360,
20963,
63,
2671,
297,
283,
5938,
358,
398,
327,
15920,
901,
283,
4436,
14,
5938,
63,
991,
7,
267,
1592,
14,
1807,
63,
2301,
360,
20963,
63,
2671,
297,
283,
5938,
63,
991,
63,
344,
358,
398,
327,
15920,
901,
283,
4436,
14,
5938,
63,
292,
7,
267,
1592,
14,
1807,
63,
2301,
360,
20963,
63,
2671,
297,
283,
5938,
63,
292,
358,
398,
327,
15920,
901,
283,
4436,
14,
1600,
63,
5764,
7,
267,
1592,
14,
1807,
63,
2301,
360,
20963,
63,
2671,
297,
283,
1600,
63,
5764,
358,
2378,
1709,
275,
469,
267,
283,
20963,
14,
8240,
356,
469,
288,
283,
3396,
356,
791,
785,
63,
354,
356,
283,
14350,
297,
283,
697,
63,
1224,
356,
298,
85,
7,
8240,
15208,
288,
283,
2682,
63,
292,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
4626,
297,
990,
791,
885,
356,
283,
2083,
14,
2083,
14,
2131,
1604,
288,
283,
8240,
63,
466,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
14640,
297,
990,
8613,
288,
283,
1317,
63,
466,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
3190,
297,
990,
791,
475,
356,
298,
1025,
459,
10778,
14,
11282,
6097,
288,
283,
344,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
4378,
297,
990,
791,
3327,
63,
498,
356,
283,
549,
1604,
288,
283,
374,
63,
14274,
471,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
5036,
297,
990,
791,
885,
356,
283,
797,
1604,
288,
283,
785,
63,
344,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
8591,
297,
990,
8613,
288,
283,
4790,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
3190,
297,
990,
791,
475,
356,
298,
1025,
459,
20963,
14,
16778,
6256,
283,
2307,
356,
283,
549,
1604,
288,
283,
24890,
316,
63,
3707,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
7624,
297,
990,
791,
2407,
63,
354,
356,
3546,
9226,
63,
8240,
4662,
283,
10247,
356,
283,
797,
297,
283,
475,
356,
298,
1025,
459,
1178,
14,
1899,
6097,
288,
283,
18323,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
7624,
297,
990,
791,
2407,
63,
354,
356,
3546,
15994,
63,
8240,
4662,
283,
10247,
356,
283,
797,
297,
283,
8304,
356,
298,
1025,
459,
20963,
14,
14350,
23601,
3694,
6256,
283,
475,
356,
298,
1025,
459,
1178,
14,
1899,
6097,
288,
283,
4705,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
6254,
297,
990,
791,
885,
356,
17172,
5593,
288,
283,
751,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
3190,
297,
990,
791,
475,
356,
298,
1025,
459,
1178,
14,
1899,
13687,
267,
1660,
267,
283,
20963,
14,
8240,
14274,
1205,
356,
469,
288,
283,
3396,
356,
791,
3235,
63,
6314,
356,
9510,
751,
297,
283,
8240,
9878,
283,
785,
63,
354,
356,
283,
14350,
23601,
3694,
2267,
288,
283,
8240,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
3190,
297,
990,
791,
475,
356,
298,
1025,
459,
20963,
14,
14350,
6097,
288,
283,
344,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
4378,
297,
990,
791,
3327,
63,
498,
356,
283,
549,
1604,
288,
283,
1205,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
14640,
297,
990,
791,
885,
356,
283,
16,
1604,
288,
283,
751,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
3190,
297,
990,
791,
475,
356,
298,
1025,
459,
1178,
14,
1899,
13687,
267,
1660,
267,
283,
20963,
14,
12628,
5934,
356,
469,
288,
283,
3396,
356,
791,
785,
63,
354,
356,
283,
23902,
19104,
2267,
288,
283,
3270,
63,
292,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
4626,
297,
990,
791,
885,
356,
283,
2083,
14,
2083,
14,
2131,
1604,
288,
283,
2502,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
3190,
297,
990,
791,
475,
356,
298,
1025,
459,
1178,
14,
1899,
6256,
283,
2307,
356,
283,
549,
1604,
288,
283,
344,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
4378,
297,
990,
791,
3327,
63,
498,
356,
283,
549,
1604,
288,
283,
711,
63,
2697,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
26969,
297,
990,
791,
988,
63,
1267,
356,
283,
1046,
1604,
288,
283,
4790,
356,
661
] |
[
2644,
26,
2774,
13,
24,
199,
646,
2197,
199,
504,
12919,
14,
697,
492,
1592,
199,
504,
12919,
14,
86,
18,
492,
24765,
199,
504,
1639,
14,
697,
492,
1709,
199,
199,
533,
12090,
8,
24822,
304,
339,
347,
17465,
8,
277,
12,
9813,
304,
2728,
327,
12934,
901,
283,
4436,
14,
5938,
7,
267,
1592,
14,
525,
63,
2301,
360,
20963,
63,
2671,
297,
283,
5938,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
5036,
7533,
885,
29,
797,
395,
4215,
63,
885,
29,
797,
9,
398,
327,
12934,
901,
283,
4436,
14,
5938,
63,
991,
7,
267,
1592,
14,
525,
63,
2301,
360,
20963,
63,
2671,
297,
283,
5938,
63,
991,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
3190,
7533,
475,
29,
1025,
459,
1178,
14,
1899,
995,
2973,
29,
549,
12,
4596,
29,
549,
395,
4215,
63,
885,
29,
797,
9,
398,
327,
12934,
901,
283,
4436,
14,
5938,
63,
292,
7,
267,
1592,
14,
525,
63,
2301,
360,
20963,
63,
2671,
297,
283,
5938,
63,
292,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
4626,
7533,
2307,
29,
549,
12,
4596,
29,
549,
395,
4215,
63,
885,
29,
797,
9,
398,
327,
12934,
901,
283,
4436,
14,
1600,
63,
5764,
7,
267,
1592,
14,
525,
63,
2301,
360,
20963,
63,
2671,
297,
283,
1600,
63,
5764,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
14640,
7533,
2307,
29,
549,
12,
4596,
29,
549,
395,
4215,
63,
885,
29,
797,
9,
2378,
347,
8552,
8,
277,
12,
9813,
304,
2728,
327,
15920,
901,
283,
4436,
14,
5938,
7,
267,
1592,
14,
1807,
63,
2301,
360,
20963,
63,
2671,
297,
283,
5938,
358,
398,
327,
15920,
901,
283,
4436,
14,
5938,
63,
991,
7,
267,
1592,
14,
1807,
63,
2301,
360,
20963,
63,
2671,
297,
283,
5938,
63,
991,
63,
344,
358,
398,
327,
15920,
901,
283,
4436,
14,
5938,
63,
292,
7,
267,
1592,
14,
1807,
63,
2301,
360,
20963,
63,
2671,
297,
283,
5938,
63,
292,
358,
398,
327,
15920,
901,
283,
4436,
14,
1600,
63,
5764,
7,
267,
1592,
14,
1807,
63,
2301,
360,
20963,
63,
2671,
297,
283,
1600,
63,
5764,
358,
2378,
1709,
275,
469,
267,
283,
20963,
14,
8240,
356,
469,
288,
283,
3396,
356,
791,
785,
63,
354,
356,
283,
14350,
297,
283,
697,
63,
1224,
356,
298,
85,
7,
8240,
15208,
288,
283,
2682,
63,
292,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
4626,
297,
990,
791,
885,
356,
283,
2083,
14,
2083,
14,
2131,
1604,
288,
283,
8240,
63,
466,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
14640,
297,
990,
8613,
288,
283,
1317,
63,
466,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
3190,
297,
990,
791,
475,
356,
298,
1025,
459,
10778,
14,
11282,
6097,
288,
283,
344,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
4378,
297,
990,
791,
3327,
63,
498,
356,
283,
549,
1604,
288,
283,
374,
63,
14274,
471,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
5036,
297,
990,
791,
885,
356,
283,
797,
1604,
288,
283,
785,
63,
344,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
8591,
297,
990,
8613,
288,
283,
4790,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
3190,
297,
990,
791,
475,
356,
298,
1025,
459,
20963,
14,
16778,
6256,
283,
2307,
356,
283,
549,
1604,
288,
283,
24890,
316,
63,
3707,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
7624,
297,
990,
791,
2407,
63,
354,
356,
3546,
9226,
63,
8240,
4662,
283,
10247,
356,
283,
797,
297,
283,
475,
356,
298,
1025,
459,
1178,
14,
1899,
6097,
288,
283,
18323,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
7624,
297,
990,
791,
2407,
63,
354,
356,
3546,
15994,
63,
8240,
4662,
283,
10247,
356,
283,
797,
297,
283,
8304,
356,
298,
1025,
459,
20963,
14,
14350,
23601,
3694,
6256,
283,
475,
356,
298,
1025,
459,
1178,
14,
1899,
6097,
288,
283,
4705,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
6254,
297,
990,
791,
885,
356,
17172,
5593,
288,
283,
751,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
3190,
297,
990,
791,
475,
356,
298,
1025,
459,
1178,
14,
1899,
13687,
267,
1660,
267,
283,
20963,
14,
8240,
14274,
1205,
356,
469,
288,
283,
3396,
356,
791,
3235,
63,
6314,
356,
9510,
751,
297,
283,
8240,
9878,
283,
785,
63,
354,
356,
283,
14350,
23601,
3694,
2267,
288,
283,
8240,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
3190,
297,
990,
791,
475,
356,
298,
1025,
459,
20963,
14,
14350,
6097,
288,
283,
344,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
4378,
297,
990,
791,
3327,
63,
498,
356,
283,
549,
1604,
288,
283,
1205,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
14640,
297,
990,
791,
885,
356,
283,
16,
1604,
288,
283,
751,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
3190,
297,
990,
791,
475,
356,
298,
1025,
459,
1178,
14,
1899,
13687,
267,
1660,
267,
283,
20963,
14,
12628,
5934,
356,
469,
288,
283,
3396,
356,
791,
785,
63,
354,
356,
283,
23902,
19104,
2267,
288,
283,
3270,
63,
292,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
4626,
297,
990,
791,
885,
356,
283,
2083,
14,
2083,
14,
2131,
1604,
288,
283,
2502,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
3190,
297,
990,
791,
475,
356,
298,
1025,
459,
1178,
14,
1899,
6256,
283,
2307,
356,
283,
549,
1604,
288,
283,
344,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
4378,
297,
990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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
Shrulik/Open-Knesset
|
mks/admin.py
|
7
|
3764
|
from django.contrib import admin
from django.contrib.contenttypes import generic
from django.db.models import Q
from models import Member, Membership, MemberAltname
from models import CoalitionMembership, Correlation, Party, \
Award, AwardType, Knesset
from links.models import Link
from video.models import Video
from persons.models import Person
class MembershipInline(admin.TabularInline):
model = Membership
extra = 1
class MemberLinksInline(generic.GenericTabularInline):
model = Link
ct_fk_field = 'object_pk'
extra = 1
class MemberAltnameInline(admin.TabularInline):
model = MemberAltname
extra = 1
class MemberPersonInline(admin.StackedInline):
model = Person
ct_fk_field = "mk"
extra = 0
max_num = 0
fields = ['calendar_url']
can_delete = False
class MemberRelatedVideosInline(generic.GenericTabularInline):
model = Video
ct_fk_field = 'object_pk'
can_delete = False
fields = ['title', 'description', 'embed_link', 'group', 'sticky', 'hide']
ordering = ['group', '-sticky', '-published']
readonly_fields = ['title', 'description', 'embed_link', 'group']
extra = 0
def queryset(self, request):
qs = super(MemberRelatedVideosInline, self).queryset(request)
qs = qs.filter(Q(hide=False) | Q(hide=None))
return qs
class CoalitionMembershipAdmin(admin.ModelAdmin):
list_display = ('party', 'start_date', 'end_date')
admin.site.register(CoalitionMembership, CoalitionMembershipAdmin)
class PartyAdmin(admin.ModelAdmin):
ordering = ('name',)
list_display = ('name', 'knesset', 'start_date', 'end_date',
'is_coalition', 'number_of_members',
'number_of_seats')
list_filter = ('knesset', )
inlines = (MembershipInline,)
admin.site.register(Party, PartyAdmin)
class MemberAdmin(admin.ModelAdmin):
ordering = ('name',)
# fields = ('name','start_date','end_date')
list_display = ('name', 'gender', 'PartiesString', 'current_party',
'is_current', 'current_position')
list_editable = ('is_current', 'current_position')
search_fields = ['name']
inlines = (MembershipInline, MemberLinksInline, MemberAltnameInline, MemberPersonInline,
MemberRelatedVideosInline)
list_filter = ('current_party__knesset', 'gender')
# A template for a very customized change view:
change_form_template = 'admin/simple/change_form_with_extra.html'
def change_view(self, request, object_id, extra_context=None):
m = Member.objects.get(id=object_id)
my_context = {
'extra': {
'hi_corr': m.CorrelationListToString(m.HighestCorrelations()),
'low_corr': m.CorrelationListToString(m.LowestCorrelations()),
}
}
return super(MemberAdmin, self).change_view(request, object_id,
extra_context=my_context)
def queryset(self, request):
return super(MemberAdmin, self).queryset(
request).select_related('current_party')
admin.site.register(Member, MemberAdmin)
class CorrelationAdmin(admin.ModelAdmin):
ordering = ('-normalized_score',)
admin.site.register(Correlation, CorrelationAdmin)
class MembershipAdmin(admin.ModelAdmin):
ordering = ('member__name',)
admin.site.register(Membership, MembershipAdmin)
class AwardTypeAdmin(admin.ModelAdmin):
pass
admin.site.register(AwardType, AwardTypeAdmin)
class AwardAdmin(admin.ModelAdmin):
list_display = ('member', 'award_type', 'date_given')
raw_id_fields = ('member',)
admin.site.register(Award, AwardAdmin)
class KnessetAdmin(admin.ModelAdmin):
pass
admin.site.register(Knesset, KnessetAdmin)
|
bsd-3-clause
|
[
504,
1639,
14,
2828,
492,
4628,
199,
504,
1639,
14,
2828,
14,
10778,
492,
7809,
199,
504,
1639,
14,
697,
14,
992,
492,
1413,
199,
199,
504,
1709,
492,
14409,
12,
24326,
12,
14409,
16985,
354,
199,
504,
1709,
492,
1849,
10874,
296,
19480,
12,
7499,
5690,
12,
2235,
369,
12,
971,
272,
437,
3079,
12,
437,
3079,
804,
12,
1804,
17775,
409,
199,
504,
6220,
14,
992,
492,
10967,
199,
504,
3991,
14,
992,
492,
15709,
199,
504,
12103,
14,
992,
492,
8028,
421,
199,
533,
24326,
10307,
8,
2113,
14,
30187,
10307,
304,
272,
1402,
275,
24326,
272,
2402,
275,
413,
421,
199,
533,
14409,
16974,
10307,
8,
6767,
14,
9417,
30187,
10307,
304,
272,
1402,
275,
10967,
272,
9428,
63,
9010,
63,
698,
275,
283,
785,
63,
2051,
7,
272,
2402,
275,
413,
421,
199,
533,
14409,
16985,
354,
10307,
8,
2113,
14,
30187,
10307,
304,
272,
1402,
275,
14409,
16985,
354,
272,
2402,
275,
413,
421,
199,
533,
14409,
7344,
10307,
8,
2113,
14,
4851,
379,
10307,
304,
272,
1402,
275,
8028,
272,
9428,
63,
9010,
63,
698,
275,
298,
3880,
2,
272,
2402,
275,
378,
272,
1390,
63,
1507,
275,
378,
272,
1504,
275,
788,
8183,
63,
633,
418,
272,
883,
63,
1807,
275,
756,
421,
199,
533,
14409,
13885,
2201,
18808,
10307,
8,
6767,
14,
9417,
30187,
10307,
304,
272,
1402,
275,
15709,
272,
9428,
63,
9010,
63,
698,
275,
283,
785,
63,
2051,
7,
272,
883,
63,
1807,
275,
756,
272,
1504,
275,
788,
1213,
297,
283,
1802,
297,
283,
6427,
63,
1073,
297,
283,
923,
297,
283,
27364,
297,
283,
8191,
418,
272,
7794,
275,
788,
923,
297,
2475,
27364,
297,
2475,
8987,
418,
272,
6863,
63,
955,
275,
788,
1213,
297,
283,
1802,
297,
283,
6427,
63,
1073,
297,
283,
923,
418,
272,
2402,
275,
378,
339,
347,
7594,
8,
277,
12,
1056,
304,
267,
6377,
275,
1613,
8,
7021,
13885,
2201,
18808,
10307,
12,
291,
680,
7924,
8,
1069,
9,
267,
6377,
275,
6377,
14,
1541,
8,
49,
8,
8191,
29,
797,
9,
1204,
1413,
8,
8191,
29,
403,
430,
267,
372,
6377,
421,
199,
533,
1849,
10874,
296,
19480,
4880,
8,
2113,
14,
12976,
304,
272,
769,
63,
2918,
275,
661,
7522,
297,
283,
928,
63,
602,
297,
283,
500,
63,
602,
358,
199,
2113,
14,
2124,
14,
2683,
8,
967,
10874,
296,
19480,
12,
1849,
10874,
296,
19480,
4880,
9,
421,
199,
533,
2235,
369,
4880,
8,
2113,
14,
12976,
304,
272,
7794,
275,
661,
354,
9538,
272,
769,
63,
2918,
275,
661,
354,
297,
283,
75,
17775,
409,
297,
283,
928,
63,
602,
297,
283,
500,
63,
602,
297,
490,
283,
374,
63,
331,
10874,
296,
297,
283,
1955,
63,
1618,
63,
6334,
297,
490,
283,
1955,
63,
1618,
63,
261,
1956,
358,
272,
769,
63,
1541,
275,
661,
75,
17775,
409,
297,
776,
272,
29177,
275,
334,
19480,
10307,
4258,
199,
2113,
14,
2124,
14,
2683,
8,
25233,
12,
2235,
369,
4880,
9,
421,
199,
533,
14409,
4880,
8,
2113,
14,
12976,
304,
272,
7794,
275,
661,
354,
9538,
199,
3,
259,
1504,
275,
661,
354,
1673,
928,
63,
602,
1673,
500,
63,
602,
358,
272,
769,
63,
2918,
275,
661,
354,
297,
283,
15791,
297,
283,
1262,
1417,
1558,
297,
283,
1818,
63,
7522,
297,
490,
283,
374,
63,
1818,
297,
283,
1818,
63,
3124,
358,
272,
769,
63,
10820,
275,
661,
374,
63,
1818,
297,
283,
1818,
63,
3124,
358,
272,
2754,
63,
955,
275,
788,
354,
418,
272,
29177,
275,
334,
19480,
10307,
12,
14409,
16974,
10307,
12,
14409,
16985,
354,
10307,
12,
14409,
7344,
10307,
12,
2049,
14409,
13885,
2201,
18808,
10307,
9,
272,
769,
63,
1541,
275,
661,
1818,
63,
7522,
363,
75,
17775,
409,
297,
283,
15791,
358,
339,
327,
437,
1978,
367,
282,
7437,
26707,
1570,
2455,
26,
272,
1570,
63,
964,
63,
1160,
275,
283,
2113,
15,
4129,
15,
1461,
63,
964,
63,
1045,
63,
2911,
14,
1360,
7,
339,
347,
1570,
63,
1345,
8,
277,
12,
1056,
12,
909,
63,
344,
12,
2402,
63,
1100,
29,
403,
304,
267,
333,
275,
14409,
14,
1462,
14,
362,
8,
344,
29,
785,
63,
344,
9,
267,
3002,
63,
1100,
275,
469,
288,
283,
2911,
356,
469,
355,
283,
5812,
63,
16742,
356,
333,
14,
8380,
5690,
1296,
7756,
8,
77,
14,
40,
12527,
8380,
15741,
4000,
355,
283,
674,
63,
16742,
356,
333,
14,
8380,
5690,
1296,
7756,
8,
77,
14,
10281,
597,
8380,
15741,
4000,
288,
789,
267,
789,
267,
372,
1613,
8,
7021,
4880,
12,
291,
680,
1461,
63,
1345,
8,
1069,
12,
909,
63,
344,
12,
8105,
2402,
63,
1100,
29,
1662,
63,
1100,
9,
339,
347,
7594,
8,
277,
12,
1056,
304,
267,
372,
1613,
8,
7021,
4880,
12,
291,
680,
7924,
8,
288,
1056,
680,
2416,
63,
2407,
360,
1818,
63,
7522,
358,
199,
2113,
14,
2124,
14,
2683,
8,
7021,
12,
14409,
4880,
9,
421,
199,
533,
7499,
5690,
4880,
8,
2113,
14,
12976,
304,
272,
7794,
275,
12291,
12916,
63,
3397,
9538,
199,
2113,
14,
2124,
14,
2683,
8,
8380,
5690,
12,
7499,
5690,
4880,
9,
421,
199,
533,
24326,
4880,
8,
2113,
14,
12976,
304,
272,
7794,
275,
661,
1114,
363,
354,
9538,
199,
2113,
14,
2124,
14,
2683,
8,
19480,
12,
24326,
4880,
9,
421,
199,
533,
437,
3079,
804,
4880,
8,
2113,
14,
12976,
304,
272,
986,
199,
2113,
14,
2124,
14,
2683,
8,
33,
3079,
804,
12,
437,
3079,
804,
4880,
9,
421,
199,
533,
437,
3079,
4880,
8,
2113,
14,
12976,
304,
272,
769,
63,
2918,
275,
661,
1114,
297,
283,
65,
3079,
63,
466,
297,
283,
602,
63,
11809,
358,
272,
3066,
63,
344,
63,
955,
275,
661,
1114,
9538,
199,
2113,
14,
2124,
14,
2683,
8,
33,
3079,
12,
437,
3079,
4880,
9,
421,
199,
533,
1804,
17775,
409,
4880,
8,
2113,
14,
12976,
304,
272,
986,
199,
2113,
14,
2124,
14,
2683,
8,
43,
17775,
409,
12,
1804,
17775,
409,
4880,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1639,
14,
2828,
492,
4628,
199,
504,
1639,
14,
2828,
14,
10778,
492,
7809,
199,
504,
1639,
14,
697,
14,
992,
492,
1413,
199,
199,
504,
1709,
492,
14409,
12,
24326,
12,
14409,
16985,
354,
199,
504,
1709,
492,
1849,
10874,
296,
19480,
12,
7499,
5690,
12,
2235,
369,
12,
971,
272,
437,
3079,
12,
437,
3079,
804,
12,
1804,
17775,
409,
199,
504,
6220,
14,
992,
492,
10967,
199,
504,
3991,
14,
992,
492,
15709,
199,
504,
12103,
14,
992,
492,
8028,
421,
199,
533,
24326,
10307,
8,
2113,
14,
30187,
10307,
304,
272,
1402,
275,
24326,
272,
2402,
275,
413,
421,
199,
533,
14409,
16974,
10307,
8,
6767,
14,
9417,
30187,
10307,
304,
272,
1402,
275,
10967,
272,
9428,
63,
9010,
63,
698,
275,
283,
785,
63,
2051,
7,
272,
2402,
275,
413,
421,
199,
533,
14409,
16985,
354,
10307,
8,
2113,
14,
30187,
10307,
304,
272,
1402,
275,
14409,
16985,
354,
272,
2402,
275,
413,
421,
199,
533,
14409,
7344,
10307,
8,
2113,
14,
4851,
379,
10307,
304,
272,
1402,
275,
8028,
272,
9428,
63,
9010,
63,
698,
275,
298,
3880,
2,
272,
2402,
275,
378,
272,
1390,
63,
1507,
275,
378,
272,
1504,
275,
788,
8183,
63,
633,
418,
272,
883,
63,
1807,
275,
756,
421,
199,
533,
14409,
13885,
2201,
18808,
10307,
8,
6767,
14,
9417,
30187,
10307,
304,
272,
1402,
275,
15709,
272,
9428,
63,
9010,
63,
698,
275,
283,
785,
63,
2051,
7,
272,
883,
63,
1807,
275,
756,
272,
1504,
275,
788,
1213,
297,
283,
1802,
297,
283,
6427,
63,
1073,
297,
283,
923,
297,
283,
27364,
297,
283,
8191,
418,
272,
7794,
275,
788,
923,
297,
2475,
27364,
297,
2475,
8987,
418,
272,
6863,
63,
955,
275,
788,
1213,
297,
283,
1802,
297,
283,
6427,
63,
1073,
297,
283,
923,
418,
272,
2402,
275,
378,
339,
347,
7594,
8,
277,
12,
1056,
304,
267,
6377,
275,
1613,
8,
7021,
13885,
2201,
18808,
10307,
12,
291,
680,
7924,
8,
1069,
9,
267,
6377,
275,
6377,
14,
1541,
8,
49,
8,
8191,
29,
797,
9,
1204,
1413,
8,
8191,
29,
403,
430,
267,
372,
6377,
421,
199,
533,
1849,
10874,
296,
19480,
4880,
8,
2113,
14,
12976,
304,
272,
769,
63,
2918,
275,
661,
7522,
297,
283,
928,
63,
602,
297,
283,
500,
63,
602,
358,
199,
2113,
14,
2124,
14,
2683,
8,
967,
10874,
296,
19480,
12,
1849,
10874,
296,
19480,
4880,
9,
421,
199,
533,
2235,
369,
4880,
8,
2113,
14,
12976,
304,
272,
7794,
275,
661,
354,
9538,
272,
769,
63,
2918,
275,
661,
354,
297,
283,
75,
17775,
409,
297,
283,
928,
63,
602,
297,
283,
500,
63,
602,
297,
490,
283,
374,
63,
331,
10874,
296,
297,
283,
1955,
63,
1618,
63,
6334,
297,
490,
283,
1955,
63,
1618,
63,
261,
1956,
358,
272,
769,
63,
1541,
275,
661,
75,
17775,
409,
297,
776,
272,
29177,
275,
334,
19480,
10307,
4258,
199,
2113,
14,
2124,
14,
2683,
8,
25233,
12,
2235,
369,
4880,
9,
421,
199,
533,
14409,
4880,
8,
2113,
14,
12976,
304,
272,
7794,
275,
661,
354,
9538,
199,
3,
259,
1504,
275,
661,
354,
1673,
928,
63,
602,
1673,
500,
63,
602,
358,
272,
769,
63,
2918,
275,
661,
354,
297,
283,
15791,
297,
283,
1262,
1417,
1558,
297,
283,
1818,
63,
7522,
297,
490,
283,
374,
63,
1818,
297,
283,
1818,
63,
3124,
358,
272,
769,
63,
10820,
275,
661,
374,
63,
1818,
297,
283,
1818,
63,
3124,
358,
272,
2754,
63,
955,
275,
788,
354,
418,
272,
29177,
275,
334,
19480,
10307,
12,
14409,
16974,
10307,
12,
14409,
16985,
354,
10307,
12,
14409,
7344,
10307,
12,
2049,
14409,
13885,
2201,
18808,
10307,
9,
272,
769,
63,
1541,
275,
661,
1818,
63,
7522,
363,
75,
17775,
409,
297,
283,
15791,
358,
339,
327,
437,
1978,
367,
282,
7437,
26707,
1570,
2455,
26,
272,
1570,
63,
964,
63,
1160,
275,
283,
2113,
15,
4129,
15,
1461,
63,
964,
63,
1045,
63,
2911,
14,
1360,
7,
339,
347,
1570,
63,
1345,
8,
277,
12,
1056,
12,
909,
63,
344,
12,
2402,
63,
1100,
29,
403,
304,
267,
333,
275,
14409,
14,
1462,
14,
362,
8,
344,
29,
785,
63,
344,
9,
267,
3002,
63,
1100,
275,
469,
288,
283,
2911,
356,
469,
355,
283,
5812,
63,
16742,
356,
333,
14,
8380,
5690,
1296,
7756,
8,
77,
14,
40,
12527,
8380,
15741,
4000,
355,
283,
674,
63,
16742,
356,
333,
14,
8380,
5690,
1296,
7756,
8,
77,
14,
10281,
597,
8380,
15741,
4000,
288,
789,
267,
789,
267,
372,
1613,
8,
7021,
4880,
12,
291,
680,
1461,
63,
1345,
8,
1069,
12,
909,
63,
344,
12,
8105,
2402,
63,
1100,
29,
1662,
63,
1100,
9,
339,
347,
7594,
8,
277,
12,
1056,
304,
267,
372,
1613,
8,
7021,
4880,
12,
291,
680,
7924,
8,
288,
1056,
680,
2416,
63,
2407,
360,
1818,
63,
7522,
358,
199,
2113,
14,
2124,
14,
2683,
8,
7021,
12,
14409,
4880,
9,
421,
199,
533,
7499,
5690,
4880,
8,
2113,
14,
12976,
304,
272,
7794,
275,
12291,
12916,
63,
3397,
9538,
199,
2113,
14,
2124,
14,
2683,
8,
8380,
5690,
12,
7499,
5690,
4880,
9,
421,
199,
533,
24326,
4880,
8,
2113,
14,
12976,
304,
272,
7794,
275,
661,
1114,
363,
354,
9538,
199,
2113,
14,
2124,
14,
2683,
8,
19480,
12,
24326,
4880,
9,
421,
199,
533,
437,
3079,
804,
4880,
8,
2113,
14,
12976,
304,
272,
986,
199,
2113,
14,
2124,
14,
2683,
8,
33,
3079,
804,
12,
437,
3079,
804,
4880,
9,
421,
199,
533,
437,
3079,
4880,
8,
2113,
14,
12976,
304,
272,
769,
63,
2918,
275,
661,
1114,
297,
283,
65,
3079,
63,
466,
297,
283,
602,
63,
11809,
358,
272,
3066,
63,
344,
63,
955,
275,
661,
1114,
9538,
199,
2113,
14,
2124,
14,
2683,
8,
33,
3079,
12,
437,
3079,
4880,
9,
421,
199,
533,
1804,
17775,
409,
4880,
8,
2113,
14,
12976,
304,
272,
986,
199,
2113,
14,
2124,
14,
2683,
8,
43,
17775,
409,
12,
1804,
17775,
409,
4880,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
ktnyt/chainer
|
examples/memnn/test_memnn.py
|
2
|
2072
|
#!/usr/bin/env python
import argparse
import numpy
import babi
import memnn
def main():
parser = argparse.ArgumentParser(
description='Chainer example: End-to-end memory networks')
parser.add_argument('MODEL',
help='Path to model directory specified with `-m` '
'argument in the training script')
parser.add_argument('DATA',
help='Path to test data in bAbI dataset '
'(e.g. "qa1_single-supporting-fact_test.txt")')
parser.add_argument('--gpu', '-g', type=int, default=-1,
help='GPU ID (negative value indicates CPU)')
args = parser.parse_args()
model, vocab = memnn.load_model(args.MODEL)
network = model.predictor
max_memory = network.max_memory
id_to_vocab = {i: v for v, i in vocab.items()}
test_data = babi.read_data(vocab, args.DATA)
print('Test data: %s: %d' % (args.DATA, len(test_data)))
sentence_len = max(max(len(s.sentence) for s in story)
for story in test_data)
correct = total = 0
for story in test_data:
mem = numpy.zeros((max_memory, sentence_len), dtype=numpy.int32)
i = 0
for sent in story:
if isinstance(sent, babi.Sentence):
if i == max_memory:
mem[0:i - 1, :] = mem[1:i, :]
i -= 1
mem[i, 0:len(sent.sentence)] = sent.sentence
i += 1
elif isinstance(sent, babi.Query):
query = numpy.array(sent.sentence, dtype=numpy.int32)
# networks assumes mini-batch data
score = network(mem[None], query[None])[0]
answer = numpy.argmax(score.array)
if answer == sent.answer:
correct += 1
total += 1
print(id_to_vocab[answer], id_to_vocab[sent.answer])
accuracy = float(correct) / total
print('Accuracy: %.2f%%' % (accuracy * 100))
if __name__ == '__main__':
main()
|
mit
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
199,
646,
7534,
199,
199,
646,
2680,
199,
199,
646,
330,
14677,
199,
646,
7573,
4411,
421,
199,
318,
2446,
837,
272,
1798,
275,
7534,
14,
10730,
8,
267,
1369,
534,
10720,
281,
2893,
26,
9599,
13,
475,
13,
500,
4402,
11759,
358,
272,
1798,
14,
525,
63,
2094,
360,
11429,
297,
717,
1720,
534,
2042,
370,
1402,
2082,
2013,
543,
658,
13,
77,
64,
283,
717,
283,
2094,
315,
314,
6093,
2884,
358,
272,
1798,
14,
525,
63,
2094,
360,
3998,
297,
717,
1720,
534,
2042,
370,
511,
666,
315,
330,
5583,
41,
4789,
283,
717,
8189,
69,
14,
71,
14,
298,
7096,
17,
63,
4780,
13,
4058,
316,
13,
7783,
63,
396,
14,
2424,
531,
358,
272,
1798,
14,
525,
63,
2094,
4517,
6477,
297,
2475,
71,
297,
730,
29,
442,
12,
849,
4022,
17,
12,
717,
1720,
534,
20769,
2870,
334,
7371,
574,
9126,
11952,
5942,
272,
1249,
275,
1798,
14,
1122,
63,
589,
342,
339,
1402,
12,
11181,
275,
7573,
4411,
14,
912,
63,
1238,
8,
589,
14,
11429,
9,
272,
2784,
275,
1402,
14,
5790,
630,
272,
1390,
63,
4844,
275,
2784,
14,
988,
63,
4844,
272,
1305,
63,
475,
63,
9953,
275,
469,
73,
26,
373,
367,
373,
12,
284,
315,
11181,
14,
1744,
12737,
339,
511,
63,
576,
275,
330,
14677,
14,
739,
63,
576,
8,
9953,
12,
1249,
14,
3998,
9,
272,
870,
360,
774,
666,
26,
450,
83,
26,
450,
68,
7,
450,
334,
589,
14,
3998,
12,
822,
8,
396,
63,
576,
1724,
339,
14537,
63,
552,
275,
1390,
8,
988,
8,
552,
8,
83,
14,
17727,
9,
367,
308,
315,
19222,
9,
2432,
367,
19222,
315,
511,
63,
576,
9,
272,
3211,
275,
3141,
275,
378,
272,
367,
19222,
315,
511,
63,
576,
26,
267,
7573,
275,
2680,
14,
4250,
1332,
988,
63,
4844,
12,
14537,
63,
552,
395,
2152,
29,
4714,
14,
442,
708,
9,
267,
284,
275,
378,
267,
367,
4847,
315,
19222,
26,
288,
340,
1228,
8,
1150,
12,
330,
14677,
14,
18569,
6692,
304,
355,
340,
284,
508,
1390,
63,
4844,
26,
490,
7573,
59,
16,
26,
73,
446,
413,
12,
12228,
275,
7573,
59,
17,
26,
73,
12,
12228,
490,
284,
4862,
413,
355,
7573,
59,
73,
12,
378,
26,
552,
8,
1150,
14,
17727,
1874,
275,
4847,
14,
17727,
355,
284,
847,
413,
288,
916,
1228,
8,
1150,
12,
330,
14677,
14,
3227,
304,
355,
1827,
275,
2680,
14,
1144,
8,
1150,
14,
17727,
12,
2152,
29,
4714,
14,
442,
708,
9,
2234,
327,
11759,
15194,
20536,
13,
2912,
666,
355,
5396,
275,
2784,
8,
5286,
59,
403,
467,
1827,
59,
403,
11057,
16,
61,
355,
6385,
275,
2680,
14,
16383,
8,
3397,
14,
1144,
9,
2234,
340,
6385,
508,
4847,
14,
5934,
26,
490,
3211,
847,
413,
355,
3141,
847,
413,
355,
870,
8,
344,
63,
475,
63,
9953,
59,
5934,
467,
1305,
63,
475,
63,
9953,
59,
1150,
14,
5934,
566,
339,
12862,
275,
2069,
8,
4525,
9,
1182,
3141,
272,
870,
360,
1945,
7933,
26,
10536,
18,
70,
8530,
7,
450,
334,
13374,
627,
2948,
430,
421,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
2446,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
199,
646,
7534,
199,
199,
646,
2680,
199,
199,
646,
330,
14677,
199,
646,
7573,
4411,
421,
199,
318,
2446,
837,
272,
1798,
275,
7534,
14,
10730,
8,
267,
1369,
534,
10720,
281,
2893,
26,
9599,
13,
475,
13,
500,
4402,
11759,
358,
272,
1798,
14,
525,
63,
2094,
360,
11429,
297,
717,
1720,
534,
2042,
370,
1402,
2082,
2013,
543,
658,
13,
77,
64,
283,
717,
283,
2094,
315,
314,
6093,
2884,
358,
272,
1798,
14,
525,
63,
2094,
360,
3998,
297,
717,
1720,
534,
2042,
370,
511,
666,
315,
330,
5583,
41,
4789,
283,
717,
8189,
69,
14,
71,
14,
298,
7096,
17,
63,
4780,
13,
4058,
316,
13,
7783,
63,
396,
14,
2424,
531,
358,
272,
1798,
14,
525,
63,
2094,
4517,
6477,
297,
2475,
71,
297,
730,
29,
442,
12,
849,
4022,
17,
12,
717,
1720,
534,
20769,
2870,
334,
7371,
574,
9126,
11952,
5942,
272,
1249,
275,
1798,
14,
1122,
63,
589,
342,
339,
1402,
12,
11181,
275,
7573,
4411,
14,
912,
63,
1238,
8,
589,
14,
11429,
9,
272,
2784,
275,
1402,
14,
5790,
630,
272,
1390,
63,
4844,
275,
2784,
14,
988,
63,
4844,
272,
1305,
63,
475,
63,
9953,
275,
469,
73,
26,
373,
367,
373,
12,
284,
315,
11181,
14,
1744,
12737,
339,
511,
63,
576,
275,
330,
14677,
14,
739,
63,
576,
8,
9953,
12,
1249,
14,
3998,
9,
272,
870,
360,
774,
666,
26,
450,
83,
26,
450,
68,
7,
450,
334,
589,
14,
3998,
12,
822,
8,
396,
63,
576,
1724,
339,
14537,
63,
552,
275,
1390,
8,
988,
8,
552,
8,
83,
14,
17727,
9,
367,
308,
315,
19222,
9,
2432,
367,
19222,
315,
511,
63,
576,
9,
272,
3211,
275,
3141,
275,
378,
272,
367,
19222,
315,
511,
63,
576,
26,
267,
7573,
275,
2680,
14,
4250,
1332,
988,
63,
4844,
12,
14537,
63,
552,
395,
2152,
29,
4714,
14,
442,
708,
9,
267,
284,
275,
378,
267,
367,
4847,
315,
19222,
26,
288,
340,
1228,
8,
1150,
12,
330,
14677,
14,
18569,
6692,
304,
355,
340,
284,
508,
1390,
63,
4844,
26,
490,
7573,
59,
16,
26,
73,
446,
413,
12,
12228,
275,
7573,
59,
17,
26,
73,
12,
12228,
490,
284,
4862,
413,
355,
7573,
59,
73,
12,
378,
26,
552,
8,
1150,
14,
17727,
1874,
275,
4847,
14,
17727,
355,
284,
847,
413,
288,
916,
1228,
8,
1150,
12,
330,
14677,
14,
3227,
304,
355,
1827,
275,
2680,
14,
1144,
8,
1150,
14,
17727,
12,
2152,
29,
4714,
14,
442,
708,
9,
2234,
327,
11759,
15194,
20536,
13,
2912,
666,
355,
5396,
275,
2784,
8,
5286,
59,
403,
467,
1827,
59,
403,
11057,
16,
61,
355,
6385,
275,
2680,
14,
16383,
8,
3397,
14,
1144,
9,
2234,
340,
6385,
508,
4847,
14,
5934,
26,
490,
3211,
847,
413,
355,
3141,
847,
413,
355,
870,
8,
344,
63,
475,
63,
9953,
59,
5934,
467,
1305,
63,
475,
63,
9953,
59,
1150,
14,
5934,
566,
339,
12862,
275,
2069,
8,
4525,
9,
1182,
3141,
272,
870,
360,
1945,
7933,
26,
10536,
18,
70,
8530,
7,
450,
334,
13374,
627,
2948,
430,
421,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
2446,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
openmotics/gateway
|
src/gateway/api/serializers/ventilation.py
|
1
|
4596
|
# Copyright (C) 2020 OpenMotics BV
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
Ventilation (de)serializer
"""
from __future__ import absolute_import
import logging
from gateway.api.serializers.base import SerializerToolbox
from gateway.dto import VentilationDTO, VentilationSourceDTO, \
VentilationStatusDTO
from toolbox import Toolbox
if False: # MYPY
from typing import Any, Dict, Optional, List, Tuple
logger = logging.getLogger(__name__)
class VentilationSerializer(object):
@staticmethod
def serialize(ventilation_dto, fields):
# type: (VentilationDTO, Optional[List[str]]) -> Dict[str,Any]
data = {'id': ventilation_dto.id,
'external_id': Toolbox.denonify(ventilation_dto.external_id, ''),
'source': {'type': ventilation_dto.source.type,
'name': ventilation_dto.source.name},
'name': Toolbox.denonify(ventilation_dto.name, ''),
'amount_of_levels': Toolbox.denonify(ventilation_dto.amount_of_levels, 0),
'device': {'vendor': Toolbox.denonify(ventilation_dto.device_vendor, ''),
'type': Toolbox.denonify(ventilation_dto.device_type, '')}}
if ventilation_dto.device_serial:
data['device'].update({'serial': Toolbox.denonify(ventilation_dto.device_serial, '')})
return SerializerToolbox.filter_fields(data, fields)
@staticmethod
def deserialize(api_data): # type: (Dict[str,Any]) -> VentilationDTO
ventilation_id = None # type: Optional[int]
if 'id' in api_data:
ventilation_id = api_data['id']
source_dto = None # type: Optional[VentilationSourceDTO]
if 'source' in api_data:
source_dto = VentilationSourceDTO(None,
name=api_data['source']['name'],
type=api_data['source']['type'])
ventilation_dto = VentilationDTO(id=ventilation_id, source=source_dto)
if 'external_id' in api_data:
ventilation_dto.external_id = Toolbox.nonify(api_data['external_id'], '')
if 'name' in api_data:
ventilation_dto.name = Toolbox.nonify(api_data['name'], '')
if 'amount_of_levels' in api_data:
ventilation_dto.amount_of_levels = Toolbox.nonify(api_data['amount_of_levels'], '')
if 'device' in api_data:
if 'type' in api_data['device']:
ventilation_dto.device_type = Toolbox.nonify(api_data['device']['type'], '')
if 'vendor' in api_data['device']:
ventilation_dto.device_vendor = Toolbox.nonify(api_data['device']['vendor'], '')
if 'serial' in api_data['device']:
ventilation_dto.device_serial = Toolbox.nonify(api_data['device']['serial'], '')
return ventilation_dto
class VentilationStatusSerializer(object):
@staticmethod
def serialize(status_dto, fields):
# type: (VentilationStatusDTO, Optional[List[str]]) -> Dict[str,Any]
data = {'id': status_dto.id,
'mode': status_dto.mode,
'level': status_dto.level,
'remaining_time': status_dto.remaining_time,
'timer': status_dto.timer,
'connected': status_dto.is_connected}
return SerializerToolbox.filter_fields(data, fields)
@staticmethod
def deserialize(api_data): # type: (Dict[str,Any]) -> VentilationStatusDTO
status_dto = VentilationStatusDTO(id=api_data['id'],
mode=api_data['mode'])
if 'level' in api_data:
status_dto.level = Toolbox.nonify(api_data['level'], 0)
if 'timer' in api_data:
status_dto.timer = Toolbox.nonify(api_data['timer'], 0)
if 'remaining_time' in api_data:
status_dto.remaining_time = Toolbox.nonify(api_data['remaining_time'], 0)
return status_dto
|
agpl-3.0
|
[
3,
1898,
334,
35,
9,
25455,
3232,
3716,
7769,
699,
54,
199,
3,
199,
3,
961,
2240,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
652,
1334,
314,
2895,
402,
314,
1664,
4265,
1696,
1684,
844,
465,
199,
3,
3267,
701,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
199,
3,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
1664,
4265,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
4265,
1696,
1684,
844,
199,
3,
3180,
543,
642,
2240,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
199,
624,
199,
54,
287,
280,
2212,
334,
271,
9,
8349,
199,
624,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
199,
199,
646,
2050,
199,
199,
504,
10391,
14,
1246,
14,
12844,
14,
1095,
492,
25555,
5157,
1977,
199,
504,
10391,
14,
68,
475,
492,
812,
287,
280,
2212,
36,
2566,
12,
812,
287,
280,
2212,
2980,
36,
2566,
12,
971,
272,
812,
287,
280,
2212,
3694,
36,
2566,
199,
504,
4744,
1977,
492,
15650,
1977,
199,
199,
692,
756,
26,
221,
327,
603,
57,
4521,
272,
687,
14090,
492,
6184,
12,
7448,
12,
4879,
12,
3820,
12,
11634,
199,
199,
2921,
275,
2050,
14,
5572,
3460,
354,
3368,
421,
199,
533,
812,
287,
280,
2212,
7299,
8,
785,
304,
272,
768,
4639,
272,
347,
8437,
8,
1856,
280,
2212,
63,
68,
475,
12,
1504,
304,
267,
327,
730,
26,
334,
54,
287,
280,
2212,
36,
2566,
12,
4879,
59,
1296,
59,
495,
3934,
1035,
7448,
59,
495,
12,
9874,
61,
267,
666,
275,
791,
344,
356,
373,
287,
280,
2212,
63,
68,
475,
14,
344,
12,
355,
283,
5159,
63,
344,
356,
15650,
1977,
14,
848,
265,
2021,
8,
1856,
280,
2212,
63,
68,
475,
14,
5159,
63,
344,
12,
9929,
355,
283,
1365,
356,
791,
466,
356,
373,
287,
280,
2212,
63,
68,
475,
14,
1365,
14,
466,
12,
2574,
283,
354,
356,
373,
287,
280,
2212,
63,
68,
475,
14,
1365,
14,
354,
1386,
355,
283,
354,
356,
15650,
1977,
14,
848,
265,
2021,
8,
1856,
280,
2212,
63,
68,
475,
14,
354,
12,
9929,
355,
283,
4606,
63,
1618,
63,
11402,
356,
15650,
1977,
14,
848,
265,
2021,
8,
1856,
280,
2212,
63,
68,
475,
14,
4606,
63,
1618,
63,
11402,
12,
378,
395,
355,
283,
1782,
356,
791,
9884,
356,
15650,
1977,
14,
848,
265,
2021,
8,
1856,
280,
2212,
63,
68,
475,
14,
1782,
63,
9884,
12,
9929,
2574,
283,
466,
356,
15650,
1977,
14,
848,
265,
2021,
8,
1856,
280,
2212,
63,
68,
475,
14,
1782,
63,
466,
12,
4074,
4863,
267,
340,
373,
287,
280,
2212,
63,
68,
475,
14,
1782,
63,
2171,
26,
288,
666,
459,
1782,
2278,
873,
3252,
2171,
356,
15650,
1977,
14,
848,
265,
2021,
8,
1856,
280,
2212,
63,
68,
475,
14,
1782,
63,
2171,
12,
4074,
1552,
267,
372,
25555,
5157,
1977,
14,
1541,
63,
955,
8,
576,
12,
1504,
9,
339,
768,
4639,
272,
347,
22920,
8,
1246,
63,
576,
304,
221,
327,
730,
26,
334,
2141,
59,
495,
12,
9874,
566,
1035,
812,
287,
280,
2212,
36,
2566,
267,
373,
287,
280,
2212,
63,
344,
275,
488,
221,
327,
730,
26,
4879,
59,
442,
61,
267,
340,
283,
344,
7,
315,
2986,
63,
576,
26,
288,
373,
287,
280,
2212,
63,
344,
275,
2986,
63,
576,
459,
344,
418,
267,
1350,
63,
68,
475,
275,
488,
221,
327,
730,
26,
4879,
59,
54,
287,
280,
2212,
2980,
36,
2566,
61,
267,
340,
283,
1365,
7,
315,
2986,
63,
576,
26,
288,
1350,
63,
68,
475,
275,
812,
287,
280,
2212,
2980,
36,
2566,
8,
403,
12,
6343,
536,
29,
1246,
63,
576,
459,
1365,
2545,
354,
995,
6343,
730,
29,
1246,
63,
576,
459,
1365,
2545,
466,
1105,
267,
373,
287,
280,
2212,
63,
68,
475,
275,
812,
287,
280,
2212,
36,
2566,
8,
344,
29,
1856,
280,
2212,
63,
344,
12,
1350,
29,
1365,
63,
68,
475,
9,
267,
340,
283,
5159,
63,
344,
7,
315,
2986,
63,
576,
26,
288,
373,
287,
280,
2212,
63,
68,
475,
14,
5159,
63,
344,
275,
15650,
1977,
14,
2865,
2021,
8,
1246,
63,
576,
459,
5159,
63,
344,
995,
4074,
267,
340,
283,
354,
7,
315,
2986,
63,
576,
26,
288,
373,
287,
280,
2212,
63,
68,
475,
14,
354,
275,
15650,
1977,
14,
2865,
2021,
8,
1246,
63,
576,
459,
354,
995,
4074,
267,
340,
283,
4606,
63,
1618,
63,
11402,
7,
315,
2986,
63,
576,
26,
288,
373,
287,
280,
2212,
63,
68,
475,
14,
4606,
63,
1618,
63,
11402,
275,
15650,
1977,
14,
2865,
2021,
8,
1246,
63,
576,
459,
4606,
63,
1618,
63,
11402,
995,
4074,
267,
340,
283,
1782,
7,
315,
2986,
63,
576,
26,
288,
340,
283,
466,
7,
315,
2986,
63,
576,
459,
1782,
2565,
355,
373,
287,
280,
2212,
63,
68,
475,
14,
1782,
63,
466,
275,
15650,
1977,
14,
2865,
2021,
8,
1246,
63,
576,
459,
1782,
2545,
466,
995,
4074,
288,
340,
283,
9884,
7,
315,
2986,
63,
576,
459,
1782,
2565,
355,
373,
287,
280,
2212,
63,
68,
475,
14,
1782,
63,
9884,
275,
15650,
1977,
14,
2865,
2021,
8,
1246,
63,
576,
459,
1782,
2545,
9884,
995,
4074,
288,
340,
283,
2171,
7,
315,
2986,
63,
576,
459,
1782,
2565,
355,
373,
287,
280,
2212,
63,
68,
475,
14,
1782,
63,
2171,
275,
15650,
1977,
14,
2865,
2021,
8,
1246,
63,
576,
459,
1782,
2545,
2171,
995,
4074,
267,
372,
373,
287,
280,
2212,
63,
68,
475,
421,
199,
533,
812,
287,
280,
2212,
3694,
7299,
8,
785,
304,
272,
768,
4639,
272,
347,
8437,
8,
1205,
63,
68,
475,
12,
1504,
304,
267,
327,
730,
26,
334,
54
] |
[
1898,
334,
35,
9,
25455,
3232,
3716,
7769,
699,
54,
199,
3,
199,
3,
961,
2240,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
652,
1334,
314,
2895,
402,
314,
1664,
4265,
1696,
1684,
844,
465,
199,
3,
3267,
701,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
199,
3,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
1664,
4265,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
4265,
1696,
1684,
844,
199,
3,
3180,
543,
642,
2240,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
199,
624,
199,
54,
287,
280,
2212,
334,
271,
9,
8349,
199,
624,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
199,
199,
646,
2050,
199,
199,
504,
10391,
14,
1246,
14,
12844,
14,
1095,
492,
25555,
5157,
1977,
199,
504,
10391,
14,
68,
475,
492,
812,
287,
280,
2212,
36,
2566,
12,
812,
287,
280,
2212,
2980,
36,
2566,
12,
971,
272,
812,
287,
280,
2212,
3694,
36,
2566,
199,
504,
4744,
1977,
492,
15650,
1977,
199,
199,
692,
756,
26,
221,
327,
603,
57,
4521,
272,
687,
14090,
492,
6184,
12,
7448,
12,
4879,
12,
3820,
12,
11634,
199,
199,
2921,
275,
2050,
14,
5572,
3460,
354,
3368,
421,
199,
533,
812,
287,
280,
2212,
7299,
8,
785,
304,
272,
768,
4639,
272,
347,
8437,
8,
1856,
280,
2212,
63,
68,
475,
12,
1504,
304,
267,
327,
730,
26,
334,
54,
287,
280,
2212,
36,
2566,
12,
4879,
59,
1296,
59,
495,
3934,
1035,
7448,
59,
495,
12,
9874,
61,
267,
666,
275,
791,
344,
356,
373,
287,
280,
2212,
63,
68,
475,
14,
344,
12,
355,
283,
5159,
63,
344,
356,
15650,
1977,
14,
848,
265,
2021,
8,
1856,
280,
2212,
63,
68,
475,
14,
5159,
63,
344,
12,
9929,
355,
283,
1365,
356,
791,
466,
356,
373,
287,
280,
2212,
63,
68,
475,
14,
1365,
14,
466,
12,
2574,
283,
354,
356,
373,
287,
280,
2212,
63,
68,
475,
14,
1365,
14,
354,
1386,
355,
283,
354,
356,
15650,
1977,
14,
848,
265,
2021,
8,
1856,
280,
2212,
63,
68,
475,
14,
354,
12,
9929,
355,
283,
4606,
63,
1618,
63,
11402,
356,
15650,
1977,
14,
848,
265,
2021,
8,
1856,
280,
2212,
63,
68,
475,
14,
4606,
63,
1618,
63,
11402,
12,
378,
395,
355,
283,
1782,
356,
791,
9884,
356,
15650,
1977,
14,
848,
265,
2021,
8,
1856,
280,
2212,
63,
68,
475,
14,
1782,
63,
9884,
12,
9929,
2574,
283,
466,
356,
15650,
1977,
14,
848,
265,
2021,
8,
1856,
280,
2212,
63,
68,
475,
14,
1782,
63,
466,
12,
4074,
4863,
267,
340,
373,
287,
280,
2212,
63,
68,
475,
14,
1782,
63,
2171,
26,
288,
666,
459,
1782,
2278,
873,
3252,
2171,
356,
15650,
1977,
14,
848,
265,
2021,
8,
1856,
280,
2212,
63,
68,
475,
14,
1782,
63,
2171,
12,
4074,
1552,
267,
372,
25555,
5157,
1977,
14,
1541,
63,
955,
8,
576,
12,
1504,
9,
339,
768,
4639,
272,
347,
22920,
8,
1246,
63,
576,
304,
221,
327,
730,
26,
334,
2141,
59,
495,
12,
9874,
566,
1035,
812,
287,
280,
2212,
36,
2566,
267,
373,
287,
280,
2212,
63,
344,
275,
488,
221,
327,
730,
26,
4879,
59,
442,
61,
267,
340,
283,
344,
7,
315,
2986,
63,
576,
26,
288,
373,
287,
280,
2212,
63,
344,
275,
2986,
63,
576,
459,
344,
418,
267,
1350,
63,
68,
475,
275,
488,
221,
327,
730,
26,
4879,
59,
54,
287,
280,
2212,
2980,
36,
2566,
61,
267,
340,
283,
1365,
7,
315,
2986,
63,
576,
26,
288,
1350,
63,
68,
475,
275,
812,
287,
280,
2212,
2980,
36,
2566,
8,
403,
12,
6343,
536,
29,
1246,
63,
576,
459,
1365,
2545,
354,
995,
6343,
730,
29,
1246,
63,
576,
459,
1365,
2545,
466,
1105,
267,
373,
287,
280,
2212,
63,
68,
475,
275,
812,
287,
280,
2212,
36,
2566,
8,
344,
29,
1856,
280,
2212,
63,
344,
12,
1350,
29,
1365,
63,
68,
475,
9,
267,
340,
283,
5159,
63,
344,
7,
315,
2986,
63,
576,
26,
288,
373,
287,
280,
2212,
63,
68,
475,
14,
5159,
63,
344,
275,
15650,
1977,
14,
2865,
2021,
8,
1246,
63,
576,
459,
5159,
63,
344,
995,
4074,
267,
340,
283,
354,
7,
315,
2986,
63,
576,
26,
288,
373,
287,
280,
2212,
63,
68,
475,
14,
354,
275,
15650,
1977,
14,
2865,
2021,
8,
1246,
63,
576,
459,
354,
995,
4074,
267,
340,
283,
4606,
63,
1618,
63,
11402,
7,
315,
2986,
63,
576,
26,
288,
373,
287,
280,
2212,
63,
68,
475,
14,
4606,
63,
1618,
63,
11402,
275,
15650,
1977,
14,
2865,
2021,
8,
1246,
63,
576,
459,
4606,
63,
1618,
63,
11402,
995,
4074,
267,
340,
283,
1782,
7,
315,
2986,
63,
576,
26,
288,
340,
283,
466,
7,
315,
2986,
63,
576,
459,
1782,
2565,
355,
373,
287,
280,
2212,
63,
68,
475,
14,
1782,
63,
466,
275,
15650,
1977,
14,
2865,
2021,
8,
1246,
63,
576,
459,
1782,
2545,
466,
995,
4074,
288,
340,
283,
9884,
7,
315,
2986,
63,
576,
459,
1782,
2565,
355,
373,
287,
280,
2212,
63,
68,
475,
14,
1782,
63,
9884,
275,
15650,
1977,
14,
2865,
2021,
8,
1246,
63,
576,
459,
1782,
2545,
9884,
995,
4074,
288,
340,
283,
2171,
7,
315,
2986,
63,
576,
459,
1782,
2565,
355,
373,
287,
280,
2212,
63,
68,
475,
14,
1782,
63,
2171,
275,
15650,
1977,
14,
2865,
2021,
8,
1246,
63,
576,
459,
1782,
2545,
2171,
995,
4074,
267,
372,
373,
287,
280,
2212,
63,
68,
475,
421,
199,
533,
812,
287,
280,
2212,
3694,
7299,
8,
785,
304,
272,
768,
4639,
272,
347,
8437,
8,
1205,
63,
68,
475,
12,
1504,
304,
267,
327,
730,
26,
334,
54,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
2014c2g4/w16b_test
|
static/Brython3.1.0-20150301-090019/Lib/_dummy_thread.py
|
742
|
4769
|
"""Drop-in replacement for the thread module.
Meant to be used as a brain-dead substitute so that threaded code does
not need to be rewritten for when the thread module is not present.
Suggested usage is::
try:
import _thread
except ImportError:
import _dummy_thread as _thread
"""
# Exports only things specified by thread documentation;
# skipping obsolete synonyms allocate(), start_new(), exit_thread().
__all__ = ['error', 'start_new_thread', 'exit', 'get_ident', 'allocate_lock',
'interrupt_main', 'LockType']
# A dummy value
TIMEOUT_MAX = 2**31
# NOTE: this module can be imported early in the extension building process,
# and so top level imports of other modules should be avoided. Instead, all
# imports are done when needed on a function-by-function basis. Since threads
# are disabled, the import lock should not be an issue anyway (??).
error = RuntimeError
def start_new_thread(function, args, kwargs={}):
"""Dummy implementation of _thread.start_new_thread().
Compatibility is maintained by making sure that ``args`` is a
tuple and ``kwargs`` is a dictionary. If an exception is raised
and it is SystemExit (which can be done by _thread.exit()) it is
caught and nothing is done; all other exceptions are printed out
by using traceback.print_exc().
If the executed function calls interrupt_main the KeyboardInterrupt will be
raised when the function returns.
"""
if type(args) != type(tuple()):
raise TypeError("2nd arg must be a tuple")
if type(kwargs) != type(dict()):
raise TypeError("3rd arg must be a dict")
global _main
_main = False
try:
function(*args, **kwargs)
except SystemExit:
pass
except:
import traceback
traceback.print_exc()
_main = True
global _interrupt
if _interrupt:
_interrupt = False
raise KeyboardInterrupt
def exit():
"""Dummy implementation of _thread.exit()."""
raise SystemExit
def get_ident():
"""Dummy implementation of _thread.get_ident().
Since this module should only be used when _threadmodule is not
available, it is safe to assume that the current process is the
only thread. Thus a constant can be safely returned.
"""
return -1
def allocate_lock():
"""Dummy implementation of _thread.allocate_lock()."""
return LockType()
def stack_size(size=None):
"""Dummy implementation of _thread.stack_size()."""
if size is not None:
raise error("setting thread stack size not supported")
return 0
class LockType(object):
"""Class implementing dummy implementation of _thread.LockType.
Compatibility is maintained by maintaining self.locked_status
which is a boolean that stores the state of the lock. Pickling of
the lock, though, should not be done since if the _thread module is
then used with an unpickled ``lock()`` from here problems could
occur from this class not having atomic methods.
"""
def __init__(self):
self.locked_status = False
def acquire(self, waitflag=None, timeout=-1):
"""Dummy implementation of acquire().
For blocking calls, self.locked_status is automatically set to
True and returned appropriately based on value of
``waitflag``. If it is non-blocking, then the value is
actually checked and not set if it is already acquired. This
is all done so that threading.Condition's assert statements
aren't triggered and throw a little fit.
"""
if waitflag is None or waitflag:
self.locked_status = True
return True
else:
if not self.locked_status:
self.locked_status = True
return True
else:
if timeout > 0:
import time
time.sleep(timeout)
return False
__enter__ = acquire
def __exit__(self, typ, val, tb):
self.release()
def release(self):
"""Release the dummy lock."""
# XXX Perhaps shouldn't actually bother to test? Could lead
# to problems for complex, threaded code.
if not self.locked_status:
raise error
self.locked_status = False
return True
def locked(self):
return self.locked_status
# Used to signal that interrupt_main was called in a "thread"
_interrupt = False
# True when not executing in a "thread"
_main = True
def interrupt_main():
"""Set _interrupt flag to True to have start_new_thread raise
KeyboardInterrupt upon exiting."""
if _main:
raise KeyboardInterrupt
else:
global _interrupt
_interrupt = True
|
gpl-3.0
|
[
624,
11070,
13,
262,
8343,
367,
314,
2462,
859,
14,
199,
199,
1352,
867,
370,
506,
1202,
465,
282,
330,
6322,
13,
10957,
23080,
880,
626,
25396,
1233,
1630,
199,
1397,
1929,
370,
506,
28286,
367,
1380,
314,
2462,
859,
365,
440,
3451,
14,
199,
199,
51,
17417,
4503,
365,
447,
339,
862,
26,
267,
492,
485,
2671,
272,
871,
3545,
26,
267,
492,
485,
5869,
63,
2671,
465,
485,
2671,
199,
199,
624,
199,
3,
1316,
5203,
1454,
7645,
2013,
701,
2462,
3794,
27,
199,
3,
16068,
24985,
9560,
5220,
706,
18310,
1062,
1343,
63,
1222,
1062,
4458,
63,
2671,
1252,
199,
363,
452,
363,
275,
788,
705,
297,
283,
928,
63,
1222,
63,
2671,
297,
283,
2224,
297,
283,
362,
63,
5425,
297,
283,
12991,
63,
831,
297,
1779,
283,
20172,
63,
973,
297,
283,
6432,
804,
418,
199,
199,
3,
437,
7283,
574,
199,
8899,
63,
4283,
275,
499,
538,
2192,
199,
199,
3,
6944,
26,
642,
859,
883,
506,
8439,
14670,
315,
314,
3329,
10015,
2112,
12,
199,
3,
436,
880,
2746,
2166,
8925,
402,
1163,
4621,
1077,
506,
2289,
16142,
770,
14,
221,
15345,
12,
1006,
199,
3,
8925,
787,
4224,
1380,
4346,
641,
282,
805,
13,
991,
13,
1593,
5597,
14,
221,
9336,
7183,
199,
3,
787,
6980,
12,
314,
492,
4650,
1077,
440,
506,
376,
4976,
15988,
7558,
31,
680,
199,
199,
705,
275,
6064,
199,
199,
318,
1343,
63,
1222,
63,
2671,
8,
1593,
12,
1249,
12,
2074,
16420,
272,
408,
11324,
4514,
402,
485,
2671,
14,
928,
63,
1222,
63,
2671,
1252,
339,
3599,
5880,
365,
26391,
701,
10663,
3238,
626,
1124,
589,
1040,
365,
282,
272,
2008,
436,
1124,
958,
1040,
365,
282,
2600,
14,
221,
982,
376,
1919,
365,
4915,
272,
436,
652,
365,
14838,
334,
6777,
883,
506,
4224,
701,
485,
2671,
14,
2224,
1012,
652,
365,
272,
15604,
436,
6548,
365,
4224,
27,
1006,
1163,
4967,
787,
12487,
734,
272,
701,
1808,
5190,
14,
1361,
63,
2804,
1252,
339,
982,
314,
7934,
805,
4882,
26791,
63,
973,
314,
13483,
911,
506,
272,
4915,
1380,
314,
805,
2529,
14,
339,
408,
272,
340,
730,
8,
589,
9,
1137,
730,
8,
2960,
5109,
267,
746,
3146,
480,
18,
977,
1680,
1471,
506,
282,
2008,
531,
272,
340,
730,
8,
958,
9,
1137,
730,
8,
807,
5109,
267,
746,
3146,
480,
19,
6883,
1680,
1471,
506,
282,
1211,
531,
272,
2288,
485,
973,
272,
485,
973,
275,
756,
272,
862,
26,
267,
805,
2031,
589,
12,
1011,
958,
9,
272,
871,
14838,
26,
267,
986,
272,
871,
26,
267,
492,
5190,
267,
5190,
14,
1361,
63,
2804,
342,
272,
485,
973,
275,
715,
272,
2288,
485,
20172,
272,
340,
485,
20172,
26,
267,
485,
20172,
275,
756,
267,
746,
13483,
199,
199,
318,
4458,
837,
272,
408,
11324,
4514,
402,
485,
2671,
14,
2224,
20693,
272,
746,
14838,
199,
199,
318,
664,
63,
5425,
837,
272,
408,
11324,
4514,
402,
485,
2671,
14,
362,
63,
5425,
1252,
339,
9336,
642,
859,
1077,
1454,
506,
1202,
1380,
485,
2671,
578,
365,
440,
272,
2808,
12,
652,
365,
5048,
370,
5534,
626,
314,
1453,
2112,
365,
314,
272,
1454,
2462,
14,
221,
20227,
282,
4413,
883,
506,
19353,
2138,
14,
272,
408,
272,
372,
446,
17,
199,
199,
318,
18310,
63,
831,
837,
272,
408,
11324,
4514,
402,
485,
2671,
14,
12991,
63,
831,
20693,
272,
372,
15536,
804,
342,
199,
199,
318,
3464,
63,
890,
8,
890,
29,
403,
304,
272,
408,
11324,
4514,
402,
485,
2671,
14,
2340,
63,
890,
20693,
272,
340,
1568,
365,
440,
488,
26,
267,
746,
1125,
480,
6031,
2462,
3464,
1568,
440,
3748,
531,
272,
372,
378,
199,
199,
533,
15536,
804,
8,
785,
304,
272,
408,
2543,
18234,
7283,
4514,
402,
485,
2671,
14,
6432,
804,
14,
339,
3599,
5880,
365,
26391,
701,
11075,
316,
291,
14,
9325,
63,
1205,
272,
1314,
365,
282,
5046,
626,
14086,
314,
1174,
402,
314,
4650,
14,
221,
16568,
2983,
402,
272,
314,
4650,
12,
10617,
12,
1077,
440,
506,
4224,
3967,
340,
314,
485,
2671,
859,
365,
272,
2066,
1202,
543,
376,
625,
20428,
1124,
831,
8497,
687,
2348,
8826,
4293,
272,
4781,
687,
642,
1021,
440,
9445,
15374,
3102,
14,
339,
408,
339,
347,
636,
826,
721,
277,
304,
267,
291,
14,
9325,
63,
1205,
275,
756,
339,
347,
16919,
8,
277,
12,
3618,
4173,
29,
403,
12,
2653,
4022,
17,
304,
267,
408,
11324,
4514,
402,
16919,
1252,
398,
2104,
14592,
4882,
12,
291,
14,
9325,
63,
1205,
365,
5847,
663,
370,
267,
715,
436,
2138,
22497,
4079,
641,
574,
402,
267,
1124,
2573,
4173,
4345,
221,
982,
652,
365,
2222,
13,
13091,
12,
2066,
314,
574,
365,
267,
5965,
7923,
436,
440,
663,
340,
652,
365,
2575,
28320,
14,
221,
961,
267,
365,
1006,
4224,
880,
626,
5796,
14,
9558,
1159,
702,
9834,
267,
10621,
1133,
15572,
436,
7978,
282,
12050,
5542,
14,
398,
408,
267,
340,
3618,
4173,
365,
488,
503,
3618,
4173,
26,
288,
291,
14,
9325,
63,
1205,
275,
715,
288,
372,
715,
267,
587,
26,
288,
340,
440,
291,
14,
9325,
63,
1205,
26,
355,
291,
14,
9325,
63,
1205,
275,
715,
355,
372,
715,
288,
587,
26,
355,
340,
2653,
690,
378,
26,
490,
492,
900,
490,
900,
14,
4532,
8,
2593,
9,
355,
372,
756,
339,
636,
4200,
363,
275,
16919,
339,
347,
636,
2224,
721,
277,
12,
6211,
12,
1139,
12,
7070,
304,
267,
291,
14,
3221,
342,
339,
347,
4683,
8,
277,
304,
267,
408,
9625,
314,
7283,
4650,
1041,
267,
327,
5787,
3492,
17396,
9296,
1133,
5965,
26962,
370,
511,
31,
221,
18615,
12690,
267,
327,
258,
370,
8826,
367,
6114,
12,
25396,
1233,
14,
267,
340,
440,
291,
14,
9325,
63,
1205,
26,
288,
746,
1125,
267,
291,
14,
9325,
63,
1205,
275,
756,
267,
372,
715,
339,
347,
14233,
8,
277,
304,
267,
372,
291,
14,
9325,
63,
1205,
199,
199,
3,
8051,
370,
4673,
626,
26791,
63,
973,
1990,
2797,
315,
282,
298,
2671,
2,
199,
63,
20172,
275,
756,
199,
3,
715,
1380,
440,
14043,
315,
282,
298,
2671,
2,
199,
63,
973,
275,
715
] |
[
11070,
13,
262,
8343,
367,
314,
2462,
859,
14,
199,
199,
1352,
867,
370,
506,
1202,
465,
282,
330,
6322,
13,
10957,
23080,
880,
626,
25396,
1233,
1630,
199,
1397,
1929,
370,
506,
28286,
367,
1380,
314,
2462,
859,
365,
440,
3451,
14,
199,
199,
51,
17417,
4503,
365,
447,
339,
862,
26,
267,
492,
485,
2671,
272,
871,
3545,
26,
267,
492,
485,
5869,
63,
2671,
465,
485,
2671,
199,
199,
624,
199,
3,
1316,
5203,
1454,
7645,
2013,
701,
2462,
3794,
27,
199,
3,
16068,
24985,
9560,
5220,
706,
18310,
1062,
1343,
63,
1222,
1062,
4458,
63,
2671,
1252,
199,
363,
452,
363,
275,
788,
705,
297,
283,
928,
63,
1222,
63,
2671,
297,
283,
2224,
297,
283,
362,
63,
5425,
297,
283,
12991,
63,
831,
297,
1779,
283,
20172,
63,
973,
297,
283,
6432,
804,
418,
199,
199,
3,
437,
7283,
574,
199,
8899,
63,
4283,
275,
499,
538,
2192,
199,
199,
3,
6944,
26,
642,
859,
883,
506,
8439,
14670,
315,
314,
3329,
10015,
2112,
12,
199,
3,
436,
880,
2746,
2166,
8925,
402,
1163,
4621,
1077,
506,
2289,
16142,
770,
14,
221,
15345,
12,
1006,
199,
3,
8925,
787,
4224,
1380,
4346,
641,
282,
805,
13,
991,
13,
1593,
5597,
14,
221,
9336,
7183,
199,
3,
787,
6980,
12,
314,
492,
4650,
1077,
440,
506,
376,
4976,
15988,
7558,
31,
680,
199,
199,
705,
275,
6064,
199,
199,
318,
1343,
63,
1222,
63,
2671,
8,
1593,
12,
1249,
12,
2074,
16420,
272,
408,
11324,
4514,
402,
485,
2671,
14,
928,
63,
1222,
63,
2671,
1252,
339,
3599,
5880,
365,
26391,
701,
10663,
3238,
626,
1124,
589,
1040,
365,
282,
272,
2008,
436,
1124,
958,
1040,
365,
282,
2600,
14,
221,
982,
376,
1919,
365,
4915,
272,
436,
652,
365,
14838,
334,
6777,
883,
506,
4224,
701,
485,
2671,
14,
2224,
1012,
652,
365,
272,
15604,
436,
6548,
365,
4224,
27,
1006,
1163,
4967,
787,
12487,
734,
272,
701,
1808,
5190,
14,
1361,
63,
2804,
1252,
339,
982,
314,
7934,
805,
4882,
26791,
63,
973,
314,
13483,
911,
506,
272,
4915,
1380,
314,
805,
2529,
14,
339,
408,
272,
340,
730,
8,
589,
9,
1137,
730,
8,
2960,
5109,
267,
746,
3146,
480,
18,
977,
1680,
1471,
506,
282,
2008,
531,
272,
340,
730,
8,
958,
9,
1137,
730,
8,
807,
5109,
267,
746,
3146,
480,
19,
6883,
1680,
1471,
506,
282,
1211,
531,
272,
2288,
485,
973,
272,
485,
973,
275,
756,
272,
862,
26,
267,
805,
2031,
589,
12,
1011,
958,
9,
272,
871,
14838,
26,
267,
986,
272,
871,
26,
267,
492,
5190,
267,
5190,
14,
1361,
63,
2804,
342,
272,
485,
973,
275,
715,
272,
2288,
485,
20172,
272,
340,
485,
20172,
26,
267,
485,
20172,
275,
756,
267,
746,
13483,
199,
199,
318,
4458,
837,
272,
408,
11324,
4514,
402,
485,
2671,
14,
2224,
20693,
272,
746,
14838,
199,
199,
318,
664,
63,
5425,
837,
272,
408,
11324,
4514,
402,
485,
2671,
14,
362,
63,
5425,
1252,
339,
9336,
642,
859,
1077,
1454,
506,
1202,
1380,
485,
2671,
578,
365,
440,
272,
2808,
12,
652,
365,
5048,
370,
5534,
626,
314,
1453,
2112,
365,
314,
272,
1454,
2462,
14,
221,
20227,
282,
4413,
883,
506,
19353,
2138,
14,
272,
408,
272,
372,
446,
17,
199,
199,
318,
18310,
63,
831,
837,
272,
408,
11324,
4514,
402,
485,
2671,
14,
12991,
63,
831,
20693,
272,
372,
15536,
804,
342,
199,
199,
318,
3464,
63,
890,
8,
890,
29,
403,
304,
272,
408,
11324,
4514,
402,
485,
2671,
14,
2340,
63,
890,
20693,
272,
340,
1568,
365,
440,
488,
26,
267,
746,
1125,
480,
6031,
2462,
3464,
1568,
440,
3748,
531,
272,
372,
378,
199,
199,
533,
15536,
804,
8,
785,
304,
272,
408,
2543,
18234,
7283,
4514,
402,
485,
2671,
14,
6432,
804,
14,
339,
3599,
5880,
365,
26391,
701,
11075,
316,
291,
14,
9325,
63,
1205,
272,
1314,
365,
282,
5046,
626,
14086,
314,
1174,
402,
314,
4650,
14,
221,
16568,
2983,
402,
272,
314,
4650,
12,
10617,
12,
1077,
440,
506,
4224,
3967,
340,
314,
485,
2671,
859,
365,
272,
2066,
1202,
543,
376,
625,
20428,
1124,
831,
8497,
687,
2348,
8826,
4293,
272,
4781,
687,
642,
1021,
440,
9445,
15374,
3102,
14,
339,
408,
339,
347,
636,
826,
721,
277,
304,
267,
291,
14,
9325,
63,
1205,
275,
756,
339,
347,
16919,
8,
277,
12,
3618,
4173,
29,
403,
12,
2653,
4022,
17,
304,
267,
408,
11324,
4514,
402,
16919,
1252,
398,
2104,
14592,
4882,
12,
291,
14,
9325,
63,
1205,
365,
5847,
663,
370,
267,
715,
436,
2138,
22497,
4079,
641,
574,
402,
267,
1124,
2573,
4173,
4345,
221,
982,
652,
365,
2222,
13,
13091,
12,
2066,
314,
574,
365,
267,
5965,
7923,
436,
440,
663,
340,
652,
365,
2575,
28320,
14,
221,
961,
267,
365,
1006,
4224,
880,
626,
5796,
14,
9558,
1159,
702,
9834,
267,
10621,
1133,
15572,
436,
7978,
282,
12050,
5542,
14,
398,
408,
267,
340,
3618,
4173,
365,
488,
503,
3618,
4173,
26,
288,
291,
14,
9325,
63,
1205,
275,
715,
288,
372,
715,
267,
587,
26,
288,
340,
440,
291,
14,
9325,
63,
1205,
26,
355,
291,
14,
9325,
63,
1205,
275,
715,
355,
372,
715,
288,
587,
26,
355,
340,
2653,
690,
378,
26,
490,
492,
900,
490,
900,
14,
4532,
8,
2593,
9,
355,
372,
756,
339,
636,
4200,
363,
275,
16919,
339,
347,
636,
2224,
721,
277,
12,
6211,
12,
1139,
12,
7070,
304,
267,
291,
14,
3221,
342,
339,
347,
4683,
8,
277,
304,
267,
408,
9625,
314,
7283,
4650,
1041,
267,
327,
5787,
3492,
17396,
9296,
1133,
5965,
26962,
370,
511,
31,
221,
18615,
12690,
267,
327,
258,
370,
8826,
367,
6114,
12,
25396,
1233,
14,
267,
340,
440,
291,
14,
9325,
63,
1205,
26,
288,
746,
1125,
267,
291,
14,
9325,
63,
1205,
275,
756,
267,
372,
715,
339,
347,
14233,
8,
277,
304,
267,
372,
291,
14,
9325,
63,
1205,
199,
199,
3,
8051,
370,
4673,
626,
26791,
63,
973,
1990,
2797,
315,
282,
298,
2671,
2,
199,
63,
20172,
275,
756,
199,
3,
715,
1380,
440,
14043,
315,
282,
298,
2671,
2,
199,
63,
973,
275,
715,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,
1,
1
] |
AVGInnovationLabs/DoNotSnap
|
train.py
|
1
|
4886
|
import cv2
import sys
import pickle
import numpy as np
import matplotlib.pyplot as plt
from AffineInvariantFeatures import AffineInvariant
from TemplateMatcher import TemplateMatch, Templates
from PIL import Image
from itertools import izip_longest
from sklearn.cross_validation import train_test_split
from sklearn.grid_search import GridSearchCV
from sklearn.metrics import classification_report, roc_curve, auc, confusion_matrix, accuracy_score
from sklearn.pipeline import Pipeline
from sklearn.tree import export_graphviz, DecisionTreeClassifier
def line_count(filename):
with open(filename) as data:
return sum(1 for line in data)
def read_image(filename):
return np.array(Image.open(filename.strip('\n')).convert('L'), np.uint8)
def read_file(filename, limit=0):
n = 0
lines = line_count(filename)
with open(filename) as data:
while True:
line = next(data, None)
if not line or (limit and n >= limit):
break
n += 1
print '\r%s %d/%d' % (filename, n, limit or lines),
try:
yield read_image(line)
except:
continue
def get_templates():
return np.array(list(read_file('templates.txt')))
def get_images(limit=0):
positive = read_file('positive.txt', limit / 2 if limit else 0)
negative = read_file('negative.txt', limit / 2 if limit else 0)
for p, n in izip_longest(positive, negative):
if p is not None:
yield (1, p)
if n is not None:
yield (0, n)
def get_dataset(limit):
return map(np.asarray, zip(*get_images(limit)))
def plot_roc(fpr, tpr, roc_auc):
# Plot all ROC curves
plt.figure()
plt.plot(fpr, tpr, label='ROC curve (area = %0.2f)' % roc_auc)
plt.plot([0, 1], [0, 1], 'k--')
plt.xlim([0.0, 1.0])
plt.ylim([0.0, 1.05])
plt.xlabel('False Positive Rate')
plt.ylabel('True Positive Rate')
plt.title('Affine Invariant SURF + Decision Tree Classifier')
plt.legend(loc='lower right')
plt.show()
def plot_importance(feature_count, importances, indices):
plt.figure()
plt.title('Feature importances')
plt.bar(range(feature_count), importances[indices], color='r', align='center')
plt.xticks(range(feature_count), indices)
plt.xlim([-1, feature_count])
plt.show()
def main(name, dataset_size):
templates = get_templates()
print 'templates: %d' % len(templates)
labels, samples = get_dataset(dataset_size)
print 'samples: %d' % len(samples)
extractor = cv2.FeatureDetector_create('SURF')
detector = cv2.DescriptorExtractor_create('SURF')
print 'applying affine invariant transform'
affine = AffineInvariant(extractor, detector)
templates = affine.transform(templates)
samples = affine.transform(samples)
model = Pipeline([
('match', TemplateMatch(Templates(templates))), # XXX: hack to bypass cloning error
# ('reduce_dim', PCA(n_components = 12 * 6))
])
samples = model.fit_transform(samples)
rng = np.random.RandomState()
X_train, X_test, y_train, y_test = train_test_split(samples, labels, test_size=0.5, random_state=rng)
print 'train: %d, test: %d' % (len(X_train), len(X_test))
params = dict(
min_samples_split = [5, 6, 7, 8, 9, 10],
min_samples_leaf = [3, 4, 5, 6, 7],
max_leaf_nodes = [10, 9, 8, 7, 6],
class_weight = [{1: w} for w in [10, 8, 4, 2, 1]]
)
tree = DecisionTreeClassifier(max_depth=4, random_state=rng)
cvmodel = GridSearchCV(tree, params, cv=10, n_jobs=cv2.getNumberOfCPUs())
cvmodel.fit(X_train, y_train)
print 'grid scores'
for params, mean_score, scores in cvmodel.grid_scores_:
print '%0.3f (+/-%0.03f) for %r' % (mean_score, scores.std() * 2, params)
print 'best parameters'
print cvmodel.best_params_
importances = cvmodel.best_estimator_.feature_importances_
indices = np.argsort(importances)[::-1]
plot_importance(6, importances, indices)
y_pred = cvmodel.predict(X_test)
accuracy = accuracy_score(y_test, y_pred)
print 'accuracy: %f' % accuracy
print classification_report(y_test, y_pred)
print confusion_matrix(y_test, y_pred)
y_score = cvmodel.predict_proba(X_test)[:, 1]
fpr, tpr, _ = roc_curve(y_test, y_score)
roc_auc = auc(fpr, tpr)
plot_roc(fpr, tpr, roc_auc)
export_graphviz(cvmodel.best_estimator_, out_file=name + '.dot', class_names=['background', 'badge'], filled=True, rounded=True, special_characters=True)
pickle.dump(dict(params=params, pipe=model, model=cvmodel.best_estimator_), open(name + '.pkl', 'wb'))
if __name__ == '__main__':
name = sys.argv[1] if len(sys.argv) >= 2 else 'classifier'
dataset_size = int(sys.argv[2]) if len(sys.argv) >= 3 else 0
main(name, dataset_size)
|
gpl-3.0
|
[
646,
6277,
18,
199,
646,
984,
199,
646,
5927,
199,
646,
2680,
465,
980,
199,
646,
8027,
14,
13563,
465,
4488,
199,
199,
504,
31030,
1132,
607,
8759,
10807,
492,
31030,
1132,
607,
8759,
199,
504,
5458,
16073,
492,
5458,
4486,
12,
31273,
199,
199,
504,
14937,
492,
6047,
199,
504,
7975,
492,
28697,
63,
20820,
199,
199,
504,
6357,
14,
7925,
63,
6136,
492,
3560,
63,
396,
63,
1294,
199,
504,
6357,
14,
3825,
63,
1733,
492,
32570,
199,
504,
6357,
14,
6759,
492,
12505,
63,
3070,
12,
882,
67,
63,
11895,
12,
282,
947,
12,
26314,
63,
3642,
12,
12862,
63,
3397,
199,
504,
6357,
14,
7379,
492,
19090,
199,
504,
6357,
14,
2350,
492,
4843,
63,
2180,
17249,
12,
1487,
24116,
8508,
421,
199,
318,
1004,
63,
835,
8,
1501,
304,
272,
543,
1551,
8,
1501,
9,
465,
666,
26,
267,
372,
3089,
8,
17,
367,
1004,
315,
666,
9,
421,
199,
318,
1586,
63,
1569,
8,
1501,
304,
272,
372,
980,
14,
1144,
8,
3491,
14,
1490,
8,
1501,
14,
1913,
2258,
78,
11103,
3916,
360,
44,
659,
980,
14,
1635,
24,
9,
421,
199,
318,
1586,
63,
493,
8,
1501,
12,
2304,
29,
16,
304,
272,
302,
275,
378,
272,
2385,
275,
1004,
63,
835,
8,
1501,
9,
339,
543,
1551,
8,
1501,
9,
465,
666,
26,
267,
1830,
715,
26,
288,
1004,
275,
2163,
8,
576,
12,
488,
9,
288,
340,
440,
1004,
503,
334,
3097,
436,
302,
2356,
2304,
304,
355,
2059,
953,
302,
847,
413,
288,
870,
1557,
82,
5,
83,
450,
68,
3149,
68,
7,
450,
334,
1501,
12,
302,
12,
2304,
503,
2385,
395,
288,
862,
26,
355,
1995,
1586,
63,
1569,
8,
604,
9,
288,
871,
26,
355,
1980,
421,
199,
318,
664,
63,
5876,
837,
272,
372,
980,
14,
1144,
8,
513,
8,
739,
63,
493,
360,
5876,
14,
2424,
7058,
421,
199,
318,
664,
63,
4782,
8,
3097,
29,
16,
304,
272,
7317,
275,
1586,
63,
493,
360,
8965,
14,
2424,
297,
2304,
1182,
499,
340,
2304,
587,
378,
9,
272,
6946,
275,
1586,
63,
493,
360,
7371,
14,
2424,
297,
2304,
1182,
499,
340,
2304,
587,
378,
9,
339,
367,
299,
12,
302,
315,
28697,
63,
20820,
8,
8965,
12,
6946,
304,
267,
340,
299,
365,
440,
488,
26,
288,
1995,
334,
17,
12,
299,
9,
267,
340,
302,
365,
440,
488,
26,
288,
1995,
334,
16,
12,
302,
9,
421,
199,
318,
664,
63,
5214,
8,
3097,
304,
272,
372,
2341,
8,
1590,
14,
8748,
12,
3482,
2031,
362,
63,
4782,
8,
3097,
1724,
421,
199,
318,
5137,
63,
26786,
8,
70,
2700,
12,
307,
2700,
12,
882,
67,
63,
19129,
304,
272,
327,
14794,
1006,
9769,
35,
1094,
2310,
272,
4488,
14,
8941,
342,
339,
4488,
14,
2798,
8,
70,
2700,
12,
307,
2700,
12,
1768,
534,
24762,
15318,
334,
6789,
275,
450,
16,
14,
18,
70,
3171,
450,
882,
67,
63,
19129,
9,
339,
4488,
14,
2798,
779,
16,
12,
413,
467,
359,
16,
12,
413,
467,
283,
75,
306,
358,
272,
4488,
14,
18512,
779,
16,
14,
16,
12,
413,
14,
16,
566,
272,
4488,
14,
18123,
779,
16,
14,
16,
12,
413,
14,
1717,
566,
272,
4488,
14,
14168,
360,
797,
30245,
26311,
358,
272,
4488,
14,
13849,
360,
549,
30245,
26311,
358,
272,
4488,
14,
1213,
360,
19256,
1132,
1010,
8759,
428,
1230,
38,
435,
1487,
3688,
12178,
8465,
5541,
358,
272,
4488,
14,
10231,
8,
2102,
534,
2325,
2451,
358,
272,
4488,
14,
2384,
342,
421,
199,
318,
5137,
63,
646,
554,
8,
4445,
63,
835,
12,
492,
13236,
12,
4918,
304,
272,
4488,
14,
8941,
342,
272,
4488,
14,
1213,
360,
5968,
492,
13236,
358,
272,
4488,
14,
1700,
8,
1842,
8,
4445,
63,
835,
395,
492,
13236,
59,
4108,
467,
3164,
534,
82,
297,
6998,
534,
4218,
358,
272,
4488,
14,
26217,
8,
1842,
8,
4445,
63,
835,
395,
4918,
9,
272,
4488,
14,
18512,
11468,
17,
12,
3878,
63,
835,
566,
272,
4488,
14,
2384,
342,
421,
199,
318,
2446,
8,
354,
12,
4789,
63,
890,
304,
272,
7009,
275,
664,
63,
5876,
342,
339,
870,
283,
5876,
26,
450,
68,
7,
450,
822,
8,
5876,
9,
339,
3628,
12,
5845,
275,
664,
63,
5214,
8,
5214,
63,
890,
9,
339,
870,
283,
3356,
26,
450,
68,
7,
450,
822,
8,
3356,
9,
339,
31295,
275,
6277,
18,
14,
5968,
24402,
63,
981,
360,
51,
1230,
38,
358,
272,
17842,
275,
6277,
18,
14,
4311,
11039,
63,
981,
360,
51,
1230,
38,
358,
339,
870,
283,
4998,
316,
31435,
30326,
5793,
7,
339,
31435,
275,
31030,
1132,
607,
8759,
8,
22677,
12,
17842,
9,
272,
7009,
275,
31435,
14,
4711,
8,
5876,
9,
272,
5845,
275,
31435,
14,
4711,
8,
3356,
9,
339,
1402,
275,
19090,
779,
267,
661,
1431,
297,
5458,
4486,
8,
17969,
8,
5876,
11508,
221,
327,
5787,
26,
11176,
370,
21115,
824,
19718,
1125,
267,
327,
661,
5270,
63,
3572,
297,
25266,
8,
78,
63,
4608,
275,
3144,
627,
1227,
430,
272,
4794,
339,
5845,
275,
1402,
14,
3269,
63,
4711,
8,
3356,
9,
339,
9038,
275,
980,
14,
2355,
14,
15726,
342,
339,
1323,
63,
2834,
12,
1323,
63,
396,
12,
612,
63,
2834,
12,
612,
63,
396,
275,
3560,
63,
396,
63,
1294,
8,
3356,
12,
3628,
12,
511,
63,
890,
29,
16,
14,
21,
12,
2196,
63,
929,
29,
12686,
9,
272,
870,
283,
2834,
26,
450,
68,
12,
511,
26,
450,
68,
7,
450,
334,
552,
8,
56,
63,
2834,
395,
822,
8,
56,
63,
396,
430,
339,
1862,
275,
1211,
8,
267,
1748,
63,
3356,
63,
1294,
275,
359,
21,
12,
1227,
12,
1520,
12,
1695,
12,
1749,
12,
1616,
467,
267,
1748,
63,
3356,
63,
8914,
275,
359,
19,
12,
841,
12,
959,
12,
1227,
12,
1520,
467,
267,
1390,
63,
8914,
63,
2415,
275,
359,
709,
12,
1749,
12,
1695,
12,
1520,
12,
1227,
467,
267,
1021,
63,
3463,
275,
8910,
17,
26,
336,
93,
367,
336,
315,
359,
709,
12,
1695,
12,
841,
12,
499,
12,
413,
2677,
272,
776,
339,
3123,
275,
1487,
24116,
8508,
8,
988
] |
[
6277,
18,
199,
646,
984,
199,
646,
5927,
199,
646,
2680,
465,
980,
199,
646,
8027,
14,
13563,
465,
4488,
199,
199,
504,
31030,
1132,
607,
8759,
10807,
492,
31030,
1132,
607,
8759,
199,
504,
5458,
16073,
492,
5458,
4486,
12,
31273,
199,
199,
504,
14937,
492,
6047,
199,
504,
7975,
492,
28697,
63,
20820,
199,
199,
504,
6357,
14,
7925,
63,
6136,
492,
3560,
63,
396,
63,
1294,
199,
504,
6357,
14,
3825,
63,
1733,
492,
32570,
199,
504,
6357,
14,
6759,
492,
12505,
63,
3070,
12,
882,
67,
63,
11895,
12,
282,
947,
12,
26314,
63,
3642,
12,
12862,
63,
3397,
199,
504,
6357,
14,
7379,
492,
19090,
199,
504,
6357,
14,
2350,
492,
4843,
63,
2180,
17249,
12,
1487,
24116,
8508,
421,
199,
318,
1004,
63,
835,
8,
1501,
304,
272,
543,
1551,
8,
1501,
9,
465,
666,
26,
267,
372,
3089,
8,
17,
367,
1004,
315,
666,
9,
421,
199,
318,
1586,
63,
1569,
8,
1501,
304,
272,
372,
980,
14,
1144,
8,
3491,
14,
1490,
8,
1501,
14,
1913,
2258,
78,
11103,
3916,
360,
44,
659,
980,
14,
1635,
24,
9,
421,
199,
318,
1586,
63,
493,
8,
1501,
12,
2304,
29,
16,
304,
272,
302,
275,
378,
272,
2385,
275,
1004,
63,
835,
8,
1501,
9,
339,
543,
1551,
8,
1501,
9,
465,
666,
26,
267,
1830,
715,
26,
288,
1004,
275,
2163,
8,
576,
12,
488,
9,
288,
340,
440,
1004,
503,
334,
3097,
436,
302,
2356,
2304,
304,
355,
2059,
953,
302,
847,
413,
288,
870,
1557,
82,
5,
83,
450,
68,
3149,
68,
7,
450,
334,
1501,
12,
302,
12,
2304,
503,
2385,
395,
288,
862,
26,
355,
1995,
1586,
63,
1569,
8,
604,
9,
288,
871,
26,
355,
1980,
421,
199,
318,
664,
63,
5876,
837,
272,
372,
980,
14,
1144,
8,
513,
8,
739,
63,
493,
360,
5876,
14,
2424,
7058,
421,
199,
318,
664,
63,
4782,
8,
3097,
29,
16,
304,
272,
7317,
275,
1586,
63,
493,
360,
8965,
14,
2424,
297,
2304,
1182,
499,
340,
2304,
587,
378,
9,
272,
6946,
275,
1586,
63,
493,
360,
7371,
14,
2424,
297,
2304,
1182,
499,
340,
2304,
587,
378,
9,
339,
367,
299,
12,
302,
315,
28697,
63,
20820,
8,
8965,
12,
6946,
304,
267,
340,
299,
365,
440,
488,
26,
288,
1995,
334,
17,
12,
299,
9,
267,
340,
302,
365,
440,
488,
26,
288,
1995,
334,
16,
12,
302,
9,
421,
199,
318,
664,
63,
5214,
8,
3097,
304,
272,
372,
2341,
8,
1590,
14,
8748,
12,
3482,
2031,
362,
63,
4782,
8,
3097,
1724,
421,
199,
318,
5137,
63,
26786,
8,
70,
2700,
12,
307,
2700,
12,
882,
67,
63,
19129,
304,
272,
327,
14794,
1006,
9769,
35,
1094,
2310,
272,
4488,
14,
8941,
342,
339,
4488,
14,
2798,
8,
70,
2700,
12,
307,
2700,
12,
1768,
534,
24762,
15318,
334,
6789,
275,
450,
16,
14,
18,
70,
3171,
450,
882,
67,
63,
19129,
9,
339,
4488,
14,
2798,
779,
16,
12,
413,
467,
359,
16,
12,
413,
467,
283,
75,
306,
358,
272,
4488,
14,
18512,
779,
16,
14,
16,
12,
413,
14,
16,
566,
272,
4488,
14,
18123,
779,
16,
14,
16,
12,
413,
14,
1717,
566,
272,
4488,
14,
14168,
360,
797,
30245,
26311,
358,
272,
4488,
14,
13849,
360,
549,
30245,
26311,
358,
272,
4488,
14,
1213,
360,
19256,
1132,
1010,
8759,
428,
1230,
38,
435,
1487,
3688,
12178,
8465,
5541,
358,
272,
4488,
14,
10231,
8,
2102,
534,
2325,
2451,
358,
272,
4488,
14,
2384,
342,
421,
199,
318,
5137,
63,
646,
554,
8,
4445,
63,
835,
12,
492,
13236,
12,
4918,
304,
272,
4488,
14,
8941,
342,
272,
4488,
14,
1213,
360,
5968,
492,
13236,
358,
272,
4488,
14,
1700,
8,
1842,
8,
4445,
63,
835,
395,
492,
13236,
59,
4108,
467,
3164,
534,
82,
297,
6998,
534,
4218,
358,
272,
4488,
14,
26217,
8,
1842,
8,
4445,
63,
835,
395,
4918,
9,
272,
4488,
14,
18512,
11468,
17,
12,
3878,
63,
835,
566,
272,
4488,
14,
2384,
342,
421,
199,
318,
2446,
8,
354,
12,
4789,
63,
890,
304,
272,
7009,
275,
664,
63,
5876,
342,
339,
870,
283,
5876,
26,
450,
68,
7,
450,
822,
8,
5876,
9,
339,
3628,
12,
5845,
275,
664,
63,
5214,
8,
5214,
63,
890,
9,
339,
870,
283,
3356,
26,
450,
68,
7,
450,
822,
8,
3356,
9,
339,
31295,
275,
6277,
18,
14,
5968,
24402,
63,
981,
360,
51,
1230,
38,
358,
272,
17842,
275,
6277,
18,
14,
4311,
11039,
63,
981,
360,
51,
1230,
38,
358,
339,
870,
283,
4998,
316,
31435,
30326,
5793,
7,
339,
31435,
275,
31030,
1132,
607,
8759,
8,
22677,
12,
17842,
9,
272,
7009,
275,
31435,
14,
4711,
8,
5876,
9,
272,
5845,
275,
31435,
14,
4711,
8,
3356,
9,
339,
1402,
275,
19090,
779,
267,
661,
1431,
297,
5458,
4486,
8,
17969,
8,
5876,
11508,
221,
327,
5787,
26,
11176,
370,
21115,
824,
19718,
1125,
267,
327,
661,
5270,
63,
3572,
297,
25266,
8,
78,
63,
4608,
275,
3144,
627,
1227,
430,
272,
4794,
339,
5845,
275,
1402,
14,
3269,
63,
4711,
8,
3356,
9,
339,
9038,
275,
980,
14,
2355,
14,
15726,
342,
339,
1323,
63,
2834,
12,
1323,
63,
396,
12,
612,
63,
2834,
12,
612,
63,
396,
275,
3560,
63,
396,
63,
1294,
8,
3356,
12,
3628,
12,
511,
63,
890,
29,
16,
14,
21,
12,
2196,
63,
929,
29,
12686,
9,
272,
870,
283,
2834,
26,
450,
68,
12,
511,
26,
450,
68,
7,
450,
334,
552,
8,
56,
63,
2834,
395,
822,
8,
56,
63,
396,
430,
339,
1862,
275,
1211,
8,
267,
1748,
63,
3356,
63,
1294,
275,
359,
21,
12,
1227,
12,
1520,
12,
1695,
12,
1749,
12,
1616,
467,
267,
1748,
63,
3356,
63,
8914,
275,
359,
19,
12,
841,
12,
959,
12,
1227,
12,
1520,
467,
267,
1390,
63,
8914,
63,
2415,
275,
359,
709,
12,
1749,
12,
1695,
12,
1520,
12,
1227,
467,
267,
1021,
63,
3463,
275,
8910,
17,
26,
336,
93,
367,
336,
315,
359,
709,
12,
1695,
12,
841,
12,
499,
12,
413,
2677,
272,
776,
339,
3123,
275,
1487,
24116,
8508,
8,
988,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
sassystacks/DASS
|
Drone_Flight/ned_Test_roll.py
|
1
|
3898
|
from dronekit import connect, VehicleMode, LocationGlobal, LocationGlobalRelative
from pymavlink import mavutil # Needed for command message definitions
import logging
import time
import math
logging.basicConfig(filename='Roll_log.log', format = '%(levelname)s:%(asctime)s: %(message)s', level=logging.INFO)
import argparse
parser = argparse.ArgumentParser(description='Control Copter and send commands in GUIDED mode ')
parser.add_argument('--connect', default = 'tcp:10.0.0.1:14550')
args = parser.parse_args()
connection_string = args.connect
# Connect to the Vehicle
print 'Connecting to vehicle on: %s' % connection_string
vehicle = connect(connection_string, wait_ready=True)
def arm_and_takeoff(aTargetAltitude):
"""
Arms vehicle and fly to aTargetAltitude.
"""
print "Basic pre-arm checks"
# Don't let the user try to arm until autopilot is ready
while not vehicle.is_armable:
print " Waiting for vehicle to initialise..."
print "gps: ", vehicle.gps_0.fix_type
print "EKF: ", vehicle._ekf_poshorizabs
print "VehicleMode: ", vehicle.mode
time.sleep(1)
print "Arming motors"
# Copter should arm in GUIDED mode
vehicle.mode = VehicleMode("GUIDED")
vehicle.armed = True
while not vehicle.armed:
print " Waiting for arming..."
time.sleep(1)
print(vehicle.mode )
print "Taking off!"
vehicle.mode = VehicleMode("GUIDED")
vehicle.simple_takeoff(aTargetAltitude) # Take off to target altitude
# Wait until the vehicle reaches a safe height before processing the goto (otherwise the command
# after Vehicle.simple_takeoff will execute immediately).
while True:
alt_message = vehicle.location.local_frame
logging.info(alt_message)
alt_current = " Altitude: %s" % vehicle.location.global_relative_frame.alt
print " vehicle mode: ", vehicle.mode
logging.info(alt_message)
if vehicle.location.global_relative_frame.alt>=aTargetAltitude*0.95: #Trigger just below target alt.
print "Reached target altitude"
break
time.sleep(1)
def send_ned_velocity(velocity_x, velocity_y, velocity_z, duration):
msg = vehicle.message_factory.set_position_target_local_ned_encode(
0, # time_boot_ms (not used)
0, 0, # target system, target component
mavutil.mavlink.MAV_FRAME_LOCAL_NED, # frame
0b0000111111000111, # type_mask (only speeds enabled)
0, 0, 0, # x, y, z positions (not used)
velocity_x, velocity_y, velocity_z, # x, y, z velocity in m/s
0, 0, 0, # x, y, z acceleration (not supported yet, ignored in GCS_Mavlink)
0, 0) # yaw, yaw_rate (not supported yet, ignored in GCS_Mavlink)
# send command to vehicle on 1 Hz cycle
for x in range(0,duration):
vehicle.send_mavlink(msg)
time.sleep(1)
def update_pos():
position_log = vehicle.location.local_frame
heading_log = "vehicle heading: %s" % vehicle.heading
print(vehicle.location.local_frame)
print (heading_log)
logging.info(position_log)
logging.info(heading_log)
update_pos()
#Arm and take of to altitude of 5 meters
arm_and_takeoff(3)
update_pos()
time.sleep(2)
roll1 = 1
send_ned_velocity(0,roll1,0,1)
update_msg = "roll1 velocity: %s" % roll1
print(update_msg)
logging.info(update_msg)
update_pos()
send_ned_velocity(0,0,0,1)
roll2 = -1
send_ned_velocity(0,roll2,0,1)
update_msg = "roll2 velocity: %s" % roll1
print(update_msg)
logging.info(update_msg)
update_pos()
send_ned_velocity(0,0,0,1)
update_pos()
time.sleep(2)
print("Setting LAND mode...")
vehicle.mode = VehicleMode("LAND")
# Close vehicle object before exiting script
print "Close vehicle object"
vehicle.close()
|
mit
|
[
504,
16642,
368,
6065,
492,
4907,
12,
25777,
13438,
1385,
12,
12625,
7025,
12,
12625,
7025,
15277,
202,
199,
504,
1134,
24610,
492,
11456,
1974,
327,
28196,
367,
1414,
1245,
10269,
202,
199,
646,
2050,
202,
199,
646,
900,
202,
199,
646,
3473,
2999,
199,
4806,
14,
19602,
8,
1501,
534,
24363,
63,
793,
14,
793,
297,
1475,
275,
9487,
20056,
9,
83,
19648,
18331,
9,
83,
26,
2818,
1188,
9,
83,
297,
2166,
29,
4806,
14,
4531,
9,
2999,
199,
646,
7534,
202,
199,
2087,
275,
7534,
14,
10730,
8,
1802,
534,
3717,
29622,
351,
436,
3222,
3718,
315,
21645,
1149,
818,
5320,
202,
199,
2087,
14,
525,
63,
2094,
4517,
2242,
297,
849,
275,
283,
8815,
26,
709,
14,
16,
14,
16,
14,
17,
26,
1079,
16859,
358,
202,
199,
589,
275,
1798,
14,
1122,
63,
589,
342,
202,
199,
2105,
63,
875,
275,
1249,
14,
2242,
2999,
199,
3,
15175,
370,
314,
25777,
13438,
202,
199,
1361,
283,
32000,
370,
27616,
641,
26,
450,
83,
7,
450,
1950,
63,
875,
202,
199,
20073,
275,
4907,
8,
2105,
63,
875,
12,
3618,
63,
2179,
29,
549,
9,
2999,
199,
318,
30701,
63,
460,
63,
11066,
1997,
8,
65,
4277,
2439,
7951,
304,
1128,
408,
1128,
1952,
706,
27616,
436,
23158,
370,
282,
4277,
2439,
7951,
14,
1128,
408,
2958,
870,
298,
6845,
876,
13,
5362,
5920,
2,
1128,
327,
7529,
1133,
4691,
314,
922,
862,
370,
30701,
5133,
6384,
411,
73,
1653,
365,
10144,
1128,
1830,
440,
27616,
14,
374,
63,
5362,
461,
26,
1039,
870,
298,
13144,
316,
367,
27616,
370,
2536,
572,
11500,
1039,
870,
298,
25556,
26,
3872,
27616,
14,
25556,
63,
16,
14,
970,
63,
466,
1039,
870,
298,
11959,
38,
26,
3872,
27616,
423,
5711,
70,
63,
555,
609,
5546,
2101,
1039,
870,
298,
15169,
13438,
1385,
26,
3872,
27616,
14,
632,
1039,
900,
14,
4532,
8,
17,
9,
2958,
870,
298,
1596,
14566,
333,
357,
1384,
2,
1128,
327,
29622,
351,
1077,
30701,
315,
21645,
1149,
818,
1128,
27616,
14,
632,
275,
25777,
13438,
1385,
480,
17856,
1149,
531,
1128,
27616,
14,
285,
3594,
275,
715,
2958,
1830,
440,
27616,
14,
285,
3594,
26,
1039,
870,
298,
13144,
316,
367,
601,
14566,
11500,
1039,
900,
14,
4532,
8,
17,
9,
2958,
870,
8,
20073,
14,
632,
776,
2958,
870,
298,
52,
11124,
2331,
9539,
1128,
27616,
14,
632,
275,
25777,
13438,
1385,
480,
17856,
1149,
531,
1128,
27616,
14,
4129,
63,
11066,
1997,
8,
65,
4277,
2439,
7951,
9,
327,
18146,
2331,
370,
1347,
29534,
1128,
327,
13144,
5133,
314,
27616,
12276,
397,
282,
5048,
4569,
2544,
6661,
314,
18878,
334,
26617,
314,
1414,
1128,
327,
221,
2410,
25777,
13438,
14,
4129,
63,
11066,
1997,
911,
5341,
9939,
680,
1128,
1830,
715,
26,
1039,
8791,
63,
1188,
275,
27616,
14,
1985,
14,
1832,
63,
1943,
1039,
2050,
14,
815,
8,
4478,
63,
1188,
9,
1039,
8791,
63,
1818,
275,
298,
4580,
7951,
26,
450,
83,
2,
450,
27616,
14,
1985,
14,
2966,
63,
6188,
63,
1943,
14,
4478,
1039,
870,
298,
27616,
818,
26,
3872,
27616,
14,
632,
1039,
2050,
14,
815,
8,
4478,
63,
1188,
9,
1039,
340,
27616,
14,
1985,
14,
2966,
63,
6188,
63,
1943,
14,
4478,
8119,
65,
4277,
2439,
7951,
10,
16,
14,
2720,
26,
327,
16276,
2951,
5084,
1347,
8791,
14,
1675,
870,
298,
497,
4583,
1347,
29534,
2,
1675,
2059,
1039,
900,
14,
4532,
8,
17,
9,
1223,
8065,
199,
318,
3222,
63,
7439,
63,
16350,
8,
16350,
63,
88,
12,
20508,
63,
89,
12,
20508,
63,
90,
12,
7373,
304,
2958,
1499,
275,
27616,
14,
1188,
63,
3702,
14,
409,
63,
3124,
63,
1375,
63,
1832,
63,
7439,
63,
2143,
8,
1039,
378,
12,
755,
327,
900,
63,
4930,
63,
706,
334,
1397,
1202,
9,
1039,
378,
12,
378,
12,
259,
327,
1347,
2656,
12,
1347,
3931,
1039,
11456,
1974,
14,
24610,
14,
19273,
63,
12683,
63,
7486,
63,
46,
1149,
12,
327,
2787,
1039,
378,
66,
993,
6984,
845,
4183,
845,
12,
327,
730,
63,
2629,
334,
2118,
8112,
83,
5223,
9,
1039,
378,
12,
378,
12,
378,
12,
327,
671,
12,
612,
12,
1315,
12266,
334,
1397,
1202,
9,
1039,
20508,
63,
88,
12,
20508,
63,
89,
12,
20508,
63,
90,
12,
327,
671,
12,
612,
12,
1315,
20508,
315,
333,
15,
83,
1039,
378,
12,
378,
12,
378,
12,
327,
671,
12,
612,
12,
1315,
1066,
29765,
334,
1397,
3748,
5966,
12,
5525,
315,
598,
3298,
63,
45,
1214,
1073,
9,
1039,
378,
12,
378,
9,
259,
327,
612,
10084,
12,
612,
10084,
63,
1866,
334,
1397,
3748,
5966,
12,
5525,
315,
598,
3298,
63,
45,
1214,
1073,
9,
2958,
327,
3222,
1414,
370,
27616,
641,
413,
30152,
8643,
1128,
367,
671,
315,
1425,
8,
16,
12,
5553,
304,
1039,
27616,
14,
2254,
63,
24610,
8,
1328,
9,
1039,
900,
14,
4532,
8,
17,
9,
2999,
199,
318,
1678,
63,
1712,
837,
1128,
3421,
63,
793,
275,
27616,
14,
1985,
14,
1832,
63,
1943,
1128,
16631,
63,
793,
275,
298,
20073,
16631,
26,
450,
83,
2,
450,
27616,
14,
13983,
1128,
870,
8,
20073,
14,
1985,
14,
1832,
63,
1943,
9,
1128,
870,
334,
13983,
63,
793,
9,
1128,
2050,
14,
815,
8,
3124,
63,
793,
9,
1128,
2050,
14,
815,
8,
13983,
63,
793,
9,
2999,
199,
873,
63,
1712,
342,
202,
199,
3,
1596,
77,
436,
5452,
402,
370,
29534,
402,
959,
24808,
202,
199,
5362,
63,
460,
63,
11066,
1997,
8,
19,
9,
202,
199,
873,
63,
1712,
342,
2999,
199,
521,
14,
4532,
8,
18,
9,
8065,
199,
2827,
17,
275,
413,
202,
199,
2254,
63,
7439,
63,
16350,
8,
16,
12,
2827,
17,
12,
16,
12,
17,
9,
202,
199,
873,
63,
1328,
275,
298,
2827,
17,
20508,
26,
450,
83,
2,
450,
11848,
17,
202,
199,
1361,
8,
873,
63,
1328,
9,
202,
199,
4806,
14,
815,
8,
873,
63,
1328,
9,
202,
199,
873,
63,
1712,
342,
2999,
199,
2254,
63,
7439,
63,
16350,
8,
16,
12,
16,
12,
16,
12,
17,
9,
2999,
199,
2827,
18,
275,
446,
17,
202,
199,
2254,
63,
7439,
63,
16350,
8
] |
[
16642,
368,
6065,
492,
4907,
12,
25777,
13438,
1385,
12,
12625,
7025,
12,
12625,
7025,
15277,
202,
199,
504,
1134,
24610,
492,
11456,
1974,
327,
28196,
367,
1414,
1245,
10269,
202,
199,
646,
2050,
202,
199,
646,
900,
202,
199,
646,
3473,
2999,
199,
4806,
14,
19602,
8,
1501,
534,
24363,
63,
793,
14,
793,
297,
1475,
275,
9487,
20056,
9,
83,
19648,
18331,
9,
83,
26,
2818,
1188,
9,
83,
297,
2166,
29,
4806,
14,
4531,
9,
2999,
199,
646,
7534,
202,
199,
2087,
275,
7534,
14,
10730,
8,
1802,
534,
3717,
29622,
351,
436,
3222,
3718,
315,
21645,
1149,
818,
5320,
202,
199,
2087,
14,
525,
63,
2094,
4517,
2242,
297,
849,
275,
283,
8815,
26,
709,
14,
16,
14,
16,
14,
17,
26,
1079,
16859,
358,
202,
199,
589,
275,
1798,
14,
1122,
63,
589,
342,
202,
199,
2105,
63,
875,
275,
1249,
14,
2242,
2999,
199,
3,
15175,
370,
314,
25777,
13438,
202,
199,
1361,
283,
32000,
370,
27616,
641,
26,
450,
83,
7,
450,
1950,
63,
875,
202,
199,
20073,
275,
4907,
8,
2105,
63,
875,
12,
3618,
63,
2179,
29,
549,
9,
2999,
199,
318,
30701,
63,
460,
63,
11066,
1997,
8,
65,
4277,
2439,
7951,
304,
1128,
408,
1128,
1952,
706,
27616,
436,
23158,
370,
282,
4277,
2439,
7951,
14,
1128,
408,
2958,
870,
298,
6845,
876,
13,
5362,
5920,
2,
1128,
327,
7529,
1133,
4691,
314,
922,
862,
370,
30701,
5133,
6384,
411,
73,
1653,
365,
10144,
1128,
1830,
440,
27616,
14,
374,
63,
5362,
461,
26,
1039,
870,
298,
13144,
316,
367,
27616,
370,
2536,
572,
11500,
1039,
870,
298,
25556,
26,
3872,
27616,
14,
25556,
63,
16,
14,
970,
63,
466,
1039,
870,
298,
11959,
38,
26,
3872,
27616,
423,
5711,
70,
63,
555,
609,
5546,
2101,
1039,
870,
298,
15169,
13438,
1385,
26,
3872,
27616,
14,
632,
1039,
900,
14,
4532,
8,
17,
9,
2958,
870,
298,
1596,
14566,
333,
357,
1384,
2,
1128,
327,
29622,
351,
1077,
30701,
315,
21645,
1149,
818,
1128,
27616,
14,
632,
275,
25777,
13438,
1385,
480,
17856,
1149,
531,
1128,
27616,
14,
285,
3594,
275,
715,
2958,
1830,
440,
27616,
14,
285,
3594,
26,
1039,
870,
298,
13144,
316,
367,
601,
14566,
11500,
1039,
900,
14,
4532,
8,
17,
9,
2958,
870,
8,
20073,
14,
632,
776,
2958,
870,
298,
52,
11124,
2331,
9539,
1128,
27616,
14,
632,
275,
25777,
13438,
1385,
480,
17856,
1149,
531,
1128,
27616,
14,
4129,
63,
11066,
1997,
8,
65,
4277,
2439,
7951,
9,
327,
18146,
2331,
370,
1347,
29534,
1128,
327,
13144,
5133,
314,
27616,
12276,
397,
282,
5048,
4569,
2544,
6661,
314,
18878,
334,
26617,
314,
1414,
1128,
327,
221,
2410,
25777,
13438,
14,
4129,
63,
11066,
1997,
911,
5341,
9939,
680,
1128,
1830,
715,
26,
1039,
8791,
63,
1188,
275,
27616,
14,
1985,
14,
1832,
63,
1943,
1039,
2050,
14,
815,
8,
4478,
63,
1188,
9,
1039,
8791,
63,
1818,
275,
298,
4580,
7951,
26,
450,
83,
2,
450,
27616,
14,
1985,
14,
2966,
63,
6188,
63,
1943,
14,
4478,
1039,
870,
298,
27616,
818,
26,
3872,
27616,
14,
632,
1039,
2050,
14,
815,
8,
4478,
63,
1188,
9,
1039,
340,
27616,
14,
1985,
14,
2966,
63,
6188,
63,
1943,
14,
4478,
8119,
65,
4277,
2439,
7951,
10,
16,
14,
2720,
26,
327,
16276,
2951,
5084,
1347,
8791,
14,
1675,
870,
298,
497,
4583,
1347,
29534,
2,
1675,
2059,
1039,
900,
14,
4532,
8,
17,
9,
1223,
8065,
199,
318,
3222,
63,
7439,
63,
16350,
8,
16350,
63,
88,
12,
20508,
63,
89,
12,
20508,
63,
90,
12,
7373,
304,
2958,
1499,
275,
27616,
14,
1188,
63,
3702,
14,
409,
63,
3124,
63,
1375,
63,
1832,
63,
7439,
63,
2143,
8,
1039,
378,
12,
755,
327,
900,
63,
4930,
63,
706,
334,
1397,
1202,
9,
1039,
378,
12,
378,
12,
259,
327,
1347,
2656,
12,
1347,
3931,
1039,
11456,
1974,
14,
24610,
14,
19273,
63,
12683,
63,
7486,
63,
46,
1149,
12,
327,
2787,
1039,
378,
66,
993,
6984,
845,
4183,
845,
12,
327,
730,
63,
2629,
334,
2118,
8112,
83,
5223,
9,
1039,
378,
12,
378,
12,
378,
12,
327,
671,
12,
612,
12,
1315,
12266,
334,
1397,
1202,
9,
1039,
20508,
63,
88,
12,
20508,
63,
89,
12,
20508,
63,
90,
12,
327,
671,
12,
612,
12,
1315,
20508,
315,
333,
15,
83,
1039,
378,
12,
378,
12,
378,
12,
327,
671,
12,
612,
12,
1315,
1066,
29765,
334,
1397,
3748,
5966,
12,
5525,
315,
598,
3298,
63,
45,
1214,
1073,
9,
1039,
378,
12,
378,
9,
259,
327,
612,
10084,
12,
612,
10084,
63,
1866,
334,
1397,
3748,
5966,
12,
5525,
315,
598,
3298,
63,
45,
1214,
1073,
9,
2958,
327,
3222,
1414,
370,
27616,
641,
413,
30152,
8643,
1128,
367,
671,
315,
1425,
8,
16,
12,
5553,
304,
1039,
27616,
14,
2254,
63,
24610,
8,
1328,
9,
1039,
900,
14,
4532,
8,
17,
9,
2999,
199,
318,
1678,
63,
1712,
837,
1128,
3421,
63,
793,
275,
27616,
14,
1985,
14,
1832,
63,
1943,
1128,
16631,
63,
793,
275,
298,
20073,
16631,
26,
450,
83,
2,
450,
27616,
14,
13983,
1128,
870,
8,
20073,
14,
1985,
14,
1832,
63,
1943,
9,
1128,
870,
334,
13983,
63,
793,
9,
1128,
2050,
14,
815,
8,
3124,
63,
793,
9,
1128,
2050,
14,
815,
8,
13983,
63,
793,
9,
2999,
199,
873,
63,
1712,
342,
202,
199,
3,
1596,
77,
436,
5452,
402,
370,
29534,
402,
959,
24808,
202,
199,
5362,
63,
460,
63,
11066,
1997,
8,
19,
9,
202,
199,
873,
63,
1712,
342,
2999,
199,
521,
14,
4532,
8,
18,
9,
8065,
199,
2827,
17,
275,
413,
202,
199,
2254,
63,
7439,
63,
16350,
8,
16,
12,
2827,
17,
12,
16,
12,
17,
9,
202,
199,
873,
63,
1328,
275,
298,
2827,
17,
20508,
26,
450,
83,
2,
450,
11848,
17,
202,
199,
1361,
8,
873,
63,
1328,
9,
202,
199,
4806,
14,
815,
8,
873,
63,
1328,
9,
202,
199,
873,
63,
1712,
342,
2999,
199,
2254,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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PeterDaveHello/eden
|
static/scripts/tools/import_supply_item_ifrc_standard.py
|
19
|
1862
|
# Script to import all
#
# run as python web2py.py -S eden -M -R applications/eden/static/scripts/tools/import_supply_item_ifrc_standard.py -A complete
#
# Equivalent to PrePop:
# supply,item_category,supply_item_category_ifrc_standard.csv,item_category_ifrc_standard.xsl
# supply,item,supply_item_ifrc_standard.csv, item_ifrc_standard.xsl
import sys
import time
args = sys.argv
if args[1:]:
# The 1st argument is taken to be the type
set = args[1]
else:
# default to sample
set = "sample"
secs = time.mktime(time.localtime())
# Override authorization
auth.override = True
session.s3.roles.append(ADMIN)
stylesheet_dir = os.path.join(request.folder, "static", "formats", "s3csv", "supply")
import_dir = os.path.join(request.folder, "modules", "templates", "IFRC")
import_file = os.path.join(import_dir, "supply_item_category_ifrc_standard.csv")
stylesheet = os.path.join(stylesheet_dir, "item_category_ifrc_standard.xsl")
resource = s3db.resource("supply_item_category")
File = open(import_file, "r")
resource.import_xml(File,
format="csv",
stylesheet=stylesheet)
File.close()
if set == "sample":
# Sample of 100 Items
import_file = os.path.join(import_dir, "supply_item_ifrc_standard_sample.csv")
elif set == "eic":
# EIC ~3,000 Items
import_file = os.path.join(import_dir, "supply_item_eic.csv")
elif set == "complete":
# Complete ~11,000 Items
import_file = os.path.join(import_dir, "supply_item_ifrc_standard.csv")
stylesheet = os.path.join(stylesheet_dir, "item_ifrc_standard.xsl")
resource = s3db.resource("supply_item")
File = open(import_file, "r")
resource.import_xml(File,
format="csv",
stylesheet=stylesheet)
File.close()
db.commit()
auth.override = False
print "Total Time: %s" % (time.mktime(time.localtime()) - secs)
|
mit
|
[
3,
14914,
370,
492,
1006,
199,
3,
199,
3,
1255,
465,
2366,
3330,
18,
647,
14,
647,
446,
51,
325,
848,
446,
45,
446,
50,
13103,
15,
69,
848,
15,
1986,
15,
6429,
15,
2537,
15,
646,
63,
8621,
590,
63,
1053,
63,
692,
1195,
63,
6807,
14,
647,
446,
33,
4890,
199,
3,
199,
3,
24228,
370,
5543,
9606,
26,
199,
3,
17169,
12,
1053,
63,
3710,
12,
8621,
590,
63,
1053,
63,
3710,
63,
692,
1195,
63,
6807,
14,
4737,
12,
1053,
63,
3710,
63,
692,
1195,
63,
6807,
14,
19324,
199,
3,
17169,
12,
1053,
12,
8621,
590,
63,
1053,
63,
692,
1195,
63,
6807,
14,
4737,
12,
1242,
63,
692,
1195,
63,
6807,
14,
19324,
199,
199,
646,
984,
199,
646,
900,
199,
199,
589,
275,
984,
14,
3020,
199,
692,
1249,
59,
17,
10688,
272,
327,
710,
413,
270,
1423,
365,
9394,
370,
506,
314,
730,
272,
663,
275,
1249,
59,
17,
61,
199,
2836,
26,
272,
327,
849,
370,
2690,
272,
663,
275,
298,
3271,
2,
199,
199,
4855,
275,
900,
14,
23456,
8,
521,
14,
15198,
1012,
199,
199,
3,
11041,
13448,
199,
1178,
14,
4415,
275,
715,
199,
1730,
14,
83,
19,
14,
8050,
14,
740,
8,
14288,
9,
199,
199,
15479,
63,
694,
275,
747,
14,
515,
14,
904,
8,
1069,
14,
3741,
12,
298,
1986,
401,
298,
6321,
401,
298,
83,
19,
4737,
401,
298,
8621,
590,
531,
199,
646,
63,
694,
275,
747,
14,
515,
14,
904,
8,
1069,
14,
3741,
12,
298,
3112,
401,
298,
5876,
401,
298,
4656,
8205,
531,
199,
199,
646,
63,
493,
275,
747,
14,
515,
14,
904,
8,
646,
63,
694,
12,
298,
8621,
590,
63,
1053,
63,
3710,
63,
692,
1195,
63,
6807,
14,
4737,
531,
199,
15479,
275,
747,
14,
515,
14,
904,
8,
15479,
63,
694,
12,
298,
1053,
63,
3710,
63,
692,
1195,
63,
6807,
14,
19324,
531,
199,
1927,
275,
308,
19,
697,
14,
1927,
480,
8621,
590,
63,
1053,
63,
3710,
531,
199,
1173,
275,
1551,
8,
646,
63,
493,
12,
298,
82,
531,
199,
1927,
14,
646,
63,
1652,
8,
1173,
12,
490,
1475,
628,
4737,
401,
490,
3449,
5069,
29,
15479,
9,
199,
1173,
14,
1600,
342,
199,
199,
692,
663,
508,
298,
3271,
582,
272,
327,
15227,
402,
2948,
20720,
272,
492,
63,
493,
275,
747,
14,
515,
14,
904,
8,
646,
63,
694,
12,
298,
8621,
590,
63,
1053,
63,
692,
1195,
63,
6807,
63,
3271,
14,
4737,
531,
199,
4164,
663,
508,
298,
69,
530,
582,
272,
327,
662,
948,
6146,
19,
12,
1493,
20720,
272,
492,
63,
493,
275,
747,
14,
515,
14,
904,
8,
646,
63,
694,
12,
298,
8621,
590,
63,
1053,
63,
69,
530,
14,
4737,
531,
199,
4164,
663,
508,
298,
4883,
582,
272,
327,
28393,
6146,
845,
12,
1493,
20720,
272,
492,
63,
493,
275,
747,
14,
515,
14,
904,
8,
646,
63,
694,
12,
298,
8621,
590,
63,
1053,
63,
692,
1195,
63,
6807,
14,
4737,
531,
199,
199,
15479,
275,
747,
14,
515,
14,
904,
8,
15479,
63,
694,
12,
298,
1053,
63,
692,
1195,
63,
6807,
14,
19324,
531,
199,
1927,
275,
308,
19,
697,
14,
1927,
480,
8621,
590,
63,
1053,
531,
199,
1173,
275,
1551,
8,
646,
63,
493,
12,
298,
82,
531,
199,
1927,
14,
646,
63,
1652,
8,
1173,
12,
490,
1475,
628,
4737,
401,
490,
3449,
5069,
29,
15479,
9,
199,
1173,
14,
1600,
342,
199,
199,
697,
14,
3543,
342,
199,
199,
1178,
14,
4415,
275,
756,
199,
199,
1361,
298,
7316,
4703,
26,
450,
83,
2,
450,
334,
521,
14,
23456,
8,
521,
14,
15198,
1012,
446,
20091,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
14914,
370,
492,
1006,
199,
3,
199,
3,
1255,
465,
2366,
3330,
18,
647,
14,
647,
446,
51,
325,
848,
446,
45,
446,
50,
13103,
15,
69,
848,
15,
1986,
15,
6429,
15,
2537,
15,
646,
63,
8621,
590,
63,
1053,
63,
692,
1195,
63,
6807,
14,
647,
446,
33,
4890,
199,
3,
199,
3,
24228,
370,
5543,
9606,
26,
199,
3,
17169,
12,
1053,
63,
3710,
12,
8621,
590,
63,
1053,
63,
3710,
63,
692,
1195,
63,
6807,
14,
4737,
12,
1053,
63,
3710,
63,
692,
1195,
63,
6807,
14,
19324,
199,
3,
17169,
12,
1053,
12,
8621,
590,
63,
1053,
63,
692,
1195,
63,
6807,
14,
4737,
12,
1242,
63,
692,
1195,
63,
6807,
14,
19324,
199,
199,
646,
984,
199,
646,
900,
199,
199,
589,
275,
984,
14,
3020,
199,
692,
1249,
59,
17,
10688,
272,
327,
710,
413,
270,
1423,
365,
9394,
370,
506,
314,
730,
272,
663,
275,
1249,
59,
17,
61,
199,
2836,
26,
272,
327,
849,
370,
2690,
272,
663,
275,
298,
3271,
2,
199,
199,
4855,
275,
900,
14,
23456,
8,
521,
14,
15198,
1012,
199,
199,
3,
11041,
13448,
199,
1178,
14,
4415,
275,
715,
199,
1730,
14,
83,
19,
14,
8050,
14,
740,
8,
14288,
9,
199,
199,
15479,
63,
694,
275,
747,
14,
515,
14,
904,
8,
1069,
14,
3741,
12,
298,
1986,
401,
298,
6321,
401,
298,
83,
19,
4737,
401,
298,
8621,
590,
531,
199,
646,
63,
694,
275,
747,
14,
515,
14,
904,
8,
1069,
14,
3741,
12,
298,
3112,
401,
298,
5876,
401,
298,
4656,
8205,
531,
199,
199,
646,
63,
493,
275,
747,
14,
515,
14,
904,
8,
646,
63,
694,
12,
298,
8621,
590,
63,
1053,
63,
3710,
63,
692,
1195,
63,
6807,
14,
4737,
531,
199,
15479,
275,
747,
14,
515,
14,
904,
8,
15479,
63,
694,
12,
298,
1053,
63,
3710,
63,
692,
1195,
63,
6807,
14,
19324,
531,
199,
1927,
275,
308,
19,
697,
14,
1927,
480,
8621,
590,
63,
1053,
63,
3710,
531,
199,
1173,
275,
1551,
8,
646,
63,
493,
12,
298,
82,
531,
199,
1927,
14,
646,
63,
1652,
8,
1173,
12,
490,
1475,
628,
4737,
401,
490,
3449,
5069,
29,
15479,
9,
199,
1173,
14,
1600,
342,
199,
199,
692,
663,
508,
298,
3271,
582,
272,
327,
15227,
402,
2948,
20720,
272,
492,
63,
493,
275,
747,
14,
515,
14,
904,
8,
646,
63,
694,
12,
298,
8621,
590,
63,
1053,
63,
692,
1195,
63,
6807,
63,
3271,
14,
4737,
531,
199,
4164,
663,
508,
298,
69,
530,
582,
272,
327,
662,
948,
6146,
19,
12,
1493,
20720,
272,
492,
63,
493,
275,
747,
14,
515,
14,
904,
8,
646,
63,
694,
12,
298,
8621,
590,
63,
1053,
63,
69,
530,
14,
4737,
531,
199,
4164,
663,
508,
298,
4883,
582,
272,
327,
28393,
6146,
845,
12,
1493,
20720,
272,
492,
63,
493,
275,
747,
14,
515,
14,
904,
8,
646,
63,
694,
12,
298,
8621,
590,
63,
1053,
63,
692,
1195,
63,
6807,
14,
4737,
531,
199,
199,
15479,
275,
747,
14,
515,
14,
904,
8,
15479,
63,
694,
12,
298,
1053,
63,
692,
1195,
63,
6807,
14,
19324,
531,
199,
1927,
275,
308,
19,
697,
14,
1927,
480,
8621,
590,
63,
1053,
531,
199,
1173,
275,
1551,
8,
646,
63,
493,
12,
298,
82,
531,
199,
1927,
14,
646,
63,
1652,
8,
1173,
12,
490,
1475,
628,
4737,
401,
490,
3449,
5069,
29,
15479,
9,
199,
1173,
14,
1600,
342,
199,
199,
697,
14,
3543,
342,
199,
199,
1178,
14,
4415,
275,
756,
199,
199,
1361,
298,
7316,
4703,
26,
450,
83,
2,
450,
334,
521,
14,
23456,
8,
521,
14,
15198,
1012,
446,
20091,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768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0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
ed-/solum
|
solum/tests/test_db_manage.py
|
5
|
2373
|
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import sys
import mock
from solum.cmd import db_manage as cli
from solum.tests import base
class TestCli(base.BaseTestCase):
scenarios = [
('stamp', dict(
argv=['prog', 'stamp', 'foo'],
func_name='stamp',
exp_args=('foo',), exp_kwargs={})),
('version', dict(
argv=['prog', 'version'],
func_name='version',
exp_args=[], exp_kwargs={})),
('revision_auto', dict(
argv=['prog', 'revision', '--autogenerate', '-m' 'message'],
func_name='revision', exp_args=[],
exp_kwargs={'message': 'message',
'autogenerate': True})),
('revision', dict(
argv=['prog', 'revision', '-m', 'message'],
func_name='revision', exp_args=[],
exp_kwargs={'message': 'message',
'autogenerate': False})),
('upgrade', dict(
argv=['prog', 'upgrade', 'head'],
func_name='upgrade', exp_args=('head',),
exp_kwargs={})),
('downgrade', dict(
argv=['prog', 'downgrade', 'folsom'],
func_name='downgrade', exp_args=('folsom',),
exp_kwargs={})),
]
def setUp(self):
super(TestCli, self).setUp()
self.addCleanup(cli.CONF.reset)
@mock.patch.object(cli, 'get_manager')
def test_alembic_manager(self, mock_get_manager):
manager = mock_get_manager.return_value
with mock.patch.object(sys, 'argv', self.argv):
cli.main()
mock_get_manager.assert_called_once_with()
test_method = getattr(manager, self.func_name)
test_method.assert_called_once_with(*self.exp_args,
**self.exp_kwargs)
|
apache-2.0
|
[
3,
199,
3,
259,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
1265,
1443,
199,
3,
259,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
2047,
1443,
3332,
199,
3,
259,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
260,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
259,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
259,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
2428,
199,
3,
259,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
1666,
314,
199,
3,
259,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
259,
1334,
314,
844,
14,
199,
199,
646,
984,
199,
199,
646,
1683,
199,
199,
504,
8597,
453,
14,
1760,
492,
1592,
63,
9053,
465,
5053,
199,
504,
8597,
453,
14,
2219,
492,
1300,
421,
199,
533,
1379,
20653,
8,
1095,
14,
20760,
304,
272,
28444,
275,
359,
267,
661,
2359,
297,
1211,
8,
288,
9238,
2968,
6595,
297,
283,
2359,
297,
283,
1421,
995,
288,
2562,
63,
354,
534,
2359,
297,
288,
1437,
63,
589,
7782,
1421,
5529,
1437,
63,
958,
21146,
395,
267,
661,
1023,
297,
1211,
8,
288,
9238,
2968,
6595,
297,
283,
1023,
995,
288,
2562,
63,
354,
534,
1023,
297,
288,
1437,
63,
589,
6034,
1437,
63,
958,
21146,
395,
267,
661,
5792,
63,
2495,
297,
1211,
8,
288,
9238,
2968,
6595,
297,
283,
5792,
297,
2850,
6898,
974,
22978,
297,
2475,
77,
7,
283,
1188,
995,
288,
2562,
63,
354,
534,
5792,
297,
1437,
63,
589,
6034,
288,
1437,
63,
958,
3713,
1188,
356,
283,
1188,
297,
717,
283,
6898,
974,
22978,
356,
715,
1552,
395,
267,
661,
5792,
297,
1211,
8,
288,
9238,
2968,
6595,
297,
283,
5792,
297,
2475,
77,
297,
283,
1188,
995,
288,
2562,
63,
354,
534,
5792,
297,
1437,
63,
589,
6034,
288,
1437,
63,
958,
3713,
1188,
356,
283,
1188,
297,
717,
283,
6898,
974,
22978,
356,
756,
1552,
395,
267,
661,
9375,
297,
1211,
8,
288,
9238,
2968,
6595,
297,
283,
9375,
297,
283,
2993,
995,
288,
2562,
63,
354,
534,
9375,
297,
1437,
63,
589,
7782,
2993,
5529,
288,
1437,
63,
958,
21146,
395,
267,
661,
2110,
4523,
297,
1211,
8,
288,
9238,
2968,
6595,
297,
283,
2110,
4523,
297,
283,
70,
1446,
676,
995,
288,
2562,
63,
354,
534,
2110,
4523,
297,
1437,
63,
589,
7782,
70,
1446,
676,
5529,
288,
1437,
63,
958,
21146,
395,
272,
1622,
339,
347,
3613,
8,
277,
304,
267,
1613,
8,
774,
20653,
12,
291,
680,
5996,
342,
267,
291,
14,
12808,
8,
2764,
14,
3103,
14,
3958,
9,
339,
768,
1805,
14,
2068,
14,
785,
8,
2764,
12,
283,
362,
63,
2609,
358,
272,
347,
511,
63,
1895,
20596,
63,
2609,
8,
277,
12,
1683,
63,
362,
63,
2609,
304,
267,
5256,
275,
1683,
63,
362,
63,
2609,
14,
1107,
63,
585,
267,
543,
1683,
14,
2068,
14,
785,
8,
1274,
12,
283,
3020,
297,
291,
14,
3020,
304,
288,
5053,
14,
973,
342,
288,
1683,
63,
362,
63,
2609,
14,
479,
63,
3527,
63,
5089,
63,
1045,
342,
288,
511,
63,
765,
275,
2519,
8,
2609,
12,
291,
14,
1532,
63,
354,
9,
288,
511,
63,
765,
14,
479,
63,
3527,
63,
5089,
63,
1045,
2031,
277,
14,
1474,
63,
589,
12,
6059,
1011,
277,
14,
1474,
63,
958,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
199,
3,
259,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
1265,
1443,
199,
3,
259,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
2047,
1443,
3332,
199,
3,
259,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
260,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
259,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
259,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
2428,
199,
3,
259,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
1666,
314,
199,
3,
259,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
259,
1334,
314,
844,
14,
199,
199,
646,
984,
199,
199,
646,
1683,
199,
199,
504,
8597,
453,
14,
1760,
492,
1592,
63,
9053,
465,
5053,
199,
504,
8597,
453,
14,
2219,
492,
1300,
421,
199,
533,
1379,
20653,
8,
1095,
14,
20760,
304,
272,
28444,
275,
359,
267,
661,
2359,
297,
1211,
8,
288,
9238,
2968,
6595,
297,
283,
2359,
297,
283,
1421,
995,
288,
2562,
63,
354,
534,
2359,
297,
288,
1437,
63,
589,
7782,
1421,
5529,
1437,
63,
958,
21146,
395,
267,
661,
1023,
297,
1211,
8,
288,
9238,
2968,
6595,
297,
283,
1023,
995,
288,
2562,
63,
354,
534,
1023,
297,
288,
1437,
63,
589,
6034,
1437,
63,
958,
21146,
395,
267,
661,
5792,
63,
2495,
297,
1211,
8,
288,
9238,
2968,
6595,
297,
283,
5792,
297,
2850,
6898,
974,
22978,
297,
2475,
77,
7,
283,
1188,
995,
288,
2562,
63,
354,
534,
5792,
297,
1437,
63,
589,
6034,
288,
1437,
63,
958,
3713,
1188,
356,
283,
1188,
297,
717,
283,
6898,
974,
22978,
356,
715,
1552,
395,
267,
661,
5792,
297,
1211,
8,
288,
9238,
2968,
6595,
297,
283,
5792,
297,
2475,
77,
297,
283,
1188,
995,
288,
2562,
63,
354,
534,
5792,
297,
1437,
63,
589,
6034,
288,
1437,
63,
958,
3713,
1188,
356,
283,
1188,
297,
717,
283,
6898,
974,
22978,
356,
756,
1552,
395,
267,
661,
9375,
297,
1211,
8,
288,
9238,
2968,
6595,
297,
283,
9375,
297,
283,
2993,
995,
288,
2562,
63,
354,
534,
9375,
297,
1437,
63,
589,
7782,
2993,
5529,
288,
1437,
63,
958,
21146,
395,
267,
661,
2110,
4523,
297,
1211,
8,
288,
9238,
2968,
6595,
297,
283,
2110,
4523,
297,
283,
70,
1446,
676,
995,
288,
2562,
63,
354,
534,
2110,
4523,
297,
1437,
63,
589,
7782,
70,
1446,
676,
5529,
288,
1437,
63,
958,
21146,
395,
272,
1622,
339,
347,
3613,
8,
277,
304,
267,
1613,
8,
774,
20653,
12,
291,
680,
5996,
342,
267,
291,
14,
12808,
8,
2764,
14,
3103,
14,
3958,
9,
339,
768,
1805,
14,
2068,
14,
785,
8,
2764,
12,
283,
362,
63,
2609,
358,
272,
347,
511,
63,
1895,
20596,
63,
2609,
8,
277,
12,
1683,
63,
362,
63,
2609,
304,
267,
5256,
275,
1683,
63,
362,
63,
2609,
14,
1107,
63,
585,
267,
543,
1683,
14,
2068,
14,
785,
8,
1274,
12,
283,
3020,
297,
291,
14,
3020,
304,
288,
5053,
14,
973,
342,
288,
1683,
63,
362,
63,
2609,
14,
479,
63,
3527,
63,
5089,
63,
1045,
342,
288,
511,
63,
765,
275,
2519,
8,
2609,
12,
291,
14,
1532,
63,
354,
9,
288,
511,
63,
765,
14,
479,
63,
3527,
63,
5089,
63,
1045,
2031,
277,
14,
1474,
63,
589,
12,
6059,
1011,
277,
14,
1474,
63,
958,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
chenyujie/hybrid-murano
|
murano/api/v1/actions.py
|
1
|
3706
|
# Copyright (c) 2014 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from webob import exc
from murano.common import policy
from murano.common import wsgi
from murano.db import models
from murano.db.services import environments as envs
from murano.db.services import sessions
from murano.db import session as db_session
from murano.common.i18n import _LI, _LE, _
from murano.openstack.common import log as logging
from murano.services import actions
from murano.services import states
LOG = logging.getLogger(__name__)
class Controller(object):
def _validate_environment(self, unit, request, environment_id):
environment = unit.query(models.Environment).get(environment_id)
if environment is None:
LOG.info(_LI('Environment <EnvId {0}> '
'is not found').format(environment_id))
raise exc.HTTPNotFound
if environment.tenant_id != request.context.tenant:
LOG.info(_LI('User is not authorized to access '
'this tenant resources.'))
raise exc.HTTPUnauthorized
def execute(self, request, environment_id, action_id, body):
policy.check("execute_action", request.context, {})
LOG.debug('Action:Execute <ActionId: {0}>'.format(action_id))
unit = db_session.get_session()
self._validate_environment(unit, request, environment_id)
# no new session can be opened if environment has deploying status
env_status = envs.EnvironmentServices.get_status(environment_id)
if env_status in (states.EnvironmentStatus.DEPLOYING,
states.EnvironmentStatus.DELETING):
LOG.info(_LI('Could not open session for environment <EnvId: {0}>,'
'environment has deploying '
'status.').format(environment_id))
raise exc.HTTPForbidden()
user_id = request.context.user
session = sessions.SessionServices.create(environment_id, user_id)
if not sessions.SessionServices.validate(session):
LOG.error(_LE('Session <SessionId {0}> '
'is invalid').format(session.id))
raise exc.HTTPForbidden()
task_id = actions.ActionServices.execute(
action_id, session, unit, request.context.auth_token, body or {})
return {'task_id': task_id}
def get_result(self, request, environment_id, task_id):
policy.check("execute_action", request.context, {})
LOG.debug('Action:GetResult <TaskId: {0}>'.format(task_id))
unit = db_session.get_session()
self._validate_environment(unit, request, environment_id)
result = actions.ActionServices.get_result(environment_id, task_id,
unit)
if result is not None:
return result
msg = (_('Result for task with environment_id: {} and '
'task_id: {} was not found.')
.format(environment_id, task_id))
LOG.error(msg)
raise exc.HTTPNotFound(msg)
def create_resource():
return wsgi.Resource(Controller())
|
apache-2.0
|
[
3,
259,
1898,
334,
67,
9,
6927,
603,
723,
4466,
83,
12,
3277,
14,
199,
3,
199,
3,
259,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
1265,
1443,
199,
3,
259,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
2047,
1443,
3332,
199,
3,
259,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
260,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
259,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
259,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
2428,
199,
3,
259,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
1666,
314,
199,
3,
259,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
259,
1334,
314,
844,
14,
199,
199,
504,
14568,
492,
3178,
199,
199,
504,
333,
300,
8143,
14,
2330,
492,
4592,
199,
504,
333,
300,
8143,
14,
2330,
492,
12464,
199,
504,
333,
300,
8143,
14,
697,
492,
1709,
199,
504,
333,
300,
8143,
14,
697,
14,
5950,
492,
22196,
465,
2589,
83,
199,
504,
333,
300,
8143,
14,
697,
14,
5950,
492,
12184,
199,
504,
333,
300,
8143,
14,
697,
492,
2351,
465,
1592,
63,
1730,
199,
504,
333,
300,
8143,
14,
2330,
14,
73,
1085,
78,
492,
485,
2673,
12,
485,
906,
12,
485,
199,
504,
333,
300,
8143,
14,
8512,
14,
2330,
492,
943,
465,
2050,
199,
504,
333,
300,
8143,
14,
5950,
492,
5445,
199,
504,
333,
300,
8143,
14,
5950,
492,
6363,
421,
199,
4947,
275,
2050,
14,
5572,
3460,
354,
3368,
421,
199,
533,
16282,
8,
785,
304,
272,
347,
485,
3502,
63,
5418,
8,
277,
12,
4137,
12,
1056,
12,
3734,
63,
344,
304,
267,
3734,
275,
4137,
14,
1131,
8,
992,
14,
8263,
680,
362,
8,
5418,
63,
344,
9,
398,
340,
3734,
365,
488,
26,
288,
5051,
14,
815,
1547,
2673,
360,
8263,
665,
7744,
1304,
469,
16,
93,
30,
283,
586,
283,
374,
440,
1911,
1959,
908,
8,
5418,
63,
344,
430,
288,
746,
3178,
14,
26553,
398,
340,
3734,
14,
4647,
63,
344,
1137,
1056,
14,
1100,
14,
4647,
26,
288,
5051,
14,
815,
1547,
2673,
360,
1899,
365,
440,
18788,
370,
2879,
283,
586,
283,
3749,
8261,
5944,
12459,
288,
746,
3178,
14,
2856,
28290,
339,
347,
5341,
8,
277,
12,
1056,
12,
3734,
63,
344,
12,
1595,
63,
344,
12,
2396,
304,
267,
4592,
14,
1074,
480,
2526,
63,
1287,
401,
1056,
14,
1100,
12,
5009,
398,
5051,
14,
1757,
360,
3310,
26,
12049,
665,
3310,
1304,
26,
469,
16,
93,
22936,
908,
8,
1287,
63,
344,
430,
398,
4137,
275,
1592,
63,
1730,
14,
362,
63,
1730,
342,
267,
291,
423,
3502,
63,
5418,
8,
3248,
12,
1056,
12,
3734,
63,
344,
9,
398,
327,
949,
892,
2351,
883,
506,
12123,
340,
3734,
965,
12287,
316,
2004,
267,
2589,
63,
1205,
275,
2589,
83,
14,
8263,
15803,
14,
362,
63,
1205,
8,
5418,
63,
344,
9,
267,
340,
2589,
63,
1205,
315,
334,
4981,
14,
8263,
3694,
14,
26169,
1206,
12,
2079,
6363,
14,
8263,
3694,
14,
4424,
775,
1206,
304,
288,
5051,
14,
815,
1547,
2673,
360,
6531,
440,
1551,
2351,
367,
3734,
665,
7744,
1304,
26,
469,
16,
93,
30,
2584,
586,
283,
5418,
965,
12287,
316,
283,
586,
283,
1205,
14,
1959,
908,
8,
5418,
63,
344,
430,
288,
746,
3178,
14,
2856,
17454,
342,
398,
922,
63,
344,
275,
1056,
14,
1100,
14,
751,
267,
2351,
275,
12184,
14,
4434,
15803,
14,
981,
8,
5418,
63,
344,
12,
922,
63,
344,
9,
398,
340,
440,
12184,
14,
4434,
15803,
14,
3502,
8,
1730,
304,
288,
5051,
14,
705,
1547,
906,
360,
4434,
665,
4434,
1304,
469,
16,
93,
30,
283,
2079,
283,
374,
3866,
1959,
908,
8,
1730,
14,
344,
430,
288,
746,
3178,
14,
2856,
17454,
342,
398,
2120,
63,
344,
275,
5445,
14,
3310,
15803,
14,
2526,
8,
288,
1595,
63,
344,
12,
2351,
12,
4137,
12,
1056,
14,
1100,
14,
1178,
63,
1418,
12,
2396,
503,
5009,
267,
372,
791,
1765,
63,
344,
356,
2120,
63,
344,
93,
339,
347,
664,
63,
1099,
8,
277,
12,
1056,
12,
3734,
63,
344,
12,
2120,
63,
344,
304,
267,
4592,
14,
1074,
480,
2526,
63,
1287,
401,
1056,
14,
1100,
12,
5009,
398,
5051,
14,
1757,
360,
3310,
26,
1002,
2889,
665,
4476,
1304,
26,
469,
16,
93,
22936,
908,
8,
1765,
63,
344,
430,
398,
4137,
275,
1592,
63,
1730,
14,
362,
63,
1730,
342,
267,
291,
423,
3502,
63,
5418,
8,
3248,
12,
1056,
12,
3734,
63,
344,
9,
267,
754,
275,
5445,
14,
3310,
15803,
14,
362,
63,
1099,
8,
5418,
63,
344,
12,
2120,
63,
344,
12,
8962,
4137,
9,
398,
340,
754,
365,
440,
488,
26,
288,
372,
754,
267,
1499,
275,
21790,
2889,
367,
2120,
543,
3734,
63,
344,
26,
1052,
436,
283,
326,
283,
1765,
63,
344,
26,
1052,
1990,
440,
1911,
2659,
2049,
1275,
908,
8,
5418,
63,
344,
12,
2120,
63,
344,
430,
398,
5051,
14,
705,
8,
1328,
9,
267,
746,
3178,
14,
26553,
8,
1328,
9,
421,
199,
318,
1218,
63,
1927,
837,
272,
372,
12464,
14,
4031,
8,
7506,
1012,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
259,
1898,
334,
67,
9,
6927,
603,
723,
4466,
83,
12,
3277,
14,
199,
3,
199,
3,
259,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
1265,
1443,
199,
3,
259,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
2047,
1443,
3332,
199,
3,
259,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
260,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
259,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
259,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
2428,
199,
3,
259,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
1666,
314,
199,
3,
259,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
259,
1334,
314,
844,
14,
199,
199,
504,
14568,
492,
3178,
199,
199,
504,
333,
300,
8143,
14,
2330,
492,
4592,
199,
504,
333,
300,
8143,
14,
2330,
492,
12464,
199,
504,
333,
300,
8143,
14,
697,
492,
1709,
199,
504,
333,
300,
8143,
14,
697,
14,
5950,
492,
22196,
465,
2589,
83,
199,
504,
333,
300,
8143,
14,
697,
14,
5950,
492,
12184,
199,
504,
333,
300,
8143,
14,
697,
492,
2351,
465,
1592,
63,
1730,
199,
504,
333,
300,
8143,
14,
2330,
14,
73,
1085,
78,
492,
485,
2673,
12,
485,
906,
12,
485,
199,
504,
333,
300,
8143,
14,
8512,
14,
2330,
492,
943,
465,
2050,
199,
504,
333,
300,
8143,
14,
5950,
492,
5445,
199,
504,
333,
300,
8143,
14,
5950,
492,
6363,
421,
199,
4947,
275,
2050,
14,
5572,
3460,
354,
3368,
421,
199,
533,
16282,
8,
785,
304,
272,
347,
485,
3502,
63,
5418,
8,
277,
12,
4137,
12,
1056,
12,
3734,
63,
344,
304,
267,
3734,
275,
4137,
14,
1131,
8,
992,
14,
8263,
680,
362,
8,
5418,
63,
344,
9,
398,
340,
3734,
365,
488,
26,
288,
5051,
14,
815,
1547,
2673,
360,
8263,
665,
7744,
1304,
469,
16,
93,
30,
283,
586,
283,
374,
440,
1911,
1959,
908,
8,
5418,
63,
344,
430,
288,
746,
3178,
14,
26553,
398,
340,
3734,
14,
4647,
63,
344,
1137,
1056,
14,
1100,
14,
4647,
26,
288,
5051,
14,
815,
1547,
2673,
360,
1899,
365,
440,
18788,
370,
2879,
283,
586,
283,
3749,
8261,
5944,
12459,
288,
746,
3178,
14,
2856,
28290,
339,
347,
5341,
8,
277,
12,
1056,
12,
3734,
63,
344,
12,
1595,
63,
344,
12,
2396,
304,
267,
4592,
14,
1074,
480,
2526,
63,
1287,
401,
1056,
14,
1100,
12,
5009,
398,
5051,
14,
1757,
360,
3310,
26,
12049,
665,
3310,
1304,
26,
469,
16,
93,
22936,
908,
8,
1287,
63,
344,
430,
398,
4137,
275,
1592,
63,
1730,
14,
362,
63,
1730,
342,
267,
291,
423,
3502,
63,
5418,
8,
3248,
12,
1056,
12,
3734,
63,
344,
9,
398,
327,
949,
892,
2351,
883,
506,
12123,
340,
3734,
965,
12287,
316,
2004,
267,
2589,
63,
1205,
275,
2589,
83,
14,
8263,
15803,
14,
362,
63,
1205,
8,
5418,
63,
344,
9,
267,
340,
2589,
63,
1205,
315,
334,
4981,
14,
8263,
3694,
14,
26169,
1206,
12,
2079,
6363,
14,
8263,
3694,
14,
4424,
775,
1206,
304,
288,
5051,
14,
815,
1547,
2673,
360,
6531,
440,
1551,
2351,
367,
3734,
665,
7744,
1304,
26,
469,
16,
93,
30,
2584,
586,
283,
5418,
965,
12287,
316,
283,
586,
283,
1205,
14,
1959,
908,
8,
5418,
63,
344,
430,
288,
746,
3178,
14,
2856,
17454,
342,
398,
922,
63,
344,
275,
1056,
14,
1100,
14,
751,
267,
2351,
275,
12184,
14,
4434,
15803,
14,
981,
8,
5418,
63,
344,
12,
922,
63,
344,
9,
398,
340,
440,
12184,
14,
4434,
15803,
14,
3502,
8,
1730,
304,
288,
5051,
14,
705,
1547,
906,
360,
4434,
665,
4434,
1304,
469,
16,
93,
30,
283,
2079,
283,
374,
3866,
1959,
908,
8,
1730,
14,
344,
430,
288,
746,
3178,
14,
2856,
17454,
342,
398,
2120,
63,
344,
275,
5445,
14,
3310,
15803,
14,
2526,
8,
288,
1595,
63,
344,
12,
2351,
12,
4137,
12,
1056,
14,
1100,
14,
1178,
63,
1418,
12,
2396,
503,
5009,
267,
372,
791,
1765,
63,
344,
356,
2120,
63,
344,
93,
339,
347,
664,
63,
1099,
8,
277,
12,
1056,
12,
3734,
63,
344,
12,
2120,
63,
344,
304,
267,
4592,
14,
1074,
480,
2526,
63,
1287,
401,
1056,
14,
1100,
12,
5009,
398,
5051,
14,
1757,
360,
3310,
26,
1002,
2889,
665,
4476,
1304,
26,
469,
16,
93,
22936,
908,
8,
1765,
63,
344,
430,
398,
4137,
275,
1592,
63,
1730,
14,
362,
63,
1730,
342,
267,
291,
423,
3502,
63,
5418,
8,
3248,
12,
1056,
12,
3734,
63,
344,
9,
267,
754,
275,
5445,
14,
3310,
15803,
14,
362,
63,
1099,
8,
5418,
63,
344,
12,
2120,
63,
344,
12,
8962,
4137,
9,
398,
340,
754,
365,
440,
488,
26,
288,
372,
754,
267,
1499,
275,
21790,
2889,
367,
2120,
543,
3734,
63,
344,
26,
1052,
436,
283,
326,
283,
1765,
63,
344,
26,
1052,
1990,
440,
1911,
2659,
2049,
1275,
908,
8,
5418,
63,
344,
12,
2120,
63,
344,
430,
398,
5051,
14,
705,
8,
1328,
9,
267,
746,
3178,
14,
26553,
8,
1328,
9,
421,
199,
318,
1218,
63,
1927,
837,
272,
372,
12464,
14,
4031,
8,
7506,
1012,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
samithaj/headphones
|
lib/mako/ext/babelplugin.py
|
60
|
2064
|
# ext/babelplugin.py
# Copyright (C) 2006-2015 the Mako authors and contributors <see AUTHORS file>
#
# This module is part of Mako and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
"""gettext message extraction via Babel: http://babel.edgewall.org/"""
from babel.messages.extract import extract_python
from mako.ext.extract import MessageExtractor
class BabelMakoExtractor(MessageExtractor):
def __init__(self, keywords, comment_tags, options):
self.keywords = keywords
self.options = options
self.config = {
'comment-tags': u' '.join(comment_tags),
'encoding': options.get('input_encoding',
options.get('encoding', None)),
}
super(BabelMakoExtractor, self).__init__()
def __call__(self, fileobj):
return self.process_file(fileobj)
def process_python(self, code, code_lineno, translator_strings):
comment_tags = self.config['comment-tags']
for lineno, funcname, messages, python_translator_comments \
in extract_python(code,
self.keywords, comment_tags, self.options):
yield (code_lineno + (lineno - 1), funcname, messages,
translator_strings + python_translator_comments)
def extract(fileobj, keywords, comment_tags, options):
"""Extract messages from Mako templates.
:param fileobj: the file-like object the messages should be extracted from
:param keywords: a list of keywords (i.e. function names) that should be
recognized as translation functions
:param comment_tags: a list of translator tags to search for and include
in the results
:param options: a dictionary of additional options (optional)
:return: an iterator over ``(lineno, funcname, message, comments)`` tuples
:rtype: ``iterator``
"""
extractor = BabelMakoExtractor(keywords, comment_tags, options)
for message in extractor(fileobj):
yield message
|
gpl-3.0
|
[
3,
1599,
15,
66,
902,
2718,
14,
647,
199,
3,
1898,
334,
35,
9,
8315,
13,
7806,
314,
603,
23564,
11462,
436,
8417,
665,
3239,
10610,
570,
30,
199,
3,
199,
3,
961,
859,
365,
1777,
402,
603,
23564,
436,
365,
14286,
1334,
199,
3,
314,
10697,
844,
26,
1455,
921,
1544,
14,
16374,
14,
1308,
15,
2383,
15,
1147,
13,
1682,
14,
8624,
199,
199,
624,
5152,
1245,
19967,
4799,
699,
902,
26,
1455,
921,
66,
902,
14,
5173,
7567,
14,
1308,
15,
624,
199,
504,
29178,
14,
3431,
14,
5005,
492,
5536,
63,
1548,
199,
504,
26834,
14,
832,
14,
5005,
492,
6430,
11039,
421,
199,
533,
699,
902,
45,
23564,
11039,
8,
2209,
11039,
304,
272,
347,
636,
826,
721,
277,
12,
7681,
12,
3721,
63,
2969,
12,
1511,
304,
267,
291,
14,
7511,
275,
7681,
267,
291,
14,
1419,
275,
1511,
267,
291,
14,
888,
275,
469,
355,
283,
3349,
13,
2969,
356,
399,
7,
1987,
904,
8,
3349,
63,
2969,
395,
355,
283,
2991,
356,
1511,
14,
362,
360,
1210,
63,
2991,
297,
490,
1511,
14,
362,
360,
2991,
297,
488,
1826,
288,
789,
267,
1613,
8,
34,
902,
45,
23564,
11039,
12,
291,
2843,
826,
4533,
339,
347,
636,
1250,
721,
277,
12,
11099,
304,
267,
372,
291,
14,
1412,
63,
493,
8,
9234,
9,
339,
347,
2112,
63,
1548,
8,
277,
12,
1233,
12,
1233,
63,
3469,
12,
32034,
63,
5465,
304,
267,
3721,
63,
2969,
275,
291,
14,
888,
459,
3349,
13,
2969,
418,
267,
367,
5874,
12,
24092,
12,
3788,
12,
2366,
63,
29346,
63,
6223,
971,
355,
315,
5536,
63,
1548,
8,
600,
12,
717,
291,
14,
7511,
12,
3721,
63,
2969,
12,
291,
14,
1419,
304,
288,
1995,
334,
600,
63,
3469,
435,
334,
3469,
446,
413,
395,
24092,
12,
3788,
12,
673,
32034,
63,
5465,
435,
2366,
63,
29346,
63,
6223,
9,
421,
199,
318,
5536,
8,
9234,
12,
7681,
12,
3721,
63,
2969,
12,
1511,
304,
272,
408,
12147,
3788,
687,
603,
23564,
7009,
14,
339,
520,
635,
11099,
26,
314,
570,
13,
2930,
909,
314,
3788,
1077,
506,
12509,
687,
272,
520,
635,
7681,
26,
282,
769,
402,
7681,
334,
73,
14,
69,
14,
805,
1561,
9,
626,
1077,
506,
2151,
18054,
465,
7761,
3423,
272,
520,
635,
3721,
63,
2969,
26,
282,
769,
402,
32034,
3762,
370,
2754,
367,
436,
2387,
586,
315,
314,
2058,
272,
520,
635,
1511,
26,
282,
2600,
402,
4722,
1511,
334,
4144,
9,
272,
520,
1107,
26,
376,
6122,
1806,
15475,
3469,
12,
24092,
12,
1245,
12,
6786,
9719,
6346,
272,
520,
4500,
26,
1124,
5778,
1040,
272,
408,
272,
31295,
275,
699,
902,
45,
23564,
11039,
8,
7511,
12,
3721,
63,
2969,
12,
1511,
9,
272,
367,
1245,
315,
31295,
8,
9234,
304,
267,
1995,
1245,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1599,
15,
66,
902,
2718,
14,
647,
199,
3,
1898,
334,
35,
9,
8315,
13,
7806,
314,
603,
23564,
11462,
436,
8417,
665,
3239,
10610,
570,
30,
199,
3,
199,
3,
961,
859,
365,
1777,
402,
603,
23564,
436,
365,
14286,
1334,
199,
3,
314,
10697,
844,
26,
1455,
921,
1544,
14,
16374,
14,
1308,
15,
2383,
15,
1147,
13,
1682,
14,
8624,
199,
199,
624,
5152,
1245,
19967,
4799,
699,
902,
26,
1455,
921,
66,
902,
14,
5173,
7567,
14,
1308,
15,
624,
199,
504,
29178,
14,
3431,
14,
5005,
492,
5536,
63,
1548,
199,
504,
26834,
14,
832,
14,
5005,
492,
6430,
11039,
421,
199,
533,
699,
902,
45,
23564,
11039,
8,
2209,
11039,
304,
272,
347,
636,
826,
721,
277,
12,
7681,
12,
3721,
63,
2969,
12,
1511,
304,
267,
291,
14,
7511,
275,
7681,
267,
291,
14,
1419,
275,
1511,
267,
291,
14,
888,
275,
469,
355,
283,
3349,
13,
2969,
356,
399,
7,
1987,
904,
8,
3349,
63,
2969,
395,
355,
283,
2991,
356,
1511,
14,
362,
360,
1210,
63,
2991,
297,
490,
1511,
14,
362,
360,
2991,
297,
488,
1826,
288,
789,
267,
1613,
8,
34,
902,
45,
23564,
11039,
12,
291,
2843,
826,
4533,
339,
347,
636,
1250,
721,
277,
12,
11099,
304,
267,
372,
291,
14,
1412,
63,
493,
8,
9234,
9,
339,
347,
2112,
63,
1548,
8,
277,
12,
1233,
12,
1233,
63,
3469,
12,
32034,
63,
5465,
304,
267,
3721,
63,
2969,
275,
291,
14,
888,
459,
3349,
13,
2969,
418,
267,
367,
5874,
12,
24092,
12,
3788,
12,
2366,
63,
29346,
63,
6223,
971,
355,
315,
5536,
63,
1548,
8,
600,
12,
717,
291,
14,
7511,
12,
3721,
63,
2969,
12,
291,
14,
1419,
304,
288,
1995,
334,
600,
63,
3469,
435,
334,
3469,
446,
413,
395,
24092,
12,
3788,
12,
673,
32034,
63,
5465,
435,
2366,
63,
29346,
63,
6223,
9,
421,
199,
318,
5536,
8,
9234,
12,
7681,
12,
3721,
63,
2969,
12,
1511,
304,
272,
408,
12147,
3788,
687,
603,
23564,
7009,
14,
339,
520,
635,
11099,
26,
314,
570,
13,
2930,
909,
314,
3788,
1077,
506,
12509,
687,
272,
520,
635,
7681,
26,
282,
769,
402,
7681,
334,
73,
14,
69,
14,
805,
1561,
9,
626,
1077,
506,
2151,
18054,
465,
7761,
3423,
272,
520,
635,
3721,
63,
2969,
26,
282,
769,
402,
32034,
3762,
370,
2754,
367,
436,
2387,
586,
315,
314,
2058,
272,
520,
635,
1511,
26,
282,
2600,
402,
4722,
1511,
334,
4144,
9,
272,
520,
1107,
26,
376,
6122,
1806,
15475,
3469,
12,
24092,
12,
1245,
12,
6786,
9719,
6346,
272,
520,
4500,
26,
1124,
5778,
1040,
272,
408,
272,
31295,
275,
699,
902,
45,
23564,
11039,
8,
7511,
12,
3721,
63,
2969,
12,
1511,
9,
272,
367,
1245,
315,
31295,
8,
9234,
304,
267,
1995,
1245,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
yevgeniy-logachev/CATB15Kernel
|
kernel/scripts/tracing/draw_functrace.py
|
14676
|
3560
|
#!/usr/bin/python
"""
Copyright 2008 (c) Frederic Weisbecker <fweisbec@gmail.com>
Licensed under the terms of the GNU GPL License version 2
This script parses a trace provided by the function tracer in
kernel/trace/trace_functions.c
The resulted trace is processed into a tree to produce a more human
view of the call stack by drawing textual but hierarchical tree of
calls. Only the functions's names and the the call time are provided.
Usage:
Be sure that you have CONFIG_FUNCTION_TRACER
# mount -t debugfs nodev /sys/kernel/debug
# echo function > /sys/kernel/debug/tracing/current_tracer
$ cat /sys/kernel/debug/tracing/trace_pipe > ~/raw_trace_func
Wait some times but not too much, the script is a bit slow.
Break the pipe (Ctrl + Z)
$ scripts/draw_functrace.py < raw_trace_func > draw_functrace
Then you have your drawn trace in draw_functrace
"""
import sys, re
class CallTree:
""" This class provides a tree representation of the functions
call stack. If a function has no parent in the kernel (interrupt,
syscall, kernel thread...) then it is attached to a virtual parent
called ROOT.
"""
ROOT = None
def __init__(self, func, time = None, parent = None):
self._func = func
self._time = time
if parent is None:
self._parent = CallTree.ROOT
else:
self._parent = parent
self._children = []
def calls(self, func, calltime):
""" If a function calls another one, call this method to insert it
into the tree at the appropriate place.
@return: A reference to the newly created child node.
"""
child = CallTree(func, calltime, self)
self._children.append(child)
return child
def getParent(self, func):
""" Retrieve the last parent of the current node that
has the name given by func. If this function is not
on a parent, then create it as new child of root
@return: A reference to the parent.
"""
tree = self
while tree != CallTree.ROOT and tree._func != func:
tree = tree._parent
if tree == CallTree.ROOT:
child = CallTree.ROOT.calls(func, None)
return child
return tree
def __repr__(self):
return self.__toString("", True)
def __toString(self, branch, lastChild):
if self._time is not None:
s = "%s----%s (%s)\n" % (branch, self._func, self._time)
else:
s = "%s----%s\n" % (branch, self._func)
i = 0
if lastChild:
branch = branch[:-1] + " "
while i < len(self._children):
if i != len(self._children) - 1:
s += "%s" % self._children[i].__toString(branch +\
" |", False)
else:
s += "%s" % self._children[i].__toString(branch +\
" |", True)
i += 1
return s
class BrokenLineException(Exception):
"""If the last line is not complete because of the pipe breakage,
we want to stop the processing and ignore this line.
"""
pass
class CommentLineException(Exception):
""" If the line is a comment (as in the beginning of the trace file),
just ignore it.
"""
pass
def parseLine(line):
line = line.strip()
if line.startswith("#"):
raise CommentLineException
m = re.match("[^]]+?\\] +([0-9.]+): (\\w+) <-(\\w+)", line)
if m is None:
raise BrokenLineException
return (m.group(1), m.group(2), m.group(3))
def main():
CallTree.ROOT = CallTree("Root (Nowhere)", None, None)
tree = CallTree.ROOT
for line in sys.stdin:
try:
calltime, callee, caller = parseLine(line)
except BrokenLineException:
break
except CommentLineException:
continue
tree = tree.getParent(caller)
tree = tree.calls(callee, calltime)
print CallTree.ROOT
if __name__ == "__main__":
main()
|
gpl-2.0
|
[
3381,
2647,
15,
1393,
15,
1548,
199,
199,
624,
199,
7384,
9079,
334,
67,
9,
481,
21919,
1567,
2136,
374,
1235,
22043,
665,
70,
1129,
374,
24554,
32,
6799,
14,
957,
30,
199,
31661,
1334,
314,
2895,
402,
314,
1664,
14629,
844,
1015,
499,
199,
199,
2765,
2884,
19953,
282,
3307,
2741,
701,
314,
805,
29140,
315,
199,
4989,
15,
3446,
15,
3446,
63,
5777,
14,
67,
199,
1918,
522,
30355,
3307,
365,
7686,
1901,
282,
3123,
370,
7389,
282,
1655,
11779,
199,
1345,
402,
314,
1240,
3464,
701,
17455,
25884,
1325,
24787,
3123,
402,
199,
5352,
14,
5972,
314,
3423,
1159,
1561,
436,
314,
314,
1240,
900,
787,
2741,
14,
199,
199,
7692,
26,
199,
198,
3655,
3238,
626,
1265,
1172,
15869,
63,
15476,
63,
1766,
1348,
540,
199,
198,
3,
10760,
446,
84,
3105,
2319,
1031,
86,
1182,
1274,
15,
4989,
15,
1757,
199,
198,
3,
11343,
805,
690,
1182,
1274,
15,
4989,
15,
1757,
15,
21635,
15,
1818,
63,
16825,
199,
198,
4,
6230,
1182,
1274,
15,
4989,
15,
1757,
15,
21635,
15,
3446,
63,
4990,
690,
6146,
15,
1773,
63,
3446,
63,
1532,
199,
198,
7536,
2005,
5431,
1325,
440,
4634,
8298,
12,
314,
2884,
365,
282,
4546,
11999,
14,
199,
198,
13948,
314,
5200,
334,
9778,
435,
3107,
9,
199,
198,
4,
10554,
15,
5485,
63,
31939,
5986,
14,
647,
665,
3066,
63,
3446,
63,
1532,
690,
5954,
63,
31939,
5986,
199,
198,
28226,
1265,
1172,
2195,
19341,
3307,
315,
5954,
63,
31939,
5986,
199,
624,
421,
199,
646,
984,
12,
295,
199,
199,
533,
23491,
26,
199,
198,
624,
961,
1021,
6571,
282,
3123,
6025,
402,
314,
3423,
507,
198,
1250,
3464,
14,
982,
282,
805,
965,
949,
1676,
315,
314,
5114,
334,
20172,
12,
507,
198,
19444,
12,
5114,
2462,
11965,
2066,
652,
365,
10102,
370,
282,
5791,
1676,
507,
198,
3527,
16547,
14,
199,
198,
624,
199,
198,
5441,
275,
488,
421,
198,
318,
636,
826,
721,
277,
12,
2562,
12,
900,
275,
488,
12,
1676,
275,
488,
304,
507,
198,
277,
423,
1532,
275,
2562,
507,
198,
277,
423,
521,
275,
900,
507,
198,
692,
1676,
365,
488,
26,
686,
198,
277,
423,
1708,
275,
23491,
14,
5441,
507,
198,
2836,
26,
686,
198,
277,
423,
1708,
275,
1676,
507,
198,
277,
423,
3223,
275,
942,
421,
198,
318,
4882,
8,
277,
12,
2562,
12,
1240,
521,
304,
507,
198,
624,
982,
282,
805,
4882,
4573,
1373,
12,
1240,
642,
1083,
370,
5518,
652,
686,
198,
9924,
314,
3123,
737,
314,
5827,
4192,
14,
686,
198,
32,
1107,
26,
437,
3659,
370,
314,
13903,
2737,
1982,
1031,
14,
507,
198,
624,
507,
198,
1739,
275,
23491,
8,
1532,
12,
1240,
521,
12,
291,
9,
507,
198,
277,
423,
3223,
14,
740,
8,
1739,
9,
507,
198,
1107,
1982,
421,
198,
318,
664,
6652,
8,
277,
12,
2562,
304,
507,
198,
624,
13939,
314,
2061,
1676,
402,
314,
1453,
1031,
626,
686,
198,
1989,
314,
536,
1627,
701,
2562,
14,
982,
642,
805,
365,
440,
686,
198,
265,
282,
1676,
12,
2066,
1218,
652,
465,
892,
1982,
402,
1738,
686,
198,
32,
1107,
26,
437,
3659,
370,
314,
1676,
14,
507,
198,
624,
507,
198,
2350,
275,
291,
507,
198,
6710,
3123,
1137,
23491,
14,
5441,
436,
3123,
423,
1532,
1137,
2562,
26,
686,
198,
2350,
275,
3123,
423,
1708,
507,
198,
692,
3123,
508,
23491,
14,
5441,
26,
686,
198,
1739,
275,
23491,
14,
5441,
14,
5352,
8,
1532,
12,
488,
9,
686,
198,
1107,
1982,
507,
198,
1107,
3123,
421,
198,
318,
636,
2722,
721,
277,
304,
507,
198,
1107,
291,
855,
16695,
12398,
715,
9,
421,
198,
318,
636,
16695,
8,
277,
12,
5246,
12,
2061,
3493,
304,
507,
198,
692,
291,
423,
521,
365,
440,
488,
26,
686,
198,
83,
275,
2071,
83,
375,
5,
83,
4366,
83,
2862,
78,
2,
450,
334,
4694,
12,
291,
423,
1532,
12,
291,
423,
521,
9,
507,
198,
2836,
26,
686,
198,
83,
275,
2071,
83,
375,
5,
83,
60,
78,
2,
450,
334,
4694,
12,
291,
423,
1532,
9,
2742,
198,
73,
275,
378,
507,
198,
692,
2061,
3493,
26,
686,
198,
4694,
275,
5246,
4439,
17,
61,
435,
298,
298,
507,
198,
6710,
284,
665,
822,
8,
277,
423,
3223,
304,
686,
198,
692,
284,
1137,
822,
8,
277,
423,
3223,
9,
446,
413,
26,
1585,
198,
83,
847,
2071,
83,
2,
450,
291,
423,
3223,
59,
73,
17979,
16695,
8,
4694,
17992,
11674,
198,
2,
259,
1204,
401,
756,
9,
686,
198,
2836,
26,
1585,
198,
83,
847,
2071,
83,
2,
450,
291,
423,
3223,
59,
73,
17979,
16695,
8,
4694,
17992,
11674,
198,
2,
259,
1204,
401,
715,
9,
686,
198,
73,
847,
413,
507,
198,
1107,
308,
199,
199,
533,
23804,
29969,
8,
1726,
304,
199,
198,
624,
3917,
314,
2061,
1004,
365,
440,
4890,
2952,
402,
314,
5200,
2059,
474,
12,
21979,
781,
2934,
370,
3631,
314,
6661,
436,
3686,
642,
1004,
14,
199,
198,
624,
199,
198,
1529,
199,
199,
533,
6819,
29969,
8,
1726,
304,
199,
198,
624,
982,
314,
1004,
365,
282,
3721,
334,
305,
315,
314,
9608,
402,
314,
3307,
570,
395,
6722,
2951,
3686,
652,
14,
199,
198,
624,
199,
198,
1529,
421,
199,
318,
2198,
3049,
8,
604,
304,
199,
198,
604,
275,
1004,
14,
1913,
342,
199,
198,
692,
1004,
14,
2460,
10064,
2349,
507,
198,
3730,
6819,
29969,
199,
198,
77,
275,
295,
14,
1431,
480,
4735,
2677,
23778,
1103,
61,
435,
779,
16,
13,
25,
32455,
304,
334,
1103,
87,
8771,
665,
15426,
1103,
87,
11,
4186,
1004,
9,
199,
198,
692,
333,
365,
488,
26,
507,
198,
3730,
23804,
29969,
199,
198,
1107,
334,
77,
14,
923,
8,
17,
395,
333,
14,
923,
8,
18,
395,
333,
14,
923,
8,
19,
430,
421,
199,
318,
2446,
837,
199,
198,
2176,
3987,
14,
5441,
275,
23491,
480,
6405,
334,
14351,
1681,
4186,
488,
12,
488,
9,
199,
198,
2350,
275,
23491,
14,
5441,
421,
198,
509,
1004,
315,
984,
14,
6626,
26,
507,
198,
893,
26,
686,
198,
1250,
521,
12,
3213,
18387,
12,
8025,
275,
2198,
3049,
8,
604
] |
[
2647,
15,
1393,
15,
1548,
199,
199,
624,
199,
7384,
9079,
334,
67,
9,
481,
21919,
1567,
2136,
374,
1235,
22043,
665,
70,
1129,
374,
24554,
32,
6799,
14,
957,
30,
199,
31661,
1334,
314,
2895,
402,
314,
1664,
14629,
844,
1015,
499,
199,
199,
2765,
2884,
19953,
282,
3307,
2741,
701,
314,
805,
29140,
315,
199,
4989,
15,
3446,
15,
3446,
63,
5777,
14,
67,
199,
1918,
522,
30355,
3307,
365,
7686,
1901,
282,
3123,
370,
7389,
282,
1655,
11779,
199,
1345,
402,
314,
1240,
3464,
701,
17455,
25884,
1325,
24787,
3123,
402,
199,
5352,
14,
5972,
314,
3423,
1159,
1561,
436,
314,
314,
1240,
900,
787,
2741,
14,
199,
199,
7692,
26,
199,
198,
3655,
3238,
626,
1265,
1172,
15869,
63,
15476,
63,
1766,
1348,
540,
199,
198,
3,
10760,
446,
84,
3105,
2319,
1031,
86,
1182,
1274,
15,
4989,
15,
1757,
199,
198,
3,
11343,
805,
690,
1182,
1274,
15,
4989,
15,
1757,
15,
21635,
15,
1818,
63,
16825,
199,
198,
4,
6230,
1182,
1274,
15,
4989,
15,
1757,
15,
21635,
15,
3446,
63,
4990,
690,
6146,
15,
1773,
63,
3446,
63,
1532,
199,
198,
7536,
2005,
5431,
1325,
440,
4634,
8298,
12,
314,
2884,
365,
282,
4546,
11999,
14,
199,
198,
13948,
314,
5200,
334,
9778,
435,
3107,
9,
199,
198,
4,
10554,
15,
5485,
63,
31939,
5986,
14,
647,
665,
3066,
63,
3446,
63,
1532,
690,
5954,
63,
31939,
5986,
199,
198,
28226,
1265,
1172,
2195,
19341,
3307,
315,
5954,
63,
31939,
5986,
199,
624,
421,
199,
646,
984,
12,
295,
199,
199,
533,
23491,
26,
199,
198,
624,
961,
1021,
6571,
282,
3123,
6025,
402,
314,
3423,
507,
198,
1250,
3464,
14,
982,
282,
805,
965,
949,
1676,
315,
314,
5114,
334,
20172,
12,
507,
198,
19444,
12,
5114,
2462,
11965,
2066,
652,
365,
10102,
370,
282,
5791,
1676,
507,
198,
3527,
16547,
14,
199,
198,
624,
199,
198,
5441,
275,
488,
421,
198,
318,
636,
826,
721,
277,
12,
2562,
12,
900,
275,
488,
12,
1676,
275,
488,
304,
507,
198,
277,
423,
1532,
275,
2562,
507,
198,
277,
423,
521,
275,
900,
507,
198,
692,
1676,
365,
488,
26,
686,
198,
277,
423,
1708,
275,
23491,
14,
5441,
507,
198,
2836,
26,
686,
198,
277,
423,
1708,
275,
1676,
507,
198,
277,
423,
3223,
275,
942,
421,
198,
318,
4882,
8,
277,
12,
2562,
12,
1240,
521,
304,
507,
198,
624,
982,
282,
805,
4882,
4573,
1373,
12,
1240,
642,
1083,
370,
5518,
652,
686,
198,
9924,
314,
3123,
737,
314,
5827,
4192,
14,
686,
198,
32,
1107,
26,
437,
3659,
370,
314,
13903,
2737,
1982,
1031,
14,
507,
198,
624,
507,
198,
1739,
275,
23491,
8,
1532,
12,
1240,
521,
12,
291,
9,
507,
198,
277,
423,
3223,
14,
740,
8,
1739,
9,
507,
198,
1107,
1982,
421,
198,
318,
664,
6652,
8,
277,
12,
2562,
304,
507,
198,
624,
13939,
314,
2061,
1676,
402,
314,
1453,
1031,
626,
686,
198,
1989,
314,
536,
1627,
701,
2562,
14,
982,
642,
805,
365,
440,
686,
198,
265,
282,
1676,
12,
2066,
1218,
652,
465,
892,
1982,
402,
1738,
686,
198,
32,
1107,
26,
437,
3659,
370,
314,
1676,
14,
507,
198,
624,
507,
198,
2350,
275,
291,
507,
198,
6710,
3123,
1137,
23491,
14,
5441,
436,
3123,
423,
1532,
1137,
2562,
26,
686,
198,
2350,
275,
3123,
423,
1708,
507,
198,
692,
3123,
508,
23491,
14,
5441,
26,
686,
198,
1739,
275,
23491,
14,
5441,
14,
5352,
8,
1532,
12,
488,
9,
686,
198,
1107,
1982,
507,
198,
1107,
3123,
421,
198,
318,
636,
2722,
721,
277,
304,
507,
198,
1107,
291,
855,
16695,
12398,
715,
9,
421,
198,
318,
636,
16695,
8,
277,
12,
5246,
12,
2061,
3493,
304,
507,
198,
692,
291,
423,
521,
365,
440,
488,
26,
686,
198,
83,
275,
2071,
83,
375,
5,
83,
4366,
83,
2862,
78,
2,
450,
334,
4694,
12,
291,
423,
1532,
12,
291,
423,
521,
9,
507,
198,
2836,
26,
686,
198,
83,
275,
2071,
83,
375,
5,
83,
60,
78,
2,
450,
334,
4694,
12,
291,
423,
1532,
9,
2742,
198,
73,
275,
378,
507,
198,
692,
2061,
3493,
26,
686,
198,
4694,
275,
5246,
4439,
17,
61,
435,
298,
298,
507,
198,
6710,
284,
665,
822,
8,
277,
423,
3223,
304,
686,
198,
692,
284,
1137,
822,
8,
277,
423,
3223,
9,
446,
413,
26,
1585,
198,
83,
847,
2071,
83,
2,
450,
291,
423,
3223,
59,
73,
17979,
16695,
8,
4694,
17992,
11674,
198,
2,
259,
1204,
401,
756,
9,
686,
198,
2836,
26,
1585,
198,
83,
847,
2071,
83,
2,
450,
291,
423,
3223,
59,
73,
17979,
16695,
8,
4694,
17992,
11674,
198,
2,
259,
1204,
401,
715,
9,
686,
198,
73,
847,
413,
507,
198,
1107,
308,
199,
199,
533,
23804,
29969,
8,
1726,
304,
199,
198,
624,
3917,
314,
2061,
1004,
365,
440,
4890,
2952,
402,
314,
5200,
2059,
474,
12,
21979,
781,
2934,
370,
3631,
314,
6661,
436,
3686,
642,
1004,
14,
199,
198,
624,
199,
198,
1529,
199,
199,
533,
6819,
29969,
8,
1726,
304,
199,
198,
624,
982,
314,
1004,
365,
282,
3721,
334,
305,
315,
314,
9608,
402,
314,
3307,
570,
395,
6722,
2951,
3686,
652,
14,
199,
198,
624,
199,
198,
1529,
421,
199,
318,
2198,
3049,
8,
604,
304,
199,
198,
604,
275,
1004,
14,
1913,
342,
199,
198,
692,
1004,
14,
2460,
10064,
2349,
507,
198,
3730,
6819,
29969,
199,
198,
77,
275,
295,
14,
1431,
480,
4735,
2677,
23778,
1103,
61,
435,
779,
16,
13,
25,
32455,
304,
334,
1103,
87,
8771,
665,
15426,
1103,
87,
11,
4186,
1004,
9,
199,
198,
692,
333,
365,
488,
26,
507,
198,
3730,
23804,
29969,
199,
198,
1107,
334,
77,
14,
923,
8,
17,
395,
333,
14,
923,
8,
18,
395,
333,
14,
923,
8,
19,
430,
421,
199,
318,
2446,
837,
199,
198,
2176,
3987,
14,
5441,
275,
23491,
480,
6405,
334,
14351,
1681,
4186,
488,
12,
488,
9,
199,
198,
2350,
275,
23491,
14,
5441,
421,
198,
509,
1004,
315,
984,
14,
6626,
26,
507,
198,
893,
26,
686,
198,
1250,
521,
12,
3213,
18387,
12,
8025,
275,
2198,
3049,
8,
604,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
mitsei/dlkit
|
tests/commenting/test_objects.py
|
1
|
27143
|
"""Unit tests of commenting objects."""
import pytest
from ..utilities.general import is_never_authz, is_no_authz, uses_cataloging, uses_filesystem_only
from dlkit.abstract_osid.commenting import objects as ABCObjects
from dlkit.abstract_osid.id.primitives import Id as ABC_Id
from dlkit.abstract_osid.locale.primitives import DisplayText as ABC_DisplayText
from dlkit.abstract_osid.osid import errors
from dlkit.abstract_osid.osid.objects import OsidCatalog
from dlkit.json_.id.objects import IdList
from dlkit.json_.osid.metadata import Metadata
from dlkit.primordium.id.primitives import Id
from dlkit.primordium.locale.primitives import DisplayText
from dlkit.primordium.type.primitives import Type
from dlkit.runtime import PROXY_SESSION, proxy_example
from dlkit.runtime.managers import Runtime
REQUEST = proxy_example.SimpleRequest()
CONDITION = PROXY_SESSION.get_proxy_condition()
CONDITION.set_http_request(REQUEST)
PROXY = PROXY_SESSION.get_proxy(CONDITION)
DEFAULT_TYPE = Type(**{'identifier': 'DEFAULT', 'namespace': 'DEFAULT', 'authority': 'DEFAULT'})
AGENT_ID = Id(**{'identifier': 'jane_doe', 'namespace': 'osid.agent.Agent', 'authority': 'MIT-ODL'})
@pytest.fixture(scope="class",
params=['TEST_SERVICE', 'TEST_SERVICE_ALWAYS_AUTHZ', 'TEST_SERVICE_NEVER_AUTHZ', 'TEST_SERVICE_CATALOGING', 'TEST_SERVICE_FILESYSTEM', 'TEST_SERVICE_MEMCACHE'])
def comment_class_fixture(request):
request.cls.service_config = request.param
request.cls.svc_mgr = Runtime().get_service_manager(
'COMMENTING',
proxy=PROXY,
implementation=request.cls.service_config)
if not is_never_authz(request.cls.service_config):
create_form = request.cls.svc_mgr.get_book_form_for_create([])
create_form.display_name = 'Test catalog'
create_form.description = 'Test catalog description'
request.cls.catalog = request.cls.svc_mgr.create_book(create_form)
form = request.cls.catalog.get_comment_form_for_create(
Id('resource.Resource%3A1%40ODL.MIT.EDU'),
[])
form.display_name = 'Test object'
request.cls.object = request.cls.catalog.create_comment(form)
def class_tear_down():
if not is_never_authz(request.cls.service_config):
for obj in request.cls.catalog.get_comments():
request.cls.catalog.delete_comment(obj.ident)
request.cls.svc_mgr.delete_book(request.cls.catalog.ident)
request.addfinalizer(class_tear_down)
@pytest.fixture(scope="function")
def comment_test_fixture(request):
pass
@pytest.mark.usefixtures("comment_class_fixture", "comment_test_fixture")
class TestComment(object):
"""Tests for Comment"""
@pytest.mark.skip('unimplemented test')
def test_get_reference_id(self):
"""Tests get_reference_id"""
pass
@pytest.mark.skip('unimplemented test')
def test_get_commentor_id(self):
"""Tests get_commentor_id"""
pass
def test_get_commentor(self):
"""Tests get_commentor"""
if is_never_authz(self.service_config):
pass # no object to call the method on?
else:
with pytest.raises(errors.Unimplemented):
self.object.get_commentor()
def test_get_commenting_agent_id(self):
"""Tests get_commenting_agent_id"""
if not is_never_authz(self.service_config):
result = self.object.get_commenting_agent_id()
assert isinstance(result, Id)
assert str(result) == str(self.catalog._proxy.get_effective_agent_id())
def test_get_commenting_agent(self):
"""Tests get_commenting_agent"""
if not is_never_authz(self.service_config):
# because the resource doesn't actually exist
with pytest.raises(errors.OperationFailed):
self.object.get_commenting_agent()
def test_get_text(self):
"""Tests get_text"""
if not is_never_authz(self.service_config):
result = self.object.get_text()
assert isinstance(result, DisplayText)
assert result.text == ''
def test_has_rating(self):
"""Tests has_rating"""
# From test_templates/resources.py::Resource::has_avatar_template
if not is_never_authz(self.service_config):
assert isinstance(self.object.has_rating(), bool)
def test_get_rating_id(self):
"""Tests get_rating_id"""
# From test_templates/resources.py::Resource::get_avatar_id_template
if not is_never_authz(self.service_config):
pytest.raises(errors.IllegalState,
self.object.get_rating_id)
def test_get_rating(self):
"""Tests get_rating"""
# From test_templates/resources.py::Resource::get_avatar_template
if not is_never_authz(self.service_config):
pytest.raises(errors.IllegalState,
self.object.get_rating)
def test_get_comment_record(self):
"""Tests get_comment_record"""
if is_never_authz(self.service_config):
pass # no object to call the method on?
else:
with pytest.raises(errors.Unsupported):
self.object.get_comment_record(True)
@pytest.fixture(scope="class",
params=['TEST_SERVICE', 'TEST_SERVICE_ALWAYS_AUTHZ', 'TEST_SERVICE_NEVER_AUTHZ', 'TEST_SERVICE_CATALOGING', 'TEST_SERVICE_FILESYSTEM', 'TEST_SERVICE_MEMCACHE'])
def comment_form_class_fixture(request):
request.cls.service_config = request.param
request.cls.svc_mgr = Runtime().get_service_manager(
'COMMENTING',
proxy=PROXY,
implementation=request.cls.service_config)
if not is_never_authz(request.cls.service_config):
create_form = request.cls.svc_mgr.get_book_form_for_create([])
create_form.display_name = 'Test Book'
create_form.description = 'Test Book for CommentForm tests'
request.cls.catalog = request.cls.svc_mgr.create_book(create_form)
request.cls.form = request.cls.catalog.get_comment_form_for_create(AGENT_ID, [])
def class_tear_down():
if not is_never_authz(request.cls.service_config):
for catalog in request.cls.svc_mgr.get_books():
request.cls.svc_mgr.delete_book(catalog.ident)
request.addfinalizer(class_tear_down)
@pytest.fixture(scope="function")
def comment_form_test_fixture(request):
pass
@pytest.mark.usefixtures("comment_form_class_fixture", "comment_form_test_fixture")
class TestCommentForm(object):
"""Tests for CommentForm"""
def test_get_text_metadata(self):
"""Tests get_text_metadata"""
# From test_templates/resource.py::ResourceForm::get_group_metadata_template
if not is_never_authz(self.service_config):
mdata = self.form.get_text_metadata()
assert isinstance(mdata, Metadata)
assert isinstance(mdata.get_element_id(), ABC_Id)
assert isinstance(mdata.get_element_label(), ABC_DisplayText)
assert isinstance(mdata.get_instructions(), ABC_DisplayText)
assert mdata.get_syntax() == 'STRING'
assert not mdata.is_array()
assert isinstance(mdata.is_required(), bool)
assert isinstance(mdata.is_read_only(), bool)
assert isinstance(mdata.is_linked(), bool)
def test_set_text(self):
"""Tests set_text"""
# From test_templates/repository.py::AssetForm::set_title_template
if not is_never_authz(self.service_config):
default_value = self.form.get_text_metadata().get_default_string_values()[0]
assert self.form._my_map['text'] == default_value
self.form.set_text('String')
assert self.form._my_map['text']['text'] == 'String'
with pytest.raises(errors.InvalidArgument):
self.form.set_text(42)
def test_clear_text(self):
"""Tests clear_text"""
# From test_templates/repository.py::AssetForm::clear_title_template
if not is_never_authz(self.service_config):
self.form.set_text('A String to Clear')
assert self.form._my_map['text']['text'] == 'A String to Clear'
self.form.clear_text()
assert self.form._my_map['text'] == self.form.get_text_metadata().get_default_string_values()[0]
def test_get_rating_metadata(self):
"""Tests get_rating_metadata"""
# From test_templates/resource.py::ResourceForm::get_avatar_metadata_template
if not is_never_authz(self.service_config):
mdata = self.form.get_rating_metadata()
assert isinstance(mdata, Metadata)
assert isinstance(mdata.get_element_id(), ABC_Id)
assert isinstance(mdata.get_element_label(), ABC_DisplayText)
assert isinstance(mdata.get_instructions(), ABC_DisplayText)
assert mdata.get_syntax() == 'ID'
assert not mdata.is_array()
assert isinstance(mdata.is_required(), bool)
assert isinstance(mdata.is_read_only(), bool)
assert isinstance(mdata.is_linked(), bool)
def test_set_rating(self):
"""Tests set_rating"""
# From test_templates/resource.py::ResourceForm::set_avatar_template
if not is_never_authz(self.service_config):
assert self.form._my_map['ratingId'] == ''
self.form.set_rating(Id('repository.Asset%3Afake-id%40ODL.MIT.EDU'))
assert self.form._my_map['ratingId'] == 'repository.Asset%3Afake-id%40ODL.MIT.EDU'
with pytest.raises(errors.InvalidArgument):
self.form.set_rating(True)
def test_clear_rating(self):
"""Tests clear_rating"""
# From test_templates/resource.py::ResourceForm::clear_avatar_template
if not is_never_authz(self.service_config):
self.form.set_rating(Id('repository.Asset%3Afake-id%40ODL.MIT.EDU'))
assert self.form._my_map['ratingId'] == 'repository.Asset%3Afake-id%40ODL.MIT.EDU'
self.form.clear_rating()
assert self.form._my_map['ratingId'] == self.form.get_rating_metadata().get_default_id_values()[0]
def test_get_comment_form_record(self):
"""Tests get_comment_form_record"""
if not is_never_authz(self.service_config):
with pytest.raises(errors.Unsupported):
self.form.get_comment_form_record(Type('osid.Osid%3Afake-record%40ODL.MIT.EDU'))
# Here check for a real record?
@pytest.fixture(scope="class",
params=['TEST_SERVICE', 'TEST_SERVICE_ALWAYS_AUTHZ', 'TEST_SERVICE_NEVER_AUTHZ', 'TEST_SERVICE_CATALOGING', 'TEST_SERVICE_FILESYSTEM', 'TEST_SERVICE_MEMCACHE'])
def comment_list_class_fixture(request):
request.cls.service_config = request.param
request.cls.svc_mgr = Runtime().get_service_manager(
'COMMENTING',
proxy=PROXY,
implementation=request.cls.service_config)
if not is_never_authz(request.cls.service_config):
create_form = request.cls.svc_mgr.get_book_form_for_create([])
create_form.display_name = 'Test Book'
create_form.description = 'Test Book for CommentForm tests'
request.cls.catalog = request.cls.svc_mgr.create_book(create_form)
request.cls.form = request.cls.catalog.get_comment_form_for_create(AGENT_ID, [])
def class_tear_down():
if not is_never_authz(request.cls.service_config):
for catalog in request.cls.svc_mgr.get_books():
for comment in catalog.get_comments():
catalog.delete_comment(comment.ident)
request.cls.svc_mgr.delete_book(catalog.ident)
request.addfinalizer(class_tear_down)
@pytest.fixture(scope="function")
def comment_list_test_fixture(request):
from dlkit.json_.commenting.objects import CommentList
request.cls.comment_list = list()
request.cls.comment_ids = list()
if not is_never_authz(request.cls.service_config):
for num in [0, 1]:
form = request.cls.catalog.get_comment_form_for_create(AGENT_ID, [])
obj = request.cls.catalog.create_comment(form)
request.cls.comment_list.append(obj)
request.cls.comment_ids.append(obj.ident)
request.cls.comment_list = CommentList(request.cls.comment_list)
@pytest.mark.usefixtures("comment_list_class_fixture", "comment_list_test_fixture")
class TestCommentList(object):
"""Tests for CommentList"""
def test_get_next_comment(self):
"""Tests get_next_comment"""
# From test_templates/resource.py::ResourceList::get_next_resource_template
from dlkit.abstract_osid.commenting.objects import Comment
if not is_never_authz(self.service_config):
assert isinstance(self.comment_list.get_next_comment(), Comment)
def test_get_next_comments(self):
"""Tests get_next_comments"""
# From test_templates/resource.py::ResourceList::get_next_resources_template
from dlkit.abstract_osid.commenting.objects import CommentList, Comment
if not is_never_authz(self.service_config):
new_list = self.comment_list.get_next_comments(2)
assert isinstance(new_list, CommentList)
for item in new_list:
assert isinstance(item, Comment)
@pytest.fixture(scope="class",
params=['TEST_SERVICE', 'TEST_SERVICE_ALWAYS_AUTHZ', 'TEST_SERVICE_NEVER_AUTHZ', 'TEST_SERVICE_CATALOGING', 'TEST_SERVICE_FILESYSTEM', 'TEST_SERVICE_MEMCACHE'])
def book_class_fixture(request):
# From test_templates/resource.py::Bin::init_template
request.cls.service_config = request.param
request.cls.svc_mgr = Runtime().get_service_manager(
'COMMENTING',
proxy=PROXY,
implementation=request.cls.service_config)
def class_tear_down():
pass
request.addfinalizer(class_tear_down)
@pytest.fixture(scope="function")
def book_test_fixture(request):
# From test_templates/resource.py::Bin::init_template
if not is_never_authz(request.cls.service_config):
form = request.cls.svc_mgr.get_book_form_for_create([])
form.display_name = 'for testing'
request.cls.object = request.cls.svc_mgr.create_book(form)
def test_tear_down():
if not is_never_authz(request.cls.service_config):
request.cls.svc_mgr.delete_book(request.cls.object.ident)
request.addfinalizer(test_tear_down)
@pytest.mark.usefixtures("book_class_fixture", "book_test_fixture")
class TestBook(object):
"""Tests for Book"""
def test_get_book_record(self):
"""Tests get_book_record"""
if is_never_authz(self.service_config):
pass # no object to call the method on?
elif uses_cataloging(self.service_config):
pass # cannot call the _get_record() methods on catalogs
else:
with pytest.raises(errors.Unimplemented):
self.object.get_book_record(True)
@pytest.fixture(scope="class",
params=['TEST_SERVICE', 'TEST_SERVICE_ALWAYS_AUTHZ', 'TEST_SERVICE_NEVER_AUTHZ', 'TEST_SERVICE_CATALOGING', 'TEST_SERVICE_FILESYSTEM', 'TEST_SERVICE_MEMCACHE'])
def book_form_class_fixture(request):
# From test_templates/resource.py::BinForm::init_template
request.cls.service_config = request.param
request.cls.svc_mgr = Runtime().get_service_manager(
'COMMENTING',
proxy=PROXY,
implementation=request.cls.service_config)
def class_tear_down():
pass
request.addfinalizer(class_tear_down)
@pytest.fixture(scope="function")
def book_form_test_fixture(request):
# From test_templates/resource.py::BinForm::init_template
if not is_never_authz(request.cls.service_config):
request.cls.object = request.cls.svc_mgr.get_book_form_for_create([])
def test_tear_down():
pass
request.addfinalizer(test_tear_down)
@pytest.mark.usefixtures("book_form_class_fixture", "book_form_test_fixture")
class TestBookForm(object):
"""Tests for BookForm"""
def test_get_book_form_record(self):
"""Tests get_book_form_record"""
if is_never_authz(self.service_config):
pass # no object to call the method on?
elif uses_cataloging(self.service_config):
pass # cannot call the _get_record() methods on catalogs
else:
with pytest.raises(errors.Unimplemented):
self.object.get_book_form_record(True)
@pytest.fixture(scope="class",
params=['TEST_SERVICE', 'TEST_SERVICE_ALWAYS_AUTHZ', 'TEST_SERVICE_NEVER_AUTHZ', 'TEST_SERVICE_CATALOGING', 'TEST_SERVICE_FILESYSTEM', 'TEST_SERVICE_MEMCACHE'])
def book_list_class_fixture(request):
# Implemented from init template for BinList
request.cls.service_config = request.param
request.cls.svc_mgr = Runtime().get_service_manager(
'COMMENTING',
proxy=PROXY,
implementation=request.cls.service_config)
if not is_never_authz(request.cls.service_config):
create_form = request.cls.svc_mgr.get_book_form_for_create([])
create_form.display_name = 'Test Book'
create_form.description = 'Test Book for BookList tests'
request.cls.catalog = request.cls.svc_mgr.create_book(create_form)
request.cls.book_ids = list()
def class_tear_down():
if not is_never_authz(request.cls.service_config):
for obj in request.cls.book_ids:
request.cls.svc_mgr.delete_book(obj)
request.cls.svc_mgr.delete_book(request.cls.catalog.ident)
request.addfinalizer(class_tear_down)
@pytest.fixture(scope="function")
def book_list_test_fixture(request):
# Implemented from init template for BinList
from dlkit.json_.commenting.objects import BookList
request.cls.book_list = list()
if not is_never_authz(request.cls.service_config):
for num in [0, 1]:
create_form = request.cls.svc_mgr.get_book_form_for_create([])
create_form.display_name = 'Test Book ' + str(num)
create_form.description = 'Test Book for BookList tests'
obj = request.cls.svc_mgr.create_book(create_form)
request.cls.book_list.append(obj)
request.cls.book_ids.append(obj.ident)
request.cls.book_list = BookList(request.cls.book_list)
@pytest.mark.usefixtures("book_list_class_fixture", "book_list_test_fixture")
class TestBookList(object):
"""Tests for BookList"""
def test_get_next_book(self):
"""Tests get_next_book"""
# From test_templates/resource.py::ResourceList::get_next_resource_template
from dlkit.abstract_osid.commenting.objects import Book
if not is_never_authz(self.service_config):
assert isinstance(self.book_list.get_next_book(), Book)
def test_get_next_books(self):
"""Tests get_next_books"""
# From test_templates/resource.py::ResourceList::get_next_resources_template
from dlkit.abstract_osid.commenting.objects import BookList, Book
if not is_never_authz(self.service_config):
new_list = self.book_list.get_next_books(2)
assert isinstance(new_list, BookList)
for item in new_list:
assert isinstance(item, Book)
@pytest.fixture(scope="class",
params=['TEST_SERVICE', 'TEST_SERVICE_ALWAYS_AUTHZ', 'TEST_SERVICE_NEVER_AUTHZ', 'TEST_SERVICE_CATALOGING', 'TEST_SERVICE_FILESYSTEM', 'TEST_SERVICE_MEMCACHE'])
def book_node_class_fixture(request):
# Implemented from init template for BinNode
request.cls.service_config = request.param
request.cls.svc_mgr = Runtime().get_service_manager(
'COMMENTING',
proxy=PROXY,
implementation=request.cls.service_config)
if not is_never_authz(request.cls.service_config):
create_form = request.cls.svc_mgr.get_book_form_for_create([])
create_form.display_name = 'Test Book'
create_form.description = 'Test Book for BookNode tests'
request.cls.catalog = request.cls.svc_mgr.create_book(create_form)
request.cls.book_ids = list()
def class_tear_down():
if not is_never_authz(request.cls.service_config):
request.cls.svc_mgr.delete_book(request.cls.catalog.ident)
request.addfinalizer(class_tear_down)
@pytest.fixture(scope="function")
def book_node_test_fixture(request):
# Implemented from init template for BinNode
from dlkit.json_.commenting.objects import BookNode
request.cls.book_list = list()
if not is_never_authz(request.cls.service_config):
for num in [0, 1]:
create_form = request.cls.svc_mgr.get_book_form_for_create([])
create_form.display_name = 'Test Book ' + str(num)
create_form.description = 'Test Book for BookNode tests'
obj = request.cls.svc_mgr.create_book(create_form)
request.cls.book_list.append(BookNode(
obj.object_map,
runtime=request.cls.svc_mgr._runtime,
proxy=request.cls.svc_mgr._proxy))
request.cls.book_ids.append(obj.ident)
# Not put the catalogs in a hierarchy
request.cls.svc_mgr.add_root_book(request.cls.book_list[0].ident)
request.cls.svc_mgr.add_child_book(
request.cls.book_list[0].ident,
request.cls.book_list[1].ident)
request.cls.object = request.cls.svc_mgr.get_book_nodes(
request.cls.book_list[0].ident, 0, 5, False)
def test_tear_down():
if not is_never_authz(request.cls.service_config):
request.cls.svc_mgr.remove_child_book(
request.cls.book_list[0].ident,
request.cls.book_list[1].ident)
request.cls.svc_mgr.remove_root_book(request.cls.book_list[0].ident)
for node in request.cls.book_list:
request.cls.svc_mgr.delete_book(node.ident)
request.addfinalizer(test_tear_down)
@pytest.mark.usefixtures("book_node_class_fixture", "book_node_test_fixture")
class TestBookNode(object):
"""Tests for BookNode"""
def test_get_book(self):
"""Tests get_book"""
# from test_templates/resource.py::BinNode::get_bin_template
from dlkit.abstract_osid.commenting.objects import Book
if not is_never_authz(self.service_config):
assert isinstance(self.book_list[0].get_book(), OsidCatalog)
assert str(self.book_list[0].get_book().ident) == str(self.book_list[0].ident)
def test_get_parent_book_nodes(self):
"""Tests get_parent_book_nodes"""
# from test_templates/resource.py::BinNode::get_parent_bin_nodes
from dlkit.abstract_osid.commenting.objects import BookNodeList
if not is_never_authz(self.service_config):
node = self.svc_mgr.get_book_nodes(
self.book_list[1].ident,
1,
0,
False)
assert isinstance(node.get_parent_book_nodes(), BookNodeList)
assert node.get_parent_book_nodes().available() == 1
assert str(node.get_parent_book_nodes().next().ident) == str(self.book_list[0].ident)
def test_get_child_book_nodes(self):
"""Tests get_child_book_nodes"""
# from test_templates/resource.py::BinNode::get_child_bin_nodes_template
from dlkit.abstract_osid.commenting.objects import BookNodeList
if not is_never_authz(self.service_config):
node = self.svc_mgr.get_book_nodes(
self.book_list[0].ident,
0,
1,
False)
assert isinstance(node.get_child_book_nodes(), BookNodeList)
assert node.get_child_book_nodes().available() == 1
assert str(node.get_child_book_nodes().next().ident) == str(self.book_list[1].ident)
@pytest.fixture(scope="class",
params=['TEST_SERVICE', 'TEST_SERVICE_ALWAYS_AUTHZ', 'TEST_SERVICE_NEVER_AUTHZ', 'TEST_SERVICE_CATALOGING', 'TEST_SERVICE_FILESYSTEM', 'TEST_SERVICE_MEMCACHE'])
def book_node_list_class_fixture(request):
# Implemented from init template for BinNodeList
request.cls.service_config = request.param
request.cls.svc_mgr = Runtime().get_service_manager(
'COMMENTING',
proxy=PROXY,
implementation=request.cls.service_config)
if not is_never_authz(request.cls.service_config):
create_form = request.cls.svc_mgr.get_book_form_for_create([])
create_form.display_name = 'Test Book'
create_form.description = 'Test Book for BookNodeList tests'
request.cls.catalog = request.cls.svc_mgr.create_book(create_form)
request.cls.book_node_ids = list()
def class_tear_down():
if not is_never_authz(request.cls.service_config):
for obj in request.cls.book_node_ids:
request.cls.svc_mgr.delete_book(obj)
request.cls.svc_mgr.delete_book(request.cls.catalog.ident)
@pytest.fixture(scope="function")
def book_node_list_test_fixture(request):
# Implemented from init template for BinNodeList
from dlkit.json_.commenting.objects import BookNodeList, BookNode
request.cls.book_node_list = list()
if not is_never_authz(request.cls.service_config):
for num in [0, 1]:
create_form = request.cls.svc_mgr.get_book_form_for_create([])
create_form.display_name = 'Test BookNode ' + str(num)
create_form.description = 'Test BookNode for BookNodeList tests'
obj = request.cls.svc_mgr.create_book(create_form)
request.cls.book_node_list.append(BookNode(obj.object_map))
request.cls.book_node_ids.append(obj.ident)
# Not put the catalogs in a hierarchy
request.cls.svc_mgr.add_root_book(request.cls.book_node_list[0].ident)
request.cls.svc_mgr.add_child_book(
request.cls.book_node_list[0].ident,
request.cls.book_node_list[1].ident)
request.cls.book_node_list = BookNodeList(request.cls.book_node_list)
@pytest.mark.usefixtures("book_node_list_class_fixture", "book_node_list_test_fixture")
class TestBookNodeList(object):
"""Tests for BookNodeList"""
def test_get_next_book_node(self):
"""Tests get_next_book_node"""
# From test_templates/resource.py::ResourceList::get_next_resource_template
from dlkit.abstract_osid.commenting.objects import BookNode
if not is_never_authz(self.service_config):
assert isinstance(self.book_node_list.get_next_book_node(), BookNode)
def test_get_next_book_nodes(self):
"""Tests get_next_book_nodes"""
# From test_templates/resource.py::ResourceList::get_next_resources_template
from dlkit.abstract_osid.commenting.objects import BookNodeList, BookNode
if not is_never_authz(self.service_config):
new_list = self.book_node_list.get_next_book_nodes(2)
assert isinstance(new_list, BookNodeList)
for item in new_list:
assert isinstance(item, BookNode)
|
mit
|
[
624,
5072,
2295,
402,
3721,
316,
2251,
1041,
421,
199,
646,
4613,
421,
199,
504,
2508,
16355,
14,
10706,
492,
365,
63,
18178,
63,
1178,
90,
12,
365,
63,
889,
63,
1178,
90,
12,
4440,
63,
7959,
316,
12,
4440,
63,
11381,
63,
2118,
199,
504,
15396,
6065,
14,
6198,
63,
79,
4148,
14,
3349,
316,
492,
2251,
465,
14840,
19561,
83,
199,
504,
15396,
6065,
14,
6198,
63,
79,
4148,
14,
344,
14,
1359,
22337,
492,
15418,
465,
17281,
63,
1304,
199,
504,
15396,
6065,
14,
6198,
63,
79,
4148,
14,
5508,
14,
1359,
22337,
492,
12175,
1872,
465,
17281,
63,
7687,
1872,
199,
504,
15396,
6065,
14,
6198,
63,
79,
4148,
14,
79,
4148,
492,
2552,
199,
504,
15396,
6065,
14,
6198,
63,
79,
4148,
14,
79,
4148,
14,
1462,
492,
593,
4148,
17161,
199,
504,
15396,
6065,
14,
1001,
3754,
344,
14,
1462,
492,
15418,
1296,
199,
504,
15396,
6065,
14,
1001,
3754,
79,
4148,
14,
2343,
492,
16160,
199,
504,
15396,
6065,
14,
1359,
12416,
12980,
14,
344,
14,
1359,
22337,
492,
15418,
199,
504,
15396,
6065,
14,
1359,
12416,
12980,
14,
5508,
14,
1359,
22337,
492,
12175,
1872,
199,
504,
15396,
6065,
14,
1359,
12416,
12980,
14,
466,
14,
1359,
22337,
492,
2434,
199,
504,
15396,
6065,
14,
7726,
492,
3611,
8195,
63,
12763,
12,
4566,
63,
2694,
199,
504,
15396,
6065,
14,
7726,
14,
16259,
492,
19103,
421,
199,
6780,
275,
4566,
63,
2694,
14,
3184,
2017,
342,
199,
1864,
31247,
275,
3611,
8195,
63,
12763,
14,
362,
63,
3280,
63,
5394,
342,
199,
1864,
31247,
14,
409,
63,
1014,
63,
1069,
8,
6780,
9,
199,
20026,
275,
3611,
8195,
63,
12763,
14,
362,
63,
3280,
8,
1864,
31247,
9,
199,
199,
3472,
63,
2711,
275,
2434,
3682,
1445,
5364,
356,
283,
3472,
297,
283,
3251,
356,
283,
3472,
297,
283,
23635,
356,
283,
3472,
3071,
199,
14565,
63,
998,
275,
15418,
3682,
1445,
5364,
356,
283,
74,
5865,
63,
1117,
69,
297,
283,
3251,
356,
283,
79,
4148,
14,
4054,
14,
7788,
297,
283,
23635,
356,
283,
13965,
13,
47,
8045,
3071,
421,
199,
32,
4462,
14,
5997,
8,
2645,
628,
533,
401,
355,
1862,
2968,
2864,
63,
10486,
297,
283,
2864,
63,
10486,
63,
32509,
63,
5580,
58,
297,
283,
2864,
63,
10486,
63,
6388,
2111,
63,
5580,
58,
297,
283,
2864,
63,
10486,
63,
11206,
23622,
1206,
297,
283,
2864,
63,
10486,
63,
9472,
57,
9757,
297,
283,
2864,
63,
10486,
63,
10293,
8677,
1105,
199,
318,
3721,
63,
533,
63,
5997,
8,
1069,
304,
272,
1056,
14,
1886,
14,
1364,
63,
888,
275,
1056,
14,
635,
272,
1056,
14,
1886,
14,
10599,
63,
7755,
275,
19103,
1252,
362,
63,
1364,
63,
2609,
8,
267,
283,
10973,
1206,
297,
267,
4566,
29,
20026,
12,
267,
4514,
29,
1069,
14,
1886,
14,
1364,
63,
888,
9,
272,
340,
440,
365,
63,
18178,
63,
1178,
90,
8,
1069,
14,
1886,
14,
1364,
63,
888,
304,
267,
1218,
63,
964,
275,
1056,
14,
1886,
14,
10599,
63,
7755,
14,
362,
63,
2706,
63,
964,
63,
509,
63,
981,
4157,
267,
1218,
63,
964,
14,
2918,
63,
354,
275,
283,
774,
10594,
7,
267,
1218,
63,
964,
14,
1802,
275,
283,
774,
10594,
1369,
7,
267,
1056,
14,
1886,
14,
7959,
275,
1056,
14,
1886,
14,
10599,
63,
7755,
14,
981,
63,
2706,
8,
981,
63,
964,
9,
398,
1824,
275,
1056,
14,
1886,
14,
7959,
14,
362,
63,
3349,
63,
964,
63,
509,
63,
981,
8,
288,
15418,
360,
1927,
14,
4031,
5,
19,
33,
17,
5,
2167,
47,
8045,
14,
13965,
14,
1149,
53,
659,
288,
3073,
267,
1824,
14,
2918,
63,
354,
275,
283,
774,
909,
7,
267,
1056,
14,
1886,
14,
785,
275,
1056,
14,
1886,
14,
7959,
14,
981,
63,
3349,
8,
964,
9,
339,
347,
1021,
63,
266,
285,
63,
2110,
837,
267,
340,
440,
365,
63,
18178,
63,
1178,
90,
8,
1069,
14,
1886,
14,
1364,
63,
888,
304,
288,
367,
1559,
315,
1056,
14,
1886,
14,
7959,
14,
362,
63,
6223,
837,
355,
1056,
14,
1886,
14,
7959,
14,
1807,
63,
3349,
8,
1113,
14,
5425,
9,
288,
1056,
14,
1886,
14,
10599,
63,
7755,
14,
1807,
63,
2706,
8,
1069,
14,
1886,
14,
7959,
14,
5425,
9,
339,
1056,
14,
525,
30092,
8,
533,
63,
266,
285,
63,
2110,
9,
421,
199,
32,
4462,
14,
5997,
8,
2645,
628,
1593,
531,
199,
318,
3721,
63,
396,
63,
5997,
8,
1069,
304,
272,
986,
421,
199,
32,
4462,
14,
1657,
14,
1180,
8769,
480,
3349,
63,
533,
63,
5997,
401,
298,
3349,
63,
396,
63,
5997,
531,
199,
533,
1379,
7488,
8,
785,
304,
272,
408,
2925,
367,
6819,
624,
272,
768,
4462,
14,
1657,
14,
2759,
360,
324,
13825,
511,
358,
272,
347,
511,
63,
362,
63,
4443,
63,
344,
8,
277,
304,
267,
408,
2925,
664,
63,
4443,
63,
344,
624,
267,
986,
339,
768,
4462,
14,
1657,
14,
2759,
360,
324,
13825,
511,
358,
272,
347,
511,
63,
362,
63,
3349,
269,
63,
344,
8,
277,
304,
267,
408,
2925,
664,
63,
3349,
269,
63,
344,
624,
267,
986,
339,
347,
511,
63,
362,
63,
3349,
269,
8,
277,
304,
267,
408,
2925,
664,
63,
3349,
269,
624,
267,
340,
365,
63,
18178,
63,
1178,
90,
8,
277,
14,
1364,
63,
888,
304,
288,
986,
221,
327,
949,
909,
370,
1240,
314,
1083,
641,
31,
267,
587,
26,
288,
543,
4613,
14,
3536,
8,
2550,
14,
1358,
13825,
304,
355,
291,
14,
785,
14,
362,
63,
3349,
269,
342,
339,
347,
511,
63,
362,
63,
3349,
316,
63,
4054,
63,
344,
8,
277,
304,
267,
408,
2925,
664,
63,
3349,
316,
63,
4054,
63,
344,
624,
267,
340,
440,
365,
63,
18178,
63,
1178,
90,
8,
277,
14,
1364,
63,
888,
304,
288,
754,
275,
291,
14,
785,
14,
362,
63,
3349,
316,
63,
4054,
63,
344,
342,
288,
702,
1228,
8,
1099,
12,
15418,
9,
288,
702,
620,
8,
1099,
9,
508,
620,
8,
277,
14,
7959,
423,
3280,
14,
362,
63,
20427,
63,
4054,
63,
344,
1012,
339,
347,
511,
63,
362,
63,
3349,
316,
63
] |
[
5072,
2295,
402,
3721,
316,
2251,
1041,
421,
199,
646,
4613,
421,
199,
504,
2508,
16355,
14,
10706,
492,
365,
63,
18178,
63,
1178,
90,
12,
365,
63,
889,
63,
1178,
90,
12,
4440,
63,
7959,
316,
12,
4440,
63,
11381,
63,
2118,
199,
504,
15396,
6065,
14,
6198,
63,
79,
4148,
14,
3349,
316,
492,
2251,
465,
14840,
19561,
83,
199,
504,
15396,
6065,
14,
6198,
63,
79,
4148,
14,
344,
14,
1359,
22337,
492,
15418,
465,
17281,
63,
1304,
199,
504,
15396,
6065,
14,
6198,
63,
79,
4148,
14,
5508,
14,
1359,
22337,
492,
12175,
1872,
465,
17281,
63,
7687,
1872,
199,
504,
15396,
6065,
14,
6198,
63,
79,
4148,
14,
79,
4148,
492,
2552,
199,
504,
15396,
6065,
14,
6198,
63,
79,
4148,
14,
79,
4148,
14,
1462,
492,
593,
4148,
17161,
199,
504,
15396,
6065,
14,
1001,
3754,
344,
14,
1462,
492,
15418,
1296,
199,
504,
15396,
6065,
14,
1001,
3754,
79,
4148,
14,
2343,
492,
16160,
199,
504,
15396,
6065,
14,
1359,
12416,
12980,
14,
344,
14,
1359,
22337,
492,
15418,
199,
504,
15396,
6065,
14,
1359,
12416,
12980,
14,
5508,
14,
1359,
22337,
492,
12175,
1872,
199,
504,
15396,
6065,
14,
1359,
12416,
12980,
14,
466,
14,
1359,
22337,
492,
2434,
199,
504,
15396,
6065,
14,
7726,
492,
3611,
8195,
63,
12763,
12,
4566,
63,
2694,
199,
504,
15396,
6065,
14,
7726,
14,
16259,
492,
19103,
421,
199,
6780,
275,
4566,
63,
2694,
14,
3184,
2017,
342,
199,
1864,
31247,
275,
3611,
8195,
63,
12763,
14,
362,
63,
3280,
63,
5394,
342,
199,
1864,
31247,
14,
409,
63,
1014,
63,
1069,
8,
6780,
9,
199,
20026,
275,
3611,
8195,
63,
12763,
14,
362,
63,
3280,
8,
1864,
31247,
9,
199,
199,
3472,
63,
2711,
275,
2434,
3682,
1445,
5364,
356,
283,
3472,
297,
283,
3251,
356,
283,
3472,
297,
283,
23635,
356,
283,
3472,
3071,
199,
14565,
63,
998,
275,
15418,
3682,
1445,
5364,
356,
283,
74,
5865,
63,
1117,
69,
297,
283,
3251,
356,
283,
79,
4148,
14,
4054,
14,
7788,
297,
283,
23635,
356,
283,
13965,
13,
47,
8045,
3071,
421,
199,
32,
4462,
14,
5997,
8,
2645,
628,
533,
401,
355,
1862,
2968,
2864,
63,
10486,
297,
283,
2864,
63,
10486,
63,
32509,
63,
5580,
58,
297,
283,
2864,
63,
10486,
63,
6388,
2111,
63,
5580,
58,
297,
283,
2864,
63,
10486,
63,
11206,
23622,
1206,
297,
283,
2864,
63,
10486,
63,
9472,
57,
9757,
297,
283,
2864,
63,
10486,
63,
10293,
8677,
1105,
199,
318,
3721,
63,
533,
63,
5997,
8,
1069,
304,
272,
1056,
14,
1886,
14,
1364,
63,
888,
275,
1056,
14,
635,
272,
1056,
14,
1886,
14,
10599,
63,
7755,
275,
19103,
1252,
362,
63,
1364,
63,
2609,
8,
267,
283,
10973,
1206,
297,
267,
4566,
29,
20026,
12,
267,
4514,
29,
1069,
14,
1886,
14,
1364,
63,
888,
9,
272,
340,
440,
365,
63,
18178,
63,
1178,
90,
8,
1069,
14,
1886,
14,
1364,
63,
888,
304,
267,
1218,
63,
964,
275,
1056,
14,
1886,
14,
10599,
63,
7755,
14,
362,
63,
2706,
63,
964,
63,
509,
63,
981,
4157,
267,
1218,
63,
964,
14,
2918,
63,
354,
275,
283,
774,
10594,
7,
267,
1218,
63,
964,
14,
1802,
275,
283,
774,
10594,
1369,
7,
267,
1056,
14,
1886,
14,
7959,
275,
1056,
14,
1886,
14,
10599,
63,
7755,
14,
981,
63,
2706,
8,
981,
63,
964,
9,
398,
1824,
275,
1056,
14,
1886,
14,
7959,
14,
362,
63,
3349,
63,
964,
63,
509,
63,
981,
8,
288,
15418,
360,
1927,
14,
4031,
5,
19,
33,
17,
5,
2167,
47,
8045,
14,
13965,
14,
1149,
53,
659,
288,
3073,
267,
1824,
14,
2918,
63,
354,
275,
283,
774,
909,
7,
267,
1056,
14,
1886,
14,
785,
275,
1056,
14,
1886,
14,
7959,
14,
981,
63,
3349,
8,
964,
9,
339,
347,
1021,
63,
266,
285,
63,
2110,
837,
267,
340,
440,
365,
63,
18178,
63,
1178,
90,
8,
1069,
14,
1886,
14,
1364,
63,
888,
304,
288,
367,
1559,
315,
1056,
14,
1886,
14,
7959,
14,
362,
63,
6223,
837,
355,
1056,
14,
1886,
14,
7959,
14,
1807,
63,
3349,
8,
1113,
14,
5425,
9,
288,
1056,
14,
1886,
14,
10599,
63,
7755,
14,
1807,
63,
2706,
8,
1069,
14,
1886,
14,
7959,
14,
5425,
9,
339,
1056,
14,
525,
30092,
8,
533,
63,
266,
285,
63,
2110,
9,
421,
199,
32,
4462,
14,
5997,
8,
2645,
628,
1593,
531,
199,
318,
3721,
63,
396,
63,
5997,
8,
1069,
304,
272,
986,
421,
199,
32,
4462,
14,
1657,
14,
1180,
8769,
480,
3349,
63,
533,
63,
5997,
401,
298,
3349,
63,
396,
63,
5997,
531,
199,
533,
1379,
7488,
8,
785,
304,
272,
408,
2925,
367,
6819,
624,
272,
768,
4462,
14,
1657,
14,
2759,
360,
324,
13825,
511,
358,
272,
347,
511,
63,
362,
63,
4443,
63,
344,
8,
277,
304,
267,
408,
2925,
664,
63,
4443,
63,
344,
624,
267,
986,
339,
768,
4462,
14,
1657,
14,
2759,
360,
324,
13825,
511,
358,
272,
347,
511,
63,
362,
63,
3349,
269,
63,
344,
8,
277,
304,
267,
408,
2925,
664,
63,
3349,
269,
63,
344,
624,
267,
986,
339,
347,
511,
63,
362,
63,
3349,
269,
8,
277,
304,
267,
408,
2925,
664,
63,
3349,
269,
624,
267,
340,
365,
63,
18178,
63,
1178,
90,
8,
277,
14,
1364,
63,
888,
304,
288,
986,
221,
327,
949,
909,
370,
1240,
314,
1083,
641,
31,
267,
587,
26,
288,
543,
4613,
14,
3536,
8,
2550,
14,
1358,
13825,
304,
355,
291,
14,
785,
14,
362,
63,
3349,
269,
342,
339,
347,
511,
63,
362,
63,
3349,
316,
63,
4054,
63,
344,
8,
277,
304,
267,
408,
2925,
664,
63,
3349,
316,
63,
4054,
63,
344,
624,
267,
340,
440,
365,
63,
18178,
63,
1178,
90,
8,
277,
14,
1364,
63,
888,
304,
288,
754,
275,
291,
14,
785,
14,
362,
63,
3349,
316,
63,
4054,
63,
344,
342,
288,
702,
1228,
8,
1099,
12,
15418,
9,
288,
702,
620,
8,
1099,
9,
508,
620,
8,
277,
14,
7959,
423,
3280,
14,
362,
63,
20427,
63,
4054,
63,
344,
1012,
339,
347,
511,
63,
362,
63,
3349,
316,
63,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
michael-dev2rights/ansible
|
lib/ansible/modules/storage/infinidat/infini_vol.py
|
29
|
4232
|
#!/usr/bin/python
# -*- coding: utf-8 -*-
# (c) 2016, Gregory Shulov (gregory.shulov@gmail.com)
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
__metaclass__ = type
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['preview'],
'supported_by': 'community'}
DOCUMENTATION = '''
---
module: infini_vol
version_added: 2.3
short_description: Create, Delete or Modify volumes on Infinibox
description:
- This module creates, deletes or modifies volume on Infinibox.
author: Gregory Shulov (@GR360RY)
options:
name:
description:
- Volume Name
required: true
state:
description:
- Creates/Modifies volume when present or removes when absent
required: false
default: present
choices: [ "present", "absent" ]
size:
description:
- Volume size in MB, GB or TB units. See examples.
required: false
pool:
description:
- Pool that volume will reside on
required: true
extends_documentation_fragment:
- infinibox
requirements:
- capacity
'''
EXAMPLES = '''
- name: Create new volume named foo under pool named bar
infini_vol:
name: foo
size: 1TB
pool: bar
state: present
user: admin
password: secret
system: ibox001
'''
RETURN = '''
'''
try:
from capacity import KiB, Capacity
HAS_CAPACITY = True
except ImportError:
HAS_CAPACITY = False
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.infinibox import HAS_INFINISDK, api_wrapper, get_system, infinibox_argument_spec
@api_wrapper
def get_pool(module, system):
"""Return Pool or None"""
try:
return system.pools.get(name=module.params['pool'])
except:
return None
@api_wrapper
def get_volume(module, system):
"""Return Volume or None"""
try:
return system.volumes.get(name=module.params['name'])
except:
return None
@api_wrapper
def create_volume(module, system):
"""Create Volume"""
if not module.check_mode:
volume = system.volumes.create(name=module.params['name'], pool=get_pool(module, system))
if module.params['size']:
size = Capacity(module.params['size']).roundup(64 * KiB)
volume.update_size(size)
module.exit_json(changed=True)
@api_wrapper
def update_volume(module, volume):
"""Update Volume"""
changed = False
if module.params['size']:
size = Capacity(module.params['size']).roundup(64 * KiB)
if volume.get_size() != size:
if not module.check_mode:
volume.update_size(size)
changed = True
module.exit_json(changed=changed)
@api_wrapper
def delete_volume(module, volume):
""" Delete Volume"""
if not module.check_mode:
volume.delete()
module.exit_json(changed=True)
def main():
argument_spec = infinibox_argument_spec()
argument_spec.update(
dict(
name = dict(required=True),
state = dict(default='present', choices=['present', 'absent']),
pool = dict(required=True),
size = dict()
)
)
module = AnsibleModule(argument_spec, supports_check_mode=True)
if not HAS_INFINISDK:
module.fail_json(msg='infinisdk is required for this module')
if module.params['size']:
try:
Capacity(module.params['size'])
except:
module.fail_json(msg='size (Physical Capacity) should be defined in MB, GB, TB or PB units')
state = module.params['state']
system = get_system(module)
pool = get_pool(module, system)
volume = get_volume(module, system)
if pool is None:
module.fail_json(msg='Pool {} not found'.format(module.params['pool']))
if state == 'present' and not volume:
create_volume(module, system)
elif state == 'present' and volume:
update_volume(module, volume)
elif state == 'absent' and volume:
delete_volume(module, volume)
elif state == 'absent' and not volume:
module.exit_json(changed=False)
if __name__ == '__main__':
main()
|
gpl-3.0
|
[
3381,
2647,
15,
1393,
15,
1548,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
3,
334,
67,
9,
7800,
12,
29096,
1089,
5244,
13957,
86,
334,
3939,
1089,
14,
609,
13957,
86,
32,
6799,
14,
957,
9,
199,
3,
1664,
1696,
1684,
844,
373,
19,
14,
16,
11,
334,
3239,
9685,
503,
4178,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
15,
11692,
13,
19,
14,
16,
14,
2424,
9,
199,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
12,
4629,
12,
870,
63,
1593,
199,
363,
6577,
363,
275,
730,
421,
199,
8490,
63,
8314,
275,
791,
2343,
63,
1023,
356,
283,
17,
14,
17,
297,
490,
283,
1205,
356,
788,
7780,
995,
490,
283,
4946,
63,
991,
356,
283,
9387,
936,
421,
199,
8948,
275,
1449,
199,
2595,
199,
578,
26,
315,
7295,
63,
5650,
199,
1023,
63,
3270,
26,
499,
14,
19,
199,
3612,
63,
1802,
26,
221,
2790,
12,
8496,
503,
22520,
12158,
641,
1010,
7295,
1977,
199,
1802,
26,
272,
446,
961,
859,
8491,
12,
21812,
503,
26473,
3301,
641,
1010,
7295,
1977,
14,
199,
2502,
26,
29096,
1089,
5244,
13957,
86,
8593,
3975,
11197,
5782,
9,
199,
1419,
26,
523,
536,
26,
272,
1369,
26,
489,
446,
15018,
2812,
272,
1415,
26,
2549,
523,
1174,
26,
272,
1369,
26,
489,
446,
10560,
15,
7469,
5604,
3301,
1380,
3451,
503,
14185,
1380,
9552,
272,
1415,
26,
3055,
272,
849,
26,
3451,
272,
3415,
26,
359,
298,
1881,
401,
298,
5575,
2,
1622,
523,
1568,
26,
272,
1369,
26,
489,
446,
15018,
1568,
315,
19487,
12,
18553,
503,
377,
34,
6204,
14,
1666,
7251,
14,
272,
1415,
26,
3055,
523,
4203,
26,
272,
1369,
26,
489,
446,
15553,
626,
3301,
911,
295,
2441,
641,
272,
1415,
26,
2549,
199,
11036,
63,
9970,
63,
7677,
26,
272,
446,
315,
7295,
1977,
199,
7538,
26,
272,
446,
14893,
199,
2344,
199,
199,
8918,
275,
1449,
199,
13,
536,
26,
2790,
892,
3301,
4310,
3925,
1334,
4203,
4310,
4681,
523,
315,
7295,
63,
5650,
26,
272,
536,
26,
3925,
272,
1568,
26,
413,
20098,
272,
4203,
26,
4681,
272,
1174,
26,
3451,
272,
922,
26,
4628,
272,
2505,
26,
7565,
272,
2656,
26,
284,
1977,
4587,
199,
2344,
199,
199,
9677,
275,
1449,
199,
2344,
199,
199,
893,
26,
272,
687,
14893,
492,
1804,
17587,
12,
8790,
6192,
272,
7509,
63,
8549,
1348,
1922,
275,
715,
199,
2590,
3545,
26,
272,
7509,
63,
8549,
1348,
1922,
275,
756,
199,
199,
504,
3242,
14,
578,
63,
1208,
14,
4316,
492,
6953,
199,
504,
3242,
14,
578,
63,
1208,
14,
262,
7295,
1977,
492,
7509,
63,
32191,
1311,
10892,
12,
2986,
63,
5029,
12,
664,
63,
2253,
12,
315,
7295,
1977,
63,
2094,
63,
1650,
421,
199,
32,
1246,
63,
5029,
199,
318,
664,
63,
2293,
8,
578,
12,
2656,
304,
272,
408,
1767,
15553,
503,
488,
624,
272,
862,
26,
267,
372,
2656,
14,
12406,
14,
362,
8,
354,
29,
578,
14,
1162,
459,
2293,
1105,
272,
871,
26,
267,
372,
488,
421,
199,
32,
1246,
63,
5029,
199,
318,
664,
63,
2405,
8,
578,
12,
2656,
304,
272,
408,
1767,
15018,
503,
488,
624,
272,
862,
26,
267,
372,
2656,
14,
8838,
14,
362,
8,
354,
29,
578,
14,
1162,
459,
354,
1105,
272,
871,
26,
267,
372,
488,
421,
199,
32,
1246,
63,
5029,
199,
318,
1218,
63,
2405,
8,
578,
12,
2656,
304,
272,
408,
2499,
15018,
624,
272,
340,
440,
859,
14,
1074,
63,
632,
26,
267,
3301,
275,
2656,
14,
8838,
14,
981,
8,
354,
29,
578,
14,
1162,
459,
354,
995,
4203,
29,
362,
63,
2293,
8,
578,
12,
2656,
430,
267,
340,
859,
14,
1162,
459,
890,
2565,
288,
1568,
275,
8790,
6192,
8,
578,
14,
1162,
459,
890,
13227,
2363,
384,
8,
772,
627,
1804,
17587,
9,
288,
3301,
14,
873,
63,
890,
8,
890,
9,
272,
859,
14,
2224,
63,
1001,
8,
2489,
29,
549,
9,
421,
199,
32,
1246,
63,
5029,
199,
318,
1678,
63,
2405,
8,
578,
12,
3301,
304,
272,
408,
4152,
15018,
624,
272,
2896,
275,
756,
272,
340,
859,
14,
1162,
459,
890,
2565,
267,
1568,
275,
8790,
6192,
8,
578,
14,
1162,
459,
890,
13227,
2363,
384,
8,
772,
627,
1804,
17587,
9,
267,
340,
3301,
14,
362,
63,
890,
342,
1137,
1568,
26,
288,
340,
440,
859,
14,
1074,
63,
632,
26,
355,
3301,
14,
873,
63,
890,
8,
890,
9,
288,
2896,
275,
715,
339,
859,
14,
2224,
63,
1001,
8,
2489,
29,
2489,
9,
421,
199,
32,
1246,
63,
5029,
199,
318,
3145,
63,
2405,
8,
578,
12,
3301,
304,
272,
408,
8496,
15018,
624,
272,
340,
440,
859,
14,
1074,
63,
632,
26,
267,
3301,
14,
1807,
342,
272,
859,
14,
2224,
63,
1001,
8,
2489,
29,
549,
9,
421,
199,
318,
2446,
837,
272,
1423,
63,
1650,
275,
315,
7295,
1977,
63,
2094,
63,
1650,
342,
272,
1423,
63,
1650,
14,
873,
8,
267,
1211,
8,
288,
536,
221,
275,
1211,
8,
2427,
29,
549,
395,
288,
1174,
275,
1211,
8,
885,
534,
1881,
297,
3415,
2968,
1881,
297,
283,
5575,
3815,
288,
4203,
221,
275,
1211,
8,
2427,
29,
549,
395,
288,
1568,
221,
275,
1211,
342,
267,
776,
272,
776,
339,
859,
275,
6953,
8,
2094,
63,
1650,
12,
5171,
63,
1074,
63,
632,
29,
549,
9,
339,
340,
440,
7509,
63,
32191,
1311,
10892,
26,
267,
859,
14,
1633,
63,
1001,
8,
1328,
534,
262,
2408,
374,
6341,
365,
1415,
367,
642,
859,
358,
339,
340,
859,
14,
1162,
459,
890,
2565,
267,
862,
26,
288,
8790,
6192,
8,
578,
14,
1162,
459,
890,
1105,
267,
871,
26,
288,
859,
14,
1633,
63,
1001,
8,
1328,
534,
890,
334,
20303,
8790,
6192,
9,
1077,
506,
3247,
315,
19487,
12,
18553,
12,
377,
34,
503,
510,
34,
6204,
358,
339,
1174,
221,
275,
859,
14,
1162,
459,
929,
418,
272,
2656,
275,
664,
63,
2253,
8,
578,
9,
272,
4203,
257,
275,
664,
63,
2293,
8,
578,
12,
2656,
9,
272,
3301,
275,
664,
63,
2405,
8,
578,
12,
2656,
9,
339,
340,
4203,
365,
488,
26,
267
] |
[
2647,
15,
1393,
15,
1548,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
3,
334,
67,
9,
7800,
12,
29096,
1089,
5244,
13957,
86,
334,
3939,
1089,
14,
609,
13957,
86,
32,
6799,
14,
957,
9,
199,
3,
1664,
1696,
1684,
844,
373,
19,
14,
16,
11,
334,
3239,
9685,
503,
4178,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
15,
11692,
13,
19,
14,
16,
14,
2424,
9,
199,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
12,
4629,
12,
870,
63,
1593,
199,
363,
6577,
363,
275,
730,
421,
199,
8490,
63,
8314,
275,
791,
2343,
63,
1023,
356,
283,
17,
14,
17,
297,
490,
283,
1205,
356,
788,
7780,
995,
490,
283,
4946,
63,
991,
356,
283,
9387,
936,
421,
199,
8948,
275,
1449,
199,
2595,
199,
578,
26,
315,
7295,
63,
5650,
199,
1023,
63,
3270,
26,
499,
14,
19,
199,
3612,
63,
1802,
26,
221,
2790,
12,
8496,
503,
22520,
12158,
641,
1010,
7295,
1977,
199,
1802,
26,
272,
446,
961,
859,
8491,
12,
21812,
503,
26473,
3301,
641,
1010,
7295,
1977,
14,
199,
2502,
26,
29096,
1089,
5244,
13957,
86,
8593,
3975,
11197,
5782,
9,
199,
1419,
26,
523,
536,
26,
272,
1369,
26,
489,
446,
15018,
2812,
272,
1415,
26,
2549,
523,
1174,
26,
272,
1369,
26,
489,
446,
10560,
15,
7469,
5604,
3301,
1380,
3451,
503,
14185,
1380,
9552,
272,
1415,
26,
3055,
272,
849,
26,
3451,
272,
3415,
26,
359,
298,
1881,
401,
298,
5575,
2,
1622,
523,
1568,
26,
272,
1369,
26,
489,
446,
15018,
1568,
315,
19487,
12,
18553,
503,
377,
34,
6204,
14,
1666,
7251,
14,
272,
1415,
26,
3055,
523,
4203,
26,
272,
1369,
26,
489,
446,
15553,
626,
3301,
911,
295,
2441,
641,
272,
1415,
26,
2549,
199,
11036,
63,
9970,
63,
7677,
26,
272,
446,
315,
7295,
1977,
199,
7538,
26,
272,
446,
14893,
199,
2344,
199,
199,
8918,
275,
1449,
199,
13,
536,
26,
2790,
892,
3301,
4310,
3925,
1334,
4203,
4310,
4681,
523,
315,
7295,
63,
5650,
26,
272,
536,
26,
3925,
272,
1568,
26,
413,
20098,
272,
4203,
26,
4681,
272,
1174,
26,
3451,
272,
922,
26,
4628,
272,
2505,
26,
7565,
272,
2656,
26,
284,
1977,
4587,
199,
2344,
199,
199,
9677,
275,
1449,
199,
2344,
199,
199,
893,
26,
272,
687,
14893,
492,
1804,
17587,
12,
8790,
6192,
272,
7509,
63,
8549,
1348,
1922,
275,
715,
199,
2590,
3545,
26,
272,
7509,
63,
8549,
1348,
1922,
275,
756,
199,
199,
504,
3242,
14,
578,
63,
1208,
14,
4316,
492,
6953,
199,
504,
3242,
14,
578,
63,
1208,
14,
262,
7295,
1977,
492,
7509,
63,
32191,
1311,
10892,
12,
2986,
63,
5029,
12,
664,
63,
2253,
12,
315,
7295,
1977,
63,
2094,
63,
1650,
421,
199,
32,
1246,
63,
5029,
199,
318,
664,
63,
2293,
8,
578,
12,
2656,
304,
272,
408,
1767,
15553,
503,
488,
624,
272,
862,
26,
267,
372,
2656,
14,
12406,
14,
362,
8,
354,
29,
578,
14,
1162,
459,
2293,
1105,
272,
871,
26,
267,
372,
488,
421,
199,
32,
1246,
63,
5029,
199,
318,
664,
63,
2405,
8,
578,
12,
2656,
304,
272,
408,
1767,
15018,
503,
488,
624,
272,
862,
26,
267,
372,
2656,
14,
8838,
14,
362,
8,
354,
29,
578,
14,
1162,
459,
354,
1105,
272,
871,
26,
267,
372,
488,
421,
199,
32,
1246,
63,
5029,
199,
318,
1218,
63,
2405,
8,
578,
12,
2656,
304,
272,
408,
2499,
15018,
624,
272,
340,
440,
859,
14,
1074,
63,
632,
26,
267,
3301,
275,
2656,
14,
8838,
14,
981,
8,
354,
29,
578,
14,
1162,
459,
354,
995,
4203,
29,
362,
63,
2293,
8,
578,
12,
2656,
430,
267,
340,
859,
14,
1162,
459,
890,
2565,
288,
1568,
275,
8790,
6192,
8,
578,
14,
1162,
459,
890,
13227,
2363,
384,
8,
772,
627,
1804,
17587,
9,
288,
3301,
14,
873,
63,
890,
8,
890,
9,
272,
859,
14,
2224,
63,
1001,
8,
2489,
29,
549,
9,
421,
199,
32,
1246,
63,
5029,
199,
318,
1678,
63,
2405,
8,
578,
12,
3301,
304,
272,
408,
4152,
15018,
624,
272,
2896,
275,
756,
272,
340,
859,
14,
1162,
459,
890,
2565,
267,
1568,
275,
8790,
6192,
8,
578,
14,
1162,
459,
890,
13227,
2363,
384,
8,
772,
627,
1804,
17587,
9,
267,
340,
3301,
14,
362,
63,
890,
342,
1137,
1568,
26,
288,
340,
440,
859,
14,
1074,
63,
632,
26,
355,
3301,
14,
873,
63,
890,
8,
890,
9,
288,
2896,
275,
715,
339,
859,
14,
2224,
63,
1001,
8,
2489,
29,
2489,
9,
421,
199,
32,
1246,
63,
5029,
199,
318,
3145,
63,
2405,
8,
578,
12,
3301,
304,
272,
408,
8496,
15018,
624,
272,
340,
440,
859,
14,
1074,
63,
632,
26,
267,
3301,
14,
1807,
342,
272,
859,
14,
2224,
63,
1001,
8,
2489,
29,
549,
9,
421,
199,
318,
2446,
837,
272,
1423,
63,
1650,
275,
315,
7295,
1977,
63,
2094,
63,
1650,
342,
272,
1423,
63,
1650,
14,
873,
8,
267,
1211,
8,
288,
536,
221,
275,
1211,
8,
2427,
29,
549,
395,
288,
1174,
275,
1211,
8,
885,
534,
1881,
297,
3415,
2968,
1881,
297,
283,
5575,
3815,
288,
4203,
221,
275,
1211,
8,
2427,
29,
549,
395,
288,
1568,
221,
275,
1211,
342,
267,
776,
272,
776,
339,
859,
275,
6953,
8,
2094,
63,
1650,
12,
5171,
63,
1074,
63,
632,
29,
549,
9,
339,
340,
440,
7509,
63,
32191,
1311,
10892,
26,
267,
859,
14,
1633,
63,
1001,
8,
1328,
534,
262,
2408,
374,
6341,
365,
1415,
367,
642,
859,
358,
339,
340,
859,
14,
1162,
459,
890,
2565,
267,
862,
26,
288,
8790,
6192,
8,
578,
14,
1162,
459,
890,
1105,
267,
871,
26,
288,
859,
14,
1633,
63,
1001,
8,
1328,
534,
890,
334,
20303,
8790,
6192,
9,
1077,
506,
3247,
315,
19487,
12,
18553,
12,
377,
34,
503,
510,
34,
6204,
358,
339,
1174,
221,
275,
859,
14,
1162,
459,
929,
418,
272,
2656,
275,
664,
63,
2253,
8,
578,
9,
272,
4203,
257,
275,
664,
63,
2293,
8,
578,
12,
2656,
9,
272,
3301,
275,
664,
63,
2405,
8,
578,
12,
2656,
9,
339,
340,
4203,
365,
488,
26,
267,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
no2a/ansible
|
test/units/module_utils/basic/test_heuristic_log_sanitize.py
|
99
|
3815
|
# -*- coding: utf-8 -*-
# (c) 2015, Toshio Kuratomi <tkuratomi@ansible.com>
#
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
# Make coding more python3-ish
from __future__ import (absolute_import, division)
__metaclass__ = type
import sys
import syslog
from ansible.compat.tests import unittest
from ansible.compat.tests.mock import patch, MagicMock
from ansible.module_utils.basic import heuristic_log_sanitize
class TestHeuristicLogSanitize(unittest.TestCase):
def setUp(self):
self.URL_SECRET = 'http://username:pas:word@foo.com/data'
self.SSH_SECRET = 'username:pas:word@foo.com/data'
self.clean_data = repr(self._gen_data(3, True, True, 'no_secret_here'))
self.url_data = repr(self._gen_data(3, True, True, self.URL_SECRET))
self.ssh_data = repr(self._gen_data(3, True, True, self.SSH_SECRET))
def _gen_data(self, records, per_rec, top_level, secret_text):
hostvars = {'hostvars': {}}
for i in range(1, records, 1):
host_facts = {'host%s' % i:
{'pstack':
{'running': '875.1',
'symlinked': '880.0',
'tars': [],
'versions': ['885.0']},
}}
if per_rec:
host_facts['host%s' % i]['secret'] = secret_text
hostvars['hostvars'].update(host_facts)
if top_level:
hostvars['secret'] = secret_text
return hostvars
def test_did_not_hide_too_much(self):
self.assertEquals(heuristic_log_sanitize(self.clean_data), self.clean_data)
def test_hides_url_secrets(self):
url_output = heuristic_log_sanitize(self.url_data)
# Basic functionality: Successfully hid the password
self.assertNotIn('pas:word', url_output)
# Slightly more advanced, we hid all of the password despite the ":"
self.assertNotIn('pas', url_output)
# In this implementation we replace the password with 8 "*" which is
# also the length of our password. The url fields should be able to
# accurately detect where the password ends so the length should be
# the same:
self.assertEqual(len(url_output), len(self.url_data))
def test_hides_ssh_secrets(self):
ssh_output = heuristic_log_sanitize(self.ssh_data)
self.assertNotIn('pas:word', ssh_output)
# Slightly more advanced, we hid all of the password despite the ":"
self.assertNotIn('pas', ssh_output)
# ssh checking is harder as the heuristic is overzealous in many
# cases. Since the input will have at least one ":" present before
# the password we can tell some things about the beginning and end of
# the data, though:
self.assertTrue(ssh_output.startswith("{'"))
self.assertTrue(ssh_output.endswith("}"))
self.assertIn(":********@foo.com/data'", ssh_output)
def test_hides_parameter_secrets(self):
output = heuristic_log_sanitize('token="secret", user="person", token_entry="test=secret"', frozenset(['secret']))
self.assertNotIn('secret', output)
|
gpl-3.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
334,
67,
9,
6900,
12,
4005,
609,
2308,
1804,
300,
4188,
73,
665,
2663,
300,
4188,
73,
32,
4853,
14,
957,
30,
199,
3,
199,
3,
961,
570,
365,
1777,
402,
2622,
199,
3,
199,
3,
2622,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
199,
3,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
844,
12,
503,
199,
3,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
2622,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
3,
3180,
543,
2622,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
199,
3,
4155,
2803,
1655,
2366,
19,
13,
2453,
199,
504,
636,
2443,
363,
492,
334,
6116,
63,
646,
12,
4629,
9,
199,
363,
6577,
363,
275,
730,
199,
199,
646,
984,
199,
646,
22112,
199,
199,
504,
3242,
14,
5819,
14,
2219,
492,
2882,
199,
504,
3242,
14,
5819,
14,
2219,
14,
1805,
492,
3371,
12,
10079,
199,
199,
504,
3242,
14,
578,
63,
1208,
14,
4316,
492,
25332,
63,
793,
63,
18177,
199,
199,
533,
1379,
1966,
20911,
2445,
51,
12531,
8,
2796,
14,
1746,
304,
272,
347,
3613,
8,
277,
304,
267,
291,
14,
2632,
63,
12961,
275,
283,
1014,
921,
2473,
26,
15534,
26,
1027,
32,
1421,
14,
957,
15,
576,
7,
267,
291,
14,
13716,
63,
12961,
275,
283,
2473,
26,
15534,
26,
1027,
32,
1421,
14,
957,
15,
576,
7,
267,
291,
14,
3118,
63,
576,
275,
4700,
8,
277,
423,
2268,
63,
576,
8,
19,
12,
715,
12,
715,
12,
283,
889,
63,
4731,
63,
1681,
1333,
267,
291,
14,
633,
63,
576,
275,
4700,
8,
277,
423,
2268,
63,
576,
8,
19,
12,
715,
12,
715,
12,
291,
14,
2632,
63,
12961,
430,
267,
291,
14,
5510,
63,
576,
275,
4700,
8,
277,
423,
2268,
63,
576,
8,
19,
12,
715,
12,
715,
12,
291,
14,
13716,
63,
12961,
430,
339,
347,
485,
2268,
63,
576,
8,
277,
12,
5767,
12,
1126,
63,
2761,
12,
2746,
63,
1896,
12,
7565,
63,
505,
304,
267,
21835,
275,
791,
23265,
356,
24312,
267,
367,
284,
315,
1425,
8,
17,
12,
5767,
12,
413,
304,
288,
1591,
63,
5047,
275,
791,
1102,
5,
83,
7,
450,
284,
26,
1169,
791,
80,
2340,
356,
1816,
791,
5720,
356,
283,
13357,
14,
17,
297,
639,
283,
3840,
12751,
356,
283,
30321,
14,
16,
297,
639,
283,
84,
4291,
356,
990,
639,
283,
6234,
356,
788,
15889,
14,
16,
14949,
586,
3586,
288,
340,
1126,
63,
2761,
26,
355,
1591,
63,
5047,
459,
1102,
5,
83,
7,
450,
284,
2733,
4731,
418,
275,
7565,
63,
505,
288,
21835,
459,
23265,
2278,
873,
8,
1102,
63,
5047,
9,
267,
340,
2746,
63,
1896,
26,
288,
21835,
459,
4731,
418,
275,
7565,
63,
505,
267,
372,
21835,
339,
347,
511,
63,
14887,
63,
1397,
63,
8191,
63,
7354,
63,
77,
2133,
8,
277,
304,
267,
291,
14,
2947,
8,
426,
20911,
63,
793,
63,
18177,
8,
277,
14,
3118,
63,
576,
395,
291,
14,
3118,
63,
576,
9,
339,
347,
511,
63,
8191,
83,
63,
633,
63,
16153,
8,
277,
304,
267,
1166,
63,
1199,
275,
25332,
63,
793,
63,
18177,
8,
277,
14,
633,
63,
576,
9,
267,
327,
10082,
9330,
26,
22318,
5836,
27276,
314,
2505,
267,
291,
14,
8795,
360,
15534,
26,
1027,
297,
1166,
63,
1199,
9,
398,
327,
428,
4040,
590,
1655,
19472,
12,
781,
27276,
1006,
402,
314,
2505,
477,
681,
1175,
314,
14725,
267,
291,
14,
8795,
360,
15534,
297,
1166,
63,
1199,
9,
398,
327,
1010,
642,
4514,
781,
3350,
314,
2505,
543,
1695,
22423,
1314,
365,
267,
327,
2597,
314,
2582,
402,
4154,
2505,
14,
221,
710,
1166,
1504,
1077,
506,
7688,
370,
267,
327,
1066,
895,
13824,
9696,
2382,
314,
2505,
11187,
880,
314,
2582,
1077,
506,
267,
327,
314,
2011,
26,
267,
291,
14,
629,
8,
552,
8,
633,
63,
1199,
395,
822,
8,
277,
14,
633,
63,
576,
430,
339,
347,
511,
63,
8191,
83,
63,
5510,
63,
16153,
8,
277,
304,
267,
8635,
63,
1199,
275,
25332,
63,
793,
63,
18177,
8,
277,
14,
5510,
63,
576,
9,
267,
291,
14,
8795,
360,
15534,
26,
1027,
297,
8635,
63,
1199,
9,
398,
327,
428,
4040,
590,
1655,
19472,
12,
781,
27276,
1006,
402,
314,
2505,
477,
681,
1175,
314,
14725,
267,
291,
14,
8795,
360,
15534,
297,
8635,
63,
1199,
9,
398,
327,
8635,
7907,
365,
12159,
424,
465,
314,
25332,
365,
1806,
806,
279,
1785,
315,
5002,
267,
327,
5560,
14,
221,
9336,
314,
1324,
911,
1172,
737,
5210,
1373,
14725,
3451,
2544,
267,
327,
314,
2505,
781,
883,
11480,
2005,
7645,
3595,
314,
9608,
436,
1284,
402,
267,
327,
314,
666,
12,
10617,
26,
267,
291,
14,
1815,
8,
5510,
63,
1199,
14,
2460,
480,
1445,
2237,
267,
291,
14,
1815,
8,
5510,
63,
1199,
14,
4130,
480,
93,
2237,
267,
291,
14,
4080,
20308,
1801,
32,
1421,
14,
957,
15,
576,
4662,
8635,
63,
1199,
9,
339,
347,
511,
63,
8191,
83,
63,
5329,
63,
16153,
8,
277,
304,
267,
1072,
275,
25332,
63,
793,
63,
18177,
360,
1418,
628,
4731,
401,
922,
628,
5484,
401,
1526,
63,
2373,
628,
396,
29,
4731,
6949,
9522,
2941,
4731,
5156,
267,
291,
14,
8795,
360,
4731,
297,
1072,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
334,
67,
9,
6900,
12,
4005,
609,
2308,
1804,
300,
4188,
73,
665,
2663,
300,
4188,
73,
32,
4853,
14,
957,
30,
199,
3,
199,
3,
961,
570,
365,
1777,
402,
2622,
199,
3,
199,
3,
2622,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
199,
3,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
844,
12,
503,
199,
3,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
2622,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
3,
3180,
543,
2622,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
199,
3,
4155,
2803,
1655,
2366,
19,
13,
2453,
199,
504,
636,
2443,
363,
492,
334,
6116,
63,
646,
12,
4629,
9,
199,
363,
6577,
363,
275,
730,
199,
199,
646,
984,
199,
646,
22112,
199,
199,
504,
3242,
14,
5819,
14,
2219,
492,
2882,
199,
504,
3242,
14,
5819,
14,
2219,
14,
1805,
492,
3371,
12,
10079,
199,
199,
504,
3242,
14,
578,
63,
1208,
14,
4316,
492,
25332,
63,
793,
63,
18177,
199,
199,
533,
1379,
1966,
20911,
2445,
51,
12531,
8,
2796,
14,
1746,
304,
272,
347,
3613,
8,
277,
304,
267,
291,
14,
2632,
63,
12961,
275,
283,
1014,
921,
2473,
26,
15534,
26,
1027,
32,
1421,
14,
957,
15,
576,
7,
267,
291,
14,
13716,
63,
12961,
275,
283,
2473,
26,
15534,
26,
1027,
32,
1421,
14,
957,
15,
576,
7,
267,
291,
14,
3118,
63,
576,
275,
4700,
8,
277,
423,
2268,
63,
576,
8,
19,
12,
715,
12,
715,
12,
283,
889,
63,
4731,
63,
1681,
1333,
267,
291,
14,
633,
63,
576,
275,
4700,
8,
277,
423,
2268,
63,
576,
8,
19,
12,
715,
12,
715,
12,
291,
14,
2632,
63,
12961,
430,
267,
291,
14,
5510,
63,
576,
275,
4700,
8,
277,
423,
2268,
63,
576,
8,
19,
12,
715,
12,
715,
12,
291,
14,
13716,
63,
12961,
430,
339,
347,
485,
2268,
63,
576,
8,
277,
12,
5767,
12,
1126,
63,
2761,
12,
2746,
63,
1896,
12,
7565,
63,
505,
304,
267,
21835,
275,
791,
23265,
356,
24312,
267,
367,
284,
315,
1425,
8,
17,
12,
5767,
12,
413,
304,
288,
1591,
63,
5047,
275,
791,
1102,
5,
83,
7,
450,
284,
26,
1169,
791,
80,
2340,
356,
1816,
791,
5720,
356,
283,
13357,
14,
17,
297,
639,
283,
3840,
12751,
356,
283,
30321,
14,
16,
297,
639,
283,
84,
4291,
356,
990,
639,
283,
6234,
356,
788,
15889,
14,
16,
14949,
586,
3586,
288,
340,
1126,
63,
2761,
26,
355,
1591,
63,
5047,
459,
1102,
5,
83,
7,
450,
284,
2733,
4731,
418,
275,
7565,
63,
505,
288,
21835,
459,
23265,
2278,
873,
8,
1102,
63,
5047,
9,
267,
340,
2746,
63,
1896,
26,
288,
21835,
459,
4731,
418,
275,
7565,
63,
505,
267,
372,
21835,
339,
347,
511,
63,
14887,
63,
1397,
63,
8191,
63,
7354,
63,
77,
2133,
8,
277,
304,
267,
291,
14,
2947,
8,
426,
20911,
63,
793,
63,
18177,
8,
277,
14,
3118,
63,
576,
395,
291,
14,
3118,
63,
576,
9,
339,
347,
511,
63,
8191,
83,
63,
633,
63,
16153,
8,
277,
304,
267,
1166,
63,
1199,
275,
25332,
63,
793,
63,
18177,
8,
277,
14,
633,
63,
576,
9,
267,
327,
10082,
9330,
26,
22318,
5836,
27276,
314,
2505,
267,
291,
14,
8795,
360,
15534,
26,
1027,
297,
1166,
63,
1199,
9,
398,
327,
428,
4040,
590,
1655,
19472,
12,
781,
27276,
1006,
402,
314,
2505,
477,
681,
1175,
314,
14725,
267,
291,
14,
8795,
360,
15534,
297,
1166,
63,
1199,
9,
398,
327,
1010,
642,
4514,
781,
3350,
314,
2505,
543,
1695,
22423,
1314,
365,
267,
327,
2597,
314,
2582,
402,
4154,
2505,
14,
221,
710,
1166,
1504,
1077,
506,
7688,
370,
267,
327,
1066,
895,
13824,
9696,
2382,
314,
2505,
11187,
880,
314,
2582,
1077,
506,
267,
327,
314,
2011,
26,
267,
291,
14,
629,
8,
552,
8,
633,
63,
1199,
395,
822,
8,
277,
14,
633,
63,
576,
430,
339,
347,
511,
63,
8191,
83,
63,
5510,
63,
16153,
8,
277,
304,
267,
8635,
63,
1199,
275,
25332,
63,
793,
63,
18177,
8,
277,
14,
5510,
63,
576,
9,
267,
291,
14,
8795,
360,
15534,
26,
1027,
297,
8635,
63,
1199,
9,
398,
327,
428,
4040,
590,
1655,
19472,
12,
781,
27276,
1006,
402,
314,
2505,
477,
681,
1175,
314,
14725,
267,
291,
14,
8795,
360,
15534,
297,
8635,
63,
1199,
9,
398,
327,
8635,
7907,
365,
12159,
424,
465,
314,
25332,
365,
1806,
806,
279,
1785,
315,
5002,
267,
327,
5560,
14,
221,
9336,
314,
1324,
911,
1172,
737,
5210,
1373,
14725,
3451,
2544,
267,
327,
314,
2505,
781,
883,
11480,
2005,
7645,
3595,
314,
9608,
436,
1284,
402,
267,
327,
314,
666,
12,
10617,
26,
267,
291,
14,
1815,
8,
5510,
63,
1199,
14,
2460,
480,
1445,
2237,
267,
291,
14,
1815,
8,
5510,
63,
1199,
14,
4130,
480,
93,
2237,
267,
291,
14,
4080,
20308,
1801,
32,
1421,
14,
957,
15,
576,
4662,
8635,
63,
1199,
9,
339,
347,
511,
63,
8191,
83,
63,
5329,
63,
16153,
8,
277,
304,
267,
1072,
275,
25332,
63,
793,
63,
18177,
360,
1418,
628,
4731,
401,
922,
628,
5484,
401,
1526,
63,
2373,
628,
396,
29,
4731,
6949,
9522,
2941,
4731,
5156,
267,
291,
14,
8795,
360,
4731,
297,
1072,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
rexyeah/jira-cli
|
jiracli/processor.py
|
1
|
9984
|
"""
"""
from abc import ABCMeta, abstractmethod
import six
from jiracli.cli import colorfunc
from jiracli.errors import UsageError, UsageWarning
from jiracli.utils import get_text_from_editor, print_output
@six.add_metaclass(ABCMeta)
class Command(object):
def __init__(self, jira, args):
self.args = args
self.jira = jira
@abstractmethod
def eval(self):
raise NotImplementedError
def execute(self):
return self.eval()
class ViewCommand(Command):
def eval(self):
if self.args.oneline:
mode = -1
elif self.args.verbosity > 1:
mode = self.args.verbosity
else:
mode = 0
if self.args.search_freetext:
issues = self.jira.search_issues(self.args.search_freetext, project = self.args.project)
elif self.args.search_jql:
issues = self.jira.search_issues_jql(self.args.search_jql)
elif self.args.filter:
issues = self.jira.get_issues_by_filter(*self.args.filter)
else:
issues = filter(lambda issue:issue is not None, [self.jira.get_issue(jira.upper()) for jira in self.args.jira_ids])
for issue in issues:
print_output(self.jira.format_issue(
issue,
mode=mode,
formatter=self.args.format,
comments_only=self.args.comments_only,
last_comment=self.args.last_comment,
num_comments=self.args.num_comments
))
class ListCommand(Command):
def eval(self):
mappers = {
"issue_types": (self.jira.get_issue_types,),
'subtask_types': (self.jira.get_subtask_issue_types,),
'projects': (self.jira.get_projects,),
'priorities': (self.jira.get_priorities,),
'statuses': (self.jira.get_statuses,),
'resolutions': (self.jira.get_resolutions,),
'components': (self.jira.get_components, 'project'),
'transitions': (self.jira.get_available_transitions, 'issue'),
'filters': (self.jira.get_filters,)
}
func, arguments = mappers[self.args.type][0], mappers[self.args.type][1:]
_ = []
_k = {}
for earg in arguments:
if isinstance(earg, tuple):
if getattr(self.args, earg[0]):
_k.update({earg[0]: getattr(self.args, earg[0])})
else:
_k[earg[0]] = earg[1]
else:
if not getattr(self.args, earg):
raise UsageError("'--%s' is required for listing '%s'" % (earg, self.args.type))
_.append(getattr(self.args, earg))
found = False
data = func(*_, **_k)
data_dict = {}
if type(data) == type([]):
for item in data:
data_dict[item['name']] = item
else:
data_dict = data
for item in data_dict.values():
found = True
val = item
if type(item) == type({}):
val = colorfunc(item['name'], 'white')
if 'key' in item and item['key']:
val += " [" + colorfunc(item['key'], 'magenta') + "]"
if 'description' in item and item['description']:
val += " [" + colorfunc(item['description'], 'green') + "]"
print_output(colorfunc(val, 'white'))
if not found:
raise UsageWarning("No %s found." % self.args.type)
class UpdateCommand(Command):
def eval(self):
extras = {}
if self.args.extra_fields:
try:
for item in self.args.extra_fields:
key, value = item.split("=")
if key in extras:
if not isinstance(extras[key], list):
v = [extras[key]]
extras[key] = v
extras[key].append(value)
else:
extras[key] = value
except Exception:
raise UsageWarning("Unknown extra fields %s" % (self.args.extra_fields))
self.jira.update_issue(
self.args.issue,
**extras
)
if self.args.issue_comment:
self.jira.add_comment(
self.args.issue, self.args.issue_comment if isinstance(self.args.issue_comment, basestring) else get_text_from_editor()
)
print_output(self.jira.format_issue(self.jira.get_issue(self.args.issue), comments_only=True))
elif self.args.issue_priority:
self.jira.update_issue(
self.args.issue,
priority=self.jira.get_priorities()[self.args.issue_priority]["id"]
)
elif self.args.issue_components:
components = dict(
(k["name"], k["id"]) for k in self.jira.get_components(
self.args.issue.split("-")[0]
)
)
current_components = set(k["name"] for k in self.jira.get_issue(self.args.issue)["components"])
if not set(self.args.issue_components).issubset(current_components):
new_components = current_components.union(self.args.issue_components)
self.jira.update_issue(self.args.issue,
components=[components[k] for k in new_components]
)
print_output(colorfunc(
'component(s): %s added to %s' % (
",".join(self.args.issue_components), self.args.issue), 'green'
))
else:
raise UsageWarning("component(s):[%s] already exist in %s" % (
",".join(self.args.issue_components), self.args.issue)
)
elif self.args.issue_transition:
self.jira.transition_issue(self.args.issue, self.args.issue_transition.lower())
print_output(colorfunc(
'%s transitioned to "%s"' % (self.args.issue, self.args.issue_transition), 'green'
))
elif self.args.issue_assignee:
self.jira.assign_issue(self.args.issue, self.args.issue_assignee)
print_output(colorfunc(
'%s assigned to %s' % (self.args.issue, self.args.issue_assignee), 'green'
))
elif self.args.labels:
self.jira.add_labels(self.args.issue, self.args.labels, True)
print_output(colorfunc(
'%s labelled with %s' % (self.args.issue, ",".join(self.args.labels)), 'green'
))
if self.args.affects_version:
self.jira.add_versions(self.args.issue, self.args.affects_version,'affects')
print_output(colorfunc(
'Added affected version(s) %s to %s' % (",".join(self.args.affects_version), self.args.issue), 'green'
))
if self.args.remove_affects_version:
self.jira.remove_versions(self.args.issue, self.args.remove_affects_version,'affects')
print_output(colorfunc(
'Removed affected version(s) %s from %s' % (",".join(self.args.remove_affects_version), self.args.issue), 'blue'
))
if self.args.fix_version:
self.jira.add_versions(self.args.issue, self.args.fix_version,'fix')
print_output(colorfunc(
'Added fixed version(s) %s to %s' % (",".join(self.args.fix_version), self.args.issue), 'green'
))
if self.args.remove_fix_version:
self.jira.remove_versions(self.args.issue, self.args.remove_fix_version,'fix')
print_output(colorfunc(
'Removed fixed version(s) %s from %s' % (",".join(self.args.remove_fix_version), self.args.issue), 'blue'
))
class AddCommand(Command):
def eval(self):
if not self.args.issue_project:
raise UsageError('project must be specified when creating an issue')
if not (self.args.issue_parent or self.args.issue_type):
self.args.issue_type = 'bug'
if self.args.issue_type and not self.args.issue_type.lower() in self.jira.get_issue_types().keys() + self.jira.get_subtask_issue_types().keys():
raise UsageError(
"invalid issue type: %s (try using jira-cli "
"list issue_types or jira-cli list subtask_types)" % self.args.issue_type
)
if self.args.issue_parent:
if not self.args.issue_type:
self.args.issue_type = 'sub-task'
if not self.args.issue_type in self.jira.get_subtask_issue_types():
raise UsageError(
"issues created with parents must be one of {%s}" % ",".join(self.jira.get_subtask_issue_types())
)
components = {}
if self.args.issue_components:
valid_components = dict(
(k["name"], k["id"]) for k in self.jira.get_components(
self.args.issue_project
)
)
if not set(self.args.issue_components).issubset(valid_components):
raise UsageError(
"components for project %s should be one of {%s}" % (
self.args.issue_project, ",".join(valid_components)
)
)
else:
components = {k: valid_components[k] for k in self.args.issue_components}
description = self.args.issue_description or get_text_from_editor()
print_output(self.jira.format_issue(
self.jira.create_issue(self.args.issue_project, self.args.issue_type, self.args.title, description,
self.args.issue_priority, self.args.issue_parent, self.args.issue_assignee,
self.args.issue_reporter, self.args.labels, components)
))
|
mit
|
[
624,
199,
199,
624,
199,
504,
13022,
492,
29565,
12,
9006,
765,
199,
199,
646,
3816,
199,
199,
504,
1335,
20936,
2764,
14,
2764,
492,
3164,
1532,
199,
504,
1335,
20936,
2764,
14,
2550,
492,
11028,
547,
12,
11028,
3849,
199,
504,
1335,
20936,
2764,
14,
1208,
492,
664,
63,
505,
63,
504,
63,
7515,
12,
870,
63,
1199,
421,
199,
32,
4174,
14,
525,
63,
6577,
8,
22254,
9,
199,
533,
5817,
8,
785,
304,
272,
347,
636,
826,
721,
277,
12,
1335,
20936,
12,
1249,
304,
267,
291,
14,
589,
275,
1249,
267,
291,
14,
28097,
275,
1335,
20936,
272,
768,
10315,
272,
347,
3468,
8,
277,
304,
267,
746,
4279,
339,
347,
5341,
8,
277,
304,
267,
372,
291,
14,
2579,
342,
199,
199,
533,
10935,
3110,
8,
3110,
304,
272,
347,
3468,
8,
277,
304,
267,
340,
291,
14,
589,
14,
265,
32347,
26,
288,
818,
275,
446,
17,
267,
916,
291,
14,
589,
14,
9833,
690,
413,
26,
288,
818,
275,
291,
14,
589,
14,
9833,
267,
587,
26,
288,
818,
275,
378,
267,
340,
291,
14,
589,
14,
1733,
63,
4624,
505,
26,
288,
10876,
275,
291,
14,
28097,
14,
1733,
63,
10115,
8,
277,
14,
589,
14,
1733,
63,
4624,
505,
12,
2199,
275,
291,
14,
589,
14,
1715,
9,
267,
916,
291,
14,
589,
14,
1733,
63,
74,
1710,
26,
288,
10876,
275,
291,
14,
28097,
14,
1733,
63,
10115,
63,
74,
1710,
8,
277,
14,
589,
14,
1733,
63,
74,
1710,
9,
267,
916,
291,
14,
589,
14,
1541,
26,
288,
10876,
275,
291,
14,
28097,
14,
362,
63,
10115,
63,
991,
63,
1541,
2031,
277,
14,
589,
14,
1541,
9,
267,
587,
26,
288,
10876,
275,
2457,
8,
2734,
4976,
26,
5237,
365,
440,
488,
12,
359,
277,
14,
28097,
14,
362,
63,
5237,
8,
28097,
14,
4142,
1012,
367,
1335,
20936,
315,
291,
14,
589,
14,
28097,
63,
1580,
566,
398,
367,
4976,
315,
10876,
26,
288,
870,
63,
1199,
8,
277,
14,
28097,
14,
908,
63,
5237,
8,
355,
4976,
12,
355,
818,
29,
632,
12,
355,
9698,
29,
277,
14,
589,
14,
908,
12,
355,
6786,
63,
2118,
29,
277,
14,
589,
14,
6223,
63,
2118,
12,
355,
2061,
63,
3349,
29,
277,
14,
589,
14,
2019,
63,
3349,
12,
355,
1967,
63,
6223,
29,
277,
14,
589,
14,
1507,
63,
6223,
288,
5082,
199,
199,
533,
3820,
3110,
8,
3110,
304,
272,
347,
3468,
8,
277,
304,
267,
7796,
83,
275,
469,
288,
298,
5237,
63,
1313,
582,
334,
277,
14,
28097,
14,
362,
63,
5237,
63,
1313,
4706,
288,
283,
31719,
63,
1313,
356,
334,
277,
14,
28097,
14,
362,
63,
31719,
63,
5237,
63,
1313,
4706,
288,
283,
6776,
356,
334,
277,
14,
28097,
14,
362,
63,
6776,
4706,
288,
283,
13775,
12107,
356,
334,
277,
14,
28097,
14,
362,
63,
13775,
12107,
4706,
288,
283,
17084,
356,
334,
277,
14,
28097,
14,
362,
63,
17084,
4706,
288,
283,
26702,
8653,
356,
334,
277,
14,
28097,
14,
362,
63,
26702,
8653,
4706,
288,
283,
4608,
356,
334,
277,
14,
28097,
14,
362,
63,
4608,
12,
283,
1715,
659,
288,
283,
23062,
356,
334,
277,
14,
28097,
14,
362,
63,
4561,
63,
23062,
12,
283,
5237,
659,
288,
283,
4273,
356,
334,
277,
14,
28097,
14,
362,
63,
4273,
4258,
267,
789,
267,
2562,
12,
2368,
275,
7796,
83,
59,
277,
14,
589,
14,
466,
1527,
16,
467,
7796,
83,
59,
277,
14,
589,
14,
466,
1527,
17,
2938,
267,
485,
275,
942,
267,
485,
75,
275,
1052,
267,
367,
325,
1273,
315,
2368,
26,
288,
340,
1228,
8,
69,
1273,
12,
2008,
304,
355,
340,
2519,
8,
277,
14,
589,
12,
325,
1273,
59,
16,
4682,
490,
485,
75,
14,
873,
2561,
69,
1273,
59,
16,
2189,
2519,
8,
277,
14,
589,
12,
325,
1273,
59,
16,
566,
1552,
355,
587,
26,
490,
485,
75,
59,
69,
1273,
59,
16,
2677,
275,
325,
1273,
59,
17,
61,
288,
587,
26,
355,
340,
440,
2519,
8,
277,
14,
589,
12,
325,
1273,
304,
490,
746,
11028,
547,
15587,
306,
5,
83,
7,
365,
1415,
367,
13778,
1543,
83,
4065,
450,
334,
69,
1273,
12,
291,
14,
589,
14,
466,
430,
355,
485,
14,
740,
8,
5675,
8,
277,
14,
589,
12,
325,
1273,
430,
267,
1911,
275,
756,
267,
666,
275,
2562,
2031,
3131,
29666,
75,
9,
267,
666,
63,
807,
275,
1052,
267,
340,
730,
8,
576,
9,
508,
730,
779,
4682,
288,
367,
1242,
315,
666,
26,
355,
666,
63,
807,
59,
1053,
459,
354,
6538,
275,
1242,
267,
587,
26,
288,
666,
63,
807,
275,
666,
267,
367,
1242,
315,
666,
63,
807,
14,
1459,
837,
288,
1911,
275,
715,
288,
1139,
275,
1242,
288,
340,
730,
8,
1053,
9,
508,
730,
24692,
304,
355,
1139,
275,
3164,
1532,
8,
1053,
459,
354,
995,
283,
7510,
358,
355,
340,
283,
498,
7,
315,
1242,
436,
1242,
459,
498,
2565,
490,
1139,
847,
298,
2097,
435,
3164,
1532,
8,
1053,
459,
498,
995,
283,
5615,
21335,
358,
435,
298,
8480,
355,
340,
283,
1802,
7,
315,
1242,
436,
1242,
459,
1802,
2565,
490,
1139,
847,
298,
2097,
435,
3164,
1532,
8,
1053,
459,
1802,
995,
283,
7731,
358,
435,
298,
8480,
288,
870,
63,
1199,
8,
2326,
1532,
8,
637,
12,
283,
7510,
1333,
267,
340,
440,
1911,
26,
288,
746,
11028,
3849,
480,
1944,
450,
83,
1911,
2122,
450,
291,
14,
589,
14,
466,
9,
199,
199,
533,
6162,
3110,
8,
3110,
304,
272,
347,
3468,
8,
277,
304,
267,
13751,
275,
1052,
267,
340,
291,
14,
589,
14,
2911,
63,
955,
26,
288,
862,
26,
355,
367,
1242,
315,
291,
14,
589,
14,
2911,
63,
955,
26,
490,
790,
12,
574,
275,
1242,
14,
1294,
480,
23758,
490,
340,
790,
315,
13751,
26,
717,
340,
440,
1228,
8,
9975,
59,
498,
467,
769,
304,
1169,
373,
275,
359,
9975,
59,
498,
2677,
1169,
13751,
59,
498,
61,
275,
373,
717,
13751,
59,
498,
1055,
740,
8,
585,
9,
490,
587,
26,
717,
13751,
59,
498,
61,
275,
574,
288,
871,
2186,
26,
355,
746,
11028
] |
[
199,
199,
624,
199,
504,
13022,
492,
29565,
12,
9006,
765,
199,
199,
646,
3816,
199,
199,
504,
1335,
20936,
2764,
14,
2764,
492,
3164,
1532,
199,
504,
1335,
20936,
2764,
14,
2550,
492,
11028,
547,
12,
11028,
3849,
199,
504,
1335,
20936,
2764,
14,
1208,
492,
664,
63,
505,
63,
504,
63,
7515,
12,
870,
63,
1199,
421,
199,
32,
4174,
14,
525,
63,
6577,
8,
22254,
9,
199,
533,
5817,
8,
785,
304,
272,
347,
636,
826,
721,
277,
12,
1335,
20936,
12,
1249,
304,
267,
291,
14,
589,
275,
1249,
267,
291,
14,
28097,
275,
1335,
20936,
272,
768,
10315,
272,
347,
3468,
8,
277,
304,
267,
746,
4279,
339,
347,
5341,
8,
277,
304,
267,
372,
291,
14,
2579,
342,
199,
199,
533,
10935,
3110,
8,
3110,
304,
272,
347,
3468,
8,
277,
304,
267,
340,
291,
14,
589,
14,
265,
32347,
26,
288,
818,
275,
446,
17,
267,
916,
291,
14,
589,
14,
9833,
690,
413,
26,
288,
818,
275,
291,
14,
589,
14,
9833,
267,
587,
26,
288,
818,
275,
378,
267,
340,
291,
14,
589,
14,
1733,
63,
4624,
505,
26,
288,
10876,
275,
291,
14,
28097,
14,
1733,
63,
10115,
8,
277,
14,
589,
14,
1733,
63,
4624,
505,
12,
2199,
275,
291,
14,
589,
14,
1715,
9,
267,
916,
291,
14,
589,
14,
1733,
63,
74,
1710,
26,
288,
10876,
275,
291,
14,
28097,
14,
1733,
63,
10115,
63,
74,
1710,
8,
277,
14,
589,
14,
1733,
63,
74,
1710,
9,
267,
916,
291,
14,
589,
14,
1541,
26,
288,
10876,
275,
291,
14,
28097,
14,
362,
63,
10115,
63,
991,
63,
1541,
2031,
277,
14,
589,
14,
1541,
9,
267,
587,
26,
288,
10876,
275,
2457,
8,
2734,
4976,
26,
5237,
365,
440,
488,
12,
359,
277,
14,
28097,
14,
362,
63,
5237,
8,
28097,
14,
4142,
1012,
367,
1335,
20936,
315,
291,
14,
589,
14,
28097,
63,
1580,
566,
398,
367,
4976,
315,
10876,
26,
288,
870,
63,
1199,
8,
277,
14,
28097,
14,
908,
63,
5237,
8,
355,
4976,
12,
355,
818,
29,
632,
12,
355,
9698,
29,
277,
14,
589,
14,
908,
12,
355,
6786,
63,
2118,
29,
277,
14,
589,
14,
6223,
63,
2118,
12,
355,
2061,
63,
3349,
29,
277,
14,
589,
14,
2019,
63,
3349,
12,
355,
1967,
63,
6223,
29,
277,
14,
589,
14,
1507,
63,
6223,
288,
5082,
199,
199,
533,
3820,
3110,
8,
3110,
304,
272,
347,
3468,
8,
277,
304,
267,
7796,
83,
275,
469,
288,
298,
5237,
63,
1313,
582,
334,
277,
14,
28097,
14,
362,
63,
5237,
63,
1313,
4706,
288,
283,
31719,
63,
1313,
356,
334,
277,
14,
28097,
14,
362,
63,
31719,
63,
5237,
63,
1313,
4706,
288,
283,
6776,
356,
334,
277,
14,
28097,
14,
362,
63,
6776,
4706,
288,
283,
13775,
12107,
356,
334,
277,
14,
28097,
14,
362,
63,
13775,
12107,
4706,
288,
283,
17084,
356,
334,
277,
14,
28097,
14,
362,
63,
17084,
4706,
288,
283,
26702,
8653,
356,
334,
277,
14,
28097,
14,
362,
63,
26702,
8653,
4706,
288,
283,
4608,
356,
334,
277,
14,
28097,
14,
362,
63,
4608,
12,
283,
1715,
659,
288,
283,
23062,
356,
334,
277,
14,
28097,
14,
362,
63,
4561,
63,
23062,
12,
283,
5237,
659,
288,
283,
4273,
356,
334,
277,
14,
28097,
14,
362,
63,
4273,
4258,
267,
789,
267,
2562,
12,
2368,
275,
7796,
83,
59,
277,
14,
589,
14,
466,
1527,
16,
467,
7796,
83,
59,
277,
14,
589,
14,
466,
1527,
17,
2938,
267,
485,
275,
942,
267,
485,
75,
275,
1052,
267,
367,
325,
1273,
315,
2368,
26,
288,
340,
1228,
8,
69,
1273,
12,
2008,
304,
355,
340,
2519,
8,
277,
14,
589,
12,
325,
1273,
59,
16,
4682,
490,
485,
75,
14,
873,
2561,
69,
1273,
59,
16,
2189,
2519,
8,
277,
14,
589,
12,
325,
1273,
59,
16,
566,
1552,
355,
587,
26,
490,
485,
75,
59,
69,
1273,
59,
16,
2677,
275,
325,
1273,
59,
17,
61,
288,
587,
26,
355,
340,
440,
2519,
8,
277,
14,
589,
12,
325,
1273,
304,
490,
746,
11028,
547,
15587,
306,
5,
83,
7,
365,
1415,
367,
13778,
1543,
83,
4065,
450,
334,
69,
1273,
12,
291,
14,
589,
14,
466,
430,
355,
485,
14,
740,
8,
5675,
8,
277,
14,
589,
12,
325,
1273,
430,
267,
1911,
275,
756,
267,
666,
275,
2562,
2031,
3131,
29666,
75,
9,
267,
666,
63,
807,
275,
1052,
267,
340,
730,
8,
576,
9,
508,
730,
779,
4682,
288,
367,
1242,
315,
666,
26,
355,
666,
63,
807,
59,
1053,
459,
354,
6538,
275,
1242,
267,
587,
26,
288,
666,
63,
807,
275,
666,
267,
367,
1242,
315,
666,
63,
807,
14,
1459,
837,
288,
1911,
275,
715,
288,
1139,
275,
1242,
288,
340,
730,
8,
1053,
9,
508,
730,
24692,
304,
355,
1139,
275,
3164,
1532,
8,
1053,
459,
354,
995,
283,
7510,
358,
355,
340,
283,
498,
7,
315,
1242,
436,
1242,
459,
498,
2565,
490,
1139,
847,
298,
2097,
435,
3164,
1532,
8,
1053,
459,
498,
995,
283,
5615,
21335,
358,
435,
298,
8480,
355,
340,
283,
1802,
7,
315,
1242,
436,
1242,
459,
1802,
2565,
490,
1139,
847,
298,
2097,
435,
3164,
1532,
8,
1053,
459,
1802,
995,
283,
7731,
358,
435,
298,
8480,
288,
870,
63,
1199,
8,
2326,
1532,
8,
637,
12,
283,
7510,
1333,
267,
340,
440,
1911,
26,
288,
746,
11028,
3849,
480,
1944,
450,
83,
1911,
2122,
450,
291,
14,
589,
14,
466,
9,
199,
199,
533,
6162,
3110,
8,
3110,
304,
272,
347,
3468,
8,
277,
304,
267,
13751,
275,
1052,
267,
340,
291,
14,
589,
14,
2911,
63,
955,
26,
288,
862,
26,
355,
367,
1242,
315,
291,
14,
589,
14,
2911,
63,
955,
26,
490,
790,
12,
574,
275,
1242,
14,
1294,
480,
23758,
490,
340,
790,
315,
13751,
26,
717,
340,
440,
1228,
8,
9975,
59,
498,
467,
769,
304,
1169,
373,
275,
359,
9975,
59,
498,
2677,
1169,
13751,
59,
498,
61,
275,
373,
717,
13751,
59,
498,
1055,
740,
8,
585,
9,
490,
587,
26,
717,
13751,
59,
498,
61,
275,
574,
288,
871,
2186,
26,
355,
746,
11028,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
mirsys/amlogic_kernel
|
tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/Util.py
|
12527
|
1935
|
# Util.py - Python extension for perf script, miscellaneous utility code
#
# Copyright (C) 2010 by Tom Zanussi <tzanussi@gmail.com>
#
# This software may be distributed under the terms of the GNU General
# Public License ("GPL") version 2 as published by the Free Software
# Foundation.
import errno, os
FUTEX_WAIT = 0
FUTEX_WAKE = 1
FUTEX_PRIVATE_FLAG = 128
FUTEX_CLOCK_REALTIME = 256
FUTEX_CMD_MASK = ~(FUTEX_PRIVATE_FLAG | FUTEX_CLOCK_REALTIME)
NSECS_PER_SEC = 1000000000
def avg(total, n):
return total / n
def nsecs(secs, nsecs):
return secs * NSECS_PER_SEC + nsecs
def nsecs_secs(nsecs):
return nsecs / NSECS_PER_SEC
def nsecs_nsecs(nsecs):
return nsecs % NSECS_PER_SEC
def nsecs_str(nsecs):
str = "%5u.%09u" % (nsecs_secs(nsecs), nsecs_nsecs(nsecs)),
return str
def add_stats(dict, key, value):
if not dict.has_key(key):
dict[key] = (value, value, value, 1)
else:
min, max, avg, count = dict[key]
if value < min:
min = value
if value > max:
max = value
avg = (avg + value) / 2
dict[key] = (min, max, avg, count + 1)
def clear_term():
print("\x1b[H\x1b[2J")
audit_package_warned = False
try:
import audit
machine_to_id = {
'x86_64': audit.MACH_86_64,
'alpha' : audit.MACH_ALPHA,
'ia64' : audit.MACH_IA64,
'ppc' : audit.MACH_PPC,
'ppc64' : audit.MACH_PPC64,
's390' : audit.MACH_S390,
's390x' : audit.MACH_S390X,
'i386' : audit.MACH_X86,
'i586' : audit.MACH_X86,
'i686' : audit.MACH_X86,
}
try:
machine_to_id['armeb'] = audit.MACH_ARMEB
except:
pass
machine_id = machine_to_id[os.uname()[4]]
except:
if not audit_package_warned:
audit_package_warned = True
print "Install the audit-libs-python package to get syscall names"
def syscall_name(id):
try:
return audit.audit_syscall_to_name(id, machine_id)
except:
return str(id)
def strerror(nr):
try:
return errno.errorcode[abs(nr)]
except:
return "Unknown %d errno" % nr
|
gpl-2.0
|
[
3,
21248,
14,
647,
446,
2018,
3329,
367,
8582,
2884,
12,
3201,
19549,
11420,
1233,
199,
3,
199,
3,
1898,
334,
35,
9,
7129,
701,
21644,
29385,
665,
29453,
32,
6799,
14,
957,
30,
199,
3,
199,
3,
961,
2032,
1443,
506,
1854,
1334,
314,
2895,
402,
314,
1664,
1696,
199,
3,
1684,
844,
1689,
12006,
531,
1015,
499,
465,
3267,
701,
314,
2868,
2290,
199,
3,
2752,
14,
199,
199,
646,
7554,
12,
747,
199,
199,
31179,
63,
12458,
275,
378,
199,
31179,
63,
9004,
2430,
275,
413,
199,
31179,
63,
18748,
63,
3719,
275,
7960,
199,
31179,
63,
30690,
63,
15508,
4961,
275,
7633,
199,
31179,
63,
9744,
63,
12880,
275,
6146,
8,
31179,
63,
18748,
63,
3719,
1204,
481,
934,
1438,
63,
30690,
63,
15508,
4961,
9,
199,
199,
46,
28466,
63,
4227,
63,
15048,
259,
275,
413,
25464,
199,
199,
318,
12402,
8,
2923,
12,
302,
304,
272,
372,
3141,
1182,
302,
199,
199,
318,
13781,
8,
4855,
12,
13781,
304,
272,
372,
20091,
627,
653,
28466,
63,
4227,
63,
15048,
435,
13781,
199,
199,
318,
13781,
63,
4855,
8,
9618,
304,
272,
372,
13781,
1182,
653,
28466,
63,
4227,
63,
15048,
199,
199,
318,
13781,
63,
9618,
8,
9618,
304,
272,
372,
13781,
450,
653,
28466,
63,
4227,
63,
15048,
199,
199,
318,
13781,
63,
495,
8,
9618,
304,
272,
620,
275,
2071,
21,
85,
4111,
1643,
85,
2,
450,
334,
9618,
63,
4855,
8,
9618,
395,
13781,
63,
9618,
8,
9618,
1826,
272,
372,
620,
199,
199,
318,
1050,
63,
3200,
8,
807,
12,
790,
12,
574,
304,
199,
198,
692,
440,
1211,
14,
1989,
63,
498,
8,
498,
304,
507,
198,
807,
59,
498,
61,
275,
334,
585,
12,
574,
12,
574,
12,
413,
9,
199,
198,
2836,
26,
507,
198,
827,
12,
1390,
12,
12402,
12,
2338,
275,
1211,
59,
498,
61,
507,
198,
692,
574,
665,
1748,
26,
686,
198,
827,
275,
574,
507,
198,
692,
574,
690,
1390,
26,
686,
198,
988,
275,
574,
507,
198,
8595,
275,
334,
8595,
435,
574,
9,
1182,
499,
507,
198,
807,
59,
498,
61,
275,
334,
827,
12,
1390,
12,
12402,
12,
2338,
435,
413,
9,
199,
199,
318,
5436,
63,
5125,
837,
272,
870,
4582,
88,
17,
66,
59,
40,
60,
88,
17,
66,
59,
18,
42,
531,
199,
199,
14274,
63,
2491,
63,
4050,
379,
275,
756,
199,
199,
893,
26,
199,
198,
646,
13968,
199,
198,
6744,
63,
475,
63,
344,
275,
469,
507,
198,
7,
88,
1184,
63,
772,
356,
13968,
14,
13802,
63,
1184,
63,
772,
12,
507,
198,
7,
4468,
7,
198,
26,
13968,
14,
13802,
63,
18554,
12,
507,
198,
7,
4674,
772,
7,
198,
26,
13968,
14,
13802,
63,
13033,
772,
12,
507,
198,
7,
20638,
7,
198,
26,
13968,
14,
13802,
63,
48,
4222,
12,
507,
198,
7,
20638,
772,
7,
198,
26,
13968,
14,
13802,
63,
48,
4222,
772,
12,
507,
198,
1159,
12302,
7,
198,
26,
13968,
14,
13802,
63,
51,
12302,
12,
507,
198,
1159,
12302,
88,
7,
198,
26,
13968,
14,
13802,
63,
51,
12302,
56,
12,
507,
198,
7,
73,
8040,
7,
198,
26,
13968,
14,
13802,
63,
56,
1184,
12,
507,
198,
7,
73,
26888,
7,
198,
26,
13968,
14,
13802,
63,
56,
1184,
12,
507,
198,
7,
73,
10253,
7,
198,
26,
13968,
14,
13802,
63,
56,
1184,
12,
199,
198,
93,
199,
198,
893,
26,
507,
198,
6744,
63,
475,
63,
344,
459,
285,
278,
66,
418,
275,
13968,
14,
13802,
63,
689,
3635,
34,
199,
198,
2590,
26,
507,
198,
1529,
199,
198,
6744,
63,
344,
275,
6844,
63,
475,
63,
344,
59,
736,
14,
16040,
3430,
20,
2677,
199,
2590,
26,
199,
198,
692,
440,
13968,
63,
2491,
63,
4050,
379,
26,
507,
198,
14274,
63,
2491,
63,
4050,
379,
275,
715,
507,
198,
1361,
298,
8154,
314,
13968,
13,
8450,
13,
1548,
2559,
370,
664,
18901,
1561,
2,
199,
199,
318,
18901,
63,
354,
8,
344,
304,
199,
198,
893,
26,
507,
198,
1107,
13968,
14,
14274,
63,
19444,
63,
475,
63,
354,
8,
344,
12,
6844,
63,
344,
9,
199,
198,
2590,
26,
507,
198,
1107,
620,
8,
344,
9,
199,
199,
318,
410,
17844,
8,
7865,
304,
199,
198,
893,
26,
507,
198,
1107,
7554,
14,
28857,
59,
2101,
8,
7865,
1874,
199,
198,
2590,
26,
507,
198,
1107,
298,
5912,
450,
68,
7554,
2,
450,
14762,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
21248,
14,
647,
446,
2018,
3329,
367,
8582,
2884,
12,
3201,
19549,
11420,
1233,
199,
3,
199,
3,
1898,
334,
35,
9,
7129,
701,
21644,
29385,
665,
29453,
32,
6799,
14,
957,
30,
199,
3,
199,
3,
961,
2032,
1443,
506,
1854,
1334,
314,
2895,
402,
314,
1664,
1696,
199,
3,
1684,
844,
1689,
12006,
531,
1015,
499,
465,
3267,
701,
314,
2868,
2290,
199,
3,
2752,
14,
199,
199,
646,
7554,
12,
747,
199,
199,
31179,
63,
12458,
275,
378,
199,
31179,
63,
9004,
2430,
275,
413,
199,
31179,
63,
18748,
63,
3719,
275,
7960,
199,
31179,
63,
30690,
63,
15508,
4961,
275,
7633,
199,
31179,
63,
9744,
63,
12880,
275,
6146,
8,
31179,
63,
18748,
63,
3719,
1204,
481,
934,
1438,
63,
30690,
63,
15508,
4961,
9,
199,
199,
46,
28466,
63,
4227,
63,
15048,
259,
275,
413,
25464,
199,
199,
318,
12402,
8,
2923,
12,
302,
304,
272,
372,
3141,
1182,
302,
199,
199,
318,
13781,
8,
4855,
12,
13781,
304,
272,
372,
20091,
627,
653,
28466,
63,
4227,
63,
15048,
435,
13781,
199,
199,
318,
13781,
63,
4855,
8,
9618,
304,
272,
372,
13781,
1182,
653,
28466,
63,
4227,
63,
15048,
199,
199,
318,
13781,
63,
9618,
8,
9618,
304,
272,
372,
13781,
450,
653,
28466,
63,
4227,
63,
15048,
199,
199,
318,
13781,
63,
495,
8,
9618,
304,
272,
620,
275,
2071,
21,
85,
4111,
1643,
85,
2,
450,
334,
9618,
63,
4855,
8,
9618,
395,
13781,
63,
9618,
8,
9618,
1826,
272,
372,
620,
199,
199,
318,
1050,
63,
3200,
8,
807,
12,
790,
12,
574,
304,
199,
198,
692,
440,
1211,
14,
1989,
63,
498,
8,
498,
304,
507,
198,
807,
59,
498,
61,
275,
334,
585,
12,
574,
12,
574,
12,
413,
9,
199,
198,
2836,
26,
507,
198,
827,
12,
1390,
12,
12402,
12,
2338,
275,
1211,
59,
498,
61,
507,
198,
692,
574,
665,
1748,
26,
686,
198,
827,
275,
574,
507,
198,
692,
574,
690,
1390,
26,
686,
198,
988,
275,
574,
507,
198,
8595,
275,
334,
8595,
435,
574,
9,
1182,
499,
507,
198,
807,
59,
498,
61,
275,
334,
827,
12,
1390,
12,
12402,
12,
2338,
435,
413,
9,
199,
199,
318,
5436,
63,
5125,
837,
272,
870,
4582,
88,
17,
66,
59,
40,
60,
88,
17,
66,
59,
18,
42,
531,
199,
199,
14274,
63,
2491,
63,
4050,
379,
275,
756,
199,
199,
893,
26,
199,
198,
646,
13968,
199,
198,
6744,
63,
475,
63,
344,
275,
469,
507,
198,
7,
88,
1184,
63,
772,
356,
13968,
14,
13802,
63,
1184,
63,
772,
12,
507,
198,
7,
4468,
7,
198,
26,
13968,
14,
13802,
63,
18554,
12,
507,
198,
7,
4674,
772,
7,
198,
26,
13968,
14,
13802,
63,
13033,
772,
12,
507,
198,
7,
20638,
7,
198,
26,
13968,
14,
13802,
63,
48,
4222,
12,
507,
198,
7,
20638,
772,
7,
198,
26,
13968,
14,
13802,
63,
48,
4222,
772,
12,
507,
198,
1159,
12302,
7,
198,
26,
13968,
14,
13802,
63,
51,
12302,
12,
507,
198,
1159,
12302,
88,
7,
198,
26,
13968,
14,
13802,
63,
51,
12302,
56,
12,
507,
198,
7,
73,
8040,
7,
198,
26,
13968,
14,
13802,
63,
56,
1184,
12,
507,
198,
7,
73,
26888,
7,
198,
26,
13968,
14,
13802,
63,
56,
1184,
12,
507,
198,
7,
73,
10253,
7,
198,
26,
13968,
14,
13802,
63,
56,
1184,
12,
199,
198,
93,
199,
198,
893,
26,
507,
198,
6744,
63,
475,
63,
344,
459,
285,
278,
66,
418,
275,
13968,
14,
13802,
63,
689,
3635,
34,
199,
198,
2590,
26,
507,
198,
1529,
199,
198,
6744,
63,
344,
275,
6844,
63,
475,
63,
344,
59,
736,
14,
16040,
3430,
20,
2677,
199,
2590,
26,
199,
198,
692,
440,
13968,
63,
2491,
63,
4050,
379,
26,
507,
198,
14274,
63,
2491,
63,
4050,
379,
275,
715,
507,
198,
1361,
298,
8154,
314,
13968,
13,
8450,
13,
1548,
2559,
370,
664,
18901,
1561,
2,
199,
199,
318,
18901,
63,
354,
8,
344,
304,
199,
198,
893,
26,
507,
198,
1107,
13968,
14,
14274,
63,
19444,
63,
475,
63,
354,
8,
344,
12,
6844,
63,
344,
9,
199,
198,
2590,
26,
507,
198,
1107,
620,
8,
344,
9,
199,
199,
318,
410,
17844,
8,
7865,
304,
199,
198,
893,
26,
507,
198,
1107,
7554,
14,
28857,
59,
2101,
8,
7865,
1874,
199,
198,
2590,
26,
507,
198,
1107,
298,
5912,
450,
68,
7554,
2,
450,
14762,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
poljeff/odoo
|
addons/website_gengo/controllers/main.py
|
350
|
1799
|
# -*- coding: utf-8 -*-
import openerp
from openerp import http, SUPERUSER_ID
from openerp.http import request
import time
GENGO_DEFAULT_LIMIT = 20
class website_gengo(http.Controller):
@http.route('/website/get_translated_length', type='json', auth='user', website=True)
def get_translated_length(self, translated_ids, lang):
ir_translation_obj = request.registry['ir.translation']
result={"done":0}
gengo_translation_ids = ir_translation_obj.search(request.cr, request.uid, [('id','in',translated_ids),('gengo_translation','!=', False)])
for trans in ir_translation_obj.browse(request.cr, request.uid, gengo_translation_ids):
result['done'] += len(trans.source.split())
return result
@http.route('/website/check_gengo_set', type='json', auth='user', website=True)
def check_gengo_set(self):
user = request.registry['res.users'].browse(request.cr, SUPERUSER_ID, request.uid)
company_flag = 0
if not user.company_id.gengo_public_key or not user.company_id.gengo_private_key:
company_flag = user.company_id.id
return company_flag
@http.route('/website/set_gengo_config', type='json', auth='user', website=True)
def set_gengo_config(self,config):
user = request.registry['res.users'].browse(request.cr, request.uid, request.uid)
if user.company_id:
request.registry['res.company'].write(request.cr, request.uid, user.company_id.id, config)
return True
@http.route('/website/post_gengo_jobs', type='json', auth='user', website=True)
def post_gengo_jobs(self):
request.registry['base.gengo.translations']._sync_request(request.cr, request.uid, limit=GENGO_DEFAULT_LIMIT, context=request.context)
return True
|
agpl-3.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
646,
5166,
199,
504,
5166,
492,
1455,
12,
12824,
63,
998,
199,
504,
5166,
14,
1014,
492,
1056,
199,
646,
900,
199,
199,
9289,
13160,
63,
3472,
63,
13387,
275,
3388,
199,
199,
533,
10691,
63,
2268,
1939,
8,
1014,
14,
7506,
304,
339,
768,
1014,
14,
4449,
2336,
7360,
15,
362,
63,
18065,
63,
1267,
297,
730,
534,
1001,
297,
1790,
534,
751,
297,
10691,
29,
549,
9,
272,
347,
664,
63,
18065,
63,
1267,
8,
277,
12,
14598,
63,
1580,
12,
6339,
304,
267,
8190,
63,
6893,
63,
1113,
275,
1056,
14,
5189,
459,
723,
14,
6893,
418,
267,
754,
8871,
4456,
582,
16,
93,
267,
3805,
1939,
63,
6893,
63,
1580,
275,
8190,
63,
6893,
63,
1113,
14,
1733,
8,
1069,
14,
1556,
12,
1056,
14,
1535,
12,
4274,
344,
1673,
262,
297,
18065,
63,
1580,
11169,
2268,
1939,
63,
6893,
1673,
1111,
297,
756,
3948,
267,
367,
1752,
315,
8190,
63,
6893,
63,
1113,
14,
4570,
8,
1069,
14,
1556,
12,
1056,
14,
1535,
12,
3805,
1939,
63,
6893,
63,
1580,
304,
288,
754,
459,
4456,
418,
847,
822,
8,
1515,
14,
1365,
14,
1294,
1012,
267,
372,
754,
2286,
768,
1014,
14,
4449,
2336,
7360,
15,
1074,
63,
2268,
1939,
63,
409,
297,
730,
534,
1001,
297,
1790,
534,
751,
297,
10691,
29,
549,
9,
272,
347,
1104,
63,
2268,
1939,
63,
409,
8,
277,
304,
267,
922,
275,
1056,
14,
5189,
459,
470,
14,
3707,
2278,
4570,
8,
1069,
14,
1556,
12,
12824,
63,
998,
12,
1056,
14,
1535,
9,
267,
7233,
63,
4173,
275,
378,
267,
340,
440,
922,
14,
4627,
63,
344,
14,
2268,
1939,
63,
3455,
63,
498,
503,
440,
922,
14,
4627,
63,
344,
14,
2268,
1939,
63,
4239,
63,
498,
26,
288,
7233,
63,
4173,
275,
922,
14,
4627,
63,
344,
14,
344,
267,
372,
7233,
63,
4173,
2286,
768,
1014,
14,
4449,
2336,
7360,
15,
409,
63,
2268,
1939,
63,
888,
297,
730,
534,
1001,
297,
1790,
534,
751,
297,
10691,
29,
549,
9,
272,
347,
663,
63,
2268,
1939,
63,
888,
8,
277,
12,
888,
304,
267,
922,
275,
1056,
14,
5189,
459,
470,
14,
3707,
2278,
4570,
8,
1069,
14,
1556,
12,
1056,
14,
1535,
12,
1056,
14,
1535,
9,
267,
340,
922,
14,
4627,
63,
344,
26,
288,
1056,
14,
5189,
459,
470,
14,
4627,
2278,
952,
8,
1069,
14,
1556,
12,
1056,
14,
1535,
12,
922,
14,
4627,
63,
344,
14,
344,
12,
1101,
9,
267,
372,
715,
339,
768,
1014,
14,
4449,
2336,
7360,
15,
1932,
63,
2268,
1939,
63,
6920,
297,
730,
534,
1001,
297,
1790,
534,
751,
297,
10691,
29,
549,
9,
272,
347,
2963,
63,
2268,
1939,
63,
6920,
8,
277,
304,
267,
1056,
14,
5189,
459,
1095,
14,
2268,
1939,
14,
13982,
26099,
5186,
63,
1069,
8,
1069,
14,
1556,
12,
1056,
14,
1535,
12,
2304,
29,
9289,
13160,
63,
3472,
63,
13387,
12,
1067,
29,
1069,
14,
1100,
9,
267,
372,
715,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
646,
5166,
199,
504,
5166,
492,
1455,
12,
12824,
63,
998,
199,
504,
5166,
14,
1014,
492,
1056,
199,
646,
900,
199,
199,
9289,
13160,
63,
3472,
63,
13387,
275,
3388,
199,
199,
533,
10691,
63,
2268,
1939,
8,
1014,
14,
7506,
304,
339,
768,
1014,
14,
4449,
2336,
7360,
15,
362,
63,
18065,
63,
1267,
297,
730,
534,
1001,
297,
1790,
534,
751,
297,
10691,
29,
549,
9,
272,
347,
664,
63,
18065,
63,
1267,
8,
277,
12,
14598,
63,
1580,
12,
6339,
304,
267,
8190,
63,
6893,
63,
1113,
275,
1056,
14,
5189,
459,
723,
14,
6893,
418,
267,
754,
8871,
4456,
582,
16,
93,
267,
3805,
1939,
63,
6893,
63,
1580,
275,
8190,
63,
6893,
63,
1113,
14,
1733,
8,
1069,
14,
1556,
12,
1056,
14,
1535,
12,
4274,
344,
1673,
262,
297,
18065,
63,
1580,
11169,
2268,
1939,
63,
6893,
1673,
1111,
297,
756,
3948,
267,
367,
1752,
315,
8190,
63,
6893,
63,
1113,
14,
4570,
8,
1069,
14,
1556,
12,
1056,
14,
1535,
12,
3805,
1939,
63,
6893,
63,
1580,
304,
288,
754,
459,
4456,
418,
847,
822,
8,
1515,
14,
1365,
14,
1294,
1012,
267,
372,
754,
2286,
768,
1014,
14,
4449,
2336,
7360,
15,
1074,
63,
2268,
1939,
63,
409,
297,
730,
534,
1001,
297,
1790,
534,
751,
297,
10691,
29,
549,
9,
272,
347,
1104,
63,
2268,
1939,
63,
409,
8,
277,
304,
267,
922,
275,
1056,
14,
5189,
459,
470,
14,
3707,
2278,
4570,
8,
1069,
14,
1556,
12,
12824,
63,
998,
12,
1056,
14,
1535,
9,
267,
7233,
63,
4173,
275,
378,
267,
340,
440,
922,
14,
4627,
63,
344,
14,
2268,
1939,
63,
3455,
63,
498,
503,
440,
922,
14,
4627,
63,
344,
14,
2268,
1939,
63,
4239,
63,
498,
26,
288,
7233,
63,
4173,
275,
922,
14,
4627,
63,
344,
14,
344,
267,
372,
7233,
63,
4173,
2286,
768,
1014,
14,
4449,
2336,
7360,
15,
409,
63,
2268,
1939,
63,
888,
297,
730,
534,
1001,
297,
1790,
534,
751,
297,
10691,
29,
549,
9,
272,
347,
663,
63,
2268,
1939,
63,
888,
8,
277,
12,
888,
304,
267,
922,
275,
1056,
14,
5189,
459,
470,
14,
3707,
2278,
4570,
8,
1069,
14,
1556,
12,
1056,
14,
1535,
12,
1056,
14,
1535,
9,
267,
340,
922,
14,
4627,
63,
344,
26,
288,
1056,
14,
5189,
459,
470,
14,
4627,
2278,
952,
8,
1069,
14,
1556,
12,
1056,
14,
1535,
12,
922,
14,
4627,
63,
344,
14,
344,
12,
1101,
9,
267,
372,
715,
339,
768,
1014,
14,
4449,
2336,
7360,
15,
1932,
63,
2268,
1939,
63,
6920,
297,
730,
534,
1001,
297,
1790,
534,
751,
297,
10691,
29,
549,
9,
272,
347,
2963,
63,
2268,
1939,
63,
6920,
8,
277,
304,
267,
1056,
14,
5189,
459,
1095,
14,
2268,
1939,
14,
13982,
26099,
5186,
63,
1069,
8,
1069,
14,
1556,
12,
1056,
14,
1535,
12,
2304,
29,
9289,
13160,
63,
3472,
63,
13387,
12,
1067,
29,
1069,
14,
1100,
9,
267,
372,
715,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
ToonTownInfiniteRepo/ToontownInfinite
|
toontown/toon/NPCFriendPanel.py
|
3
|
9972
|
from direct.gui.DirectGui import *
from direct.directnotify import DirectNotifyGlobal
from pandac.PandaModules import *
import NPCToons
import ToonHead
import ToonDNA
from toontown.toonbase import TTLocalizer
from toontown.toonbase import ToontownGlobals
from toontown.toonbase import ToontownBattleGlobals
from toontown.toon import LaughingManGlobals
class NPCFriendPanel(DirectFrame):
notify = DirectNotifyGlobal.directNotify.newCategory('NPCFriendPanel')
def __init__(self, parent = aspect2d, **kw):
optiondefs = (('relief', None, None), ('doneEvent', None, None))
self.defineoptions(kw, optiondefs)
DirectFrame.__init__(self, parent=parent)
self.cardList = []
self.updateLayout()
self.initialiseoptions(NPCFriendPanel)
self.accept(localAvatar.uniqueName('maxNPCFriendsChange'), self.updateLayout)
return None
def update(self, friendDict, fCallable = 0):
friendList = friendDict.keys()
for i in xrange(self.maxNPCFriends):
card = self.cardList[i]
try:
NPCID = friendList[i]
count = friendDict[NPCID]
except IndexError:
NPCID = None
count = 0
card.update(NPCID, count, fCallable)
return
def updateLayout(self):
for card in self.cardList:
card.destroy()
self.cardList = []
self.maxNPCFriends = localAvatar.getMaxNPCFriends()
rotateCard = False
if self.maxNPCFriends == 8:
rotateCard = True
xOffset = -5.25
yOffset = 2.3
yOffset2 = -4.7
elif self.maxNPCFriends == 16:
xOffset = -5.2
yOffset = 3.5
yOffset2 = -2.45
else:
self.notify.error('got wrong max SOS cards %s' % self.maxNPCFriends)
count = 0
for i in xrange(self.maxNPCFriends):
card = NPCFriendCard(parent=self, rotateCard=rotateCard, doneEvent=self['doneEvent'])
self.cardList.append(card)
card.setPos(xOffset, 1, yOffset)
card.setScale(0.75)
xOffset += 3.5
count += 1
if count % 4 == 0:
xOffset = -5.25
yOffset += yOffset2
class NPCFriendCard(DirectFrame):
normalTextColor = (0.3, 0.25, 0.2, 1)
maxRarity = 5
sosTracks = ToontownBattleGlobals.Tracks + ToontownBattleGlobals.NPCTracks
def __init__(self, parent = aspect2dp, rotateCard = False, **kw):
optiondefs = (('NPCID', 'Uninitialized', None), ('relief', None, None), ('doneEvent', None, None))
self.defineoptions(kw, optiondefs)
DirectFrame.__init__(self, parent=parent)
self.initialiseoptions(NPCFriendCard)
cardModel = loader.loadModel('phase_3.5/models/gui/playingCard')
self.front = DirectFrame(parent=self, relief=None, image=cardModel.find('**/card_front'))
self.front.hide()
self.back = DirectFrame(parent=self, relief=None, image=cardModel.find('**/card_back'), geom=cardModel.find('**/logo'))
callButtonPosZ = -0.9
textWordWrap = 16.0
textScale = 0.35
textPosZ = 1.15
nameScale = 0.4
namePosZ = -0.45
rarityScale = 0.2
rarityPosZ = -1.2
self.NPCHeadDim = 1.2
self.NPCHeadPosZ = 0.45
self.sosCountInfoPosZ = -0.9
self.sosCountInfoScale = 0.4
self.sosCountInfo2PosZ = -0.9
self.sosCountInfo2Scale = 0.5
if rotateCard:
self.front.component('image0').configure(pos=(0, 0, 0.22), hpr=(0, 0, -90), scale=1.35)
self.back.component('image0').configure(hpr=(0, 0, -90), scale=(-1.35, 1.35, 1.35))
callButtonPosZ = -2.1
textWordWrap = 7.0
textScale = 0.5
textPosZ = 2.0
nameScale = 0.5
namePosZ = -0.89
rarityScale = 0.25
rarityPosZ = -2.4
self.NPCHeadDim = 1.8
self.NPCHeadPosZ = 0.4
self.sosCountInfoPosZ = -2.1
self.sosCountInfoScale = 0.4
self.sosCountInfo2PosZ = -2.0
self.sosCountInfo2Scale = 0.55
self.sosTypeInfo = DirectLabel(parent=self.front, relief=None, text='', text_font=ToontownGlobals.getMinnieFont(), text_fg=self.normalTextColor, text_scale=textScale, text_align=TextNode.ACenter, text_wordwrap=textWordWrap, pos=(0, 0, textPosZ))
self.NPCHead = None
self.NPCName = DirectLabel(parent=self.front, relief=None, text='', text_fg=self.normalTextColor, text_scale=nameScale, text_align=TextNode.ACenter, text_wordwrap=8.0, pos=(0, 0, namePosZ))
buttonModels = loader.loadModel('phase_3.5/models/gui/inventory_gui')
upButton = buttonModels.find('**/InventoryButtonUp')
downButton = buttonModels.find('**/InventoryButtonDown')
rolloverButton = buttonModels.find('**/InventoryButtonRollover')
self.sosCallButton = DirectButton(parent=self.front, relief=None, text=TTLocalizer.NPCCallButtonLabel, text_fg=self.normalTextColor, text_scale=0.28, text_align=TextNode.ACenter, image=(upButton,
downButton,
rolloverButton,
upButton), image_color=(1.0, 0.2, 0.2, 1), image0_color=Vec4(1.0, 0.4, 0.4, 1), image3_color=Vec4(1.0, 0.4, 0.4, 0.4), image_scale=(4.4, 1, 3.6), image_pos=Vec3(0, 0, 0.08), pos=(-1.15, 0, callButtonPosZ), scale=1.25, command=self.__chooseNPCFriend)
self.sosCallButton.hide()
self.sosCountInfo = DirectLabel(parent=self.front, relief=None, text='', text_fg=self.normalTextColor, text_scale=0.75, text_align=TextNode.ALeft, textMayChange=1, pos=(0.0, 0, -1.0))
star = loader.loadModel('phase_3.5/models/gui/name_star')
self.rarityStars = []
for i in xrange(self.maxRarity):
label = DirectLabel(parent=self.front, relief=None, image=star, image_scale=rarityScale, image_color=Vec4(0.502, 0.251, 0.251, 1.0), pos=(1.1 - i * 0.24, 0, rarityPosZ))
label.hide()
self.rarityStars.append(label)
return
def __chooseNPCFriend(self):
if self['NPCID'] and self['doneEvent']:
doneStatus = {}
doneStatus['mode'] = 'NPCFriend'
doneStatus['friend'] = self['NPCID']
messenger.send(self['doneEvent'], [doneStatus])
def destroy(self):
if self.NPCHead:
self.NPCHead.detachNode()
self.NPCHead.delete()
DirectFrame.destroy(self)
def update(self, NPCID, count = 0, fCallable = 0):
oldNPCID = self['NPCID']
self['NPCID'] = NPCID
if NPCID != oldNPCID:
if self.NPCHead:
self.NPCHead.detachNode()
self.NPCHead.delete()
if NPCID is None:
self.showBack()
return
self.front.show()
self.back.hide()
self.NPCName['text'] = TTLocalizer.NPCToonNames[NPCID]
self.NPCHead = self.createNPCToonHead(NPCID, dimension=self.NPCHeadDim)
self.NPCHead.reparentTo(self.front)
self.NPCHead.setZ(self.NPCHeadPosZ)
track, level, hp, rarity = NPCToons.getNPCTrackLevelHpRarity(NPCID)
sosText = self.sosTracks[track]
if track == ToontownBattleGlobals.NPC_RESTOCK_GAGS:
if level == -1:
sosText += ' All'
else:
sosText += ' ' + self.sosTracks[level]
sosText = TextEncoder.upper(sosText)
self.sosTypeInfo['text'] = sosText
for i in xrange(self.maxRarity):
if i < rarity:
self.rarityStars[i].show()
else:
self.rarityStars[i].hide()
if fCallable:
self.sosCallButton.show()
self.sosCountInfo.setPos(-0.4, 0, self.sosCountInfoPosZ)
self.sosCountInfo['text_scale'] = self.sosCountInfoScale
self.sosCountInfo['text_align'] = TextNode.ALeft
else:
self.sosCallButton.hide()
self.sosCountInfo.setPos(0, 0, self.sosCountInfo2PosZ)
self.sosCountInfo['text_scale'] = self.sosCountInfo2Scale
self.sosCountInfo['text_align'] = TextNode.ACenter
if count > 0:
countText = TTLocalizer.NPCFriendPanelRemaining % count
self.sosCallButton['state'] = DGG.NORMAL
else:
countText = 'Unavailable'
self.sosCallButton['state'] = DGG.DISABLED
self.sosCountInfo['text'] = countText
return
def showFront(self):
self.front.show()
self.back.hide()
def showBack(self):
self.front.hide()
self.back.show()
def createNPCToonHead(self, NPCID, dimension = 0.5):
NPCInfo = NPCToons.NPCToonDict[NPCID]
dnaList = NPCInfo[2]
gender = NPCInfo[3]
if dnaList == 'r':
dnaList = NPCToons.getRandomDNA(NPCID, gender)
dna = ToonDNA.ToonDNA()
dna.newToonFromProperties(*dnaList)
head = ToonHead.ToonHead()
head.setupHead(dna, forGui=1)
self.fitGeometry(head, fFlip=1, dimension=dimension)
if NPCID == 91917:
LaughingManGlobals.addHeadEffect(head, book=True)
return head
def fitGeometry(self, geom, fFlip = 0, dimension = 0.5):
p1 = Point3()
p2 = Point3()
geom.calcTightBounds(p1, p2)
if fFlip:
t = p1[0]
p1.setX(-p2[0])
p2.setX(-t)
d = p2 - p1
biggest = max(d[0], d[2])
s = dimension / biggest
mid = (p1 + d / 2.0) * s
geomXform = hidden.attachNewNode('geomXform')
for child in geom.getChildren():
child.reparentTo(geomXform)
geomXform.setPosHprScale(-mid[0], -mid[1] + 1, -mid[2], 180, 0, 0, s, s, s)
geomXform.reparentTo(geom)
|
mit
|
[
504,
4125,
14,
5885,
14,
16281,
4324,
492,
627,
199,
504,
4125,
14,
2275,
6814,
492,
21128,
8645,
7025,
199,
504,
299,
460,
645,
14,
48,
18328,
17981,
492,
627,
199,
646,
25413,
1028,
79,
4654,
199,
646,
4005,
265,
11664,
199,
646,
4005,
265,
23372,
199,
504,
370,
265,
16231,
14,
475,
265,
1095,
492,
377,
52,
5339,
1793,
199,
504,
370,
265,
16231,
14,
475,
265,
1095,
492,
4005,
265,
16231,
21675,
199,
504,
370,
265,
16231,
14,
475,
265,
1095,
492,
4005,
265,
16231,
34,
29274,
21675,
199,
504,
370,
265,
16231,
14,
475,
265,
492,
7964,
3080,
316,
2395,
21675,
199,
199,
533,
653,
4222,
38,
8528,
10185,
8,
16281,
3160,
304,
272,
11705,
275,
21128,
8645,
7025,
14,
2275,
8645,
14,
1222,
7841,
360,
46,
4222,
38,
8528,
10185,
358,
339,
347,
636,
826,
721,
277,
12,
1676,
275,
17435,
18,
68,
12,
1011,
829,
304,
267,
945,
8710,
275,
13636,
26557,
2829,
297,
488,
12,
488,
395,
661,
4456,
2390,
297,
488,
12,
488,
430,
267,
291,
14,
4640,
1419,
8,
829,
12,
945,
8710,
9,
267,
21128,
3160,
855,
826,
721,
277,
12,
1676,
29,
1708,
9,
267,
291,
14,
5841,
1296,
275,
942,
267,
291,
14,
873,
4798,
342,
267,
291,
14,
2747,
572,
1419,
8,
46,
4222,
38,
8528,
10185,
9,
267,
291,
14,
5694,
8,
1832,
24916,
14,
3235,
985,
360,
988,
46,
4222,
38,
13010,
4001,
659,
291,
14,
873,
4798,
9,
267,
372,
488,
339,
347,
1678,
8,
277,
12,
32506,
2141,
12,
289,
16410,
275,
378,
304,
267,
32506,
1296,
275,
32506,
2141,
14,
1612,
342,
267,
367,
284,
315,
4945,
8,
277,
14,
988,
46,
4222,
38,
13010,
304,
288,
12564,
275,
291,
14,
5841,
1296,
59,
73,
61,
288,
862,
26,
355,
653,
4222,
998,
275,
32506,
1296,
59,
73,
61,
355,
2338,
275,
32506,
2141,
59,
46,
4222,
998,
61,
288,
871,
7888,
26,
355,
653,
4222,
998,
275,
488,
355,
2338,
275,
378,
953,
12564,
14,
873,
8,
46,
4222,
998,
12,
2338,
12,
289,
16410,
9,
398,
372,
339,
347,
1678,
4798,
8,
277,
304,
267,
367,
12564,
315,
291,
14,
5841,
1296,
26,
288,
12564,
14,
7237,
342,
398,
291,
14,
5841,
1296,
275,
942,
267,
291,
14,
988,
46,
4222,
38,
13010,
275,
2257,
24916,
14,
362,
4261,
46,
4222,
38,
13010,
342,
267,
20071,
13832,
275,
756,
267,
340,
291,
14,
988,
46,
4222,
38,
13010,
508,
1695,
26,
288,
20071,
13832,
275,
715,
288,
671,
6397,
275,
446,
21,
14,
821,
288,
612,
6397,
275,
499,
14,
19,
288,
612,
6397,
18,
275,
446,
20,
14,
23,
267,
916,
291,
14,
988,
46,
4222,
38,
13010,
508,
3193,
26,
288,
671,
6397,
275,
446,
21,
14,
18,
288,
612,
6397,
275,
650,
14,
21,
288,
612,
6397,
18,
275,
446,
18,
14,
2322,
267,
587,
26,
288,
291,
14,
6814,
14,
705,
360,
7808,
6835,
1390,
428,
3100,
27181,
450,
83,
7,
450,
291,
14,
988,
46,
4222,
38,
13010,
9,
267,
2338,
275,
378,
267,
367,
284,
315,
4945,
8,
277,
14,
988,
46,
4222,
38,
13010,
304,
288,
12564,
275,
653,
4222,
38,
8528,
13832,
8,
1708,
29,
277,
12,
20071,
13832,
29,
12873,
13832,
12,
4224,
2390,
29,
277,
459,
4456,
2390,
1105,
288,
291,
14,
5841,
1296,
14,
740,
8,
5841,
9,
288,
12564,
14,
409,
6981,
8,
88,
6397,
12,
413,
12,
612,
6397,
9,
288,
12564,
14,
409,
9944,
8,
16,
14,
2194,
9,
288,
671,
6397,
847,
650,
14,
21,
288,
2338,
847,
413,
288,
340,
2338,
450,
841,
508,
378,
26,
355,
671,
6397,
275,
446,
21,
14,
821,
355,
612,
6397,
847,
612,
6397,
18,
421,
199,
533,
653,
4222,
38,
8528,
13832,
8,
16281,
3160,
304,
272,
3293,
1872,
4117,
275,
334,
16,
14,
19,
12,
378,
14,
821,
12,
378,
14,
18,
12,
413,
9,
272,
1390,
50,
7945,
275,
959,
272,
308,
736,
2437,
5618,
275,
4005,
265,
16231,
34,
29274,
21675,
14,
2437,
5618,
435,
4005,
265,
16231,
34,
29274,
21675,
14,
14970,
1028,
345,
5618,
339,
347,
636,
826,
721,
277,
12,
1676,
275,
17435,
18,
5780,
12,
20071,
13832,
275,
756,
12,
1011,
829,
304,
267,
945,
8710,
275,
13636,
46,
4222,
998,
297,
283,
1358,
12486,
297,
488,
395,
661,
26557,
2829,
297,
488,
12,
488,
395,
661,
4456,
2390,
297,
488,
12,
488,
430,
267,
291,
14,
4640,
1419,
8,
829,
12,
945,
8710,
9,
267,
21128,
3160,
855,
826,
721,
277,
12,
1676,
29,
1708,
9,
267,
291,
14,
2747,
572,
1419,
8,
46,
4222,
38,
8528,
13832,
9,
267,
12564,
1685,
275,
5077,
14,
912,
1685,
360,
6971,
63,
19,
14,
21,
15,
992,
15,
5885,
15,
22224,
13832,
358,
267,
291,
14,
14708,
275,
21128,
3160,
8,
1708,
29,
277,
12,
28958,
29,
403,
12,
1834,
29,
5841,
1685,
14,
1623,
31260,
15,
5841,
63,
14708,
1333,
267,
291,
14,
14708,
14,
8191,
342,
267,
291,
14,
894,
275,
21128,
3160,
8,
1708,
29,
277,
12,
28958,
29,
403,
12,
1834,
29,
5841,
1685,
14,
1623,
31260,
15,
5841,
63,
894,
659,
9671,
29,
5841,
1685,
14,
1623,
31260,
15,
9733,
1333,
267,
1240,
4259,
6981,
58,
275,
446,
16,
14,
25,
267,
1318,
10155,
15991,
275,
3193,
14,
16,
267,
1318,
9944,
275,
378,
14,
1276,
267,
1318,
6981,
58,
275,
413,
14,
1046,
267,
536,
9944,
275,
378,
14,
20,
267,
536,
6981,
58,
275,
446,
16,
14,
2322,
267,
519,
7945,
9944,
275,
378,
14,
18,
267,
519,
7945,
6981,
58,
275,
446,
17,
14,
18,
267,
291,
14,
14970,
1244,
69,
350,
19156,
275,
413,
14,
18,
267,
291,
14,
14970,
1244,
69,
350,
6981,
58,
275,
378,
14,
2322,
267,
291,
14,
83,
736,
2353,
2354,
6981,
58,
275,
446,
16,
14,
25,
267,
291,
14,
83,
736,
2353,
2354,
9944,
275,
378,
14,
20,
267,
291,
14,
83,
736,
2353,
2354,
18,
6981,
58,
275,
446,
16,
14,
25,
267,
291,
14,
83,
736,
2353,
2354,
18,
9944,
275,
378,
14,
21,
267,
340,
20071,
13832,
26,
288,
291,
14,
14708,
14,
3173,
360,
1569,
16
] |
[
4125,
14,
5885,
14,
16281,
4324,
492,
627,
199,
504,
4125,
14,
2275,
6814,
492,
21128,
8645,
7025,
199,
504,
299,
460,
645,
14,
48,
18328,
17981,
492,
627,
199,
646,
25413,
1028,
79,
4654,
199,
646,
4005,
265,
11664,
199,
646,
4005,
265,
23372,
199,
504,
370,
265,
16231,
14,
475,
265,
1095,
492,
377,
52,
5339,
1793,
199,
504,
370,
265,
16231,
14,
475,
265,
1095,
492,
4005,
265,
16231,
21675,
199,
504,
370,
265,
16231,
14,
475,
265,
1095,
492,
4005,
265,
16231,
34,
29274,
21675,
199,
504,
370,
265,
16231,
14,
475,
265,
492,
7964,
3080,
316,
2395,
21675,
199,
199,
533,
653,
4222,
38,
8528,
10185,
8,
16281,
3160,
304,
272,
11705,
275,
21128,
8645,
7025,
14,
2275,
8645,
14,
1222,
7841,
360,
46,
4222,
38,
8528,
10185,
358,
339,
347,
636,
826,
721,
277,
12,
1676,
275,
17435,
18,
68,
12,
1011,
829,
304,
267,
945,
8710,
275,
13636,
26557,
2829,
297,
488,
12,
488,
395,
661,
4456,
2390,
297,
488,
12,
488,
430,
267,
291,
14,
4640,
1419,
8,
829,
12,
945,
8710,
9,
267,
21128,
3160,
855,
826,
721,
277,
12,
1676,
29,
1708,
9,
267,
291,
14,
5841,
1296,
275,
942,
267,
291,
14,
873,
4798,
342,
267,
291,
14,
2747,
572,
1419,
8,
46,
4222,
38,
8528,
10185,
9,
267,
291,
14,
5694,
8,
1832,
24916,
14,
3235,
985,
360,
988,
46,
4222,
38,
13010,
4001,
659,
291,
14,
873,
4798,
9,
267,
372,
488,
339,
347,
1678,
8,
277,
12,
32506,
2141,
12,
289,
16410,
275,
378,
304,
267,
32506,
1296,
275,
32506,
2141,
14,
1612,
342,
267,
367,
284,
315,
4945,
8,
277,
14,
988,
46,
4222,
38,
13010,
304,
288,
12564,
275,
291,
14,
5841,
1296,
59,
73,
61,
288,
862,
26,
355,
653,
4222,
998,
275,
32506,
1296,
59,
73,
61,
355,
2338,
275,
32506,
2141,
59,
46,
4222,
998,
61,
288,
871,
7888,
26,
355,
653,
4222,
998,
275,
488,
355,
2338,
275,
378,
953,
12564,
14,
873,
8,
46,
4222,
998,
12,
2338,
12,
289,
16410,
9,
398,
372,
339,
347,
1678,
4798,
8,
277,
304,
267,
367,
12564,
315,
291,
14,
5841,
1296,
26,
288,
12564,
14,
7237,
342,
398,
291,
14,
5841,
1296,
275,
942,
267,
291,
14,
988,
46,
4222,
38,
13010,
275,
2257,
24916,
14,
362,
4261,
46,
4222,
38,
13010,
342,
267,
20071,
13832,
275,
756,
267,
340,
291,
14,
988,
46,
4222,
38,
13010,
508,
1695,
26,
288,
20071,
13832,
275,
715,
288,
671,
6397,
275,
446,
21,
14,
821,
288,
612,
6397,
275,
499,
14,
19,
288,
612,
6397,
18,
275,
446,
20,
14,
23,
267,
916,
291,
14,
988,
46,
4222,
38,
13010,
508,
3193,
26,
288,
671,
6397,
275,
446,
21,
14,
18,
288,
612,
6397,
275,
650,
14,
21,
288,
612,
6397,
18,
275,
446,
18,
14,
2322,
267,
587,
26,
288,
291,
14,
6814,
14,
705,
360,
7808,
6835,
1390,
428,
3100,
27181,
450,
83,
7,
450,
291,
14,
988,
46,
4222,
38,
13010,
9,
267,
2338,
275,
378,
267,
367,
284,
315,
4945,
8,
277,
14,
988,
46,
4222,
38,
13010,
304,
288,
12564,
275,
653,
4222,
38,
8528,
13832,
8,
1708,
29,
277,
12,
20071,
13832,
29,
12873,
13832,
12,
4224,
2390,
29,
277,
459,
4456,
2390,
1105,
288,
291,
14,
5841,
1296,
14,
740,
8,
5841,
9,
288,
12564,
14,
409,
6981,
8,
88,
6397,
12,
413,
12,
612,
6397,
9,
288,
12564,
14,
409,
9944,
8,
16,
14,
2194,
9,
288,
671,
6397,
847,
650,
14,
21,
288,
2338,
847,
413,
288,
340,
2338,
450,
841,
508,
378,
26,
355,
671,
6397,
275,
446,
21,
14,
821,
355,
612,
6397,
847,
612,
6397,
18,
421,
199,
533,
653,
4222,
38,
8528,
13832,
8,
16281,
3160,
304,
272,
3293,
1872,
4117,
275,
334,
16,
14,
19,
12,
378,
14,
821,
12,
378,
14,
18,
12,
413,
9,
272,
1390,
50,
7945,
275,
959,
272,
308,
736,
2437,
5618,
275,
4005,
265,
16231,
34,
29274,
21675,
14,
2437,
5618,
435,
4005,
265,
16231,
34,
29274,
21675,
14,
14970,
1028,
345,
5618,
339,
347,
636,
826,
721,
277,
12,
1676,
275,
17435,
18,
5780,
12,
20071,
13832,
275,
756,
12,
1011,
829,
304,
267,
945,
8710,
275,
13636,
46,
4222,
998,
297,
283,
1358,
12486,
297,
488,
395,
661,
26557,
2829,
297,
488,
12,
488,
395,
661,
4456,
2390,
297,
488,
12,
488,
430,
267,
291,
14,
4640,
1419,
8,
829,
12,
945,
8710,
9,
267,
21128,
3160,
855,
826,
721,
277,
12,
1676,
29,
1708,
9,
267,
291,
14,
2747,
572,
1419,
8,
46,
4222,
38,
8528,
13832,
9,
267,
12564,
1685,
275,
5077,
14,
912,
1685,
360,
6971,
63,
19,
14,
21,
15,
992,
15,
5885,
15,
22224,
13832,
358,
267,
291,
14,
14708,
275,
21128,
3160,
8,
1708,
29,
277,
12,
28958,
29,
403,
12,
1834,
29,
5841,
1685,
14,
1623,
31260,
15,
5841,
63,
14708,
1333,
267,
291,
14,
14708,
14,
8191,
342,
267,
291,
14,
894,
275,
21128,
3160,
8,
1708,
29,
277,
12,
28958,
29,
403,
12,
1834,
29,
5841,
1685,
14,
1623,
31260,
15,
5841,
63,
894,
659,
9671,
29,
5841,
1685,
14,
1623,
31260,
15,
9733,
1333,
267,
1240,
4259,
6981,
58,
275,
446,
16,
14,
25,
267,
1318,
10155,
15991,
275,
3193,
14,
16,
267,
1318,
9944,
275,
378,
14,
1276,
267,
1318,
6981,
58,
275,
413,
14,
1046,
267,
536,
9944,
275,
378,
14,
20,
267,
536,
6981,
58,
275,
446,
16,
14,
2322,
267,
519,
7945,
9944,
275,
378,
14,
18,
267,
519,
7945,
6981,
58,
275,
446,
17,
14,
18,
267,
291,
14,
14970,
1244,
69,
350,
19156,
275,
413,
14,
18,
267,
291,
14,
14970,
1244,
69,
350,
6981,
58,
275,
378,
14,
2322,
267,
291,
14,
83,
736,
2353,
2354,
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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
parksandwildlife/static
|
static/firesource/static/admin/js/compress.py
|
784
|
1896
|
#!/usr/bin/env python
import os
import optparse
import subprocess
import sys
here = os.path.dirname(__file__)
def main():
usage = "usage: %prog [file1..fileN]"
description = """With no file paths given this script will automatically
compress all jQuery-based files of the admin app. Requires the Google Closure
Compiler library and Java version 6 or later."""
parser = optparse.OptionParser(usage, description=description)
parser.add_option("-c", dest="compiler", default="~/bin/compiler.jar",
help="path to Closure Compiler jar file")
parser.add_option("-v", "--verbose",
action="store_true", dest="verbose")
parser.add_option("-q", "--quiet",
action="store_false", dest="verbose")
(options, args) = parser.parse_args()
compiler = os.path.expanduser(options.compiler)
if not os.path.exists(compiler):
sys.exit("Google Closure compiler jar file %s not found. Please use the -c option to specify the path." % compiler)
if not args:
if options.verbose:
sys.stdout.write("No filenames given; defaulting to admin scripts\n")
args = [os.path.join(here, f) for f in [
"actions.js", "collapse.js", "inlines.js", "prepopulate.js"]]
for arg in args:
if not arg.endswith(".js"):
arg = arg + ".js"
to_compress = os.path.expanduser(arg)
if os.path.exists(to_compress):
to_compress_min = "%s.min.js" % "".join(arg.rsplit(".js"))
cmd = "java -jar %s --js %s --js_output_file %s" % (compiler, to_compress, to_compress_min)
if options.verbose:
sys.stdout.write("Running: %s\n" % cmd)
subprocess.call(cmd.split())
else:
sys.stdout.write("File %s not found. Sure it exists?\n" % to_compress)
if __name__ == '__main__':
main()
|
apache-2.0
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
646,
747,
199,
646,
8691,
199,
646,
3873,
199,
646,
984,
199,
199,
1681,
275,
747,
14,
515,
14,
3475,
3460,
493,
3368,
199,
199,
318,
2446,
837,
272,
4503,
275,
298,
3807,
26,
450,
6595,
359,
493,
17,
703,
493,
46,
8480,
272,
1369,
275,
408,
3007,
949,
570,
3792,
1627,
642,
2884,
911,
5847,
199,
6447,
1006,
1335,
3227,
13,
6788,
1584,
402,
314,
4628,
1145,
14,
15127,
314,
4475,
5980,
3253,
199,
9131,
3555,
436,
9586,
1015,
1227,
503,
2945,
1041,
272,
1798,
275,
8691,
14,
14553,
8,
3807,
12,
1369,
29,
1802,
9,
272,
1798,
14,
525,
63,
1422,
6096,
67,
401,
2053,
628,
5772,
401,
849,
628,
94,
15,
1393,
15,
5772,
14,
7338,
401,
1993,
1720,
628,
515,
370,
5980,
3253,
27154,
16290,
570,
531,
272,
1798,
14,
525,
63,
1422,
6096,
86,
401,
4320,
3832,
401,
1993,
1595,
628,
1617,
63,
2052,
401,
2053,
628,
3832,
531,
272,
1798,
14,
525,
63,
1422,
6096,
81,
401,
4320,
10243,
401,
1993,
1595,
628,
1617,
63,
3910,
401,
2053,
628,
3832,
531,
272,
334,
1419,
12,
1249,
9,
275,
1798,
14,
1122,
63,
589,
342,
339,
6365,
275,
747,
14,
515,
14,
12131,
8,
1419,
14,
5772,
9,
272,
340,
440,
747,
14,
515,
14,
2444,
8,
5772,
304,
267,
984,
14,
2224,
480,
13266,
5980,
3253,
6365,
16290,
570,
450,
83,
440,
1911,
14,
7754,
675,
314,
446,
67,
945,
370,
4165,
314,
931,
2122,
450,
6365,
9,
339,
340,
440,
1249,
26,
267,
340,
1511,
14,
3832,
26,
288,
984,
14,
2703,
14,
952,
480,
1944,
6203,
1627,
27,
849,
316,
370,
4628,
10554,
60,
78,
531,
267,
1249,
275,
359,
736,
14,
515,
14,
904,
8,
1681,
12,
289,
9,
367,
289,
315,
359,
288,
298,
3723,
14,
3596,
401,
298,
20681,
14,
3596,
401,
298,
26739,
14,
3596,
401,
298,
657,
13817,
14,
3596,
15261,
339,
367,
1680,
315,
1249,
26,
267,
340,
440,
1680,
14,
4130,
9520,
3596,
2349,
288,
1680,
275,
1680,
435,
3680,
3596,
2,
267,
370,
63,
6447,
275,
747,
14,
515,
14,
12131,
8,
1273,
9,
267,
340,
747,
14,
515,
14,
2444,
8,
475,
63,
6447,
304,
288,
370,
63,
6447,
63,
827,
275,
2071,
83,
14,
827,
14,
3596,
2,
450,
10587,
904,
8,
1273,
14,
13490,
9520,
3596,
2237,
288,
2088,
275,
298,
6138,
446,
7338,
450,
83,
1553,
3596,
450,
83,
1553,
3596,
63,
1199,
63,
493,
450,
83,
2,
450,
334,
5772,
12,
370,
63,
6447,
12,
370,
63,
6447,
63,
827,
9,
288,
340,
1511,
14,
3832,
26,
355,
984,
14,
2703,
14,
952,
480,
9602,
26,
450,
83,
60,
78,
2,
450,
2088,
9,
288,
3873,
14,
1250,
8,
1760,
14,
1294,
1012,
267,
587,
26,
288,
984,
14,
2703,
14,
952,
480,
1173,
450,
83,
440,
1911,
14,
428,
608,
652,
3495,
8995,
78,
2,
450,
370,
63,
6447,
9,
199,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
2446,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
646,
747,
199,
646,
8691,
199,
646,
3873,
199,
646,
984,
199,
199,
1681,
275,
747,
14,
515,
14,
3475,
3460,
493,
3368,
199,
199,
318,
2446,
837,
272,
4503,
275,
298,
3807,
26,
450,
6595,
359,
493,
17,
703,
493,
46,
8480,
272,
1369,
275,
408,
3007,
949,
570,
3792,
1627,
642,
2884,
911,
5847,
199,
6447,
1006,
1335,
3227,
13,
6788,
1584,
402,
314,
4628,
1145,
14,
15127,
314,
4475,
5980,
3253,
199,
9131,
3555,
436,
9586,
1015,
1227,
503,
2945,
1041,
272,
1798,
275,
8691,
14,
14553,
8,
3807,
12,
1369,
29,
1802,
9,
272,
1798,
14,
525,
63,
1422,
6096,
67,
401,
2053,
628,
5772,
401,
849,
628,
94,
15,
1393,
15,
5772,
14,
7338,
401,
1993,
1720,
628,
515,
370,
5980,
3253,
27154,
16290,
570,
531,
272,
1798,
14,
525,
63,
1422,
6096,
86,
401,
4320,
3832,
401,
1993,
1595,
628,
1617,
63,
2052,
401,
2053,
628,
3832,
531,
272,
1798,
14,
525,
63,
1422,
6096,
81,
401,
4320,
10243,
401,
1993,
1595,
628,
1617,
63,
3910,
401,
2053,
628,
3832,
531,
272,
334,
1419,
12,
1249,
9,
275,
1798,
14,
1122,
63,
589,
342,
339,
6365,
275,
747,
14,
515,
14,
12131,
8,
1419,
14,
5772,
9,
272,
340,
440,
747,
14,
515,
14,
2444,
8,
5772,
304,
267,
984,
14,
2224,
480,
13266,
5980,
3253,
6365,
16290,
570,
450,
83,
440,
1911,
14,
7754,
675,
314,
446,
67,
945,
370,
4165,
314,
931,
2122,
450,
6365,
9,
339,
340,
440,
1249,
26,
267,
340,
1511,
14,
3832,
26,
288,
984,
14,
2703,
14,
952,
480,
1944,
6203,
1627,
27,
849,
316,
370,
4628,
10554,
60,
78,
531,
267,
1249,
275,
359,
736,
14,
515,
14,
904,
8,
1681,
12,
289,
9,
367,
289,
315,
359,
288,
298,
3723,
14,
3596,
401,
298,
20681,
14,
3596,
401,
298,
26739,
14,
3596,
401,
298,
657,
13817,
14,
3596,
15261,
339,
367,
1680,
315,
1249,
26,
267,
340,
440,
1680,
14,
4130,
9520,
3596,
2349,
288,
1680,
275,
1680,
435,
3680,
3596,
2,
267,
370,
63,
6447,
275,
747,
14,
515,
14,
12131,
8,
1273,
9,
267,
340,
747,
14,
515,
14,
2444,
8,
475,
63,
6447,
304,
288,
370,
63,
6447,
63,
827,
275,
2071,
83,
14,
827,
14,
3596,
2,
450,
10587,
904,
8,
1273,
14,
13490,
9520,
3596,
2237,
288,
2088,
275,
298,
6138,
446,
7338,
450,
83,
1553,
3596,
450,
83,
1553,
3596,
63,
1199,
63,
493,
450,
83,
2,
450,
334,
5772,
12,
370,
63,
6447,
12,
370,
63,
6447,
63,
827,
9,
288,
340,
1511,
14,
3832,
26,
355,
984,
14,
2703,
14,
952,
480,
9602,
26,
450,
83,
60,
78,
2,
450,
2088,
9,
288,
3873,
14,
1250,
8,
1760,
14,
1294,
1012,
267,
587,
26,
288,
984,
14,
2703,
14,
952,
480,
1173,
450,
83,
440,
1911,
14,
428,
608,
652,
3495,
8995,
78,
2,
450,
370,
63,
6447,
9,
199,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
2446,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
liw/daos
|
src/tests/ftest/datamover/dm_copy_procs.py
|
1
|
3305
|
#!/usr/bin/python
'''
(C) Copyright 2020-2021 Intel Corporation.
SPDX-License-Identifier: BSD-2-Clause-Patent
'''
from data_mover_test_base import DataMoverTestBase
from os.path import join
class DmvrCopyProcs(DataMoverTestBase):
# pylint: disable=too-many-ancestors
"""Test class for POSIX DataMover multiple processes.
Test Class Description:
Tests multi-process (rank) copying of the POSIX DataMover utility.
Tests the following cases:
Copying with varying numbers of processes (ranks).
:avocado: recursive
"""
def setUp(self):
"""Set up each test case."""
# Start the servers and agents
super().setUp()
# Get the parameters
self.test_file = self.ior_cmd.test_file.value
self.ior_flags = self.params.get(
"ior_flags", "/run/ior/*")
def test_copy_procs(self):
"""
Test Description:
Tests POSIX copy with multiple processes.
DAOS-5659: Verify multi-process (rank) copying.
Use Cases:
Create pool.
Create POSIX cont1 and cont2 in pool.
Create a single 100M file in cont1 using ior.
:avocado: tags=all,daily_regression
:avocado: tags=small,hw
:avocado: tags=datamover
:avocado: tags=copy_procs
"""
# Create pool and containers
pool1 = self.create_pool()
cont1 = self.create_cont(pool1)
cont2 = self.create_cont(pool1)
# Get the varying number of processes
procs_list = self.params.get(
"processes", "/run/dcp/copy_procs/*")
# Generate test file paths
src_daos = join("/", self.test_file)
dst_daos = join("/", self.test_file)
src_posix = join(self.new_posix_test_path(), self.test_file)
dst_posix = join(self.new_posix_test_path(), self.test_file)
# Create the test files
self.run_ior_with_params("DAOS", src_daos,
pool1, cont1,
flags=self.ior_flags[0])
self.run_ior_with_params("POSIX", src_posix,
flags=self.ior_flags[0])
# DAOS -> POSIX
# Run with varying number of processes
self.set_datamover_params(
"DAOS_UUID", src_daos, pool1, cont1,
"POSIX", dst_posix)
for num_procs in procs_list:
test_desc = "copy_procs (DAOS->POSIX with {} procs)".format(
num_procs)
self.run_datamover(
test_desc=test_desc,
processes=num_procs)
self.run_ior_with_params(
"POSIX", dst_posix, flags=self.ior_flags[1])
# POSIX -> DAOS
# Run with varying number of processes
self.set_datamover_params(
"POSIX", src_posix, None, None,
"DAOS_UUID", dst_daos, pool1, cont2)
for num_procs in procs_list:
test_desc = "copy_procs (POSIX->DAOS with {} procs)".format(
num_procs)
self.run_datamover(
test_desc=test_desc,
processes=num_procs)
self.run_ior_with_params(
"DAOS_UUID", dst_daos, pool1, cont2,
flags=self.ior_flags[1])
|
apache-2.0
|
[
3381,
2647,
15,
1393,
15,
1548,
199,
2344,
523,
334,
35,
9,
1898,
25455,
13,
22150,
20619,
11098,
14,
819,
6988,
19596,
13,
3761,
13,
7544,
26,
6289,
13,
18,
13,
16009,
13,
48,
323,
343,
199,
2344,
199,
504,
666,
63,
573,
422,
63,
396,
63,
1095,
492,
3918,
45,
1883,
14440,
199,
504,
747,
14,
515,
492,
4263,
421,
199,
533,
577,
77,
10922,
5116,
919,
1259,
8,
1451,
45,
1883,
14440,
304,
272,
327,
4287,
26,
3507,
29,
7354,
13,
3479,
13,
23732,
272,
408,
774,
1021,
367,
18169,
3918,
45,
1883,
3663,
10358,
14,
339,
1379,
8089,
11994,
26,
267,
6496,
3510,
13,
1412,
334,
4648,
9,
16743,
402,
314,
18169,
3918,
45,
1883,
11420,
14,
267,
6496,
314,
2569,
5560,
26,
288,
11247,
316,
543,
17083,
316,
5579,
402,
10358,
334,
29473,
680,
339,
520,
1214,
679,
5129,
26,
9133,
272,
408,
339,
347,
3613,
8,
277,
304,
267,
408,
1084,
1536,
1924,
511,
1930,
1041,
267,
327,
7707,
314,
8037,
436,
22867,
267,
1613,
1252,
5996,
342,
398,
327,
2372,
314,
2633,
267,
291,
14,
396,
63,
493,
275,
291,
14,
15499,
63,
1760,
14,
396,
63,
493,
14,
585,
267,
291,
14,
15499,
63,
2469,
275,
291,
14,
1162,
14,
362,
8,
288,
298,
15499,
63,
2469,
401,
3286,
1065,
15,
15499,
6331,
531,
339,
347,
511,
63,
1574,
63,
24463,
8,
277,
304,
267,
408,
267,
1379,
11994,
26,
288,
6496,
18169,
1331,
543,
3663,
10358,
14,
288,
577,
33,
3100,
13,
1367,
1427,
26,
7635,
3510,
13,
1412,
334,
4648,
9,
16743,
14,
267,
3645,
445,
3274,
26,
288,
2790,
4203,
14,
288,
2790,
18169,
13770,
17,
436,
13770,
18,
315,
4203,
14,
288,
2790,
282,
2849,
2948,
45,
570,
315,
13770,
17,
1808,
284,
269,
14,
267,
520,
1214,
679,
5129,
26,
3762,
29,
452,
12,
18621,
63,
12513,
267,
520,
1214,
679,
5129,
26,
3762,
29,
7241,
12,
8090,
267,
520,
1214,
679,
5129,
26,
3762,
29,
576,
573,
422,
267,
520,
1214,
679,
5129,
26,
3762,
29,
1574,
63,
24463,
267,
408,
267,
327,
2790,
4203,
436,
15333,
267,
4203,
17,
275,
291,
14,
981,
63,
2293,
342,
267,
13770,
17,
275,
291,
14,
981,
63,
11096,
8,
2293,
17,
9,
267,
13770,
18,
275,
291,
14,
981,
63,
11096,
8,
2293,
17,
9,
398,
327,
2372,
314,
17083,
316,
1329,
402,
10358,
267,
557,
1259,
63,
513,
275,
291,
14,
1162,
14,
362,
8,
288,
298,
11816,
401,
3286,
1065,
15,
68,
1850,
15,
1574,
63,
24463,
6331,
531,
398,
327,
7958,
511,
570,
3792,
267,
2928,
63,
983,
736,
275,
4263,
27374,
291,
14,
396,
63,
493,
9,
267,
5042,
63,
983,
736,
275,
4263,
27374,
291,
14,
396,
63,
493,
9,
267,
2928,
63,
9228,
275,
4263,
8,
277,
14,
1222,
63,
9228,
63,
396,
63,
515,
1062,
291,
14,
396,
63,
493,
9,
267,
5042,
63,
9228,
275,
4263,
8,
277,
14,
1222,
63,
9228,
63,
396,
63,
515,
1062,
291,
14,
396,
63,
493,
9,
398,
327,
2790,
314,
511,
1584,
267,
291,
14,
1065,
63,
15499,
63,
1045,
63,
1162,
480,
8980,
3100,
401,
2928,
63,
983,
736,
12,
639,
4203,
17,
12,
13770,
17,
12,
639,
3285,
29,
277,
14,
15499,
63,
2469,
59,
16,
566,
267,
291,
14,
1065,
63,
15499,
63,
1045,
63,
1162,
480,
16399,
401,
2928,
63,
9228,
12,
639,
3285,
29,
277,
14,
15499,
63,
2469,
59,
16,
566,
398,
327,
577,
33,
3100,
1035,
18169,
267,
327,
3378,
543,
17083,
316,
1329,
402,
10358,
267,
291,
14,
409,
63,
576,
573,
422,
63,
1162,
8,
288,
298,
8980,
3100,
63,
8757,
401,
2928,
63,
983,
736,
12,
4203,
17,
12,
13770,
17,
12,
288,
298,
16399,
401,
5042,
63,
9228,
9,
267,
367,
1967,
63,
24463,
315,
557,
1259,
63,
513,
26,
288,
511,
63,
3257,
275,
298,
1574,
63,
24463,
334,
8980,
3100,
5118,
16399,
543,
1052,
557,
1259,
30351,
908,
8,
355,
1967,
63,
24463,
9,
288,
291,
14,
1065,
63,
576,
573,
422,
8,
355,
511,
63,
3257,
29,
396,
63,
3257,
12,
355,
10358,
29,
1507,
63,
24463,
9,
288,
291,
14,
1065,
63,
15499,
63,
1045,
63,
1162,
8,
355,
298,
16399,
401,
5042,
63,
9228,
12,
3285,
29,
277,
14,
15499,
63,
2469,
59,
17,
566,
398,
327,
18169,
1035,
577,
33,
3100,
267,
327,
3378,
543,
17083,
316,
1329,
402,
10358,
267,
291,
14,
409,
63,
576,
573,
422,
63,
1162,
8,
288,
298,
16399,
401,
2928,
63,
9228,
12,
488,
12,
488,
12,
288,
298,
8980,
3100,
63,
8757,
401,
5042,
63,
983,
736,
12,
4203,
17,
12,
13770,
18,
9,
267,
367,
1967,
63,
24463,
315,
557,
1259,
63,
513,
26,
288,
511,
63,
3257,
275,
298,
1574,
63,
24463,
334,
16399,
5118,
8980,
3100,
543,
1052,
557,
1259,
30351,
908,
8,
355,
1967,
63,
24463,
9,
288,
291,
14,
1065,
63,
576,
573,
422,
8,
355,
511,
63,
3257,
29,
396,
63,
3257,
12,
355,
10358,
29,
1507,
63,
24463,
9,
288,
291,
14,
1065,
63,
15499,
63,
1045,
63,
1162,
8,
355,
298,
8980,
3100,
63,
8757,
401,
5042,
63,
983,
736,
12,
4203,
17,
12,
13770,
18,
12,
355,
3285,
29,
277,
14,
15499,
63,
2469,
59,
17,
566,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
2647,
15,
1393,
15,
1548,
199,
2344,
523,
334,
35,
9,
1898,
25455,
13,
22150,
20619,
11098,
14,
819,
6988,
19596,
13,
3761,
13,
7544,
26,
6289,
13,
18,
13,
16009,
13,
48,
323,
343,
199,
2344,
199,
504,
666,
63,
573,
422,
63,
396,
63,
1095,
492,
3918,
45,
1883,
14440,
199,
504,
747,
14,
515,
492,
4263,
421,
199,
533,
577,
77,
10922,
5116,
919,
1259,
8,
1451,
45,
1883,
14440,
304,
272,
327,
4287,
26,
3507,
29,
7354,
13,
3479,
13,
23732,
272,
408,
774,
1021,
367,
18169,
3918,
45,
1883,
3663,
10358,
14,
339,
1379,
8089,
11994,
26,
267,
6496,
3510,
13,
1412,
334,
4648,
9,
16743,
402,
314,
18169,
3918,
45,
1883,
11420,
14,
267,
6496,
314,
2569,
5560,
26,
288,
11247,
316,
543,
17083,
316,
5579,
402,
10358,
334,
29473,
680,
339,
520,
1214,
679,
5129,
26,
9133,
272,
408,
339,
347,
3613,
8,
277,
304,
267,
408,
1084,
1536,
1924,
511,
1930,
1041,
267,
327,
7707,
314,
8037,
436,
22867,
267,
1613,
1252,
5996,
342,
398,
327,
2372,
314,
2633,
267,
291,
14,
396,
63,
493,
275,
291,
14,
15499,
63,
1760,
14,
396,
63,
493,
14,
585,
267,
291,
14,
15499,
63,
2469,
275,
291,
14,
1162,
14,
362,
8,
288,
298,
15499,
63,
2469,
401,
3286,
1065,
15,
15499,
6331,
531,
339,
347,
511,
63,
1574,
63,
24463,
8,
277,
304,
267,
408,
267,
1379,
11994,
26,
288,
6496,
18169,
1331,
543,
3663,
10358,
14,
288,
577,
33,
3100,
13,
1367,
1427,
26,
7635,
3510,
13,
1412,
334,
4648,
9,
16743,
14,
267,
3645,
445,
3274,
26,
288,
2790,
4203,
14,
288,
2790,
18169,
13770,
17,
436,
13770,
18,
315,
4203,
14,
288,
2790,
282,
2849,
2948,
45,
570,
315,
13770,
17,
1808,
284,
269,
14,
267,
520,
1214,
679,
5129,
26,
3762,
29,
452,
12,
18621,
63,
12513,
267,
520,
1214,
679,
5129,
26,
3762,
29,
7241,
12,
8090,
267,
520,
1214,
679,
5129,
26,
3762,
29,
576,
573,
422,
267,
520,
1214,
679,
5129,
26,
3762,
29,
1574,
63,
24463,
267,
408,
267,
327,
2790,
4203,
436,
15333,
267,
4203,
17,
275,
291,
14,
981,
63,
2293,
342,
267,
13770,
17,
275,
291,
14,
981,
63,
11096,
8,
2293,
17,
9,
267,
13770,
18,
275,
291,
14,
981,
63,
11096,
8,
2293,
17,
9,
398,
327,
2372,
314,
17083,
316,
1329,
402,
10358,
267,
557,
1259,
63,
513,
275,
291,
14,
1162,
14,
362,
8,
288,
298,
11816,
401,
3286,
1065,
15,
68,
1850,
15,
1574,
63,
24463,
6331,
531,
398,
327,
7958,
511,
570,
3792,
267,
2928,
63,
983,
736,
275,
4263,
27374,
291,
14,
396,
63,
493,
9,
267,
5042,
63,
983,
736,
275,
4263,
27374,
291,
14,
396,
63,
493,
9,
267,
2928,
63,
9228,
275,
4263,
8,
277,
14,
1222,
63,
9228,
63,
396,
63,
515,
1062,
291,
14,
396,
63,
493,
9,
267,
5042,
63,
9228,
275,
4263,
8,
277,
14,
1222,
63,
9228,
63,
396,
63,
515,
1062,
291,
14,
396,
63,
493,
9,
398,
327,
2790,
314,
511,
1584,
267,
291,
14,
1065,
63,
15499,
63,
1045,
63,
1162,
480,
8980,
3100,
401,
2928,
63,
983,
736,
12,
639,
4203,
17,
12,
13770,
17,
12,
639,
3285,
29,
277,
14,
15499,
63,
2469,
59,
16,
566,
267,
291,
14,
1065,
63,
15499,
63,
1045,
63,
1162,
480,
16399,
401,
2928,
63,
9228,
12,
639,
3285,
29,
277,
14,
15499,
63,
2469,
59,
16,
566,
398,
327,
577,
33,
3100,
1035,
18169,
267,
327,
3378,
543,
17083,
316,
1329,
402,
10358,
267,
291,
14,
409,
63,
576,
573,
422,
63,
1162,
8,
288,
298,
8980,
3100,
63,
8757,
401,
2928,
63,
983,
736,
12,
4203,
17,
12,
13770,
17,
12,
288,
298,
16399,
401,
5042,
63,
9228,
9,
267,
367,
1967,
63,
24463,
315,
557,
1259,
63,
513,
26,
288,
511,
63,
3257,
275,
298,
1574,
63,
24463,
334,
8980,
3100,
5118,
16399,
543,
1052,
557,
1259,
30351,
908,
8,
355,
1967,
63,
24463,
9,
288,
291,
14,
1065,
63,
576,
573,
422,
8,
355,
511,
63,
3257,
29,
396,
63,
3257,
12,
355,
10358,
29,
1507,
63,
24463,
9,
288,
291,
14,
1065,
63,
15499,
63,
1045,
63,
1162,
8,
355,
298,
16399,
401,
5042,
63,
9228,
12,
3285,
29,
277,
14,
15499,
63,
2469,
59,
17,
566,
398,
327,
18169,
1035,
577,
33,
3100,
267,
327,
3378,
543,
17083,
316,
1329,
402,
10358,
267,
291,
14,
409,
63,
576,
573,
422,
63,
1162,
8,
288,
298,
16399,
401,
2928,
63,
9228,
12,
488,
12,
488,
12,
288,
298,
8980,
3100,
63,
8757,
401,
5042,
63,
983,
736,
12,
4203,
17,
12,
13770,
18,
9,
267,
367,
1967,
63,
24463,
315,
557,
1259,
63,
513,
26,
288,
511,
63,
3257,
275,
298,
1574,
63,
24463,
334,
16399,
5118,
8980,
3100,
543,
1052,
557,
1259,
30351,
908,
8,
355,
1967,
63,
24463,
9,
288,
291,
14,
1065,
63,
576,
573,
422,
8,
355,
511,
63,
3257,
29,
396,
63,
3257,
12,
355,
10358,
29,
1507,
63,
24463,
9,
288,
291,
14,
1065,
63,
15499,
63,
1045,
63,
1162,
8,
355,
298,
8980,
3100,
63,
8757,
401,
5042,
63,
983,
736,
12,
4203,
17,
12,
13770,
18,
12,
355,
3285,
29,
277,
14,
15499,
63,
2469,
59,
17,
566,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
y12uc231/edx-platform
|
common/djangoapps/util/models.py
|
56
|
2768
|
"""Models for the util app. """
import cStringIO
import gzip
import logging
from django.db import models
from django.db.models.signals import post_init
from django.utils.text import compress_string
from config_models.models import ConfigurationModel
logger = logging.getLogger(__name__) # pylint: disable=invalid-name
class RateLimitConfiguration(ConfigurationModel):
"""Configuration flag to enable/disable rate limiting.
Applies to Django Rest Framework views.
This is useful for disabling rate limiting for performance tests.
When enabled, it will disable rate limiting on any view decorated
with the `can_disable_rate_limit` class decorator.
"""
pass
def uncompress_string(s):
"""
Helper function to reverse CompressedTextField.get_prep_value.
"""
try:
val = s.encode('utf').decode('base64')
zbuf = cStringIO.StringIO(val)
zfile = gzip.GzipFile(fileobj=zbuf)
ret = zfile.read()
zfile.close()
except Exception as e:
logger.error('String decompression failed. There may be corrupted data in the database: %s', e)
ret = s
return ret
class CompressedTextField(models.TextField):
"""transparently compress data before hitting the db and uncompress after fetching"""
def get_prep_value(self, value):
if value is not None:
if isinstance(value, unicode):
value = value.encode('utf8')
value = compress_string(value)
value = value.encode('base64').decode('utf8')
return value
def post_init(self, instance=None, **kwargs): # pylint: disable=unused-argument
value = self._get_val_from_obj(instance)
if value:
setattr(instance, self.attname, value)
def contribute_to_class(self, cls, name):
super(CompressedTextField, self).contribute_to_class(cls, name)
post_init.connect(self.post_init, sender=cls)
def _get_val_from_obj(self, obj):
if obj:
value = uncompress_string(getattr(obj, self.attname))
if value is not None:
try:
value = value.decode('utf8')
except UnicodeDecodeError:
pass
return value
else:
return self.get_default()
else:
return self.get_default()
def south_field_triple(self):
"""Returns a suitable description of this field for South."""
# We'll just introspect the _actual_ field.
from south.modelsinspector import introspector
field_class = "django.db.models.fields.TextField"
args, kwargs = introspector(self)
# That's our definition!
return field_class, args, kwargs
|
agpl-3.0
|
[
624,
20474,
367,
314,
4884,
1145,
14,
408,
199,
646,
15073,
199,
646,
11756,
199,
646,
2050,
199,
199,
504,
1639,
14,
697,
492,
1709,
199,
504,
1639,
14,
697,
14,
992,
14,
10458,
492,
2963,
63,
826,
199,
504,
1639,
14,
1208,
14,
505,
492,
11029,
63,
875,
199,
199,
504,
1101,
63,
992,
14,
992,
492,
11595,
1685,
421,
199,
2921,
275,
2050,
14,
5572,
3460,
354,
3368,
221,
327,
4287,
26,
3507,
29,
3197,
13,
354,
421,
199,
533,
26311,
8407,
5688,
8,
5688,
1685,
304,
272,
408,
5688,
3305,
370,
4756,
15,
5993,
6634,
2304,
316,
14,
339,
4693,
6528,
370,
5634,
30417,
22545,
6858,
14,
339,
961,
365,
2997,
367,
30723,
6634,
2304,
316,
367,
10238,
2295,
14,
272,
3979,
5223,
12,
652,
911,
3507,
6634,
2304,
316,
641,
1263,
2455,
16225,
272,
543,
314,
658,
2425,
63,
5993,
63,
1866,
63,
3097,
64,
1021,
7531,
14,
272,
408,
272,
986,
421,
199,
318,
625,
6447,
63,
875,
8,
83,
304,
272,
408,
272,
11642,
805,
370,
3837,
3599,
5111,
6254,
14,
362,
63,
10837,
63,
585,
14,
272,
408,
339,
862,
26,
267,
1139,
275,
308,
14,
2143,
360,
1624,
1959,
2708,
360,
1095,
772,
358,
267,
1315,
1436,
275,
15073,
14,
6424,
8,
637,
9,
267,
1315,
493,
275,
11756,
14,
29827,
8,
9234,
29,
90,
1436,
9,
267,
2203,
275,
1315,
493,
14,
739,
342,
267,
1315,
493,
14,
1600,
342,
272,
871,
2186,
465,
325,
26,
267,
2512,
14,
705,
360,
1558,
477,
12849,
3405,
14,
6006,
1443,
506,
1970,
15692,
666,
315,
314,
3050,
26,
450,
83,
297,
325,
9,
267,
2203,
275,
308,
272,
372,
2203,
421,
199,
533,
3599,
5111,
6254,
8,
992,
14,
6254,
304,
272,
408,
24420,
590,
11029,
666,
2544,
9793,
1337,
314,
1592,
436,
625,
6447,
2410,
21239,
624,
339,
347,
664,
63,
10837,
63,
585,
8,
277,
12,
574,
304,
267,
340,
574,
365,
440,
488,
26,
288,
340,
1228,
8,
585,
12,
2649,
304,
355,
574,
275,
574,
14,
2143,
360,
1624,
24,
358,
288,
574,
275,
11029,
63,
875,
8,
585,
9,
288,
574,
275,
574,
14,
2143,
360,
1095,
772,
1959,
2708,
360,
1624,
24,
358,
267,
372,
574,
339,
347,
2963,
63,
826,
8,
277,
12,
1256,
29,
403,
12,
1011,
958,
304,
257,
327,
4287,
26,
3507,
29,
8618,
13,
2094,
267,
574,
275,
291,
423,
362,
63,
637,
63,
504,
63,
1113,
8,
842,
9,
267,
340,
574,
26,
288,
5371,
8,
842,
12,
291,
14,
13651,
12,
574,
9,
339,
347,
28567,
63,
475,
63,
533,
8,
277,
12,
843,
12,
536,
304,
267,
1613,
8,
25428,
6254,
12,
291,
680,
388,
999,
63,
475,
63,
533,
8,
1886,
12,
536,
9,
267,
2963,
63,
826,
14,
2242,
8,
277,
14,
1932,
63,
826,
12,
8904,
29,
1886,
9,
339,
347,
485,
362,
63,
637,
63,
504,
63,
1113,
8,
277,
12,
1559,
304,
267,
340,
1559,
26,
288,
574,
275,
625,
6447,
63,
875,
8,
5675,
8,
1113,
12,
291,
14,
13651,
430,
288,
340,
574,
365,
440,
488,
26,
355,
862,
26,
490,
574,
275,
574,
14,
2708,
360,
1624,
24,
358,
355,
871,
18965,
26,
490,
986,
355,
372,
574,
288,
587,
26,
355,
372,
291,
14,
362,
63,
885,
342,
267,
587,
26,
288,
372,
291,
14,
362,
63,
885,
342,
339,
347,
12919,
63,
698,
63,
19956,
8,
277,
304,
267,
408,
3407,
282,
11233,
1369,
402,
642,
901,
367,
23150,
1041,
267,
327,
2136,
7171,
2951,
1109,
21302,
314,
485,
6514,
63,
901,
14,
267,
687,
12919,
14,
992,
26047,
492,
1109,
4796,
15152,
398,
901,
63,
533,
275,
298,
1176,
14,
697,
14,
992,
14,
955,
14,
6254,
2,
267,
1249,
12,
2074,
275,
1109,
4796,
15152,
8,
277,
9,
267,
327,
10314,
1159,
4154,
5492,
1,
267,
372,
901,
63,
533,
12,
1249,
12,
2074,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
20474,
367,
314,
4884,
1145,
14,
408,
199,
646,
15073,
199,
646,
11756,
199,
646,
2050,
199,
199,
504,
1639,
14,
697,
492,
1709,
199,
504,
1639,
14,
697,
14,
992,
14,
10458,
492,
2963,
63,
826,
199,
504,
1639,
14,
1208,
14,
505,
492,
11029,
63,
875,
199,
199,
504,
1101,
63,
992,
14,
992,
492,
11595,
1685,
421,
199,
2921,
275,
2050,
14,
5572,
3460,
354,
3368,
221,
327,
4287,
26,
3507,
29,
3197,
13,
354,
421,
199,
533,
26311,
8407,
5688,
8,
5688,
1685,
304,
272,
408,
5688,
3305,
370,
4756,
15,
5993,
6634,
2304,
316,
14,
339,
4693,
6528,
370,
5634,
30417,
22545,
6858,
14,
339,
961,
365,
2997,
367,
30723,
6634,
2304,
316,
367,
10238,
2295,
14,
272,
3979,
5223,
12,
652,
911,
3507,
6634,
2304,
316,
641,
1263,
2455,
16225,
272,
543,
314,
658,
2425,
63,
5993,
63,
1866,
63,
3097,
64,
1021,
7531,
14,
272,
408,
272,
986,
421,
199,
318,
625,
6447,
63,
875,
8,
83,
304,
272,
408,
272,
11642,
805,
370,
3837,
3599,
5111,
6254,
14,
362,
63,
10837,
63,
585,
14,
272,
408,
339,
862,
26,
267,
1139,
275,
308,
14,
2143,
360,
1624,
1959,
2708,
360,
1095,
772,
358,
267,
1315,
1436,
275,
15073,
14,
6424,
8,
637,
9,
267,
1315,
493,
275,
11756,
14,
29827,
8,
9234,
29,
90,
1436,
9,
267,
2203,
275,
1315,
493,
14,
739,
342,
267,
1315,
493,
14,
1600,
342,
272,
871,
2186,
465,
325,
26,
267,
2512,
14,
705,
360,
1558,
477,
12849,
3405,
14,
6006,
1443,
506,
1970,
15692,
666,
315,
314,
3050,
26,
450,
83,
297,
325,
9,
267,
2203,
275,
308,
272,
372,
2203,
421,
199,
533,
3599,
5111,
6254,
8,
992,
14,
6254,
304,
272,
408,
24420,
590,
11029,
666,
2544,
9793,
1337,
314,
1592,
436,
625,
6447,
2410,
21239,
624,
339,
347,
664,
63,
10837,
63,
585,
8,
277,
12,
574,
304,
267,
340,
574,
365,
440,
488,
26,
288,
340,
1228,
8,
585,
12,
2649,
304,
355,
574,
275,
574,
14,
2143,
360,
1624,
24,
358,
288,
574,
275,
11029,
63,
875,
8,
585,
9,
288,
574,
275,
574,
14,
2143,
360,
1095,
772,
1959,
2708,
360,
1624,
24,
358,
267,
372,
574,
339,
347,
2963,
63,
826,
8,
277,
12,
1256,
29,
403,
12,
1011,
958,
304,
257,
327,
4287,
26,
3507,
29,
8618,
13,
2094,
267,
574,
275,
291,
423,
362,
63,
637,
63,
504,
63,
1113,
8,
842,
9,
267,
340,
574,
26,
288,
5371,
8,
842,
12,
291,
14,
13651,
12,
574,
9,
339,
347,
28567,
63,
475,
63,
533,
8,
277,
12,
843,
12,
536,
304,
267,
1613,
8,
25428,
6254,
12,
291,
680,
388,
999,
63,
475,
63,
533,
8,
1886,
12,
536,
9,
267,
2963,
63,
826,
14,
2242,
8,
277,
14,
1932,
63,
826,
12,
8904,
29,
1886,
9,
339,
347,
485,
362,
63,
637,
63,
504,
63,
1113,
8,
277,
12,
1559,
304,
267,
340,
1559,
26,
288,
574,
275,
625,
6447,
63,
875,
8,
5675,
8,
1113,
12,
291,
14,
13651,
430,
288,
340,
574,
365,
440,
488,
26,
355,
862,
26,
490,
574,
275,
574,
14,
2708,
360,
1624,
24,
358,
355,
871,
18965,
26,
490,
986,
355,
372,
574,
288,
587,
26,
355,
372,
291,
14,
362,
63,
885,
342,
267,
587,
26,
288,
372,
291,
14,
362,
63,
885,
342,
339,
347,
12919,
63,
698,
63,
19956,
8,
277,
304,
267,
408,
3407,
282,
11233,
1369,
402,
642,
901,
367,
23150,
1041,
267,
327,
2136,
7171,
2951,
1109,
21302,
314,
485,
6514,
63,
901,
14,
267,
687,
12919,
14,
992,
26047,
492,
1109,
4796,
15152,
398,
901,
63,
533,
275,
298,
1176,
14,
697,
14,
992,
14,
955,
14,
6254,
2,
267,
1249,
12,
2074,
275,
1109,
4796,
15152,
8,
277,
9,
267,
327,
10314,
1159,
4154,
5492,
1,
267,
372,
901,
63,
533,
12,
1249,
12,
2074,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
zzir/white
|
verificationcode.py
|
1
|
2611
|
from PIL import Image,ImageDraw, ImageFont, ImageFilter
import random
class VerifyCode():
def __init__(self):
self._letter_cases = 'abcdefghjkmnpqrstuvwxyzABCDEFGHJKMNOPRSTUVWXYZ3456789'
self._upper_cases = self._letter_cases.upper()
self._numbers = ''.join(map(str, range(3, 10)))
def createCodeImage(self,size=(80,26),img_type='jpg',
mode='RGB',bg_color=(255,255,255),fg_color=(0,0,255),
font_size=24,font_type='static/abrahamlincoln.ttf',
length=4,draw_lines=True,n_line=(1,2),
draw_points=True,point_chance=2):
width,height = size
img = Image.new(mode, size, bg_color)
draw = ImageDraw.Draw(img)
def get_chars():
return random.sample(self._letter_cases,length)
def creat_line():
line_num = random.randint(*n_line)
for i in range(line_num):
begin = (random.randint(0, size[0]), random.randint(0, size[1]))
end = (random.randint(0, size[0]), random.randint(0, size[1]))
draw.line([begin, end], fill=(0, 0, 0))
def create_points():
chance = min(100, max(0, int(point_chance)))
for w in range(width):
for h in range(height):
tmp = random.randint(0, 100)
if tmp > 100 - chance:
draw.point((w, h), fill=(0, 0, 0))
def create_strs():
c_chars = get_chars()
strs = ' %s ' % ' '.join(c_chars)
font = ImageFont.truetype(font_type, font_size)
font_width, font_height = font.getsize(strs)
draw.text(((width - font_width) / 3, (height - font_height) / 3),
strs, font=font, fill=fg_color)
return ''.join(c_chars)
if draw_lines:
creat_line()
if draw_points:
create_points()
strs = create_strs()
params = [1 - float(random.randint(1, 2)) / 100,
0,
0,
0,
1 - float(random.randint(1, 10)) / 100,
float(random.randint(1, 2)) / 500,
0.001,
float(random.randint(1, 2)) / 500
]
img = img.transform(size, Image.PERSPECTIVE, params)
img = img.filter(ImageFilter.EDGE_ENHANCE_MORE)
return img, strs
#
# if __name__ == '__main__':
# code_img,capacha_code= creat_validata_code()
# code_img.save('xx.jpg','JPEG')
|
mit
|
[
504,
14937,
492,
6047,
12,
3491,
9654,
12,
6047,
6986,
12,
6047,
4131,
199,
646,
2196,
421,
199,
533,
7635,
3034,
837,
339,
347,
636,
826,
721,
277,
304,
267,
291,
423,
9269,
63,
9403,
275,
283,
16238,
74,
14595,
1590,
21832,
22897,
22313,
43,
26225,
10171,
15110,
24648,
1082,
6690,
7,
267,
291,
423,
4142,
63,
9403,
275,
291,
423,
9269,
63,
9403,
14,
4142,
342,
267,
291,
423,
10548,
275,
6522,
904,
8,
1130,
8,
495,
12,
1425,
8,
19,
12,
1616,
1724,
339,
347,
1218,
3034,
3491,
8,
277,
12,
890,
2687,
1257,
12,
1479,
395,
4060,
63,
466,
534,
8476,
297,
717,
818,
534,
12067,
297,
6856,
63,
2326,
2687,
2299,
12,
2299,
12,
2299,
395,
9681,
63,
2326,
2687,
16,
12,
16,
12,
2299,
395,
1169,
5023,
63,
890,
29,
1194,
12,
4246,
63,
466,
534,
1986,
15,
371,
345,
10670,
472,
761,
78,
14,
32264,
297,
1169,
2582,
29,
20,
12,
5485,
63,
1278,
29,
549,
12,
78,
63,
604,
2687,
17,
12,
18,
395,
1169,
5954,
63,
3438,
29,
549,
12,
1403,
63,
335,
554,
29,
18,
304,
267,
3462,
12,
3333,
275,
1568,
267,
6050,
275,
6047,
14,
1222,
8,
632,
12,
1568,
12,
12994,
63,
2326,
9,
267,
5954,
275,
6047,
9654,
14,
9654,
8,
4060,
9,
398,
347,
664,
63,
6574,
837,
288,
372,
2196,
14,
3271,
8,
277,
423,
9269,
63,
9403,
12,
1267,
9,
398,
347,
2837,
292,
63,
604,
837,
288,
1004,
63,
1507,
275,
2196,
14,
8393,
2031,
78,
63,
604,
9,
953,
367,
284,
315,
1425,
8,
604,
63,
1507,
304,
355,
5386,
275,
334,
2355,
14,
8393,
8,
16,
12,
1568,
59,
16,
2522,
2196,
14,
8393,
8,
16,
12,
1568,
59,
17,
2459,
355,
1284,
275,
334,
2355,
14,
8393,
8,
16,
12,
1568,
59,
16,
2522,
2196,
14,
8393,
8,
16,
12,
1568,
59,
17,
2459,
355,
5954,
14,
604,
779,
5037,
12,
1284,
467,
5554,
2687,
16,
12,
378,
12,
378,
430,
398,
347,
1218,
63,
3438,
837,
288,
22044,
275,
1748,
8,
1960,
12,
1390,
8,
16,
12,
1109,
8,
1403,
63,
335,
554,
1724,
288,
367,
336,
315,
1425,
8,
2063,
304,
355,
367,
394,
315,
1425,
8,
3333,
304,
490,
3529,
275,
2196,
14,
8393,
8,
16,
12,
2948,
9,
490,
340,
3529,
690,
2948,
446,
22044,
26,
717,
5954,
14,
1403,
1332,
87,
12,
394,
395,
5554,
2687,
16,
12,
378,
12,
378,
430,
398,
347,
1218,
63,
16144,
837,
288,
286,
63,
6574,
275,
664,
63,
6574,
342,
288,
620,
83,
275,
283,
450,
83,
283,
450,
283,
1987,
904,
8,
67,
63,
6574,
9,
288,
5023,
275,
6047,
6986,
14,
2052,
466,
8,
4246,
63,
466,
12,
5023,
63,
890,
9,
288,
5023,
63,
2063,
12,
5023,
63,
3333,
275,
5023,
14,
20733,
8,
16144,
9,
288,
5954,
14,
505,
12925,
2063,
446,
5023,
63,
2063,
9,
1182,
650,
12,
334,
3333,
446,
5023,
63,
3333,
9,
1182,
650,
395,
717,
620,
83,
12,
5023,
29,
4246,
12,
5554,
29,
9681,
63,
2326,
9,
288,
372,
6522,
904,
8,
67,
63,
6574,
9,
398,
340,
5954,
63,
1278,
26,
288,
2837,
292,
63,
604,
342,
267,
340,
5954,
63,
3438,
26,
288,
1218,
63,
3438,
342,
267,
620,
83,
275,
1218,
63,
16144,
342,
398,
1862,
275,
359,
17,
446,
2069,
8,
2355,
14,
8393,
8,
17,
12,
499,
430,
1182,
2948,
12,
2116,
378,
12,
2116,
378,
12,
2116,
378,
12,
2116,
413,
446,
2069,
8,
2355,
14,
8393,
8,
17,
12,
1616,
430,
1182,
2948,
12,
2116,
2069,
8,
2355,
14,
8393,
8,
17,
12,
499,
430,
1182,
6891,
12,
2116,
378,
14,
4587,
12,
2116,
2069,
8,
2355,
14,
8393,
8,
17,
12,
499,
430,
1182,
6891,
2116,
1622,
267,
6050,
275,
6050,
14,
4711,
8,
890,
12,
6047,
14,
48,
3960,
11401,
5399,
12,
1862,
9,
267,
6050,
275,
6050,
14,
1541,
8,
3491,
4131,
14,
1149,
4962,
63,
742,
40,
7140,
63,
45,
5788,
9,
267,
372,
6050,
12,
620,
83,
199,
3,
199,
3,
340,
636,
354,
363,
508,
2560,
973,
3706,
199,
3,
258,
1233,
63,
4060,
12,
18182,
9518,
63,
600,
29,
2837,
292,
63,
1078,
419,
63,
600,
342,
199,
3,
258,
1233,
63,
4060,
14,
2117,
360,
2154,
14,
8476,
1673,
28412,
358,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
14937,
492,
6047,
12,
3491,
9654,
12,
6047,
6986,
12,
6047,
4131,
199,
646,
2196,
421,
199,
533,
7635,
3034,
837,
339,
347,
636,
826,
721,
277,
304,
267,
291,
423,
9269,
63,
9403,
275,
283,
16238,
74,
14595,
1590,
21832,
22897,
22313,
43,
26225,
10171,
15110,
24648,
1082,
6690,
7,
267,
291,
423,
4142,
63,
9403,
275,
291,
423,
9269,
63,
9403,
14,
4142,
342,
267,
291,
423,
10548,
275,
6522,
904,
8,
1130,
8,
495,
12,
1425,
8,
19,
12,
1616,
1724,
339,
347,
1218,
3034,
3491,
8,
277,
12,
890,
2687,
1257,
12,
1479,
395,
4060,
63,
466,
534,
8476,
297,
717,
818,
534,
12067,
297,
6856,
63,
2326,
2687,
2299,
12,
2299,
12,
2299,
395,
9681,
63,
2326,
2687,
16,
12,
16,
12,
2299,
395,
1169,
5023,
63,
890,
29,
1194,
12,
4246,
63,
466,
534,
1986,
15,
371,
345,
10670,
472,
761,
78,
14,
32264,
297,
1169,
2582,
29,
20,
12,
5485,
63,
1278,
29,
549,
12,
78,
63,
604,
2687,
17,
12,
18,
395,
1169,
5954,
63,
3438,
29,
549,
12,
1403,
63,
335,
554,
29,
18,
304,
267,
3462,
12,
3333,
275,
1568,
267,
6050,
275,
6047,
14,
1222,
8,
632,
12,
1568,
12,
12994,
63,
2326,
9,
267,
5954,
275,
6047,
9654,
14,
9654,
8,
4060,
9,
398,
347,
664,
63,
6574,
837,
288,
372,
2196,
14,
3271,
8,
277,
423,
9269,
63,
9403,
12,
1267,
9,
398,
347,
2837,
292,
63,
604,
837,
288,
1004,
63,
1507,
275,
2196,
14,
8393,
2031,
78,
63,
604,
9,
953,
367,
284,
315,
1425,
8,
604,
63,
1507,
304,
355,
5386,
275,
334,
2355,
14,
8393,
8,
16,
12,
1568,
59,
16,
2522,
2196,
14,
8393,
8,
16,
12,
1568,
59,
17,
2459,
355,
1284,
275,
334,
2355,
14,
8393,
8,
16,
12,
1568,
59,
16,
2522,
2196,
14,
8393,
8,
16,
12,
1568,
59,
17,
2459,
355,
5954,
14,
604,
779,
5037,
12,
1284,
467,
5554,
2687,
16,
12,
378,
12,
378,
430,
398,
347,
1218,
63,
3438,
837,
288,
22044,
275,
1748,
8,
1960,
12,
1390,
8,
16,
12,
1109,
8,
1403,
63,
335,
554,
1724,
288,
367,
336,
315,
1425,
8,
2063,
304,
355,
367,
394,
315,
1425,
8,
3333,
304,
490,
3529,
275,
2196,
14,
8393,
8,
16,
12,
2948,
9,
490,
340,
3529,
690,
2948,
446,
22044,
26,
717,
5954,
14,
1403,
1332,
87,
12,
394,
395,
5554,
2687,
16,
12,
378,
12,
378,
430,
398,
347,
1218,
63,
16144,
837,
288,
286,
63,
6574,
275,
664,
63,
6574,
342,
288,
620,
83,
275,
283,
450,
83,
283,
450,
283,
1987,
904,
8,
67,
63,
6574,
9,
288,
5023,
275,
6047,
6986,
14,
2052,
466,
8,
4246,
63,
466,
12,
5023,
63,
890,
9,
288,
5023,
63,
2063,
12,
5023,
63,
3333,
275,
5023,
14,
20733,
8,
16144,
9,
288,
5954,
14,
505,
12925,
2063,
446,
5023,
63,
2063,
9,
1182,
650,
12,
334,
3333,
446,
5023,
63,
3333,
9,
1182,
650,
395,
717,
620,
83,
12,
5023,
29,
4246,
12,
5554,
29,
9681,
63,
2326,
9,
288,
372,
6522,
904,
8,
67,
63,
6574,
9,
398,
340,
5954,
63,
1278,
26,
288,
2837,
292,
63,
604,
342,
267,
340,
5954,
63,
3438,
26,
288,
1218,
63,
3438,
342,
267,
620,
83,
275,
1218,
63,
16144,
342,
398,
1862,
275,
359,
17,
446,
2069,
8,
2355,
14,
8393,
8,
17,
12,
499,
430,
1182,
2948,
12,
2116,
378,
12,
2116,
378,
12,
2116,
378,
12,
2116,
413,
446,
2069,
8,
2355,
14,
8393,
8,
17,
12,
1616,
430,
1182,
2948,
12,
2116,
2069,
8,
2355,
14,
8393,
8,
17,
12,
499,
430,
1182,
6891,
12,
2116,
378,
14,
4587,
12,
2116,
2069,
8,
2355,
14,
8393,
8,
17,
12,
499,
430,
1182,
6891,
2116,
1622,
267,
6050,
275,
6050,
14,
4711,
8,
890,
12,
6047,
14,
48,
3960,
11401,
5399,
12,
1862,
9,
267,
6050,
275,
6050,
14,
1541,
8,
3491,
4131,
14,
1149,
4962,
63,
742,
40,
7140,
63,
45,
5788,
9,
267,
372,
6050,
12,
620,
83,
199,
3,
199,
3,
340,
636,
354,
363,
508,
2560,
973,
3706,
199,
3,
258,
1233,
63,
4060,
12,
18182,
9518,
63,
600,
29,
2837,
292,
63,
1078,
419,
63,
600,
342,
199,
3,
258,
1233,
63,
4060,
14,
2117,
360,
2154,
14,
8476,
1673,
28412,
358,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
foursquare/luigi
|
luigi/contrib/ecs.py
|
4
|
6469
|
# -*- coding: utf-8 -*-
#
# Copyright 2015 Outlier Bio, LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
"""
EC2 Container Service wrapper for Luigi
From the AWS website:
Amazon EC2 Container Service (ECS) is a highly scalable, high performance
container management service that supports Docker containers and allows you
to easily run applications on a managed cluster of Amazon EC2 instances.
To use ECS, you create a taskDefinition_ JSON that defines the `docker run`_
command for one or more containers in a task or service, and then submit this
JSON to the API to run the task.
This `boto3-powered`_ wrapper allows you to create Luigi Tasks to submit ECS
``taskDefinition`` s. You can either pass a dict (mapping directly to the
``taskDefinition`` JSON) OR an Amazon Resource Name (arn) for a previously
registered ``taskDefinition``.
Requires:
- boto3 package
- Amazon AWS credentials discoverable by boto3 (e.g., by using ``aws configure``
from awscli_)
- A running ECS cluster (see `ECS Get Started`_)
Written and maintained by Jake Feala (@jfeala) for Outlier Bio (@outlierbio)
.. _`docker run`: https://docs.docker.com/reference/commandline/run
.. _taskDefinition: http://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_defintions.html
.. _`boto3-powered`: https://boto3.readthedocs.io
.. _awscli: https://aws.amazon.com/cli
.. _`ECS Get Started`: http://docs.aws.amazon.com/AmazonECS/latest/developerguide/ECS_GetStarted.html
"""
import time
import logging
import luigi
logger = logging.getLogger('luigi-interface')
try:
import boto3
client = boto3.client('ecs')
except ImportError:
logger.warning('boto3 is not installed. ECSTasks require boto3')
POLL_TIME = 2
def _get_task_statuses(task_ids, cluster):
"""
Retrieve task statuses from ECS API
Returns list of {RUNNING|PENDING|STOPPED} for each id in task_ids
"""
response = client.describe_tasks(tasks=task_ids, cluster=cluster)
# Error checking
if response['failures'] != []:
raise Exception('There were some failures:\n{0}'.format(
response['failures']))
status_code = response['ResponseMetadata']['HTTPStatusCode']
if status_code != 200:
msg = 'Task status request received status code {0}:\n{1}'
raise Exception(msg.format(status_code, response))
return [t['lastStatus'] for t in response['tasks']]
def _track_tasks(task_ids, cluster):
"""Poll task status until STOPPED"""
while True:
statuses = _get_task_statuses(task_ids, cluster)
if all([status == 'STOPPED' for status in statuses]):
logger.info('ECS tasks {0} STOPPED'.format(','.join(task_ids)))
break
time.sleep(POLL_TIME)
logger.debug('ECS task status for tasks {0}: {1}'.format(task_ids, statuses))
class ECSTask(luigi.Task):
"""
Base class for an Amazon EC2 Container Service Task
Amazon ECS requires you to register "tasks", which are JSON descriptions
for how to issue the ``docker run`` command. This Luigi Task can either
run a pre-registered ECS taskDefinition, OR register the task on the fly
from a Python dict.
:param task_def_arn: pre-registered task definition ARN (Amazon Resource
Name), of the form::
arn:aws:ecs:<region>:<user_id>:task-definition/<family>:<tag>
:param task_def: dict describing task in taskDefinition JSON format, for
example::
task_def = {
'family': 'hello-world',
'volumes': [],
'containerDefinitions': [
{
'memory': 1,
'essential': True,
'name': 'hello-world',
'image': 'ubuntu',
'command': ['/bin/echo', 'hello world']
}
]
}
:param cluster: str defining the ECS cluster to use.
When this is not defined it will use the default one.
"""
task_def_arn = luigi.OptionalParameter(default=None)
task_def = luigi.OptionalParameter(default=None)
cluster = luigi.Parameter(default='default')
@property
def ecs_task_ids(self):
"""Expose the ECS task ID"""
if hasattr(self, '_task_ids'):
return self._task_ids
@property
def command(self):
"""
Command passed to the containers
Override to return list of dicts with keys 'name' and 'command',
describing the container names and commands to pass to the container.
Directly corresponds to the `overrides` parameter of runTask API. For
example::
[
{
'name': 'myContainer',
'command': ['/bin/sleep', '60']
}
]
"""
pass
def run(self):
if (not self.task_def and not self.task_def_arn) or \
(self.task_def and self.task_def_arn):
raise ValueError(('Either (but not both) a task_def (dict) or'
'task_def_arn (string) must be assigned'))
if not self.task_def_arn:
# Register the task and get assigned taskDefinition ID (arn)
response = client.register_task_definition(**self.task_def)
self.task_def_arn = response['taskDefinition']['taskDefinitionArn']
# Submit the task to AWS ECS and get assigned task ID
# (list containing 1 string)
if self.command:
overrides = {'containerOverrides': self.command}
else:
overrides = {}
response = client.run_task(taskDefinition=self.task_def_arn,
overrides=overrides,
cluster=self.cluster)
self._task_ids = [task['taskArn'] for task in response['tasks']]
# Wait on task completion
_track_tasks(self._task_ids, self.cluster)
|
apache-2.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
199,
3,
1898,
6900,
6219,
5697,
699,
2308,
12,
20376,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
3,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
3,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
3,
199,
199,
624,
199,
4220,
18,
15395,
7591,
4975,
367,
30936,
13721,
199,
199,
2532,
314,
10168,
10691,
26,
819,
14347,
15352,
18,
15395,
7591,
334,
37,
3298,
9,
365,
282,
4721,
590,
5269,
461,
12,
4721,
10238,
523,
3970,
10041,
2435,
626,
5171,
22067,
15333,
436,
6127,
1265,
523,
370,
16174,
1255,
13103,
641,
282,
12883,
4350,
402,
14347,
15352,
18,
4454,
14,
199,
199,
1378,
675,
662,
3298,
12,
1265,
1218,
282,
2120,
10701,
63,
4840,
626,
7890,
314,
658,
9991,
1255,
18417,
199,
1531,
367,
1373,
503,
1655,
15333,
315,
282,
2120,
503,
2435,
12,
436,
2066,
11482,
642,
199,
6243,
370,
314,
3261,
370,
1255,
314,
2120,
14,
199,
199,
2765,
658,
10914,
19,
13,
555,
21221,
18417,
4975,
6127,
1265,
370,
1218,
30936,
13721,
8495,
83,
370,
11482,
662,
3298,
199,
1040,
1765,
10701,
1040,
308,
14,
2047,
883,
1902,
986,
282,
1211,
334,
4745,
5370,
370,
314,
199,
1040,
1765,
10701,
1040,
4840,
9,
1549,
376,
14347,
7337,
2812,
334,
1060,
9,
367,
282,
10889,
199,
11616,
1124,
1765,
10701,
4345,
199,
199,
18153,
26,
199,
199,
13,
6055,
19,
2559,
199,
13,
14347,
10168,
6235,
20131,
461,
701,
6055,
19,
334,
69,
14,
71,
2020,
701,
1808,
1124,
7231,
7908,
1040,
523,
687,
26936,
551,
317,
4602,
199,
13,
437,
3879,
662,
3298,
4350,
334,
3239,
658,
37,
3298,
2372,
1933,
5015,
64,
4602,
199,
199,
32329,
436,
26391,
701,
1603,
1728,
7949,
14774,
8593,
74,
771,
14774,
9,
367,
6219,
5697,
699,
2308,
8593,
548,
5697,
17614,
9,
199,
199,
703,
485,
64,
9991,
1255,
8340,
4178,
921,
4757,
14,
9991,
14,
957,
15,
4443,
15,
1531,
604,
15,
1065,
199,
703,
485,
1765,
10701,
26,
1455,
921,
4757,
14,
7231,
14,
15144,
14,
957,
15,
33,
8872,
37,
3298,
15,
7410,
15,
11071,
17348,
15,
1765,
63,
318,
262,
852,
14,
1360,
199,
703,
485,
64,
10914,
19,
13,
555,
21221,
8340,
4178,
921,
10914,
19,
14,
25085,
14,
2308,
199,
703,
485,
10084,
551,
317,
26,
4178,
921,
7231,
14,
15144,
14,
957,
15,
2764,
199,
703,
485,
64,
37,
3298,
2372,
1933,
5015,
8340,
1455,
921,
4757,
14,
7231,
14,
15144,
14,
957,
15,
33,
8872,
37,
3298,
15,
7410,
15,
11071,
17348,
15,
37,
3298,
63,
1002,
21031,
14,
1360,
199,
199,
624,
199,
199,
646,
900,
199,
646,
2050,
199,
646,
19485,
199,
199,
2921,
275,
2050,
14,
5572,
360,
26795,
13,
3266,
358,
199,
199,
893,
26,
272,
492,
6055,
19,
272,
1890,
275,
6055,
19,
14,
1258,
360,
23075,
358,
199,
2590,
3545,
26,
272,
2512,
14,
3764,
360,
10914,
19,
365,
440,
4903,
14,
15352,
840,
813,
83,
4409,
6055,
19,
358,
199,
199,
16428,
63,
4961,
275,
499,
421,
199,
318,
485,
362,
63,
1765,
63,
17084,
8,
1765,
63,
1580,
12,
4350,
304,
272,
408,
272,
13939,
2120,
24498,
687,
662,
3298,
3261,
339,
1803,
769,
402,
469,
17305,
92,
21243,
92,
11632,
19359,
93,
367,
1924,
1305,
315,
2120,
63,
1580,
272,
408,
272,
1177,
275,
1890,
14,
11935,
63,
5054,
8,
5054,
29,
1765,
63,
1580,
12,
4350,
29,
4201,
9,
339,
327,
4520,
7907,
272,
340,
1177,
459,
9968,
418,
1137,
18410,
267,
746,
2186,
360,
10924,
4898,
2005,
9081,
3427,
78,
91,
16,
5285,
908,
8,
288,
1177,
459,
9968,
5156,
272,
2004,
63,
600,
275,
1177,
459,
2364,
5142,
2545,
2856,
23018,
418,
272,
340,
2004,
63,
600,
1137,
1926,
26,
267,
1499,
275,
283,
4476,
2004,
1056,
3086,
2004,
1233,
469,
16,
93,
3427,
78,
91,
17,
6834,
267,
746,
2186,
8,
1328,
14,
908,
8,
1205,
63,
600,
12,
1177,
430,
339,
372,
359,
84,
459,
2019,
3694,
418,
367,
307,
315,
1177,
459,
5054,
6538,
421,
199,
318,
485,
3885,
63,
5054,
8,
1765,
63,
1580,
12,
4350,
304,
272,
408,
24022,
2120,
2004,
5133,
22348,
19359,
624,
272,
1830,
715,
26,
267,
24498,
275,
485,
362,
63,
1765,
63,
17084,
8,
1765,
63,
1580,
12,
4350,
9,
267,
340,
1006,
779,
1205,
508,
283,
11632,
19359,
7,
367,
2004,
315,
24498,
4682,
288,
2512,
14,
815,
360,
37,
3298,
6527,
469,
16,
93,
22348,
19359,
1370,
908,
5102,
1370,
904,
8,
1765,
63,
1580,
1724,
288,
2059,
267,
900,
14,
4532,
8,
16428,
63,
4961,
9,
267,
2512,
14,
1757,
360,
37,
3298,
2120,
2004,
367,
6527,
469,
16,
9160,
469,
17,
5285,
908,
8,
1765,
63,
1580,
12,
24498,
430,
421,
199,
533,
15352,
840,
813,
8,
26795,
14,
4476,
304,
339,
408,
272,
3523,
1021,
367,
376,
14347,
15352,
18,
15395,
7591,
8495,
339,
14347,
662,
3298,
5074,
1265,
370,
2274,
298,
5054,
401,
1314,
787,
4840,
18714,
272,
367,
4212,
370,
4976,
314,
1124,
9991,
1255,
1040,
1414,
14,
961,
30936,
13721,
8495,
883,
1902,
272,
1255,
282,
876,
13,
11616,
662,
3298,
2120,
10701,
12,
1549,
2274,
314,
2120,
641,
314,
23158,
272,
687,
282,
2018,
1211,
14,
339,
520,
635,
2120,
63,
318,
63,
1060,
26,
876,
13,
11616,
2120,
5492,
4160,
46,
334,
33,
8872,
7337,
267,
2812,
395,
402,
314,
1824,
447,
953,
601,
78,
26,
7231,
26,
23075,
16875,
4551,
30,
16875,
751,
63,
344,
20020,
1765,
13,
7463,
8316,
6606,
30,
16875,
1450,
30,
339,
520
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
199,
3,
1898,
6900,
6219,
5697,
699,
2308,
12,
20376,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
3,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
3,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
3,
199,
199,
624,
199,
4220,
18,
15395,
7591,
4975,
367,
30936,
13721,
199,
199,
2532,
314,
10168,
10691,
26,
819,
14347,
15352,
18,
15395,
7591,
334,
37,
3298,
9,
365,
282,
4721,
590,
5269,
461,
12,
4721,
10238,
523,
3970,
10041,
2435,
626,
5171,
22067,
15333,
436,
6127,
1265,
523,
370,
16174,
1255,
13103,
641,
282,
12883,
4350,
402,
14347,
15352,
18,
4454,
14,
199,
199,
1378,
675,
662,
3298,
12,
1265,
1218,
282,
2120,
10701,
63,
4840,
626,
7890,
314,
658,
9991,
1255,
18417,
199,
1531,
367,
1373,
503,
1655,
15333,
315,
282,
2120,
503,
2435,
12,
436,
2066,
11482,
642,
199,
6243,
370,
314,
3261,
370,
1255,
314,
2120,
14,
199,
199,
2765,
658,
10914,
19,
13,
555,
21221,
18417,
4975,
6127,
1265,
370,
1218,
30936,
13721,
8495,
83,
370,
11482,
662,
3298,
199,
1040,
1765,
10701,
1040,
308,
14,
2047,
883,
1902,
986,
282,
1211,
334,
4745,
5370,
370,
314,
199,
1040,
1765,
10701,
1040,
4840,
9,
1549,
376,
14347,
7337,
2812,
334,
1060,
9,
367,
282,
10889,
199,
11616,
1124,
1765,
10701,
4345,
199,
199,
18153,
26,
199,
199,
13,
6055,
19,
2559,
199,
13,
14347,
10168,
6235,
20131,
461,
701,
6055,
19,
334,
69,
14,
71,
2020,
701,
1808,
1124,
7231,
7908,
1040,
523,
687,
26936,
551,
317,
4602,
199,
13,
437,
3879,
662,
3298,
4350,
334,
3239,
658,
37,
3298,
2372,
1933,
5015,
64,
4602,
199,
199,
32329,
436,
26391,
701,
1603,
1728,
7949,
14774,
8593,
74,
771,
14774,
9,
367,
6219,
5697,
699,
2308,
8593,
548,
5697,
17614,
9,
199,
199,
703,
485,
64,
9991,
1255,
8340,
4178,
921,
4757,
14,
9991,
14,
957,
15,
4443,
15,
1531,
604,
15,
1065,
199,
703,
485,
1765,
10701,
26,
1455,
921,
4757,
14,
7231,
14,
15144,
14,
957,
15,
33,
8872,
37,
3298,
15,
7410,
15,
11071,
17348,
15,
1765,
63,
318,
262,
852,
14,
1360,
199,
703,
485,
64,
10914,
19,
13,
555,
21221,
8340,
4178,
921,
10914,
19,
14,
25085,
14,
2308,
199,
703,
485,
10084,
551,
317,
26,
4178,
921,
7231,
14,
15144,
14,
957,
15,
2764,
199,
703,
485,
64,
37,
3298,
2372,
1933,
5015,
8340,
1455,
921,
4757,
14,
7231,
14,
15144,
14,
957,
15,
33,
8872,
37,
3298,
15,
7410,
15,
11071,
17348,
15,
37,
3298,
63,
1002,
21031,
14,
1360,
199,
199,
624,
199,
199,
646,
900,
199,
646,
2050,
199,
646,
19485,
199,
199,
2921,
275,
2050,
14,
5572,
360,
26795,
13,
3266,
358,
199,
199,
893,
26,
272,
492,
6055,
19,
272,
1890,
275,
6055,
19,
14,
1258,
360,
23075,
358,
199,
2590,
3545,
26,
272,
2512,
14,
3764,
360,
10914,
19,
365,
440,
4903,
14,
15352,
840,
813,
83,
4409,
6055,
19,
358,
199,
199,
16428,
63,
4961,
275,
499,
421,
199,
318,
485,
362,
63,
1765,
63,
17084,
8,
1765,
63,
1580,
12,
4350,
304,
272,
408,
272,
13939,
2120,
24498,
687,
662,
3298,
3261,
339,
1803,
769,
402,
469,
17305,
92,
21243,
92,
11632,
19359,
93,
367,
1924,
1305,
315,
2120,
63,
1580,
272,
408,
272,
1177,
275,
1890,
14,
11935,
63,
5054,
8,
5054,
29,
1765,
63,
1580,
12,
4350,
29,
4201,
9,
339,
327,
4520,
7907,
272,
340,
1177,
459,
9968,
418,
1137,
18410,
267,
746,
2186,
360,
10924,
4898,
2005,
9081,
3427,
78,
91,
16,
5285,
908,
8,
288,
1177,
459,
9968,
5156,
272,
2004,
63,
600,
275,
1177,
459,
2364,
5142,
2545,
2856,
23018,
418,
272,
340,
2004,
63,
600,
1137,
1926,
26,
267,
1499,
275,
283,
4476,
2004,
1056,
3086,
2004,
1233,
469,
16,
93,
3427,
78,
91,
17,
6834,
267,
746,
2186,
8,
1328,
14,
908,
8,
1205,
63,
600,
12,
1177,
430,
339,
372,
359,
84,
459,
2019,
3694,
418,
367,
307,
315,
1177,
459,
5054,
6538,
421,
199,
318,
485,
3885,
63,
5054,
8,
1765,
63,
1580,
12,
4350,
304,
272,
408,
24022,
2120,
2004,
5133,
22348,
19359,
624,
272,
1830,
715,
26,
267,
24498,
275,
485,
362,
63,
1765,
63,
17084,
8,
1765,
63,
1580,
12,
4350,
9,
267,
340,
1006,
779,
1205,
508,
283,
11632,
19359,
7,
367,
2004,
315,
24498,
4682,
288,
2512,
14,
815,
360,
37,
3298,
6527,
469,
16,
93,
22348,
19359,
1370,
908,
5102,
1370,
904,
8,
1765,
63,
1580,
1724,
288,
2059,
267,
900,
14,
4532,
8,
16428,
63,
4961,
9,
267,
2512,
14,
1757,
360,
37,
3298,
2120,
2004,
367,
6527,
469,
16,
9160,
469,
17,
5285,
908,
8,
1765,
63,
1580,
12,
24498,
430,
421,
199,
533,
15352,
840,
813,
8,
26795,
14,
4476,
304,
339,
408,
272,
3523,
1021,
367,
376,
14347,
15352,
18,
15395,
7591,
8495,
339,
14347,
662,
3298,
5074,
1265,
370,
2274,
298,
5054,
401,
1314,
787,
4840,
18714,
272,
367,
4212,
370,
4976,
314,
1124,
9991,
1255,
1040,
1414,
14,
961,
30936,
13721,
8495,
883,
1902,
272,
1255,
282,
876,
13,
11616,
662,
3298,
2120,
10701,
12,
1549,
2274,
314,
2120,
641,
314,
23158,
272,
687,
282,
2018,
1211,
14,
339,
520,
635,
2120,
63,
318,
63,
1060,
26,
876,
13,
11616,
2120,
5492,
4160,
46,
334,
33,
8872,
7337,
267,
2812,
395,
402,
314,
1824,
447,
953,
601,
78,
26,
7231,
26,
23075,
16875,
4551,
30,
16875,
751,
63,
344,
20020,
1765,
13,
7463,
8316,
6606,
30,
16875,
1450,
30,
339,
520,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
kennedyshead/home-assistant
|
homeassistant/helpers/json.py
|
3
|
1132
|
"""Helpers to help with encoding Home Assistant objects in JSON."""
from datetime import datetime, timedelta
import json
from typing import Any
class JSONEncoder(json.JSONEncoder):
"""JSONEncoder that supports Home Assistant objects."""
def default(self, o: Any) -> Any:
"""Convert Home Assistant objects.
Hand other objects to the original method.
"""
if isinstance(o, datetime):
return o.isoformat()
if isinstance(o, set):
return list(o)
if hasattr(o, "as_dict"):
return o.as_dict()
return json.JSONEncoder.default(self, o)
class ExtendedJSONEncoder(JSONEncoder):
"""JSONEncoder that supports Home Assistant objects and falls back to repr(o)."""
def default(self, o: Any) -> Any:
"""Convert certain objects.
Fall back to repr(o).
"""
if isinstance(o, timedelta):
return {"__type": str(type(o)), "total_seconds": o.total_seconds()}
try:
return super().default(o)
except TypeError:
return {"__type": str(type(o)), "repr": repr(o)}
|
apache-2.0
|
[
624,
4433,
83,
370,
1720,
543,
2644,
14621,
3709,
18832,
2251,
315,
4840,
1041,
199,
504,
2197,
492,
2197,
12,
6871,
199,
646,
2022,
199,
504,
14090,
492,
6184,
421,
199,
533,
4840,
6679,
8,
1001,
14,
23069,
304,
272,
408,
23069,
626,
5171,
14621,
3709,
18832,
2251,
1041,
339,
347,
849,
8,
277,
12,
312,
26,
6184,
9,
1035,
6184,
26,
267,
408,
7306,
14621,
3709,
18832,
2251,
14,
398,
18405,
1163,
2251,
370,
314,
3379,
1083,
14,
267,
408,
267,
340,
1228,
8,
79,
12,
2197,
304,
288,
372,
312,
14,
17070,
342,
267,
340,
1228,
8,
79,
12,
663,
304,
288,
372,
769,
8,
79,
9,
267,
340,
2688,
8,
79,
12,
298,
305,
63,
807,
2349,
288,
372,
312,
14,
305,
63,
807,
342,
398,
372,
2022,
14,
23069,
14,
885,
8,
277,
12,
312,
9,
421,
199,
533,
13706,
23069,
8,
23069,
304,
272,
408,
23069,
626,
5171,
14621,
3709,
18832,
2251,
436,
26945,
1771,
370,
4700,
8,
79,
10477,
339,
347,
849,
8,
277,
12,
312,
26,
6184,
9,
1035,
6184,
26,
267,
408,
7306,
9842,
2251,
14,
398,
481,
452,
1771,
370,
4700,
8,
79,
680,
267,
408,
267,
340,
1228,
8,
79,
12,
6871,
304,
288,
372,
2420,
363,
466,
582,
620,
8,
466,
8,
79,
1826,
298,
2923,
63,
4515,
582,
312,
14,
2923,
63,
4515,
12737,
267,
862,
26,
288,
372,
1613,
1252,
885,
8,
79,
9,
267,
871,
3146,
26,
288,
372,
2420,
363,
466,
582,
620,
8,
466,
8,
79,
1826,
298,
2722,
582,
4700,
8,
79,
6769,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
4433,
83,
370,
1720,
543,
2644,
14621,
3709,
18832,
2251,
315,
4840,
1041,
199,
504,
2197,
492,
2197,
12,
6871,
199,
646,
2022,
199,
504,
14090,
492,
6184,
421,
199,
533,
4840,
6679,
8,
1001,
14,
23069,
304,
272,
408,
23069,
626,
5171,
14621,
3709,
18832,
2251,
1041,
339,
347,
849,
8,
277,
12,
312,
26,
6184,
9,
1035,
6184,
26,
267,
408,
7306,
14621,
3709,
18832,
2251,
14,
398,
18405,
1163,
2251,
370,
314,
3379,
1083,
14,
267,
408,
267,
340,
1228,
8,
79,
12,
2197,
304,
288,
372,
312,
14,
17070,
342,
267,
340,
1228,
8,
79,
12,
663,
304,
288,
372,
769,
8,
79,
9,
267,
340,
2688,
8,
79,
12,
298,
305,
63,
807,
2349,
288,
372,
312,
14,
305,
63,
807,
342,
398,
372,
2022,
14,
23069,
14,
885,
8,
277,
12,
312,
9,
421,
199,
533,
13706,
23069,
8,
23069,
304,
272,
408,
23069,
626,
5171,
14621,
3709,
18832,
2251,
436,
26945,
1771,
370,
4700,
8,
79,
10477,
339,
347,
849,
8,
277,
12,
312,
26,
6184,
9,
1035,
6184,
26,
267,
408,
7306,
9842,
2251,
14,
398,
481,
452,
1771,
370,
4700,
8,
79,
680,
267,
408,
267,
340,
1228,
8,
79,
12,
6871,
304,
288,
372,
2420,
363,
466,
582,
620,
8,
466,
8,
79,
1826,
298,
2923,
63,
4515,
582,
312,
14,
2923,
63,
4515,
12737,
267,
862,
26,
288,
372,
1613,
1252,
885,
8,
79,
9,
267,
871,
3146,
26,
288,
372,
2420,
363,
466,
582,
620,
8,
466,
8,
79,
1826,
298,
2722,
582,
4700,
8,
79,
6769,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
daanwierstra/pybrain
|
pybrain/rl/learners/blackboxoptimizers/evolution/nsga2.py
|
1
|
7825
|
from scipy import array
from pybrain.rl.learners.blackboxoptimizers.evolution.ga import GA
import collections
__author__ = 'Justin Bayer, Tom Schaul, {justin,tom}@idsia.ch'
# TODO: not very elegant, because of the conversions between tuples and arrays all the time...
class MultiObjectiveGA(GA):
""" Multi-objective Genetic Algorithm: the fitness is a vector with one entry per objective.
By default we use NSGA-II selection. """
topproportion = 0.5
elitism = True
popsize = 100
mutationStdDev = 1.
allowEquality = True
startPop = None
def __init__(self, *args, **kwargs):
""" x0 is assumed to be an array, but then converted to a tuple.
The algorithm returns all individuals in the Pareto-front (and their fitnesses). """
GA.__init__(self, *args, **kwargs)
self.bestEvaluation = []
self.bestEvaluable = [tuple(self.x0)]
self.fitnesses = {}
def stoppingCriterion(self):
# TODO: what can be put here?
return False
def initPopulation(self):
if self.startPop == None:
GA.initPopulation(self)
self.currentpop = map(tuple, self.currentpop)
else:
self.currentpop = self.startPop
def mutated(self, indiv):
return tuple(GA.mutated(self,array(indiv)))
def oneGeneration(self):
""" do one generation step """
# evaluate fitness
for indiv in self.currentpop:
if indiv not in self.fitnesses:
self.fitnesses[indiv] = self.evaluator(array(indiv))
self.steps += 1
self.allgenerations.append((self.currentpop))
if self.elitism:
self.bestEvaluable = list(non_dominated_front(self.currentpop,
key=lambda x: self.fitnesses[x],
allowequality = self.allowEquality))
else:
self.bestEvaluable = list(non_dominated_front(self.currentpop+self.bestEvaluable,
key=lambda x: self.fitnesses[x],
allowequality = self.allowEquality))
self.bestEvaluation = map(lambda indiv: self.fitnesses[indiv], self.bestEvaluable)
self.produceOffspring()
def select(self):
return nsga2select(self.currentpop, self.fitnesses, self.selectionSize(), self.allowEquality)
def nsga2select(population, fitnesses, survivors, allowequality = True):
"""The NSGA-II selection strategy (Deb et al., 2002).
The number of individuals that survive is given by the survivors parameter."""
fronts = non_dominated_sort(population,
key=lambda x: fitnesses[x],
allowequality = allowequality)
individuals = set()
for front in fronts:
remaining = survivors - len(individuals)
if not remaining > 0:
break
if len(front) > remaining:
# If the current front does not fit in the spots left, use those
# that have the biggest crowding distance.
crowd_dist = crowding_distance(front, fitnesses)
front = sorted(front, key=lambda x: crowd_dist[x], reverse=True)
front = set(front[:remaining])
individuals |= front
return list(individuals)
def crowding_distance(individuals, fitnesses):
""" Crowding distance-measure for multiple objectives. """
distances = collections.defaultdict(lambda: 0)
individuals = list(individuals)
# Infer the number of objectives by looking at the fitness of the first.
n_obj = len(fitnesses[individuals[0]])
for i in xrange(n_obj):
individuals.sort(key=lambda x: fitnesses[x][i])
# normalization between 0 and 1.
normalization = float(fitnesses[individuals[0]][i] - fitnesses[individuals[-1]][i])
# Make sure the boundary points are always selected.
distances[individuals[0]] = 1e100
distances[individuals[-1]] = 1e100
tripled = zip(individuals, individuals[1:-1], individuals[2:])
for pre, ind, post in tripled:
distances[ind] += (fitnesses[pre][i] - fitnesses[post][i]) / normalization
return distances
def _non_dominated_front_old(iterable, key=lambda x: x, allowequality = True):
"""Return a subset of items from iterable which are not dominated by any
other item in iterable."""
items = list(iterable)
keys = dict((i, key(i)) for i in items)
dim = len(keys.values()[0])
if any(dim != len(k) for k in keys.values()):
raise ValueError("Wrong tuple size.")
# Make a dictionary that holds the items another item dominates.
dominations = collections.defaultdict(lambda: [])
for i in items:
for j in items:
if allowequality:
if all(keys[i][k] < keys[j][k] for k in xrange(dim)):
dominations[i].append(j)
else:
if all(keys[i][k] <= keys[j][k] for k in xrange(dim)):
dominations[i].append(j)
dominates = lambda i, j: j in dominations[i]
res = set()
items = set(items)
for i in items:
res.add(i)
for j in list(res):
if i is j:
continue
if dominates(j, i):
res.remove(i)
break
elif dominates(i, j):
res.remove(j)
return res
def _non_dominated_front_fast(iterable, key=lambda x: x, allowequality = True):
"""Return a subset of items from iterable which are not dominated by any
other item in iterable.
Faster version.
"""
items = list(iterable)
keys = dict((i, key(i)) for i in items)
dim = len(keys.values()[0])
dominations = {}
for i in items:
for j in items:
good = True
if allowequality:
for k in xrange(dim):
if keys[i][k] >= keys[j][k]:
good = False
break
else:
for k in xrange(dim):
if keys[i][k] > keys[j][k]:
good = False
break
if good:
dominations[(i,j)] = None
res = set()
items = set(items)
for i in items:
res.add(i)
for j in list(res):
if i is j:
continue
if (j,i) in dominations:
res.remove(i)
break
elif (i,j) in dominations:
res.remove(j)
return res
def _non_dominated_front_merge(iterable, key=lambda x: x, allowequality = True):
items = list(iterable)
l = len(items)
if l > 20:
part1 = list(_non_dominated_front_merge(items[:l/2], key, allowequality))
part2 = list(_non_dominated_front_merge(items[l/2:], key, allowequality))
if len(part1) >= l/3 or len(part2) >= l/3:
return _non_dominated_front_fast(part1+part2, key, allowequality)
else:
return _non_dominated_front_merge(part1+part2, key, allowequality)
else:
return _non_dominated_front_fast(items, key, allowequality)
non_dominated_front = _non_dominated_front_merge
def non_dominated_sort(iterable, key=lambda x: x, allowequality = True):
"""Return a list that is sorted in a non-dominating fashion.
Keys have to be n-tuple."""
items = set(iterable)
fronts = []
while items:
front = non_dominated_front(items, key, allowequality)
items -= front
fronts.append(front)
return fronts
|
bsd-3-clause
|
[
504,
7026,
492,
1625,
199,
504,
1134,
22246,
14,
4308,
14,
4643,
1192,
14,
8399,
1977,
6433,
6315,
14,
6857,
3347,
14,
5294,
492,
598,
33,
199,
646,
5055,
199,
199,
363,
2502,
363,
275,
283,
22850,
262,
29434,
281,
12,
21644,
428,
9518,
348,
12,
469,
4764,
262,
12,
3151,
93,
32,
344,
10971,
14,
335,
7,
199,
199,
3,
3254,
26,
440,
7437,
325,
4170,
867,
12,
2952,
402,
314,
24796,
3382,
6346,
436,
6572,
1006,
314,
900,
1396,
199,
199,
533,
6879,
29104,
9741,
8,
9741,
304,
272,
408,
6879,
13,
24091,
598,
6349,
764,
23823,
26,
314,
5542,
4171,
365,
282,
5477,
543,
1373,
2397,
1126,
20632,
14,
272,
4885,
849,
781,
675,
653,
4254,
33,
13,
8921,
7267,
14,
408,
2286,
2746,
4469,
15029,
275,
378,
14,
21,
272,
28214,
280,
3300,
275,
715,
2286,
4560,
890,
275,
2948,
272,
31083,
11976,
12680,
275,
413,
14,
2286,
2040,
22977,
275,
715,
2286,
1343,
9606,
275,
488,
5493,
347,
636,
826,
721,
277,
12,
627,
589,
12,
1011,
958,
304,
267,
408,
671,
16,
365,
10826,
370,
506,
376,
1625,
12,
1325,
2066,
6702,
370,
282,
2008,
14,
4960,
710,
5563,
2529,
1006,
8212,
83,
315,
314,
510,
1530,
475,
13,
14708,
334,
460,
3932,
5542,
17775,
874,
680,
408,
267,
598,
33,
855,
826,
721,
277,
12,
627,
589,
12,
1011,
958,
9,
267,
291,
14,
7010,
29786,
275,
942,
267,
291,
14,
7010,
10006,
85,
461,
275,
359,
2960,
8,
277,
14,
88,
16,
1874,
267,
291,
14,
3269,
17775,
874,
275,
1052,
258,
2286,
347,
23599,
35,
7527,
265,
8,
277,
304,
267,
327,
3254,
26,
4052,
883,
506,
5324,
2348,
31,
267,
372,
756,
2286,
347,
4205,
31824,
8,
277,
304,
267,
340,
291,
14,
928,
9606,
508,
488,
26,
288,
598,
33,
14,
826,
31824,
8,
277,
9,
288,
291,
14,
1818,
1935,
275,
2341,
8,
2960,
12,
291,
14,
1818,
1935,
9,
267,
587,
26,
288,
291,
14,
1818,
1935,
275,
291,
14,
928,
9606,
881,
272,
347,
8567,
972,
8,
277,
12,
2539,
86,
304,
267,
372,
2008,
8,
9741,
14,
6552,
972,
8,
277,
12,
1144,
8,
262,
3015,
1724,
489,
272,
347,
1373,
18514,
8,
277,
304,
267,
408,
886,
1373,
10152,
3650,
408,
267,
327,
9352,
5542,
4171,
267,
367,
2539,
86,
315,
291,
14,
1818,
1935,
26,
288,
340,
2539,
86,
440,
315,
291,
14,
3269,
17775,
874,
26,
355,
291,
14,
3269,
17775,
874,
59,
262,
3015,
61,
275,
291,
14,
27406,
8,
1144,
8,
262,
3015,
430,
355,
291,
14,
5895,
847,
413,
2728,
291,
14,
452,
2038,
1298,
14,
740,
1332,
277,
14,
1818,
1935,
430,
267,
340,
291,
14,
18865,
280,
3300,
26,
258,
288,
291,
14,
7010,
10006,
85,
461,
275,
769,
8,
2865,
63,
4556,
23831,
63,
14708,
8,
277,
14,
1818,
1935,
12,
12933,
790,
29,
2734,
671,
26,
291,
14,
3269,
17775,
874,
59,
88,
467,
12933,
2040,
20982,
275,
291,
14,
3306,
22977,
430,
267,
587,
26,
288,
291,
14,
7010,
10006,
85,
461,
275,
769,
8,
2865,
63,
4556,
23831,
63,
14708,
8,
277,
14,
1818,
1935,
11,
277,
14,
7010,
10006,
85,
461,
12,
12933,
790,
29,
2734,
671,
26,
291,
14,
3269,
17775,
874,
59,
88,
467,
12933,
2040,
20982,
275,
291,
14,
3306,
22977,
430,
267,
291,
14,
7010,
29786,
275,
2341,
8,
2734,
2539,
86,
26,
291,
14,
3269,
17775,
874,
59,
262,
3015,
467,
291,
14,
7010,
10006,
85,
461,
9,
2728,
291,
14,
7832,
5195,
26008,
342,
5493,
347,
3504,
8,
277,
304,
267,
372,
700,
5294,
18,
2416,
8,
277,
14,
1818,
1935,
12,
291,
14,
3269,
17775,
874,
12,
291,
14,
5592,
2320,
1062,
291,
14,
3306,
22977,
9,
258,
326,
16872,
199,
318,
700,
5294,
18,
2416,
8,
16003,
12,
5542,
17775,
874,
12,
6296,
433,
86,
1384,
12,
2040,
20982,
275,
715,
304,
272,
408,
1918,
653,
4254,
33,
13,
8921,
7267,
10054,
334,
872,
66,
10844,
741,
2020,
14790,
680,
272,
710,
1329,
402,
8212,
83,
626,
6296,
433,
432,
365,
1627,
701,
314,
6296,
433,
86,
1384,
2725,
1041,
272,
289,
2641,
1086,
275,
2222,
63,
4556,
23831,
63,
3191,
8,
16003,
12,
1816,
790,
29,
2734,
671,
26,
5542,
17775,
874,
59,
88,
467,
1816,
2040,
20982,
275,
2040,
20982,
9,
272,
8212,
83,
275,
663,
342,
272,
367,
13738,
315,
289,
2641,
1086,
26,
267,
7971,
275,
6296,
433,
86,
1384,
446,
822,
8,
23001,
83,
9,
267,
340,
440,
7971,
690,
378,
26,
288,
2059,
267,
340,
822,
8,
14708,
9,
690,
7971,
26,
288,
327,
982,
314,
1453,
13738,
1630,
440,
5542,
315,
314,
2249,
16673,
3602,
12,
675,
5204,
288,
327,
626,
1172,
314,
7282,
3199,
286,
1143,
1098,
6033,
14,
288,
286,
1143,
68,
63,
2686,
275,
286,
1143,
1098,
63,
5590,
8,
14708,
12,
5542,
17775,
874,
9,
288,
13738,
275,
3355,
8,
14708,
12,
790,
29,
2734,
671,
26,
286,
1143,
68,
63,
2686,
59,
88,
467,
3837,
29,
549,
9,
288,
13738,
275,
663,
8,
14708,
1491,
11266,
566,
267,
8212,
83,
8901,
13738,
2286,
372,
769,
8,
23001,
83,
9,
523,
199,
318,
286,
1143,
1098,
63,
5590,
8,
23001,
83,
12,
5542,
17775,
874,
304,
272,
408,
445,
1143,
1098,
6033,
13,
9580,
367,
3663,
1559,
825,
7301,
14,
408,
272,
15108,
275,
5055,
14,
21501,
8,
2734,
26,
378,
9,
272,
8212,
83,
275,
769,
8,
23001,
83,
9,
272,
327,
1010,
2412,
314,
1329,
402,
1559,
825,
7301,
701,
10023,
737,
314,
5542,
4171,
402,
314,
1642,
14,
272,
302,
63,
1113,
275,
822,
8,
3269,
17775,
874,
59,
23001,
83,
59,
16,
3934,
272,
367,
284,
315,
4945,
8,
78,
63,
1113,
304,
267,
8212,
83,
14,
3191,
8,
498,
29,
2734,
671,
26,
5542,
17775,
874,
59,
88,
1527,
73,
566,
267,
327,
16973,
3382,
378,
436,
413,
14,
267,
16973,
275,
2069,
8,
3269,
17775,
874,
59,
23001,
83,
59,
16,
22235,
73,
61,
446,
5542,
17775,
874,
59,
23001,
83,
1988,
17,
22235,
73,
566,
267,
327,
4155,
3238,
314,
8424,
4501,
787,
3544,
4895,
14,
267,
15108,
59,
23001
] |
[
7026,
492,
1625,
199,
504,
1134,
22246,
14,
4308,
14,
4643,
1192,
14,
8399,
1977,
6433,
6315,
14,
6857,
3347,
14,
5294,
492,
598,
33,
199,
646,
5055,
199,
199,
363,
2502,
363,
275,
283,
22850,
262,
29434,
281,
12,
21644,
428,
9518,
348,
12,
469,
4764,
262,
12,
3151,
93,
32,
344,
10971,
14,
335,
7,
199,
199,
3,
3254,
26,
440,
7437,
325,
4170,
867,
12,
2952,
402,
314,
24796,
3382,
6346,
436,
6572,
1006,
314,
900,
1396,
199,
199,
533,
6879,
29104,
9741,
8,
9741,
304,
272,
408,
6879,
13,
24091,
598,
6349,
764,
23823,
26,
314,
5542,
4171,
365,
282,
5477,
543,
1373,
2397,
1126,
20632,
14,
272,
4885,
849,
781,
675,
653,
4254,
33,
13,
8921,
7267,
14,
408,
2286,
2746,
4469,
15029,
275,
378,
14,
21,
272,
28214,
280,
3300,
275,
715,
2286,
4560,
890,
275,
2948,
272,
31083,
11976,
12680,
275,
413,
14,
2286,
2040,
22977,
275,
715,
2286,
1343,
9606,
275,
488,
5493,
347,
636,
826,
721,
277,
12,
627,
589,
12,
1011,
958,
304,
267,
408,
671,
16,
365,
10826,
370,
506,
376,
1625,
12,
1325,
2066,
6702,
370,
282,
2008,
14,
4960,
710,
5563,
2529,
1006,
8212,
83,
315,
314,
510,
1530,
475,
13,
14708,
334,
460,
3932,
5542,
17775,
874,
680,
408,
267,
598,
33,
855,
826,
721,
277,
12,
627,
589,
12,
1011,
958,
9,
267,
291,
14,
7010,
29786,
275,
942,
267,
291,
14,
7010,
10006,
85,
461,
275,
359,
2960,
8,
277,
14,
88,
16,
1874,
267,
291,
14,
3269,
17775,
874,
275,
1052,
258,
2286,
347,
23599,
35,
7527,
265,
8,
277,
304,
267,
327,
3254,
26,
4052,
883,
506,
5324,
2348,
31,
267,
372,
756,
2286,
347,
4205,
31824,
8,
277,
304,
267,
340,
291,
14,
928,
9606,
508,
488,
26,
288,
598,
33,
14,
826,
31824,
8,
277,
9,
288,
291,
14,
1818,
1935,
275,
2341,
8,
2960,
12,
291,
14,
1818,
1935,
9,
267,
587,
26,
288,
291,
14,
1818,
1935,
275,
291,
14,
928,
9606,
881,
272,
347,
8567,
972,
8,
277,
12,
2539,
86,
304,
267,
372,
2008,
8,
9741,
14,
6552,
972,
8,
277,
12,
1144,
8,
262,
3015,
1724,
489,
272,
347,
1373,
18514,
8,
277,
304,
267,
408,
886,
1373,
10152,
3650,
408,
267,
327,
9352,
5542,
4171,
267,
367,
2539,
86,
315,
291,
14,
1818,
1935,
26,
288,
340,
2539,
86,
440,
315,
291,
14,
3269,
17775,
874,
26,
355,
291,
14,
3269,
17775,
874,
59,
262,
3015,
61,
275,
291,
14,
27406,
8,
1144,
8,
262,
3015,
430,
355,
291,
14,
5895,
847,
413,
2728,
291,
14,
452,
2038,
1298,
14,
740,
1332,
277,
14,
1818,
1935,
430,
267,
340,
291,
14,
18865,
280,
3300,
26,
258,
288,
291,
14,
7010,
10006,
85,
461,
275,
769,
8,
2865,
63,
4556,
23831,
63,
14708,
8,
277,
14,
1818,
1935,
12,
12933,
790,
29,
2734,
671,
26,
291,
14,
3269,
17775,
874,
59,
88,
467,
12933,
2040,
20982,
275,
291,
14,
3306,
22977,
430,
267,
587,
26,
288,
291,
14,
7010,
10006,
85,
461,
275,
769,
8,
2865,
63,
4556,
23831,
63,
14708,
8,
277,
14,
1818,
1935,
11,
277,
14,
7010,
10006,
85,
461,
12,
12933,
790,
29,
2734,
671,
26,
291,
14,
3269,
17775,
874,
59,
88,
467,
12933,
2040,
20982,
275,
291,
14,
3306,
22977,
430,
267,
291,
14,
7010,
29786,
275,
2341,
8,
2734,
2539,
86,
26,
291,
14,
3269,
17775,
874,
59,
262,
3015,
467,
291,
14,
7010,
10006,
85,
461,
9,
2728,
291,
14,
7832,
5195,
26008,
342,
5493,
347,
3504,
8,
277,
304,
267,
372,
700,
5294,
18,
2416,
8,
277,
14,
1818,
1935,
12,
291,
14,
3269,
17775,
874,
12,
291,
14,
5592,
2320,
1062,
291,
14,
3306,
22977,
9,
258,
326,
16872,
199,
318,
700,
5294,
18,
2416,
8,
16003,
12,
5542,
17775,
874,
12,
6296,
433,
86,
1384,
12,
2040,
20982,
275,
715,
304,
272,
408,
1918,
653,
4254,
33,
13,
8921,
7267,
10054,
334,
872,
66,
10844,
741,
2020,
14790,
680,
272,
710,
1329,
402,
8212,
83,
626,
6296,
433,
432,
365,
1627,
701,
314,
6296,
433,
86,
1384,
2725,
1041,
272,
289,
2641,
1086,
275,
2222,
63,
4556,
23831,
63,
3191,
8,
16003,
12,
1816,
790,
29,
2734,
671,
26,
5542,
17775,
874,
59,
88,
467,
1816,
2040,
20982,
275,
2040,
20982,
9,
272,
8212,
83,
275,
663,
342,
272,
367,
13738,
315,
289,
2641,
1086,
26,
267,
7971,
275,
6296,
433,
86,
1384,
446,
822,
8,
23001,
83,
9,
267,
340,
440,
7971,
690,
378,
26,
288,
2059,
267,
340,
822,
8,
14708,
9,
690,
7971,
26,
288,
327,
982,
314,
1453,
13738,
1630,
440,
5542,
315,
314,
2249,
16673,
3602,
12,
675,
5204,
288,
327,
626,
1172,
314,
7282,
3199,
286,
1143,
1098,
6033,
14,
288,
286,
1143,
68,
63,
2686,
275,
286,
1143,
1098,
63,
5590,
8,
14708,
12,
5542,
17775,
874,
9,
288,
13738,
275,
3355,
8,
14708,
12,
790,
29,
2734,
671,
26,
286,
1143,
68,
63,
2686,
59,
88,
467,
3837,
29,
549,
9,
288,
13738,
275,
663,
8,
14708,
1491,
11266,
566,
267,
8212,
83,
8901,
13738,
2286,
372,
769,
8,
23001,
83,
9,
523,
199,
318,
286,
1143,
1098,
63,
5590,
8,
23001,
83,
12,
5542,
17775,
874,
304,
272,
408,
445,
1143,
1098,
6033,
13,
9580,
367,
3663,
1559,
825,
7301,
14,
408,
272,
15108,
275,
5055,
14,
21501,
8,
2734,
26,
378,
9,
272,
8212,
83,
275,
769,
8,
23001,
83,
9,
272,
327,
1010,
2412,
314,
1329,
402,
1559,
825,
7301,
701,
10023,
737,
314,
5542,
4171,
402,
314,
1642,
14,
272,
302,
63,
1113,
275,
822,
8,
3269,
17775,
874,
59,
23001,
83,
59,
16,
3934,
272,
367,
284,
315,
4945,
8,
78,
63,
1113,
304,
267,
8212,
83,
14,
3191,
8,
498,
29,
2734,
671,
26,
5542,
17775,
874,
59,
88,
1527,
73,
566,
267,
327,
16973,
3382,
378,
436,
413,
14,
267,
16973,
275,
2069,
8,
3269,
17775,
874,
59,
23001,
83,
59,
16,
22235,
73,
61,
446,
5542,
17775,
874,
59,
23001,
83,
1988,
17,
22235,
73,
566,
267,
327,
4155,
3238,
314,
8424,
4501,
787,
3544,
4895,
14,
267,
15108,
59,
23001,
0
] |
[
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|
cualbondi/cualbondi.com.ar
|
settings.py
|
1
|
11882
|
# Django settings for cualbondi project.
import os
CUALBONDI_ENV = os.environ.get('CUALBONDI_ENV', 'development')
DEBUG = True
TEMPLATE_DEBUG = DEBUG
ALLOWED_HOSTS = ['*',]
LOGIN_REDIRECT_URL = '/'
ABSOLUTE_URL_OVERRIDES = {
'auth.user': lambda u: "/usuarios/%s/" % u.username,
}
ADMINS = (
# ('Your Name', 'your_email@example.com'),
)
DEFAULT_FROM_EMAIL = "info@cualbondi.com.ar"
MANAGERS = ADMINS
BASE_PATH = os.path.dirname(os.path.abspath(__file__))
DATABASES = {}
USE_CACHE = True
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
'LOCATION': '127.0.0.1:11211',
}
}
CACHE_TIMEOUT = 60*60
# Variables personalizadas
RADIO_ORIGEN_DEFAULT = 200
RADIO_DESTINO_DEFAULT = 200
LONGITUD_PAGINA = 5
# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# On Unix systems, a value of None will cause Django to use the same
# timezone as the operating system.
# If running in a Windows environment this must be set to the same as your
# system time zone.
TIME_ZONE = 'America/Argentina/Buenos_Aires'
# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'es-ar'
SITE_ID = 1
# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = False
# If you set this to False, Django will not format dates, numbers and
# calendars according to the current locale
USE_L10N = True
# Absolute filesystem path to the directory that will hold user-uploaded files.
# Example: "/home/media/media.lawrence.com/media/"
MEDIA_ROOT = os.path.join(BASE_PATH, os.path.pardir, 'media')
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
MEDIA_URL = 'media/'
# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/home/media/media.lawrence.com/static/"
STATIC_ROOT = os.path.join(BASE_PATH, os.path.pardir, 'static')
# URL prefix for static files.
# Example: "http://media.lawrence.com/static/"
STATIC_URL = '/static/'
# URL prefix for admin static files -- CSS, JavaScript and images.
# Make sure to use a trailing slash.
# Examples: "http://foo.com/static/admin/", "/static/admin/".
ADMIN_MEDIA_PREFIX = '/static/admin/'
# Additional locations of static files
STATICFILES_DIRS = (
# Put strings here, like "/home/html/static" or "C:/www/django/static".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
)
# List of finder classes that know how to find static files in
# various locations.
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
)
# Make this unique, and don't share it with anybody.
SECRET_KEY = '=tr&%05vw6&s4eoq)wdj(d&(56#cq@5k0b-c$^v6vr)#%e(c+&'
# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
# 'django.template.loaders.eggs.Loader',
)
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'apps.core.middleware.WhodidMiddleware',
'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
)
AUTHENTICATION_BACKENDS = (
'social.backends.facebook.FacebookAppOAuth2',
'social.backends.facebook.FacebookOAuth2',
'social_auth.backends.facebook.FacebookBackend',
'django.contrib.auth.backends.ModelBackend',
)
TEMPLATE_CONTEXT_PROCESSORS = (
'social.apps.django_app.context_processors.backends',
'social.apps.django_app.context_processors.login_redirect',
"django.contrib.auth.context_processors.auth",
"django.core.context_processors.debug",
"django.core.context_processors.i18n",
"django.core.context_processors.media",
"django.core.context_processors.static",
"django.contrib.messages.context_processors.messages",
"django.core.context_processors.request",
"apps.core.context_processors.lista_ciudades",
"apps.core.context_processors.get_ciudad_actual",
"apps.core.context_processors.show_android_alert",
"apps.core.context_processors.home_url",
"apps.core.context_processors.facebook_app_id",
)
ROOT_URLCONF = 'urls'
TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
os.path.join(os.path.dirname(__file__),'templates'),
)
GOOGLE_API = "//maps.google.com/maps/api/js?v=3.6&sensor=false"
INSTALLED_APPS = (
'social.apps.django_app.default',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'django.contrib.gis',
'django.contrib.flatpages',
'django.contrib.sitemaps',
# Externas
'bootstrap_toolkit',
'floppyforms',
'imagekit',
'leaflet',
'piston',
# 'moderacion',
# 'editor',
# 'django_extensions',
'rest_framework',
'rest_framework_tracking',
'django_nose',
# Propias
'apps.api2',
'apps.catastro',
'apps.core',
'apps.usuarios',
'apps.anuncios',
'apps.mobile_updates',
'apps.editor',
)
REST_FRAMEWORK = {
'DEFAULT_PERMISSION_CLASSES': ('apps.api2.permissions.ReadOnly',),
'PAGE_SIZE': 10,
'DEFAULT_RENDERER_CLASSES': (
'rest_framework_jsonp.renderers.JSONPRenderer',
),
}
TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'
# A sample logging configuration. The only tangible logging
# performed by this configuration is to send an email to
# the site admins on every HTTP 500 error.
# See http://docs.djangoproject.com/en/dev/topics/logging for
# more details on how to customize your logging configuration.
here = lambda *x: os.path.join(os.path.dirname(os.path.realpath(__file__)), *x)
LOGGING = {
'version': 1,
'filters': {
'require_debug_false': {
'()': 'django.utils.log.RequireDebugFalse'
}
},
'formatters': {
'simple': {
'format': '%(levelname)s | %(message)s'
},
'json': {
'()': 'django_log_formatter_json.JSONFormatter',
}
},
'handlers': {
'mail_admins': {
'level': 'ERROR',
'filters': ['require_debug_false'],
'class': 'django.utils.log.AdminEmailHandler'
},
'console':{
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'formatter': 'json'
},
# 'file': {
# 'level': 'DEBUG',
# 'class': 'logging.FileHandler',
# 'filename': '/tmp/django.log',
# }
},
'loggers': {
'django.request': {
'handlers': ['console'],
'level': 'ERROR',
'propagate': True,
},
'logstash': {
'handlers': ['console'],
'level': 'DEBUG',
'propagate': True
}
},
}
if CUALBONDI_ENV == 'production':
LOGGING.update({
'handlers': {
'logstash': {
'level': 'DEBUG',
'class': 'logstash.LogstashHandler',
'host': '78.47.196.202', # stats.cualbondi.com.ar
'port': 5000,
'version': 1,
'message_type': 'logstash',
'fqdn': False,
'tags': [],
},
},
'loggers': {
'django.request': {
'handlers': ['logstash'],
'level': 'DEBUG',
'propagate': True,
},
'logstash': {
'handlers': ['logstash'],
'level': 'DEBUG',
'propagate': True,
},
},
})
FACEBOOK_APP_ID = "516530425068934"
FACEBOOK_API_SECRET = 'f90d27d49f50939996db0f299dec129d'
FACEBOOK_EXTENDED_PERMISSIONS = ['email']
SOCIAL_AUTH_FACEBOOK_KEY="516530425068934"
SOCIAL_AUTH_FACEBOOK_SECRET='f90d27d49f50939996db0f299dec129d'
SOCIAL_AUTH_FACEBOOK_SCOPE = ['email']
HOME_URL = "http://cualbondi.com.ar"
EMAIL_HOST = 'mail.cualbondi.com.ar'
EMAIL_PORT = 25
from settings_local import *
INSTALLED_APPS += LOCAL_INSTALLED_APPS
else:
DATABASES = {
'default': {
'ENGINE': 'django.contrib.gis.db.backends.postgis',
'NAME': 'geocualbondidb',
'USER': 'postgres',
'PASSWORD': '',
'HOST': '',
'PORT': '',
}
}
#MIDDLEWARE_CLASSES = ('debug_panel.middleware.DebugPanelMiddleware', ) + MIDDLEWARE_CLASSES
FACEBOOK_APP_ID = "370174876416548"
FACEBOOK_APP_ID = "516530425068934"
FACEBOOK_API_SECRET = 'f90d27d49f50939996db0f299dec129d'
FACEBOOK_EXTENDED_PERMISSIONS = ['email']
SOCIAL_AUTH_FACEBOOK_KEY="516530425068934"
SOCIAL_AUTH_FACEBOOK_SECRET='f90d27d49f50939996db0f299dec129d'
SOCIAL_AUTH_FACEBOOK_SCOPE = ['email']
HOME_URL = "http://local.cualbondi.com.ar"
#INSTALLED_APPS += ('debug_toolbar', 'debug_panel','django_extensions')
DEBUG_TOOLBAR_PATCH_SETTINGS = False
INSTALLED_APPS += ('debug_toolbar', 'django_extensions')
import logging
l = logging.getLogger('django.db.backends')
l.setLevel(logging.DEBUG)
l.addHandler(logging.StreamHandler())
LOGGING.update({
'handlers': {
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
}
},
'loggers': {
'django.db.backends': {
'level': 'DEBUG',
'handlers': ['console'],
}
}
})
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
'LOCATION': '127.0.0.1:11211',
},
# this cache backend will be used by django-debug-panel
'debug-panel': {
'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
'LOCATION': '/var/tmp/debug-panel-cache',
'TIMEOUT': 300,
'OPTIONS': {
'MAX_ENTRIES': 200
}
}
}
REQUEST_LOGGING_BACKEND = {
'host': 'localhost',
'port': 9200,
'index': 'cualbondi',
'type': 'requests'
}
WERCKER_DB_IPADDR = os.environ.get('POSTGIS_PORT_5432_TCP_ADDR', False)
if WERCKER_DB_IPADDR:
DATABASES = {
'default': {
'ENGINE': 'django.contrib.gis.db.backends.postgis',
'NAME': 'postgres',
'USER': 'postgres',
'PASSWORD': 'cb',
'HOST': WERCKER_DB_IPADDR,
'PORT': os.environ.get('POSTGIS_PORT_5432_TCP_PORT', False)
}
}
print DATABASES
# fix logging https://www.caktusgroup.com/blog/2015/01/27/Django-Logging-Configuration-logging_config-default-settings-logger/
LOGGING_CONFIG = None
import logging.config
logging.config.dictConfig(LOGGING)
|
agpl-3.0
|
[
3,
5634,
2202,
367,
286,
1061,
13520,
328,
2199,
14,
199,
646,
747,
199,
199,
35,
13841,
34,
615,
1914,
63,
9984,
275,
747,
14,
2314,
14,
362,
360,
35,
13841,
34,
615,
1914,
63,
9984,
297,
283,
31688,
358,
199,
199,
5287,
275,
715,
199,
7433,
63,
5287,
275,
10990,
199,
199,
17350,
63,
23775,
275,
788,
7693,
61,
199,
199,
17208,
63,
19747,
63,
2632,
275,
7324,
199,
199,
1217,
15096,
4586,
63,
2632,
63,
30024,
998,
654,
275,
469,
272,
283,
1178,
14,
751,
356,
2400,
399,
26,
3286,
527,
85,
17832,
3149,
83,
6687,
450,
399,
14,
2473,
12,
221,
199,
93,
199,
199,
14288,
51,
275,
334,
272,
327,
661,
14398,
2812,
297,
283,
12695,
63,
2123,
32,
2694,
14,
957,
659,
199,
9,
199,
3472,
63,
12491,
63,
10089,
275,
298,
815,
32,
67,
1061,
13520,
328,
14,
957,
14,
285,
2,
199,
199,
20600,
3960,
275,
29948,
51,
199,
199,
5825,
63,
3243,
275,
747,
14,
515,
14,
3475,
8,
736,
14,
515,
14,
4832,
3460,
493,
8964,
199,
199,
27260,
275,
1052,
199,
199,
4701,
63,
8677,
275,
715,
199,
3263,
1244,
654,
275,
469,
272,
283,
885,
356,
469,
267,
283,
18145,
356,
283,
1176,
14,
1018,
14,
1637,
14,
7765,
14,
32567,
14,
14169,
5245,
4437,
297,
267,
283,
16575,
356,
283,
4195,
14,
16,
14,
16,
14,
17,
26,
6094,
845,
297,
272,
789,
199,
93,
199,
8677,
63,
8899,
275,
5212,
10,
2259,
199,
199,
3,
17198,
25994,
565,
350,
305,
199,
19662,
2090,
63,
20332,
742,
63,
3472,
275,
1926,
199,
19662,
2090,
63,
19374,
568,
47,
63,
3472,
275,
1926,
199,
12375,
649,
3383,
63,
48,
1254,
568,
33,
275,
959,
199,
199,
3,
10111,
900,
5718,
367,
642,
12096,
14,
8802,
2370,
883,
506,
1911,
2348,
26,
199,
3,
1455,
921,
287,
14,
13961,
14,
1308,
15,
6797,
15,
1296,
63,
1618,
63,
3903,
63,
13325,
63,
991,
63,
354,
199,
3,
22160,
440,
1006,
3415,
1443,
506,
2808,
641,
1006,
17406,
10460,
14,
199,
3,
4068,
13074,
10460,
12,
282,
574,
402,
488,
911,
7675,
5634,
370,
675,
314,
2011,
199,
3,
7137,
465,
314,
17406,
2656,
14,
199,
3,
982,
3879,
315,
282,
5417,
3734,
642,
1471,
506,
663,
370,
314,
2011,
465,
2195,
199,
3,
2656,
900,
5718,
14,
199,
4961,
63,
15353,
275,
283,
8841,
15,
6373,
484,
13765,
15,
1713,
287,
736,
63,
28960,
470,
7,
199,
199,
3,
8466,
1233,
367,
642,
12096,
14,
2900,
3415,
883,
506,
1911,
2348,
26,
199,
3,
1455,
921,
1544,
14,
73,
1085,
2753,
29514,
14,
957,
15,
2975,
15,
3671,
13,
14227,
14,
1360,
199,
13947,
63,
6012,
275,
283,
397,
13,
285,
7,
199,
199,
7917,
63,
998,
275,
413,
199,
199,
3,
982,
1265,
663,
642,
370,
756,
12,
5634,
911,
1852,
2005,
5323,
12270,
880,
465,
440,
199,
3,
370,
2248,
314,
10757,
6279,
2072,
28540,
14,
199,
4701,
63,
41,
1085,
46,
275,
756,
199,
199,
3,
982,
1265,
663,
642,
370,
756,
12,
5634,
911,
440,
1475,
10831,
12,
5579,
436,
199,
3,
1704,
31276,
7182,
370,
314,
1453,
5867,
199,
4701,
63,
44,
709,
46,
275,
715,
199,
199,
3,
24964,
10036,
931,
370,
314,
2082,
626,
911,
10266,
922,
13,
19044,
1584,
14,
199,
3,
5679,
26,
3286,
4219,
15,
4603,
15,
4603,
14,
22277,
4646,
14,
957,
15,
4603,
6687,
199,
13669,
63,
5441,
275,
747,
14,
515,
14,
904,
8,
5825,
63,
3243,
12,
747,
14,
515,
14,
21386,
12,
283,
4603,
358,
199,
199,
3,
2851,
626,
10022,
314,
5898,
19733,
687,
31460,
63,
5441,
14,
4155,
3238,
370,
675,
282,
199,
3,
8520,
14457,
14,
199,
3,
6058,
26,
298,
1014,
921,
4603,
14,
22277,
4646,
14,
957,
15,
4603,
10665,
298,
1014,
921,
2694,
14,
957,
15,
4603,
6687,
199,
13669,
63,
2632,
275,
283,
4603,
4805,
199,
199,
3,
24964,
931,
370,
314,
2082,
2955,
1584,
1077,
506,
13736,
370,
14,
199,
3,
7529,
1133,
5324,
7003,
315,
642,
2082,
28225,
27,
3877,
2195,
2955,
1584,
199,
3,
315,
8686,
7,
298,
1986,
6687,
24799,
436,
315,
27815,
9472,
63,
14455,
14,
199,
3,
5679,
26,
3286,
4219,
15,
4603,
15,
4603,
14,
22277,
4646,
14,
957,
15,
1986,
6687,
199,
10449,
63,
5441,
275,
747,
14,
515,
14,
904,
8,
5825,
63,
3243,
12,
747,
14,
515,
14,
21386,
12,
283,
1986,
358,
199,
199,
3,
2851,
2403,
367,
2955,
1584,
14,
199,
3,
5679,
26,
298,
1014,
921,
4603,
14,
22277,
4646,
14,
957,
15,
1986,
6687,
199,
10449,
63,
2632,
275,
1994,
1986,
4805,
199,
199,
3,
2851,
2403,
367,
4628,
2955,
1584,
1553,
15750,
12,
15250,
436,
5935,
14,
199,
3,
4155,
3238,
370,
675,
282,
8520,
14457,
14,
199,
3,
6058,
26,
298,
1014,
921,
1421,
14,
957,
15,
1986,
15,
2113,
10665,
3286,
1986,
15,
2113,
15,
1674,
199,
14288,
63,
13669,
63,
6351,
275,
1994,
1986,
15,
2113,
4805,
199,
199,
3,
10961,
9918,
402,
2955,
1584,
199,
10449,
9472,
63,
14455,
275,
334,
272,
327,
16280,
3326,
2348,
12,
2839,
3286,
4219,
15,
1360,
15,
1986,
2,
503,
298,
35,
11254,
1544,
15,
1176,
15,
1986,
1674,
272,
327,
16763,
675,
7568,
20275,
12,
2755,
641,
5417,
14,
272,
327,
7529,
1133,
19459,
370,
675,
3679,
3792,
12,
440,
3847,
3792,
14,
199,
9,
199,
199,
3,
3820,
402,
11569,
3992,
626,
5715,
4212,
370,
2342,
2955,
1584,
315,
199,
3,
7750,
9918,
14,
199,
10449,
9472,
63,
27087,
3960,
275,
334,
272,
283,
1176,
14,
2828,
14,
18373,
14,
26677,
14,
17521,
11791,
297,
272,
283,
1176,
14,
2828,
14,
18373,
14,
26677,
14,
2640,
13752,
11791,
297,
199,
3,
259,
283,
1176,
14,
2828,
14,
18373,
14,
26677,
14,
2698,
6408,
11791,
297,
199,
9,
199,
199,
3,
4155,
642,
3747,
12,
436,
2793,
1133,
8663,
652,
543,
1263,
2030,
14,
199,
12961,
63,
3078,
275,
26143,
454,
6,
5,
1717,
19665,
22,
6,
83,
20,
20805,
81,
9,
2989,
74,
8,
68,
6,
8,
1367,
3,
26853,
32,
21,
75,
16,
66,
13,
67,
4,
62,
86,
22,
10922,
9,
25745,
69
] |
[
5634,
2202,
367,
286,
1061,
13520,
328,
2199,
14,
199,
646,
747,
199,
199,
35,
13841,
34,
615,
1914,
63,
9984,
275,
747,
14,
2314,
14,
362,
360,
35,
13841,
34,
615,
1914,
63,
9984,
297,
283,
31688,
358,
199,
199,
5287,
275,
715,
199,
7433,
63,
5287,
275,
10990,
199,
199,
17350,
63,
23775,
275,
788,
7693,
61,
199,
199,
17208,
63,
19747,
63,
2632,
275,
7324,
199,
199,
1217,
15096,
4586,
63,
2632,
63,
30024,
998,
654,
275,
469,
272,
283,
1178,
14,
751,
356,
2400,
399,
26,
3286,
527,
85,
17832,
3149,
83,
6687,
450,
399,
14,
2473,
12,
221,
199,
93,
199,
199,
14288,
51,
275,
334,
272,
327,
661,
14398,
2812,
297,
283,
12695,
63,
2123,
32,
2694,
14,
957,
659,
199,
9,
199,
3472,
63,
12491,
63,
10089,
275,
298,
815,
32,
67,
1061,
13520,
328,
14,
957,
14,
285,
2,
199,
199,
20600,
3960,
275,
29948,
51,
199,
199,
5825,
63,
3243,
275,
747,
14,
515,
14,
3475,
8,
736,
14,
515,
14,
4832,
3460,
493,
8964,
199,
199,
27260,
275,
1052,
199,
199,
4701,
63,
8677,
275,
715,
199,
3263,
1244,
654,
275,
469,
272,
283,
885,
356,
469,
267,
283,
18145,
356,
283,
1176,
14,
1018,
14,
1637,
14,
7765,
14,
32567,
14,
14169,
5245,
4437,
297,
267,
283,
16575,
356,
283,
4195,
14,
16,
14,
16,
14,
17,
26,
6094,
845,
297,
272,
789,
199,
93,
199,
8677,
63,
8899,
275,
5212,
10,
2259,
199,
199,
3,
17198,
25994,
565,
350,
305,
199,
19662,
2090,
63,
20332,
742,
63,
3472,
275,
1926,
199,
19662,
2090,
63,
19374,
568,
47,
63,
3472,
275,
1926,
199,
12375,
649,
3383,
63,
48,
1254,
568,
33,
275,
959,
199,
199,
3,
10111,
900,
5718,
367,
642,
12096,
14,
8802,
2370,
883,
506,
1911,
2348,
26,
199,
3,
1455,
921,
287,
14,
13961,
14,
1308,
15,
6797,
15,
1296,
63,
1618,
63,
3903,
63,
13325,
63,
991,
63,
354,
199,
3,
22160,
440,
1006,
3415,
1443,
506,
2808,
641,
1006,
17406,
10460,
14,
199,
3,
4068,
13074,
10460,
12,
282,
574,
402,
488,
911,
7675,
5634,
370,
675,
314,
2011,
199,
3,
7137,
465,
314,
17406,
2656,
14,
199,
3,
982,
3879,
315,
282,
5417,
3734,
642,
1471,
506,
663,
370,
314,
2011,
465,
2195,
199,
3,
2656,
900,
5718,
14,
199,
4961,
63,
15353,
275,
283,
8841,
15,
6373,
484,
13765,
15,
1713,
287,
736,
63,
28960,
470,
7,
199,
199,
3,
8466,
1233,
367,
642,
12096,
14,
2900,
3415,
883,
506,
1911,
2348,
26,
199,
3,
1455,
921,
1544,
14,
73,
1085,
2753,
29514,
14,
957,
15,
2975,
15,
3671,
13,
14227,
14,
1360,
199,
13947,
63,
6012,
275,
283,
397,
13,
285,
7,
199,
199,
7917,
63,
998,
275,
413,
199,
199,
3,
982,
1265,
663,
642,
370,
756,
12,
5634,
911,
1852,
2005,
5323,
12270,
880,
465,
440,
199,
3,
370,
2248,
314,
10757,
6279,
2072,
28540,
14,
199,
4701,
63,
41,
1085,
46,
275,
756,
199,
199,
3,
982,
1265,
663,
642,
370,
756,
12,
5634,
911,
440,
1475,
10831,
12,
5579,
436,
199,
3,
1704,
31276,
7182,
370,
314,
1453,
5867,
199,
4701,
63,
44,
709,
46,
275,
715,
199,
199,
3,
24964,
10036,
931,
370,
314,
2082,
626,
911,
10266,
922,
13,
19044,
1584,
14,
199,
3,
5679,
26,
3286,
4219,
15,
4603,
15,
4603,
14,
22277,
4646,
14,
957,
15,
4603,
6687,
199,
13669,
63,
5441,
275,
747,
14,
515,
14,
904,
8,
5825,
63,
3243,
12,
747,
14,
515,
14,
21386,
12,
283,
4603,
358,
199,
199,
3,
2851,
626,
10022,
314,
5898,
19733,
687,
31460,
63,
5441,
14,
4155,
3238,
370,
675,
282,
199,
3,
8520,
14457,
14,
199,
3,
6058,
26,
298,
1014,
921,
4603,
14,
22277,
4646,
14,
957,
15,
4603,
10665,
298,
1014,
921,
2694,
14,
957,
15,
4603,
6687,
199,
13669,
63,
2632,
275,
283,
4603,
4805,
199,
199,
3,
24964,
931,
370,
314,
2082,
2955,
1584,
1077,
506,
13736,
370,
14,
199,
3,
7529,
1133,
5324,
7003,
315,
642,
2082,
28225,
27,
3877,
2195,
2955,
1584,
199,
3,
315,
8686,
7,
298,
1986,
6687,
24799,
436,
315,
27815,
9472,
63,
14455,
14,
199,
3,
5679,
26,
3286,
4219,
15,
4603,
15,
4603,
14,
22277,
4646,
14,
957,
15,
1986,
6687,
199,
10449,
63,
5441,
275,
747,
14,
515,
14,
904,
8,
5825,
63,
3243,
12,
747,
14,
515,
14,
21386,
12,
283,
1986,
358,
199,
199,
3,
2851,
2403,
367,
2955,
1584,
14,
199,
3,
5679,
26,
298,
1014,
921,
4603,
14,
22277,
4646,
14,
957,
15,
1986,
6687,
199,
10449,
63,
2632,
275,
1994,
1986,
4805,
199,
199,
3,
2851,
2403,
367,
4628,
2955,
1584,
1553,
15750,
12,
15250,
436,
5935,
14,
199,
3,
4155,
3238,
370,
675,
282,
8520,
14457,
14,
199,
3,
6058,
26,
298,
1014,
921,
1421,
14,
957,
15,
1986,
15,
2113,
10665,
3286,
1986,
15,
2113,
15,
1674,
199,
14288,
63,
13669,
63,
6351,
275,
1994,
1986,
15,
2113,
4805,
199,
199,
3,
10961,
9918,
402,
2955,
1584,
199,
10449,
9472,
63,
14455,
275,
334,
272,
327,
16280,
3326,
2348,
12,
2839,
3286,
4219,
15,
1360,
15,
1986,
2,
503,
298,
35,
11254,
1544,
15,
1176,
15,
1986,
1674,
272,
327,
16763,
675,
7568,
20275,
12,
2755,
641,
5417,
14,
272,
327,
7529,
1133,
19459,
370,
675,
3679,
3792,
12,
440,
3847,
3792,
14,
199,
9,
199,
199,
3,
3820,
402,
11569,
3992,
626,
5715,
4212,
370,
2342,
2955,
1584,
315,
199,
3,
7750,
9918,
14,
199,
10449,
9472,
63,
27087,
3960,
275,
334,
272,
283,
1176,
14,
2828,
14,
18373,
14,
26677,
14,
17521,
11791,
297,
272,
283,
1176,
14,
2828,
14,
18373,
14,
26677,
14,
2640,
13752,
11791,
297,
199,
3,
259,
283,
1176,
14,
2828,
14,
18373,
14,
26677,
14,
2698,
6408,
11791,
297,
199,
9,
199,
199,
3,
4155,
642,
3747,
12,
436,
2793,
1133,
8663,
652,
543,
1263,
2030,
14,
199,
12961,
63,
3078,
275,
26143,
454,
6,
5,
1717,
19665,
22,
6,
83,
20,
20805,
81,
9,
2989,
74,
8,
68,
6,
8,
1367,
3,
26853,
32,
21,
75,
16,
66,
13,
67,
4,
62,
86,
22,
10922,
9,
25745,
69,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
rhomobi/node-gyp
|
gyp/pylib/gyp/generator/cmake.py
|
531
|
41681
|
# Copyright (c) 2013 Google Inc. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""cmake output module
This module is under development and should be considered experimental.
This module produces cmake (2.8.8+) input as its output. One CMakeLists.txt is
created for each configuration.
This module's original purpose was to support editing in IDEs like KDevelop
which use CMake for project management. It is also possible to use CMake to
generate projects for other IDEs such as eclipse cdt and code::blocks. QtCreator
will convert the CMakeLists.txt to a code::blocks cbp for the editor to read,
but build using CMake. As a result QtCreator editor is unaware of compiler
defines. The generated CMakeLists.txt can also be used to build on Linux. There
is currently no support for building on platforms other than Linux.
The generated CMakeLists.txt should properly compile all projects. However,
there is a mismatch between gyp and cmake with regard to linking. All attempts
are made to work around this, but CMake sometimes sees -Wl,--start-group as a
library and incorrectly repeats it. As a result the output of this generator
should not be relied on for building.
When using with kdevelop, use version 4.4+. Previous versions of kdevelop will
not be able to find the header file directories described in the generated
CMakeLists.txt file.
"""
import multiprocessing
import os
import signal
import string
import subprocess
import gyp.common
generator_default_variables = {
'EXECUTABLE_PREFIX': '',
'EXECUTABLE_SUFFIX': '',
'STATIC_LIB_PREFIX': 'lib',
'STATIC_LIB_SUFFIX': '.a',
'SHARED_LIB_PREFIX': 'lib',
'SHARED_LIB_SUFFIX': '.so',
'SHARED_LIB_DIR': '${builddir}/lib.${TOOLSET}',
'LIB_DIR': '${obj}.${TOOLSET}',
'INTERMEDIATE_DIR': '${obj}.${TOOLSET}/${TARGET}/geni',
'SHARED_INTERMEDIATE_DIR': '${obj}/gen',
'PRODUCT_DIR': '${builddir}',
'RULE_INPUT_PATH': '${RULE_INPUT_PATH}',
'RULE_INPUT_DIRNAME': '${RULE_INPUT_DIRNAME}',
'RULE_INPUT_NAME': '${RULE_INPUT_NAME}',
'RULE_INPUT_ROOT': '${RULE_INPUT_ROOT}',
'RULE_INPUT_EXT': '${RULE_INPUT_EXT}',
'CONFIGURATION_NAME': '${configuration}',
}
FULL_PATH_VARS = ('${CMAKE_SOURCE_DIR}', '${builddir}', '${obj}')
generator_supports_multiple_toolsets = True
generator_wants_static_library_dependencies_adjusted = True
COMPILABLE_EXTENSIONS = {
'.c': 'cc',
'.cc': 'cxx',
'.cpp': 'cxx',
'.cxx': 'cxx',
'.s': 's', # cc
'.S': 's', # cc
}
def RemovePrefix(a, prefix):
"""Returns 'a' without 'prefix' if it starts with 'prefix'."""
return a[len(prefix):] if a.startswith(prefix) else a
def CalculateVariables(default_variables, params):
"""Calculate additional variables for use in the build (called by gyp)."""
default_variables.setdefault('OS', gyp.common.GetFlavor(params))
def Compilable(filename):
"""Return true if the file is compilable (should be in OBJS)."""
return any(filename.endswith(e) for e in COMPILABLE_EXTENSIONS)
def Linkable(filename):
"""Return true if the file is linkable (should be on the link line)."""
return filename.endswith('.o')
def NormjoinPathForceCMakeSource(base_path, rel_path):
"""Resolves rel_path against base_path and returns the result.
If rel_path is an absolute path it is returned unchanged.
Otherwise it is resolved against base_path and normalized.
If the result is a relative path, it is forced to be relative to the
CMakeLists.txt.
"""
if os.path.isabs(rel_path):
return rel_path
if any([rel_path.startswith(var) for var in FULL_PATH_VARS]):
return rel_path
# TODO: do we need to check base_path for absolute variables as well?
return os.path.join('${CMAKE_SOURCE_DIR}',
os.path.normpath(os.path.join(base_path, rel_path)))
def NormjoinPath(base_path, rel_path):
"""Resolves rel_path against base_path and returns the result.
TODO: what is this really used for?
If rel_path begins with '$' it is returned unchanged.
Otherwise it is resolved against base_path if relative, then normalized.
"""
if rel_path.startswith('$') and not rel_path.startswith('${configuration}'):
return rel_path
return os.path.normpath(os.path.join(base_path, rel_path))
def CMakeStringEscape(a):
"""Escapes the string 'a' for use inside a CMake string.
This means escaping
'\' otherwise it may be seen as modifying the next character
'"' otherwise it will end the string
';' otherwise the string becomes a list
The following do not need to be escaped
'#' when the lexer is in string state, this does not start a comment
The following are yet unknown
'$' generator variables (like ${obj}) must not be escaped,
but text $ should be escaped
what is wanted is to know which $ come from generator variables
"""
return a.replace('\\', '\\\\').replace(';', '\\;').replace('"', '\\"')
def SetFileProperty(output, source_name, property_name, values, sep):
"""Given a set of source file, sets the given property on them."""
output.write('set_source_files_properties(')
output.write(source_name)
output.write(' PROPERTIES ')
output.write(property_name)
output.write(' "')
for value in values:
output.write(CMakeStringEscape(value))
output.write(sep)
output.write('")\n')
def SetFilesProperty(output, source_names, property_name, values, sep):
"""Given a set of source files, sets the given property on them."""
output.write('set_source_files_properties(\n')
for source_name in source_names:
output.write(' ')
output.write(source_name)
output.write('\n')
output.write(' PROPERTIES\n ')
output.write(property_name)
output.write(' "')
for value in values:
output.write(CMakeStringEscape(value))
output.write(sep)
output.write('"\n)\n')
def SetTargetProperty(output, target_name, property_name, values, sep=''):
"""Given a target, sets the given property."""
output.write('set_target_properties(')
output.write(target_name)
output.write(' PROPERTIES ')
output.write(property_name)
output.write(' "')
for value in values:
output.write(CMakeStringEscape(value))
output.write(sep)
output.write('")\n')
def SetVariable(output, variable_name, value):
"""Sets a CMake variable."""
output.write('set(')
output.write(variable_name)
output.write(' "')
output.write(CMakeStringEscape(value))
output.write('")\n')
def SetVariableList(output, variable_name, values):
"""Sets a CMake variable to a list."""
if not values:
return SetVariable(output, variable_name, "")
if len(values) == 1:
return SetVariable(output, variable_name, values[0])
output.write('list(APPEND ')
output.write(variable_name)
output.write('\n "')
output.write('"\n "'.join([CMakeStringEscape(value) for value in values]))
output.write('")\n')
def UnsetVariable(output, variable_name):
"""Unsets a CMake variable."""
output.write('unset(')
output.write(variable_name)
output.write(')\n')
def WriteVariable(output, variable_name, prepend=None):
if prepend:
output.write(prepend)
output.write('${')
output.write(variable_name)
output.write('}')
class CMakeTargetType:
def __init__(self, command, modifier, property_modifier):
self.command = command
self.modifier = modifier
self.property_modifier = property_modifier
cmake_target_type_from_gyp_target_type = {
'executable': CMakeTargetType('add_executable', None, 'RUNTIME'),
'static_library': CMakeTargetType('add_library', 'STATIC', 'ARCHIVE'),
'shared_library': CMakeTargetType('add_library', 'SHARED', 'LIBRARY'),
'loadable_module': CMakeTargetType('add_library', 'MODULE', 'LIBRARY'),
'none': CMakeTargetType('add_custom_target', 'SOURCES', None),
}
def StringToCMakeTargetName(a):
"""Converts the given string 'a' to a valid CMake target name.
All invalid characters are replaced by '_'.
Invalid for cmake: ' ', '/', '(', ')'
Invalid for make: ':'
Invalid for unknown reasons but cause failures: '.'
"""
return a.translate(string.maketrans(' /():.', '______'))
def WriteActions(target_name, actions, extra_sources, extra_deps,
path_to_gyp, output):
"""Write CMake for the 'actions' in the target.
Args:
target_name: the name of the CMake target being generated.
actions: the Gyp 'actions' dict for this target.
extra_sources: [(<cmake_src>, <src>)] to append with generated source files.
extra_deps: [<cmake_taget>] to append with generated targets.
path_to_gyp: relative path from CMakeLists.txt being generated to
the Gyp file in which the target being generated is defined.
"""
for action in actions:
action_name = StringToCMakeTargetName(action['action_name'])
action_target_name = '%s__%s' % (target_name, action_name)
inputs = action['inputs']
inputs_name = action_target_name + '__input'
SetVariableList(output, inputs_name,
[NormjoinPathForceCMakeSource(path_to_gyp, dep) for dep in inputs])
outputs = action['outputs']
cmake_outputs = [NormjoinPathForceCMakeSource(path_to_gyp, out)
for out in outputs]
outputs_name = action_target_name + '__output'
SetVariableList(output, outputs_name, cmake_outputs)
# Build up a list of outputs.
# Collect the output dirs we'll need.
dirs = set(dir for dir in (os.path.dirname(o) for o in outputs) if dir)
if int(action.get('process_outputs_as_sources', False)):
extra_sources.extend(zip(cmake_outputs, outputs))
# add_custom_command
output.write('add_custom_command(OUTPUT ')
WriteVariable(output, outputs_name)
output.write('\n')
if len(dirs) > 0:
for directory in dirs:
output.write(' COMMAND ${CMAKE_COMMAND} -E make_directory ')
output.write(directory)
output.write('\n')
output.write(' COMMAND ')
output.write(gyp.common.EncodePOSIXShellList(action['action']))
output.write('\n')
output.write(' DEPENDS ')
WriteVariable(output, inputs_name)
output.write('\n')
output.write(' WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/')
output.write(path_to_gyp)
output.write('\n')
output.write(' COMMENT ')
if 'message' in action:
output.write(action['message'])
else:
output.write(action_target_name)
output.write('\n')
output.write(' VERBATIM\n')
output.write(')\n')
# add_custom_target
output.write('add_custom_target(')
output.write(action_target_name)
output.write('\n DEPENDS ')
WriteVariable(output, outputs_name)
output.write('\n SOURCES ')
WriteVariable(output, inputs_name)
output.write('\n)\n')
extra_deps.append(action_target_name)
def NormjoinRulePathForceCMakeSource(base_path, rel_path, rule_source):
if rel_path.startswith(("${RULE_INPUT_PATH}","${RULE_INPUT_DIRNAME}")):
if any([rule_source.startswith(var) for var in FULL_PATH_VARS]):
return rel_path
return NormjoinPathForceCMakeSource(base_path, rel_path)
def WriteRules(target_name, rules, extra_sources, extra_deps,
path_to_gyp, output):
"""Write CMake for the 'rules' in the target.
Args:
target_name: the name of the CMake target being generated.
actions: the Gyp 'actions' dict for this target.
extra_sources: [(<cmake_src>, <src>)] to append with generated source files.
extra_deps: [<cmake_taget>] to append with generated targets.
path_to_gyp: relative path from CMakeLists.txt being generated to
the Gyp file in which the target being generated is defined.
"""
for rule in rules:
rule_name = StringToCMakeTargetName(target_name + '__' + rule['rule_name'])
inputs = rule.get('inputs', [])
inputs_name = rule_name + '__input'
SetVariableList(output, inputs_name,
[NormjoinPathForceCMakeSource(path_to_gyp, dep) for dep in inputs])
outputs = rule['outputs']
var_outputs = []
for count, rule_source in enumerate(rule.get('rule_sources', [])):
action_name = rule_name + '_' + str(count)
rule_source_dirname, rule_source_basename = os.path.split(rule_source)
rule_source_root, rule_source_ext = os.path.splitext(rule_source_basename)
SetVariable(output, 'RULE_INPUT_PATH', rule_source)
SetVariable(output, 'RULE_INPUT_DIRNAME', rule_source_dirname)
SetVariable(output, 'RULE_INPUT_NAME', rule_source_basename)
SetVariable(output, 'RULE_INPUT_ROOT', rule_source_root)
SetVariable(output, 'RULE_INPUT_EXT', rule_source_ext)
# Build up a list of outputs.
# Collect the output dirs we'll need.
dirs = set(dir for dir in (os.path.dirname(o) for o in outputs) if dir)
# Create variables for the output, as 'local' variable will be unset.
these_outputs = []
for output_index, out in enumerate(outputs):
output_name = action_name + '_' + str(output_index)
SetVariable(output, output_name,
NormjoinRulePathForceCMakeSource(path_to_gyp, out,
rule_source))
if int(rule.get('process_outputs_as_sources', False)):
extra_sources.append(('${' + output_name + '}', out))
these_outputs.append('${' + output_name + '}')
var_outputs.append('${' + output_name + '}')
# add_custom_command
output.write('add_custom_command(OUTPUT\n')
for out in these_outputs:
output.write(' ')
output.write(out)
output.write('\n')
for directory in dirs:
output.write(' COMMAND ${CMAKE_COMMAND} -E make_directory ')
output.write(directory)
output.write('\n')
output.write(' COMMAND ')
output.write(gyp.common.EncodePOSIXShellList(rule['action']))
output.write('\n')
output.write(' DEPENDS ')
WriteVariable(output, inputs_name)
output.write(' ')
output.write(NormjoinPath(path_to_gyp, rule_source))
output.write('\n')
# CMAKE_SOURCE_DIR is where the CMakeLists.txt lives.
# The cwd is the current build directory.
output.write(' WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/')
output.write(path_to_gyp)
output.write('\n')
output.write(' COMMENT ')
if 'message' in rule:
output.write(rule['message'])
else:
output.write(action_name)
output.write('\n')
output.write(' VERBATIM\n')
output.write(')\n')
UnsetVariable(output, 'RULE_INPUT_PATH')
UnsetVariable(output, 'RULE_INPUT_DIRNAME')
UnsetVariable(output, 'RULE_INPUT_NAME')
UnsetVariable(output, 'RULE_INPUT_ROOT')
UnsetVariable(output, 'RULE_INPUT_EXT')
# add_custom_target
output.write('add_custom_target(')
output.write(rule_name)
output.write(' DEPENDS\n')
for out in var_outputs:
output.write(' ')
output.write(out)
output.write('\n')
output.write('SOURCES ')
WriteVariable(output, inputs_name)
output.write('\n')
for rule_source in rule.get('rule_sources', []):
output.write(' ')
output.write(NormjoinPath(path_to_gyp, rule_source))
output.write('\n')
output.write(')\n')
extra_deps.append(rule_name)
def WriteCopies(target_name, copies, extra_deps, path_to_gyp, output):
"""Write CMake for the 'copies' in the target.
Args:
target_name: the name of the CMake target being generated.
actions: the Gyp 'actions' dict for this target.
extra_deps: [<cmake_taget>] to append with generated targets.
path_to_gyp: relative path from CMakeLists.txt being generated to
the Gyp file in which the target being generated is defined.
"""
copy_name = target_name + '__copies'
# CMake gets upset with custom targets with OUTPUT which specify no output.
have_copies = any(copy['files'] for copy in copies)
if not have_copies:
output.write('add_custom_target(')
output.write(copy_name)
output.write(')\n')
extra_deps.append(copy_name)
return
class Copy:
def __init__(self, ext, command):
self.cmake_inputs = []
self.cmake_outputs = []
self.gyp_inputs = []
self.gyp_outputs = []
self.ext = ext
self.inputs_name = None
self.outputs_name = None
self.command = command
file_copy = Copy('', 'copy')
dir_copy = Copy('_dirs', 'copy_directory')
for copy in copies:
files = copy['files']
destination = copy['destination']
for src in files:
path = os.path.normpath(src)
basename = os.path.split(path)[1]
dst = os.path.join(destination, basename)
copy = file_copy if os.path.basename(src) else dir_copy
copy.cmake_inputs.append(NormjoinPath(path_to_gyp, src))
copy.cmake_outputs.append(NormjoinPathForceCMakeSource(path_to_gyp, dst))
copy.gyp_inputs.append(src)
copy.gyp_outputs.append(dst)
for copy in (file_copy, dir_copy):
if copy.cmake_inputs:
copy.inputs_name = copy_name + '__input' + copy.ext
SetVariableList(output, copy.inputs_name, copy.cmake_inputs)
copy.outputs_name = copy_name + '__output' + copy.ext
SetVariableList(output, copy.outputs_name, copy.cmake_outputs)
# add_custom_command
output.write('add_custom_command(\n')
output.write('OUTPUT')
for copy in (file_copy, dir_copy):
if copy.outputs_name:
WriteVariable(output, copy.outputs_name, ' ')
output.write('\n')
for copy in (file_copy, dir_copy):
for src, dst in zip(copy.gyp_inputs, copy.gyp_outputs):
# 'cmake -E copy src dst' will create the 'dst' directory if needed.
output.write('COMMAND ${CMAKE_COMMAND} -E %s ' % copy.command)
output.write(src)
output.write(' ')
output.write(dst)
output.write("\n")
output.write('DEPENDS')
for copy in (file_copy, dir_copy):
if copy.inputs_name:
WriteVariable(output, copy.inputs_name, ' ')
output.write('\n')
output.write('WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/')
output.write(path_to_gyp)
output.write('\n')
output.write('COMMENT Copying for ')
output.write(target_name)
output.write('\n')
output.write('VERBATIM\n')
output.write(')\n')
# add_custom_target
output.write('add_custom_target(')
output.write(copy_name)
output.write('\n DEPENDS')
for copy in (file_copy, dir_copy):
if copy.outputs_name:
WriteVariable(output, copy.outputs_name, ' ')
output.write('\n SOURCES')
if file_copy.inputs_name:
WriteVariable(output, file_copy.inputs_name, ' ')
output.write('\n)\n')
extra_deps.append(copy_name)
def CreateCMakeTargetBaseName(qualified_target):
"""This is the name we would like the target to have."""
_, gyp_target_name, gyp_target_toolset = (
gyp.common.ParseQualifiedTarget(qualified_target))
cmake_target_base_name = gyp_target_name
if gyp_target_toolset and gyp_target_toolset != 'target':
cmake_target_base_name += '_' + gyp_target_toolset
return StringToCMakeTargetName(cmake_target_base_name)
def CreateCMakeTargetFullName(qualified_target):
"""An unambiguous name for the target."""
gyp_file, gyp_target_name, gyp_target_toolset = (
gyp.common.ParseQualifiedTarget(qualified_target))
cmake_target_full_name = gyp_file + ':' + gyp_target_name
if gyp_target_toolset and gyp_target_toolset != 'target':
cmake_target_full_name += '_' + gyp_target_toolset
return StringToCMakeTargetName(cmake_target_full_name)
class CMakeNamer(object):
"""Converts Gyp target names into CMake target names.
CMake requires that target names be globally unique. One way to ensure
this is to fully qualify the names of the targets. Unfortunatly, this
ends up with all targets looking like "chrome_chrome_gyp_chrome" instead
of just "chrome". If this generator were only interested in building, it
would be possible to fully qualify all target names, then create
unqualified target names which depend on all qualified targets which
should have had that name. This is more or less what the 'make' generator
does with aliases. However, one goal of this generator is to create CMake
files for use with IDEs, and fully qualified names are not as user
friendly.
Since target name collision is rare, we do the above only when required.
Toolset variants are always qualified from the base, as this is required for
building. However, it also makes sense for an IDE, as it is possible for
defines to be different.
"""
def __init__(self, target_list):
self.cmake_target_base_names_conficting = set()
cmake_target_base_names_seen = set()
for qualified_target in target_list:
cmake_target_base_name = CreateCMakeTargetBaseName(qualified_target)
if cmake_target_base_name not in cmake_target_base_names_seen:
cmake_target_base_names_seen.add(cmake_target_base_name)
else:
self.cmake_target_base_names_conficting.add(cmake_target_base_name)
def CreateCMakeTargetName(self, qualified_target):
base_name = CreateCMakeTargetBaseName(qualified_target)
if base_name in self.cmake_target_base_names_conficting:
return CreateCMakeTargetFullName(qualified_target)
return base_name
def WriteTarget(namer, qualified_target, target_dicts, build_dir, config_to_use,
options, generator_flags, all_qualified_targets, output):
# The make generator does this always.
# TODO: It would be nice to be able to tell CMake all dependencies.
circular_libs = generator_flags.get('circular', True)
if not generator_flags.get('standalone', False):
output.write('\n#')
output.write(qualified_target)
output.write('\n')
gyp_file, _, _ = gyp.common.ParseQualifiedTarget(qualified_target)
rel_gyp_file = gyp.common.RelativePath(gyp_file, options.toplevel_dir)
rel_gyp_dir = os.path.dirname(rel_gyp_file)
# Relative path from build dir to top dir.
build_to_top = gyp.common.InvertRelativePath(build_dir, options.toplevel_dir)
# Relative path from build dir to gyp dir.
build_to_gyp = os.path.join(build_to_top, rel_gyp_dir)
path_from_cmakelists_to_gyp = build_to_gyp
spec = target_dicts.get(qualified_target, {})
config = spec.get('configurations', {}).get(config_to_use, {})
target_name = spec.get('target_name', '<missing target name>')
target_type = spec.get('type', '<missing target type>')
target_toolset = spec.get('toolset')
SetVariable(output, 'TARGET', target_name)
SetVariable(output, 'TOOLSET', target_toolset)
cmake_target_name = namer.CreateCMakeTargetName(qualified_target)
extra_sources = []
extra_deps = []
# Actions must come first, since they can generate more OBJs for use below.
if 'actions' in spec:
WriteActions(cmake_target_name, spec['actions'], extra_sources, extra_deps,
path_from_cmakelists_to_gyp, output)
# Rules must be early like actions.
if 'rules' in spec:
WriteRules(cmake_target_name, spec['rules'], extra_sources, extra_deps,
path_from_cmakelists_to_gyp, output)
# Copies
if 'copies' in spec:
WriteCopies(cmake_target_name, spec['copies'], extra_deps,
path_from_cmakelists_to_gyp, output)
# Target and sources
srcs = spec.get('sources', [])
# Gyp separates the sheep from the goats based on file extensions.
def partition(l, p):
return reduce(lambda x, e: x[not p(e)].append(e) or x, l, ([], []))
compilable_srcs, other_srcs = partition(srcs, Compilable)
# CMake gets upset when executable targets provide no sources.
if target_type == 'executable' and not compilable_srcs and not extra_sources:
print ('Executable %s has no complilable sources, treating as "none".' %
target_name )
target_type = 'none'
cmake_target_type = cmake_target_type_from_gyp_target_type.get(target_type)
if cmake_target_type is None:
print ('Target %s has unknown target type %s, skipping.' %
( target_name, target_type ) )
return
other_srcs_name = None
if other_srcs:
other_srcs_name = cmake_target_name + '__other_srcs'
SetVariableList(output, other_srcs_name,
[NormjoinPath(path_from_cmakelists_to_gyp, src) for src in other_srcs])
# CMake is opposed to setting linker directories and considers the practice
# of setting linker directories dangerous. Instead, it favors the use of
# find_library and passing absolute paths to target_link_libraries.
# However, CMake does provide the command link_directories, which adds
# link directories to targets defined after it is called.
# As a result, link_directories must come before the target definition.
# CMake unfortunately has no means of removing entries from LINK_DIRECTORIES.
library_dirs = config.get('library_dirs')
if library_dirs is not None:
output.write('link_directories(')
for library_dir in library_dirs:
output.write(' ')
output.write(NormjoinPath(path_from_cmakelists_to_gyp, library_dir))
output.write('\n')
output.write(')\n')
output.write(cmake_target_type.command)
output.write('(')
output.write(cmake_target_name)
if cmake_target_type.modifier is not None:
output.write(' ')
output.write(cmake_target_type.modifier)
if other_srcs_name:
WriteVariable(output, other_srcs_name, ' ')
output.write('\n')
for src in compilable_srcs:
output.write(' ')
output.write(NormjoinPath(path_from_cmakelists_to_gyp, src))
output.write('\n')
for extra_source in extra_sources:
output.write(' ')
src, _ = extra_source
output.write(NormjoinPath(path_from_cmakelists_to_gyp, src))
output.write('\n')
output.write(')\n')
# Output name and location.
if target_type != 'none':
# Mark uncompiled sources as uncompiled.
if other_srcs_name:
output.write('set_source_files_properties(')
WriteVariable(output, other_srcs_name, '')
output.write(' PROPERTIES HEADER_FILE_ONLY "TRUE")\n')
# Output directory
target_output_directory = spec.get('product_dir')
if target_output_directory is None:
if target_type in ('executable', 'loadable_module'):
target_output_directory = generator_default_variables['PRODUCT_DIR']
elif target_type in ('shared_library'):
target_output_directory = '${builddir}/lib.${TOOLSET}'
elif spec.get('standalone_static_library', False):
target_output_directory = generator_default_variables['PRODUCT_DIR']
else:
base_path = gyp.common.RelativePath(os.path.dirname(gyp_file),
options.toplevel_dir)
target_output_directory = '${obj}.${TOOLSET}'
target_output_directory = (
os.path.join(target_output_directory, base_path))
cmake_target_output_directory = NormjoinPathForceCMakeSource(
path_from_cmakelists_to_gyp,
target_output_directory)
SetTargetProperty(output,
cmake_target_name,
cmake_target_type.property_modifier + '_OUTPUT_DIRECTORY',
cmake_target_output_directory)
# Output name
default_product_prefix = ''
default_product_name = target_name
default_product_ext = ''
if target_type == 'static_library':
static_library_prefix = generator_default_variables['STATIC_LIB_PREFIX']
default_product_name = RemovePrefix(default_product_name,
static_library_prefix)
default_product_prefix = static_library_prefix
default_product_ext = generator_default_variables['STATIC_LIB_SUFFIX']
elif target_type in ('loadable_module', 'shared_library'):
shared_library_prefix = generator_default_variables['SHARED_LIB_PREFIX']
default_product_name = RemovePrefix(default_product_name,
shared_library_prefix)
default_product_prefix = shared_library_prefix
default_product_ext = generator_default_variables['SHARED_LIB_SUFFIX']
elif target_type != 'executable':
print ('ERROR: What output file should be generated?',
'type', target_type, 'target', target_name)
product_prefix = spec.get('product_prefix', default_product_prefix)
product_name = spec.get('product_name', default_product_name)
product_ext = spec.get('product_extension')
if product_ext:
product_ext = '.' + product_ext
else:
product_ext = default_product_ext
SetTargetProperty(output, cmake_target_name, 'PREFIX', product_prefix)
SetTargetProperty(output, cmake_target_name,
cmake_target_type.property_modifier + '_OUTPUT_NAME',
product_name)
SetTargetProperty(output, cmake_target_name, 'SUFFIX', product_ext)
# Make the output of this target referenceable as a source.
cmake_target_output_basename = product_prefix + product_name + product_ext
cmake_target_output = os.path.join(cmake_target_output_directory,
cmake_target_output_basename)
SetFileProperty(output, cmake_target_output, 'GENERATED', ['TRUE'], '')
# Let CMake know if the 'all' target should depend on this target.
exclude_from_all = ('TRUE' if qualified_target not in all_qualified_targets
else 'FALSE')
SetTargetProperty(output, cmake_target_name,
'EXCLUDE_FROM_ALL', exclude_from_all)
for extra_target_name in extra_deps:
SetTargetProperty(output, extra_target_name,
'EXCLUDE_FROM_ALL', exclude_from_all)
# Includes
includes = config.get('include_dirs')
if includes:
# This (target include directories) is what requires CMake 2.8.8
includes_name = cmake_target_name + '__include_dirs'
SetVariableList(output, includes_name,
[NormjoinPathForceCMakeSource(path_from_cmakelists_to_gyp, include)
for include in includes])
output.write('set_property(TARGET ')
output.write(cmake_target_name)
output.write(' APPEND PROPERTY INCLUDE_DIRECTORIES ')
WriteVariable(output, includes_name, '')
output.write(')\n')
# Defines
defines = config.get('defines')
if defines is not None:
SetTargetProperty(output,
cmake_target_name,
'COMPILE_DEFINITIONS',
defines,
';')
# Compile Flags - http://www.cmake.org/Bug/view.php?id=6493
# CMake currently does not have target C and CXX flags.
# So, instead of doing...
# cflags_c = config.get('cflags_c')
# if cflags_c is not None:
# SetTargetProperty(output, cmake_target_name,
# 'C_COMPILE_FLAGS', cflags_c, ' ')
# cflags_cc = config.get('cflags_cc')
# if cflags_cc is not None:
# SetTargetProperty(output, cmake_target_name,
# 'CXX_COMPILE_FLAGS', cflags_cc, ' ')
# Instead we must...
s_sources = []
c_sources = []
cxx_sources = []
for src in srcs:
_, ext = os.path.splitext(src)
src_type = COMPILABLE_EXTENSIONS.get(ext, None)
if src_type == 's':
s_sources.append(NormjoinPath(path_from_cmakelists_to_gyp, src))
if src_type == 'cc':
c_sources.append(NormjoinPath(path_from_cmakelists_to_gyp, src))
if src_type == 'cxx':
cxx_sources.append(NormjoinPath(path_from_cmakelists_to_gyp, src))
for extra_source in extra_sources:
src, real_source = extra_source
_, ext = os.path.splitext(real_source)
src_type = COMPILABLE_EXTENSIONS.get(ext, None)
if src_type == 's':
s_sources.append(NormjoinPath(path_from_cmakelists_to_gyp, src))
if src_type == 'cc':
c_sources.append(NormjoinPath(path_from_cmakelists_to_gyp, src))
if src_type == 'cxx':
cxx_sources.append(NormjoinPath(path_from_cmakelists_to_gyp, src))
cflags = config.get('cflags', [])
cflags_c = config.get('cflags_c', [])
cflags_cxx = config.get('cflags_cc', [])
if c_sources and not (s_sources or cxx_sources):
flags = []
flags.extend(cflags)
flags.extend(cflags_c)
SetTargetProperty(output, cmake_target_name, 'COMPILE_FLAGS', flags, ' ')
elif cxx_sources and not (s_sources or c_sources):
flags = []
flags.extend(cflags)
flags.extend(cflags_cxx)
SetTargetProperty(output, cmake_target_name, 'COMPILE_FLAGS', flags, ' ')
else:
if s_sources and cflags:
SetFilesProperty(output, s_sources, 'COMPILE_FLAGS', cflags, ' ')
if c_sources and (cflags or cflags_c):
flags = []
flags.extend(cflags)
flags.extend(cflags_c)
SetFilesProperty(output, c_sources, 'COMPILE_FLAGS', flags, ' ')
if cxx_sources and (cflags or cflags_cxx):
flags = []
flags.extend(cflags)
flags.extend(cflags_cxx)
SetFilesProperty(output, cxx_sources, 'COMPILE_FLAGS', flags, ' ')
# Have assembly link as c if there are no other files
if not c_sources and not cxx_sources and s_sources:
SetTargetProperty(output, cmake_target_name, 'LINKER_LANGUAGE', ['C'])
# Linker flags
ldflags = config.get('ldflags')
if ldflags is not None:
SetTargetProperty(output, cmake_target_name, 'LINK_FLAGS', ldflags, ' ')
# Note on Dependencies and Libraries:
# CMake wants to handle link order, resolving the link line up front.
# Gyp does not retain or enforce specifying enough information to do so.
# So do as other gyp generators and use --start-group and --end-group.
# Give CMake as little information as possible so that it doesn't mess it up.
# Dependencies
rawDeps = spec.get('dependencies', [])
static_deps = []
shared_deps = []
other_deps = []
for rawDep in rawDeps:
dep_cmake_name = namer.CreateCMakeTargetName(rawDep)
dep_spec = target_dicts.get(rawDep, {})
dep_target_type = dep_spec.get('type', None)
if dep_target_type == 'static_library':
static_deps.append(dep_cmake_name)
elif dep_target_type == 'shared_library':
shared_deps.append(dep_cmake_name)
else:
other_deps.append(dep_cmake_name)
# ensure all external dependencies are complete before internal dependencies
# extra_deps currently only depend on their own deps, so otherwise run early
if static_deps or shared_deps or other_deps:
for extra_dep in extra_deps:
output.write('add_dependencies(')
output.write(extra_dep)
output.write('\n')
for deps in (static_deps, shared_deps, other_deps):
for dep in gyp.common.uniquer(deps):
output.write(' ')
output.write(dep)
output.write('\n')
output.write(')\n')
linkable = target_type in ('executable', 'loadable_module', 'shared_library')
other_deps.extend(extra_deps)
if other_deps or (not linkable and (static_deps or shared_deps)):
output.write('add_dependencies(')
output.write(cmake_target_name)
output.write('\n')
for dep in gyp.common.uniquer(other_deps):
output.write(' ')
output.write(dep)
output.write('\n')
if not linkable:
for deps in (static_deps, shared_deps):
for lib_dep in gyp.common.uniquer(deps):
output.write(' ')
output.write(lib_dep)
output.write('\n')
output.write(')\n')
# Libraries
if linkable:
external_libs = [lib for lib in spec.get('libraries', []) if len(lib) > 0]
if external_libs or static_deps or shared_deps:
output.write('target_link_libraries(')
output.write(cmake_target_name)
output.write('\n')
if static_deps:
write_group = circular_libs and len(static_deps) > 1
if write_group:
output.write('-Wl,--start-group\n')
for dep in gyp.common.uniquer(static_deps):
output.write(' ')
output.write(dep)
output.write('\n')
if write_group:
output.write('-Wl,--end-group\n')
if shared_deps:
for dep in gyp.common.uniquer(shared_deps):
output.write(' ')
output.write(dep)
output.write('\n')
if external_libs:
for lib in gyp.common.uniquer(external_libs):
output.write(' ')
output.write(lib)
output.write('\n')
output.write(')\n')
UnsetVariable(output, 'TOOLSET')
UnsetVariable(output, 'TARGET')
def GenerateOutputForConfig(target_list, target_dicts, data,
params, config_to_use):
options = params['options']
generator_flags = params['generator_flags']
# generator_dir: relative path from pwd to where make puts build files.
# Makes migrating from make to cmake easier, cmake doesn't put anything here.
# Each Gyp configuration creates a different CMakeLists.txt file
# to avoid incompatibilities between Gyp and CMake configurations.
generator_dir = os.path.relpath(options.generator_output or '.')
# output_dir: relative path from generator_dir to the build directory.
output_dir = generator_flags.get('output_dir', 'out')
# build_dir: relative path from source root to our output files.
# e.g. "out/Debug"
build_dir = os.path.normpath(os.path.join(generator_dir,
output_dir,
config_to_use))
toplevel_build = os.path.join(options.toplevel_dir, build_dir)
output_file = os.path.join(toplevel_build, 'CMakeLists.txt')
gyp.common.EnsureDirExists(output_file)
output = open(output_file, 'w')
output.write('cmake_minimum_required(VERSION 2.8.8 FATAL_ERROR)\n')
output.write('cmake_policy(VERSION 2.8.8)\n')
_, project_target, _ = gyp.common.ParseQualifiedTarget(target_list[-1])
output.write('project(')
output.write(project_target)
output.write(')\n')
SetVariable(output, 'configuration', config_to_use)
# The following appears to be as-yet undocumented.
# http://public.kitware.com/Bug/view.php?id=8392
output.write('enable_language(ASM)\n')
# ASM-ATT does not support .S files.
# output.write('enable_language(ASM-ATT)\n')
SetVariable(output, 'builddir', '${CMAKE_BINARY_DIR}')
SetVariable(output, 'obj', '${builddir}/obj')
output.write('\n')
# TODO: Undocumented/unsupported (the CMake Java generator depends on it).
# CMake by default names the object resulting from foo.c to be foo.c.o.
# Gyp traditionally names the object resulting from foo.c foo.o.
# This should be irrelevant, but some targets extract .o files from .a
# and depend on the name of the extracted .o files.
output.write('set(CMAKE_C_OUTPUT_EXTENSION_REPLACE 1)\n')
output.write('set(CMAKE_CXX_OUTPUT_EXTENSION_REPLACE 1)\n')
output.write('\n')
namer = CMakeNamer(target_list)
# The list of targets upon which the 'all' target should depend.
# CMake has it's own implicit 'all' target, one is not created explicitly.
all_qualified_targets = set()
for build_file in params['build_files']:
for qualified_target in gyp.common.AllTargets(target_list,
target_dicts,
os.path.normpath(build_file)):
all_qualified_targets.add(qualified_target)
for qualified_target in target_list:
WriteTarget(namer, qualified_target, target_dicts, build_dir, config_to_use,
options, generator_flags, all_qualified_targets, output)
output.close()
def PerformBuild(data, configurations, params):
options = params['options']
generator_flags = params['generator_flags']
# generator_dir: relative path from pwd to where make puts build files.
# Makes migrating from make to cmake easier, cmake doesn't put anything here.
generator_dir = os.path.relpath(options.generator_output or '.')
# output_dir: relative path from generator_dir to the build directory.
output_dir = generator_flags.get('output_dir', 'out')
for config_name in configurations:
# build_dir: relative path from source root to our output files.
# e.g. "out/Debug"
build_dir = os.path.normpath(os.path.join(generator_dir,
output_dir,
config_name))
arguments = ['cmake', '-G', 'Ninja']
print 'Generating [%s]: %s' % (config_name, arguments)
subprocess.check_call(arguments, cwd=build_dir)
arguments = ['ninja', '-C', build_dir]
print 'Building [%s]: %s' % (config_name, arguments)
subprocess.check_call(arguments)
def CallGenerateOutputForConfig(arglist):
# Ignore the interrupt signal so that the parent process catches it and
# kills all multiprocessing children.
signal.signal(signal.SIGINT, signal.SIG_IGN)
target_list, target_dicts, data, params, config_name = arglist
GenerateOutputForConfig(target_list, target_dicts, data, params, config_name)
def GenerateOutput(target_list, target_dicts, data, params):
user_config = params.get('generator_flags', {}).get('config', None)
if user_config:
GenerateOutputForConfig(target_list, target_dicts, data,
params, user_config)
else:
config_names = target_dicts[target_list[0]]['configurations'].keys()
if params['parallel']:
try:
pool = multiprocessing.Pool(len(config_names))
arglists = []
for config_name in config_names:
arglists.append((target_list, target_dicts, data,
params, config_name))
pool.map(CallGenerateOutputForConfig, arglists)
except KeyboardInterrupt, e:
pool.terminate()
raise e
else:
for config_name in config_names:
GenerateOutputForConfig(target_list, target_dicts, data,
params, config_name)
|
mit
|
[
3,
1898,
334,
67,
9,
6171,
4475,
3277,
14,
2900,
4481,
4644,
14,
199,
3,
3645,
402,
642,
1350,
1233,
365,
10413,
701,
282,
6289,
13,
2487,
4190,
626,
883,
506,
199,
3,
1911,
315,
314,
5113,
570,
14,
199,
199,
624,
16472,
1072,
859,
199,
199,
2765,
859,
365,
1334,
16367,
436,
1077,
506,
8652,
22820,
14,
199,
199,
2765,
859,
16904,
19773,
334,
18,
14,
24,
14,
24,
8771,
1324,
465,
2399,
1072,
14,
7309,
21355,
15116,
14,
2424,
365,
199,
3966,
367,
1924,
2897,
14,
199,
199,
2765,
859,
1159,
3379,
12016,
1990,
370,
2291,
20401,
315,
473,
1093,
83,
2839,
1804,
872,
7549,
199,
6777,
675,
21355,
367,
2199,
10041,
14,
2779,
365,
2597,
3962,
370,
675,
21355,
370,
199,
4208,
11336,
367,
1163,
473,
1093,
83,
4066,
465,
325,
7548,
261,
286,
3583,
436,
1233,
447,
4166,
14,
3959,
17523,
199,
14117,
3957,
314,
21355,
15116,
14,
2424,
370,
282,
1233,
447,
4166,
7434,
80,
367,
314,
8823,
370,
1586,
12,
199,
7911,
1900,
1808,
21355,
14,
3709,
282,
754,
3959,
17523,
8823,
365,
625,
14600,
402,
6365,
199,
14334,
14,
710,
4046,
21355,
15116,
14,
2424,
883,
2597,
506,
1202,
370,
1900,
641,
10130,
14,
6006,
199,
374,
5544,
949,
2291,
367,
10015,
641,
10677,
1163,
2419,
10130,
14,
199,
199,
1918,
4046,
21355,
15116,
14,
2424,
1077,
7684,
6555,
1006,
11336,
14,
9738,
12,
199,
16990,
365,
282,
15015,
3382,
4902,
436,
19773,
543,
8794,
370,
25833,
14,
2900,
12454,
199,
1530,
6326,
370,
1736,
6818,
642,
12,
1325,
21355,
15026,
542,
397,
446,
16239,
28925,
928,
13,
923,
465,
282,
199,
4342,
436,
22743,
28908,
652,
14,
3709,
282,
754,
314,
1072,
402,
642,
4306,
199,
5626,
440,
506,
295,
1857,
641,
367,
10015,
14,
199,
199,
11423,
1808,
543,
1022,
32176,
12,
675,
1015,
841,
14,
20,
26240,
26902,
5459,
402,
1022,
32176,
911,
199,
1397,
506,
7688,
370,
2342,
314,
1406,
570,
6602,
11736,
315,
314,
4046,
199,
27984,
15116,
14,
2424,
570,
14,
199,
624,
199,
199,
646,
12866,
199,
646,
747,
199,
646,
4673,
199,
646,
1059,
199,
646,
3873,
199,
646,
4902,
14,
2330,
199,
199,
4679,
63,
885,
63,
3669,
275,
469,
523,
283,
21623,
63,
6351,
356,
3260,
523,
283,
21623,
63,
12273,
356,
3260,
523,
283,
10449,
63,
5617,
63,
6351,
356,
283,
773,
297,
523,
283,
10449,
63,
5617,
63,
12273,
356,
1987,
65,
297,
523,
283,
13772,
63,
5617,
63,
6351,
356,
283,
773,
297,
523,
283,
13772,
63,
5617,
63,
12273,
356,
1987,
1152,
297,
523,
283,
13772,
63,
5617,
63,
3022,
356,
20044,
21728,
5995,
773,
14,
10545,
16892,
7293,
523,
283,
5617,
63,
3022,
356,
20044,
1113,
5565,
10545,
16892,
7293,
523,
283,
23227,
63,
3022,
356,
20044,
1113,
5565,
10545,
16892,
5995,
10545,
9268,
5995,
2268,
73,
297,
523,
283,
13772,
63,
23227,
63,
3022,
356,
20044,
1113,
5995,
2268,
297,
523,
283,
14853,
63,
3022,
356,
20044,
21728,
7293,
523,
283,
13578,
63,
7321,
63,
3243,
356,
20044,
13578,
63,
7321,
63,
3243,
7293,
523,
283,
13578,
63,
7321,
63,
3022,
2339,
356,
20044,
13578,
63,
7321,
63,
3022,
2339,
7293,
523,
283,
13578,
63,
7321,
63,
2339,
356,
20044,
13578,
63,
7321,
63,
2339,
7293,
523,
283,
13578,
63,
7321,
63,
5441,
356,
20044,
13578,
63,
7321,
63,
5441,
7293,
523,
283,
13578,
63,
7321,
63,
2472,
356,
20044,
13578,
63,
7321,
63,
2472,
7293,
523,
283,
22212,
63,
2339,
356,
20044,
4758,
7293,
199,
93,
199,
199,
14742,
63,
3243,
63,
21367,
275,
661,
10545,
30250,
63,
10187,
63,
3022,
7293,
20044,
21728,
7293,
20044,
1113,
12216,
199,
199,
4679,
63,
9823,
63,
6048,
63,
30116,
275,
715,
199,
4679,
63,
28789,
63,
1986,
63,
4342,
63,
5714,
63,
23395,
275,
715,
199,
199,
6790,
1193,
2617,
63,
18451,
275,
469,
523,
1987,
67,
356,
283,
2055,
297,
523,
1987,
2055,
356,
283,
9634,
297,
523,
1987,
5910,
356,
283,
9634,
297,
523,
1987,
9634,
356,
283,
9634,
297,
523,
1987,
83,
356,
283,
83,
297,
327,
7429,
523,
1987,
51,
356,
283,
83,
297,
327,
7429,
199,
93,
421,
199,
318,
5852,
4793,
8,
65,
12,
2403,
304,
523,
408,
3407,
283,
65,
7,
1928,
283,
1861,
7,
340,
652,
9174,
543,
283,
1861,
23690,
523,
372,
282,
59,
552,
8,
1861,
15405,
340,
282,
14,
2460,
8,
1861,
9,
587,
282,
421,
199,
318,
12707,
11458,
8,
885,
63,
3669,
12,
1862,
304,
523,
408,
14860,
4722,
2860,
367,
675,
315,
314,
1900,
334,
3527,
701,
4902,
10477,
523,
849,
63,
3669,
14,
5486,
360,
3100,
297,
4902,
14,
2330,
14,
1002,
16739,
8,
1162,
430,
421,
199,
318,
3599,
382,
461,
8,
1501,
304,
523,
408,
1767,
2549,
340,
314,
570,
365,
1013,
382,
461,
334,
5626,
506,
315,
28652,
11378,
10477,
523,
372,
1263,
8,
1501,
14,
4130,
8,
69,
9,
367,
325,
315,
16503,
1193,
2617,
63,
18451,
9,
421,
199,
318,
10967,
461,
8,
1501,
304,
523,
408,
1767,
2549,
340,
314,
570,
365,
30258,
334,
5626,
506,
641,
314,
2142,
1004,
10477,
523,
372,
1788,
14,
4130,
5175,
79,
358,
421,
199,
318,
20800,
904,
2042,
13606,
27984,
2980,
8,
1095,
63,
515,
12,
4668,
63,
515,
304,
523,
408,
1322,
393,
2310,
4668,
63,
515,
6169,
1300,
63,
515,
436,
2529,
314,
754,
14,
819,
982,
4668,
63,
515,
365,
376,
3679,
931,
652,
365,
2138,
14874,
14,
523,
6630,
652,
365,
12152,
6169,
1300,
63,
515,
436,
9657,
14,
523,
982,
314,
754,
365,
282,
3847,
931,
12,
652,
365,
19565,
370,
506,
3847,
370,
314,
523,
21355,
15116,
14,
2424,
14,
523,
408,
523,
340,
747,
14,
515,
14,
17896,
8,
3369,
63,
515,
304,
272,
372,
4668,
63,
515,
523,
340,
1263,
779,
3369,
63,
515,
14,
2460,
8,
1391,
9,
367,
2729,
315,
18530,
63,
3243,
63,
21367,
4682,
272,
372,
4668,
63,
515,
523,
327,
3254,
26,
886,
781,
1929,
370,
1104,
1300,
63,
515,
367,
3679,
2860,
465,
5521,
31,
523,
372,
747,
14,
515,
14,
904,
360,
10545,
30250,
63,
10187,
63,
3022,
7293,
1993,
747,
14,
515,
14,
9267,
8,
736,
14,
515
] |
[
1898,
334,
67,
9,
6171,
4475,
3277,
14,
2900,
4481,
4644,
14,
199,
3,
3645,
402,
642,
1350,
1233,
365,
10413,
701,
282,
6289,
13,
2487,
4190,
626,
883,
506,
199,
3,
1911,
315,
314,
5113,
570,
14,
199,
199,
624,
16472,
1072,
859,
199,
199,
2765,
859,
365,
1334,
16367,
436,
1077,
506,
8652,
22820,
14,
199,
199,
2765,
859,
16904,
19773,
334,
18,
14,
24,
14,
24,
8771,
1324,
465,
2399,
1072,
14,
7309,
21355,
15116,
14,
2424,
365,
199,
3966,
367,
1924,
2897,
14,
199,
199,
2765,
859,
1159,
3379,
12016,
1990,
370,
2291,
20401,
315,
473,
1093,
83,
2839,
1804,
872,
7549,
199,
6777,
675,
21355,
367,
2199,
10041,
14,
2779,
365,
2597,
3962,
370,
675,
21355,
370,
199,
4208,
11336,
367,
1163,
473,
1093,
83,
4066,
465,
325,
7548,
261,
286,
3583,
436,
1233,
447,
4166,
14,
3959,
17523,
199,
14117,
3957,
314,
21355,
15116,
14,
2424,
370,
282,
1233,
447,
4166,
7434,
80,
367,
314,
8823,
370,
1586,
12,
199,
7911,
1900,
1808,
21355,
14,
3709,
282,
754,
3959,
17523,
8823,
365,
625,
14600,
402,
6365,
199,
14334,
14,
710,
4046,
21355,
15116,
14,
2424,
883,
2597,
506,
1202,
370,
1900,
641,
10130,
14,
6006,
199,
374,
5544,
949,
2291,
367,
10015,
641,
10677,
1163,
2419,
10130,
14,
199,
199,
1918,
4046,
21355,
15116,
14,
2424,
1077,
7684,
6555,
1006,
11336,
14,
9738,
12,
199,
16990,
365,
282,
15015,
3382,
4902,
436,
19773,
543,
8794,
370,
25833,
14,
2900,
12454,
199,
1530,
6326,
370,
1736,
6818,
642,
12,
1325,
21355,
15026,
542,
397,
446,
16239,
28925,
928,
13,
923,
465,
282,
199,
4342,
436,
22743,
28908,
652,
14,
3709,
282,
754,
314,
1072,
402,
642,
4306,
199,
5626,
440,
506,
295,
1857,
641,
367,
10015,
14,
199,
199,
11423,
1808,
543,
1022,
32176,
12,
675,
1015,
841,
14,
20,
26240,
26902,
5459,
402,
1022,
32176,
911,
199,
1397,
506,
7688,
370,
2342,
314,
1406,
570,
6602,
11736,
315,
314,
4046,
199,
27984,
15116,
14,
2424,
570,
14,
199,
624,
199,
199,
646,
12866,
199,
646,
747,
199,
646,
4673,
199,
646,
1059,
199,
646,
3873,
199,
646,
4902,
14,
2330,
199,
199,
4679,
63,
885,
63,
3669,
275,
469,
523,
283,
21623,
63,
6351,
356,
3260,
523,
283,
21623,
63,
12273,
356,
3260,
523,
283,
10449,
63,
5617,
63,
6351,
356,
283,
773,
297,
523,
283,
10449,
63,
5617,
63,
12273,
356,
1987,
65,
297,
523,
283,
13772,
63,
5617,
63,
6351,
356,
283,
773,
297,
523,
283,
13772,
63,
5617,
63,
12273,
356,
1987,
1152,
297,
523,
283,
13772,
63,
5617,
63,
3022,
356,
20044,
21728,
5995,
773,
14,
10545,
16892,
7293,
523,
283,
5617,
63,
3022,
356,
20044,
1113,
5565,
10545,
16892,
7293,
523,
283,
23227,
63,
3022,
356,
20044,
1113,
5565,
10545,
16892,
5995,
10545,
9268,
5995,
2268,
73,
297,
523,
283,
13772,
63,
23227,
63,
3022,
356,
20044,
1113,
5995,
2268,
297,
523,
283,
14853,
63,
3022,
356,
20044,
21728,
7293,
523,
283,
13578,
63,
7321,
63,
3243,
356,
20044,
13578,
63,
7321,
63,
3243,
7293,
523,
283,
13578,
63,
7321,
63,
3022,
2339,
356,
20044,
13578,
63,
7321,
63,
3022,
2339,
7293,
523,
283,
13578,
63,
7321,
63,
2339,
356,
20044,
13578,
63,
7321,
63,
2339,
7293,
523,
283,
13578,
63,
7321,
63,
5441,
356,
20044,
13578,
63,
7321,
63,
5441,
7293,
523,
283,
13578,
63,
7321,
63,
2472,
356,
20044,
13578,
63,
7321,
63,
2472,
7293,
523,
283,
22212,
63,
2339,
356,
20044,
4758,
7293,
199,
93,
199,
199,
14742,
63,
3243,
63,
21367,
275,
661,
10545,
30250,
63,
10187,
63,
3022,
7293,
20044,
21728,
7293,
20044,
1113,
12216,
199,
199,
4679,
63,
9823,
63,
6048,
63,
30116,
275,
715,
199,
4679,
63,
28789,
63,
1986,
63,
4342,
63,
5714,
63,
23395,
275,
715,
199,
199,
6790,
1193,
2617,
63,
18451,
275,
469,
523,
1987,
67,
356,
283,
2055,
297,
523,
1987,
2055,
356,
283,
9634,
297,
523,
1987,
5910,
356,
283,
9634,
297,
523,
1987,
9634,
356,
283,
9634,
297,
523,
1987,
83,
356,
283,
83,
297,
327,
7429,
523,
1987,
51,
356,
283,
83,
297,
327,
7429,
199,
93,
421,
199,
318,
5852,
4793,
8,
65,
12,
2403,
304,
523,
408,
3407,
283,
65,
7,
1928,
283,
1861,
7,
340,
652,
9174,
543,
283,
1861,
23690,
523,
372,
282,
59,
552,
8,
1861,
15405,
340,
282,
14,
2460,
8,
1861,
9,
587,
282,
421,
199,
318,
12707,
11458,
8,
885,
63,
3669,
12,
1862,
304,
523,
408,
14860,
4722,
2860,
367,
675,
315,
314,
1900,
334,
3527,
701,
4902,
10477,
523,
849,
63,
3669,
14,
5486,
360,
3100,
297,
4902,
14,
2330,
14,
1002,
16739,
8,
1162,
430,
421,
199,
318,
3599,
382,
461,
8,
1501,
304,
523,
408,
1767,
2549,
340,
314,
570,
365,
1013,
382,
461,
334,
5626,
506,
315,
28652,
11378,
10477,
523,
372,
1263,
8,
1501,
14,
4130,
8,
69,
9,
367,
325,
315,
16503,
1193,
2617,
63,
18451,
9,
421,
199,
318,
10967,
461,
8,
1501,
304,
523,
408,
1767,
2549,
340,
314,
570,
365,
30258,
334,
5626,
506,
641,
314,
2142,
1004,
10477,
523,
372,
1788,
14,
4130,
5175,
79,
358,
421,
199,
318,
20800,
904,
2042,
13606,
27984,
2980,
8,
1095,
63,
515,
12,
4668,
63,
515,
304,
523,
408,
1322,
393,
2310,
4668,
63,
515,
6169,
1300,
63,
515,
436,
2529,
314,
754,
14,
819,
982,
4668,
63,
515,
365,
376,
3679,
931,
652,
365,
2138,
14874,
14,
523,
6630,
652,
365,
12152,
6169,
1300,
63,
515,
436,
9657,
14,
523,
982,
314,
754,
365,
282,
3847,
931,
12,
652,
365,
19565,
370,
506,
3847,
370,
314,
523,
21355,
15116,
14,
2424,
14,
523,
408,
523,
340,
747,
14,
515,
14,
17896,
8,
3369,
63,
515,
304,
272,
372,
4668,
63,
515,
523,
340,
1263,
779,
3369,
63,
515,
14,
2460,
8,
1391,
9,
367,
2729,
315,
18530,
63,
3243,
63,
21367,
4682,
272,
372,
4668,
63,
515,
523,
327,
3254,
26,
886,
781,
1929,
370,
1104,
1300,
63,
515,
367,
3679,
2860,
465,
5521,
31,
523,
372,
747,
14,
515,
14,
904,
360,
10545,
30250,
63,
10187,
63,
3022,
7293,
1993,
747,
14,
515,
14,
9267,
8,
736,
14,
515,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
mguentner/tomahawk
|
thirdparty/breakpad/third_party/protobuf/protobuf/python/google/protobuf/internal/wire_format.py
|
561
|
8431
|
# Protocol Buffers - Google's data interchange format
# Copyright 2008 Google Inc. All rights reserved.
# http://code.google.com/p/protobuf/
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""Constants and static functions to support protocol buffer wire format."""
__author__ = 'robinson@google.com (Will Robinson)'
import struct
from google.protobuf import descriptor
from google.protobuf import message
TAG_TYPE_BITS = 3 # Number of bits used to hold type info in a proto tag.
TAG_TYPE_MASK = (1 << TAG_TYPE_BITS) - 1 # 0x7
# These numbers identify the wire type of a protocol buffer value.
# We use the least-significant TAG_TYPE_BITS bits of the varint-encoded
# tag-and-type to store one of these WIRETYPE_* constants.
# These values must match WireType enum in google/protobuf/wire_format.h.
WIRETYPE_VARINT = 0
WIRETYPE_FIXED64 = 1
WIRETYPE_LENGTH_DELIMITED = 2
WIRETYPE_START_GROUP = 3
WIRETYPE_END_GROUP = 4
WIRETYPE_FIXED32 = 5
_WIRETYPE_MAX = 5
# Bounds for various integer types.
INT32_MAX = int((1 << 31) - 1)
INT32_MIN = int(-(1 << 31))
UINT32_MAX = (1 << 32) - 1
INT64_MAX = (1 << 63) - 1
INT64_MIN = -(1 << 63)
UINT64_MAX = (1 << 64) - 1
# "struct" format strings that will encode/decode the specified formats.
FORMAT_UINT32_LITTLE_ENDIAN = '<I'
FORMAT_UINT64_LITTLE_ENDIAN = '<Q'
FORMAT_FLOAT_LITTLE_ENDIAN = '<f'
FORMAT_DOUBLE_LITTLE_ENDIAN = '<d'
# We'll have to provide alternate implementations of AppendLittleEndian*() on
# any architectures where these checks fail.
if struct.calcsize(FORMAT_UINT32_LITTLE_ENDIAN) != 4:
raise AssertionError('Format "I" is not a 32-bit number.')
if struct.calcsize(FORMAT_UINT64_LITTLE_ENDIAN) != 8:
raise AssertionError('Format "Q" is not a 64-bit number.')
def PackTag(field_number, wire_type):
"""Returns an unsigned 32-bit integer that encodes the field number and
wire type information in standard protocol message wire format.
Args:
field_number: Expected to be an integer in the range [1, 1 << 29)
wire_type: One of the WIRETYPE_* constants.
"""
if not 0 <= wire_type <= _WIRETYPE_MAX:
raise message.EncodeError('Unknown wire type: %d' % wire_type)
return (field_number << TAG_TYPE_BITS) | wire_type
def UnpackTag(tag):
"""The inverse of PackTag(). Given an unsigned 32-bit number,
returns a (field_number, wire_type) tuple.
"""
return (tag >> TAG_TYPE_BITS), (tag & TAG_TYPE_MASK)
def ZigZagEncode(value):
"""ZigZag Transform: Encodes signed integers so that they can be
effectively used with varint encoding. See wire_format.h for
more details.
"""
if value >= 0:
return value << 1
return (value << 1) ^ (~0)
def ZigZagDecode(value):
"""Inverse of ZigZagEncode()."""
if not value & 0x1:
return value >> 1
return (value >> 1) ^ (~0)
# The *ByteSize() functions below return the number of bytes required to
# serialize "field number + type" information and then serialize the value.
def Int32ByteSize(field_number, int32):
return Int64ByteSize(field_number, int32)
def Int32ByteSizeNoTag(int32):
return _VarUInt64ByteSizeNoTag(0xffffffffffffffff & int32)
def Int64ByteSize(field_number, int64):
# Have to convert to uint before calling UInt64ByteSize().
return UInt64ByteSize(field_number, 0xffffffffffffffff & int64)
def UInt32ByteSize(field_number, uint32):
return UInt64ByteSize(field_number, uint32)
def UInt64ByteSize(field_number, uint64):
return TagByteSize(field_number) + _VarUInt64ByteSizeNoTag(uint64)
def SInt32ByteSize(field_number, int32):
return UInt32ByteSize(field_number, ZigZagEncode(int32))
def SInt64ByteSize(field_number, int64):
return UInt64ByteSize(field_number, ZigZagEncode(int64))
def Fixed32ByteSize(field_number, fixed32):
return TagByteSize(field_number) + 4
def Fixed64ByteSize(field_number, fixed64):
return TagByteSize(field_number) + 8
def SFixed32ByteSize(field_number, sfixed32):
return TagByteSize(field_number) + 4
def SFixed64ByteSize(field_number, sfixed64):
return TagByteSize(field_number) + 8
def FloatByteSize(field_number, flt):
return TagByteSize(field_number) + 4
def DoubleByteSize(field_number, double):
return TagByteSize(field_number) + 8
def BoolByteSize(field_number, b):
return TagByteSize(field_number) + 1
def EnumByteSize(field_number, enum):
return UInt32ByteSize(field_number, enum)
def StringByteSize(field_number, string):
return BytesByteSize(field_number, string.encode('utf-8'))
def BytesByteSize(field_number, b):
return (TagByteSize(field_number)
+ _VarUInt64ByteSizeNoTag(len(b))
+ len(b))
def GroupByteSize(field_number, message):
return (2 * TagByteSize(field_number) # START and END group.
+ message.ByteSize())
def MessageByteSize(field_number, message):
return (TagByteSize(field_number)
+ _VarUInt64ByteSizeNoTag(message.ByteSize())
+ message.ByteSize())
def MessageSetItemByteSize(field_number, msg):
# First compute the sizes of the tags.
# There are 2 tags for the beginning and ending of the repeated group, that
# is field number 1, one with field number 2 (type_id) and one with field
# number 3 (message).
total_size = (2 * TagByteSize(1) + TagByteSize(2) + TagByteSize(3))
# Add the number of bytes for type_id.
total_size += _VarUInt64ByteSizeNoTag(field_number)
message_size = msg.ByteSize()
# The number of bytes for encoding the length of the message.
total_size += _VarUInt64ByteSizeNoTag(message_size)
# The size of the message.
total_size += message_size
return total_size
def TagByteSize(field_number):
"""Returns the bytes required to serialize a tag with this field number."""
# Just pass in type 0, since the type won't affect the tag+type size.
return _VarUInt64ByteSizeNoTag(PackTag(field_number, 0))
# Private helper function for the *ByteSize() functions above.
def _VarUInt64ByteSizeNoTag(uint64):
"""Returns the number of bytes required to serialize a single varint
using boundary value comparisons. (unrolled loop optimization -WPierce)
uint64 must be unsigned.
"""
if uint64 <= 0x7f: return 1
if uint64 <= 0x3fff: return 2
if uint64 <= 0x1fffff: return 3
if uint64 <= 0xfffffff: return 4
if uint64 <= 0x7ffffffff: return 5
if uint64 <= 0x3ffffffffff: return 6
if uint64 <= 0x1ffffffffffff: return 7
if uint64 <= 0xffffffffffffff: return 8
if uint64 <= 0x7fffffffffffffff: return 9
if uint64 > UINT64_MAX:
raise message.EncodeError('Value out of range: %d' % uint64)
return 10
NON_PACKABLE_TYPES = (
descriptor.FieldDescriptor.TYPE_STRING,
descriptor.FieldDescriptor.TYPE_GROUP,
descriptor.FieldDescriptor.TYPE_MESSAGE,
descriptor.FieldDescriptor.TYPE_BYTES
)
def IsTypePackable(field_type):
"""Return true iff packable = true is valid for fields of this type.
Args:
field_type: a FieldDescriptor::Type value.
Returns:
True iff fields of this type are packable.
"""
return field_type not in NON_PACKABLE_TYPES
|
gpl-3.0
|
[
3,
11557,
699,
3043,
1192,
446,
4475,
1159,
666,
1640,
1461,
1475,
199,
3,
1898,
9079,
4475,
3277,
14,
221,
2900,
4481,
4644,
14,
199,
3,
1455,
921,
600,
14,
3098,
14,
957,
15,
80,
15,
7204,
15,
199,
3,
199,
3,
10114,
436,
675,
315,
1350,
436,
3366,
4513,
12,
543,
503,
1928,
199,
3,
7100,
12,
787,
8211,
2741,
626,
314,
2569,
3704,
787,
199,
3,
7647,
26,
199,
3,
199,
3,
258,
627,
6823,
402,
1350,
1233,
1471,
8074,
314,
3432,
4248,
199,
3,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
14,
199,
3,
258,
627,
6823,
315,
3366,
1824,
1471,
9172,
314,
3432,
199,
3,
4248,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
199,
3,
315,
314,
3794,
436,
15,
269,
1163,
8418,
2741,
543,
314,
199,
3,
4084,
14,
199,
3,
258,
627,
11443,
314,
536,
402,
4475,
3277,
14,
6590,
314,
1561,
402,
2399,
199,
3,
8417,
1443,
506,
1202,
370,
10692,
503,
10016,
7585,
7131,
687,
199,
3,
642,
2032,
1928,
2488,
6791,
5313,
4983,
14,
199,
3,
199,
3,
5749,
4141,
2281,
7049,
6515,
2334,
5877,
8164,
2401,
6483,
199,
3,
298,
1179,
2281,
2,
2401,
1821,
7168,
1549,
5292,
2990,
12,
6931,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
2334,
5292,
2990,
1634,
3169,
2401,
3092,
2381,
199,
3,
437,
3115,
3104,
9315,
9706,
14,
1621,
4825,
6461,
7000,
2334,
5877,
199,
3,
11489,
1549,
6483,
6262,
7024,
2381,
1821,
8703,
12,
9168,
12,
9716,
12,
199,
3,
8820,
12,
9836,
12,
1549,
9110,
6736,
334,
6446,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
9838,
1634,
9103,
9764,
1549,
9714,
27,
9102,
1634,
4815,
12,
199,
3,
7126,
12,
1549,
9206,
27,
1549,
9748,
9831,
9,
9802,
9817,
2401,
5258,
1821,
199,
3,
9815,
1634,
5603,
12,
7061,
1621,
7066,
12,
9644,
5603,
12,
1549,
7056,
199,
3,
334,
6446,
9254,
1549,
7334,
9,
7043,
1621,
1821,
9683,
5738,
1634,
2334,
4815,
199,
3,
1634,
5749,
4141,
12,
9704,
8036,
9691,
1634,
2334,
9726,
1634,
9712,
9784,
14,
199,
199,
624,
22185,
436,
2955,
3423,
370,
2291,
4113,
3335,
11799,
1475,
1041,
199,
199,
363,
2502,
363,
275,
283,
28191,
834,
32,
3098,
14,
957,
334,
20326,
6848,
1393,
834,
3171,
199,
199,
646,
2702,
199,
504,
6233,
14,
7204,
492,
5872,
199,
504,
6233,
14,
7204,
492,
1245,
421,
199,
6967,
63,
2711,
63,
14662,
275,
650,
221,
327,
4860,
402,
5821,
1202,
370,
10266,
730,
2256,
315,
282,
4104,
1947,
14,
199,
6967,
63,
2711,
63,
12880,
275,
334,
17,
5213,
18395,
63,
2711,
63,
14662,
9,
446,
413,
221,
327,
378,
88,
23,
199,
199,
3,
5723,
5579,
10405,
314,
11799,
730,
402,
282,
4113,
3335,
574,
14,
199,
3,
2136,
675,
314,
5210,
13,
1037,
14266,
18395,
63,
2711,
63,
14662,
5821,
402,
314,
2729,
442,
13,
8167,
199,
3,
1947,
13,
460,
13,
466,
370,
3877,
1373,
402,
3520,
644,
30287,
15192,
5262,
14,
199,
3,
5723,
1338,
1471,
1336,
644,
3621,
804,
4952,
315,
6233,
15,
7204,
15,
11239,
63,
908,
14,
72,
14,
199,
31443,
63,
5568,
2919,
275,
378,
199,
31443,
63,
23837,
772,
275,
413,
199,
31443,
63,
9127,
63,
32717,
1149,
275,
499,
199,
31443,
63,
7363,
63,
7823,
275,
650,
199,
31443,
63,
3902,
63,
7823,
275,
841,
199,
31443,
63,
23837,
708,
275,
959,
199,
63,
31443,
63,
4283,
275,
959,
421,
199,
3,
21972,
83,
367,
7750,
3000,
2943,
14,
199,
2919,
708,
63,
4283,
275,
1109,
1332,
17,
5213,
7105,
9,
446,
413,
9,
199,
2919,
708,
63,
4896,
275,
1109,
2801,
8,
17,
5213,
7105,
430,
199,
17459,
708,
63,
4283,
275,
334,
17,
5213,
4337,
9,
446,
413,
199,
199,
2919,
772,
63,
4283,
275,
334,
17,
5213,
13668,
9,
446,
413,
199,
2919,
772,
63,
4896,
275,
24953,
17,
5213,
13668,
9,
199,
17459,
772,
63,
4283,
275,
334,
17,
5213,
5049,
9,
446,
413,
199,
199,
3,
298,
1820,
2,
1475,
3326,
626,
911,
3752,
15,
2708,
314,
2013,
6752,
14,
199,
4807,
63,
17459,
708,
63,
44,
31783,
63,
21046,
275,
2650,
41,
7,
199,
4807,
63,
17459,
772,
63,
44,
31783,
63,
21046,
275,
2650,
49,
7,
199,
4807,
63,
11783,
63,
44,
31783,
63,
21046,
275,
2650,
70,
7,
199,
4807,
63,
14989,
63,
44,
31783,
63,
21046,
275,
2650,
68,
7,
421,
199,
3,
2136,
7171,
1172,
370,
5647,
18034,
12591,
402,
18726,
44,
390,
1118,
1327,
6268,
10,
342,
641,
199,
3,
1263,
3819,
1175,
22004,
2382,
3520,
5920,
2449,
14,
199,
692,
2702,
14,
21691,
8,
4807,
63,
17459,
708,
63,
44,
31783,
63,
21046,
9,
1137,
841,
26,
523,
746,
9070,
360,
3484,
298,
41,
2,
365,
440,
282,
4337,
13,
2075,
1329,
2659,
199,
692,
2702,
14,
21691,
8,
4807,
63,
17459,
772,
63,
44,
31783,
63,
21046,
9,
1137,
1695,
26,
523,
746,
9070,
360,
3484,
298,
49,
2,
365,
440,
282,
5049,
13,
2075,
1329,
2659,
421,
199,
318,
9954,
1931,
8,
698,
63,
1955,
12,
11799,
63,
466,
304,
523,
408,
3407,
376,
7381,
4337,
13,
2075,
3000,
626,
3752,
83,
314,
901,
1329,
436,
523,
11799,
730,
2556,
315,
4465,
4113,
1245,
11799,
1475,
14,
819,
3033,
26,
272,
901,
63,
1955,
26,
13796,
370,
506,
376,
3000,
315,
314,
1425,
359,
17,
12,
413,
5213,
7349,
9,
272,
11799,
63,
466,
26,
7309,
402,
314,
644,
30287,
15192,
5262,
14,
523,
408,
523,
340,
440,
378,
2695,
11799,
63,
466,
2695,
485,
31443,
63,
4283,
26,
272,
746,
1245,
14,
19994,
360,
5912,
11799,
730,
26,
450,
68,
7,
450,
11799,
63,
466,
9,
523,
372,
334,
698,
63,
1955,
5213,
18395,
63,
2711,
63,
14662,
9,
1204,
11799,
63,
466,
421,
199,
318,
31017,
1931,
8,
1450,
304,
523,
408,
1918,
11484,
402,
9954,
1931,
1252,
221,
9138,
376,
7381,
4337,
13,
2075,
1329,
12,
523,
2529,
282,
334,
698,
63,
1955,
12,
11799,
63,
466,
9,
2008,
14,
523,
408,
523,
372,
334,
1450,
4331,
18395,
63,
2711,
63,
14662,
395,
334,
1450,
1253,
18395,
63,
2711,
63,
12880,
9,
421,
199,
318,
3107
] |
[
11557,
699,
3043,
1192,
446,
4475,
1159,
666,
1640,
1461,
1475,
199,
3,
1898,
9079,
4475,
3277,
14,
221,
2900,
4481,
4644,
14,
199,
3,
1455,
921,
600,
14,
3098,
14,
957,
15,
80,
15,
7204,
15,
199,
3,
199,
3,
10114,
436,
675,
315,
1350,
436,
3366,
4513,
12,
543,
503,
1928,
199,
3,
7100,
12,
787,
8211,
2741,
626,
314,
2569,
3704,
787,
199,
3,
7647,
26,
199,
3,
199,
3,
258,
627,
6823,
402,
1350,
1233,
1471,
8074,
314,
3432,
4248,
199,
3,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
14,
199,
3,
258,
627,
6823,
315,
3366,
1824,
1471,
9172,
314,
3432,
199,
3,
4248,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
199,
3,
315,
314,
3794,
436,
15,
269,
1163,
8418,
2741,
543,
314,
199,
3,
4084,
14,
199,
3,
258,
627,
11443,
314,
536,
402,
4475,
3277,
14,
6590,
314,
1561,
402,
2399,
199,
3,
8417,
1443,
506,
1202,
370,
10692,
503,
10016,
7585,
7131,
687,
199,
3,
642,
2032,
1928,
2488,
6791,
5313,
4983,
14,
199,
3,
199,
3,
5749,
4141,
2281,
7049,
6515,
2334,
5877,
8164,
2401,
6483,
199,
3,
298,
1179,
2281,
2,
2401,
1821,
7168,
1549,
5292,
2990,
12,
6931,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
2334,
5292,
2990,
1634,
3169,
2401,
3092,
2381,
199,
3,
437,
3115,
3104,
9315,
9706,
14,
1621,
4825,
6461,
7000,
2334,
5877,
199,
3,
11489,
1549,
6483,
6262,
7024,
2381,
1821,
8703,
12,
9168,
12,
9716,
12,
199,
3,
8820,
12,
9836,
12,
1549,
9110,
6736,
334,
6446,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
9838,
1634,
9103,
9764,
1549,
9714,
27,
9102,
1634,
4815,
12,
199,
3,
7126,
12,
1549,
9206,
27,
1549,
9748,
9831,
9,
9802,
9817,
2401,
5258,
1821,
199,
3,
9815,
1634,
5603,
12,
7061,
1621,
7066,
12,
9644,
5603,
12,
1549,
7056,
199,
3,
334,
6446,
9254,
1549,
7334,
9,
7043,
1621,
1821,
9683,
5738,
1634,
2334,
4815,
199,
3,
1634,
5749,
4141,
12,
9704,
8036,
9691,
1634,
2334,
9726,
1634,
9712,
9784,
14,
199,
199,
624,
22185,
436,
2955,
3423,
370,
2291,
4113,
3335,
11799,
1475,
1041,
199,
199,
363,
2502,
363,
275,
283,
28191,
834,
32,
3098,
14,
957,
334,
20326,
6848,
1393,
834,
3171,
199,
199,
646,
2702,
199,
504,
6233,
14,
7204,
492,
5872,
199,
504,
6233,
14,
7204,
492,
1245,
421,
199,
6967,
63,
2711,
63,
14662,
275,
650,
221,
327,
4860,
402,
5821,
1202,
370,
10266,
730,
2256,
315,
282,
4104,
1947,
14,
199,
6967,
63,
2711,
63,
12880,
275,
334,
17,
5213,
18395,
63,
2711,
63,
14662,
9,
446,
413,
221,
327,
378,
88,
23,
199,
199,
3,
5723,
5579,
10405,
314,
11799,
730,
402,
282,
4113,
3335,
574,
14,
199,
3,
2136,
675,
314,
5210,
13,
1037,
14266,
18395,
63,
2711,
63,
14662,
5821,
402,
314,
2729,
442,
13,
8167,
199,
3,
1947,
13,
460,
13,
466,
370,
3877,
1373,
402,
3520,
644,
30287,
15192,
5262,
14,
199,
3,
5723,
1338,
1471,
1336,
644,
3621,
804,
4952,
315,
6233,
15,
7204,
15,
11239,
63,
908,
14,
72,
14,
199,
31443,
63,
5568,
2919,
275,
378,
199,
31443,
63,
23837,
772,
275,
413,
199,
31443,
63,
9127,
63,
32717,
1149,
275,
499,
199,
31443,
63,
7363,
63,
7823,
275,
650,
199,
31443,
63,
3902,
63,
7823,
275,
841,
199,
31443,
63,
23837,
708,
275,
959,
199,
63,
31443,
63,
4283,
275,
959,
421,
199,
3,
21972,
83,
367,
7750,
3000,
2943,
14,
199,
2919,
708,
63,
4283,
275,
1109,
1332,
17,
5213,
7105,
9,
446,
413,
9,
199,
2919,
708,
63,
4896,
275,
1109,
2801,
8,
17,
5213,
7105,
430,
199,
17459,
708,
63,
4283,
275,
334,
17,
5213,
4337,
9,
446,
413,
199,
199,
2919,
772,
63,
4283,
275,
334,
17,
5213,
13668,
9,
446,
413,
199,
2919,
772,
63,
4896,
275,
24953,
17,
5213,
13668,
9,
199,
17459,
772,
63,
4283,
275,
334,
17,
5213,
5049,
9,
446,
413,
199,
199,
3,
298,
1820,
2,
1475,
3326,
626,
911,
3752,
15,
2708,
314,
2013,
6752,
14,
199,
4807,
63,
17459,
708,
63,
44,
31783,
63,
21046,
275,
2650,
41,
7,
199,
4807,
63,
17459,
772,
63,
44,
31783,
63,
21046,
275,
2650,
49,
7,
199,
4807,
63,
11783,
63,
44,
31783,
63,
21046,
275,
2650,
70,
7,
199,
4807,
63,
14989,
63,
44,
31783,
63,
21046,
275,
2650,
68,
7,
421,
199,
3,
2136,
7171,
1172,
370,
5647,
18034,
12591,
402,
18726,
44,
390,
1118,
1327,
6268,
10,
342,
641,
199,
3,
1263,
3819,
1175,
22004,
2382,
3520,
5920,
2449,
14,
199,
692,
2702,
14,
21691,
8,
4807,
63,
17459,
708,
63,
44,
31783,
63,
21046,
9,
1137,
841,
26,
523,
746,
9070,
360,
3484,
298,
41,
2,
365,
440,
282,
4337,
13,
2075,
1329,
2659,
199,
692,
2702,
14,
21691,
8,
4807,
63,
17459,
772,
63,
44,
31783,
63,
21046,
9,
1137,
1695,
26,
523,
746,
9070,
360,
3484,
298,
49,
2,
365,
440,
282,
5049,
13,
2075,
1329,
2659,
421,
199,
318,
9954,
1931,
8,
698,
63,
1955,
12,
11799,
63,
466,
304,
523,
408,
3407,
376,
7381,
4337,
13,
2075,
3000,
626,
3752,
83,
314,
901,
1329,
436,
523,
11799,
730,
2556,
315,
4465,
4113,
1245,
11799,
1475,
14,
819,
3033,
26,
272,
901,
63,
1955,
26,
13796,
370,
506,
376,
3000,
315,
314,
1425,
359,
17,
12,
413,
5213,
7349,
9,
272,
11799,
63,
466,
26,
7309,
402,
314,
644,
30287,
15192,
5262,
14,
523,
408,
523,
340,
440,
378,
2695,
11799,
63,
466,
2695,
485,
31443,
63,
4283,
26,
272,
746,
1245,
14,
19994,
360,
5912,
11799,
730,
26,
450,
68,
7,
450,
11799,
63,
466,
9,
523,
372,
334,
698,
63,
1955,
5213,
18395,
63,
2711,
63,
14662,
9,
1204,
11799,
63,
466,
421,
199,
318,
31017,
1931,
8,
1450,
304,
523,
408,
1918,
11484,
402,
9954,
1931,
1252,
221,
9138,
376,
7381,
4337,
13,
2075,
1329,
12,
523,
2529,
282,
334,
698,
63,
1955,
12,
11799,
63,
466,
9,
2008,
14,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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
fw1121/genomics
|
docs/source/conf.py
|
2
|
7884
|
# -*- coding: utf-8 -*-
#
# genomics-bcftbx documentation build configuration file, created by
# sphinx-quickstart on Thu Mar 19 12:09:50 2015.
#
# This file is execfile()d with the current directory set to its containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.
import sys, os
sys.path.append('../')
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#sys.path.insert(0, os.path.abspath('.'))
# -- General configuration -----------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
#needs_sphinx = '1.0'
# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = ['sphinx.ext.autodoc']
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# The suffix of source filenames.
source_suffix = '.rst'
# The encoding of source files.
#source_encoding = 'utf-8-sig'
# The master toctree document.
master_doc = 'index'
# General information about the project.
project = u'genomics-bcftbx'
copyright = u'2015, Peter Briggs'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
from bcftbx import get_version
version = get_version()
# The full version, including alpha/beta/rc tags.
release = get_version()
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#language = None
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
#today = ''
# Else, today_fmt is used as the format for a strftime call.
#today_fmt = '%B %d, %Y'
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = []
# The reST default role (used for this markup: `text`) to use for all documents.
#default_role = None
# If true, '()' will be appended to :func: etc. cross-reference text.
#add_function_parentheses = True
# If true, the current module name will be prepended to all description
# unit titles (such as .. function::).
#add_module_names = True
# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
#show_authors = False
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
# A list of ignored prefixes for module index sorting.
#modindex_common_prefix = []
# -- Options for HTML output ---------------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = 'default'
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#html_theme_options = {}
# Add any paths that contain custom themes here, relative to this directory.
#html_theme_path = []
# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
#html_title = None
# A shorter title for the navigation bar. Default is the same as html_title.
#html_short_title = None
# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
#html_logo = None
# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
#html_favicon = None
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
#html_last_updated_fmt = '%b %d, %Y'
# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
#html_use_smartypants = True
# Custom sidebar templates, maps document names to template names.
#html_sidebars = {}
# Additional templates that should be rendered to pages, maps page names to
# template names.
#html_additional_pages = {}
# If false, no module index is generated.
#html_domain_indices = True
# If false, no index is generated.
#html_use_index = True
# If true, the index is split into individual pages for each letter.
#html_split_index = False
# If true, links to the reST sources are added to the pages.
#html_show_sourcelink = True
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
#html_show_sphinx = True
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
#html_show_copyright = True
# If true, an OpenSearch description file will be output, and all pages will
# contain a <link> tag referring to it. The value of this option must be the
# base URL from which the finished HTML is served.
#html_use_opensearch = ''
# This is the file name suffix for HTML files (e.g. ".xhtml").
#html_file_suffix = None
# Output file base name for HTML help builder.
htmlhelp_basename = 'genomics-bcftbxdoc'
# -- Options for LaTeX output --------------------------------------------------
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#'preamble': '',
}
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
('index', 'genomics-bcftbx.tex', u'genomics-bcftbx Documentation',
u'Peter Briggs', 'manual'),
]
# The name of an image file (relative to this directory) to place at the top of
# the title page.
#latex_logo = None
# For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters.
#latex_use_parts = False
# If true, show page references after internal links.
#latex_show_pagerefs = False
# If true, show URL addresses after external links.
#latex_show_urls = False
# Documents to append as an appendix to all manuals.
#latex_appendices = []
# If false, no module index is generated.
#latex_domain_indices = True
# -- Options for manual page output --------------------------------------------
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'genomics-bcftbx', u'genomics-bcftbx Documentation',
[u'Peter Briggs'], 1)
]
# If true, show URL addresses after external links.
#man_show_urls = False
# -- Options for Texinfo output ------------------------------------------------
# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
('index', 'genomics-bcftbx', u'genomics-bcftbx Documentation',
u'Peter Briggs', 'genomics-bcftbx', 'One line description of project.',
'Miscellaneous'),
]
# Documents to append as an appendix to all manuals.
#texinfo_appendices = []
# If false, no module index is generated.
#texinfo_domain_indices = True
# How to display URL addresses: 'footnote', 'no', or 'inline'.
#texinfo_show_urls = 'footnote'
|
artistic-2.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
199,
3,
3805,
676,
2932,
13,
3776,
856,
13691,
3794,
1900,
2897,
570,
12,
2737,
701,
199,
3,
15882,
13,
28957,
641,
3868,
85,
16794,
5851,
3144,
26,
1643,
26,
1400,
6900,
14,
199,
3,
199,
3,
961,
570,
365,
22711,
342,
68,
543,
314,
1453,
2082,
663,
370,
2399,
3035,
2935,
14,
199,
3,
199,
3,
3390,
626,
440,
1006,
3962,
2897,
1338,
787,
3451,
315,
642,
199,
3,
18392,
570,
14,
199,
3,
199,
3,
2900,
2897,
1338,
1172,
282,
849,
27,
1338,
626,
787,
21804,
734,
199,
3,
14062,
370,
2498,
314,
849,
14,
199,
199,
646,
984,
12,
747,
199,
1274,
14,
515,
14,
740,
24592,
358,
199,
199,
3,
982,
5478,
334,
269,
4621,
370,
2213,
543,
29973,
9,
787,
315,
4573,
2082,
12,
199,
3,
1050,
3520,
6602,
370,
984,
14,
515,
2348,
14,
982,
314,
2082,
365,
3847,
370,
314,
199,
3,
3794,
1738,
12,
675,
747,
14,
515,
14,
4832,
370,
1852,
652,
3679,
12,
2839,
9164,
2348,
14,
199,
3,
1274,
14,
515,
14,
3176,
8,
16,
12,
747,
14,
515,
14,
4832,
24535,
199,
199,
3,
1553,
1696,
2897,
9527,
9858,
199,
199,
3,
982,
2195,
3794,
4839,
282,
13460,
10229,
1015,
12,
1174,
652,
2348,
14,
199,
3,
10065,
63,
8008,
275,
283,
17,
14,
16,
7,
199,
199,
3,
2654,
1263,
10229,
3329,
859,
1561,
2348,
12,
465,
3326,
14,
9322,
883,
506,
5478,
199,
3,
17262,
543,
10229,
334,
4579,
283,
8008,
14,
832,
24915,
503,
2195,
3537,
7869,
14,
199,
5359,
275,
788,
8008,
14,
832,
14,
28056,
418,
199,
199,
3,
2654,
1263,
3792,
626,
1395,
7009,
2348,
12,
3847,
370,
642,
2082,
14,
199,
5876,
63,
515,
275,
4044,
5876,
418,
199,
199,
3,
710,
4739,
402,
1350,
6203,
14,
199,
1365,
63,
4511,
275,
1987,
8332,
7,
199,
199,
3,
710,
2644,
402,
1350,
1584,
14,
199,
3,
1365,
63,
2991,
275,
283,
1624,
13,
24,
13,
4093,
7,
199,
199,
3,
710,
5288,
28310,
2213,
14,
199,
4133,
63,
1301,
275,
283,
1080,
7,
199,
199,
3,
1696,
2556,
3595,
314,
2199,
14,
199,
1715,
275,
399,
7,
2268,
676,
2932,
13,
3776,
856,
13691,
7,
199,
7307,
275,
399,
7,
7806,
12,
22912,
699,
322,
71,
458,
7,
199,
199,
3,
710,
1015,
2256,
367,
314,
2199,
1265,
3984,
29904,
12,
17795,
465,
8343,
367,
199,
3,
1204,
1023,
92,
436,
1204,
3221,
18712,
2597,
1202,
315,
7750,
1163,
9825,
23088,
314,
199,
3,
6137,
8247,
14,
199,
3,
199,
3,
710,
3974,
1323,
14,
57,
1015,
14,
199,
504,
16604,
856,
13691,
492,
664,
63,
1023,
199,
1023,
275,
664,
63,
1023,
342,
199,
3,
710,
2615,
1015,
12,
5893,
5131,
15,
5683,
15,
1195,
3762,
14,
199,
3221,
275,
664,
63,
1023,
342,
199,
199,
3,
710,
2637,
367,
1564,
18392,
701,
10229,
14,
21751,
370,
3794,
199,
3,
367,
282,
769,
402,
3748,
10815,
14,
199,
3,
3671,
275,
488,
199,
199,
3,
6006,
787,
2877,
1511,
367,
15810,
1204,
8136,
25004,
1902,
12,
1265,
663,
11168,
370,
2005,
199,
3,
2222,
13,
3910,
574,
12,
2066,
652,
365,
1202,
26,
199,
3,
8136,
275,
2125,
199,
3,
19524,
12,
11168,
63,
5045,
365,
1202,
465,
314,
1475,
367,
282,
14053,
1240,
14,
199,
3,
8136,
63,
5045,
275,
1543,
34,
450,
68,
12,
450,
57,
7,
199,
199,
3,
3820,
402,
7970,
12,
3847,
370,
1350,
2082,
12,
626,
1336,
1584,
436,
199,
3,
6602,
370,
3686,
1380,
10023,
367,
1350,
1584,
14,
199,
5473,
63,
7435,
275,
942,
199,
199,
3,
710,
20883,
849,
4719,
334,
2972,
367,
642,
9189,
26,
658,
505,
10522,
370,
675,
367,
1006,
8247,
14,
199,
3,
885,
63,
3756,
275,
488,
199,
199,
3,
982,
2549,
12,
26380,
911,
506,
11544,
370,
520,
1532,
26,
5423,
14,
8059,
13,
4443,
1318,
14,
199,
3,
525,
63,
1593,
63,
25510,
275,
715,
199,
199,
3,
982,
2549,
12,
314,
1453,
859,
536,
911,
506,
20247,
370,
1006,
1369,
199,
3,
4137,
16194,
334,
10180,
465,
2508,
805,
32469,
199,
3,
525,
63,
578,
63,
1247,
275,
715,
199,
199,
3,
982,
2549,
12,
3420,
2502,
436,
28966,
13502,
911,
506,
9164,
315,
314,
199,
3,
1072,
14,
9322,
787,
5525,
701,
849,
14,
199,
3,
2384,
63,
8149,
275,
756,
199,
199,
3,
710,
536,
402,
314,
14493,
334,
7093,
22437,
9,
3449,
370,
675,
14,
199,
12173,
63,
2487,
275,
283,
8008,
7,
199,
199,
3,
437,
769,
402,
5525,
13158,
367,
859,
1478,
13351,
14,
199,
3,
27555,
63,
2330,
63,
1861,
275,
942,
421,
199,
3,
1553,
8394,
367,
4163,
1072,
9527,
2595,
199,
199,
3,
710,
8879,
370,
675,
367,
4163,
436,
4163,
15456,
6497,
14,
221,
1666,
314,
3794,
367,
199,
3,
282,
769,
402,
6762,
17915,
14,
199,
1360,
63,
7915,
275,
283,
885,
7,
199,
199,
3,
23978,
1511,
787,
8879,
13,
6100,
436,
17551,
314,
3648,
436,
23109,
402,
282,
8879,
199,
3,
9848,
14,
221,
2104,
282,
769,
402,
1511,
2808,
367,
1924,
8879,
12,
1937,
314,
199,
3,
3794,
14,
199,
3,
1360,
63,
7915,
63,
1419,
275,
1052,
199,
199,
3,
2654,
1263,
3792,
626,
1395,
3537,
17915,
2348,
12,
3847,
370,
642,
2082,
14,
199,
3,
1360,
63,
7915,
63,
515,
275,
942,
199,
199,
3,
710,
536,
367,
642,
663,
402,
10229,
8247,
14,
221,
982,
488,
12,
652,
4243,
370,
199,
3,
3886,
1715,
30,
373,
28,
3221,
30,
3794,
1674,
199,
3,
1360,
63,
1213,
275,
488,
199,
199,
3,
437,
18299,
2538,
367,
314,
19191,
4681,
14,
221,
3758,
365,
314,
2011,
465,
3517,
63,
1213,
14,
199,
3,
1360,
63,
3612,
63,
1213,
275,
488,
199,
199,
3,
710,
536,
402,
376,
1834,
570,
334,
6188,
370,
642,
2082,
9,
370,
4192,
737,
314,
2746,
199,
3,
402,
314,
18437,
14,
199,
3,
1360,
63,
9733,
275,
488,
199,
199,
3,
710,
536,
402,
376,
1834,
570,
334,
12541,
314,
2955,
931,
9,
370,
675,
465,
29139,
402,
314,
199,
3,
9149,
14,
221,
961,
570,
1077,
506
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
199,
3,
3805,
676,
2932,
13,
3776,
856,
13691,
3794,
1900,
2897,
570,
12,
2737,
701,
199,
3,
15882,
13,
28957,
641,
3868,
85,
16794,
5851,
3144,
26,
1643,
26,
1400,
6900,
14,
199,
3,
199,
3,
961,
570,
365,
22711,
342,
68,
543,
314,
1453,
2082,
663,
370,
2399,
3035,
2935,
14,
199,
3,
199,
3,
3390,
626,
440,
1006,
3962,
2897,
1338,
787,
3451,
315,
642,
199,
3,
18392,
570,
14,
199,
3,
199,
3,
2900,
2897,
1338,
1172,
282,
849,
27,
1338,
626,
787,
21804,
734,
199,
3,
14062,
370,
2498,
314,
849,
14,
199,
199,
646,
984,
12,
747,
199,
1274,
14,
515,
14,
740,
24592,
358,
199,
199,
3,
982,
5478,
334,
269,
4621,
370,
2213,
543,
29973,
9,
787,
315,
4573,
2082,
12,
199,
3,
1050,
3520,
6602,
370,
984,
14,
515,
2348,
14,
982,
314,
2082,
365,
3847,
370,
314,
199,
3,
3794,
1738,
12,
675,
747,
14,
515,
14,
4832,
370,
1852,
652,
3679,
12,
2839,
9164,
2348,
14,
199,
3,
1274,
14,
515,
14,
3176,
8,
16,
12,
747,
14,
515,
14,
4832,
24535,
199,
199,
3,
1553,
1696,
2897,
9527,
9858,
199,
199,
3,
982,
2195,
3794,
4839,
282,
13460,
10229,
1015,
12,
1174,
652,
2348,
14,
199,
3,
10065,
63,
8008,
275,
283,
17,
14,
16,
7,
199,
199,
3,
2654,
1263,
10229,
3329,
859,
1561,
2348,
12,
465,
3326,
14,
9322,
883,
506,
5478,
199,
3,
17262,
543,
10229,
334,
4579,
283,
8008,
14,
832,
24915,
503,
2195,
3537,
7869,
14,
199,
5359,
275,
788,
8008,
14,
832,
14,
28056,
418,
199,
199,
3,
2654,
1263,
3792,
626,
1395,
7009,
2348,
12,
3847,
370,
642,
2082,
14,
199,
5876,
63,
515,
275,
4044,
5876,
418,
199,
199,
3,
710,
4739,
402,
1350,
6203,
14,
199,
1365,
63,
4511,
275,
1987,
8332,
7,
199,
199,
3,
710,
2644,
402,
1350,
1584,
14,
199,
3,
1365,
63,
2991,
275,
283,
1624,
13,
24,
13,
4093,
7,
199,
199,
3,
710,
5288,
28310,
2213,
14,
199,
4133,
63,
1301,
275,
283,
1080,
7,
199,
199,
3,
1696,
2556,
3595,
314,
2199,
14,
199,
1715,
275,
399,
7,
2268,
676,
2932,
13,
3776,
856,
13691,
7,
199,
7307,
275,
399,
7,
7806,
12,
22912,
699,
322,
71,
458,
7,
199,
199,
3,
710,
1015,
2256,
367,
314,
2199,
1265,
3984,
29904,
12,
17795,
465,
8343,
367,
199,
3,
1204,
1023,
92,
436,
1204,
3221,
18712,
2597,
1202,
315,
7750,
1163,
9825,
23088,
314,
199,
3,
6137,
8247,
14,
199,
3,
199,
3,
710,
3974,
1323,
14,
57,
1015,
14,
199,
504,
16604,
856,
13691,
492,
664,
63,
1023,
199,
1023,
275,
664,
63,
1023,
342,
199,
3,
710,
2615,
1015,
12,
5893,
5131,
15,
5683,
15,
1195,
3762,
14,
199,
3221,
275,
664,
63,
1023,
342,
199,
199,
3,
710,
2637,
367,
1564,
18392,
701,
10229,
14,
21751,
370,
3794,
199,
3,
367,
282,
769,
402,
3748,
10815,
14,
199,
3,
3671,
275,
488,
199,
199,
3,
6006,
787,
2877,
1511,
367,
15810,
1204,
8136,
25004,
1902,
12,
1265,
663,
11168,
370,
2005,
199,
3,
2222,
13,
3910,
574,
12,
2066,
652,
365,
1202,
26,
199,
3,
8136,
275,
2125,
199,
3,
19524,
12,
11168,
63,
5045,
365,
1202,
465,
314,
1475,
367,
282,
14053,
1240,
14,
199,
3,
8136,
63,
5045,
275,
1543,
34,
450,
68,
12,
450,
57,
7,
199,
199,
3,
3820,
402,
7970,
12,
3847,
370,
1350,
2082,
12,
626,
1336,
1584,
436,
199,
3,
6602,
370,
3686,
1380,
10023,
367,
1350,
1584,
14,
199,
5473,
63,
7435,
275,
942,
199,
199,
3,
710,
20883,
849,
4719,
334,
2972,
367,
642,
9189,
26,
658,
505,
10522,
370,
675,
367,
1006,
8247,
14,
199,
3,
885,
63,
3756,
275,
488,
199,
199,
3,
982,
2549,
12,
26380,
911,
506,
11544,
370,
520,
1532,
26,
5423,
14,
8059,
13,
4443,
1318,
14,
199,
3,
525,
63,
1593,
63,
25510,
275,
715,
199,
199,
3,
982,
2549,
12,
314,
1453,
859,
536,
911,
506,
20247,
370,
1006,
1369,
199,
3,
4137,
16194,
334,
10180,
465,
2508,
805,
32469,
199,
3,
525,
63,
578,
63,
1247,
275,
715,
199,
199,
3,
982,
2549,
12,
3420,
2502,
436,
28966,
13502,
911,
506,
9164,
315,
314,
199,
3,
1072,
14,
9322,
787,
5525,
701,
849,
14,
199,
3,
2384,
63,
8149,
275,
756,
199,
199,
3,
710,
536,
402,
314,
14493,
334,
7093,
22437,
9,
3449,
370,
675,
14,
199,
12173,
63,
2487,
275,
283,
8008,
7,
199,
199,
3,
437,
769,
402,
5525,
13158,
367,
859,
1478,
13351,
14,
199,
3,
27555,
63,
2330,
63,
1861,
275,
942,
421,
199,
3,
1553,
8394,
367,
4163,
1072,
9527,
2595,
199,
199,
3,
710,
8879,
370,
675,
367,
4163,
436,
4163,
15456,
6497,
14,
221,
1666,
314,
3794,
367,
199,
3,
282,
769,
402,
6762,
17915,
14,
199,
1360,
63,
7915,
275,
283,
885,
7,
199,
199,
3,
23978,
1511,
787,
8879,
13,
6100,
436,
17551,
314,
3648,
436,
23109,
402,
282,
8879,
199,
3,
9848,
14,
221,
2104,
282,
769,
402,
1511,
2808,
367,
1924,
8879,
12,
1937,
314,
199,
3,
3794,
14,
199,
3,
1360,
63,
7915,
63,
1419,
275,
1052,
199,
199,
3,
2654,
1263,
3792,
626,
1395,
3537,
17915,
2348,
12,
3847,
370,
642,
2082,
14,
199,
3,
1360,
63,
7915,
63,
515,
275,
942,
199,
199,
3,
710,
536,
367,
642,
663,
402,
10229,
8247,
14,
221,
982,
488,
12,
652,
4243,
370,
199,
3,
3886,
1715,
30,
373,
28,
3221,
30,
3794,
1674,
199,
3,
1360,
63,
1213,
275,
488,
199,
199,
3,
437,
18299,
2538,
367,
314,
19191,
4681,
14,
221,
3758,
365,
314,
2011,
465,
3517,
63,
1213,
14,
199,
3,
1360,
63,
3612,
63,
1213,
275,
488,
199,
199,
3,
710,
536,
402,
376,
1834,
570,
334,
6188,
370,
642,
2082,
9,
370,
4192,
737,
314,
2746,
199,
3,
402,
314,
18437,
14,
199,
3,
1360,
63,
9733,
275,
488,
199,
199,
3,
710,
536,
402,
376,
1834,
570,
334,
12541,
314,
2955,
931,
9,
370,
675,
465,
29139,
402,
314,
199,
3,
9149,
14,
221,
961,
570,
1077,
506,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
codepantry/django
|
django/shortcuts.py
|
129
|
7958
|
"""
This module collects helper functions and classes that "span" multiple levels
of MVC. In other words, these functions/classes introduce controlled coupling
for convenience's sake.
"""
import warnings
from django.core import urlresolvers
from django.db.models.base import ModelBase
from django.db.models.manager import Manager
from django.db.models.query import QuerySet
from django.http import (
Http404, HttpResponse, HttpResponsePermanentRedirect, HttpResponseRedirect,
)
from django.template import RequestContext, loader
from django.template.context import _current_app_undefined
from django.template.engine import (
_context_instance_undefined, _dictionary_undefined, _dirs_undefined,
)
from django.utils import six
from django.utils.deprecation import RemovedInDjango110Warning
from django.utils.encoding import force_text
from django.utils.functional import Promise
def render_to_response(template_name, context=None,
context_instance=_context_instance_undefined,
content_type=None, status=None, dirs=_dirs_undefined,
dictionary=_dictionary_undefined, using=None):
"""
Returns a HttpResponse whose content is filled with the result of calling
django.template.loader.render_to_string() with the passed arguments.
"""
if (context_instance is _context_instance_undefined
and dirs is _dirs_undefined
and dictionary is _dictionary_undefined):
# No deprecated arguments were passed - use the new code path
content = loader.render_to_string(template_name, context, using=using)
else:
# Some deprecated arguments were passed - use the legacy code path
content = loader.render_to_string(
template_name, context, context_instance, dirs, dictionary,
using=using)
return HttpResponse(content, content_type, status)
def render(request, template_name, context=None,
context_instance=_context_instance_undefined,
content_type=None, status=None, current_app=_current_app_undefined,
dirs=_dirs_undefined, dictionary=_dictionary_undefined,
using=None):
"""
Returns a HttpResponse whose content is filled with the result of calling
django.template.loader.render_to_string() with the passed arguments.
Uses a RequestContext by default.
"""
if (context_instance is _context_instance_undefined
and current_app is _current_app_undefined
and dirs is _dirs_undefined
and dictionary is _dictionary_undefined):
# No deprecated arguments were passed - use the new code path
# In Django 1.10, request should become a positional argument.
content = loader.render_to_string(
template_name, context, request=request, using=using)
else:
# Some deprecated arguments were passed - use the legacy code path
if context_instance is not _context_instance_undefined:
if current_app is not _current_app_undefined:
raise ValueError('If you provide a context_instance you must '
'set its current_app before calling render()')
else:
context_instance = RequestContext(request)
if current_app is not _current_app_undefined:
warnings.warn(
"The current_app argument of render is deprecated. "
"Set the current_app attribute of request instead.",
RemovedInDjango110Warning, stacklevel=2)
request.current_app = current_app
# Directly set the private attribute to avoid triggering the
# warning in RequestContext.__init__.
context_instance._current_app = current_app
content = loader.render_to_string(
template_name, context, context_instance, dirs, dictionary,
using=using)
return HttpResponse(content, content_type, status)
def redirect(to, *args, **kwargs):
"""
Returns an HttpResponseRedirect to the appropriate URL for the arguments
passed.
The arguments could be:
* A model: the model's `get_absolute_url()` function will be called.
* A view name, possibly with arguments: `urlresolvers.reverse()` will
be used to reverse-resolve the name.
* A URL, which will be used as-is for the redirect location.
By default issues a temporary redirect; pass permanent=True to issue a
permanent redirect
"""
if kwargs.pop('permanent', False):
redirect_class = HttpResponsePermanentRedirect
else:
redirect_class = HttpResponseRedirect
return redirect_class(resolve_url(to, *args, **kwargs))
def _get_queryset(klass):
"""
Returns a QuerySet from a Model, Manager, or QuerySet. Created to make
get_object_or_404 and get_list_or_404 more DRY.
Raises a ValueError if klass is not a Model, Manager, or QuerySet.
"""
if isinstance(klass, QuerySet):
return klass
elif isinstance(klass, Manager):
manager = klass
elif isinstance(klass, ModelBase):
manager = klass._default_manager
else:
if isinstance(klass, type):
klass__name = klass.__name__
else:
klass__name = klass.__class__.__name__
raise ValueError("Object is of type '%s', but must be a Django Model, "
"Manager, or QuerySet" % klass__name)
return manager.all()
def get_object_or_404(klass, *args, **kwargs):
"""
Uses get() to return an object, or raises a Http404 exception if the object
does not exist.
klass may be a Model, Manager, or QuerySet object. All other passed
arguments and keyword arguments are used in the get() query.
Note: Like with get(), an MultipleObjectsReturned will be raised if more than one
object is found.
"""
queryset = _get_queryset(klass)
try:
return queryset.get(*args, **kwargs)
except queryset.model.DoesNotExist:
raise Http404('No %s matches the given query.' % queryset.model._meta.object_name)
def get_list_or_404(klass, *args, **kwargs):
"""
Uses filter() to return a list of objects, or raise a Http404 exception if
the list is empty.
klass may be a Model, Manager, or QuerySet object. All other passed
arguments and keyword arguments are used in the filter() query.
"""
queryset = _get_queryset(klass)
obj_list = list(queryset.filter(*args, **kwargs))
if not obj_list:
raise Http404('No %s matches the given query.' % queryset.model._meta.object_name)
return obj_list
def resolve_url(to, *args, **kwargs):
"""
Return a URL appropriate for the arguments passed.
The arguments could be:
* A model: the model's `get_absolute_url()` function will be called.
* A view name, possibly with arguments: `urlresolvers.reverse()` will
be used to reverse-resolve the name.
* A URL, which will be returned as-is.
"""
# If it's a model, use get_absolute_url()
if hasattr(to, 'get_absolute_url'):
return to.get_absolute_url()
if isinstance(to, Promise):
# Expand the lazy instance, as it can cause issues when it is passed
# further to some Python functions like urlparse.
to = force_text(to)
if isinstance(to, six.string_types):
# Handle relative URLs
if to.startswith(('./', '../')):
return to
# Next try a reverse URL resolution.
try:
return urlresolvers.reverse(to, args=args, kwargs=kwargs)
except urlresolvers.NoReverseMatch:
# If this is a callable, re-raise.
if callable(to):
raise
# If this doesn't "feel" like a URL, re-raise.
if '/' not in to and '.' not in to:
raise
# Finally, fall back and assume it's a URL
return to
|
bsd-3-clause
|
[
624,
199,
2765,
859,
8775,
83,
5922,
3423,
436,
3992,
626,
298,
3751,
2,
3663,
11106,
199,
1618,
603,
9454,
14,
1010,
1163,
5932,
12,
3520,
3423,
15,
2888,
13318,
3402,
22284,
512,
384,
2983,
199,
509,
16777,
1159,
308,
1728,
14,
199,
624,
199,
199,
646,
3598,
199,
199,
504,
1639,
14,
1018,
492,
32403,
199,
504,
1639,
14,
697,
14,
992,
14,
1095,
492,
5822,
1563,
199,
504,
1639,
14,
697,
14,
992,
14,
2609,
492,
13537,
199,
504,
1639,
14,
697,
14,
992,
14,
1131,
492,
18397,
199,
504,
1639,
14,
1014,
492,
334,
272,
4760,
5188,
12,
6183,
12,
6183,
31776,
7071,
12,
14935,
12,
199,
9,
199,
504,
1639,
14,
1160,
492,
22538,
12,
5077,
199,
504,
1639,
14,
1160,
14,
1100,
492,
485,
1818,
63,
571,
63,
10705,
199,
504,
1639,
14,
1160,
14,
3908,
492,
334,
272,
485,
1100,
63,
842,
63,
10705,
12,
485,
9086,
63,
10705,
12,
485,
3220,
63,
10705,
12,
199,
9,
199,
504,
1639,
14,
1208,
492,
3816,
199,
504,
1639,
14,
1208,
14,
15383,
492,
23687,
6019,
3849,
199,
504,
1639,
14,
1208,
14,
2991,
492,
3542,
63,
505,
199,
504,
1639,
14,
1208,
14,
15481,
492,
27724,
572,
421,
199,
318,
3795,
63,
475,
63,
1310,
8,
1160,
63,
354,
12,
1067,
29,
403,
12,
2432,
1067,
63,
842,
3699,
1100,
63,
842,
63,
10705,
12,
2432,
1564,
63,
466,
29,
403,
12,
2004,
29,
403,
12,
7606,
3699,
3220,
63,
10705,
12,
2432,
2600,
3699,
9086,
63,
10705,
12,
1808,
29,
403,
304,
272,
408,
272,
1803,
282,
6183,
7447,
1564,
365,
13457,
543,
314,
754,
402,
6358,
272,
1639,
14,
1160,
14,
3422,
14,
3352,
63,
475,
63,
875,
342,
543,
314,
3032,
2368,
14,
272,
408,
272,
340,
334,
1100,
63,
842,
365,
485,
1100,
63,
842,
63,
10705,
288,
436,
7606,
365,
485,
3220,
63,
10705,
288,
436,
2600,
365,
485,
9086,
63,
10705,
304,
267,
327,
3091,
5906,
2368,
4898,
3032,
446,
675,
314,
892,
1233,
931,
267,
1564,
275,
5077,
14,
3352,
63,
475,
63,
875,
8,
1160,
63,
354,
12,
1067,
12,
1808,
29,
4941,
9,
339,
587,
26,
267,
327,
6601,
5906,
2368,
4898,
3032,
446,
675,
314,
12139,
1233,
931,
267,
1564,
275,
5077,
14,
3352,
63,
475,
63,
875,
8,
288,
1978,
63,
354,
12,
1067,
12,
1067,
63,
842,
12,
7606,
12,
2600,
12,
288,
1808,
29,
4941,
9,
339,
372,
6183,
8,
1317,
12,
1564,
63,
466,
12,
2004,
9,
421,
199,
318,
3795,
8,
1069,
12,
1978,
63,
354,
12,
1067,
29,
403,
12,
1779,
1067,
63,
842,
3699,
1100,
63,
842,
63,
10705,
12,
1779,
1564,
63,
466,
29,
403,
12,
2004,
29,
403,
12,
1453,
63,
571,
3699,
1818,
63,
571,
63,
10705,
12,
1779,
7606,
3699,
3220,
63,
10705,
12,
2600,
3699,
9086,
63,
10705,
12,
1779,
1808,
29,
403,
304,
272,
408,
272,
1803,
282,
6183,
7447,
1564,
365,
13457,
543,
314,
754,
402,
6358,
272,
1639,
14,
1160,
14,
3422,
14,
3352,
63,
475,
63,
875,
342,
543,
314,
3032,
2368,
14,
272,
14911,
282,
22538,
701,
849,
14,
272,
408,
272,
340,
334,
1100,
63,
842,
365,
485,
1100,
63,
842,
63,
10705,
288,
436,
1453,
63,
571,
365,
485,
1818,
63,
571,
63,
10705,
288,
436,
7606,
365,
485,
3220,
63,
10705,
288,
436,
2600,
365,
485,
9086,
63,
10705,
304,
267,
327,
3091,
5906,
2368,
4898,
3032,
446,
675,
314,
892,
1233,
931,
267,
327,
1010,
5634,
413,
14,
709,
12,
1056,
1077,
8649,
282,
11333,
1423,
14,
267,
1564,
275,
5077,
14,
3352,
63,
475,
63,
875,
8,
288,
1978,
63,
354,
12,
1067,
12,
1056,
29,
1069,
12,
1808,
29,
4941,
9,
339,
587,
26,
267,
327,
6601,
5906,
2368,
4898,
3032,
446,
675,
314,
12139,
1233,
931,
267,
340,
1067,
63,
842,
365,
440,
485,
1100,
63,
842,
63,
10705,
26,
288,
340,
1453,
63,
571,
365,
440,
485,
1818,
63,
571,
63,
10705,
26,
355,
746,
1722,
360,
3917,
1265,
5647,
282,
1067,
63,
842,
1265,
1471,
283,
639,
283,
409,
2399,
1453,
63,
571,
2544,
6358,
3795,
19004,
267,
587,
26,
288,
1067,
63,
842,
275,
22538,
8,
1069,
9,
288,
340,
1453,
63,
571,
365,
440,
485,
1818,
63,
571,
63,
10705,
26,
355,
3598,
14,
4050,
8,
490,
298,
1918,
1453,
63,
571,
1423,
402,
3795,
365,
5906,
14,
298,
490,
298,
1084,
314,
1453,
63,
571,
2225,
402,
1056,
3140,
4765,
490,
23687,
6019,
3849,
12,
13232,
29,
18,
9,
355,
1056,
14,
1818,
63,
571,
275,
1453,
63,
571,
355,
327,
21128,
590,
663,
314,
5726,
2225,
370,
5126,
6804,
316,
314,
355,
327,
5721,
315,
22538,
855,
826,
4343,
355,
1067,
63,
842,
423,
1818,
63,
571,
275,
1453,
63,
571,
398,
1564,
275,
5077,
14,
3352,
63,
475,
63,
875,
8,
288,
1978,
63,
354,
12,
1067,
12,
1067,
63,
842,
12,
7606,
12,
2600,
12,
288,
1808,
29,
4941,
9,
339,
372,
6183,
8,
1317,
12,
1564,
63,
466,
12,
2004,
9,
421,
199,
318,
4660,
8,
475,
12,
627,
589,
12,
1011,
958,
304,
272,
408,
272,
1803,
376,
14935,
370,
314,
5827,
2851,
367,
314,
2368,
272,
3032,
14,
339,
710,
2368,
4293,
506,
26,
398,
627,
437,
1402,
26,
314,
1402,
1159,
658,
362,
63,
6116,
63,
633,
11995,
805,
911,
506,
2797,
14,
398,
627,
437,
2455,
536,
12,
12570,
543,
2368,
26,
658,
16522,
14,
4471,
11995,
911,
881,
506,
1202,
370,
3837,
13,
6983,
314,
536,
14,
398,
627,
437,
2851,
12,
1314,
911,
506,
1202,
465,
13,
374,
367,
314,
4660,
2909,
14,
339,
4885,
849,
10876,
282,
7937,
4660,
27,
986,
19860,
29,
549,
370,
4976,
282,
272,
19860,
4660,
272,
408,
272,
340,
2074,
14,
1935,
360,
19904,
297,
756,
304,
267,
4660,
63,
533,
275,
6183,
31776,
7071,
272,
587,
26,
267,
4660,
63,
533,
275,
14935,
339,
372,
4660,
63,
533,
8,
6983,
63,
633,
8,
475,
12,
627,
589,
12,
1011,
958,
430,
421,
199,
318,
485,
362,
63,
7924,
8,
11645,
304,
272,
408,
272,
1803,
282,
18397,
687,
282,
5822,
12,
13537,
12
] |
[
199,
2765,
859,
8775,
83,
5922,
3423,
436,
3992,
626,
298,
3751,
2,
3663,
11106,
199,
1618,
603,
9454,
14,
1010,
1163,
5932,
12,
3520,
3423,
15,
2888,
13318,
3402,
22284,
512,
384,
2983,
199,
509,
16777,
1159,
308,
1728,
14,
199,
624,
199,
199,
646,
3598,
199,
199,
504,
1639,
14,
1018,
492,
32403,
199,
504,
1639,
14,
697,
14,
992,
14,
1095,
492,
5822,
1563,
199,
504,
1639,
14,
697,
14,
992,
14,
2609,
492,
13537,
199,
504,
1639,
14,
697,
14,
992,
14,
1131,
492,
18397,
199,
504,
1639,
14,
1014,
492,
334,
272,
4760,
5188,
12,
6183,
12,
6183,
31776,
7071,
12,
14935,
12,
199,
9,
199,
504,
1639,
14,
1160,
492,
22538,
12,
5077,
199,
504,
1639,
14,
1160,
14,
1100,
492,
485,
1818,
63,
571,
63,
10705,
199,
504,
1639,
14,
1160,
14,
3908,
492,
334,
272,
485,
1100,
63,
842,
63,
10705,
12,
485,
9086,
63,
10705,
12,
485,
3220,
63,
10705,
12,
199,
9,
199,
504,
1639,
14,
1208,
492,
3816,
199,
504,
1639,
14,
1208,
14,
15383,
492,
23687,
6019,
3849,
199,
504,
1639,
14,
1208,
14,
2991,
492,
3542,
63,
505,
199,
504,
1639,
14,
1208,
14,
15481,
492,
27724,
572,
421,
199,
318,
3795,
63,
475,
63,
1310,
8,
1160,
63,
354,
12,
1067,
29,
403,
12,
2432,
1067,
63,
842,
3699,
1100,
63,
842,
63,
10705,
12,
2432,
1564,
63,
466,
29,
403,
12,
2004,
29,
403,
12,
7606,
3699,
3220,
63,
10705,
12,
2432,
2600,
3699,
9086,
63,
10705,
12,
1808,
29,
403,
304,
272,
408,
272,
1803,
282,
6183,
7447,
1564,
365,
13457,
543,
314,
754,
402,
6358,
272,
1639,
14,
1160,
14,
3422,
14,
3352,
63,
475,
63,
875,
342,
543,
314,
3032,
2368,
14,
272,
408,
272,
340,
334,
1100,
63,
842,
365,
485,
1100,
63,
842,
63,
10705,
288,
436,
7606,
365,
485,
3220,
63,
10705,
288,
436,
2600,
365,
485,
9086,
63,
10705,
304,
267,
327,
3091,
5906,
2368,
4898,
3032,
446,
675,
314,
892,
1233,
931,
267,
1564,
275,
5077,
14,
3352,
63,
475,
63,
875,
8,
1160,
63,
354,
12,
1067,
12,
1808,
29,
4941,
9,
339,
587,
26,
267,
327,
6601,
5906,
2368,
4898,
3032,
446,
675,
314,
12139,
1233,
931,
267,
1564,
275,
5077,
14,
3352,
63,
475,
63,
875,
8,
288,
1978,
63,
354,
12,
1067,
12,
1067,
63,
842,
12,
7606,
12,
2600,
12,
288,
1808,
29,
4941,
9,
339,
372,
6183,
8,
1317,
12,
1564,
63,
466,
12,
2004,
9,
421,
199,
318,
3795,
8,
1069,
12,
1978,
63,
354,
12,
1067,
29,
403,
12,
1779,
1067,
63,
842,
3699,
1100,
63,
842,
63,
10705,
12,
1779,
1564,
63,
466,
29,
403,
12,
2004,
29,
403,
12,
1453,
63,
571,
3699,
1818,
63,
571,
63,
10705,
12,
1779,
7606,
3699,
3220,
63,
10705,
12,
2600,
3699,
9086,
63,
10705,
12,
1779,
1808,
29,
403,
304,
272,
408,
272,
1803,
282,
6183,
7447,
1564,
365,
13457,
543,
314,
754,
402,
6358,
272,
1639,
14,
1160,
14,
3422,
14,
3352,
63,
475,
63,
875,
342,
543,
314,
3032,
2368,
14,
272,
14911,
282,
22538,
701,
849,
14,
272,
408,
272,
340,
334,
1100,
63,
842,
365,
485,
1100,
63,
842,
63,
10705,
288,
436,
1453,
63,
571,
365,
485,
1818,
63,
571,
63,
10705,
288,
436,
7606,
365,
485,
3220,
63,
10705,
288,
436,
2600,
365,
485,
9086,
63,
10705,
304,
267,
327,
3091,
5906,
2368,
4898,
3032,
446,
675,
314,
892,
1233,
931,
267,
327,
1010,
5634,
413,
14,
709,
12,
1056,
1077,
8649,
282,
11333,
1423,
14,
267,
1564,
275,
5077,
14,
3352,
63,
475,
63,
875,
8,
288,
1978,
63,
354,
12,
1067,
12,
1056,
29,
1069,
12,
1808,
29,
4941,
9,
339,
587,
26,
267,
327,
6601,
5906,
2368,
4898,
3032,
446,
675,
314,
12139,
1233,
931,
267,
340,
1067,
63,
842,
365,
440,
485,
1100,
63,
842,
63,
10705,
26,
288,
340,
1453,
63,
571,
365,
440,
485,
1818,
63,
571,
63,
10705,
26,
355,
746,
1722,
360,
3917,
1265,
5647,
282,
1067,
63,
842,
1265,
1471,
283,
639,
283,
409,
2399,
1453,
63,
571,
2544,
6358,
3795,
19004,
267,
587,
26,
288,
1067,
63,
842,
275,
22538,
8,
1069,
9,
288,
340,
1453,
63,
571,
365,
440,
485,
1818,
63,
571,
63,
10705,
26,
355,
3598,
14,
4050,
8,
490,
298,
1918,
1453,
63,
571,
1423,
402,
3795,
365,
5906,
14,
298,
490,
298,
1084,
314,
1453,
63,
571,
2225,
402,
1056,
3140,
4765,
490,
23687,
6019,
3849,
12,
13232,
29,
18,
9,
355,
1056,
14,
1818,
63,
571,
275,
1453,
63,
571,
355,
327,
21128,
590,
663,
314,
5726,
2225,
370,
5126,
6804,
316,
314,
355,
327,
5721,
315,
22538,
855,
826,
4343,
355,
1067,
63,
842,
423,
1818,
63,
571,
275,
1453,
63,
571,
398,
1564,
275,
5077,
14,
3352,
63,
475,
63,
875,
8,
288,
1978,
63,
354,
12,
1067,
12,
1067,
63,
842,
12,
7606,
12,
2600,
12,
288,
1808,
29,
4941,
9,
339,
372,
6183,
8,
1317,
12,
1564,
63,
466,
12,
2004,
9,
421,
199,
318,
4660,
8,
475,
12,
627,
589,
12,
1011,
958,
304,
272,
408,
272,
1803,
376,
14935,
370,
314,
5827,
2851,
367,
314,
2368,
272,
3032,
14,
339,
710,
2368,
4293,
506,
26,
398,
627,
437,
1402,
26,
314,
1402,
1159,
658,
362,
63,
6116,
63,
633,
11995,
805,
911,
506,
2797,
14,
398,
627,
437,
2455,
536,
12,
12570,
543,
2368,
26,
658,
16522,
14,
4471,
11995,
911,
881,
506,
1202,
370,
3837,
13,
6983,
314,
536,
14,
398,
627,
437,
2851,
12,
1314,
911,
506,
1202,
465,
13,
374,
367,
314,
4660,
2909,
14,
339,
4885,
849,
10876,
282,
7937,
4660,
27,
986,
19860,
29,
549,
370,
4976,
282,
272,
19860,
4660,
272,
408,
272,
340,
2074,
14,
1935,
360,
19904,
297,
756,
304,
267,
4660,
63,
533,
275,
6183,
31776,
7071,
272,
587,
26,
267,
4660,
63,
533,
275,
14935,
339,
372,
4660,
63,
533,
8,
6983,
63,
633,
8,
475,
12,
627,
589,
12,
1011,
958,
430,
421,
199,
318,
485,
362,
63,
7924,
8,
11645,
304,
272,
408,
272,
1803,
282,
18397,
687,
282,
5822,
12,
13537,
12,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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ime import datetime
from unicodedata import normalize
from odoo.exceptions import Warning as UserError
from odoo.tools.translate import _
from odoo.addons.l10n_br_account.sped.document import FiscalDocument
from odoo.addons.l10n_br_base.tools.misc import punctuation_rm
class NFe200(FiscalDocument):
def __init__(self):
super(NFe200, self).__init__()
self.nfe = None
self.nfref = None
self.det = None
self.dup = None
def _serializer(self, invoices, nfe_environment):
nfes = []
for invoice in invoices:
company = invoice.company_id.partner_id
self.nfe = self.get_NFe()
self._nfe_identification(invoice, company, nfe_environment)
self._in_out_adress(invoice)
for inv_related in invoice.fiscal_document_related_ids:
self.nfref = self._get_NFRef()
self._nfe_references(inv_related)
self.nfe.infNFe.ide.NFref.append(self.nfref)
self._emmiter(invoice, company)
self._receiver(invoice, company, nfe_environment)
i = 0
for inv_line in invoice.invoice_line_ids:
i += 1
self.det = self._get_Det()
self._details(invoice, inv_line, i)
for inv_di in inv_line.import_declaration_ids:
self.di = self._get_DI()
self._di(inv_di)
for inv_di_line in inv_di.line_ids:
self.di_line = self._get_Addition()
self._addition(inv_di_line)
self.di.adi.append(self.di_line)
self.det.prod.DI.append(self.di)
self.nfe.infNFe.det.append(self.det)
if invoice.journal_id.revenue_expense:
numero_dup = 0
for move_line in invoice.move_line_receivable_id:
numero_dup += 1
self.dup = self._get_Dup()
self._encashment_data(invoice, move_line, numero_dup)
self.nfe.infNFe.cobr.dup.append(self.dup)
try:
self._carrier_data(invoice)
except AttributeError:
pass
self.pag = self._get_Pag()
self._details_pag(invoice)
self.detPag = self._get_DetPag()
self._details_pag_data(invoice)
self.nfe.infNFe.pag.detPag.append(self.detPag)
self.vol = self._get_Vol()
self._weight_data(invoice)
self.nfe.infNFe.transp.vol.append(self.vol)
self._additional_information(invoice)
self._total(invoice)
self._export(invoice)
# Gera Chave da NFe
self.nfe.gera_nova_chave()
nfes.append(self.nfe)
return nfes
def _nfe_identification(self, invoice, company, nfe_environment):
# Identificação da NF-e
#
self.nfe.infNFe.ide.cUF.valor = (company.state_id and
company.state_id.ibge_code or '')
self.nfe.infNFe.ide.cNF.valor = ''
self.nfe.infNFe.ide.natOp.valor = (
invoice.fiscal_category_id.name[:60] or '')
self.nfe.infNFe.ide.indPag.valor = (
invoice.payment_term_id and
invoice.payment_term_id.indPag or '0')
self.nfe.infNFe.ide.mod.valor = invoice.fiscal_document_id.code or ''
self.nfe.infNFe.ide.serie.valor = invoice.document_serie_id.code or ''
self.nfe.infNFe.ide.nNF.valor = invoice.fiscal_number or ''
self.nfe.infNFe.ide.dEmi.valor = invoice.date_invoice or ''
self.nfe.infNFe.ide.dSaiEnt.valor = datetime.strptime(
invoice.date_in_out, '%Y-%m-%d %H:%M:%S').date() or ''
self.nfe.infNFe.ide.cMunFG.valor = ('%s%s') % (
company.state_id.ibge_code, company.l10n_br_city_id.ibge_code)
self.nfe.infNFe.ide.tpImp.valor = 1 # (1 - Retrato; 2 - Paisagem)
self.nfe.infNFe.ide.tpEmis.valor = 1
self.nfe.infNFe.ide.tpAmb.valor = nfe_environment
self.nfe.infNFe.ide.finNFe.valor = invoice.nfe_purpose
self.nfe.infNFe.ide.procEmi.valor = 0
self.nfe.infNFe.ide.verProc.valor = 'Odoo Brasil v12.0'
self.nfe.infNFe.compra.xPed.valor = invoice.name or ''
if invoice.cfop_ids[0].type in ("input"):
self.nfe.infNFe.ide.tpNF.valor = 0
else:
self.nfe.infNFe.ide.tpNF.valor = 1
def _in_out_adress(self, invoice):
#
# Endereço de Entrega ou Retirada
#
if invoice.partner_shipping_id:
if invoice.partner_id.id != invoice.partner_shipping_id.id:
if self.nfe.infNFe.ide.tpNF.valor == 0:
self.nfe.infNFe.retirada.CNPJ.valor = punctuation_rm(
invoice.partner_shipping_id.cnpj_cpf)
self.nfe.infNFe.retirada.xLgr.valor = (
invoice.partner_shipping_id.street or '')
self.nfe.infNFe.retirada.nro.valor = (
invoice.partner_shipping_id.number or '')
self.nfe.infNFe.retirada.xCpl.valor = (
invoice.partner_shipping_id.street2 or '')
self.nfe.infNFe.retirada.xBairro.valor = (
invoice.partner_shipping_id.district or 'Sem Bairro')
self.nfe.infNFe.retirada.cMun.valor = '%s%s' % (
invoice.partner_shipping_id.state_id.ibge_code,
invoice.partner_shipping_id.l10n_br_city_id.ibge_code)
self.nfe.infNFe.retirada.xMun.valor = (
invoice.partner_shipping_id.l10n_br_city_id.name or '')
self.nfe.infNFe.retirada.UF.valor = (
invoice.partner_shipping_id.state_id.code or '')
else:
self.nfe.infNFe.entrega.CNPJ.valor = punctuation_rm(
invoice.partner_shipping_id.cnpj_cpf)
self.nfe.infNFe.entrega.xLgr.valor = (
invoice.partner_shipping_id.street or '')
self.nfe.infNFe.entrega.nro.valor = (
invoice.partner_shipping_id.number or '')
self.nfe.infNFe.entrega.xCpl.valor = (
invoice.partner_shipping_id.street2 or '')
self.nfe.infNFe.entrega.xBairro.valor = (
invoice.partner_shipping_id.district or 'Sem Bairro')
self.nfe.infNFe.entrega.cMun.valor = '%s%s' % (
invoice.partner_shipping_id.state_id.ibge_code,
invoice.partner_shipping_id.l10n_br_city_id.ibge_code)
self.nfe.infNFe.entrega.xMun.valor = (
invoice.partner_shipping_id.l10n_br_city_id.name or '')
self.nfe.infNFe.entrega.UF.valor = (
invoice.partner_shipping_id.state_id.code or '')
def _nfe_references(self, inv_related):
#
# Documentos referenciadas
#
if inv_related.document_type == 'nf':
self.nfref.refNF.cUF.valor = (
inv_related.state_id and
inv_related.state_id.ibge_code or '',)
self.nfref.refNF.AAMM.valor = datetime.strptime(
inv_related.date, '%Y-%m-%d').strftime('%y%m') or ''
self.nfref.refNF.CNPJ.valor = punctuation_rm(inv_related.cnpj_cpf)
self.nfref.refNF.mod.valor = (
inv_related.fiscal_document_id and
inv_related.fiscal_document_id.code or '')
self.nfref.refNF.serie.valor = inv_related.serie or ''
self.nfref.refNF.nNF.valor = inv_related.internal_number or ''
elif inv_related.document_type == 'nfrural':
self.nfref.refNFP.cUF.valor = (
inv_related.state_id and
inv_related.state_id.ibge_code or '',)
self.nfref.refNFP.AAMM.valor = datetime.strptime(
inv_related.date, '%Y-%m-%d').strftime('%y%m') or ''
self.nfref.refNFP.IE.valor = punctuation_rm(inv_related.inscr_est)
self.nfref.refNFP.mod.valor = (
inv_related.fiscal_document_id and
inv_related.fiscal_document_id.code or '')
self.nfref.refNFP.serie.valor = inv_related.serie or ''
self.nfref.refNFP.nNF.valor = inv_related.internal_number or ''
if inv_related.cpfcnpj_type == 'cnpj':
self.nfref.refNFP.CNPJ.valor = punctuation_rm(
inv_related.cnpj_cpf)
else:
self.nfref.refNFP.CPF.valor = punctuation_rm(
inv_related.cnpj_cpf)
elif inv_related.document_type == 'nfe':
self.nfref.refNFe.valor = inv_related.access_key or ''
elif inv_related.document_type == 'cte':
self.nfref.refCTe.valor = inv_related.access_key or ''
elif inv_related.document_type == 'cf':
self.nfref.refECF.mod.valor = (
inv_related.fiscal_document_id and
inv_related.fiscal_document_id.code or '')
self.nfref.refECF.nECF.valor = inv_related.internal_number
self.nfref.refECF.nCOO.valor = inv_related.serie
def _emmiter(self, invoice, company):
"""Emitente"""
self.nfe.infNFe.emit.CNPJ.valor = punctuation_rm(
invoice.company_id.partner_id.cnpj_cpf)
self.nfe.infNFe.emit.xNome.valor = (normalize(
'NFKD', unicode(
invoice.company_id.partner_id.legal_name[:60])).encode(
'ASCII', 'ignore'))
self.nfe.infNFe.emit.xFant.valor = invoice.company_id.partner_id.name
self.nfe.infNFe.emit.enderEmit.xLgr.valor = (normalize(
'NFKD', unicode(company.street or '')).encode('ASCII', 'ignore'))
self.nfe.infNFe.emit.enderEmit.nro.valor = company.number or ''
self.nfe.infNFe.emit.enderEmit.xCpl.valor = (normalize(
'NFKD', unicode(company.street2 or '')).encode('ASCII', 'ignore'))
self.nfe.infNFe.emit.enderEmit.xBairro.valor = (normalize(
'NFKD', unicode(
company.district or 'Sem Bairro')).encode('ASCII', 'ignore'))
self.nfe.infNFe.emit.enderEmit.cMun.valor = '%s%s' % (
company.state_id.ibge_code, company.l10n_br_city_id.ibge_code)
self.nfe.infNFe.emit.enderEmit.xMun.valor = (normalize(
'NFKD', unicode(
company.l10n_br_city_id.name or '')).encode('ASCII', 'ignore'))
self.nfe.infNFe.emit.enderEmit.UF.valor = company.state_id.code or ''
self.nfe.infNFe.emit.enderEmit.CEP.valor = punctuation_rm(
company.zip or '')
self.nfe.infNFe.emit.enderEmit.cPais.valor = (
company.country_id.bc_code[1:])
self.nfe.infNFe.emit.enderEmit.xPais.valor = company.country_id.name
self.nfe.infNFe.emit.enderEmit.fone.valor = punctuation_rm(
str(company.phone or '').replace(' ', ''))
self.nfe.infNFe.emit.IE.valor = punctuation_rm(
invoice.company_id.partner_id.inscr_est)
for inscr_est_line in\
invoice.company_id.partner_id.other_inscr_est_lines:
if inscr_est_line.state_id.id == invoice.partner_id.state_id.id:
self.nfe.infNFe.emit.IEST.valor = punctuation_rm(
inscr_est_line.inscr_est)
else:
self.nfe.infNFe.emit.IEST.valor = ''
self.nfe.infNFe.emit.IM.valor = punctuation_rm(
invoice.company_id.partner_id.inscr_mun or '')
self.nfe.infNFe.emit.CRT.valor = invoice.company_id.fiscal_type or ''
if invoice.company_id.partner_id.inscr_mun:
self.nfe.infNFe.emit.CNAE.valor = punctuation_rm(
invoice.company_id.cnae_main_id.code or '')
def _receiver(self, invoice, company, nfe_environment):
"""Destinatário"""
partner_bc_code = ''
address_invoice_state_code = ''
address_invoice_city = ''
partner_cep = ''
if invoice.partner_id.country_id.bc_code:
partner_bc_code = invoice.partner_id.country_id.bc_code[1:]
if invoice.partner_id.country_id.id != \
invoice.company_id.country_id.id:
address_invoice_state_code = 'EX'
address_invoice_city = 'Exterior'
address_invoice_city_code = '9999999'
else:
address_invoice_state_code = invoice.partner_id.state_id.code
address_invoice_city = (normalize(
'NFKD', unicode(
invoice.partner_id.l10n_br_city_id.name or '')).encode(
'ASCII', 'ignore'))
address_invoice_city_code = ('%s%s') % (
invoice.partner_id.state_id.ibge_code,
invoice.partner_id.l10n_br_city_id.ibge_code)
partner_cep = punctuation_rm(invoice.partner_id.zip)
# Se o ambiente for de teste deve ser
# escrito na razão do destinatário
if nfe_environment == 2:
self.nfe.infNFe.dest.xNome.valor = (
'NF-E EMITIDA EM AMBIENTE DE HOMOLOGACAO - SEM VALOR FISCAL')
self.nfe.infNFe.dest.CNPJ.valor = '99999999000191'
else:
self.nfe.infNFe.dest.xNome.valor = (normalize(
'NFKD', unicode(
invoice.partner_id.legal_name[:60] or '')
).encode('ASCII', 'ignore'))
if invoice.partner_id.is_company:
self.nfe.infNFe.dest.IE.valor = punctuation_rm(
invoice.partner_id.inscr_est)
if invoice.partner_id.country_id.id == \
invoice.company_id.country_id.id:
if invoice.partner_id.is_company:
self.nfe.infNFe.dest.CNPJ.valor = punctuation_rm(
invoice.partner_id.cnpj_cpf)
else:
self.nfe.infNFe.dest.CPF.valor = punctuation_rm(
invoice.partner_id.cnpj_cpf)
self.nfe.infNFe.dest.indIEDest.valor = \
invoice.partner_id.partner_fiscal_type_id.ind_ie_dest
self.nfe.infNFe.dest.enderDest.xLgr.valor = (normalize(
'NFKD', unicode(
invoice.partner_id.street or '')).encode('ASCII', 'ignore'))
self.nfe.infNFe.dest.enderDest.nro.valor = (
invoice.partner_id.number or '')
self.nfe.infNFe.dest.enderDest.xCpl.valor = (normalize(
'NFKD', unicode(
invoice.partner_id.street2 or '')).encode('ASCII', 'ignore'))
self.nfe.infNFe.dest.enderDest.xBairro.valor = (normalize(
'NFKD', unicode(
invoice.partner_id.district or 'Sem Bairro')
).encode('ASCII', 'ignore'))
self.nfe.infNFe.dest.enderDest.cMun.valor = address_invoice_city_code
self.nfe.infNFe.dest.enderDest.xMun.valor = address_invoice_city
self.nfe.infNFe.dest.enderDest.UF.valor = address_invoice_state_code
self.nfe.infNFe.dest.enderDest.CEP.valor = partner_cep
self.nfe.infNFe.dest.enderDest.cPais.valor = partner_bc_code
self.nfe.infNFe.dest.enderDest.xPais.valor = (
invoice.partner_id.country_id.name or '')
self.nfe.infNFe.dest.enderDest.fone.valor = punctuation_rm(
invoice.partner_id.phone or '').replace(' ', '')
self.nfe.infNFe.dest.email.valor = invoice.partner_id.email or ''
def _details(self, invoice, invoice_line, index):
"""Detalhe"""
self.det.nItem.valor = index
if invoice_line.product_id:
self.det.prod.cProd.valor = invoice_line.product_id.code or ''
self.det.prod.cEAN.valor =\
invoice_line.product_id.barcode or 'SEM GTIN'
self.det.prod.cEANTrib.valor =\
invoice_line.product_id.barcode or ''
self.det.prod.xProd.valor = (normalize(
'NFKD', unicode(
invoice_line.product_id.name[:120] or '')
).encode('ASCII', 'ignore'))
else:
self.det.prod.cProd.valor = invoice_line.code or ''
self.det.prod.xProd.valor = (normalize(
'NFKD', unicode(
invoice_line.name[:120] or '')
).encode('ASCII', 'ignore'))
self.det.prod.NCM.valor = punctuation_rm(
invoice_line.fiscal_classification_id.code or '')[:8]
self.det.prod.EXTIPI.valor = punctuation_rm(
invoice_line.fiscal_classification_id.code or '')[8:]
self.det.prod.CEST.valor = punctuation_rm(
invoice_line.cest_id.code or '')
self.det.prod.nFCI.valor = invoice_line.fci or ''
self.det.prod.CFOP.valor = invoice_line.cfop_id.code
self.det.prod.uCom.valor = invoice_line.uom_id.name or ''
self.det.prod.qCom.valor = str("%.4f" % invoice_line.quantity)
self.det.prod.vUnCom.valor = str("%.7f" % invoice_line.price_unit)
self.det.prod.vProd.valor = str("%.2f" % invoice_line.price_gross)
self.det.prod.uTrib.valor = self.det.prod.uCom.valor
self.det.prod.qTrib.valor = self.det.prod.qCom.valor
self.det.prod.vUnTrib.valor = self.det.prod.vUnCom.valor
self.det.prod.vFrete.valor = str("%.2f" % invoice_line.freight_value)
self.det.prod.vSeg.valor = str("%.2f" % invoice_line.insurance_value)
self.det.prod.vDesc.valor = str("%.2f" % invoice_line.discount_value)
self.det.prod.vOutro.valor = str(
"%.2f" % invoice_line.other_costs_value)
self.det.prod.xPed.valor = invoice_line.partner_order or ''
self.det.prod.nItemPed.valor = invoice_line.partner_order_line or ''
self.det.infAdProd.valor = invoice_line.fiscal_comment or ''
#
# Produto entra no total da NF-e
#
self.det.prod.indTot.valor = 1
if invoice_line.product_type == 'product':
# ICMS
if invoice_line.icms_cst_id.code > 100:
self.det.imposto.ICMS.CSOSN.valor = (
invoice_line.icms_cst_id.code)
self.det.imposto.ICMS.pCredSN.valor = str(
"%.2f" % invoice_line.icms_percent)
self.det.imposto.ICMS.vCredICMSSN.valor = str(
"%.2f" % invoice_line.icms_value)
self.det.imposto.ICMS.orig.valor = invoice_line.icms_origin or ''
self.det.imposto.ICMS.CST.valor = invoice_line.icms_cst_id.code
self.det.imposto.ICMS.modBC.valor = invoice_line.icms_base_type
self.det.imposto.ICMS.vBC.valor = str(
"%.2f" % invoice_line.icms_base)
self.det.imposto.ICMS.pRedBC.valor = str(
"%.2f" % invoice_line.icms_percent_reduction)
self.det.imposto.ICMS.pICMS.valor = str(
"%.2f" % invoice_line.icms_percent)
self.det.imposto.ICMS.vICMS.valor = str(
"%.2f" % invoice_line.icms_value)
self.det.imposto.ICMS.motDesICMS.valor = (
invoice_line.icms_relief_id.code or '')
# ICMS ST
self.det.imposto.ICMS.modBCST.valor = (
invoice_line.icms_st_base_type)
self.det.imposto.ICMS.pMVAST.valor = str(
"%.2f" % invoice_line.icms_st_mva)
self.det.imposto.ICMS.pRedBCST.valor = str(
"%.2f" % invoice_line.icms_st_percent_reduction)
self.det.imposto.ICMS.vBCST.valor = str(
"%.2f" % invoice_line.icms_st_base)
self.det.imposto.ICMS.pICMSST.valor = str(
"%.2f" % invoice_line.icms_st_percent)
self.det.imposto.ICMS.vICMSST.valor = str(
"%.2f" % invoice_line.icms_st_value)
# Informação do ICMS Interestadual nas vendas para consumidor final
self.det.imposto.ICMSUFDest.vBCUFDest.valor = str(
"%.2f" % invoice_line.icms_dest_base)
self.det.imposto.ICMSUFDest.pFCPUFDest.valor = str(
"%.2f" % invoice_line.icms_fcp_percent)
self.det.imposto.ICMSUFDest.pICMSUFDest.valor = str(
"%.2f" % invoice_line.icms_dest_percent)
self.det.imposto.ICMSUFDest.pICMSInter.valor = str(
"%.2f" % invoice_line.icms_origin_percent)
self.det.imposto.ICMSUFDest.pICMSInterPart.valor = str(
"%.2f" % invoice_line.icms_part_percent)
self.det.imposto.ICMSUFDest.vFCPUFDest.valor = str(
"%.2f" % invoice_line.icms_fcp_value)
self.det.imposto.ICMSUFDest.vICMSUFDest.valor = str(
"%.2f" % invoice_line.icms_dest_value)
self.det.imposto.ICMSUFDest.vICMSUFRemet.valor = str(
"%.2f" % invoice_line.icms_origin_value)
# IPI
self.det.imposto.IPI.CST.valor = invoice_line.ipi_cst_id.code
if invoice_line.ipi_type == 'percent' or '':
self.det.imposto.IPI.vBC.valor = str(
"%.2f" % invoice_line.ipi_base)
self.det.imposto.IPI.pIPI.valor = str(
"%.2f" % invoice_line.ipi_percent)
if invoice_line.ipi_type == 'quantity':
pesol = 0
if invoice_line.product_id:
pesol = invoice_line.product_id.weight_net
self.det.imposto.IPI.qUnid.valor = str(
"%.2f" % invoice_line.quantity * pesol)
self.det.imposto.IPI.vUnid.valor = str(
"%.2f" % invoice_line.ipi_percent)
self.det.imposto.IPI.vIPI.valor = str(
"%.2f" % invoice_line.ipi_value)
self.det.imposto.IPI.cEnq.valor = str(
invoice_line.ipi_guideline_id.code or '999').zfill(3)
else:
# ISSQN
self.det.imposto.ISSQN.vBC.valor = str(
"%.2f" % invoice_line.issqn_base)
self.det.imposto.ISSQN.vAliq.valor = str(
"%.2f" % invoice_line.issqn_percent)
self.det.imposto.ISSQN.vISSQN.valor = str(
"%.2f" % invoice_line.issqn_value)
self.det.imposto.ISSQN.cMunFG.valor = ('%s%s') % (
invoice.partner_id.state_id.ibge_code,
invoice.partner_id.l10n_br_city_id.ibge_code)
self.det.imposto.ISSQN.cListServ.valor = punctuation_rm(
invoice_line.service_type_id.code or '')
self.det.imposto.ISSQN.cSitTrib.valor = invoice_line.issqn_type
# PIS
self.det.imposto.PIS.CST.valor = invoice_line.pis_cst_id.code
self.det.imposto.PIS.vBC.valor = str("%.2f" % invoice_line.pis_base)
self.det.imposto.PIS.pPIS.valor = str(
"%.2f" % invoice_line.pis_percent)
self.det.imposto.PIS.vPIS.valor = str("%.2f" % invoice_line.pis_value)
# PISST
self.det.imposto.PISST.vBC.valor = str(
"%.2f" % invoice_line.pis_st_base)
self.det.imposto.PISST.pPIS.valor = str(
"%.2f" % invoice_line.pis_st_percent)
self.det.imposto.PISST.qBCProd.valor = ''
self.det.imposto.PISST.vAliqProd.valor = ''
self.det.imposto.PISST.vPIS.valor = str(
"%.2f" % invoice_line.pis_st_value)
# COFINS
self.det.imposto.COFINS.CST.valor = invoice_line.cofins_cst_id.code
self.det.imposto.COFINS.vBC.valor = str(
"%.2f" % invoice_line.cofins_base)
self.det.imposto.COFINS.pCOFINS.valor = str(
"%.2f" % invoice_line.cofins_percent)
self.det.imposto.COFINS.vCOFINS.valor = str(
"%.2f" % invoice_line.cofins_value)
# COFINSST
self.det.imposto.COFINSST.vBC.valor = str(
"%.2f" % invoice_line.cofins_st_base)
self.det.imposto.COFINSST.pCOFINS.valor = str(
"%.2f" % invoice_line.cofins_st_percent)
self.det.imposto.COFINSST.qBCProd.valor = ''
self.det.imposto.COFINSST.vAliqProd.valor = ''
self.det.imposto.COFINSST.vCOFINS.valor = str(
"%.2f" % invoice_line.cofins_st_value)
# II
self.det.imposto.II.vBC.valor = str("%.2f" % invoice_line.ii_base)
self.det.imposto.II.vDespAdu.valor = str(
"%.2f" % invoice_line.ii_customhouse_charges)
self.det.imposto.II.vII.valor = str("%.2f" % invoice_line.ii_value)
self.det.imposto.II.vIOF.valor = str("%.2f" % invoice_line.ii_iof)
self.det.imposto.vTotTrib.valor = str(
"%.2f" % invoice_line.total_taxes)
def _di(self, invoice_line_di):
self.di.nDI.valor = invoice_line_di.name
self.di.dDI.valor = invoice_line_di.date_registration or ''
self.di.xLocDesemb.valor = invoice_line_di.location
self.di.UFDesemb.valor = invoice_line_di.state_id.code or ''
self.di.dDesemb.valor = invoice_line_di.date_release or ''
self.di.cExportador.valor = invoice_line_di.exporting_code
def _addition(self, invoice_line_di):
self.di_line.nAdicao.valor = invoice_line_di.name
self.di_line.nSeqAdic.valor = invoice_line_di.sequence
self.di_line.cFabricante.valor = invoice_line_di.manufacturer_code
self.di_line.vDescDI.valor = str(
"%.2f" % invoice_line_di.amount_discount)
def _encashment_data(self, invoice, move_line, numero_dup):
"""Dados de Cobrança"""
if invoice.type in ('out_invoice', 'in_refund'):
value = move_line.debit
else:
value = move_line.credit
self.dup.nDup.valor = str(numero_dup).zfill(3)
self.dup.dVenc.valor = (move_line.date_maturity or
invoice.date_due or
invoice.date_invoice)
self.dup.vDup.valor = str("%.2f" % value)
def _carrier_data(self, invoice):
"""Dados da Transportadora e veiculo"""
self.nfe.infNFe.transp.modFrete.valor = (
invoice.incoterm and
invoice.incoterm.freight_responsibility or '9')
if invoice.carrier_id:
if invoice.carrier_id.partner_id.is_company:
self.nfe.infNFe.transp.transporta.CNPJ.valor = \
punctuation_rm(
invoice.carrier_id.partner_id.cnpj_cpf or '')
else:
self.nfe.infNFe.transp.transporta.CPF.valor = \
punctuation_rm(
invoice.carrier_id.partner_id.cnpj_cpf or '')
self.nfe.infNFe.transp.transporta.xNome.valor = (
invoice.carrier_id.partner_id.legal_name[:60] or '')
self.nfe.infNFe.transp.transporta.IE.valor = punctuation_rm(
invoice.carrier_id.partner_id.inscr_est)
self.nfe.infNFe.transp.transporta.xEnder.valor = (
invoice.carrier_id.partner_id.street or '')
self.nfe.infNFe.transp.transporta.xMun.valor = (
invoice.carrier_id.partner_id.l10n_br_city_id.name or '')
self.nfe.infNFe.transp.transporta.UF.valor = (
invoice.carrier_id.partner_id.state_id.code or '')
if invoice.vehicle_id:
self.nfe.infNFe.transp.veicTransp.placa.valor = (
invoice.vehicle_id.plate or '')
self.nfe.infNFe.transp.veicTransp.UF.valor = (
invoice.vehicle_id.plate.state_id.code or '')
self.nfe.infNFe.transp.veicTransp.RNTC.valor = (
invoice.vehicle_id.rntc_code or '')
def _weight_data(self, invoice):
"""Campos do Transporte da NF-e Bloco 381"""
self.vol.qVol.valor = invoice.number_of_packages
self.vol.esp.valor = invoice.kind_of_packages or ''
self.vol.marca.valor = invoice.brand_of_packages or ''
self.vol.nVol.valor = invoice.notation_of_packages or ''
self.vol.pesoL.valor = str("%.2f" % invoice.weight_net)
self.vol.pesoB.valor = str("%.2f" % invoice.weight)
def _additional_information(self, invoice):
"""Informações adicionais"""
self.nfe.infNFe.infAdic.infAdFisco.valor = invoice.fiscal_comment or ''
self.nfe.infNFe.infAdic.infCpl.valor = invoice.comment or ''
def _total(self, invoice):
"""Totais"""
self.nfe.infNFe.total.ICMSTot.vBC.valor = str(
"%.2f" % invoice.icms_base)
self.nfe.infNFe.total.ICMSTot.vICMS.valor = str(
"%.2f" % invoice.icms_value)
self.nfe.infNFe.total.ICMSTot.vFCPUFDest.valor = str(
"%.2f" % invoice.icms_fcp_value)
self.nfe.infNFe.total.ICMSTot.vICMSUFDest.valor = str(
"%.2f" % invoice.icms_dest_value)
self.nfe.infNFe.total.ICMSTot.vICMSUFRemet.valor = str(
"%.2f" % invoice.icms_origin_value)
self.nfe.infNFe.total.ICMSTot.vBCST.valor = str(
"%.2f" % invoice.icms_st_base)
self.nfe.infNFe.total.ICMSTot.vST.valor = str(
"%.2f" % invoice.icms_st_value)
self.nfe.infNFe.total.ICMSTot.vProd.valor = str(
"%.2f" % invoice.amount_gross)
self.nfe.infNFe.total.ICMSTot.vFrete.valor = str(
"%.2f" % invoice.amount_freight)
self.nfe.infNFe.total.ICMSTot.vSeg.valor = str(
"%.2f" % invoice.amount_insurance)
self.nfe.infNFe.total.ICMSTot.vDesc.valor = str(
"%.2f" % invoice.amount_discount)
self.nfe.infNFe.total.ICMSTot.vII.valor = str(
"%.2f" % invoice.ii_value)
self.nfe.infNFe.total.ICMSTot.vIPI.valor = str(
"%.2f" % invoice.ipi_value)
self.nfe.infNFe.total.ICMSTot.vPIS.valor = str(
"%.2f" % invoice.pis_value)
self.nfe.infNFe.total.ICMSTot.vCOFINS.valor = str(
"%.2f" % invoice.cofins_value)
self.nfe.infNFe.total.ICMSTot.vOutro.valor = str(
"%.2f" % invoice.amount_costs)
self.nfe.infNFe.total.ICMSTot.vNF.valor = str(
"%.2f" % invoice.amount_total)
self.nfe.infNFe.total.ICMSTot.vTotTrib.valor = str(
"%.2f" % invoice.amount_total_taxes)
def _export(self, invoice):
"Informações de exportação"
self.nfe.infNFe.exporta.UFEmbarq.valor = (
invoice.shipping_state_id.code or '')
self.nfe.infNFe.exporta.xLocEmbarq.valor = (
invoice.shipping_location or '')
def get_NFe(self):
try:
from pysped.nfe.leiaute import NFe_200
except ImportError:
raise UserError(
_(u"Biblioteca PySPED não instalada!"))
return NFe_200()
def _get_NFRef(self):
try:
from pysped.nfe.leiaute import NFRef_200
except ImportError:
raise UserError(
_(u"Biblioteca PySPED não instalada!"))
return NFRef_200()
def _get_Det(self):
try:
from pysped.nfe.leiaute import Det_200
except ImportError:
raise UserError(
_(u"Biblioteca PySPED não instalada!"))
return Det_200()
def _get_DI(self):
try:
from pysped.nfe.leiaute import DI_200
except ImportError:
raise UserError(
_(u"Biblioteca PySPED não instalada!"))
return DI_200()
def _get_Addition(self):
try:
from pysped.nfe.leiaute import Adi_200
except ImportError:
raise UserError(
_(u"Biblioteca PySPED não instalada!"))
return Adi_200()
def _get_Vol(self):
try:
from pysped.nfe.leiaute import Vol_200
except ImportError:
raise UserError(
_(u"Biblioteca PySPED não instalada!"))
return Vol_200()
def _get_Dup(self):
try:
from pysped.nfe.leiaute import Dup_200
except ImportError:
raise UserError(
_(u"Biblioteca PySPED não instalada!"))
return Dup_200()
def get_xml(self, invoices, nfe_environment):
""""""
result = []
for nfe in self._serializer(invoices, nfe_environment):
result.append({'key': nfe.infNFe.Id.valor, 'nfe': nfe.get_xml()})
return result
def set_xml(self, nfe_string, context=None):
""""""
nfe = self.get_NFe()
nfe.set_xml(nfe_string)
return nfe
class NFe310(NFe200):
def __init__(self):
super(NFe310, self).__init__()
def _nfe_identification(self, invoice, company, nfe_environment):
super(NFe310, self)._nfe_identification(
invoice, company, nfe_environment)
self.nfe.infNFe.ide.idDest.valor = (
invoice.fiscal_position_id.cfop_id.id_dest or '')
self.nfe.infNFe.ide.indFinal.valor = invoice.ind_final or ''
self.nfe.infNFe.ide.indPres.valor = invoice.ind_pres or ''
self.nfe.infNFe.ide.dhEmi.valor = datetime.strptime(
invoice.date_hour_invoice, '%Y-%m-%d %H:%M:%S')
self.nfe.infNFe.ide.dhSaiEnt.valor = datetime.strptime(
invoice.date_in_out, '%Y-%m-%d %H:%M:%S')
self.aut_xml = self._get_AutXML()
self.aut_xml.CNPJ.valor = punctuation_rm(
invoice.company_id.accountant_cnpj_cpf)
self.nfe.infNFe.autXML.append(self.aut_xml)
def _receiver(self, invoice, company, nfe_environment):
super(NFe310, self)._receiver(
invoice, company, nfe_environment)
if invoice.partner_id.country_id.id != \
invoice.company_id.country_id.id:
self.nfe.infNFe.dest.idEstrangeiro.valor = punctuation_rm(
invoice.partner_id.cnpj_cpf)
def _di(self, invoice_line_di):
super(NFe310, self)._di(invoice_line_di)
self.di.tpViaTransp.valor = invoice_line_di.type_transportation or ''
self.di.vAFRMM.valor = str("%.2f" % invoice_line_di.afrmm_value)
self.di.tpIntermedio.valor = invoice_line_di.type_import or ''
self.di.CNPJ.valor = invoice_line_di.exporting_code or ''
self.di.UFTerceiro.valor = (
invoice_line_di.thirdparty_state_id.code or '')
def _export(self, invoice):
"Informações de exportação"
self.nfe.infNFe.exporta.UFSaidaPais.valor = (
invoice.shipping_state_id.code or '')
self.nfe.infNFe.exporta.xLocExporta.valor = (
invoice.shipping_location or '')
self.nfe.infNFe.exporta.xLocDespacho.valor = (
invoice.expedition_location or '')
def get_NFe(self):
try:
from pysped.nfe.leiaute import NFe_310
except ImportError:
raise UserError(
_(u"Biblioteca PySPED não instalada!"))
return NFe_310()
def _get_NFRef(self):
try:
from pysped.nfe.leiaute import NFRef_310
except ImportError:
raise UserError(
_(u"Biblioteca PySPED não instalada!"))
return NFRef_310()
def _get_Det(self):
try:
from pysped.nfe.leiaute import Det_310
except ImportError:
raise UserError(
_(u"Biblioteca PySPED não instalada!"))
return Det_310()
def _get_Dup(self):
try:
from pysped.nfe.leiaute import Dup_310
except ImportError:
raise UserError(
_(u"Biblioteca PySPED não instalada!"))
return Dup_310()
def _get_DI(self):
try:
from pysped.nfe.leiaute import DI_310
except ImportError:
raise UserError(
_(u"Biblioteca PySPED não instalada!"))
return DI_310()
def _get_AutXML(self):
try:
from pysped.nfe.leiaute import AutXML_310
except ImportError:
raise UserError(
_(u"Biblioteca PySPED não instalada!"))
return AutXML_310()
class NFe400(NFe310):
def __init__(self):
super(NFe400, self).__init__()
def _details_pag(self, invoice):
# TODO - implementar campo
self.pag.vTroco.valor = ''
def _details_pag_data(self, invoice):
# TODO - existe a possibilidade de pagar uma parte
# em uma forma de pagto e outra parte em outra
# ex.: metade em dinheiro e metade boleto
self.detPag.tPag.valor = invoice.type_nf_payment
self.detPag.vPag.valor = invoice.amount_total
def get_NFe(self):
try:
from pysped.nfe.leiaute import NFe_400
except ImportError:
raise UserError(
_(u"Biblioteca PySPED não instalada!"))
return NFe_400()
def _get_NFRef(self):
try:
from pysped.nfe.leiaute import NFRef_400
except ImportError:
raise UserError(
_(u"Biblioteca PySPED não instalada!"))
return NFRef_400()
def _get_Det(self):
try:
from pysped.nfe.leiaute import Det_400
except ImportError:
raise UserError(
_(u"Biblioteca PySPED não instalada!"))
return Det_400()
def _get_Dup(self):
try:
from pysped.nfe.leiaute import Dup_400
except ImportError:
raise UserError(
_(u"Biblioteca PySPED não instalada!"))
return Dup_400()
def _get_DI(self):
try:
from pysped.nfe.leiaute import DI_400
except ImportError:
raise UserError(
_(u"Biblioteca PySPED não instalada!"))
return DI_400()
def _get_Pag(self):
try:
from pysped.nfe.leiaute import Pag_400
except ImportError:
raise UserError(
_(u"Biblioteca PySPED não instalada!"))
return Pag_400()
def _get_DetPag(self):
try:
from pysped.nfe.leiaute import DetPag_400
except ImportError:
raise UserError(
_(u"Biblioteca PySPED não instalada!"))
return DetPag_400()
def _get_AutXML(self):
try:
from pysped.nfe.leiaute import AutXML_400
except ImportError:
raise UserError(
_(u"Biblioteca PySPED não instalada!"))
return AutXML_400()
|
agpl-3.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
1898,
334,
35,
9,
6171,
221,
10055,
11318,
491,
11744,
446,
437,
75,
264,
296,
199,
3,
844,
437,
12006,
13,
19,
446,
1666,
1455,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
15,
643,
1168,
13,
19,
14,
16,
14,
1360,
199,
199,
504,
2197,
492,
2197,
199,
504,
23128,
492,
7666,
199,
199,
504,
28811,
14,
3924,
492,
15902,
465,
29908,
199,
504,
28811,
14,
2537,
14,
5275,
492,
485,
199,
199,
504,
28811,
14,
10788,
14,
76,
709,
78,
63,
3289,
63,
2048,
14,
83,
1915,
14,
3554,
492,
481,
15734,
5564,
199,
504,
28811,
14,
10788,
14,
76,
709,
78,
63,
3289,
63,
1095,
14,
2537,
14,
9923,
492,
22929,
63,
5682,
421,
199,
533,
653,
3456,
1840,
8,
38,
15734,
5564,
304,
272,
347,
636,
826,
721,
277,
304,
267,
1613,
8,
46,
3456,
1840,
12,
291,
2843,
826,
4533,
267,
291,
14,
78,
771,
275,
488,
267,
291,
14,
9914,
1121,
275,
488,
267,
291,
14,
9886,
275,
488,
267,
291,
14,
11048,
275,
488,
339,
347,
485,
8349,
8,
277,
12,
26175,
12,
302,
771,
63,
5418,
304,
398,
302,
70,
397,
275,
942,
398,
367,
8485,
315,
26175,
26,
288,
7233,
275,
8485,
14,
4627,
63,
344,
14,
3899,
63,
344,
953,
291,
14,
78,
771,
275,
291,
14,
362,
63,
46,
3456,
342,
953,
291,
423,
78,
771,
63,
73,
24926,
8,
5404,
12,
7233,
12,
302,
771,
63,
5418,
9,
953,
291,
423,
262,
63,
548,
63,
350,
753,
8,
5404,
9,
953,
367,
4572,
63,
2407,
315,
8485,
14,
18646,
63,
3554,
63,
2407,
63,
1580,
26,
355,
291,
14,
9914,
1121,
275,
291,
423,
362,
63,
19749,
2891,
342,
355,
291,
423,
78,
771,
63,
12635,
8,
5350,
63,
2407,
9,
355,
291,
14,
78,
771,
14,
4904,
46,
3456,
14,
2655,
14,
19749,
1121,
14,
740,
8,
277,
14,
9914,
1121,
9,
953,
291,
423,
69,
596,
1661,
8,
5404,
12,
7233,
9,
288,
291,
423,
10244,
8,
5404,
12,
7233,
12,
302,
771,
63,
5418,
9,
953,
284,
275,
378,
288,
367,
4572,
63,
604,
315,
8485,
14,
5404,
63,
604,
63,
1580,
26,
355,
284,
847,
413,
355,
291,
14,
9886,
275,
291,
423,
362,
63,
21097,
342,
355,
291,
423,
5087,
8,
5404,
12,
4572,
63,
604,
12,
284,
9,
2234,
367,
4572,
63,
328,
315,
4572,
63,
604,
14,
646,
63,
15477,
63,
1580,
26,
4951,
291,
14,
328,
275,
291,
423,
362,
63,
1914,
342,
490,
291,
423,
328,
8,
5350,
63,
328,
9,
4951,
367,
4572,
63,
328,
63,
604,
315,
4572,
63,
328,
14,
604,
63,
1580,
26,
717,
291,
14,
328,
63,
604,
275,
291,
423,
362,
63,
2767,
1671,
342,
717,
291,
423,
26799,
8,
5350,
63,
328,
63,
604,
9,
717,
291,
14,
328,
14,
65,
328,
14,
740,
8,
277,
14,
328,
63,
604,
9,
4951,
291,
14,
9886,
14,
8788,
14,
1914,
14,
740,
8,
277,
14,
328,
9,
2234,
291,
14,
78,
771,
14,
4904,
46,
3456,
14,
9886,
14,
740,
8,
277,
14,
9886,
9,
953,
340,
8485,
14,
7067,
63,
344,
14,
264,
24728,
63,
16886,
26,
355,
10330,
293,
63,
11048,
275,
378,
355,
367,
4057,
63,
604,
315,
8485,
14,
1185,
63,
604,
63,
24890,
461,
63,
344,
26,
490,
10330,
293,
63,
11048,
847,
413,
490,
291,
14,
11048,
275,
291,
423,
362,
63,
36,
384,
342,
490,
291,
423,
10945,
1119,
434,
63,
576,
8,
5404,
12,
4057,
63,
604,
12,
10330,
293,
63,
11048,
9,
490,
291,
14,
78,
771,
14,
4904,
46,
3456,
14,
331,
3289,
14,
11048,
14,
740,
8,
277,
14,
11048,
9,
953,
862,
26,
355,
291,
423,
24499,
63,
576,
8,
5404,
9,
288,
871,
4281,
26,
355,
986,
953,
291,
14,
15351,
275,
291,
423,
362,
63,
23862,
342,
288,
291,
423,
5087,
63,
15351,
8,
5404,
9,
953,
291,
14,
9886,
23862,
275,
291,
423,
362,
63,
21097,
23862,
342,
288,
291,
423,
5087,
63,
15351,
63,
576,
8,
5404,
9,
288,
291,
14,
78,
771,
14,
4904,
46,
3456,
14,
15351,
14,
9886,
23862,
14,
740,
8,
277,
14,
9886,
23862,
9,
953,
291,
14,
5650,
275,
291,
423,
362,
63,
16969,
342,
288,
291,
423,
3463,
63,
576,
8,
5404,
9,
288,
291,
14,
78,
771,
14,
4904,
46,
3456,
14,
3936,
681,
14,
5650,
14,
740,
8,
277,
14,
5650,
9,
953,
291,
423,
8460,
63,
11697,
8,
5404,
9,
288,
291,
423,
2923,
8,
5404,
9,
288,
291,
423,
3790,
8,
5404,
9,
953,
327,
22261,
65,
2799,
811,
12927,
653,
3456,
288,
291,
14,
78,
771,
14,
836,
65,
63,
6765,
63,
335,
811,
342,
288,
302,
70,
397,
14,
740,
8,
277,
14,
78,
771,
9,
398,
372,
302,
70,
397,
339,
347,
485,
78,
771,
63,
73,
24926,
8,
277,
12,
8485,
12,
7233,
12,
302,
771,
63,
5418,
304,
398,
327,
473,
2433,
696,
22723,
12927,
653,
38,
13,
69,
267,
327,
267,
291,
14,
78,
771,
14,
4904,
46,
3456,
14,
2655,
14,
67,
27363,
14,
637,
269,
275,
334,
4627,
14,
929,
63,
344,
436,
1460,
7233,
14,
929,
63,
344,
14,
1892,
303,
63,
600,
503,
4074,
267,
291,
14,
78,
771,
14,
4904,
46,
3456,
14,
2655,
14,
67,
19749,
14,
637,
269,
275,
2125,
267,
291,
14,
78,
771,
14,
4904,
46,
3456,
14,
2655,
14,
9468,
4619,
14,
637,
269,
275,
334,
288,
8485,
14,
18646,
63,
3710,
63,
344,
14,
354,
1491,
2259,
61,
503,
4074,
267,
291,
14,
78,
771,
14,
4904,
46,
3456,
14,
2655,
14,
688,
23862,
14,
637,
269,
275,
334,
288,
8485,
14,
7948,
63,
5125,
63,
344,
436,
288,
8485,
14,
7948,
63,
5125,
63,
344,
14,
688,
23862,
503,
283,
16,
358,
267,
291,
14,
78,
771,
14,
4904,
46,
3456,
14,
2655,
14,
1494,
14,
637,
269,
275,
8485,
14,
18646,
63,
3554,
63,
344,
14,
600,
503,
2125,
267,
291,
14,
78,
771,
14,
4904,
46,
3456,
14,
2655,
14,
261,
11317,
14,
637,
269,
275,
8485,
14,
3554,
63
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
1898,
334,
35,
9,
6171,
221,
10055,
11318,
491,
11744,
446,
437,
75,
264,
296,
199,
3,
844,
437,
12006,
13,
19,
446,
1666,
1455,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
15,
643,
1168,
13,
19,
14,
16,
14,
1360,
199,
199,
504,
2197,
492,
2197,
199,
504,
23128,
492,
7666,
199,
199,
504,
28811,
14,
3924,
492,
15902,
465,
29908,
199,
504,
28811,
14,
2537,
14,
5275,
492,
485,
199,
199,
504,
28811,
14,
10788,
14,
76,
709,
78,
63,
3289,
63,
2048,
14,
83,
1915,
14,
3554,
492,
481,
15734,
5564,
199,
504,
28811,
14,
10788,
14,
76,
709,
78,
63,
3289,
63,
1095,
14,
2537,
14,
9923,
492,
22929,
63,
5682,
421,
199,
533,
653,
3456,
1840,
8,
38,
15734,
5564,
304,
272,
347,
636,
826,
721,
277,
304,
267,
1613,
8,
46,
3456,
1840,
12,
291,
2843,
826,
4533,
267,
291,
14,
78,
771,
275,
488,
267,
291,
14,
9914,
1121,
275,
488,
267,
291,
14,
9886,
275,
488,
267,
291,
14,
11048,
275,
488,
339,
347,
485,
8349,
8,
277,
12,
26175,
12,
302,
771,
63,
5418,
304,
398,
302,
70,
397,
275,
942,
398,
367,
8485,
315,
26175,
26,
288,
7233,
275,
8485,
14,
4627,
63,
344,
14,
3899,
63,
344,
953,
291,
14,
78,
771,
275,
291,
14,
362,
63,
46,
3456,
342,
953,
291,
423,
78,
771,
63,
73,
24926,
8,
5404,
12,
7233,
12,
302,
771,
63,
5418,
9,
953,
291,
423,
262,
63,
548,
63,
350,
753,
8,
5404,
9,
953,
367,
4572,
63,
2407,
315,
8485,
14,
18646,
63,
3554,
63,
2407,
63,
1580,
26,
355,
291,
14,
9914,
1121,
275,
291,
423,
362,
63,
19749,
2891,
342,
355,
291,
423,
78,
771,
63,
12635,
8,
5350,
63,
2407,
9,
355,
291,
14,
78,
771,
14,
4904,
46,
3456,
14,
2655,
14,
19749,
1121,
14,
740,
8,
277,
14,
9914,
1121,
9,
953,
291,
423,
69,
596,
1661,
8,
5404,
12,
7233,
9,
288,
291,
423,
10244,
8,
5404,
12,
7233,
12,
302,
771,
63,
5418,
9,
953,
284,
275,
378,
288,
367,
4572,
63,
604,
315,
8485,
14,
5404,
63,
604,
63,
1580,
26,
355,
284,
847,
413,
355,
291,
14,
9886,
275,
291,
423,
362,
63,
21097,
342,
355,
291,
423,
5087,
8,
5404,
12,
4572,
63,
604,
12,
284,
9,
2234,
367,
4572,
63,
328,
315,
4572,
63,
604,
14,
646,
63,
15477,
63,
1580,
26,
4951,
291,
14,
328,
275,
291,
423,
362,
63,
1914,
342,
490,
291,
423,
328,
8,
5350,
63,
328,
9,
4951,
367,
4572,
63,
328,
63,
604,
315,
4572,
63,
328,
14,
604,
63,
1580,
26,
717,
291,
14,
328,
63,
604,
275,
291,
423,
362,
63,
2767,
1671,
342,
717,
291,
423,
26799,
8,
5350,
63,
328,
63,
604,
9,
717,
291,
14,
328,
14,
65,
328,
14,
740,
8,
277,
14,
328,
63,
604,
9,
4951,
291,
14,
9886,
14,
8788,
14,
1914,
14,
740,
8,
277,
14,
328,
9,
2234,
291,
14,
78,
771,
14,
4904,
46,
3456,
14,
9886,
14,
740,
8,
277,
14,
9886,
9,
953,
340,
8485,
14,
7067,
63,
344,
14,
264,
24728,
63,
16886,
26,
355,
10330,
293,
63,
11048,
275,
378,
355,
367,
4057,
63,
604,
315,
8485,
14,
1185,
63,
604,
63,
24890,
461,
63,
344,
26,
490,
10330,
293,
63,
11048,
847,
413,
490,
291,
14,
11048,
275,
291,
423,
362,
63,
36,
384,
342,
490,
291,
423,
10945,
1119,
434,
63,
576,
8,
5404,
12,
4057,
63,
604,
12,
10330,
293,
63,
11048,
9,
490,
291,
14,
78,
771,
14,
4904,
46,
3456,
14,
331,
3289,
14,
11048,
14,
740,
8,
277,
14,
11048,
9,
953,
862,
26,
355,
291,
423,
24499,
63,
576,
8,
5404,
9,
288,
871,
4281,
26,
355,
986,
953,
291,
14,
15351,
275,
291,
423,
362,
63,
23862,
342,
288,
291,
423,
5087,
63,
15351,
8,
5404,
9,
953,
291,
14,
9886,
23862,
275,
291,
423,
362,
63,
21097,
23862,
342,
288,
291,
423,
5087,
63,
15351,
63,
576,
8,
5404,
9,
288,
291,
14,
78,
771,
14,
4904,
46,
3456,
14,
15351,
14,
9886,
23862,
14,
740,
8,
277,
14,
9886,
23862,
9,
953,
291,
14,
5650,
275,
291,
423,
362,
63,
16969,
342,
288,
291,
423,
3463,
63,
576,
8,
5404,
9,
288,
291,
14,
78,
771,
14,
4904,
46,
3456,
14,
3936,
681,
14,
5650,
14,
740,
8,
277,
14,
5650,
9,
953,
291,
423,
8460,
63,
11697,
8,
5404,
9,
288,
291,
423,
2923,
8,
5404,
9,
288,
291,
423,
3790,
8,
5404,
9,
953,
327,
22261,
65,
2799,
811,
12927,
653,
3456,
288,
291,
14,
78,
771,
14,
836,
65,
63,
6765,
63,
335,
811,
342,
288,
302,
70,
397,
14,
740,
8,
277,
14,
78,
771,
9,
398,
372,
302,
70,
397,
339,
347,
485,
78,
771,
63,
73,
24926,
8,
277,
12,
8485,
12,
7233,
12,
302,
771,
63,
5418,
304,
398,
327,
473,
2433,
696,
22723,
12927,
653,
38,
13,
69,
267,
327,
267,
291,
14,
78,
771,
14,
4904,
46,
3456,
14,
2655,
14,
67,
27363,
14,
637,
269,
275,
334,
4627,
14,
929,
63,
344,
436,
1460,
7233,
14,
929,
63,
344,
14,
1892,
303,
63,
600,
503,
4074,
267,
291,
14,
78,
771,
14,
4904,
46,
3456,
14,
2655,
14,
67,
19749,
14,
637,
269,
275,
2125,
267,
291,
14,
78,
771,
14,
4904,
46,
3456,
14,
2655,
14,
9468,
4619,
14,
637,
269,
275,
334,
288,
8485,
14,
18646,
63,
3710,
63,
344,
14,
354,
1491,
2259,
61,
503,
4074,
267,
291,
14,
78,
771,
14,
4904,
46,
3456,
14,
2655,
14,
688,
23862,
14,
637,
269,
275,
334,
288,
8485,
14,
7948,
63,
5125,
63,
344,
436,
288,
8485,
14,
7948,
63,
5125,
63,
344,
14,
688,
23862,
503,
283,
16,
358,
267,
291,
14,
78,
771,
14,
4904,
46,
3456,
14,
2655,
14,
1494,
14,
637,
269,
275,
8485,
14,
18646,
63,
3554,
63,
344,
14,
600,
503,
2125,
267,
291,
14,
78,
771,
14,
4904,
46,
3456,
14,
2655,
14,
261,
11317,
14,
637,
269,
275,
8485,
14,
3554,
63,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
fredericosilva/node-gyp
|
gyp/pylib/gyp/MSVSSettings.py
|
253
|
43329
|
# Copyright (c) 2012 Google Inc. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Code to validate and convert settings of the Microsoft build tools.
This file contains code to validate and convert settings of the Microsoft
build tools. The function ConvertToMSBuildSettings(), ValidateMSVSSettings(),
and ValidateMSBuildSettings() are the entry points.
This file was created by comparing the projects created by Visual Studio 2008
and Visual Studio 2010 for all available settings through the user interface.
The MSBuild schemas were also considered. They are typically found in the
MSBuild install directory, e.g. c:\Program Files (x86)\MSBuild
"""
import sys
import re
# Dictionaries of settings validators. The key is the tool name, the value is
# a dictionary mapping setting names to validation functions.
_msvs_validators = {}
_msbuild_validators = {}
# A dictionary of settings converters. The key is the tool name, the value is
# a dictionary mapping setting names to conversion functions.
_msvs_to_msbuild_converters = {}
# Tool name mapping from MSVS to MSBuild.
_msbuild_name_of_tool = {}
class _Tool(object):
"""Represents a tool used by MSVS or MSBuild.
Attributes:
msvs_name: The name of the tool in MSVS.
msbuild_name: The name of the tool in MSBuild.
"""
def __init__(self, msvs_name, msbuild_name):
self.msvs_name = msvs_name
self.msbuild_name = msbuild_name
def _AddTool(tool):
"""Adds a tool to the four dictionaries used to process settings.
This only defines the tool. Each setting also needs to be added.
Args:
tool: The _Tool object to be added.
"""
_msvs_validators[tool.msvs_name] = {}
_msbuild_validators[tool.msbuild_name] = {}
_msvs_to_msbuild_converters[tool.msvs_name] = {}
_msbuild_name_of_tool[tool.msvs_name] = tool.msbuild_name
def _GetMSBuildToolSettings(msbuild_settings, tool):
"""Returns an MSBuild tool dictionary. Creates it if needed."""
return msbuild_settings.setdefault(tool.msbuild_name, {})
class _Type(object):
"""Type of settings (Base class)."""
def ValidateMSVS(self, value):
"""Verifies that the value is legal for MSVS.
Args:
value: the value to check for this type.
Raises:
ValueError if value is not valid for MSVS.
"""
def ValidateMSBuild(self, value):
"""Verifies that the value is legal for MSBuild.
Args:
value: the value to check for this type.
Raises:
ValueError if value is not valid for MSBuild.
"""
def ConvertToMSBuild(self, value):
"""Returns the MSBuild equivalent of the MSVS value given.
Args:
value: the MSVS value to convert.
Returns:
the MSBuild equivalent.
Raises:
ValueError if value is not valid.
"""
return value
class _String(_Type):
"""A setting that's just a string."""
def ValidateMSVS(self, value):
if not isinstance(value, basestring):
raise ValueError('expected string; got %r' % value)
def ValidateMSBuild(self, value):
if not isinstance(value, basestring):
raise ValueError('expected string; got %r' % value)
def ConvertToMSBuild(self, value):
# Convert the macros
return ConvertVCMacrosToMSBuild(value)
class _StringList(_Type):
"""A settings that's a list of strings."""
def ValidateMSVS(self, value):
if not isinstance(value, basestring) and not isinstance(value, list):
raise ValueError('expected string list; got %r' % value)
def ValidateMSBuild(self, value):
if not isinstance(value, basestring) and not isinstance(value, list):
raise ValueError('expected string list; got %r' % value)
def ConvertToMSBuild(self, value):
# Convert the macros
if isinstance(value, list):
return [ConvertVCMacrosToMSBuild(i) for i in value]
else:
return ConvertVCMacrosToMSBuild(value)
class _Boolean(_Type):
"""Boolean settings, can have the values 'false' or 'true'."""
def _Validate(self, value):
if value != 'true' and value != 'false':
raise ValueError('expected bool; got %r' % value)
def ValidateMSVS(self, value):
self._Validate(value)
def ValidateMSBuild(self, value):
self._Validate(value)
def ConvertToMSBuild(self, value):
self._Validate(value)
return value
class _Integer(_Type):
"""Integer settings."""
def __init__(self, msbuild_base=10):
_Type.__init__(self)
self._msbuild_base = msbuild_base
def ValidateMSVS(self, value):
# Try to convert, this will raise ValueError if invalid.
self.ConvertToMSBuild(value)
def ValidateMSBuild(self, value):
# Try to convert, this will raise ValueError if invalid.
int(value, self._msbuild_base)
def ConvertToMSBuild(self, value):
msbuild_format = (self._msbuild_base == 10) and '%d' or '0x%04x'
return msbuild_format % int(value)
class _Enumeration(_Type):
"""Type of settings that is an enumeration.
In MSVS, the values are indexes like '0', '1', and '2'.
MSBuild uses text labels that are more representative, like 'Win32'.
Constructor args:
label_list: an array of MSBuild labels that correspond to the MSVS index.
In the rare cases where MSVS has skipped an index value, None is
used in the array to indicate the unused spot.
new: an array of labels that are new to MSBuild.
"""
def __init__(self, label_list, new=None):
_Type.__init__(self)
self._label_list = label_list
self._msbuild_values = set(value for value in label_list
if value is not None)
if new is not None:
self._msbuild_values.update(new)
def ValidateMSVS(self, value):
# Try to convert. It will raise an exception if not valid.
self.ConvertToMSBuild(value)
def ValidateMSBuild(self, value):
if value not in self._msbuild_values:
raise ValueError('unrecognized enumerated value %s' % value)
def ConvertToMSBuild(self, value):
index = int(value)
if index < 0 or index >= len(self._label_list):
raise ValueError('index value (%d) not in expected range [0, %d)' %
(index, len(self._label_list)))
label = self._label_list[index]
if label is None:
raise ValueError('converted value for %s not specified.' % value)
return label
# Instantiate the various generic types.
_boolean = _Boolean()
_integer = _Integer()
# For now, we don't do any special validation on these types:
_string = _String()
_file_name = _String()
_folder_name = _String()
_file_list = _StringList()
_folder_list = _StringList()
_string_list = _StringList()
# Some boolean settings went from numerical values to boolean. The
# mapping is 0: default, 1: false, 2: true.
_newly_boolean = _Enumeration(['', 'false', 'true'])
def _Same(tool, name, setting_type):
"""Defines a setting that has the same name in MSVS and MSBuild.
Args:
tool: a dictionary that gives the names of the tool for MSVS and MSBuild.
name: the name of the setting.
setting_type: the type of this setting.
"""
_Renamed(tool, name, name, setting_type)
def _Renamed(tool, msvs_name, msbuild_name, setting_type):
"""Defines a setting for which the name has changed.
Args:
tool: a dictionary that gives the names of the tool for MSVS and MSBuild.
msvs_name: the name of the MSVS setting.
msbuild_name: the name of the MSBuild setting.
setting_type: the type of this setting.
"""
def _Translate(value, msbuild_settings):
msbuild_tool_settings = _GetMSBuildToolSettings(msbuild_settings, tool)
msbuild_tool_settings[msbuild_name] = setting_type.ConvertToMSBuild(value)
_msvs_validators[tool.msvs_name][msvs_name] = setting_type.ValidateMSVS
_msbuild_validators[tool.msbuild_name][msbuild_name] = (
setting_type.ValidateMSBuild)
_msvs_to_msbuild_converters[tool.msvs_name][msvs_name] = _Translate
def _Moved(tool, settings_name, msbuild_tool_name, setting_type):
_MovedAndRenamed(tool, settings_name, msbuild_tool_name, settings_name,
setting_type)
def _MovedAndRenamed(tool, msvs_settings_name, msbuild_tool_name,
msbuild_settings_name, setting_type):
"""Defines a setting that may have moved to a new section.
Args:
tool: a dictionary that gives the names of the tool for MSVS and MSBuild.
msvs_settings_name: the MSVS name of the setting.
msbuild_tool_name: the name of the MSBuild tool to place the setting under.
msbuild_settings_name: the MSBuild name of the setting.
setting_type: the type of this setting.
"""
def _Translate(value, msbuild_settings):
tool_settings = msbuild_settings.setdefault(msbuild_tool_name, {})
tool_settings[msbuild_settings_name] = setting_type.ConvertToMSBuild(value)
_msvs_validators[tool.msvs_name][msvs_settings_name] = (
setting_type.ValidateMSVS)
validator = setting_type.ValidateMSBuild
_msbuild_validators[msbuild_tool_name][msbuild_settings_name] = validator
_msvs_to_msbuild_converters[tool.msvs_name][msvs_settings_name] = _Translate
def _MSVSOnly(tool, name, setting_type):
"""Defines a setting that is only found in MSVS.
Args:
tool: a dictionary that gives the names of the tool for MSVS and MSBuild.
name: the name of the setting.
setting_type: the type of this setting.
"""
def _Translate(unused_value, unused_msbuild_settings):
# Since this is for MSVS only settings, no translation will happen.
pass
_msvs_validators[tool.msvs_name][name] = setting_type.ValidateMSVS
_msvs_to_msbuild_converters[tool.msvs_name][name] = _Translate
def _MSBuildOnly(tool, name, setting_type):
"""Defines a setting that is only found in MSBuild.
Args:
tool: a dictionary that gives the names of the tool for MSVS and MSBuild.
name: the name of the setting.
setting_type: the type of this setting.
"""
_msbuild_validators[tool.msbuild_name][name] = setting_type.ValidateMSBuild
def _ConvertedToAdditionalOption(tool, msvs_name, flag):
"""Defines a setting that's handled via a command line option in MSBuild.
Args:
tool: a dictionary that gives the names of the tool for MSVS and MSBuild.
msvs_name: the name of the MSVS setting that if 'true' becomes a flag
flag: the flag to insert at the end of the AdditionalOptions
"""
def _Translate(value, msbuild_settings):
if value == 'true':
tool_settings = _GetMSBuildToolSettings(msbuild_settings, tool)
if 'AdditionalOptions' in tool_settings:
new_flags = '%s %s' % (tool_settings['AdditionalOptions'], flag)
else:
new_flags = flag
tool_settings['AdditionalOptions'] = new_flags
_msvs_validators[tool.msvs_name][msvs_name] = _boolean.ValidateMSVS
_msvs_to_msbuild_converters[tool.msvs_name][msvs_name] = _Translate
def _CustomGeneratePreprocessedFile(tool, msvs_name):
def _Translate(value, msbuild_settings):
tool_settings = _GetMSBuildToolSettings(msbuild_settings, tool)
if value == '0':
tool_settings['PreprocessToFile'] = 'false'
tool_settings['PreprocessSuppressLineNumbers'] = 'false'
elif value == '1': # /P
tool_settings['PreprocessToFile'] = 'true'
tool_settings['PreprocessSuppressLineNumbers'] = 'false'
elif value == '2': # /EP /P
tool_settings['PreprocessToFile'] = 'true'
tool_settings['PreprocessSuppressLineNumbers'] = 'true'
else:
raise ValueError('value must be one of [0, 1, 2]; got %s' % value)
# Create a bogus validator that looks for '0', '1', or '2'
msvs_validator = _Enumeration(['a', 'b', 'c']).ValidateMSVS
_msvs_validators[tool.msvs_name][msvs_name] = msvs_validator
msbuild_validator = _boolean.ValidateMSBuild
msbuild_tool_validators = _msbuild_validators[tool.msbuild_name]
msbuild_tool_validators['PreprocessToFile'] = msbuild_validator
msbuild_tool_validators['PreprocessSuppressLineNumbers'] = msbuild_validator
_msvs_to_msbuild_converters[tool.msvs_name][msvs_name] = _Translate
fix_vc_macro_slashes_regex_list = ('IntDir', 'OutDir')
fix_vc_macro_slashes_regex = re.compile(
r'(\$\((?:%s)\))(?:[\\/]+)' % "|".join(fix_vc_macro_slashes_regex_list)
)
def FixVCMacroSlashes(s):
"""Replace macros which have excessive following slashes.
These macros are known to have a built-in trailing slash. Furthermore, many
scripts hiccup on processing paths with extra slashes in the middle.
This list is probably not exhaustive. Add as needed.
"""
if '$' in s:
s = fix_vc_macro_slashes_regex.sub(r'\1', s)
return s
def ConvertVCMacrosToMSBuild(s):
"""Convert the the MSVS macros found in the string to the MSBuild equivalent.
This list is probably not exhaustive. Add as needed.
"""
if '$' in s:
replace_map = {
'$(ConfigurationName)': '$(Configuration)',
'$(InputDir)': '%(RootDir)%(Directory)',
'$(InputExt)': '%(Extension)',
'$(InputFileName)': '%(Filename)%(Extension)',
'$(InputName)': '%(Filename)',
'$(InputPath)': '%(FullPath)',
'$(ParentName)': '$(ProjectFileName)',
'$(PlatformName)': '$(Platform)',
'$(SafeInputName)': '%(Filename)',
}
for old, new in replace_map.iteritems():
s = s.replace(old, new)
s = FixVCMacroSlashes(s)
return s
def ConvertToMSBuildSettings(msvs_settings, stderr=sys.stderr):
"""Converts MSVS settings (VS2008 and earlier) to MSBuild settings (VS2010+).
Args:
msvs_settings: A dictionary. The key is the tool name. The values are
themselves dictionaries of settings and their values.
stderr: The stream receiving the error messages.
Returns:
A dictionary of MSBuild settings. The key is either the MSBuild tool name
or the empty string (for the global settings). The values are themselves
dictionaries of settings and their values.
"""
msbuild_settings = {}
for msvs_tool_name, msvs_tool_settings in msvs_settings.iteritems():
if msvs_tool_name in _msvs_to_msbuild_converters:
msvs_tool = _msvs_to_msbuild_converters[msvs_tool_name]
for msvs_setting, msvs_value in msvs_tool_settings.iteritems():
if msvs_setting in msvs_tool:
# Invoke the translation function.
try:
msvs_tool[msvs_setting](msvs_value, msbuild_settings)
except ValueError, e:
print >> stderr, ('Warning: while converting %s/%s to MSBuild, '
'%s' % (msvs_tool_name, msvs_setting, e))
else:
# We don't know this setting. Give a warning.
print >> stderr, ('Warning: unrecognized setting %s/%s '
'while converting to MSBuild.' %
(msvs_tool_name, msvs_setting))
else:
print >> stderr, ('Warning: unrecognized tool %s while converting to '
'MSBuild.' % msvs_tool_name)
return msbuild_settings
def ValidateMSVSSettings(settings, stderr=sys.stderr):
"""Validates that the names of the settings are valid for MSVS.
Args:
settings: A dictionary. The key is the tool name. The values are
themselves dictionaries of settings and their values.
stderr: The stream receiving the error messages.
"""
_ValidateSettings(_msvs_validators, settings, stderr)
def ValidateMSBuildSettings(settings, stderr=sys.stderr):
"""Validates that the names of the settings are valid for MSBuild.
Args:
settings: A dictionary. The key is the tool name. The values are
themselves dictionaries of settings and their values.
stderr: The stream receiving the error messages.
"""
_ValidateSettings(_msbuild_validators, settings, stderr)
def _ValidateSettings(validators, settings, stderr):
"""Validates that the settings are valid for MSBuild or MSVS.
We currently only validate the names of the settings, not their values.
Args:
validators: A dictionary of tools and their validators.
settings: A dictionary. The key is the tool name. The values are
themselves dictionaries of settings and their values.
stderr: The stream receiving the error messages.
"""
for tool_name in settings:
if tool_name in validators:
tool_validators = validators[tool_name]
for setting, value in settings[tool_name].iteritems():
if setting in tool_validators:
try:
tool_validators[setting](value)
except ValueError, e:
print >> stderr, ('Warning: for %s/%s, %s' %
(tool_name, setting, e))
else:
print >> stderr, ('Warning: unrecognized setting %s/%s' %
(tool_name, setting))
else:
print >> stderr, ('Warning: unrecognized tool %s' % tool_name)
# MSVS and MBuild names of the tools.
_compile = _Tool('VCCLCompilerTool', 'ClCompile')
_link = _Tool('VCLinkerTool', 'Link')
_midl = _Tool('VCMIDLTool', 'Midl')
_rc = _Tool('VCResourceCompilerTool', 'ResourceCompile')
_lib = _Tool('VCLibrarianTool', 'Lib')
_manifest = _Tool('VCManifestTool', 'Manifest')
_AddTool(_compile)
_AddTool(_link)
_AddTool(_midl)
_AddTool(_rc)
_AddTool(_lib)
_AddTool(_manifest)
# Add sections only found in the MSBuild settings.
_msbuild_validators[''] = {}
_msbuild_validators['ProjectReference'] = {}
_msbuild_validators['ManifestResourceCompile'] = {}
# Descriptions of the compiler options, i.e. VCCLCompilerTool in MSVS and
# ClCompile in MSBuild.
# See "c:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\1033\cl.xml" for
# the schema of the MSBuild ClCompile settings.
# Options that have the same name in MSVS and MSBuild
_Same(_compile, 'AdditionalIncludeDirectories', _folder_list) # /I
_Same(_compile, 'AdditionalOptions', _string_list)
_Same(_compile, 'AdditionalUsingDirectories', _folder_list) # /AI
_Same(_compile, 'AssemblerListingLocation', _file_name) # /Fa
_Same(_compile, 'BrowseInformationFile', _file_name)
_Same(_compile, 'BufferSecurityCheck', _boolean) # /GS
_Same(_compile, 'DisableLanguageExtensions', _boolean) # /Za
_Same(_compile, 'DisableSpecificWarnings', _string_list) # /wd
_Same(_compile, 'EnableFiberSafeOptimizations', _boolean) # /GT
_Same(_compile, 'EnablePREfast', _boolean) # /analyze Visible='false'
_Same(_compile, 'ExpandAttributedSource', _boolean) # /Fx
_Same(_compile, 'FloatingPointExceptions', _boolean) # /fp:except
_Same(_compile, 'ForceConformanceInForLoopScope', _boolean) # /Zc:forScope
_Same(_compile, 'ForcedIncludeFiles', _file_list) # /FI
_Same(_compile, 'ForcedUsingFiles', _file_list) # /FU
_Same(_compile, 'GenerateXMLDocumentationFiles', _boolean) # /doc
_Same(_compile, 'IgnoreStandardIncludePath', _boolean) # /X
_Same(_compile, 'MinimalRebuild', _boolean) # /Gm
_Same(_compile, 'OmitDefaultLibName', _boolean) # /Zl
_Same(_compile, 'OmitFramePointers', _boolean) # /Oy
_Same(_compile, 'PreprocessorDefinitions', _string_list) # /D
_Same(_compile, 'ProgramDataBaseFileName', _file_name) # /Fd
_Same(_compile, 'RuntimeTypeInfo', _boolean) # /GR
_Same(_compile, 'ShowIncludes', _boolean) # /showIncludes
_Same(_compile, 'SmallerTypeCheck', _boolean) # /RTCc
_Same(_compile, 'StringPooling', _boolean) # /GF
_Same(_compile, 'SuppressStartupBanner', _boolean) # /nologo
_Same(_compile, 'TreatWChar_tAsBuiltInType', _boolean) # /Zc:wchar_t
_Same(_compile, 'UndefineAllPreprocessorDefinitions', _boolean) # /u
_Same(_compile, 'UndefinePreprocessorDefinitions', _string_list) # /U
_Same(_compile, 'UseFullPaths', _boolean) # /FC
_Same(_compile, 'WholeProgramOptimization', _boolean) # /GL
_Same(_compile, 'XMLDocumentationFileName', _file_name)
_Same(_compile, 'AssemblerOutput',
_Enumeration(['NoListing',
'AssemblyCode', # /FA
'All', # /FAcs
'AssemblyAndMachineCode', # /FAc
'AssemblyAndSourceCode'])) # /FAs
_Same(_compile, 'BasicRuntimeChecks',
_Enumeration(['Default',
'StackFrameRuntimeCheck', # /RTCs
'UninitializedLocalUsageCheck', # /RTCu
'EnableFastChecks'])) # /RTC1
_Same(_compile, 'BrowseInformation',
_Enumeration(['false',
'true', # /FR
'true'])) # /Fr
_Same(_compile, 'CallingConvention',
_Enumeration(['Cdecl', # /Gd
'FastCall', # /Gr
'StdCall'])) # /Gz
_Same(_compile, 'CompileAs',
_Enumeration(['Default',
'CompileAsC', # /TC
'CompileAsCpp'])) # /TP
_Same(_compile, 'DebugInformationFormat',
_Enumeration(['', # Disabled
'OldStyle', # /Z7
None,
'ProgramDatabase', # /Zi
'EditAndContinue'])) # /ZI
_Same(_compile, 'EnableEnhancedInstructionSet',
_Enumeration(['NotSet',
'StreamingSIMDExtensions', # /arch:SSE
'StreamingSIMDExtensions2'])) # /arch:SSE2
_Same(_compile, 'ErrorReporting',
_Enumeration(['None', # /errorReport:none
'Prompt', # /errorReport:prompt
'Queue'], # /errorReport:queue
new=['Send'])) # /errorReport:send"
_Same(_compile, 'ExceptionHandling',
_Enumeration(['false',
'Sync', # /EHsc
'Async'], # /EHa
new=['SyncCThrow'])) # /EHs
_Same(_compile, 'FavorSizeOrSpeed',
_Enumeration(['Neither',
'Speed', # /Ot
'Size'])) # /Os
_Same(_compile, 'FloatingPointModel',
_Enumeration(['Precise', # /fp:precise
'Strict', # /fp:strict
'Fast'])) # /fp:fast
_Same(_compile, 'InlineFunctionExpansion',
_Enumeration(['Default',
'OnlyExplicitInline', # /Ob1
'AnySuitable'], # /Ob2
new=['Disabled'])) # /Ob0
_Same(_compile, 'Optimization',
_Enumeration(['Disabled', # /Od
'MinSpace', # /O1
'MaxSpeed', # /O2
'Full'])) # /Ox
_Same(_compile, 'RuntimeLibrary',
_Enumeration(['MultiThreaded', # /MT
'MultiThreadedDebug', # /MTd
'MultiThreadedDLL', # /MD
'MultiThreadedDebugDLL'])) # /MDd
_Same(_compile, 'StructMemberAlignment',
_Enumeration(['Default',
'1Byte', # /Zp1
'2Bytes', # /Zp2
'4Bytes', # /Zp4
'8Bytes', # /Zp8
'16Bytes'])) # /Zp16
_Same(_compile, 'WarningLevel',
_Enumeration(['TurnOffAllWarnings', # /W0
'Level1', # /W1
'Level2', # /W2
'Level3', # /W3
'Level4'], # /W4
new=['EnableAllWarnings'])) # /Wall
# Options found in MSVS that have been renamed in MSBuild.
_Renamed(_compile, 'EnableFunctionLevelLinking', 'FunctionLevelLinking',
_boolean) # /Gy
_Renamed(_compile, 'EnableIntrinsicFunctions', 'IntrinsicFunctions',
_boolean) # /Oi
_Renamed(_compile, 'KeepComments', 'PreprocessKeepComments', _boolean) # /C
_Renamed(_compile, 'ObjectFile', 'ObjectFileName', _file_name) # /Fo
_Renamed(_compile, 'OpenMP', 'OpenMPSupport', _boolean) # /openmp
_Renamed(_compile, 'PrecompiledHeaderThrough', 'PrecompiledHeaderFile',
_file_name) # Used with /Yc and /Yu
_Renamed(_compile, 'PrecompiledHeaderFile', 'PrecompiledHeaderOutputFile',
_file_name) # /Fp
_Renamed(_compile, 'UsePrecompiledHeader', 'PrecompiledHeader',
_Enumeration(['NotUsing', # VS recognized '' for this value too.
'Create', # /Yc
'Use'])) # /Yu
_Renamed(_compile, 'WarnAsError', 'TreatWarningAsError', _boolean) # /WX
_ConvertedToAdditionalOption(_compile, 'DefaultCharIsUnsigned', '/J')
# MSVS options not found in MSBuild.
_MSVSOnly(_compile, 'Detect64BitPortabilityProblems', _boolean)
_MSVSOnly(_compile, 'UseUnicodeResponseFiles', _boolean)
# MSBuild options not found in MSVS.
_MSBuildOnly(_compile, 'BuildingInIDE', _boolean)
_MSBuildOnly(_compile, 'CompileAsManaged',
_Enumeration([], new=['false',
'true', # /clr
'Pure', # /clr:pure
'Safe', # /clr:safe
'OldSyntax'])) # /clr:oldSyntax
_MSBuildOnly(_compile, 'CreateHotpatchableImage', _boolean) # /hotpatch
_MSBuildOnly(_compile, 'MultiProcessorCompilation', _boolean) # /MP
_MSBuildOnly(_compile, 'PreprocessOutputPath', _string) # /Fi
_MSBuildOnly(_compile, 'ProcessorNumber', _integer) # the number of processors
_MSBuildOnly(_compile, 'TrackerLogDirectory', _folder_name)
_MSBuildOnly(_compile, 'TreatSpecificWarningsAsErrors', _string_list) # /we
_MSBuildOnly(_compile, 'UseUnicodeForAssemblerListing', _boolean) # /FAu
# Defines a setting that needs very customized processing
_CustomGeneratePreprocessedFile(_compile, 'GeneratePreprocessedFile')
# Directives for converting MSVS VCLinkerTool to MSBuild Link.
# See "c:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\1033\link.xml" for
# the schema of the MSBuild Link settings.
# Options that have the same name in MSVS and MSBuild
_Same(_link, 'AdditionalDependencies', _file_list)
_Same(_link, 'AdditionalLibraryDirectories', _folder_list) # /LIBPATH
# /MANIFESTDEPENDENCY:
_Same(_link, 'AdditionalManifestDependencies', _file_list)
_Same(_link, 'AdditionalOptions', _string_list)
_Same(_link, 'AddModuleNamesToAssembly', _file_list) # /ASSEMBLYMODULE
_Same(_link, 'AllowIsolation', _boolean) # /ALLOWISOLATION
_Same(_link, 'AssemblyLinkResource', _file_list) # /ASSEMBLYLINKRESOURCE
_Same(_link, 'BaseAddress', _string) # /BASE
_Same(_link, 'CLRUnmanagedCodeCheck', _boolean) # /CLRUNMANAGEDCODECHECK
_Same(_link, 'DelayLoadDLLs', _file_list) # /DELAYLOAD
_Same(_link, 'DelaySign', _boolean) # /DELAYSIGN
_Same(_link, 'EmbedManagedResourceFile', _file_list) # /ASSEMBLYRESOURCE
_Same(_link, 'EnableUAC', _boolean) # /MANIFESTUAC
_Same(_link, 'EntryPointSymbol', _string) # /ENTRY
_Same(_link, 'ForceSymbolReferences', _file_list) # /INCLUDE
_Same(_link, 'FunctionOrder', _file_name) # /ORDER
_Same(_link, 'GenerateDebugInformation', _boolean) # /DEBUG
_Same(_link, 'GenerateMapFile', _boolean) # /MAP
_Same(_link, 'HeapCommitSize', _string)
_Same(_link, 'HeapReserveSize', _string) # /HEAP
_Same(_link, 'IgnoreAllDefaultLibraries', _boolean) # /NODEFAULTLIB
_Same(_link, 'IgnoreEmbeddedIDL', _boolean) # /IGNOREIDL
_Same(_link, 'ImportLibrary', _file_name) # /IMPLIB
_Same(_link, 'KeyContainer', _file_name) # /KEYCONTAINER
_Same(_link, 'KeyFile', _file_name) # /KEYFILE
_Same(_link, 'ManifestFile', _file_name) # /ManifestFile
_Same(_link, 'MapExports', _boolean) # /MAPINFO:EXPORTS
_Same(_link, 'MapFileName', _file_name)
_Same(_link, 'MergedIDLBaseFileName', _file_name) # /IDLOUT
_Same(_link, 'MergeSections', _string) # /MERGE
_Same(_link, 'MidlCommandFile', _file_name) # /MIDL
_Same(_link, 'ModuleDefinitionFile', _file_name) # /DEF
_Same(_link, 'OutputFile', _file_name) # /OUT
_Same(_link, 'PerUserRedirection', _boolean)
_Same(_link, 'Profile', _boolean) # /PROFILE
_Same(_link, 'ProfileGuidedDatabase', _file_name) # /PGD
_Same(_link, 'ProgramDatabaseFile', _file_name) # /PDB
_Same(_link, 'RegisterOutput', _boolean)
_Same(_link, 'SetChecksum', _boolean) # /RELEASE
_Same(_link, 'StackCommitSize', _string)
_Same(_link, 'StackReserveSize', _string) # /STACK
_Same(_link, 'StripPrivateSymbols', _file_name) # /PDBSTRIPPED
_Same(_link, 'SupportUnloadOfDelayLoadedDLL', _boolean) # /DELAY:UNLOAD
_Same(_link, 'SuppressStartupBanner', _boolean) # /NOLOGO
_Same(_link, 'SwapRunFromCD', _boolean) # /SWAPRUN:CD
_Same(_link, 'TurnOffAssemblyGeneration', _boolean) # /NOASSEMBLY
_Same(_link, 'TypeLibraryFile', _file_name) # /TLBOUT
_Same(_link, 'TypeLibraryResourceID', _integer) # /TLBID
_Same(_link, 'UACUIAccess', _boolean) # /uiAccess='true'
_Same(_link, 'Version', _string) # /VERSION
_Same(_link, 'EnableCOMDATFolding', _newly_boolean) # /OPT:ICF
_Same(_link, 'FixedBaseAddress', _newly_boolean) # /FIXED
_Same(_link, 'LargeAddressAware', _newly_boolean) # /LARGEADDRESSAWARE
_Same(_link, 'OptimizeReferences', _newly_boolean) # /OPT:REF
_Same(_link, 'RandomizedBaseAddress', _newly_boolean) # /DYNAMICBASE
_Same(_link, 'TerminalServerAware', _newly_boolean) # /TSAWARE
_subsystem_enumeration = _Enumeration(
['NotSet',
'Console', # /SUBSYSTEM:CONSOLE
'Windows', # /SUBSYSTEM:WINDOWS
'Native', # /SUBSYSTEM:NATIVE
'EFI Application', # /SUBSYSTEM:EFI_APPLICATION
'EFI Boot Service Driver', # /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER
'EFI ROM', # /SUBSYSTEM:EFI_ROM
'EFI Runtime', # /SUBSYSTEM:EFI_RUNTIME_DRIVER
'WindowsCE'], # /SUBSYSTEM:WINDOWSCE
new=['POSIX']) # /SUBSYSTEM:POSIX
_target_machine_enumeration = _Enumeration(
['NotSet',
'MachineX86', # /MACHINE:X86
None,
'MachineARM', # /MACHINE:ARM
'MachineEBC', # /MACHINE:EBC
'MachineIA64', # /MACHINE:IA64
None,
'MachineMIPS', # /MACHINE:MIPS
'MachineMIPS16', # /MACHINE:MIPS16
'MachineMIPSFPU', # /MACHINE:MIPSFPU
'MachineMIPSFPU16', # /MACHINE:MIPSFPU16
None,
None,
None,
'MachineSH4', # /MACHINE:SH4
None,
'MachineTHUMB', # /MACHINE:THUMB
'MachineX64']) # /MACHINE:X64
_Same(_link, 'AssemblyDebug',
_Enumeration(['',
'true', # /ASSEMBLYDEBUG
'false'])) # /ASSEMBLYDEBUG:DISABLE
_Same(_link, 'CLRImageType',
_Enumeration(['Default',
'ForceIJWImage', # /CLRIMAGETYPE:IJW
'ForcePureILImage', # /Switch="CLRIMAGETYPE:PURE
'ForceSafeILImage'])) # /Switch="CLRIMAGETYPE:SAFE
_Same(_link, 'CLRThreadAttribute',
_Enumeration(['DefaultThreadingAttribute', # /CLRTHREADATTRIBUTE:NONE
'MTAThreadingAttribute', # /CLRTHREADATTRIBUTE:MTA
'STAThreadingAttribute'])) # /CLRTHREADATTRIBUTE:STA
_Same(_link, 'DataExecutionPrevention',
_Enumeration(['',
'false', # /NXCOMPAT:NO
'true'])) # /NXCOMPAT
_Same(_link, 'Driver',
_Enumeration(['NotSet',
'Driver', # /Driver
'UpOnly', # /DRIVER:UPONLY
'WDM'])) # /DRIVER:WDM
_Same(_link, 'LinkTimeCodeGeneration',
_Enumeration(['Default',
'UseLinkTimeCodeGeneration', # /LTCG
'PGInstrument', # /LTCG:PGInstrument
'PGOptimization', # /LTCG:PGOptimize
'PGUpdate'])) # /LTCG:PGUpdate
_Same(_link, 'ShowProgress',
_Enumeration(['NotSet',
'LinkVerbose', # /VERBOSE
'LinkVerboseLib'], # /VERBOSE:Lib
new=['LinkVerboseICF', # /VERBOSE:ICF
'LinkVerboseREF', # /VERBOSE:REF
'LinkVerboseSAFESEH', # /VERBOSE:SAFESEH
'LinkVerboseCLR'])) # /VERBOSE:CLR
_Same(_link, 'SubSystem', _subsystem_enumeration)
_Same(_link, 'TargetMachine', _target_machine_enumeration)
_Same(_link, 'UACExecutionLevel',
_Enumeration(['AsInvoker', # /level='asInvoker'
'HighestAvailable', # /level='highestAvailable'
'RequireAdministrator'])) # /level='requireAdministrator'
# Options found in MSVS that have been renamed in MSBuild.
_Renamed(_link, 'ErrorReporting', 'LinkErrorReporting',
_Enumeration(['NoErrorReport', # /ERRORREPORT:NONE
'PromptImmediately', # /ERRORREPORT:PROMPT
'QueueForNextLogin'], # /ERRORREPORT:QUEUE
new=['SendErrorReport'])) # /ERRORREPORT:SEND
_Renamed(_link, 'IgnoreDefaultLibraryNames', 'IgnoreSpecificDefaultLibraries',
_file_list) # /NODEFAULTLIB
_Renamed(_link, 'ResourceOnlyDLL', 'NoEntryPoint', _boolean) # /NOENTRY
_Renamed(_link, 'SwapRunFromNet', 'SwapRunFromNET', _boolean) # /SWAPRUN:NET
_Moved(_link, 'GenerateManifest', '', _boolean)
_Moved(_link, 'IgnoreImportLibrary', '', _boolean)
_Moved(_link, 'LinkIncremental', '', _newly_boolean)
_Moved(_link, 'LinkLibraryDependencies', 'ProjectReference', _boolean)
_Moved(_link, 'UseLibraryDependencyInputs', 'ProjectReference', _boolean)
# MSVS options not found in MSBuild.
_MSVSOnly(_link, 'OptimizeForWindows98', _newly_boolean)
_MSVSOnly(_link, 'UseUnicodeResponseFiles', _boolean)
# TODO(jeanluc) I don't think these are genuine settings but byproducts of Gyp.
_MSVSOnly(_link, 'AdditionalLibraryDirectories_excluded', _folder_list)
# MSBuild options not found in MSVS.
_MSBuildOnly(_link, 'BuildingInIDE', _boolean)
_MSBuildOnly(_link, 'ImageHasSafeExceptionHandlers', _boolean) # /SAFESEH
_MSBuildOnly(_link, 'LinkDLL', _boolean) # /DLL Visible='false'
_MSBuildOnly(_link, 'LinkStatus', _boolean) # /LTCG:STATUS
_MSBuildOnly(_link, 'PreventDllBinding', _boolean) # /ALLOWBIND
_MSBuildOnly(_link, 'SupportNobindOfDelayLoadedDLL', _boolean) # /DELAY:NOBIND
_MSBuildOnly(_link, 'TrackerLogDirectory', _folder_name)
_MSBuildOnly(_link, 'TreatLinkerWarningAsErrors', _boolean) # /WX
_MSBuildOnly(_link, 'MinimumRequiredVersion', _string)
_MSBuildOnly(_link, 'MSDOSStubFileName', _file_name) # /STUB Visible='false'
_MSBuildOnly(_link, 'SectionAlignment', _integer) # /ALIGN
_MSBuildOnly(_link, 'SpecifySectionAttributes', _string) # /SECTION
_MSBuildOnly(_link, 'ForceFileOutput',
_Enumeration([], new=['Enabled', # /FORCE
# /FORCE:MULTIPLE
'MultiplyDefinedSymbolOnly',
'UndefinedSymbolOnly'])) # /FORCE:UNRESOLVED
_MSBuildOnly(_link, 'CreateHotPatchableImage',
_Enumeration([], new=['Enabled', # /FUNCTIONPADMIN
'X86Image', # /FUNCTIONPADMIN:5
'X64Image', # /FUNCTIONPADMIN:6
'ItaniumImage'])) # /FUNCTIONPADMIN:16
_MSBuildOnly(_link, 'CLRSupportLastError',
_Enumeration([], new=['Enabled', # /CLRSupportLastError
'Disabled', # /CLRSupportLastError:NO
# /CLRSupportLastError:SYSTEMDLL
'SystemDlls']))
# Directives for converting VCResourceCompilerTool to ResourceCompile.
# See "c:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\1033\rc.xml" for
# the schema of the MSBuild ResourceCompile settings.
_Same(_rc, 'AdditionalOptions', _string_list)
_Same(_rc, 'AdditionalIncludeDirectories', _folder_list) # /I
_Same(_rc, 'Culture', _Integer(msbuild_base=16))
_Same(_rc, 'IgnoreStandardIncludePath', _boolean) # /X
_Same(_rc, 'PreprocessorDefinitions', _string_list) # /D
_Same(_rc, 'ResourceOutputFileName', _string) # /fo
_Same(_rc, 'ShowProgress', _boolean) # /v
# There is no UI in VisualStudio 2008 to set the following properties.
# However they are found in CL and other tools. Include them here for
# completeness, as they are very likely to have the same usage pattern.
_Same(_rc, 'SuppressStartupBanner', _boolean) # /nologo
_Same(_rc, 'UndefinePreprocessorDefinitions', _string_list) # /u
# MSBuild options not found in MSVS.
_MSBuildOnly(_rc, 'NullTerminateStrings', _boolean) # /n
_MSBuildOnly(_rc, 'TrackerLogDirectory', _folder_name)
# Directives for converting VCMIDLTool to Midl.
# See "c:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\1033\midl.xml" for
# the schema of the MSBuild Midl settings.
_Same(_midl, 'AdditionalIncludeDirectories', _folder_list) # /I
_Same(_midl, 'AdditionalOptions', _string_list)
_Same(_midl, 'CPreprocessOptions', _string) # /cpp_opt
_Same(_midl, 'ErrorCheckAllocations', _boolean) # /error allocation
_Same(_midl, 'ErrorCheckBounds', _boolean) # /error bounds_check
_Same(_midl, 'ErrorCheckEnumRange', _boolean) # /error enum
_Same(_midl, 'ErrorCheckRefPointers', _boolean) # /error ref
_Same(_midl, 'ErrorCheckStubData', _boolean) # /error stub_data
_Same(_midl, 'GenerateStublessProxies', _boolean) # /Oicf
_Same(_midl, 'GenerateTypeLibrary', _boolean)
_Same(_midl, 'HeaderFileName', _file_name) # /h
_Same(_midl, 'IgnoreStandardIncludePath', _boolean) # /no_def_idir
_Same(_midl, 'InterfaceIdentifierFileName', _file_name) # /iid
_Same(_midl, 'MkTypLibCompatible', _boolean) # /mktyplib203
_Same(_midl, 'OutputDirectory', _string) # /out
_Same(_midl, 'PreprocessorDefinitions', _string_list) # /D
_Same(_midl, 'ProxyFileName', _file_name) # /proxy
_Same(_midl, 'RedirectOutputAndErrors', _file_name) # /o
_Same(_midl, 'SuppressStartupBanner', _boolean) # /nologo
_Same(_midl, 'TypeLibraryName', _file_name) # /tlb
_Same(_midl, 'UndefinePreprocessorDefinitions', _string_list) # /U
_Same(_midl, 'WarnAsError', _boolean) # /WX
_Same(_midl, 'DefaultCharType',
_Enumeration(['Unsigned', # /char unsigned
'Signed', # /char signed
'Ascii'])) # /char ascii7
_Same(_midl, 'TargetEnvironment',
_Enumeration(['NotSet',
'Win32', # /env win32
'Itanium', # /env ia64
'X64'])) # /env x64
_Same(_midl, 'EnableErrorChecks',
_Enumeration(['EnableCustom',
'None', # /error none
'All'])) # /error all
_Same(_midl, 'StructMemberAlignment',
_Enumeration(['NotSet',
'1', # Zp1
'2', # Zp2
'4', # Zp4
'8'])) # Zp8
_Same(_midl, 'WarningLevel',
_Enumeration(['0', # /W0
'1', # /W1
'2', # /W2
'3', # /W3
'4'])) # /W4
_Renamed(_midl, 'DLLDataFileName', 'DllDataFileName', _file_name) # /dlldata
_Renamed(_midl, 'ValidateParameters', 'ValidateAllParameters',
_boolean) # /robust
# MSBuild options not found in MSVS.
_MSBuildOnly(_midl, 'ApplicationConfigurationMode', _boolean) # /app_config
_MSBuildOnly(_midl, 'ClientStubFile', _file_name) # /cstub
_MSBuildOnly(_midl, 'GenerateClientFiles',
_Enumeration([], new=['Stub', # /client stub
'None'])) # /client none
_MSBuildOnly(_midl, 'GenerateServerFiles',
_Enumeration([], new=['Stub', # /client stub
'None'])) # /client none
_MSBuildOnly(_midl, 'LocaleID', _integer) # /lcid DECIMAL
_MSBuildOnly(_midl, 'ServerStubFile', _file_name) # /sstub
_MSBuildOnly(_midl, 'SuppressCompilerWarnings', _boolean) # /no_warn
_MSBuildOnly(_midl, 'TrackerLogDirectory', _folder_name)
_MSBuildOnly(_midl, 'TypeLibFormat',
_Enumeration([], new=['NewFormat', # /newtlb
'OldFormat'])) # /oldtlb
# Directives for converting VCLibrarianTool to Lib.
# See "c:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\1033\lib.xml" for
# the schema of the MSBuild Lib settings.
_Same(_lib, 'AdditionalDependencies', _file_list)
_Same(_lib, 'AdditionalLibraryDirectories', _folder_list) # /LIBPATH
_Same(_lib, 'AdditionalOptions', _string_list)
_Same(_lib, 'ExportNamedFunctions', _string_list) # /EXPORT
_Same(_lib, 'ForceSymbolReferences', _string) # /INCLUDE
_Same(_lib, 'IgnoreAllDefaultLibraries', _boolean) # /NODEFAULTLIB
_Same(_lib, 'IgnoreSpecificDefaultLibraries', _file_list) # /NODEFAULTLIB
_Same(_lib, 'ModuleDefinitionFile', _file_name) # /DEF
_Same(_lib, 'OutputFile', _file_name) # /OUT
_Same(_lib, 'SuppressStartupBanner', _boolean) # /NOLOGO
_Same(_lib, 'UseUnicodeResponseFiles', _boolean)
_Same(_lib, 'LinkTimeCodeGeneration', _boolean) # /LTCG
# TODO(jeanluc) _link defines the same value that gets moved to
# ProjectReference. We may want to validate that they are consistent.
_Moved(_lib, 'LinkLibraryDependencies', 'ProjectReference', _boolean)
# TODO(jeanluc) I don't think these are genuine settings but byproducts of Gyp.
_MSVSOnly(_lib, 'AdditionalLibraryDirectories_excluded', _folder_list)
_MSBuildOnly(_lib, 'DisplayLibrary', _string) # /LIST Visible='false'
_MSBuildOnly(_lib, 'ErrorReporting',
_Enumeration([], new=['PromptImmediately', # /ERRORREPORT:PROMPT
'QueueForNextLogin', # /ERRORREPORT:QUEUE
'SendErrorReport', # /ERRORREPORT:SEND
'NoErrorReport'])) # /ERRORREPORT:NONE
_MSBuildOnly(_lib, 'MinimumRequiredVersion', _string)
_MSBuildOnly(_lib, 'Name', _file_name) # /NAME
_MSBuildOnly(_lib, 'RemoveObjects', _file_list) # /REMOVE
_MSBuildOnly(_lib, 'SubSystem', _subsystem_enumeration)
_MSBuildOnly(_lib, 'TargetMachine', _target_machine_enumeration)
_MSBuildOnly(_lib, 'TrackerLogDirectory', _folder_name)
_MSBuildOnly(_lib, 'TreatLibWarningAsErrors', _boolean) # /WX
_MSBuildOnly(_lib, 'Verbose', _boolean)
# Directives for converting VCManifestTool to Mt.
# See "c:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\1033\mt.xml" for
# the schema of the MSBuild Lib settings.
# Options that have the same name in MSVS and MSBuild
_Same(_manifest, 'AdditionalManifestFiles', _file_list) # /manifest
_Same(_manifest, 'AdditionalOptions', _string_list)
_Same(_manifest, 'AssemblyIdentity', _string) # /identity:
_Same(_manifest, 'ComponentFileName', _file_name) # /dll
_Same(_manifest, 'GenerateCatalogFiles', _boolean) # /makecdfs
_Same(_manifest, 'InputResourceManifests', _string) # /inputresource
_Same(_manifest, 'OutputManifestFile', _file_name) # /out
_Same(_manifest, 'RegistrarScriptFile', _file_name) # /rgs
_Same(_manifest, 'ReplacementsFile', _file_name) # /replacements
_Same(_manifest, 'SuppressStartupBanner', _boolean) # /nologo
_Same(_manifest, 'TypeLibraryFile', _file_name) # /tlb:
_Same(_manifest, 'UpdateFileHashes', _boolean) # /hashupdate
_Same(_manifest, 'UpdateFileHashesSearchPath', _file_name)
_Same(_manifest, 'VerboseOutput', _boolean) # /verbose
# Options that have moved location.
_MovedAndRenamed(_manifest, 'ManifestResourceFile',
'ManifestResourceCompile',
'ResourceOutputFileName',
_file_name)
_Moved(_manifest, 'EmbedManifest', '', _boolean)
# MSVS options not found in MSBuild.
_MSVSOnly(_manifest, 'DependencyInformationFile', _file_name)
_MSVSOnly(_manifest, 'UseFAT32Workaround', _boolean)
_MSVSOnly(_manifest, 'UseUnicodeResponseFiles', _boolean)
# MSBuild options not found in MSVS.
_MSBuildOnly(_manifest, 'EnableDPIAwareness', _boolean)
_MSBuildOnly(_manifest, 'GenerateCategoryTags', _boolean) # /category
_MSBuildOnly(_manifest, 'ManifestFromManagedAssembly',
_file_name) # /managedassemblyname
_MSBuildOnly(_manifest, 'OutputResourceManifests', _string) # /outputresource
_MSBuildOnly(_manifest, 'SuppressDependencyElement', _boolean) # /nodependency
_MSBuildOnly(_manifest, 'TrackerLogDirectory', _folder_name)
|
mit
|
[
3,
1898,
334,
67,
9,
6029,
4475,
3277,
14,
2900,
4481,
4644,
14,
199,
3,
3645,
402,
642,
1350,
1233,
365,
10413,
701,
282,
6289,
13,
2487,
4190,
626,
883,
506,
199,
3,
1911,
315,
314,
5113,
570,
14,
199,
199,
624,
3034,
370,
4107,
436,
3957,
2202,
402,
314,
15332,
1900,
7249,
14,
199,
199,
2765,
570,
3509,
1233,
370,
4107,
436,
3957,
2202,
402,
314,
15332,
199,
1506,
7249,
14,
221,
710,
805,
7905,
28361,
5268,
1062,
12134,
14206,
5268,
1062,
199,
460,
12134,
10733,
5268,
342,
787,
314,
2397,
4501,
14,
199,
199,
2765,
570,
1990,
2737,
701,
20234,
314,
11336,
2737,
701,
14702,
13225,
9079,
199,
460,
14702,
13225,
7129,
367,
1006,
2808,
2202,
4012,
314,
922,
3217,
14,
199,
1918,
21374,
32536,
4898,
2597,
8652,
14,
221,
9322,
787,
13609,
1911,
315,
314,
199,
10733,
3907,
2082,
12,
325,
14,
71,
14,
286,
3427,
9184,
16920,
334,
88,
1184,
2862,
10733,
199,
624,
199,
199,
646,
984,
199,
646,
295,
199,
199,
3,
3757,
10150,
402,
2202,
14370,
14,
710,
790,
365,
314,
4744,
536,
12,
314,
574,
365,
199,
3,
282,
2600,
4412,
4260,
1561,
370,
6411,
3423,
14,
199,
63,
8338,
63,
11346,
275,
1052,
199,
63,
14087,
63,
11346,
275,
1052,
421,
199,
3,
437,
2600,
402,
2202,
23172,
14,
710,
790,
365,
314,
4744,
536,
12,
314,
574,
365,
199,
3,
282,
2600,
4412,
4260,
1561,
370,
8603,
3423,
14,
199,
63,
8338,
63,
475,
63,
14087,
63,
17911,
275,
1052,
421,
199,
3,
15650,
536,
4412,
687,
13828,
370,
21374,
14,
199,
63,
14087,
63,
354,
63,
1618,
63,
3557,
275,
1052,
421,
199,
533,
485,
5157,
8,
785,
304,
523,
408,
18089,
282,
4744,
1202,
701,
13828,
503,
21374,
14,
819,
9382,
26,
489,
13795,
63,
354,
26,
710,
536,
402,
314,
4744,
315,
13828,
14,
489,
14835,
63,
354,
26,
710,
536,
402,
314,
4744,
315,
21374,
14,
523,
408,
819,
347,
636,
826,
721,
277,
12,
13795,
63,
354,
12,
14835,
63,
354,
304,
272,
291,
14,
8338,
63,
354,
275,
13795,
63,
354,
272,
291,
14,
14087,
63,
354,
275,
14835,
63,
354,
421,
199,
318,
485,
1123,
5157,
8,
3557,
304,
523,
408,
14995,
282,
4744,
370,
314,
11648,
11196,
1202,
370,
2112,
2202,
14,
819,
961,
1454,
7890,
314,
4744,
14,
221,
7048,
4260,
2597,
4839,
370,
506,
3483,
14,
819,
3033,
26,
272,
4744,
26,
710,
485,
5157,
909,
370,
506,
3483,
14,
523,
408,
523,
485,
8338,
63,
11346,
59,
3557,
14,
8338,
63,
354,
61,
275,
1052,
523,
485,
14087,
63,
11346,
59,
3557,
14,
14087,
63,
354,
61,
275,
1052,
523,
485,
8338,
63,
475,
63,
14087,
63,
17911,
59,
3557,
14,
8338,
63,
354,
61,
275,
1052,
523,
485,
14087,
63,
354,
63,
1618,
63,
3557,
59,
3557,
14,
8338,
63,
354,
61,
275,
4744,
14,
14087,
63,
354,
421,
199,
318,
485,
26772,
5157,
5268,
8,
14087,
63,
1751,
12,
4744,
304,
523,
408,
3407,
376,
21374,
4744,
2600,
14,
221,
10560,
652,
340,
4346,
1041,
523,
372,
14835,
63,
1751,
14,
5486,
8,
3557,
14,
14087,
63,
354,
12,
5009,
421,
199,
533,
485,
804,
8,
785,
304,
523,
408,
804,
402,
2202,
334,
1563,
1021,
10477,
819,
347,
12134,
14206,
8,
277,
12,
574,
304,
272,
408,
21168,
626,
314,
574,
365,
18393,
367,
13828,
14,
339,
3033,
26,
489,
574,
26,
314,
574,
370,
1104,
367,
642,
730,
14,
339,
6218,
26,
489,
1722,
340,
574,
365,
440,
1686,
367,
13828,
14,
272,
408,
819,
347,
12134,
10733,
8,
277,
12,
574,
304,
272,
408,
21168,
626,
314,
574,
365,
18393,
367,
21374,
14,
339,
3033,
26,
489,
574,
26,
314,
574,
370,
1104,
367,
642,
730,
14,
339,
6218,
26,
489,
1722,
340,
574,
365,
440,
1686,
367,
21374,
14,
272,
408,
819,
347,
7905,
28361,
8,
277,
12,
574,
304,
272,
408,
3407,
314,
21374,
7353,
402,
314,
13828,
574,
1627,
14,
339,
3033,
26,
489,
574,
26,
314,
13828,
574,
370,
3957,
14,
339,
1803,
26,
489,
314,
21374,
7353,
14,
339,
6218,
26,
489,
1722,
340,
574,
365,
440,
1686,
14,
272,
408,
272,
372,
574,
421,
199,
533,
485,
1558,
1547,
804,
304,
523,
408,
33,
4260,
626,
1159,
2951,
282,
1059,
1041,
819,
347,
12134,
14206,
8,
277,
12,
574,
304,
272,
340,
440,
1228,
8,
585,
12,
7116,
304,
489,
746,
1722,
360,
2062,
1059,
27,
4788,
450,
82,
7,
450,
574,
9,
819,
347,
12134,
10733,
8,
277,
12,
574,
304,
272,
340,
440,
1228,
8,
585,
12,
7116,
304,
489,
746,
1722,
360,
2062,
1059,
27,
4788,
450,
82,
7,
450,
574,
9,
819,
347,
7905,
28361,
8,
277,
12,
574,
304,
272,
327,
7905,
314,
16954,
272,
372,
7905,
9454,
25402,
28361,
8,
585,
9,
421,
199,
533,
485,
32216,
1547,
804,
304,
523,
408,
33,
2202,
626,
1159,
282,
769,
402,
3326,
1041,
819,
347,
12134,
14206,
8,
277,
12,
574,
304,
272,
340,
440,
1228,
8,
585,
12,
7116,
9,
436,
440,
1228,
8,
585,
12,
769,
304,
489,
746,
1722,
360,
2062,
1059,
769,
27,
4788,
450,
82,
7,
450,
574,
9,
819,
347,
12134,
10733,
8,
277,
12,
574,
304,
272,
340,
440,
1228,
8,
585,
12,
7116,
9,
436,
440,
1228,
8,
585,
12,
769,
304,
489,
746,
1722,
360,
2062,
1059,
769,
27,
4788,
450,
82,
7,
450,
574,
9,
819,
347,
7905,
28361,
8,
277,
12,
574,
304,
272,
327,
7905,
314,
16954,
272,
340,
1228,
8,
585,
12,
769,
304,
489,
372,
359,
7306,
9454,
25402,
28361,
8,
73,
9,
367,
284,
315,
574,
61,
272,
587,
26,
489,
372,
7905,
9454,
25402,
28361,
8,
585,
9,
421,
199,
533,
485,
4082,
1547,
804,
304,
523,
408,
4082,
2202,
12,
883,
1172,
314,
1338,
283,
3910,
7,
503,
283,
2052,
23690,
819,
347,
485,
12584,
8,
277,
12,
574,
304,
272,
340,
574,
1137,
283,
2052,
7,
436,
574,
1137,
283,
3910,
356,
489,
746,
1722,
360,
2062,
2155,
27,
4788,
450,
82,
7,
450,
574,
9,
819,
347,
12134,
14206,
8,
277,
12,
574,
304,
272,
291,
423,
12584,
8
] |
[
1898,
334,
67,
9,
6029,
4475,
3277,
14,
2900,
4481,
4644,
14,
199,
3,
3645,
402,
642,
1350,
1233,
365,
10413,
701,
282,
6289,
13,
2487,
4190,
626,
883,
506,
199,
3,
1911,
315,
314,
5113,
570,
14,
199,
199,
624,
3034,
370,
4107,
436,
3957,
2202,
402,
314,
15332,
1900,
7249,
14,
199,
199,
2765,
570,
3509,
1233,
370,
4107,
436,
3957,
2202,
402,
314,
15332,
199,
1506,
7249,
14,
221,
710,
805,
7905,
28361,
5268,
1062,
12134,
14206,
5268,
1062,
199,
460,
12134,
10733,
5268,
342,
787,
314,
2397,
4501,
14,
199,
199,
2765,
570,
1990,
2737,
701,
20234,
314,
11336,
2737,
701,
14702,
13225,
9079,
199,
460,
14702,
13225,
7129,
367,
1006,
2808,
2202,
4012,
314,
922,
3217,
14,
199,
1918,
21374,
32536,
4898,
2597,
8652,
14,
221,
9322,
787,
13609,
1911,
315,
314,
199,
10733,
3907,
2082,
12,
325,
14,
71,
14,
286,
3427,
9184,
16920,
334,
88,
1184,
2862,
10733,
199,
624,
199,
199,
646,
984,
199,
646,
295,
199,
199,
3,
3757,
10150,
402,
2202,
14370,
14,
710,
790,
365,
314,
4744,
536,
12,
314,
574,
365,
199,
3,
282,
2600,
4412,
4260,
1561,
370,
6411,
3423,
14,
199,
63,
8338,
63,
11346,
275,
1052,
199,
63,
14087,
63,
11346,
275,
1052,
421,
199,
3,
437,
2600,
402,
2202,
23172,
14,
710,
790,
365,
314,
4744,
536,
12,
314,
574,
365,
199,
3,
282,
2600,
4412,
4260,
1561,
370,
8603,
3423,
14,
199,
63,
8338,
63,
475,
63,
14087,
63,
17911,
275,
1052,
421,
199,
3,
15650,
536,
4412,
687,
13828,
370,
21374,
14,
199,
63,
14087,
63,
354,
63,
1618,
63,
3557,
275,
1052,
421,
199,
533,
485,
5157,
8,
785,
304,
523,
408,
18089,
282,
4744,
1202,
701,
13828,
503,
21374,
14,
819,
9382,
26,
489,
13795,
63,
354,
26,
710,
536,
402,
314,
4744,
315,
13828,
14,
489,
14835,
63,
354,
26,
710,
536,
402,
314,
4744,
315,
21374,
14,
523,
408,
819,
347,
636,
826,
721,
277,
12,
13795,
63,
354,
12,
14835,
63,
354,
304,
272,
291,
14,
8338,
63,
354,
275,
13795,
63,
354,
272,
291,
14,
14087,
63,
354,
275,
14835,
63,
354,
421,
199,
318,
485,
1123,
5157,
8,
3557,
304,
523,
408,
14995,
282,
4744,
370,
314,
11648,
11196,
1202,
370,
2112,
2202,
14,
819,
961,
1454,
7890,
314,
4744,
14,
221,
7048,
4260,
2597,
4839,
370,
506,
3483,
14,
819,
3033,
26,
272,
4744,
26,
710,
485,
5157,
909,
370,
506,
3483,
14,
523,
408,
523,
485,
8338,
63,
11346,
59,
3557,
14,
8338,
63,
354,
61,
275,
1052,
523,
485,
14087,
63,
11346,
59,
3557,
14,
14087,
63,
354,
61,
275,
1052,
523,
485,
8338,
63,
475,
63,
14087,
63,
17911,
59,
3557,
14,
8338,
63,
354,
61,
275,
1052,
523,
485,
14087,
63,
354,
63,
1618,
63,
3557,
59,
3557,
14,
8338,
63,
354,
61,
275,
4744,
14,
14087,
63,
354,
421,
199,
318,
485,
26772,
5157,
5268,
8,
14087,
63,
1751,
12,
4744,
304,
523,
408,
3407,
376,
21374,
4744,
2600,
14,
221,
10560,
652,
340,
4346,
1041,
523,
372,
14835,
63,
1751,
14,
5486,
8,
3557,
14,
14087,
63,
354,
12,
5009,
421,
199,
533,
485,
804,
8,
785,
304,
523,
408,
804,
402,
2202,
334,
1563,
1021,
10477,
819,
347,
12134,
14206,
8,
277,
12,
574,
304,
272,
408,
21168,
626,
314,
574,
365,
18393,
367,
13828,
14,
339,
3033,
26,
489,
574,
26,
314,
574,
370,
1104,
367,
642,
730,
14,
339,
6218,
26,
489,
1722,
340,
574,
365,
440,
1686,
367,
13828,
14,
272,
408,
819,
347,
12134,
10733,
8,
277,
12,
574,
304,
272,
408,
21168,
626,
314,
574,
365,
18393,
367,
21374,
14,
339,
3033,
26,
489,
574,
26,
314,
574,
370,
1104,
367,
642,
730,
14,
339,
6218,
26,
489,
1722,
340,
574,
365,
440,
1686,
367,
21374,
14,
272,
408,
819,
347,
7905,
28361,
8,
277,
12,
574,
304,
272,
408,
3407,
314,
21374,
7353,
402,
314,
13828,
574,
1627,
14,
339,
3033,
26,
489,
574,
26,
314,
13828,
574,
370,
3957,
14,
339,
1803,
26,
489,
314,
21374,
7353,
14,
339,
6218,
26,
489,
1722,
340,
574,
365,
440,
1686,
14,
272,
408,
272,
372,
574,
421,
199,
533,
485,
1558,
1547,
804,
304,
523,
408,
33,
4260,
626,
1159,
2951,
282,
1059,
1041,
819,
347,
12134,
14206,
8,
277,
12,
574,
304,
272,
340,
440,
1228,
8,
585,
12,
7116,
304,
489,
746,
1722,
360,
2062,
1059,
27,
4788,
450,
82,
7,
450,
574,
9,
819,
347,
12134,
10733,
8,
277,
12,
574,
304,
272,
340,
440,
1228,
8,
585,
12,
7116,
304,
489,
746,
1722,
360,
2062,
1059,
27,
4788,
450,
82,
7,
450,
574,
9,
819,
347,
7905,
28361,
8,
277,
12,
574,
304,
272,
327,
7905,
314,
16954,
272,
372,
7905,
9454,
25402,
28361,
8,
585,
9,
421,
199,
533,
485,
32216,
1547,
804,
304,
523,
408,
33,
2202,
626,
1159,
282,
769,
402,
3326,
1041,
819,
347,
12134,
14206,
8,
277,
12,
574,
304,
272,
340,
440,
1228,
8,
585,
12,
7116,
9,
436,
440,
1228,
8,
585,
12,
769,
304,
489,
746,
1722,
360,
2062,
1059,
769,
27,
4788,
450,
82,
7,
450,
574,
9,
819,
347,
12134,
10733,
8,
277,
12,
574,
304,
272,
340,
440,
1228,
8,
585,
12,
7116,
9,
436,
440,
1228,
8,
585,
12,
769,
304,
489,
746,
1722,
360,
2062,
1059,
769,
27,
4788,
450,
82,
7,
450,
574,
9,
819,
347,
7905,
28361,
8,
277,
12,
574,
304,
272,
327,
7905,
314,
16954,
272,
340,
1228,
8,
585,
12,
769,
304,
489,
372,
359,
7306,
9454,
25402,
28361,
8,
73,
9,
367,
284,
315,
574,
61,
272,
587,
26,
489,
372,
7905,
9454,
25402,
28361,
8,
585,
9,
421,
199,
533,
485,
4082,
1547,
804,
304,
523,
408,
4082,
2202,
12,
883,
1172,
314,
1338,
283,
3910,
7,
503,
283,
2052,
23690,
819,
347,
485,
12584,
8,
277,
12,
574,
304,
272,
340,
574,
1137,
283,
2052,
7,
436,
574,
1137,
283,
3910,
356,
489,
746,
1722,
360,
2062,
2155,
27,
4788,
450,
82,
7,
450,
574,
9,
819,
347,
12134,
14206,
8,
277,
12,
574,
304,
272,
291,
423,
12584,
8,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
dios-game/dios
|
src/oslibs/google_breakpad/google-breakpad-read-only/src/tools/gyp/test/intermediate_dir/gyptest-intermediate-dir.py
|
243
|
1398
|
#!/usr/bin/env python
# Copyright (c) 2012 Google Inc. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""
Verifies that targets have independent INTERMEDIATE_DIRs.
"""
import TestGyp
test = TestGyp.TestGyp()
test.run_gyp('test.gyp', chdir='src')
test.build('test.gyp', 'target1', chdir='src')
# Check stuff exists.
intermediate_file1 = test.read('src/outfile.txt')
test.must_contain(intermediate_file1, 'target1')
shared_intermediate_file1 = test.read('src/shared_outfile.txt')
test.must_contain(shared_intermediate_file1, 'shared_target1')
test.run_gyp('test2.gyp', chdir='src')
# Force the shared intermediate to be rebuilt.
test.sleep()
test.touch('src/shared_infile.txt')
test.build('test2.gyp', 'target2', chdir='src')
# Check INTERMEDIATE_DIR file didn't get overwritten but SHARED_INTERMEDIATE_DIR
# file did.
intermediate_file2 = test.read('src/outfile.txt')
test.must_contain(intermediate_file1, 'target1')
test.must_contain(intermediate_file2, 'target2')
shared_intermediate_file2 = test.read('src/shared_outfile.txt')
if shared_intermediate_file1 != shared_intermediate_file2:
test.fail_test(shared_intermediate_file1 + ' != ' + shared_intermediate_file2)
test.must_contain(shared_intermediate_file1, 'shared_target2')
test.must_contain(shared_intermediate_file2, 'shared_target2')
test.pass_test()
|
mit
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
199,
3,
1898,
334,
67,
9,
6029,
4475,
3277,
14,
2900,
4481,
4644,
14,
199,
3,
3645,
402,
642,
1350,
1233,
365,
10413,
701,
282,
6289,
13,
2487,
4190,
626,
883,
506,
199,
3,
1911,
315,
314,
5113,
570,
14,
199,
199,
624,
199,
21168,
626,
4545,
1172,
12717,
8729,
19464,
63,
3022,
83,
14,
199,
624,
199,
199,
646,
25688,
199,
199,
396,
275,
25688,
14,
774,
13899,
342,
199,
199,
396,
14,
1065,
63,
6179,
360,
396,
14,
6179,
297,
13097,
534,
2164,
358,
199,
396,
14,
1506,
360,
396,
14,
6179,
297,
283,
1375,
17,
297,
13097,
534,
2164,
358,
199,
3,
2670,
8292,
3495,
14,
199,
15940,
63,
493,
17,
275,
511,
14,
739,
360,
2164,
15,
4984,
14,
2424,
358,
199,
396,
14,
7790,
63,
7747,
8,
15940,
63,
493,
17,
12,
283,
1375,
17,
358,
199,
199,
5555,
63,
15940,
63,
493,
17,
275,
511,
14,
739,
360,
2164,
15,
5555,
63,
4984,
14,
2424,
358,
199,
396,
14,
7790,
63,
7747,
8,
5555,
63,
15940,
63,
493,
17,
12,
283,
5555,
63,
1375,
17,
358,
199,
199,
396,
14,
1065,
63,
6179,
360,
396,
18,
14,
6179,
297,
13097,
534,
2164,
358,
199,
3,
18771,
314,
5709,
13197,
370,
506,
295,
11730,
14,
199,
396,
14,
4532,
342,
199,
396,
14,
12376,
360,
2164,
15,
5555,
63,
13880,
14,
2424,
358,
199,
396,
14,
1506,
360,
396,
18,
14,
6179,
297,
283,
1375,
18,
297,
13097,
534,
2164,
358,
199,
3,
2670,
8729,
19464,
63,
3022,
570,
9980,
1133,
664,
20200,
1325,
4410,
689,
1149,
63,
23227,
63,
3022,
199,
3,
570,
8103,
14,
199,
15940,
63,
493,
18,
275,
511,
14,
739,
360,
2164,
15,
4984,
14,
2424,
358,
199,
396,
14,
7790,
63,
7747,
8,
15940,
63,
493,
17,
12,
283,
1375,
17,
358,
199,
396,
14,
7790,
63,
7747,
8,
15940,
63,
493,
18,
12,
283,
1375,
18,
358,
199,
199,
5555,
63,
15940,
63,
493,
18,
275,
511,
14,
739,
360,
2164,
15,
5555,
63,
4984,
14,
2424,
358,
199,
692,
5709,
63,
15940,
63,
493,
17,
1137,
5709,
63,
15940,
63,
493,
18,
26,
523,
511,
14,
1633,
63,
396,
8,
5555,
63,
15940,
63,
493,
17,
435,
283,
1137,
283,
435,
5709,
63,
15940,
63,
493,
18,
9,
199,
199,
396,
14,
7790,
63,
7747,
8,
5555,
63,
15940,
63,
493,
17,
12,
283,
5555,
63,
1375,
18,
358,
199,
396,
14,
7790,
63,
7747,
8,
5555,
63,
15940,
63,
493,
18,
12,
283,
5555,
63,
1375,
18,
358,
199,
199,
396,
14,
1529,
63,
396,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
199,
3,
1898,
334,
67,
9,
6029,
4475,
3277,
14,
2900,
4481,
4644,
14,
199,
3,
3645,
402,
642,
1350,
1233,
365,
10413,
701,
282,
6289,
13,
2487,
4190,
626,
883,
506,
199,
3,
1911,
315,
314,
5113,
570,
14,
199,
199,
624,
199,
21168,
626,
4545,
1172,
12717,
8729,
19464,
63,
3022,
83,
14,
199,
624,
199,
199,
646,
25688,
199,
199,
396,
275,
25688,
14,
774,
13899,
342,
199,
199,
396,
14,
1065,
63,
6179,
360,
396,
14,
6179,
297,
13097,
534,
2164,
358,
199,
396,
14,
1506,
360,
396,
14,
6179,
297,
283,
1375,
17,
297,
13097,
534,
2164,
358,
199,
3,
2670,
8292,
3495,
14,
199,
15940,
63,
493,
17,
275,
511,
14,
739,
360,
2164,
15,
4984,
14,
2424,
358,
199,
396,
14,
7790,
63,
7747,
8,
15940,
63,
493,
17,
12,
283,
1375,
17,
358,
199,
199,
5555,
63,
15940,
63,
493,
17,
275,
511,
14,
739,
360,
2164,
15,
5555,
63,
4984,
14,
2424,
358,
199,
396,
14,
7790,
63,
7747,
8,
5555,
63,
15940,
63,
493,
17,
12,
283,
5555,
63,
1375,
17,
358,
199,
199,
396,
14,
1065,
63,
6179,
360,
396,
18,
14,
6179,
297,
13097,
534,
2164,
358,
199,
3,
18771,
314,
5709,
13197,
370,
506,
295,
11730,
14,
199,
396,
14,
4532,
342,
199,
396,
14,
12376,
360,
2164,
15,
5555,
63,
13880,
14,
2424,
358,
199,
396,
14,
1506,
360,
396,
18,
14,
6179,
297,
283,
1375,
18,
297,
13097,
534,
2164,
358,
199,
3,
2670,
8729,
19464,
63,
3022,
570,
9980,
1133,
664,
20200,
1325,
4410,
689,
1149,
63,
23227,
63,
3022,
199,
3,
570,
8103,
14,
199,
15940,
63,
493,
18,
275,
511,
14,
739,
360,
2164,
15,
4984,
14,
2424,
358,
199,
396,
14,
7790,
63,
7747,
8,
15940,
63,
493,
17,
12,
283,
1375,
17,
358,
199,
396,
14,
7790,
63,
7747,
8,
15940,
63,
493,
18,
12,
283,
1375,
18,
358,
199,
199,
5555,
63,
15940,
63,
493,
18,
275,
511,
14,
739,
360,
2164,
15,
5555,
63,
4984,
14,
2424,
358,
199,
692,
5709,
63,
15940,
63,
493,
17,
1137,
5709,
63,
15940,
63,
493,
18,
26,
523,
511,
14,
1633,
63,
396,
8,
5555,
63,
15940,
63,
493,
17,
435,
283,
1137,
283,
435,
5709,
63,
15940,
63,
493,
18,
9,
199,
199,
396,
14,
7790,
63,
7747,
8,
5555,
63,
15940,
63,
493,
17,
12,
283,
5555,
63,
1375,
18,
358,
199,
396,
14,
7790,
63,
7747,
8,
5555,
63,
15940,
63,
493,
18,
12,
283,
5555,
63,
1375,
18,
358,
199,
199,
396,
14,
1529,
63,
396,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
wenderen/servo
|
components/script/dom/bindings/codegen/parser/tests/test_distinguishability.py
|
50
|
12785
|
def firstArgType(method):
return method.signatures()[0][1][0].type
def WebIDLTest(parser, harness):
parser.parse("""
dictionary Dict {
};
callback interface Foo {
};
interface Bar {
// Bit of a pain to get things that have dictionary types
void passDict(optional Dict arg);
void passFoo(Foo arg);
void passNullableUnion((object? or DOMString) arg);
void passNullable(Foo? arg);
};
""")
results = parser.finish()
iface = results[2]
harness.ok(iface.isInterface(), "Should have interface")
dictMethod = iface.members[0]
ifaceMethod = iface.members[1]
nullableUnionMethod = iface.members[2]
nullableIfaceMethod = iface.members[3]
dictType = firstArgType(dictMethod)
ifaceType = firstArgType(ifaceMethod)
harness.ok(dictType.isDictionary(), "Should have dictionary type");
harness.ok(ifaceType.isInterface(), "Should have interface type");
harness.ok(ifaceType.isCallbackInterface(), "Should have callback interface type");
harness.ok(not dictType.isDistinguishableFrom(ifaceType),
"Dictionary not distinguishable from callback interface")
harness.ok(not ifaceType.isDistinguishableFrom(dictType),
"Callback interface not distinguishable from dictionary")
nullableUnionType = firstArgType(nullableUnionMethod)
nullableIfaceType = firstArgType(nullableIfaceMethod)
harness.ok(nullableUnionType.isUnion(), "Should have union type");
harness.ok(nullableIfaceType.isInterface(), "Should have interface type");
harness.ok(nullableIfaceType.nullable(), "Should have nullable type");
harness.ok(not nullableUnionType.isDistinguishableFrom(nullableIfaceType),
"Nullable type not distinguishable from union with nullable "
"member type")
harness.ok(not nullableIfaceType.isDistinguishableFrom(nullableUnionType),
"Union with nullable member type not distinguishable from "
"nullable type")
parser = parser.reset()
parser.parse("""
interface TestIface {
void passKid(Kid arg);
void passParent(Parent arg);
void passGrandparent(Grandparent arg);
void passImplemented(Implemented arg);
void passImplementedParent(ImplementedParent arg);
void passUnrelated1(Unrelated1 arg);
void passUnrelated2(Unrelated2 arg);
void passArrayBuffer(ArrayBuffer arg);
void passArrayBuffer(ArrayBufferView arg);
};
interface Kid : Parent {};
interface Parent : Grandparent {};
interface Grandparent {};
interface Implemented : ImplementedParent {};
Parent implements Implemented;
interface ImplementedParent {};
interface Unrelated1 {};
interface Unrelated2 {};
""")
results = parser.finish()
iface = results[0]
harness.ok(iface.isInterface(), "Should have interface")
argTypes = [firstArgType(method) for method in iface.members]
unrelatedTypes = [firstArgType(method) for method in iface.members[-3:]]
for type1 in argTypes:
for type2 in argTypes:
distinguishable = (type1 is not type2 and
(type1 in unrelatedTypes or
type2 in unrelatedTypes))
harness.check(type1.isDistinguishableFrom(type2),
distinguishable,
"Type %s should %sbe distinguishable from type %s" %
(type1, "" if distinguishable else "not ", type2))
harness.check(type2.isDistinguishableFrom(type1),
distinguishable,
"Type %s should %sbe distinguishable from type %s" %
(type2, "" if distinguishable else "not ", type1))
parser = parser.reset()
parser.parse("""
interface Dummy {};
interface TestIface {
void method(long arg1, TestIface arg2);
void method(long arg1, long arg2);
void method(long arg1, Dummy arg2);
void method(DOMString arg1, DOMString arg2, DOMString arg3);
};
""")
results = parser.finish()
harness.check(len(results[1].members), 1,
"Should look like we have one method")
harness.check(len(results[1].members[0].signatures()), 4,
"Should have four signatures")
parser = parser.reset()
threw = False
try:
parser.parse("""
interface Dummy {};
interface TestIface {
void method(long arg1, TestIface arg2);
void method(long arg1, long arg2);
void method(any arg1, Dummy arg2);
void method(DOMString arg1, DOMString arg2, DOMString arg3);
};
""")
results = parser.finish()
except:
threw = True
harness.ok(threw,
"Should throw when args before the distinguishing arg are not "
"all the same type")
parser = parser.reset()
threw = False
try:
parser.parse("""
interface Dummy {};
interface TestIface {
void method(long arg1, TestIface arg2);
void method(long arg1, long arg2);
void method(any arg1, DOMString arg2);
void method(DOMString arg1, DOMString arg2, DOMString arg3);
};
""")
results = parser.finish()
except:
threw = True
harness.ok(threw, "Should throw when there is no distinguishing index")
# Now let's test our whole distinguishability table
argTypes = [ "long", "short", "long?", "short?", "boolean",
"boolean?", "DOMString", "ByteString", "Enum", "Enum2",
"Interface", "Interface?",
"AncestorInterface", "UnrelatedInterface",
"ImplementedInterface", "CallbackInterface",
"CallbackInterface?", "CallbackInterface2",
"object", "Callback", "Callback2", "optional Dict",
"optional Dict2", "sequence<long>", "sequence<short>",
"MozMap<object>", "MozMap<Dict>", "MozMap<long>",
"Date", "Date?", "any",
"Promise<any>", "Promise<any>?",
"USVString", "ArrayBuffer", "ArrayBufferView", "SharedArrayBuffer",
"Uint8Array", "Uint16Array" ]
# When we can parse Date and RegExp, we need to add them here.
# Try to categorize things a bit to keep list lengths down
def allBut(list1, list2):
return [a for a in list1 if a not in list2 and
(a != "any" and a != "Promise<any>" and a != "Promise<any>?")]
numerics = [ "long", "short", "long?", "short?" ]
booleans = [ "boolean", "boolean?" ]
primitives = numerics + booleans
nonNumerics = allBut(argTypes, numerics)
nonBooleans = allBut(argTypes, booleans)
strings = [ "DOMString", "ByteString", "Enum", "Enum2", "USVString" ]
nonStrings = allBut(argTypes, strings)
nonObjects = primitives + strings
objects = allBut(argTypes, nonObjects )
bufferSourceTypes = ["ArrayBuffer", "ArrayBufferView", "Uint8Array", "Uint16Array"]
sharedBufferSourceTypes = ["SharedArrayBuffer"]
interfaces = [ "Interface", "Interface?", "AncestorInterface",
"UnrelatedInterface", "ImplementedInterface" ] + bufferSourceTypes + sharedBufferSourceTypes
nullables = ["long?", "short?", "boolean?", "Interface?",
"CallbackInterface?", "optional Dict", "optional Dict2",
"Date?", "any", "Promise<any>?"]
dates = [ "Date", "Date?" ]
sequences = [ "sequence<long>", "sequence<short>" ]
nonUserObjects = nonObjects + interfaces + dates + sequences
otherObjects = allBut(argTypes, nonUserObjects + ["object"])
notRelatedInterfaces = (nonObjects + ["UnrelatedInterface"] +
otherObjects + dates + sequences + bufferSourceTypes + sharedBufferSourceTypes)
mozMaps = [ "MozMap<object>", "MozMap<Dict>", "MozMap<long>" ]
# Build a representation of the distinguishability table as a dict
# of dicts, holding True values where needed, holes elsewhere.
data = dict();
for type in argTypes:
data[type] = dict()
def setDistinguishable(type, types):
for other in types:
data[type][other] = True
setDistinguishable("long", nonNumerics)
setDistinguishable("short", nonNumerics)
setDistinguishable("long?", allBut(nonNumerics, nullables))
setDistinguishable("short?", allBut(nonNumerics, nullables))
setDistinguishable("boolean", nonBooleans)
setDistinguishable("boolean?", allBut(nonBooleans, nullables))
setDistinguishable("DOMString", nonStrings)
setDistinguishable("ByteString", nonStrings)
setDistinguishable("USVString", nonStrings)
setDistinguishable("Enum", nonStrings)
setDistinguishable("Enum2", nonStrings)
setDistinguishable("Interface", notRelatedInterfaces)
setDistinguishable("Interface?", allBut(notRelatedInterfaces, nullables))
setDistinguishable("AncestorInterface", notRelatedInterfaces)
setDistinguishable("UnrelatedInterface",
allBut(argTypes, ["object", "UnrelatedInterface"]))
setDistinguishable("ImplementedInterface", notRelatedInterfaces)
setDistinguishable("CallbackInterface", nonUserObjects)
setDistinguishable("CallbackInterface?", allBut(nonUserObjects, nullables))
setDistinguishable("CallbackInterface2", nonUserObjects)
setDistinguishable("object", nonObjects)
setDistinguishable("Callback", nonUserObjects)
setDistinguishable("Callback2", nonUserObjects)
setDistinguishable("optional Dict", allBut(nonUserObjects, nullables))
setDistinguishable("optional Dict2", allBut(nonUserObjects, nullables))
setDistinguishable("sequence<long>",
allBut(argTypes, sequences + ["object"]))
setDistinguishable("sequence<short>",
allBut(argTypes, sequences + ["object"]))
setDistinguishable("MozMap<object>", nonUserObjects)
setDistinguishable("MozMap<Dict>", nonUserObjects)
setDistinguishable("MozMap<long>", nonUserObjects)
setDistinguishable("Date", allBut(argTypes, dates + ["object"]))
setDistinguishable("Date?", allBut(argTypes, dates + nullables + ["object"]))
setDistinguishable("any", [])
setDistinguishable("Promise<any>", [])
setDistinguishable("Promise<any>?", [])
setDistinguishable("ArrayBuffer", allBut(argTypes, ["ArrayBuffer", "object"]))
setDistinguishable("ArrayBufferView", allBut(argTypes, ["ArrayBufferView", "Uint8Array", "Uint16Array", "object"]))
setDistinguishable("Uint8Array", allBut(argTypes, ["ArrayBufferView", "Uint8Array", "object"]))
setDistinguishable("Uint16Array", allBut(argTypes, ["ArrayBufferView", "Uint16Array", "object"]))
setDistinguishable("SharedArrayBuffer", allBut(argTypes, ["SharedArrayBuffer", "object"]))
def areDistinguishable(type1, type2):
return data[type1].get(type2, False)
def checkDistinguishability(parser, type1, type2):
idlTemplate = """
enum Enum { "a", "b" };
enum Enum2 { "c", "d" };
interface Interface : AncestorInterface {};
interface AncestorInterface {};
interface UnrelatedInterface {};
interface ImplementedInterface {};
Interface implements ImplementedInterface;
callback interface CallbackInterface {};
callback interface CallbackInterface2 {};
callback Callback = any();
callback Callback2 = long(short arg);
dictionary Dict {};
dictionary Dict2 {};
interface _Promise {};
interface TestInterface {%s
};
"""
methodTemplate = """
void myMethod(%s arg);"""
methods = (methodTemplate % type1) + (methodTemplate % type2)
idl = idlTemplate % methods
parser = parser.reset()
threw = False
try:
parser.parse(idl)
results = parser.finish()
except:
threw = True
if areDistinguishable(type1, type2):
harness.ok(not threw,
"Should not throw for '%s' and '%s' because they are distinguishable" % (type1, type2))
else:
harness.ok(threw,
"Should throw for '%s' and '%s' because they are not distinguishable" % (type1, type2))
# Enumerate over everything in both orders, since order matters in
# terms of our implementation of distinguishability checks
for type1 in argTypes:
for type2 in argTypes:
checkDistinguishability(parser, type1, type2)
|
mpl-2.0
|
[
318,
1642,
6373,
804,
8,
765,
304,
272,
372,
1083,
14,
15132,
3430,
16,
1527,
17,
1527,
16,
1055,
466,
199,
199,
318,
22817,
774,
8,
2087,
12,
20458,
304,
272,
1798,
14,
1122,
4852,
489,
2600,
7448,
469,
489,
16735,
489,
3233,
3217,
8024,
469,
489,
16735,
489,
3217,
12377,
469,
267,
5001,
10199,
402,
282,
691,
262,
370,
664,
7645,
626,
1172,
2600,
2943,
267,
2309,
986,
2141,
8,
4144,
7448,
1680,
2736,
267,
2309,
986,
5686,
8,
5686,
1680,
2736,
267,
2309,
986,
8849,
461,
15540,
1332,
785,
31,
503,
14316,
1558,
9,
1680,
2736,
267,
2309,
986,
8849,
461,
8,
5686,
31,
1680,
2736,
489,
16735,
272,
7857,
272,
2058,
275,
1798,
14,
8192,
342,
339,
13395,
275,
2058,
59,
18,
61,
272,
20458,
14,
745,
8,
11166,
14,
374,
4267,
1062,
298,
11408,
1172,
3217,
531,
272,
1211,
3767,
275,
13395,
14,
6334,
59,
16,
61,
272,
13395,
3767,
275,
13395,
14,
6334,
59,
17,
61,
272,
7854,
15540,
3767,
275,
13395,
14,
6334,
59,
18,
61,
272,
7854,
30606,
3767,
275,
13395,
14,
6334,
59,
19,
61,
339,
1211,
804,
275,
1642,
6373,
804,
8,
807,
3767,
9,
272,
13395,
804,
275,
1642,
6373,
804,
8,
11166,
3767,
9,
339,
20458,
14,
745,
8,
807,
804,
14,
374,
11728,
1062,
298,
11408,
1172,
2600,
730,
3547,
272,
20458,
14,
745,
8,
11166,
804,
14,
374,
4267,
1062,
298,
11408,
1172,
3217,
730,
3547,
272,
20458,
14,
745,
8,
11166,
804,
14,
374,
2806,
4267,
1062,
298,
11408,
1172,
3233,
3217,
730,
3547,
339,
20458,
14,
745,
8,
1397,
1211,
804,
14,
374,
12012,
17603,
461,
2532,
8,
11166,
804,
395,
2049,
298,
11728,
440,
22237,
461,
687,
3233,
3217,
531,
272,
20458,
14,
745,
8,
1397,
13395,
804,
14,
374,
12012,
17603,
461,
2532,
8,
807,
804,
395,
2049,
298,
2806,
3217,
440,
22237,
461,
687,
2600,
531,
339,
7854,
15540,
804,
275,
1642,
6373,
804,
8,
16375,
15540,
3767,
9,
272,
7854,
30606,
804,
275,
1642,
6373,
804,
8,
16375,
30606,
3767,
9,
339,
20458,
14,
745,
8,
16375,
15540,
804,
14,
374,
15540,
1062,
298,
11408,
1172,
13629,
730,
3547,
272,
20458,
14,
745,
8,
16375,
30606,
804,
14,
374,
4267,
1062,
298,
11408,
1172,
3217,
730,
3547,
272,
20458,
14,
745,
8,
16375,
30606,
804,
14,
16375,
1062,
298,
11408,
1172,
7854,
730,
3547,
339,
20458,
14,
745,
8,
1397,
7854,
15540,
804,
14,
374,
12012,
17603,
461,
2532,
8,
16375,
30606,
804,
395,
2049,
298,
8849,
461,
730,
440,
22237,
461,
687,
13629,
543,
7854,
298,
2049,
298,
1114,
730,
531,
272,
20458,
14,
745,
8,
1397,
7854,
30606,
804,
14,
374,
12012,
17603,
461,
2532,
8,
16375,
15540,
804,
395,
2049,
298,
15540,
543,
7854,
3653,
730,
440,
22237,
461,
687,
298,
2049,
298,
16375,
730,
531,
339,
1798,
275,
1798,
14,
3958,
342,
272,
1798,
14,
1122,
4852,
489,
3217,
1379,
30606,
469,
267,
2309,
986,
43,
344,
8,
43,
344,
1680,
2736,
267,
2309,
986,
6652,
8,
6652,
1680,
2736,
267,
2309,
986,
39,
3759,
1708,
8,
39,
3759,
1708,
1680,
2736,
267,
2309,
986,
3500,
8,
3500,
1680,
2736,
267,
2309,
986,
3500,
6652,
8,
3500,
6652,
1680,
2736,
267,
2309,
986,
1358,
2407,
17,
8,
1358,
2407,
17,
1680,
2736,
267,
2309,
986,
1358,
2407,
18,
8,
1358,
2407,
18,
1680,
2736,
267,
2309,
986,
3836,
3299,
8,
3836,
3299,
1680,
2736,
267,
2309,
986,
3836,
3299,
8,
3836,
3299,
2768,
1680,
2736,
489,
16735,
2541,
3217,
1804,
344,
520,
16396,
27978,
489,
3217,
16396,
520,
598,
3759,
1708,
27978,
489,
3217,
598,
3759,
1708,
27978,
489,
3217,
11794,
2509,
520,
11794,
2509,
6652,
27978,
489,
16396,
9031,
11794,
2509,
27,
489,
3217,
11794,
2509,
6652,
27978,
489,
3217,
1910,
2407,
17,
27978,
489,
3217,
1910,
2407,
18,
27978,
272,
7857,
272,
2058,
275,
1798,
14,
8192,
342,
339,
13395,
275,
2058,
59,
16,
61,
272,
20458,
14,
745,
8,
11166,
14,
374,
4267,
1062,
298,
11408,
1172,
3217,
531,
272,
1680,
4100,
275,
359,
2246,
6373,
804,
8,
765,
9,
367,
1083,
315,
13395,
14,
6334,
61,
272,
625,
2407,
4100,
275,
359,
2246,
6373,
804,
8,
765,
9,
367,
1083,
315,
13395,
14,
6334,
1988,
19,
21316,
339,
367,
730,
17,
315,
1680,
4100,
26,
267,
367,
730,
18,
315,
1680,
4100,
26,
288,
22237,
461,
275,
334,
466,
17,
365,
440,
730,
18,
436,
3044,
334,
466,
17,
315,
625,
2407,
4100,
503,
1816,
730,
18,
315,
625,
2407,
4100,
430,
953,
20458,
14,
1074,
8,
466,
17,
14,
374,
12012,
17603,
461,
2532,
8,
466,
18,
395,
2079,
22237,
461,
12,
2079,
298,
804,
450,
83,
1077,
450,
83,
1235,
22237,
461,
687,
730,
450,
83,
2,
450,
2079,
334,
466,
17,
12,
3087,
340,
22237,
461,
587,
298,
1397,
3872,
730,
18,
430,
288,
20458,
14,
1074,
8,
466,
18,
14,
374,
12012,
17603,
461,
2532,
8,
466,
17,
395,
2079,
22237,
461,
12,
2079,
298,
804,
450,
83,
1077,
450,
83,
1235,
22237,
461,
687,
730,
450,
83,
2,
450,
2079,
334,
466,
18,
12,
3087,
340,
22237,
461,
587,
298,
1397,
3872,
730,
17,
430,
339,
1798,
275,
1798,
14,
3958,
342,
272,
1798,
14,
1122,
4852,
489,
3217,
9762,
27978,
489,
3217,
1379,
30606,
469,
267,
2309,
1083,
8,
2809,
1680,
17,
12,
1379,
30606,
1680,
18,
2736,
267,
2309,
1083,
8,
2809,
1680,
17,
12,
1846,
1680,
18,
2736,
267,
2309,
1083,
8,
2809,
1680,
17,
12,
9762,
1680,
18,
2736,
267,
2309,
1083,
8,
10462,
1558,
1680,
17,
12,
14316,
1558,
1680,
18,
12,
14316,
1558,
1680,
19,
2736,
489,
16735,
272,
7857,
272,
2058,
275,
1798,
14,
8192,
342,
272,
20458,
14,
1074,
8,
552,
8,
2604,
59,
17,
1055,
6334,
395,
413,
12,
2116,
298,
11408,
3648,
2839,
781,
1172,
1373,
1083,
531,
272,
20458,
14,
1074,
8,
552,
8,
2604,
59,
17,
1055,
6334,
59,
16,
1055,
15132,
4000,
841,
12,
2116,
298,
11408,
1172,
11648,
17597,
531,
339,
1798,
275,
1798,
14,
3958,
342,
272,
28176,
275,
756,
272,
862,
26,
267,
1798,
14,
1122,
4852,
881,
3217,
9762,
27978,
881,
3217,
1379,
30606,
469
] |
[
1642,
6373,
804,
8,
765,
304,
272,
372,
1083,
14,
15132,
3430,
16,
1527,
17,
1527,
16,
1055,
466,
199,
199,
318,
22817,
774,
8,
2087,
12,
20458,
304,
272,
1798,
14,
1122,
4852,
489,
2600,
7448,
469,
489,
16735,
489,
3233,
3217,
8024,
469,
489,
16735,
489,
3217,
12377,
469,
267,
5001,
10199,
402,
282,
691,
262,
370,
664,
7645,
626,
1172,
2600,
2943,
267,
2309,
986,
2141,
8,
4144,
7448,
1680,
2736,
267,
2309,
986,
5686,
8,
5686,
1680,
2736,
267,
2309,
986,
8849,
461,
15540,
1332,
785,
31,
503,
14316,
1558,
9,
1680,
2736,
267,
2309,
986,
8849,
461,
8,
5686,
31,
1680,
2736,
489,
16735,
272,
7857,
272,
2058,
275,
1798,
14,
8192,
342,
339,
13395,
275,
2058,
59,
18,
61,
272,
20458,
14,
745,
8,
11166,
14,
374,
4267,
1062,
298,
11408,
1172,
3217,
531,
272,
1211,
3767,
275,
13395,
14,
6334,
59,
16,
61,
272,
13395,
3767,
275,
13395,
14,
6334,
59,
17,
61,
272,
7854,
15540,
3767,
275,
13395,
14,
6334,
59,
18,
61,
272,
7854,
30606,
3767,
275,
13395,
14,
6334,
59,
19,
61,
339,
1211,
804,
275,
1642,
6373,
804,
8,
807,
3767,
9,
272,
13395,
804,
275,
1642,
6373,
804,
8,
11166,
3767,
9,
339,
20458,
14,
745,
8,
807,
804,
14,
374,
11728,
1062,
298,
11408,
1172,
2600,
730,
3547,
272,
20458,
14,
745,
8,
11166,
804,
14,
374,
4267,
1062,
298,
11408,
1172,
3217,
730,
3547,
272,
20458,
14,
745,
8,
11166,
804,
14,
374,
2806,
4267,
1062,
298,
11408,
1172,
3233,
3217,
730,
3547,
339,
20458,
14,
745,
8,
1397,
1211,
804,
14,
374,
12012,
17603,
461,
2532,
8,
11166,
804,
395,
2049,
298,
11728,
440,
22237,
461,
687,
3233,
3217,
531,
272,
20458,
14,
745,
8,
1397,
13395,
804,
14,
374,
12012,
17603,
461,
2532,
8,
807,
804,
395,
2049,
298,
2806,
3217,
440,
22237,
461,
687,
2600,
531,
339,
7854,
15540,
804,
275,
1642,
6373,
804,
8,
16375,
15540,
3767,
9,
272,
7854,
30606,
804,
275,
1642,
6373,
804,
8,
16375,
30606,
3767,
9,
339,
20458,
14,
745,
8,
16375,
15540,
804,
14,
374,
15540,
1062,
298,
11408,
1172,
13629,
730,
3547,
272,
20458,
14,
745,
8,
16375,
30606,
804,
14,
374,
4267,
1062,
298,
11408,
1172,
3217,
730,
3547,
272,
20458,
14,
745,
8,
16375,
30606,
804,
14,
16375,
1062,
298,
11408,
1172,
7854,
730,
3547,
339,
20458,
14,
745,
8,
1397,
7854,
15540,
804,
14,
374,
12012,
17603,
461,
2532,
8,
16375,
30606,
804,
395,
2049,
298,
8849,
461,
730,
440,
22237,
461,
687,
13629,
543,
7854,
298,
2049,
298,
1114,
730,
531,
272,
20458,
14,
745,
8,
1397,
7854,
30606,
804,
14,
374,
12012,
17603,
461,
2532,
8,
16375,
15540,
804,
395,
2049,
298,
15540,
543,
7854,
3653,
730,
440,
22237,
461,
687,
298,
2049,
298,
16375,
730,
531,
339,
1798,
275,
1798,
14,
3958,
342,
272,
1798,
14,
1122,
4852,
489,
3217,
1379,
30606,
469,
267,
2309,
986,
43,
344,
8,
43,
344,
1680,
2736,
267,
2309,
986,
6652,
8,
6652,
1680,
2736,
267,
2309,
986,
39,
3759,
1708,
8,
39,
3759,
1708,
1680,
2736,
267,
2309,
986,
3500,
8,
3500,
1680,
2736,
267,
2309,
986,
3500,
6652,
8,
3500,
6652,
1680,
2736,
267,
2309,
986,
1358,
2407,
17,
8,
1358,
2407,
17,
1680,
2736,
267,
2309,
986,
1358,
2407,
18,
8,
1358,
2407,
18,
1680,
2736,
267,
2309,
986,
3836,
3299,
8,
3836,
3299,
1680,
2736,
267,
2309,
986,
3836,
3299,
8,
3836,
3299,
2768,
1680,
2736,
489,
16735,
2541,
3217,
1804,
344,
520,
16396,
27978,
489,
3217,
16396,
520,
598,
3759,
1708,
27978,
489,
3217,
598,
3759,
1708,
27978,
489,
3217,
11794,
2509,
520,
11794,
2509,
6652,
27978,
489,
16396,
9031,
11794,
2509,
27,
489,
3217,
11794,
2509,
6652,
27978,
489,
3217,
1910,
2407,
17,
27978,
489,
3217,
1910,
2407,
18,
27978,
272,
7857,
272,
2058,
275,
1798,
14,
8192,
342,
339,
13395,
275,
2058,
59,
16,
61,
272,
20458,
14,
745,
8,
11166,
14,
374,
4267,
1062,
298,
11408,
1172,
3217,
531,
272,
1680,
4100,
275,
359,
2246,
6373,
804,
8,
765,
9,
367,
1083,
315,
13395,
14,
6334,
61,
272,
625,
2407,
4100,
275,
359,
2246,
6373,
804,
8,
765,
9,
367,
1083,
315,
13395,
14,
6334,
1988,
19,
21316,
339,
367,
730,
17,
315,
1680,
4100,
26,
267,
367,
730,
18,
315,
1680,
4100,
26,
288,
22237,
461,
275,
334,
466,
17,
365,
440,
730,
18,
436,
3044,
334,
466,
17,
315,
625,
2407,
4100,
503,
1816,
730,
18,
315,
625,
2407,
4100,
430,
953,
20458,
14,
1074,
8,
466,
17,
14,
374,
12012,
17603,
461,
2532,
8,
466,
18,
395,
2079,
22237,
461,
12,
2079,
298,
804,
450,
83,
1077,
450,
83,
1235,
22237,
461,
687,
730,
450,
83,
2,
450,
2079,
334,
466,
17,
12,
3087,
340,
22237,
461,
587,
298,
1397,
3872,
730,
18,
430,
288,
20458,
14,
1074,
8,
466,
18,
14,
374,
12012,
17603,
461,
2532,
8,
466,
17,
395,
2079,
22237,
461,
12,
2079,
298,
804,
450,
83,
1077,
450,
83,
1235,
22237,
461,
687,
730,
450,
83,
2,
450,
2079,
334,
466,
18,
12,
3087,
340,
22237,
461,
587,
298,
1397,
3872,
730,
17,
430,
339,
1798,
275,
1798,
14,
3958,
342,
272,
1798,
14,
1122,
4852,
489,
3217,
9762,
27978,
489,
3217,
1379,
30606,
469,
267,
2309,
1083,
8,
2809,
1680,
17,
12,
1379,
30606,
1680,
18,
2736,
267,
2309,
1083,
8,
2809,
1680,
17,
12,
1846,
1680,
18,
2736,
267,
2309,
1083,
8,
2809,
1680,
17,
12,
9762,
1680,
18,
2736,
267,
2309,
1083,
8,
10462,
1558,
1680,
17,
12,
14316,
1558,
1680,
18,
12,
14316,
1558,
1680,
19,
2736,
489,
16735,
272,
7857,
272,
2058,
275,
1798,
14,
8192,
342,
272,
20458,
14,
1074,
8,
552,
8,
2604,
59,
17,
1055,
6334,
395,
413,
12,
2116,
298,
11408,
3648,
2839,
781,
1172,
1373,
1083,
531,
272,
20458,
14,
1074,
8,
552,
8,
2604,
59,
17,
1055,
6334,
59,
16,
1055,
15132,
4000,
841,
12,
2116,
298,
11408,
1172,
11648,
17597,
531,
339,
1798,
275,
1798,
14,
3958,
342,
272,
28176,
275,
756,
272,
862,
26,
267,
1798,
14,
1122,
4852,
881,
3217,
9762,
27978,
881,
3217,
1379,
30606,
469,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
Eseoghene/bite-project
|
deps/gdata-python-client/src/gdata/Crypto/PublicKey/DSA.py
|
228
|
6674
|
#
# DSA.py : Digital Signature Algorithm
#
# Part of the Python Cryptography Toolkit
#
# Distribute and use freely; there are no restrictions on further
# dissemination and usage except those imposed by the laws of your
# country of residence. This software is provided "as is" without
# warranty of fitness for use or suitability for any purpose, express
# or implied. Use at your own risk or not at all.
#
__revision__ = "$Id: DSA.py,v 1.16 2004/05/06 12:52:54 akuchling Exp $"
from Crypto.PublicKey.pubkey import *
from Crypto.Util import number
from Crypto.Util.number import bytes_to_long, long_to_bytes
from Crypto.Hash import SHA
try:
from Crypto.PublicKey import _fastmath
except ImportError:
_fastmath = None
class error (Exception):
pass
def generateQ(randfunc):
S=randfunc(20)
hash1=SHA.new(S).digest()
hash2=SHA.new(long_to_bytes(bytes_to_long(S)+1)).digest()
q = bignum(0)
for i in range(0,20):
c=ord(hash1[i])^ord(hash2[i])
if i==0:
c=c | 128
if i==19:
c= c | 1
q=q*256+c
while (not isPrime(q)):
q=q+2
if pow(2,159L) < q < pow(2,160L):
return S, q
raise error, 'Bad q value generated'
def generate(bits, randfunc, progress_func=None):
"""generate(bits:int, randfunc:callable, progress_func:callable)
Generate a DSA key of length 'bits', using 'randfunc' to get
random data and 'progress_func', if present, to display
the progress of the key generation.
"""
if bits<160:
raise error, 'Key length <160 bits'
obj=DSAobj()
# Generate string S and prime q
if progress_func:
progress_func('p,q\n')
while (1):
S, obj.q = generateQ(randfunc)
n=(bits-1)/160
C, N, V = 0, 2, {}
b=(obj.q >> 5) & 15
powb=pow(bignum(2), b)
powL1=pow(bignum(2), bits-1)
while C<4096:
for k in range(0, n+1):
V[k]=bytes_to_long(SHA.new(S+str(N)+str(k)).digest())
W=V[n] % powb
for k in range(n-1, -1, -1):
W=(W<<160L)+V[k]
X=W+powL1
p=X-(X%(2*obj.q)-1)
if powL1<=p and isPrime(p):
break
C, N = C+1, N+n+1
if C<4096:
break
if progress_func:
progress_func('4096 multiples failed\n')
obj.p = p
power=(p-1)/obj.q
if progress_func:
progress_func('h,g\n')
while (1):
h=bytes_to_long(randfunc(bits)) % (p-1)
g=pow(h, power, p)
if 1<h<p-1 and g>1:
break
obj.g=g
if progress_func:
progress_func('x,y\n')
while (1):
x=bytes_to_long(randfunc(20))
if 0 < x < obj.q:
break
obj.x, obj.y = x, pow(g, x, p)
return obj
def construct(tuple):
"""construct(tuple:(long,long,long,long)|(long,long,long,long,long)):DSAobj
Construct a DSA object from a 4- or 5-tuple of numbers.
"""
obj=DSAobj()
if len(tuple) not in [4,5]:
raise error, 'argument for construct() wrong length'
for i in range(len(tuple)):
field = obj.keydata[i]
setattr(obj, field, tuple[i])
return obj
class DSAobj(pubkey):
keydata=['y', 'g', 'p', 'q', 'x']
def _encrypt(self, s, Kstr):
raise error, 'DSA algorithm cannot encrypt data'
def _decrypt(self, s):
raise error, 'DSA algorithm cannot decrypt data'
def _sign(self, M, K):
if (K<2 or self.q<=K):
raise error, 'K is not between 2 and q'
r=pow(self.g, K, self.p) % self.q
s=(inverse(K, self.q)*(M+self.x*r)) % self.q
return (r,s)
def _verify(self, M, sig):
r, s = sig
if r<=0 or r>=self.q or s<=0 or s>=self.q:
return 0
w=inverse(s, self.q)
u1, u2 = (M*w) % self.q, (r*w) % self.q
v1 = pow(self.g, u1, self.p)
v2 = pow(self.y, u2, self.p)
v = ((v1*v2) % self.p)
v = v % self.q
if v==r:
return 1
return 0
def size(self):
"Return the maximum number of bits that can be handled by this key."
return number.size(self.p) - 1
def has_private(self):
"""Return a Boolean denoting whether the object contains
private components."""
if hasattr(self, 'x'):
return 1
else:
return 0
def can_sign(self):
"""Return a Boolean value recording whether this algorithm can generate signatures."""
return 1
def can_encrypt(self):
"""Return a Boolean value recording whether this algorithm can encrypt data."""
return 0
def publickey(self):
"""Return a new key object containing only the public information."""
return construct((self.y, self.g, self.p, self.q))
object=DSAobj
generate_py = generate
construct_py = construct
class DSAobj_c(pubkey):
keydata = ['y', 'g', 'p', 'q', 'x']
def __init__(self, key):
self.key = key
def __getattr__(self, attr):
if attr in self.keydata:
return getattr(self.key, attr)
else:
if self.__dict__.has_key(attr):
self.__dict__[attr]
else:
raise AttributeError, '%s instance has no attribute %s' % (self.__class__, attr)
def __getstate__(self):
d = {}
for k in self.keydata:
if hasattr(self.key, k):
d[k]=getattr(self.key, k)
return d
def __setstate__(self, state):
y,g,p,q = state['y'], state['g'], state['p'], state['q']
if not state.has_key('x'):
self.key = _fastmath.dsa_construct(y,g,p,q)
else:
x = state['x']
self.key = _fastmath.dsa_construct(y,g,p,q,x)
def _sign(self, M, K):
return self.key._sign(M, K)
def _verify(self, M, (r, s)):
return self.key._verify(M, r, s)
def size(self):
return self.key.size()
def has_private(self):
return self.key.has_private()
def publickey(self):
return construct_c((self.key.y, self.key.g, self.key.p, self.key.q))
def can_sign(self):
return 1
def can_encrypt(self):
return 0
def generate_c(bits, randfunc, progress_func=None):
obj = generate_py(bits, randfunc, progress_func)
y,g,p,q,x = obj.y, obj.g, obj.p, obj.q, obj.x
return construct_c((y,g,p,q,x))
def construct_c(tuple):
key = apply(_fastmath.dsa_construct, tuple)
return DSAobj_c(key)
if _fastmath:
#print "using C version of DSA"
generate = generate_c
construct = construct_c
error = _fastmath.error
|
apache-2.0
|
[
199,
3,
199,
3,
257,
577,
4251,
14,
647,
520,
29979,
18603,
23823,
199,
3,
199,
3,
221,
14320,
402,
314,
2018,
18855,
9773,
15650,
6065,
199,
3,
199,
3,
577,
5414,
266,
436,
675,
20673,
7742,
27,
2337,
787,
949,
24488,
641,
9848,
199,
3,
2153,
261,
827,
425,
436,
4503,
871,
5204,
1742,
79,
939,
701,
314,
1127,
3569,
402,
2195,
199,
3,
9023,
402,
28633,
5606,
14,
221,
961,
2032,
365,
2741,
298,
305,
365,
2,
1928,
199,
3,
3750,
402,
5542,
4171,
367,
675,
503,
308,
4993,
3616,
367,
1263,
12016,
12,
4056,
199,
3,
503,
2478,
14,
3645,
737,
2195,
5705,
22633,
503,
440,
737,
1006,
14,
199,
3,
199,
199,
363,
5792,
363,
275,
7880,
1304,
26,
577,
4251,
14,
647,
12,
86,
413,
14,
975,
8353,
15,
1717,
15,
1690,
3144,
26,
2528,
26,
1477,
282,
75,
2133,
2983,
7910,
2672,
2,
199,
199,
504,
18855,
14,
26238,
14,
17178,
492,
627,
199,
504,
18855,
14,
9562,
492,
1329,
199,
504,
18855,
14,
9562,
14,
1955,
492,
2783,
63,
475,
63,
2809,
12,
1846,
63,
475,
63,
2394,
199,
504,
18855,
14,
3476,
492,
12002,
199,
199,
893,
26,
272,
687,
18855,
14,
26238,
492,
485,
7015,
3442,
199,
2590,
3545,
26,
272,
485,
7015,
3442,
275,
488,
199,
199,
533,
1125,
334,
1726,
304,
272,
986,
199,
199,
318,
3550,
49,
8,
3759,
1532,
304,
272,
428,
29,
3759,
1532,
8,
1165,
9,
272,
2631,
17,
29,
8461,
14,
1222,
8,
51,
680,
5671,
342,
272,
2631,
18,
29,
8461,
14,
1222,
8,
2809,
63,
475,
63,
2394,
8,
2394,
63,
475,
63,
2809,
8,
51,
6393,
17,
4992,
5671,
342,
272,
1894,
275,
330,
1030,
453,
8,
16,
9,
272,
367,
284,
315,
1425,
8,
16,
12,
1165,
304,
267,
286,
29,
2181,
8,
2227,
17,
59,
73,
566,
62,
2181,
8,
2227,
18,
59,
73,
566,
267,
340,
284,
389,
16,
26,
288,
286,
29,
67,
1204,
7960,
267,
340,
284,
389,
1167,
26,
288,
286,
29,
286,
1204,
413,
267,
1894,
29,
81,
10,
3912,
11,
67,
272,
1830,
334,
1397,
365,
4562,
278,
8,
81,
2298,
267,
1894,
29,
81,
11,
18,
272,
340,
13131,
8,
18,
12,
9327,
44,
9,
665,
1894,
665,
13131,
8,
18,
12,
8488,
44,
304,
267,
372,
428,
12,
1894,
272,
746,
1125,
12,
283,
5725,
1894,
574,
4046,
7,
199,
199,
318,
3550,
8,
5609,
12,
10261,
1532,
12,
6696,
63,
1532,
29,
403,
304,
272,
408,
4208,
8,
5609,
26,
442,
12,
10261,
1532,
26,
8296,
12,
6696,
63,
1532,
26,
8296,
9,
339,
7958,
282,
577,
4251,
790,
402,
2582,
283,
5609,
297,
1808,
283,
3759,
1532,
7,
370,
664,
272,
2196,
666,
436,
283,
5734,
63,
1532,
297,
340,
3451,
12,
370,
2929,
272,
314,
6696,
402,
314,
790,
10152,
14,
272,
408,
339,
340,
5821,
28,
8488,
26,
267,
746,
1125,
12,
283,
1197,
2582,
665,
8488,
5821,
7,
272,
1559,
29,
23007,
1113,
342,
272,
327,
7958,
1059,
428,
436,
21619,
1894,
272,
340,
6696,
63,
1532,
26,
267,
6696,
63,
1532,
360,
80,
12,
81,
60,
78,
358,
272,
1830,
334,
17,
304,
267,
428,
12,
1559,
14,
81,
275,
3550,
49,
8,
3759,
1532,
9,
267,
302,
2687,
5609,
13,
17,
2447,
8488,
267,
445,
12,
653,
12,
812,
275,
378,
12,
499,
12,
1052,
267,
330,
2687,
1113,
14,
81,
4331,
959,
9,
1253,
4114,
267,
13131,
66,
29,
8278,
8,
66,
1030,
453,
8,
18,
395,
330,
9,
267,
13131,
44,
17,
29,
8278,
8,
66,
1030,
453,
8,
18,
395,
5821,
13,
17,
9,
267,
1830,
445,
28,
20579,
26,
288,
367,
1022,
315,
1425,
8,
16,
12,
302,
11,
17,
304,
355,
812,
59,
75,
10404,
2394,
63,
475,
63,
2809,
8,
8461,
14,
1222,
8,
51,
11,
495,
8,
46,
6393,
495,
8,
75,
4992,
5671,
1012,
288,
644,
29,
54,
59,
78,
61,
450,
13131,
66,
288,
367,
1022,
315,
1425,
8,
78,
13,
17,
12,
446,
17,
12,
446,
17,
304,
355,
644,
2687,
55,
8999,
8488,
44,
6393,
54,
59,
75,
61,
288,
1323,
29,
55,
11,
8278,
44,
17,
288,
299,
29,
56,
15426,
56,
2840,
18,
10,
1113,
14,
81,
7216,
17,
9,
288,
340,
13131,
44,
17,
12932,
80,
436,
365,
4562,
278,
8,
80,
304,
355,
2059,
288,
445,
12,
653,
275,
445,
11,
17,
12,
653,
11,
78,
11,
17,
267,
340,
445,
28,
20579,
26,
288,
2059,
267,
340,
6696,
63,
1532,
26,
288,
6696,
63,
1532,
360,
20579,
3663,
83,
3405,
60,
78,
358,
339,
1559,
14,
80,
275,
299,
272,
7074,
2687,
80,
13,
17,
2447,
1113,
14,
81,
272,
340,
6696,
63,
1532,
26,
267,
6696,
63,
1532,
360,
72,
12,
71,
60,
78,
358,
272,
1830,
334,
17,
304,
267,
394,
29,
2394,
63,
475,
63,
2809,
8,
3759,
1532,
8,
5609,
430,
450,
334,
80,
13,
17,
9,
267,
486,
29,
8278,
8,
72,
12,
7074,
12,
299,
9,
267,
340,
413,
28,
72,
28,
80,
13,
17,
436,
486,
30,
17,
26,
288,
2059,
272,
1559,
14,
71,
29,
71,
272,
340,
6696,
63,
1532,
26,
267,
6696,
63,
1532,
360,
88,
12,
89,
60,
78,
358,
272,
1830,
334,
17,
304,
267,
671,
29,
2394,
63,
475,
63,
2809,
8,
3759,
1532,
8,
1165,
430,
267,
340,
378,
665,
671,
665,
1559,
14,
81,
26,
288,
2059,
272,
1559,
14,
88,
12,
1559,
14,
89,
275,
671,
12,
13131,
8,
71,
12,
671,
12,
299,
9,
272,
372,
1559,
199,
199,
318,
6982,
8,
2960,
304,
272,
408,
8514,
8,
2960,
20334,
2809,
12,
2809,
12,
2809,
12,
2809,
8636,
8,
2809,
12,
2809,
12,
2809,
12,
2809,
12,
2809,
2298,
23007,
1113,
272,
9215,
282,
577,
4251,
909,
687,
282,
841,
13,
503,
959,
13,
2960,
402,
5579,
14,
272,
408,
272,
1559,
29,
23007,
1113,
342,
272,
340,
822,
8,
2960,
9,
440,
315,
359,
20,
12,
21,
2189,
267,
746,
1125,
12,
283,
2094,
367,
6982,
342,
6835,
2582,
7,
272,
367,
284,
315,
1425,
8,
552,
8,
2960,
2298,
267,
901,
275,
1559
] |
[
3,
199,
3,
257,
577,
4251,
14,
647,
520,
29979,
18603,
23823,
199,
3,
199,
3,
221,
14320,
402,
314,
2018,
18855,
9773,
15650,
6065,
199,
3,
199,
3,
577,
5414,
266,
436,
675,
20673,
7742,
27,
2337,
787,
949,
24488,
641,
9848,
199,
3,
2153,
261,
827,
425,
436,
4503,
871,
5204,
1742,
79,
939,
701,
314,
1127,
3569,
402,
2195,
199,
3,
9023,
402,
28633,
5606,
14,
221,
961,
2032,
365,
2741,
298,
305,
365,
2,
1928,
199,
3,
3750,
402,
5542,
4171,
367,
675,
503,
308,
4993,
3616,
367,
1263,
12016,
12,
4056,
199,
3,
503,
2478,
14,
3645,
737,
2195,
5705,
22633,
503,
440,
737,
1006,
14,
199,
3,
199,
199,
363,
5792,
363,
275,
7880,
1304,
26,
577,
4251,
14,
647,
12,
86,
413,
14,
975,
8353,
15,
1717,
15,
1690,
3144,
26,
2528,
26,
1477,
282,
75,
2133,
2983,
7910,
2672,
2,
199,
199,
504,
18855,
14,
26238,
14,
17178,
492,
627,
199,
504,
18855,
14,
9562,
492,
1329,
199,
504,
18855,
14,
9562,
14,
1955,
492,
2783,
63,
475,
63,
2809,
12,
1846,
63,
475,
63,
2394,
199,
504,
18855,
14,
3476,
492,
12002,
199,
199,
893,
26,
272,
687,
18855,
14,
26238,
492,
485,
7015,
3442,
199,
2590,
3545,
26,
272,
485,
7015,
3442,
275,
488,
199,
199,
533,
1125,
334,
1726,
304,
272,
986,
199,
199,
318,
3550,
49,
8,
3759,
1532,
304,
272,
428,
29,
3759,
1532,
8,
1165,
9,
272,
2631,
17,
29,
8461,
14,
1222,
8,
51,
680,
5671,
342,
272,
2631,
18,
29,
8461,
14,
1222,
8,
2809,
63,
475,
63,
2394,
8,
2394,
63,
475,
63,
2809,
8,
51,
6393,
17,
4992,
5671,
342,
272,
1894,
275,
330,
1030,
453,
8,
16,
9,
272,
367,
284,
315,
1425,
8,
16,
12,
1165,
304,
267,
286,
29,
2181,
8,
2227,
17,
59,
73,
566,
62,
2181,
8,
2227,
18,
59,
73,
566,
267,
340,
284,
389,
16,
26,
288,
286,
29,
67,
1204,
7960,
267,
340,
284,
389,
1167,
26,
288,
286,
29,
286,
1204,
413,
267,
1894,
29,
81,
10,
3912,
11,
67,
272,
1830,
334,
1397,
365,
4562,
278,
8,
81,
2298,
267,
1894,
29,
81,
11,
18,
272,
340,
13131,
8,
18,
12,
9327,
44,
9,
665,
1894,
665,
13131,
8,
18,
12,
8488,
44,
304,
267,
372,
428,
12,
1894,
272,
746,
1125,
12,
283,
5725,
1894,
574,
4046,
7,
199,
199,
318,
3550,
8,
5609,
12,
10261,
1532,
12,
6696,
63,
1532,
29,
403,
304,
272,
408,
4208,
8,
5609,
26,
442,
12,
10261,
1532,
26,
8296,
12,
6696,
63,
1532,
26,
8296,
9,
339,
7958,
282,
577,
4251,
790,
402,
2582,
283,
5609,
297,
1808,
283,
3759,
1532,
7,
370,
664,
272,
2196,
666,
436,
283,
5734,
63,
1532,
297,
340,
3451,
12,
370,
2929,
272,
314,
6696,
402,
314,
790,
10152,
14,
272,
408,
339,
340,
5821,
28,
8488,
26,
267,
746,
1125,
12,
283,
1197,
2582,
665,
8488,
5821,
7,
272,
1559,
29,
23007,
1113,
342,
272,
327,
7958,
1059,
428,
436,
21619,
1894,
272,
340,
6696,
63,
1532,
26,
267,
6696,
63,
1532,
360,
80,
12,
81,
60,
78,
358,
272,
1830,
334,
17,
304,
267,
428,
12,
1559,
14,
81,
275,
3550,
49,
8,
3759,
1532,
9,
267,
302,
2687,
5609,
13,
17,
2447,
8488,
267,
445,
12,
653,
12,
812,
275,
378,
12,
499,
12,
1052,
267,
330,
2687,
1113,
14,
81,
4331,
959,
9,
1253,
4114,
267,
13131,
66,
29,
8278,
8,
66,
1030,
453,
8,
18,
395,
330,
9,
267,
13131,
44,
17,
29,
8278,
8,
66,
1030,
453,
8,
18,
395,
5821,
13,
17,
9,
267,
1830,
445,
28,
20579,
26,
288,
367,
1022,
315,
1425,
8,
16,
12,
302,
11,
17,
304,
355,
812,
59,
75,
10404,
2394,
63,
475,
63,
2809,
8,
8461,
14,
1222,
8,
51,
11,
495,
8,
46,
6393,
495,
8,
75,
4992,
5671,
1012,
288,
644,
29,
54,
59,
78,
61,
450,
13131,
66,
288,
367,
1022,
315,
1425,
8,
78,
13,
17,
12,
446,
17,
12,
446,
17,
304,
355,
644,
2687,
55,
8999,
8488,
44,
6393,
54,
59,
75,
61,
288,
1323,
29,
55,
11,
8278,
44,
17,
288,
299,
29,
56,
15426,
56,
2840,
18,
10,
1113,
14,
81,
7216,
17,
9,
288,
340,
13131,
44,
17,
12932,
80,
436,
365,
4562,
278,
8,
80,
304,
355,
2059,
288,
445,
12,
653,
275,
445,
11,
17,
12,
653,
11,
78,
11,
17,
267,
340,
445,
28,
20579,
26,
288,
2059,
267,
340,
6696,
63,
1532,
26,
288,
6696,
63,
1532,
360,
20579,
3663,
83,
3405,
60,
78,
358,
339,
1559,
14,
80,
275,
299,
272,
7074,
2687,
80,
13,
17,
2447,
1113,
14,
81,
272,
340,
6696,
63,
1532,
26,
267,
6696,
63,
1532,
360,
72,
12,
71,
60,
78,
358,
272,
1830,
334,
17,
304,
267,
394,
29,
2394,
63,
475,
63,
2809,
8,
3759,
1532,
8,
5609,
430,
450,
334,
80,
13,
17,
9,
267,
486,
29,
8278,
8,
72,
12,
7074,
12,
299,
9,
267,
340,
413,
28,
72,
28,
80,
13,
17,
436,
486,
30,
17,
26,
288,
2059,
272,
1559,
14,
71,
29,
71,
272,
340,
6696,
63,
1532,
26,
267,
6696,
63,
1532,
360,
88,
12,
89,
60,
78,
358,
272,
1830,
334,
17,
304,
267,
671,
29,
2394,
63,
475,
63,
2809,
8,
3759,
1532,
8,
1165,
430,
267,
340,
378,
665,
671,
665,
1559,
14,
81,
26,
288,
2059,
272,
1559,
14,
88,
12,
1559,
14,
89,
275,
671,
12,
13131,
8,
71,
12,
671,
12,
299,
9,
272,
372,
1559,
199,
199,
318,
6982,
8,
2960,
304,
272,
408,
8514,
8,
2960,
20334,
2809,
12,
2809,
12,
2809,
12,
2809,
8636,
8,
2809,
12,
2809,
12,
2809,
12,
2809,
12,
2809,
2298,
23007,
1113,
272,
9215,
282,
577,
4251,
909,
687,
282,
841,
13,
503,
959,
13,
2960,
402,
5579,
14,
272,
408,
272,
1559,
29,
23007,
1113,
342,
272,
340,
822,
8,
2960,
9,
440,
315,
359,
20,
12,
21,
2189,
267,
746,
1125,
12,
283,
2094,
367,
6982,
342,
6835,
2582,
7,
272,
367,
284,
315,
1425,
8,
552,
8,
2960,
2298,
267,
901,
275,
1559,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
ging/keystone
|
keystone/auth/plugins/two_factor.py
|
1
|
3545
|
# Copyright (C) 2015 Universidad Politecnica de Madrid
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import sys
import six
from keystone.auth.plugins.password import UserAuthInfo, Password
from keystone.common import dependency
from keystone import exception
from keystone.i18n import _
from keystone.openstack.common import log
LOG = log.getLogger(__name__)
METHOD_NAME = 'password'
@dependency.requires('assignment_api', 'identity_api')
class UserTwoFactorAuthInfo(UserAuthInfo):
@staticmethod
def create(auth_payload):
user_auth_info = UserTwoFactorAuthInfo()
user_auth_info._validate_and_normalize_auth_data(auth_payload)
return user_auth_info
def __init__(self):
super(UserTwoFactorAuthInfo, self).__init__()
self.verification_code = None
self.device_data = None
def _validate_and_normalize_auth_data(self, auth_payload):
super(UserTwoFactorAuthInfo, self)._validate_and_normalize_auth_data(auth_payload)
verification_code = auth_payload['user'].get('verification_code', None)
device_data = auth_payload['user'].get('device_data', None)
if not (verification_code or device_data):
raise exception.ValidationError(attribute='verification_code or device_data', target=METHOD_NAME)
if verification_code:
self.verification_code = verification_code
elif device_data:
self.device_data = device_data
@dependency.requires('two_factor_auth_api')
class TwoFactor(Password):
method = METHOD_NAME
def authenticate(self, context, auth_payload, auth_context):
"""Two factor authentication"""
if not self.two_factor_auth_api:
raise exception.Unauthorized(_('%s not supported') % self.method)
user_info = UserAuthInfo.create(auth_payload)
user_id = user_info.user_id
try:
self.two_factor_auth_api.is_two_factor_enabled(user_id)
except exception.NotFound:
return super(TwoFactor, self).authenticate(context, auth_payload, auth_context)
user_info = UserTwoFactorAuthInfo.create(auth_payload)
if user_info.verification_code:
if not self.two_factor_auth_api.verify_code(user_id, user_info.verification_code):
raise exception.Unauthorized(_('Invalid time based code'))
elif user_info.device_data:
device_id = user_info.device_data['device_id']
device_token = user_info.device_data['device_token']
user_id = user_info.user_id
try:
if not self.two_factor_auth_api.is_device_valid(device_id=device_id, device_token=device_token, user_id=user_id):
raise exception.Unauthorized(_('Invalid device data: old token'))
except exception.NotFound:
raise exception.Unauthorized(_('Invalid device data: wrong data'))
return super(TwoFactor, self).authenticate(context, auth_payload, auth_context)
|
apache-2.0
|
[
3,
1898,
334,
35,
9,
6900,
1910,
4380,
4148,
350,
4376,
5333,
6413,
24027,
477,
603,
350,
1677,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
1265,
1443,
199,
3,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
2047,
1443,
3332,
199,
3,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
420,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
2428,
199,
3,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
1666,
314,
199,
3,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
1334,
314,
844,
14,
199,
199,
646,
984,
199,
199,
646,
3816,
199,
199,
504,
19395,
14,
1178,
14,
5265,
14,
2060,
492,
2876,
2817,
2354,
12,
13635,
199,
504,
19395,
14,
2330,
492,
5936,
199,
504,
19395,
492,
1919,
199,
504,
19395,
14,
73,
1085,
78,
492,
485,
199,
504,
19395,
14,
8512,
14,
2330,
492,
943,
421,
199,
4947,
275,
943,
14,
5572,
3460,
354,
3368,
199,
199,
9977,
63,
2339,
275,
283,
2060,
7,
2126,
199,
32,
8575,
14,
6537,
360,
10861,
63,
1246,
297,
283,
5582,
63,
1246,
358,
199,
533,
2876,
11467,
12666,
2817,
2354,
8,
1899,
2817,
2354,
304,
272,
768,
4639,
272,
347,
1218,
8,
1178,
63,
4749,
304,
267,
922,
63,
1178,
63,
815,
275,
2876,
11467,
12666,
2817,
2354,
342,
267,
922,
63,
1178,
63,
815,
423,
3502,
63,
460,
63,
7721,
63,
1178,
63,
576,
8,
1178,
63,
4749,
9,
267,
372,
922,
63,
1178,
63,
815,
339,
347,
636,
826,
721,
277,
304,
267,
1613,
8,
1899,
11467,
12666,
2817,
2354,
12,
291,
2843,
826,
4533,
267,
291,
14,
16257,
63,
600,
275,
488,
267,
291,
14,
1782,
63,
576,
275,
488,
339,
347,
485,
3502,
63,
460,
63,
7721,
63,
1178,
63,
576,
8,
277,
12,
1790,
63,
4749,
304,
267,
1613,
8,
1899,
11467,
12666,
2817,
2354,
12,
291,
10445,
3502,
63,
460,
63,
7721,
63,
1178,
63,
576,
8,
1178,
63,
4749,
9,
267,
14786,
63,
600,
275,
1790,
63,
4749,
459,
751,
2278,
362,
360,
16257,
63,
600,
297,
488,
9,
267,
2243,
63,
576,
275,
1790,
63,
4749,
459,
751,
2278,
362,
360,
1782,
63,
576,
297,
488,
9,
398,
340,
440,
334,
16257,
63,
600,
503,
2243,
63,
576,
304,
288,
746,
1919,
14,
8172,
8,
3215,
534,
16257,
63,
600,
503,
2243,
63,
576,
297,
1347,
29,
9977,
63,
2339,
9,
2728,
340,
14786,
63,
600,
26,
288,
291,
14,
16257,
63,
600,
275,
14786,
63,
600,
267,
916,
2243,
63,
576,
26,
288,
291,
14,
1782,
63,
576,
275,
2243,
63,
576,
421,
199,
32,
8575,
14,
6537,
360,
5601,
63,
4778,
63,
1178,
63,
1246,
358,
199,
533,
16853,
12666,
8,
6139,
304,
339,
1083,
275,
27411,
36,
63,
2339,
339,
347,
12895,
8,
277,
12,
1067,
12,
1790,
63,
4749,
12,
1790,
63,
1100,
304,
267,
408,
11467,
6535,
6299,
624,
398,
340,
440,
291,
14,
5601,
63,
4778,
63,
1178,
63,
1246,
26,
288,
746,
1919,
14,
28290,
1547,
3508,
83,
440,
3748,
358,
450,
291,
14,
765,
9,
398,
922,
63,
815,
275,
2876,
2817,
2354,
14,
981,
8,
1178,
63,
4749,
9,
267,
922,
63,
344,
275,
922,
63,
815,
14,
751,
63,
344,
398,
862,
26,
288,
291,
14,
5601,
63,
4778,
63,
1178,
63,
1246,
14,
374,
63,
5601,
63,
4778,
63,
3827,
8,
751,
63,
344,
9,
267,
871,
1919,
14,
4667,
26,
288,
372,
1613,
8,
11467,
12666,
12,
291,
680,
13975,
8,
1100,
12,
1790,
63,
4749,
12,
1790,
63,
1100,
9,
398,
922,
63,
815,
275,
2876,
11467,
12666,
2817,
2354,
14,
981,
8,
1178,
63,
4749,
9,
398,
340,
922,
63,
815,
14,
16257,
63,
600,
26,
288,
340,
440,
291,
14,
5601,
63,
4778,
63,
1178,
63,
1246,
14,
4712,
63,
600,
8,
751,
63,
344,
12,
922,
63,
815,
14,
16257,
63,
600,
304,
355,
746,
1919,
14,
28290,
6723,
3364,
900,
4079,
1233,
1333,
267,
916,
922,
63,
815,
14,
1782,
63,
576,
26,
288,
2243,
63,
344,
275,
922,
63,
815,
14,
1782,
63,
576,
459,
1782,
63,
344,
418,
288,
2243,
63,
1418,
275,
922,
63,
815,
14,
1782,
63,
576,
459,
1782,
63,
1418,
418,
288,
922,
63,
344,
275,
922,
63,
815,
14,
751,
63,
344,
953,
862,
26,
355,
340,
440,
291,
14,
5601,
63,
4778,
63,
1178,
63,
1246,
14,
374,
63,
1782,
63,
1078,
8,
1782,
63,
344,
29,
1782,
63,
344,
12,
2243,
63,
1418,
29,
1782,
63,
1418,
12,
922,
63,
344,
29,
751,
63,
344,
304,
490,
746,
1919,
14,
28290,
6723,
3364,
2243,
666,
26,
2269,
1526,
1333,
288,
871,
1919,
14,
4667,
26,
355,
746,
1919,
14,
28290,
6723,
3364,
2243,
666,
26,
6835,
666,
1333,
2728,
372,
1613,
8,
11467,
12666,
12,
291,
680,
13975,
8,
1100,
12,
1790,
63,
4749,
12,
1790,
63,
1100,
9,
268,
1467,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1898,
334,
35,
9,
6900,
1910,
4380,
4148,
350,
4376,
5333,
6413,
24027,
477,
603,
350,
1677,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
1265,
1443,
199,
3,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
2047,
1443,
3332,
199,
3,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
420,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
2428,
199,
3,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
1666,
314,
199,
3,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
1334,
314,
844,
14,
199,
199,
646,
984,
199,
199,
646,
3816,
199,
199,
504,
19395,
14,
1178,
14,
5265,
14,
2060,
492,
2876,
2817,
2354,
12,
13635,
199,
504,
19395,
14,
2330,
492,
5936,
199,
504,
19395,
492,
1919,
199,
504,
19395,
14,
73,
1085,
78,
492,
485,
199,
504,
19395,
14,
8512,
14,
2330,
492,
943,
421,
199,
4947,
275,
943,
14,
5572,
3460,
354,
3368,
199,
199,
9977,
63,
2339,
275,
283,
2060,
7,
2126,
199,
32,
8575,
14,
6537,
360,
10861,
63,
1246,
297,
283,
5582,
63,
1246,
358,
199,
533,
2876,
11467,
12666,
2817,
2354,
8,
1899,
2817,
2354,
304,
272,
768,
4639,
272,
347,
1218,
8,
1178,
63,
4749,
304,
267,
922,
63,
1178,
63,
815,
275,
2876,
11467,
12666,
2817,
2354,
342,
267,
922,
63,
1178,
63,
815,
423,
3502,
63,
460,
63,
7721,
63,
1178,
63,
576,
8,
1178,
63,
4749,
9,
267,
372,
922,
63,
1178,
63,
815,
339,
347,
636,
826,
721,
277,
304,
267,
1613,
8,
1899,
11467,
12666,
2817,
2354,
12,
291,
2843,
826,
4533,
267,
291,
14,
16257,
63,
600,
275,
488,
267,
291,
14,
1782,
63,
576,
275,
488,
339,
347,
485,
3502,
63,
460,
63,
7721,
63,
1178,
63,
576,
8,
277,
12,
1790,
63,
4749,
304,
267,
1613,
8,
1899,
11467,
12666,
2817,
2354,
12,
291,
10445,
3502,
63,
460,
63,
7721,
63,
1178,
63,
576,
8,
1178,
63,
4749,
9,
267,
14786,
63,
600,
275,
1790,
63,
4749,
459,
751,
2278,
362,
360,
16257,
63,
600,
297,
488,
9,
267,
2243,
63,
576,
275,
1790,
63,
4749,
459,
751,
2278,
362,
360,
1782,
63,
576,
297,
488,
9,
398,
340,
440,
334,
16257,
63,
600,
503,
2243,
63,
576,
304,
288,
746,
1919,
14,
8172,
8,
3215,
534,
16257,
63,
600,
503,
2243,
63,
576,
297,
1347,
29,
9977,
63,
2339,
9,
2728,
340,
14786,
63,
600,
26,
288,
291,
14,
16257,
63,
600,
275,
14786,
63,
600,
267,
916,
2243,
63,
576,
26,
288,
291,
14,
1782,
63,
576,
275,
2243,
63,
576,
421,
199,
32,
8575,
14,
6537,
360,
5601,
63,
4778,
63,
1178,
63,
1246,
358,
199,
533,
16853,
12666,
8,
6139,
304,
339,
1083,
275,
27411,
36,
63,
2339,
339,
347,
12895,
8,
277,
12,
1067,
12,
1790,
63,
4749,
12,
1790,
63,
1100,
304,
267,
408,
11467,
6535,
6299,
624,
398,
340,
440,
291,
14,
5601,
63,
4778,
63,
1178,
63,
1246,
26,
288,
746,
1919,
14,
28290,
1547,
3508,
83,
440,
3748,
358,
450,
291,
14,
765,
9,
398,
922,
63,
815,
275,
2876,
2817,
2354,
14,
981,
8,
1178,
63,
4749,
9,
267,
922,
63,
344,
275,
922,
63,
815,
14,
751,
63,
344,
398,
862,
26,
288,
291,
14,
5601,
63,
4778,
63,
1178,
63,
1246,
14,
374,
63,
5601,
63,
4778,
63,
3827,
8,
751,
63,
344,
9,
267,
871,
1919,
14,
4667,
26,
288,
372,
1613,
8,
11467,
12666,
12,
291,
680,
13975,
8,
1100,
12,
1790,
63,
4749,
12,
1790,
63,
1100,
9,
398,
922,
63,
815,
275,
2876,
11467,
12666,
2817,
2354,
14,
981,
8,
1178,
63,
4749,
9,
398,
340,
922,
63,
815,
14,
16257,
63,
600,
26,
288,
340,
440,
291,
14,
5601,
63,
4778,
63,
1178,
63,
1246,
14,
4712,
63,
600,
8,
751,
63,
344,
12,
922,
63,
815,
14,
16257,
63,
600,
304,
355,
746,
1919,
14,
28290,
6723,
3364,
900,
4079,
1233,
1333,
267,
916,
922,
63,
815,
14,
1782,
63,
576,
26,
288,
2243,
63,
344,
275,
922,
63,
815,
14,
1782,
63,
576,
459,
1782,
63,
344,
418,
288,
2243,
63,
1418,
275,
922,
63,
815,
14,
1782,
63,
576,
459,
1782,
63,
1418,
418,
288,
922,
63,
344,
275,
922,
63,
815,
14,
751,
63,
344,
953,
862,
26,
355,
340,
440,
291,
14,
5601,
63,
4778,
63,
1178,
63,
1246,
14,
374,
63,
1782,
63,
1078,
8,
1782,
63,
344,
29,
1782,
63,
344,
12,
2243,
63,
1418,
29,
1782,
63,
1418,
12,
922,
63,
344,
29,
751,
63,
344,
304,
490,
746,
1919,
14,
28290,
6723,
3364,
2243,
666,
26,
2269,
1526,
1333,
288,
871,
1919,
14,
4667,
26,
355,
746,
1919,
14,
28290,
6723,
3364,
2243,
666,
26,
6835,
666,
1333,
2728,
372,
1613,
8,
11467,
12666,
12,
291,
680,
13975,
8,
1100,
12,
1790,
63,
4749,
12,
1790,
63,
1100,
9,
268,
1467,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
armadill-odyssey/aima-python
|
submissions/Karman/puzzles.py
|
18
|
1974
|
import search
from math import(cos, pi)
tuscany_map = search.UndirectedGraph(dict(
Florence=dict(Prato=24, Montevarchi=51, Sienna=75, Empoli=31),
Prato=dict(Pistoia=26, Florence=24, Empoli = 29.3),
Pistoia=dict(Prato=26, Lucca=43),
Lucca=dict(Pistoia=43, Pisa=18, Pontedera = 29, SanMiniato = 44.3),
Pisa=dict(Lucca=18, Pontedera=33, Cecina=63.3),
Pontedera=dict(Pisa=33, SanMiniato=22, Lucca = 29, Volterra=45.5),
SanMiniato=dict(Pontedera=22, Empoli=11, Lucca = 44.3),
Empoli=dict(SanMiniato=11, Florence=31, Sienna = 76.6, Prato = 29.3),
Montevarchi=dict(Florence=51, Arezzo=37, Sienna = 54.4),
Arezzo=dict(Montevarchi=37, Sienna=74.6),
Sienna=dict(Florence=75, Arezzo =74.6, Empoli =76.6, Montevarchi = 54.4, Volterra = 54),
Volterra=dict(Sienna=54, Pontedera=45.5, Cecina=39),
Cecina=dict(Volterra=39, Pisa=63.3)
))
tuscany_map.locations = dict(
Florence=(43.77, 11.25), Prato=(43.87,11.10),
Pistoia=(43.93, 10.90), Lucca=(43.83, 10.49),
Pisa=(43.72, 10.39), Pontedera=(43.66, 10.62),
SanMiniato=(43.68, 10.85), Empoli=(43.72, 10.95),
Montevarchi=(43.53, 11.56), Arezzo=(43.46, 11.89),
Sienna=(43.32, 11.33), Volterra=(43.40, 10.86),
Cecina=(43.31,10.51),
)
tuscany_puzzle = search.GraphProblem('Sienna', 'Lucca', tuscany_map)
tuscany_puzzle.label = 'Tuscany Map'
tuscany_puzzle.description = '''
an abbreviated map of the Tuscany region of Italy
'''
# A trivial Problem definition
class LightSwitch(search.Problem):
def actions(self, state):
return ['up', 'down']
def result(self, state, action):
if action == 'up':
return 'on'
else:
return 'off'
def goal_test(self, state):
return state == 'on'
def h(self, node):
state = node.state
if self.goal_test(state):
return 0
else:
return 1
switch_puzzle = LightSwitch('off')
switch_puzzle.label = 'Light Switch'
myPuzzles = [
tuscany_puzzle,
switch_puzzle,
]
|
mit
|
[
646,
2754,
199,
504,
3473,
492,
8,
5197,
12,
6682,
9,
421,
199,
84,
527,
67,
1629,
63,
1130,
275,
2754,
14,
1358,
12080,
4578,
8,
807,
8,
199,
38,
320,
4646,
29,
807,
8,
9779,
11318,
29,
1194,
12,
10953,
266,
86,
1047,
73,
29,
2869,
12,
428,
24555,
3540,
29,
2194,
12,
662,
9613,
317,
29,
2192,
395,
199,
9779,
11318,
29,
807,
8,
48,
7133,
4674,
29,
1479,
12,
481,
320,
4646,
29,
1194,
12,
662,
9613,
317,
275,
7349,
14,
19,
395,
199,
48,
7133,
4674,
29,
807,
8,
9779,
11318,
29,
1479,
12,
491,
947,
696,
29,
2824,
395,
199,
44,
947,
696,
29,
807,
8,
48,
7133,
4674,
29,
2824,
12,
510,
13655,
29,
1085,
12,
510,
265,
266,
271,
345,
275,
7349,
12,
29359,
26822,
11318,
275,
10868,
14,
19,
395,
199,
48,
13655,
29,
807,
8,
44,
947,
696,
29,
1085,
12,
510,
265,
266,
271,
345,
29,
1153,
12,
445,
825,
13765,
29,
2766,
14,
19,
395,
199,
48,
265,
266,
271,
345,
29,
807,
8,
48,
13655,
29,
1153,
12,
29359,
26822,
11318,
29,
1081,
12,
491,
947,
696,
275,
7349,
12,
16171,
351,
345,
29,
2322,
14,
21,
395,
199,
23906,
26822,
11318,
29,
807,
8,
48,
265,
266,
271,
345,
29,
1081,
12,
662,
9613,
317,
29,
845,
12,
491,
947,
696,
275,
10868,
14,
19,
395,
199,
37,
9613,
317,
29,
807,
8,
23906,
26822,
11318,
29,
845,
12,
481,
320,
4646,
29,
2192,
12,
428,
24555,
3540,
275,
14646,
14,
22,
12,
25716,
11318,
275,
7349,
14,
19,
395,
199,
6671,
266,
86,
1047,
73,
29,
807,
8,
38,
320,
4646,
29,
2869,
12,
23889,
4348,
79,
29,
1401,
12,
428,
24555,
3540,
275,
13470,
14,
20,
395,
199,
17683,
4348,
79,
29,
807,
8,
6671,
266,
86,
1047,
73,
29,
1401,
12,
428,
24555,
3540,
29,
1342,
14,
22,
395,
199,
18934,
287,
3540,
29,
807,
8,
38,
320,
4646,
29,
2194,
12,
23889,
4348,
79,
275,
1342,
14,
22,
12,
662,
9613,
317,
275,
2114,
14,
22,
12,
10953,
266,
86,
1047,
73,
275,
13470,
14,
20,
12,
16171,
351,
345,
275,
13470,
395,
199,
16969,
351,
345,
29,
807,
8,
18934,
287,
3540,
29,
1477,
12,
510,
265,
266,
271,
345,
29,
2322,
14,
21,
12,
445,
825,
13765,
29,
1355,
395,
199,
35,
825,
13765,
29,
807,
8,
16969,
351,
345,
29,
1355,
12,
510,
13655,
29,
2766,
14,
19,
9,
199,
199,
430,
199,
199,
84,
527,
67,
1629,
63,
1130,
14,
8022,
275,
1211,
8,
272,
481,
320,
4646,
2687,
2824,
14,
1138,
12,
4119,
14,
821,
395,
25716,
11318,
2687,
2824,
14,
1555,
12,
845,
14,
709,
395,
272,
510,
7133,
4674,
2687,
2824,
14,
3129,
12,
1616,
14,
2710,
395,
491,
947,
696,
2687,
2824,
14,
2658,
12,
1616,
14,
1887,
395,
272,
510,
13655,
2687,
2824,
14,
2819,
12,
1616,
14,
1355,
395,
510,
265,
266,
271,
345,
2687,
2824,
14,
1272,
12,
1616,
14,
2789,
395,
272,
29359,
26822,
11318,
2687,
2824,
14,
2333,
12,
1616,
14,
2426,
395,
662,
9613,
317,
2687,
2824,
14,
2819,
12,
1616,
14,
2720,
395,
272,
10953,
266,
86,
1047,
73,
2687,
2824,
14,
2481,
12,
4119,
14,
1367,
395,
23889,
4348,
79,
2687,
2824,
14,
2466,
12,
4119,
14,
1407,
395,
272,
428,
24555,
3540,
2687,
2824,
14,
708,
12,
4119,
14,
1153,
395,
16171,
351,
345,
2687,
2824,
14,
2167,
12,
1616,
14,
1184,
395,
272,
445,
825,
13765,
2687,
2824,
14,
2192,
12,
709,
14,
2869,
395,
199,
9,
199,
84,
527,
67,
1629,
63,
3165,
17622,
275,
2754,
14,
4578,
16467,
360,
18934,
287,
3540,
297,
283,
44,
947,
696,
297,
307,
527,
67,
1629,
63,
1130,
9,
199,
84,
527,
67,
1629,
63,
3165,
17622,
14,
1302,
275,
283,
52,
527,
67,
1629,
9672,
7,
199,
84,
527,
67,
1629,
63,
3165,
17622,
14,
1802,
275,
1449,
199,
290,
2236,
23988,
972,
2341,
402,
314,
377,
527,
67,
1629,
4897,
402,
2779,
2618,
199,
2344,
199,
199,
3,
437,
28586,
20980,
5492,
199,
533,
29684,
10167,
8,
1733,
14,
16467,
304,
272,
347,
5445,
8,
277,
12,
1174,
304,
267,
372,
788,
384,
297,
283,
2110,
418,
339,
347,
754,
8,
277,
12,
1174,
12,
1595,
304,
267,
340,
1595,
508,
283,
384,
356,
288,
372,
283,
265,
7,
267,
587,
26,
288,
372,
283,
1997,
7,
339,
347,
14850,
63,
396,
8,
277,
12,
1174,
304,
267,
372,
1174,
508,
283,
265,
7,
339,
347,
394,
8,
277,
12,
1031,
304,
267,
1174,
275,
1031,
14,
929,
267,
340,
291,
14,
16117,
63,
396,
8,
929,
304,
288,
372,
378,
267,
587,
26,
288,
372,
413,
199,
199,
5656,
63,
3165,
17622,
275,
29684,
10167,
360,
1997,
358,
199,
5656,
63,
3165,
17622,
14,
1302,
275,
283,
16393,
17711,
7,
199,
199,
1662,
26607,
4348,
2978,
275,
359,
272,
307,
527,
67,
1629,
63,
3165,
17622,
12,
272,
6258,
63,
3165,
17622,
12,
199,
61,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
2754,
199,
504,
3473,
492,
8,
5197,
12,
6682,
9,
421,
199,
84,
527,
67,
1629,
63,
1130,
275,
2754,
14,
1358,
12080,
4578,
8,
807,
8,
199,
38,
320,
4646,
29,
807,
8,
9779,
11318,
29,
1194,
12,
10953,
266,
86,
1047,
73,
29,
2869,
12,
428,
24555,
3540,
29,
2194,
12,
662,
9613,
317,
29,
2192,
395,
199,
9779,
11318,
29,
807,
8,
48,
7133,
4674,
29,
1479,
12,
481,
320,
4646,
29,
1194,
12,
662,
9613,
317,
275,
7349,
14,
19,
395,
199,
48,
7133,
4674,
29,
807,
8,
9779,
11318,
29,
1479,
12,
491,
947,
696,
29,
2824,
395,
199,
44,
947,
696,
29,
807,
8,
48,
7133,
4674,
29,
2824,
12,
510,
13655,
29,
1085,
12,
510,
265,
266,
271,
345,
275,
7349,
12,
29359,
26822,
11318,
275,
10868,
14,
19,
395,
199,
48,
13655,
29,
807,
8,
44,
947,
696,
29,
1085,
12,
510,
265,
266,
271,
345,
29,
1153,
12,
445,
825,
13765,
29,
2766,
14,
19,
395,
199,
48,
265,
266,
271,
345,
29,
807,
8,
48,
13655,
29,
1153,
12,
29359,
26822,
11318,
29,
1081,
12,
491,
947,
696,
275,
7349,
12,
16171,
351,
345,
29,
2322,
14,
21,
395,
199,
23906,
26822,
11318,
29,
807,
8,
48,
265,
266,
271,
345,
29,
1081,
12,
662,
9613,
317,
29,
845,
12,
491,
947,
696,
275,
10868,
14,
19,
395,
199,
37,
9613,
317,
29,
807,
8,
23906,
26822,
11318,
29,
845,
12,
481,
320,
4646,
29,
2192,
12,
428,
24555,
3540,
275,
14646,
14,
22,
12,
25716,
11318,
275,
7349,
14,
19,
395,
199,
6671,
266,
86,
1047,
73,
29,
807,
8,
38,
320,
4646,
29,
2869,
12,
23889,
4348,
79,
29,
1401,
12,
428,
24555,
3540,
275,
13470,
14,
20,
395,
199,
17683,
4348,
79,
29,
807,
8,
6671,
266,
86,
1047,
73,
29,
1401,
12,
428,
24555,
3540,
29,
1342,
14,
22,
395,
199,
18934,
287,
3540,
29,
807,
8,
38,
320,
4646,
29,
2194,
12,
23889,
4348,
79,
275,
1342,
14,
22,
12,
662,
9613,
317,
275,
2114,
14,
22,
12,
10953,
266,
86,
1047,
73,
275,
13470,
14,
20,
12,
16171,
351,
345,
275,
13470,
395,
199,
16969,
351,
345,
29,
807,
8,
18934,
287,
3540,
29,
1477,
12,
510,
265,
266,
271,
345,
29,
2322,
14,
21,
12,
445,
825,
13765,
29,
1355,
395,
199,
35,
825,
13765,
29,
807,
8,
16969,
351,
345,
29,
1355,
12,
510,
13655,
29,
2766,
14,
19,
9,
199,
199,
430,
199,
199,
84,
527,
67,
1629,
63,
1130,
14,
8022,
275,
1211,
8,
272,
481,
320,
4646,
2687,
2824,
14,
1138,
12,
4119,
14,
821,
395,
25716,
11318,
2687,
2824,
14,
1555,
12,
845,
14,
709,
395,
272,
510,
7133,
4674,
2687,
2824,
14,
3129,
12,
1616,
14,
2710,
395,
491,
947,
696,
2687,
2824,
14,
2658,
12,
1616,
14,
1887,
395,
272,
510,
13655,
2687,
2824,
14,
2819,
12,
1616,
14,
1355,
395,
510,
265,
266,
271,
345,
2687,
2824,
14,
1272,
12,
1616,
14,
2789,
395,
272,
29359,
26822,
11318,
2687,
2824,
14,
2333,
12,
1616,
14,
2426,
395,
662,
9613,
317,
2687,
2824,
14,
2819,
12,
1616,
14,
2720,
395,
272,
10953,
266,
86,
1047,
73,
2687,
2824,
14,
2481,
12,
4119,
14,
1367,
395,
23889,
4348,
79,
2687,
2824,
14,
2466,
12,
4119,
14,
1407,
395,
272,
428,
24555,
3540,
2687,
2824,
14,
708,
12,
4119,
14,
1153,
395,
16171,
351,
345,
2687,
2824,
14,
2167,
12,
1616,
14,
1184,
395,
272,
445,
825,
13765,
2687,
2824,
14,
2192,
12,
709,
14,
2869,
395,
199,
9,
199,
84,
527,
67,
1629,
63,
3165,
17622,
275,
2754,
14,
4578,
16467,
360,
18934,
287,
3540,
297,
283,
44,
947,
696,
297,
307,
527,
67,
1629,
63,
1130,
9,
199,
84,
527,
67,
1629,
63,
3165,
17622,
14,
1302,
275,
283,
52,
527,
67,
1629,
9672,
7,
199,
84,
527,
67,
1629,
63,
3165,
17622,
14,
1802,
275,
1449,
199,
290,
2236,
23988,
972,
2341,
402,
314,
377,
527,
67,
1629,
4897,
402,
2779,
2618,
199,
2344,
199,
199,
3,
437,
28586,
20980,
5492,
199,
533,
29684,
10167,
8,
1733,
14,
16467,
304,
272,
347,
5445,
8,
277,
12,
1174,
304,
267,
372,
788,
384,
297,
283,
2110,
418,
339,
347,
754,
8,
277,
12,
1174,
12,
1595,
304,
267,
340,
1595,
508,
283,
384,
356,
288,
372,
283,
265,
7,
267,
587,
26,
288,
372,
283,
1997,
7,
339,
347,
14850,
63,
396,
8,
277,
12,
1174,
304,
267,
372,
1174,
508,
283,
265,
7,
339,
347,
394,
8,
277,
12,
1031,
304,
267,
1174,
275,
1031,
14,
929,
267,
340,
291,
14,
16117,
63,
396,
8,
929,
304,
288,
372,
378,
267,
587,
26,
288,
372,
413,
199,
199,
5656,
63,
3165,
17622,
275,
29684,
10167,
360,
1997,
358,
199,
5656,
63,
3165,
17622,
14,
1302,
275,
283,
16393,
17711,
7,
199,
199,
1662,
26607,
4348,
2978,
275,
359,
272,
307,
527,
67,
1629,
63,
3165,
17622,
12,
272,
6258,
63,
3165,
17622,
12,
199,
61,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
demon-ru/iml-crm
|
addons/mail/wizard/__init__.py
|
438
|
1075
|
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2010-Today OpenERP SA (<http://www.openerp.com>)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>
#
##############################################################################
import invite
import mail_compose_message
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
agpl-3.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
4605,
199,
3,
199,
3,
259,
7653,
12,
3232,
5800,
8259,
9274,
199,
3,
259,
1898,
334,
35,
9,
7129,
13,
31982,
7653,
13950,
8642,
1014,
921,
1544,
14,
11267,
14,
957,
18956,
199,
3,
199,
3,
259,
961,
2240,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
259,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
199,
3,
259,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
844,
12,
503,
199,
3,
259,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
259,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
259,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
259,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
259,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
259,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
3,
259,
3180,
543,
642,
2240,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
3133,
199,
3,
199,
4605,
199,
199,
646,
24542,
199,
646,
6016,
63,
12607,
63,
1188,
199,
199,
3,
6695,
26,
10379,
26,
10558,
26,
6492,
29,
20,
26,
10503,
29,
20,
26,
10425,
29,
20,
26,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
4605,
199,
3,
199,
3,
259,
7653,
12,
3232,
5800,
8259,
9274,
199,
3,
259,
1898,
334,
35,
9,
7129,
13,
31982,
7653,
13950,
8642,
1014,
921,
1544,
14,
11267,
14,
957,
18956,
199,
3,
199,
3,
259,
961,
2240,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
259,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
199,
3,
259,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
844,
12,
503,
199,
3,
259,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
259,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
259,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
259,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
259,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
259,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
3,
259,
3180,
543,
642,
2240,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
3133,
199,
3,
199,
4605,
199,
199,
646,
24542,
199,
646,
6016,
63,
12607,
63,
1188,
199,
199,
3,
6695,
26,
10379,
26,
10558,
26,
6492,
29,
20,
26,
10503,
29,
20,
26,
10425,
29,
20,
26,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
hstau/covar-cryo
|
covariance/rotatefill.py
|
1
|
1524
|
'''function [out] = imrotateFill(inp, angle)
% function [out] = imrotateFill(inp)
% Rotates an 2D image couterclockwise by angle in degrees
% Output image has the same dimension as input.
% Undefined regions are filled in by repeating the original image
% Note: input images must be square
%
% Copyright (c) UWM, Peter Schwander Mar. 20, 2014
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
version = 'imrotateFill, V0.9';
Ported to python. Hstau Liao Oct. 2016
'''
import numpy as np
import logging,sys
import math
from scipy.ndimage.interpolation import rotate
import matplotlib.pyplot as plt
def op(input, angle, visual=False):
nPix = input.shape[0]
inpRep = np.tile(input, (3, 3))
outRep = rotate(inpRep, angle, reshape=False)
out = outRep[nPix:2 * nPix, nPix:2 * nPix]
if visual:
plt.subplot(2, 2, 1)
plt.imshow(input,cmap = plt.get_cmap('gray'))
plt.title('Input')
plt.subplot(2, 2, 2)
plt.imshow(out, cmap=plt.get_cmap('gray'))
plt.title('Output')
plt.subplot(2, 2, 3)
plt.imshow(inpRep, cmap=plt.get_cmap('gray'))
plt.title('Input 3x3')
plt.subplot(2, 2, 4)
plt.imshow(outRep, cmap=plt.get_cmap('gray'))
plt.title('Output 3x3')
plt.show()
return out
if __name__ == '__main__':
# tested using a 6x6 image
img = np.loadtxt(sys.argv[1])
ang = float(sys.argv[2]) # in degrees
visual = bool(sys.argv[3])
result = op(img,ang,visual)
|
gpl-2.0
|
[
2344,
1593,
359,
548,
61,
275,
3416,
12873,
12914,
8,
11416,
12,
9324,
9,
199,
5,
805,
221,
359,
548,
61,
275,
3416,
12873,
12914,
8,
11416,
9,
199,
5,
20423,
2335,
376,
499,
36,
1834,
512,
2699,
9597,
2605,
701,
9324,
315,
14358,
199,
5,
7242,
1834,
965,
314,
2011,
6240,
465,
1324,
14,
199,
5,
25868,
16150,
787,
13457,
315,
701,
6375,
1958,
314,
3379,
1834,
199,
5,
3390,
26,
1324,
5935,
1471,
506,
12386,
199,
5,
199,
5,
1898,
334,
67,
9,
738,
13073,
12,
22912,
22985,
87,
11438,
16794,
14,
3388,
12,
6927,
199,
8530,
8530,
8530,
8530,
8530,
8530,
8530,
8530,
8530,
8530,
8530,
8530,
8530,
8530,
8530,
8530,
8530,
8530,
8530,
8530,
8530,
8530,
8530,
8530,
8530,
8530,
8530,
8530,
8530,
8530,
8530,
8530,
8530,
8530,
8530,
8530,
8530,
8530,
8530,
5,
199,
1023,
275,
283,
1017,
12873,
12914,
12,
812,
16,
14,
25,
13619,
199,
199,
48,
1376,
370,
2366,
14,
869,
1207,
85,
491,
18939,
18365,
14,
7800,
199,
2344,
199,
199,
646,
2680,
465,
980,
199,
646,
2050,
12,
1274,
199,
646,
3473,
199,
504,
7026,
14,
78,
23335,
14,
21080,
492,
20071,
199,
646,
8027,
14,
13563,
465,
4488,
199,
199,
318,
1687,
8,
1210,
12,
9324,
12,
13104,
29,
797,
304,
272,
302,
25747,
275,
1324,
14,
1392,
59,
16,
61,
272,
10702,
6875,
275,
980,
14,
7172,
8,
1210,
12,
334,
19,
12,
650,
430,
272,
734,
6875,
275,
20071,
8,
11416,
6875,
12,
9324,
12,
21460,
29,
797,
9,
272,
734,
275,
734,
6875,
59,
78,
25747,
26,
18,
627,
302,
25747,
12,
302,
25747,
26,
18,
627,
302,
25747,
61,
339,
340,
13104,
26,
267,
4488,
14,
13334,
8,
18,
12,
499,
12,
413,
9,
267,
4488,
14,
20413,
8,
1210,
12,
16513,
275,
4488,
14,
362,
63,
16513,
360,
12150,
1333,
267,
4488,
14,
1213,
360,
3205,
358,
267,
4488,
14,
13334,
8,
18,
12,
499,
12,
499,
9,
267,
4488,
14,
20413,
8,
548,
12,
14920,
29,
6003,
14,
362,
63,
16513,
360,
12150,
1333,
267,
4488,
14,
1213,
360,
2959,
358,
267,
4488,
14,
13334,
8,
18,
12,
499,
12,
650,
9,
267,
4488,
14,
20413,
8,
11416,
6875,
12,
14920,
29,
6003,
14,
362,
63,
16513,
360,
12150,
1333,
267,
4488,
14,
1213,
360,
3205,
650,
88,
19,
358,
267,
4488,
14,
13334,
8,
18,
12,
499,
12,
841,
9,
267,
4488,
14,
20413,
8,
548,
6875,
12,
14920,
29,
6003,
14,
362,
63,
16513,
360,
12150,
1333,
267,
4488,
14,
1213,
360,
2959,
650,
88,
19,
358,
267,
4488,
14,
2384,
342,
272,
372,
734,
199,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
339,
327,
12470,
1808,
282,
1227,
88,
22,
1834,
272,
6050,
275,
980,
14,
27992,
8,
1274,
14,
3020,
59,
17,
566,
272,
14550,
275,
2069,
8,
1274,
14,
3020,
59,
18,
566,
327,
315,
14358,
272,
13104,
275,
2155,
8,
1274,
14,
3020,
59,
19,
566,
272,
754,
275,
1687,
8,
4060,
12,
621,
12,
16948,
9,
4388,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1593,
359,
548,
61,
275,
3416,
12873,
12914,
8,
11416,
12,
9324,
9,
199,
5,
805,
221,
359,
548,
61,
275,
3416,
12873,
12914,
8,
11416,
9,
199,
5,
20423,
2335,
376,
499,
36,
1834,
512,
2699,
9597,
2605,
701,
9324,
315,
14358,
199,
5,
7242,
1834,
965,
314,
2011,
6240,
465,
1324,
14,
199,
5,
25868,
16150,
787,
13457,
315,
701,
6375,
1958,
314,
3379,
1834,
199,
5,
3390,
26,
1324,
5935,
1471,
506,
12386,
199,
5,
199,
5,
1898,
334,
67,
9,
738,
13073,
12,
22912,
22985,
87,
11438,
16794,
14,
3388,
12,
6927,
199,
8530,
8530,
8530,
8530,
8530,
8530,
8530,
8530,
8530,
8530,
8530,
8530,
8530,
8530,
8530,
8530,
8530,
8530,
8530,
8530,
8530,
8530,
8530,
8530,
8530,
8530,
8530,
8530,
8530,
8530,
8530,
8530,
8530,
8530,
8530,
8530,
8530,
8530,
8530,
5,
199,
1023,
275,
283,
1017,
12873,
12914,
12,
812,
16,
14,
25,
13619,
199,
199,
48,
1376,
370,
2366,
14,
869,
1207,
85,
491,
18939,
18365,
14,
7800,
199,
2344,
199,
199,
646,
2680,
465,
980,
199,
646,
2050,
12,
1274,
199,
646,
3473,
199,
504,
7026,
14,
78,
23335,
14,
21080,
492,
20071,
199,
646,
8027,
14,
13563,
465,
4488,
199,
199,
318,
1687,
8,
1210,
12,
9324,
12,
13104,
29,
797,
304,
272,
302,
25747,
275,
1324,
14,
1392,
59,
16,
61,
272,
10702,
6875,
275,
980,
14,
7172,
8,
1210,
12,
334,
19,
12,
650,
430,
272,
734,
6875,
275,
20071,
8,
11416,
6875,
12,
9324,
12,
21460,
29,
797,
9,
272,
734,
275,
734,
6875,
59,
78,
25747,
26,
18,
627,
302,
25747,
12,
302,
25747,
26,
18,
627,
302,
25747,
61,
339,
340,
13104,
26,
267,
4488,
14,
13334,
8,
18,
12,
499,
12,
413,
9,
267,
4488,
14,
20413,
8,
1210,
12,
16513,
275,
4488,
14,
362,
63,
16513,
360,
12150,
1333,
267,
4488,
14,
1213,
360,
3205,
358,
267,
4488,
14,
13334,
8,
18,
12,
499,
12,
499,
9,
267,
4488,
14,
20413,
8,
548,
12,
14920,
29,
6003,
14,
362,
63,
16513,
360,
12150,
1333,
267,
4488,
14,
1213,
360,
2959,
358,
267,
4488,
14,
13334,
8,
18,
12,
499,
12,
650,
9,
267,
4488,
14,
20413,
8,
11416,
6875,
12,
14920,
29,
6003,
14,
362,
63,
16513,
360,
12150,
1333,
267,
4488,
14,
1213,
360,
3205,
650,
88,
19,
358,
267,
4488,
14,
13334,
8,
18,
12,
499,
12,
841,
9,
267,
4488,
14,
20413,
8,
548,
6875,
12,
14920,
29,
6003,
14,
362,
63,
16513,
360,
12150,
1333,
267,
4488,
14,
1213,
360,
2959,
650,
88,
19,
358,
267,
4488,
14,
2384,
342,
272,
372,
734,
199,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
339,
327,
12470,
1808,
282,
1227,
88,
22,
1834,
272,
6050,
275,
980,
14,
27992,
8,
1274,
14,
3020,
59,
17,
566,
272,
14550,
275,
2069,
8,
1274,
14,
3020,
59,
18,
566,
327,
315,
14358,
272,
13104,
275,
2155,
8,
1274,
14,
3020,
59,
19,
566,
272,
754,
275,
1687,
8,
4060,
12,
621,
12,
16948,
9,
4388,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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udstack/cs_instance.py
|
22
|
36186
|
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# (c) 2015, René Moser <mail@renemoser.net>
#
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
DOCUMENTATION = '''
---
module: cs_instance
short_description: Manages instances and virtual machines on Apache CloudStack based clouds.
description:
- Deploy, start, update, scale, restart, restore, stop and destroy instances.
version_added: '2.0'
author: "René Moser (@resmo)"
options:
name:
description:
- Host name of the instance. C(name) can only contain ASCII letters.
- Name will be generated (UUID) by CloudStack if not specified and can not be changed afterwards.
- Either C(name) or C(display_name) is required.
required: false
default: null
display_name:
description:
- Custom display name of the instances.
- Display name will be set to C(name) if not specified.
- Either C(name) or C(display_name) is required.
required: false
default: null
group:
description:
- Group in where the new instance should be in.
required: false
default: null
state:
description:
- State of the instance.
required: false
default: 'present'
choices: [ 'deployed', 'started', 'stopped', 'restarted', 'restored', 'destroyed', 'expunged', 'present', 'absent' ]
service_offering:
description:
- Name or id of the service offering of the new instance.
- If not set, first found service offering is used.
required: false
default: null
cpu:
description:
- The number of CPUs to allocate to the instance, used with custom service offerings
required: false
default: null
cpu_speed:
description:
- The clock speed/shares allocated to the instance, used with custom service offerings
required: false
default: null
memory:
description:
- The memory allocated to the instance, used with custom service offerings
required: false
default: null
template:
description:
- Name or id of the template to be used for creating the new instance.
- Required when using C(state=present).
- Mutually exclusive with C(ISO) option.
required: false
default: null
iso:
description:
- Name or id of the ISO to be used for creating the new instance.
- Required when using C(state=present).
- Mutually exclusive with C(template) option.
required: false
default: null
template_filter:
description:
- Name of the filter used to search for the template or iso.
- Used for params C(iso) or C(template) on C(state=present).
required: false
default: 'executable'
choices: [ 'featured', 'self', 'selfexecutable', 'sharedexecutable', 'executable', 'community' ]
aliases: [ 'iso_filter' ]
version_added: '2.1'
hypervisor:
description:
- Name the hypervisor to be used for creating the new instance.
- Relevant when using C(state=present), but only considered if not set on ISO/template.
- If not set or found on ISO/template, first found hypervisor will be used.
required: false
default: null
choices: [ 'KVM', 'VMware', 'BareMetal', 'XenServer', 'LXC', 'HyperV', 'UCS', 'OVM' ]
keyboard:
description:
- Keyboard device type for the instance.
required: false
default: null
choices: [ 'de', 'de-ch', 'es', 'fi', 'fr', 'fr-be', 'fr-ch', 'is', 'it', 'jp', 'nl-be', 'no', 'pt', 'uk', 'us' ]
networks:
description:
- List of networks to use for the new instance.
required: false
default: []
aliases: [ 'network' ]
ip_address:
description:
- IPv4 address for default instance's network during creation.
required: false
default: null
ip6_address:
description:
- IPv6 address for default instance's network.
required: false
default: null
ip_to_networks:
description:
- "List of mappings in the form {'network': NetworkName, 'ip': 1.2.3.4}"
- Mutually exclusive with C(networks) option.
required: false
default: null
aliases: [ 'ip_to_network' ]
disk_offering:
description:
- Name of the disk offering to be used.
required: false
default: null
disk_size:
description:
- Disk size in GByte required if deploying instance from ISO.
required: false
default: null
root_disk_size:
description:
- Root disk size in GByte required if deploying instance with KVM hypervisor and want resize the root disk size at startup (need CloudStack >= 4.4, cloud-initramfs-growroot installed and enabled in the template)
required: false
default: null
security_groups:
description:
- List of security groups the instance to be applied to.
required: false
default: null
aliases: [ 'security_group' ]
domain:
description:
- Domain the instance is related to.
required: false
default: null
account:
description:
- Account the instance is related to.
required: false
default: null
project:
description:
- Name of the project the instance to be deployed in.
required: false
default: null
zone:
description:
- Name of the zone in which the instance shoud be deployed.
- If not set, default zone is used.
required: false
default: null
ssh_key:
description:
- Name of the SSH key to be deployed on the new instance.
required: false
default: null
affinity_groups:
description:
- Affinity groups names to be applied to the new instance.
required: false
default: []
aliases: [ 'affinity_group' ]
user_data:
description:
- Optional data (ASCII) that can be sent to the instance upon a successful deployment.
- The data will be automatically base64 encoded.
- Consider switching to HTTP_POST by using C(CLOUDSTACK_METHOD=post) to increase the HTTP_GET size limit of 2KB to 32 KB.
required: false
default: null
force:
description:
- Force stop/start the instance if required to apply changes, otherwise a running instance will not be changed.
required: false
default: false
tags:
description:
- List of tags. Tags are a list of dictionaries having keys C(key) and C(value).
- "If you want to delete all tags, set a empty list e.g. C(tags: [])."
required: false
default: null
poll_async:
description:
- Poll async jobs until job has finished.
required: false
default: true
extends_documentation_fragment: cloudstack
'''
EXAMPLES = '''
# Create a instance from an ISO
# NOTE: Names of offerings and ISOs depending on the CloudStack configuration.
- local_action:
module: cs_instance
name: web-vm-1
iso: Linux Debian 7 64-bit
hypervisor: VMware
project: Integration
zone: ch-zrh-ix-01
service_offering: 1cpu_1gb
disk_offering: PerfPlus Storage
disk_size: 20
networks:
- Server Integration
- Sync Integration
- Storage Integration
# For changing a running instance, use the 'force' parameter
- local_action:
module: cs_instance
name: web-vm-1
display_name: web-vm-01.example.com
iso: Linux Debian 7 64-bit
service_offering: 2cpu_2gb
force: yes
# Create or update a instance on Exoscale's public cloud using display_name.
# Note: user_data can be used to kickstart the instance using cloud-init yaml config.
- local_action:
module: cs_instance
display_name: web-vm-1
template: Linux Debian 7 64-bit
service_offering: Tiny
ssh_key: john@example.com
tags:
- { key: admin, value: john }
- { key: foo, value: bar }
user_data: |
#cloud-config
packages:
- nginx
# Create an instance with multiple interfaces specifying the IP addresses
- local_action:
module: cs_instance
name: web-vm-1
template: Linux Debian 7 64-bit
service_offering: Tiny
ip_to_networks:
- {'network': NetworkA, 'ip': '10.1.1.1'}
- {'network': NetworkB, 'ip': '192.0.2.1'}
# Ensure an instance is stopped
- local_action: cs_instance name=web-vm-1 state=stopped
# Ensure an instance is running
- local_action: cs_instance name=web-vm-1 state=started
# Remove an instance
- local_action: cs_instance name=web-vm-1 state=absent
'''
RETURN = '''
---
id:
description: UUID of the instance.
returned: success
type: string
sample: 04589590-ac63-4ffc-93f5-b698b8ac38b6
name:
description: Name of the instance.
returned: success
type: string
sample: web-01
display_name:
description: Display name of the instance.
returned: success
type: string
sample: web-01
group:
description: Group name of the instance is related.
returned: success
type: string
sample: web
created:
description: Date of the instance was created.
returned: success
type: string
sample: 2014-12-01T14:57:57+0100
password_enabled:
description: True if password setting is enabled.
returned: success
type: boolean
sample: true
password:
description: The password of the instance if exists.
returned: success
type: string
sample: Ge2oe7Do
ssh_key:
description: Name of SSH key deployed to instance.
returned: success
type: string
sample: key@work
domain:
description: Domain the instance is related to.
returned: success
type: string
sample: example domain
account:
description: Account the instance is related to.
returned: success
type: string
sample: example account
project:
description: Name of project the instance is related to.
returned: success
type: string
sample: Production
default_ip:
description: Default IP address of the instance.
returned: success
type: string
sample: 10.23.37.42
public_ip:
description: Public IP address with instance via static NAT rule.
returned: success
type: string
sample: 1.2.3.4
iso:
description: Name of ISO the instance was deployed with.
returned: success
type: string
sample: Debian-8-64bit
template:
description: Name of template the instance was deployed with.
returned: success
type: string
sample: Debian-8-64bit
service_offering:
description: Name of the service offering the instance has.
returned: success
type: string
sample: 2cpu_2gb
zone:
description: Name of zone the instance is in.
returned: success
type: string
sample: ch-gva-2
state:
description: State of the instance.
returned: success
type: string
sample: Running
security_groups:
description: Security groups the instance is in.
returned: success
type: list
sample: '[ "default" ]'
affinity_groups:
description: Affinity groups the instance is in.
returned: success
type: list
sample: '[ "webservers" ]'
tags:
description: List of resource tags associated with the instance.
returned: success
type: dict
sample: '[ { "key": "foo", "value": "bar" } ]'
hypervisor:
description: Hypervisor related to this instance.
returned: success
type: string
sample: KVM
instance_name:
description: Internal name of the instance (ROOT admin only).
returned: success
type: string
sample: i-44-3992-VM
'''
import base64
# import cloudstack common
from ansible.module_utils.cloudstack import *
class AnsibleCloudStackInstance(AnsibleCloudStack):
def __init__(self, module):
super(AnsibleCloudStackInstance, self).__init__(module)
self.returns = {
'group': 'group',
'hypervisor': 'hypervisor',
'instancename': 'instance_name',
'publicip': 'public_ip',
'passwordenabled': 'password_enabled',
'password': 'password',
'serviceofferingname': 'service_offering',
'isoname': 'iso',
'templatename': 'template',
'keypair': 'ssh_key',
}
self.instance = None
self.template = None
self.iso = None
def get_service_offering_id(self):
service_offering = self.module.params.get('service_offering')
service_offerings = self.cs.listServiceOfferings()
if service_offerings:
if not service_offering:
return service_offerings['serviceoffering'][0]['id']
for s in service_offerings['serviceoffering']:
if service_offering in [ s['name'], s['id'] ]:
return s['id']
self.module.fail_json(msg="Service offering '%s' not found" % service_offering)
def get_template_or_iso(self, key=None):
template = self.module.params.get('template')
iso = self.module.params.get('iso')
if not template and not iso:
return None
args = {}
args['account'] = self.get_account(key='name')
args['domainid'] = self.get_domain(key='id')
args['projectid'] = self.get_project(key='id')
args['zoneid'] = self.get_zone(key='id')
args['isrecursive'] = True
if template:
if self.template:
return self._get_by_key(key, self.template)
args['templatefilter'] = self.module.params.get('template_filter')
templates = self.cs.listTemplates(**args)
if templates:
for t in templates['template']:
if template in [ t['displaytext'], t['name'], t['id'] ]:
self.template = t
return self._get_by_key(key, self.template)
self.module.fail_json(msg="Template '%s' not found" % template)
elif iso:
if self.iso:
return self._get_by_key(key, self.iso)
args['isofilter'] = self.module.params.get('template_filter')
isos = self.cs.listIsos(**args)
if isos:
for i in isos['iso']:
if iso in [ i['displaytext'], i['name'], i['id'] ]:
self.iso = i
return self._get_by_key(key, self.iso)
self.module.fail_json(msg="ISO '%s' not found" % iso)
def get_disk_offering_id(self):
disk_offering = self.module.params.get('disk_offering')
if not disk_offering:
return None
disk_offerings = self.cs.listDiskOfferings()
if disk_offerings:
for d in disk_offerings['diskoffering']:
if disk_offering in [ d['displaytext'], d['name'], d['id'] ]:
return d['id']
self.module.fail_json(msg="Disk offering '%s' not found" % disk_offering)
def get_instance(self):
instance = self.instance
if not instance:
instance_name = self.get_or_fallback('name', 'display_name')
args = {}
args['account'] = self.get_account(key='name')
args['domainid'] = self.get_domain(key='id')
args['projectid'] = self.get_project(key='id')
# Do not pass zoneid, as the instance name must be unique across zones.
instances = self.cs.listVirtualMachines(**args)
if instances:
for v in instances['virtualmachine']:
if instance_name.lower() in [ v['name'].lower(), v['displayname'].lower(), v['id'] ]:
self.instance = v
break
return self.instance
def get_iptonetwork_mappings(self):
network_mappings = self.module.params.get('ip_to_networks')
if network_mappings is None:
return
if network_mappings and self.module.params.get('networks'):
self.module.fail_json(msg="networks and ip_to_networks are mutually exclusive.")
network_names = [n['network'] for n in network_mappings]
ids = self.get_network_ids(network_names)
res = []
for i, data in enumerate(network_mappings):
res.append({'networkid': ids[i], 'ip': data['ip']})
return res
def security_groups_has_changed(self):
security_groups = self.module.params.get('security_groups')
if security_groups is None:
return False
security_groups = [s.lower() for s in security_groups]
instance_security_groups = self.instance.get('securitygroup',[])
instance_security_group_names = []
for instance_security_group in instance_security_groups:
if instance_security_group['name'].lower() not in security_groups:
return True
else:
instance_security_group_names.append(instance_security_group['name'].lower())
for security_group in security_groups:
if security_group not in instance_security_group_names:
return True
return False
def get_network_ids(self, network_names=None):
if network_names is None:
network_names = self.module.params.get('networks')
if not network_names:
return None
args = {}
args['account'] = self.get_account(key='name')
args['domainid'] = self.get_domain(key='id')
args['projectid'] = self.get_project(key='id')
args['zoneid'] = self.get_zone(key='id')
networks = self.cs.listNetworks(**args)
if not networks:
self.module.fail_json(msg="No networks available")
network_ids = []
network_displaytexts = []
for network_name in network_names:
for n in networks['network']:
if network_name in [ n['displaytext'], n['name'], n['id'] ]:
network_ids.append(n['id'])
network_displaytexts.append(n['name'])
break
if len(network_ids) != len(network_names):
self.module.fail_json(msg="Could not find all networks, networks list found: %s" % network_displaytexts)
return network_ids
def present_instance(self, start_vm=True):
instance = self.get_instance()
if not instance:
instance = self.deploy_instance(start_vm=start_vm)
else:
instance = self.recover_instance(instance=instance)
instance = self.update_instance(instance=instance, start_vm=start_vm)
# In check mode, we do not necessarely have an instance
if instance:
instance = self.ensure_tags(resource=instance, resource_type='UserVm')
# refresh instance data
self.instance = instance
return instance
def get_user_data(self):
user_data = self.module.params.get('user_data')
if user_data is not None:
user_data = base64.b64encode(str(user_data))
return user_data
def get_details(self):
res = None
cpu = self.module.params.get('cpu')
cpu_speed = self.module.params.get('cpu_speed')
memory = self.module.params.get('memory')
if all([cpu, cpu_speed, memory]):
res = [{
'cpuNumber': cpu,
'cpuSpeed': cpu_speed,
'memory': memory,
}]
return res
def deploy_instance(self, start_vm=True):
self.result['changed'] = True
networkids = self.get_network_ids()
if networkids is not None:
networkids = ','.join(networkids)
args = {}
args['templateid'] = self.get_template_or_iso(key='id')
if not args['templateid']:
self.module.fail_json(msg="Template or ISO is required.")
args['zoneid'] = self.get_zone(key='id')
args['serviceofferingid'] = self.get_service_offering_id()
args['account'] = self.get_account(key='name')
args['domainid'] = self.get_domain(key='id')
args['projectid'] = self.get_project(key='id')
args['diskofferingid'] = self.get_disk_offering_id()
args['networkids'] = networkids
args['iptonetworklist'] = self.get_iptonetwork_mappings()
args['userdata'] = self.get_user_data()
args['keyboard'] = self.module.params.get('keyboard')
args['ipaddress'] = self.module.params.get('ip_address')
args['ip6address'] = self.module.params.get('ip6_address')
args['name'] = self.module.params.get('name')
args['displayname'] = self.get_or_fallback('display_name', 'name')
args['group'] = self.module.params.get('group')
args['keypair'] = self.module.params.get('ssh_key')
args['size'] = self.module.params.get('disk_size')
args['startvm'] = start_vm
args['rootdisksize'] = self.module.params.get('root_disk_size')
args['affinitygroupnames'] = ','.join(self.module.params.get('affinity_groups'))
args['details'] = self.get_details()
security_groups = self.module.params.get('security_groups')
if security_groups is not None:
args['securitygroupnames'] = ','.join(security_groups)
template_iso = self.get_template_or_iso()
if 'hypervisor' not in template_iso:
args['hypervisor'] = self.get_hypervisor()
instance = None
if not self.module.check_mode:
instance = self.cs.deployVirtualMachine(**args)
if 'errortext' in instance:
self.module.fail_json(msg="Failed: '%s'" % instance['errortext'])
poll_async = self.module.params.get('poll_async')
if poll_async:
instance = self.poll_job(instance, 'virtualmachine')
return instance
def update_instance(self, instance, start_vm=True):
# Service offering data
args_service_offering = {}
args_service_offering['id'] = instance['id']
if self.module.params.get('service_offering'):
args_service_offering['serviceofferingid'] = self.get_service_offering_id()
service_offering_changed = self.has_changed(args_service_offering, instance)
# Instance data
args_instance_update = {}
args_instance_update['id'] = instance['id']
args_instance_update['userdata'] = self.get_user_data()
args_instance_update['ostypeid'] = self.get_os_type(key='id')
if self.module.params.get('group'):
args_instance_update['group'] = self.module.params.get('group')
if self.module.params.get('display_name'):
args_instance_update['displayname'] = self.module.params.get('display_name')
instance_changed = self.has_changed(args_instance_update, instance)
# SSH key data
args_ssh_key = {}
args_ssh_key['id'] = instance['id']
args_ssh_key['projectid'] = self.get_project(key='id')
if self.module.params.get('ssh_key'):
args_ssh_key['keypair'] = self.module.params.get('ssh_key')
ssh_key_changed = self.has_changed(args_ssh_key, instance)
security_groups_changed = self.security_groups_has_changed()
changed = [
service_offering_changed,
instance_changed,
security_groups_changed,
ssh_key_changed,
]
if True in changed:
force = self.module.params.get('force')
instance_state = instance['state'].lower()
if instance_state == 'stopped' or force:
self.result['changed'] = True
if not self.module.check_mode:
# Ensure VM has stopped
instance = self.stop_instance()
instance = self.poll_job(instance, 'virtualmachine')
self.instance = instance
# Change service offering
if service_offering_changed:
res = self.cs.changeServiceForVirtualMachine(**args_service_offering)
if 'errortext' in res:
self.module.fail_json(msg="Failed: '%s'" % res['errortext'])
instance = res['virtualmachine']
self.instance = instance
# Update VM
if instance_changed or security_groups_changed:
if security_groups_changed:
args_instance_update['securitygroupnames'] = ','.join(self.module.params.get('security_groups'))
res = self.cs.updateVirtualMachine(**args_instance_update)
if 'errortext' in res:
self.module.fail_json(msg="Failed: '%s'" % res['errortext'])
instance = res['virtualmachine']
self.instance = instance
# Reset SSH key
if ssh_key_changed:
instance = self.cs.resetSSHKeyForVirtualMachine(**args_ssh_key)
if 'errortext' in instance:
self.module.fail_json(msg="Failed: '%s'" % instance['errortext'])
instance = self.poll_job(instance, 'virtualmachine')
self.instance = instance
# Start VM again if it was running before
if instance_state == 'running' and start_vm:
instance = self.start_instance()
return instance
def recover_instance(self, instance):
if instance['state'].lower() in [ 'destroying', 'destroyed' ]:
self.result['changed'] = True
if not self.module.check_mode:
res = self.cs.recoverVirtualMachine(id=instance['id'])
if 'errortext' in res:
self.module.fail_json(msg="Failed: '%s'" % res['errortext'])
instance = res['virtualmachine']
return instance
def absent_instance(self):
instance = self.get_instance()
if instance:
if instance['state'].lower() not in ['expunging', 'destroying', 'destroyed']:
self.result['changed'] = True
if not self.module.check_mode:
res = self.cs.destroyVirtualMachine(id=instance['id'])
if 'errortext' in res:
self.module.fail_json(msg="Failed: '%s'" % res['errortext'])
poll_async = self.module.params.get('poll_async')
if poll_async:
instance = self.poll_job(res, 'virtualmachine')
return instance
def expunge_instance(self):
instance = self.get_instance()
if instance:
res = {}
if instance['state'].lower() in [ 'destroying', 'destroyed' ]:
self.result['changed'] = True
if not self.module.check_mode:
res = self.cs.destroyVirtualMachine(id=instance['id'], expunge=True)
elif instance['state'].lower() not in [ 'expunging' ]:
self.result['changed'] = True
if not self.module.check_mode:
res = self.cs.destroyVirtualMachine(id=instance['id'], expunge=True)
if res and 'errortext' in res:
self.module.fail_json(msg="Failed: '%s'" % res['errortext'])
poll_async = self.module.params.get('poll_async')
if poll_async:
res = self.poll_job(res, 'virtualmachine')
return instance
def stop_instance(self):
instance = self.get_instance()
# in check mode intance may not be instanciated
if instance:
if instance['state'].lower() in ['stopping', 'stopped']:
return instance
if instance['state'].lower() in ['starting', 'running']:
self.result['changed'] = True
if not self.module.check_mode:
instance = self.cs.stopVirtualMachine(id=instance['id'])
if 'errortext' in instance:
self.module.fail_json(msg="Failed: '%s'" % instance['errortext'])
poll_async = self.module.params.get('poll_async')
if poll_async:
instance = self.poll_job(instance, 'virtualmachine')
return instance
def start_instance(self):
instance = self.get_instance()
# in check mode intance may not be instanciated
if instance:
if instance['state'].lower() in ['starting', 'running']:
return instance
if instance['state'].lower() in ['stopped', 'stopping']:
self.result['changed'] = True
if not self.module.check_mode:
instance = self.cs.startVirtualMachine(id=instance['id'])
if 'errortext' in instance:
self.module.fail_json(msg="Failed: '%s'" % instance['errortext'])
poll_async = self.module.params.get('poll_async')
if poll_async:
instance = self.poll_job(instance, 'virtualmachine')
return instance
def restart_instance(self):
instance = self.get_instance()
# in check mode intance may not be instanciated
if instance:
if instance['state'].lower() in [ 'running', 'starting' ]:
self.result['changed'] = True
if not self.module.check_mode:
instance = self.cs.rebootVirtualMachine(id=instance['id'])
if 'errortext' in instance:
self.module.fail_json(msg="Failed: '%s'" % instance['errortext'])
poll_async = self.module.params.get('poll_async')
if poll_async:
instance = self.poll_job(instance, 'virtualmachine')
elif instance['state'].lower() in [ 'stopping', 'stopped' ]:
instance = self.start_instance()
return instance
def restore_instance(self):
instance = self.get_instance()
self.result['changed'] = True
# in check mode intance may not be instanciated
if instance:
args = {}
args['templateid'] = self.get_template_or_iso(key='id')
args['virtualmachineid'] = instance['id']
res = self.cs.restoreVirtualMachine(**args)
if 'errortext' in res:
self.module.fail_json(msg="Failed: '%s'" % res['errortext'])
poll_async = self.module.params.get('poll_async')
if poll_async:
instance = self.poll_job(res, 'virtualmachine')
return instance
def get_result(self, instance):
super(AnsibleCloudStackInstance, self).get_result(instance)
if instance:
if 'securitygroup' in instance:
security_groups = []
for securitygroup in instance['securitygroup']:
security_groups.append(securitygroup['name'])
self.result['security_groups'] = security_groups
if 'affinitygroup' in instance:
affinity_groups = []
for affinitygroup in instance['affinitygroup']:
affinity_groups.append(affinitygroup['name'])
self.result['affinity_groups'] = affinity_groups
if 'nic' in instance:
for nic in instance['nic']:
if nic['isdefault'] and 'ipaddress' in nic:
self.result['default_ip'] = nic['ipaddress']
return self.result
def main():
argument_spec = cs_argument_spec()
argument_spec.update(dict(
name = dict(default=None),
display_name = dict(default=None),
group = dict(default=None),
state = dict(choices=['present', 'deployed', 'started', 'stopped', 'restarted', 'restored', 'absent', 'destroyed', 'expunged'], default='present'),
service_offering = dict(default=None),
cpu = dict(default=None, type='int'),
cpu_speed = dict(default=None, type='int'),
memory = dict(default=None, type='int'),
template = dict(default=None),
iso = dict(default=None),
template_filter = dict(default="executable", aliases=['iso_filter'], choices=['featured', 'self', 'selfexecutable', 'sharedexecutable', 'executable', 'community']),
networks = dict(type='list', aliases=[ 'network' ], default=None),
ip_to_networks = dict(type='list', aliases=['ip_to_network'], default=None),
ip_address = dict(defaul=None),
ip6_address = dict(defaul=None),
disk_offering = dict(default=None),
disk_size = dict(type='int', default=None),
root_disk_size = dict(type='int', default=None),
keyboard = dict(choices=['de', 'de-ch', 'es', 'fi', 'fr', 'fr-be', 'fr-ch', 'is', 'it', 'jp', 'nl-be', 'no', 'pt', 'uk', 'us'], default=None),
hypervisor = dict(choices=CS_HYPERVISORS, default=None),
security_groups = dict(type='list', aliases=[ 'security_group' ], default=None),
affinity_groups = dict(type='list', aliases=[ 'affinity_group' ], default=[]),
domain = dict(default=None),
account = dict(default=None),
project = dict(default=None),
user_data = dict(default=None),
zone = dict(default=None),
ssh_key = dict(default=None),
force = dict(type='bool', default=False),
tags = dict(type='list', aliases=[ 'tag' ], default=None),
poll_async = dict(type='bool', default=True),
))
required_together = cs_required_together()
required_together.extend([
['cpu', 'cpu_speed', 'memory'],
])
module = AnsibleModule(
argument_spec=argument_spec,
required_together=required_together,
required_one_of = (
['display_name', 'name'],
),
mutually_exclusive = (
['template', 'iso'],
),
supports_check_mode=True
)
try:
acs_instance = AnsibleCloudStackInstance(module)
state = module.params.get('state')
if state in ['absent', 'destroyed']:
instance = acs_instance.absent_instance()
elif state in ['expunged']:
instance = acs_instance.expunge_instance()
elif state in ['restored']:
acs_instance.present_instance()
instance = acs_instance.restore_instance()
elif state in ['present', 'deployed']:
instance = acs_instance.present_instance()
elif state in ['stopped']:
acs_instance.present_instance(start_vm=False)
instance = acs_instance.stop_instance()
elif state in ['started']:
acs_instance.present_instance()
instance = acs_instance.start_instance()
elif state in ['restarted']:
acs_instance.present_instance()
instance = acs_instance.restart_instance()
if instance and 'state' in instance and instance['state'].lower() == 'error':
module.fail_json(msg="Instance named '%s' in error state." % module.params.get('name'))
result = acs_instance.get_result(instance)
except CloudStackException as e:
module.fail_json(msg='CloudStackException: %s' % str(e))
module.exit_json(**result)
# import module snippets
from ansible.module_utils.basic import *
if __name__ == '__main__':
main()
|
gpl-3.0
|
[
3381,
2647,
15,
1393,
15,
1548,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
199,
3,
334,
67,
9,
6900,
12,
10055,
5741,
3930,
332,
665,
1198,
32,
264,
685,
573,
332,
14,
846,
30,
199,
3,
199,
3,
961,
570,
365,
1777,
402,
2622,
199,
3,
199,
3,
2622,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
199,
3,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
844,
12,
503,
199,
3,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
2622,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
1666,
314,
199,
3,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
3,
3180,
543,
2622,
14,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
199,
8948,
275,
1449,
199,
2595,
199,
578,
26,
7117,
63,
842,
199,
3612,
63,
1802,
26,
21612,
4454,
436,
5791,
20601,
641,
3668,
8142,
4851,
4079,
2463,
14577,
14,
199,
1802,
26,
272,
446,
21588,
3374,
12,
1343,
12,
1678,
12,
4666,
12,
11004,
12,
9066,
12,
3631,
436,
11972,
4454,
14,
199,
1023,
63,
3270,
26,
283,
18,
14,
16,
7,
199,
2502,
26,
298,
5349,
5741,
3930,
332,
8593,
470,
573,
2924,
199,
1419,
26,
523,
536,
26,
272,
1369,
26,
489,
446,
10891,
536,
402,
314,
1256,
14,
445,
8,
354,
9,
883,
1454,
1395,
10485,
14435,
14,
489,
446,
2812,
911,
506,
4046,
334,
8757,
9,
701,
8142,
4851,
340,
440,
2013,
436,
883,
440,
506,
2896,
26982,
14,
489,
446,
13083,
445,
8,
354,
9,
503,
445,
8,
2918,
63,
354,
9,
365,
1415,
14,
272,
1415,
26,
3055,
272,
849,
26,
2973,
523,
2929,
63,
354,
26,
272,
1369,
26,
489,
446,
8388,
2929,
536,
402,
314,
4454,
14,
489,
446,
12175,
536,
911,
506,
663,
370,
445,
8,
354,
9,
340,
440,
2013,
14,
489,
446,
13083,
445,
8,
354,
9,
503,
445,
8,
2918,
63,
354,
9,
365,
1415,
14,
272,
1415,
26,
3055,
272,
849,
26,
2973,
523,
1572,
26,
272,
1369,
26,
489,
446,
5611,
315,
2382,
314,
892,
1256,
1077,
506,
315,
14,
272,
1415,
26,
3055,
272,
849,
26,
2973,
523,
1174,
26,
272,
1369,
26,
489,
446,
8511,
402,
314,
1256,
14,
272,
1415,
26,
3055,
272,
849,
26,
283,
1881,
7,
272,
3415,
26,
359,
283,
11060,
379,
297,
283,
8924,
297,
283,
14661,
297,
283,
3911,
5015,
297,
283,
3911,
2908,
297,
283,
7237,
379,
297,
283,
1474,
324,
3046,
297,
283,
1881,
297,
283,
5575,
7,
1622,
523,
2435,
63,
19501,
26,
272,
1369,
26,
489,
446,
2812,
503,
1305,
402,
314,
2435,
2331,
15663,
402,
314,
892,
1256,
14,
489,
446,
982,
440,
663,
12,
1642,
1911,
2435,
2331,
15663,
365,
1202,
14,
272,
1415,
26,
3055,
272,
849,
26,
2973,
523,
5033,
26,
272,
1369,
26,
489,
446,
710,
1329,
402,
28504,
370,
18310,
370,
314,
1256,
12,
1202,
543,
3537,
2435,
19793,
780,
272,
1415,
26,
3055,
272,
849,
26,
2973,
523,
5033,
63,
7625,
26,
272,
1369,
26,
489,
446,
710,
12516,
8112,
15,
18318,
17659,
370,
314,
1256,
12,
1202,
543,
3537,
2435,
19793,
780,
272,
1415,
26,
3055,
272,
849,
26,
2973,
523,
4402,
26,
272,
1369,
26,
489,
446,
710,
4402,
17659,
370,
314,
1256,
12,
1202,
543,
3537,
2435,
19793,
780,
272,
1415,
26,
3055,
272,
849,
26,
2973,
523,
1978,
26,
272,
1369,
26,
489,
446,
2812,
503,
1305,
402,
314,
1978,
370,
506,
1202,
367,
6425,
314,
892,
1256,
14,
489,
446,
11105,
1380,
1808,
445,
8,
929,
29,
1881,
680,
489,
446,
26550,
3163,
13914,
543,
445,
8,
7336,
9,
945,
14,
272,
1415,
26,
3055,
272,
849,
26,
2973,
523,
11601,
26,
272,
1369,
26,
489,
446,
2812,
503,
1305,
402,
314,
9055,
370,
506,
1202,
367,
6425,
314,
892,
1256,
14,
489,
446,
11105,
1380,
1808,
445,
8,
929,
29,
1881,
680,
489,
446,
26550,
3163,
13914,
543,
445,
8,
1160,
9,
945,
14,
272,
1415,
26,
3055,
272,
849,
26,
2973,
523,
1978,
63,
1541,
26,
272,
1369,
26,
489,
446,
2812,
402,
314,
2457,
1202,
370,
2754,
367,
314,
1978,
503,
11601,
14,
489,
446,
8051,
367,
1862,
445,
8,
4595,
9,
503,
445,
8,
1160,
9,
641,
445,
8,
929,
29,
1881,
680,
272,
1415,
26,
3055,
272,
849,
26,
283,
5904,
7,
272,
3415,
26,
359,
283,
30779,
297,
283,
277,
297,
283,
277,
5904,
297,
283,
6251,
731,
825,
2964,
297,
283,
5904,
297,
283,
9387,
7,
1622,
272,
5481,
26,
359,
283,
4595,
63,
1541,
7,
1622,
272,
1015,
63,
3270,
26,
283,
18,
14,
17,
7,
523,
21724,
26,
272,
1369,
26,
489,
446,
2812,
314,
21724,
370,
506,
1202,
367,
6425,
314,
892,
1256,
14,
489,
446,
799,
9723,
1380,
1808,
445,
8,
929,
29,
1881,
395,
1325,
1454,
8652,
340,
440,
663,
641,
9055,
15,
1160,
14,
489,
446,
982,
440,
663,
503,
1911,
641,
9055,
15,
1160,
12,
1642,
1911,
21724,
911,
506,
1202,
14,
272,
1415,
26,
3055,
272,
849,
26,
2973,
272,
3415,
26,
359,
283,
43,
6849,
297,
283,
6849,
1068,
297,
283,
34,
1530,
4015,
279,
297,
283,
30643,
3120,
297,
283,
44,
20770,
297,
283,
18727,
54,
297,
283,
21269,
297,
283,
47,
6849,
7,
1622,
523,
18716,
26,
272,
1369,
26,
489,
446,
2606,
3576,
2243,
730,
367,
314,
1256,
14,
272,
1415,
26,
3055,
272,
849,
26,
2973,
272,
3415,
26,
359,
283,
271,
297,
283,
271,
13,
335,
297,
283,
397,
297,
283,
329,
297,
283,
4391,
297,
283,
4391,
13,
1235,
297,
283,
4391,
13,
335,
297,
283,
374,
297,
283,
390,
297,
283,
11538,
297,
283,
7530,
13,
1235,
297,
283,
889,
297,
283,
541,
297,
283,
3210,
297
] |
[
2647,
15,
1393,
15,
1548,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
199,
3,
334,
67,
9,
6900,
12,
10055,
5741,
3930,
332,
665,
1198,
32,
264,
685,
573,
332,
14,
846,
30,
199,
3,
199,
3,
961,
570,
365,
1777,
402,
2622,
199,
3,
199,
3,
2622,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
199,
3,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
844,
12,
503,
199,
3,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
2622,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
1666,
314,
199,
3,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
3,
3180,
543,
2622,
14,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
199,
8948,
275,
1449,
199,
2595,
199,
578,
26,
7117,
63,
842,
199,
3612,
63,
1802,
26,
21612,
4454,
436,
5791,
20601,
641,
3668,
8142,
4851,
4079,
2463,
14577,
14,
199,
1802,
26,
272,
446,
21588,
3374,
12,
1343,
12,
1678,
12,
4666,
12,
11004,
12,
9066,
12,
3631,
436,
11972,
4454,
14,
199,
1023,
63,
3270,
26,
283,
18,
14,
16,
7,
199,
2502,
26,
298,
5349,
5741,
3930,
332,
8593,
470,
573,
2924,
199,
1419,
26,
523,
536,
26,
272,
1369,
26,
489,
446,
10891,
536,
402,
314,
1256,
14,
445,
8,
354,
9,
883,
1454,
1395,
10485,
14435,
14,
489,
446,
2812,
911,
506,
4046,
334,
8757,
9,
701,
8142,
4851,
340,
440,
2013,
436,
883,
440,
506,
2896,
26982,
14,
489,
446,
13083,
445,
8,
354,
9,
503,
445,
8,
2918,
63,
354,
9,
365,
1415,
14,
272,
1415,
26,
3055,
272,
849,
26,
2973,
523,
2929,
63,
354,
26,
272,
1369,
26,
489,
446,
8388,
2929,
536,
402,
314,
4454,
14,
489,
446,
12175,
536,
911,
506,
663,
370,
445,
8,
354,
9,
340,
440,
2013,
14,
489,
446,
13083,
445,
8,
354,
9,
503,
445,
8,
2918,
63,
354,
9,
365,
1415,
14,
272,
1415,
26,
3055,
272,
849,
26,
2973,
523,
1572,
26,
272,
1369,
26,
489,
446,
5611,
315,
2382,
314,
892,
1256,
1077,
506,
315,
14,
272,
1415,
26,
3055,
272,
849,
26,
2973,
523,
1174,
26,
272,
1369,
26,
489,
446,
8511,
402,
314,
1256,
14,
272,
1415,
26,
3055,
272,
849,
26,
283,
1881,
7,
272,
3415,
26,
359,
283,
11060,
379,
297,
283,
8924,
297,
283,
14661,
297,
283,
3911,
5015,
297,
283,
3911,
2908,
297,
283,
7237,
379,
297,
283,
1474,
324,
3046,
297,
283,
1881,
297,
283,
5575,
7,
1622,
523,
2435,
63,
19501,
26,
272,
1369,
26,
489,
446,
2812,
503,
1305,
402,
314,
2435,
2331,
15663,
402,
314,
892,
1256,
14,
489,
446,
982,
440,
663,
12,
1642,
1911,
2435,
2331,
15663,
365,
1202,
14,
272,
1415,
26,
3055,
272,
849,
26,
2973,
523,
5033,
26,
272,
1369,
26,
489,
446,
710,
1329,
402,
28504,
370,
18310,
370,
314,
1256,
12,
1202,
543,
3537,
2435,
19793,
780,
272,
1415,
26,
3055,
272,
849,
26,
2973,
523,
5033,
63,
7625,
26,
272,
1369,
26,
489,
446,
710,
12516,
8112,
15,
18318,
17659,
370,
314,
1256,
12,
1202,
543,
3537,
2435,
19793,
780,
272,
1415,
26,
3055,
272,
849,
26,
2973,
523,
4402,
26,
272,
1369,
26,
489,
446,
710,
4402,
17659,
370,
314,
1256,
12,
1202,
543,
3537,
2435,
19793,
780,
272,
1415,
26,
3055,
272,
849,
26,
2973,
523,
1978,
26,
272,
1369,
26,
489,
446,
2812,
503,
1305,
402,
314,
1978,
370,
506,
1202,
367,
6425,
314,
892,
1256,
14,
489,
446,
11105,
1380,
1808,
445,
8,
929,
29,
1881,
680,
489,
446,
26550,
3163,
13914,
543,
445,
8,
7336,
9,
945,
14,
272,
1415,
26,
3055,
272,
849,
26,
2973,
523,
11601,
26,
272,
1369,
26,
489,
446,
2812,
503,
1305,
402,
314,
9055,
370,
506,
1202,
367,
6425,
314,
892,
1256,
14,
489,
446,
11105,
1380,
1808,
445,
8,
929,
29,
1881,
680,
489,
446,
26550,
3163,
13914,
543,
445,
8,
1160,
9,
945,
14,
272,
1415,
26,
3055,
272,
849,
26,
2973,
523,
1978,
63,
1541,
26,
272,
1369,
26,
489,
446,
2812,
402,
314,
2457,
1202,
370,
2754,
367,
314,
1978,
503,
11601,
14,
489,
446,
8051,
367,
1862,
445,
8,
4595,
9,
503,
445,
8,
1160,
9,
641,
445,
8,
929,
29,
1881,
680,
272,
1415,
26,
3055,
272,
849,
26,
283,
5904,
7,
272,
3415,
26,
359,
283,
30779,
297,
283,
277,
297,
283,
277,
5904,
297,
283,
6251,
731,
825,
2964,
297,
283,
5904,
297,
283,
9387,
7,
1622,
272,
5481,
26,
359,
283,
4595,
63,
1541,
7,
1622,
272,
1015,
63,
3270,
26,
283,
18,
14,
17,
7,
523,
21724,
26,
272,
1369,
26,
489,
446,
2812,
314,
21724,
370,
506,
1202,
367,
6425,
314,
892,
1256,
14,
489,
446,
799,
9723,
1380,
1808,
445,
8,
929,
29,
1881,
395,
1325,
1454,
8652,
340,
440,
663,
641,
9055,
15,
1160,
14,
489,
446,
982,
440,
663,
503,
1911,
641,
9055,
15,
1160,
12,
1642,
1911,
21724,
911,
506,
1202,
14,
272,
1415,
26,
3055,
272,
849,
26,
2973,
272,
3415,
26,
359,
283,
43,
6849,
297,
283,
6849,
1068,
297,
283,
34,
1530,
4015,
279,
297,
283,
30643,
3120,
297,
283,
44,
20770,
297,
283,
18727,
54,
297,
283,
21269,
297,
283,
47,
6849,
7,
1622,
523,
18716,
26,
272,
1369,
26,
489,
446,
2606,
3576,
2243,
730,
367,
314,
1256,
14,
272,
1415,
26,
3055,
272,
849,
26,
2973,
272,
3415,
26,
359,
283,
271,
297,
283,
271,
13,
335,
297,
283,
397,
297,
283,
329,
297,
283,
4391,
297,
283,
4391,
13,
1235,
297,
283,
4391,
13,
335,
297,
283,
374,
297,
283,
390,
297,
283,
11538,
297,
283,
7530,
13,
1235,
297,
283,
889,
297,
283,
541,
297,
283,
3210,
297,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
rudivs/TaxonLinker
|
taxonlinker.py
|
1
|
9916
|
#!/usr/bin/env python
from settings import *
import os.path, Tkinter, tkFont, tkFileDialog
import taxonutils
class TaxonLinker():
def __init__(self,root):
self.taxondict = DICTIONARY_FILE
self.nameslist = []
self.results = []
self.dictload = False
self.nmload = False
# options and format definitions
sans10px = tkFont.Font(family='Arial',size=-15)
button_opt = {'padx': 5, 'pady': 5, 'side': Tkinter.LEFT}
entry_opt = {'padx': 5, 'pady': 5, 'side': Tkinter.LEFT, 'fill': Tkinter.X,
'expand': 1}
self.ftypes=(('Text files', '*.txt'),('CSV files', '*.csv'),
('All files','*.*'))
# loading buttons frame
buttonframe = Tkinter.Frame(root)
Tkinter.Button(buttonframe,text='Load Dictionary',
command=self.load_dict).pack(**button_opt)
Tkinter.Button(buttonframe,text='Load Names',
command=self.load_names).pack(**button_opt)
buttonframe.pack(fill=Tkinter.X,expand=1)
# current taxon frame
taxonframe = Tkinter.Frame(root)
self.taxonentry = Tkinter.Text(taxonframe,width='110',height='2',
wrap='word',font=sans10px)
self.taxonentry.pack(**entry_opt)
Tkinter.Button(taxonframe,text='Check Updated Name',
command=self.check_updated).pack(**button_opt)
taxonframe.pack(fill=Tkinter.X,expand=1)
# select frame with buttons on the right
Tkinter.Label(root,text='Select correct taxon:').pack(side=Tkinter.TOP,
anchor=Tkinter.W,padx=5)
selectframe = Tkinter.Frame(root)
self.select = Tkinter.Listbox(selectframe,width=100,height=8,font=sans10px)
self.select.bind('<<ListboxSelect>>')
self.select.pack(side=Tkinter.LEFT,fill=Tkinter.BOTH,expand=1,
anchor=Tkinter.W,padx=5,pady=5)
buttonframe = Tkinter.Frame(selectframe)
self.savebtn = Tkinter.Button(buttonframe,text='Save',
state=Tkinter.DISABLED, command=self.save)
self.savebtn.pack(fill=Tkinter.BOTH,padx=5,pady=5)
self.skipbtn = Tkinter.Button(buttonframe,text='Skip',
state=Tkinter.DISABLED, command=self.skip)
self.skipbtn.pack(fill=Tkinter.BOTH,padx=5,pady=5)
buttonframe.pack(side=Tkinter.LEFT,padx=5,pady=5,anchor=Tkinter.W)
selectframe.pack(anchor=Tkinter.NW,fill=Tkinter.BOTH,expand=1)
# status bar at the bottom
self.status = Tkinter.Label(root,text='')
self.status.pack(side=Tkinter.LEFT,anchor=Tkinter.W,padx=5,pady=5)
# check if dictionary file exists, and if so, load it
if os.path.isfile(self.taxondict):
self.dictionary = taxonutils.TaxonIndex(self.taxondict)
self.dictload = True
# check if there's a current batch of names, and if so, load it
if os.path.isfile(CURRENT_BATCH):
with open(CURRENT_BATCH,'r') as f:
for line in f:
self.nameslist.append(line.strip())
self.nmload = True
self.readnext()
self.update_status()
def load_dict(self):
self.taxondict = tkFileDialog.askopenfilename(filetypes=self.ftypes,
title="Please select dictionary file")
if self.taxondict:
self.dictionary = taxonutils.TaxonIndex(self.taxondict)
self.dictload = True
self.update_status()
def load_names(self):
fn = tkFileDialog.askopenfilename(filetypes=self.ftypes,
title="Please select input names file")
if fn:
self.nameslist = []
with open(fn,'r') as f:
for line in f:
self.nameslist.append(line.rstrip('\n'))
self.nmload = True
self.readnext()
def check_updated(self):
self.process_taxon()
def save(self,taxon=''):
"""log current taxon to output file"""
# Todo: handle case when relatedResourceID field is not in the dictionary
if taxon == '':
taxon = self.results[int(self.select.curselection()[0])]
if 'taxonomicStatus' in self.dictionary.taxonindex[taxon].keys():
if self.dictionary.taxonindex[taxon]['taxonomicStatus'].lower() == \
'synonym' and self.dictionary.taxonindex[taxon]\
['relatedResourceID'] != '':
# if it's a synonym, save the linked ID for the synonym
self.log(self.nameslist[0].strip()+FIELD_SEP+self.dictionary.\
taxonindex[taxon]['relatedResourceID'],OUTPUT_FILE)
if self.dictionary.taxonindex[taxon]['taxonomicStatus'].lower() not in \
['accepted','valid','synonym']:
# if the status is not valid or synonym, save it to work on separately
self.log(self.nameslist[0].strip()+FIELD_SEP+self.dictionary.\
taxonindex[taxon]['taxonID'],NOTVALID_FILE)
else:
# if it's not a synonym save the ID
self.log(self.nameslist[0].strip()+FIELD_SEP+self.dictionary.\
taxonindex[taxon]['taxonID'],OUTPUT_FILE)
else:
# if there's no taxonomicStatus field, just save the taxonID
self.log(self.nameslist[0].strip()+FIELD_SEP+self.dictionary.\
taxonindex[taxon]['taxonID'],OUTPUT_FILE)
self.skip('save')
def skip(self,reason='button'):
"""Log skipped name with reason, and move to the next record."""
if reason == 'genus':
self.log(self.nameslist[0].strip()+" (couldn't find genus)",LOGFILE)
elif reason == 'button':
self.log(self.nameslist[0].strip()+" (skip button)",LOGFILE)
if len(self.nameslist) > 1:
self.nameslist = self.nameslist[1:]
self.taxonentry.delete('1.0','end')
self.taxonentry.insert('1.0',self.nameslist[0].strip())
self.readnext()
else:
self.nameslist = []
self.taxonentry.delete('1.0','end')
self.taxonentry.insert('1.0','No more unmatched names.')
self.savebtn.configure(state=Tkinter.DISABLED)
self.skipbtn.configure(state=Tkinter.DISABLED)
self.nmload = False
def update_status(self):
"""Update the status bar."""
if not self.dictload and not self.nmload:
self.status.configure(text="Dictionary not loaded; Names not loaded.")
elif self.dictload and not self.nmload:
s = '{:,}'.format(len(self.dictionary.taxonindex))
self.status.configure(text="Dictionary loaded with %s taxa; Names not "
"loaded." % s)
elif not self.dictload and self.nmload:
s = '{:,}'.format(len(self.nameslist))
self.status.configure(text="Dictionary not loaded; %s names remaining to "
"process." % s)
elif self.dictload and self.nmload:
self.savebtn.configure(state=Tkinter.NORMAL)
self.skipbtn.configure(state=Tkinter.NORMAL)
s = ('{:,}'.format(len(self.dictionary.taxonindex)),
'{:,}'.format(len(self.nameslist)))
self.status.configure(text="Dictionary loaded with %s taxa; %s names "
"remaining to process." % s)
else:
self.status.configure(text="Error updating status.")
def log(self,s,f):
"""Driver for writing text to a specified log file."""
d = os.path.dirname(f)
if not os.path.exists(d) and not d=='':
os.makedirs(d)
open(f, 'a+').writelines(s.strip() + '\n')
def process_taxon(self):
"""Uses certainty cutoff levels to automatically skip or match taxa, and
ask the user if uncertain.
"""
self.select.delete(0,'end')
#First look for genus match to speed up performance
genus = self.dictionary.matchgenera(self.taxonentry.get('1.0','end'),
1,GENUS_CUTOFF)
if len(genus) > 0:
self.results = self.dictionary.matchtaxa(self.taxonentry.get('1.0','end'),
genus[0],8,FUZZY_CUTOFF)
if len(self.results) > 0:
# if first match is good enough, save automatically, else wait for user
# to skip or select and save.
if taxonutils.ratio(self.taxonentry.get('1.0','end'),
self.results[0]) >= PERFECT_CUTOFF:
self.select.select_set(0)
self.log(self.nameslist[0].strip() + " -> " + self.results[0],AUTOLOG)
self.save(self.results[0])
else:
for taxon in self.results:
if 'taxonomicStatus' in self.dictionary.taxonindex[taxon].keys():
if self.dictionary.taxonindex[taxon]['taxonomicStatus'].lower()\
in ['current', 'valid']:
self.select.insert('end',taxon)
elif self.dictionary.taxonindex[taxon]['taxonomicStatus'].lower()\
== 'synonym' and self.dictionary.taxonindex[taxon]\
['relatedResourceID'] != '':
synonym = self.dictionary.idindex[self.dictionary.\
taxonindex[taxon]['relatedResourceID']]['scientificName']
self.select.insert('end',"*" + taxon + " = " + synonym)
else:
self.select.insert('end',"*" + taxon + " (not current)")
else:
self.select.insert('end',taxon)
self.select.select_set(0)
else:
self.skip('genus')
def readnext(self):
"""Load the next name to be processed."""
if self.nameslist is not None and len(self.nameslist) > 0:
self.taxonentry.delete('1.0','end')
self.taxonentry.insert('1.0',self.nameslist[0])
self.process_taxon()
self.update_status()
else:
raise TypeError("No names to process.")
def on_exit(self):
"""Write current file on exit."""
if len(self.nameslist)>0:
with open(CURRENT_BATCH,'w+') as f:
for n in self.nameslist:
f.write(n+'\n')
root.destroy()
else:
try:
os.remove(CURRENT_BATCH)
except OSError:
pass
root.destroy()
if __name__=='__main__':
root = Tkinter.Tk()
root.wm_title("Taxon Linker")
myapp = TaxonLinker(root)
root.protocol("WM_DELETE_WINDOW", myapp.on_exit)
root.mainloop()
|
mit
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
199,
504,
2202,
492,
627,
199,
646,
747,
14,
515,
12,
16826,
12,
10157,
6986,
12,
10157,
25213,
199,
646,
9067,
265,
1208,
421,
199,
533,
30174,
265,
3834,
281,
837,
819,
347,
636,
826,
721,
277,
12,
1231,
304,
2043,
272,
291,
14,
5530,
265,
807,
275,
577,
6196,
1075,
4392,
63,
3817,
272,
291,
14,
1247,
513,
275,
942,
272,
291,
14,
2604,
275,
942,
272,
291,
14,
807,
912,
275,
756,
272,
291,
14,
10756,
912,
275,
756,
2286,
327,
1511,
436,
1475,
10269,
272,
308,
796,
709,
5326,
275,
10157,
6986,
14,
6986,
8,
6606,
534,
33,
1383,
297,
890,
4022,
1046,
9,
272,
5528,
63,
2992,
275,
791,
6226,
88,
356,
959,
12,
283,
6226,
89,
356,
959,
12,
283,
2441,
356,
16826,
14,
9894,
93,
272,
2397,
63,
2992,
275,
791,
6226,
88,
356,
959,
12,
283,
6226,
89,
356,
959,
12,
283,
2441,
356,
16826,
14,
9894,
12,
283,
4498,
356,
16826,
14,
56,
12,
20169,
283,
4441,
356,
413,
93,
272,
291,
14,
70,
1313,
2687,
360,
1872,
1584,
297,
11937,
2424,
8157,
19018,
1584,
297,
11937,
4737,
659,
326,
661,
2422,
1584,
1673,
10,
2795,
1333,
2286,
327,
8697,
15766,
2787,
272,
5528,
1943,
275,
16826,
14,
3160,
8,
1231,
9,
272,
16826,
14,
4259,
8,
3887,
1943,
12,
505,
534,
6200,
11932,
297,
673,
1414,
29,
277,
14,
912,
63,
807,
680,
1389,
3682,
3887,
63,
2992,
9,
272,
16826,
14,
4259,
8,
3887,
1943,
12,
505,
534,
6200,
23923,
297,
718,
1414,
29,
277,
14,
912,
63,
1247,
680,
1389,
3682,
3887,
63,
2992,
9,
272,
5528,
1943,
14,
1389,
8,
4498,
29,
15189,
1058,
14,
56,
12,
4441,
29,
17,
9,
2286,
327,
1453,
9067,
265,
2787,
272,
9067,
265,
1943,
275,
16826,
14,
3160,
8,
1231,
9,
272,
291,
14,
5530,
265,
2373,
275,
16826,
14,
1872,
8,
5530,
265,
1943,
12,
2063,
534,
6019,
297,
3333,
534,
18,
297,
3521,
4816,
534,
1027,
297,
4246,
29,
26052,
709,
5326,
9,
272,
291,
14,
5530,
265,
2373,
14,
1389,
3682,
2373,
63,
2992,
9,
272,
16826,
14,
4259,
8,
5530,
265,
1943,
12,
505,
534,
1799,
6162,
68,
2812,
297,
673,
1414,
29,
277,
14,
1074,
63,
5334,
680,
1389,
3682,
3887,
63,
2992,
9,
272,
9067,
265,
1943,
14,
1389,
8,
4498,
29,
15189,
1058,
14,
56,
12,
4441,
29,
17,
9,
2286,
327,
3504,
2787,
543,
15766,
641,
314,
2451,
272,
16826,
14,
4314,
8,
1231,
12,
505,
534,
5446,
3211,
9067,
265,
26,
1959,
1389,
8,
2441,
29,
15189,
1058,
14,
11422,
12,
288,
12514,
29,
15189,
1058,
14,
55,
12,
6226,
88,
29,
21,
9,
272,
3504,
1943,
275,
16826,
14,
3160,
8,
1231,
9,
272,
291,
14,
2416,
275,
16826,
14,
1296,
1977,
8,
2416,
1943,
12,
2063,
29,
1960,
12,
3333,
29,
24,
12,
4246,
29,
26052,
709,
5326,
9,
272,
291,
14,
2416,
14,
3409,
4827,
28,
1296,
1977,
5446,
1140,
358,
272,
291,
14,
2416,
14,
1389,
8,
2441,
29,
15189,
1058,
14,
9894,
12,
4498,
29,
15189,
1058,
14,
28784,
12,
4441,
29,
17,
12,
2151,
12514,
29,
15189,
1058,
14,
55,
12,
6226,
88,
29,
21,
12,
6226,
89,
29,
21,
9,
272,
5528,
1943,
275,
16826,
14,
3160,
8,
2416,
1943,
9,
272,
291,
14,
2117,
9633,
275,
16826,
14,
4259,
8,
3887,
1943,
12,
505,
534,
8229,
297,
288,
1174,
29,
15189,
1058,
14,
16205,
12,
1414,
29,
277,
14,
2117,
9,
272,
291,
14,
2117,
9633,
14,
1389,
8,
4498,
29,
15189,
1058,
14,
28784,
12,
6226,
88,
29,
21,
12,
6226,
89,
29,
21,
9,
272,
291,
14,
2759,
9633,
275,
16826,
14,
4259,
8,
3887,
1943,
12,
505,
534,
7738,
297,
288,
1174,
29,
15189,
1058,
14,
16205,
12,
1414,
29,
277,
14,
2759,
9,
272,
291,
14,
2759,
9633,
14,
1389,
8,
4498,
29,
15189,
1058,
14,
28784,
12,
6226,
88,
29,
21,
12,
6226,
89,
29,
21,
9,
272,
5528,
1943,
14,
1389,
8,
2441,
29,
15189,
1058,
14,
9894,
12,
6226,
88,
29,
21,
12,
6226,
89,
29,
21,
12,
11498,
29,
15189,
1058,
14,
55,
9,
272,
3504,
1943,
14,
1389,
8,
11498,
29,
15189,
1058,
14,
23471,
12,
4498,
29,
15189,
1058,
14,
28784,
12,
4441,
29,
17,
9,
339,
327,
2004,
4681,
737,
314,
9048,
272,
291,
14,
1205,
275,
16826,
14,
4314,
8,
1231,
12,
505,
13275,
272,
291,
14,
1205,
14,
1389,
8,
2441,
29,
15189,
1058,
14,
9894,
12,
11498,
29,
15189,
1058,
14,
55,
12,
6226,
88,
29,
21,
12,
6226,
89,
29,
21,
9,
2286,
327,
1104,
340,
2600,
570,
3495,
12,
436,
340,
880,
12,
2248,
652,
272,
340,
747,
14,
515,
14,
6292,
8,
277,
14,
5530,
265,
807,
304,
489,
291,
14,
9086,
275,
9067,
265,
1208,
14,
26019,
265,
2681,
8,
277,
14,
5530,
265,
807,
9,
489,
291,
14,
807,
912,
275,
715,
2126,
272,
327,
1104,
340,
2337,
1159,
282,
1453,
3522,
402,
1561,
12,
436,
340,
880,
12,
2248,
652,
272,
340,
747,
14,
515,
14,
6292,
8,
14211,
63,
20813,
304,
489,
543,
1551,
8,
14211,
63,
20813,
2584,
82,
358,
465,
289,
26,
4960,
367,
1004,
315,
289,
26,
288,
291,
14,
1247,
513,
14,
740,
8,
604,
14,
1913,
1012,
489,
291,
14,
10756,
912,
275,
715,
489,
291,
14,
739,
2184,
342,
2286,
291,
14,
873,
63,
1205,
342,
2043,
819,
347,
2248,
63,
807,
8,
277,
304,
272,
291,
14,
5530,
265,
807,
275,
10157,
25213,
14,
813,
1490,
1501,
8,
493,
1313,
29,
277,
14,
70,
1313,
12,
267,
2538,
628,
8254,
3504,
2600,
570,
531,
272,
340,
291,
14,
5530,
265,
807,
26,
489,
291,
14,
9086,
275,
9067,
265,
1208,
14,
26019,
265,
2681,
8,
277,
14,
5530,
265,
807,
9,
489,
291,
14,
807,
912,
275,
715,
489,
291,
14,
873,
63,
1205,
342,
8410,
523,
347,
2248,
63,
1247,
8,
277,
304,
272,
4325,
275,
10157,
25213,
14,
813,
1490,
1501,
8,
493,
1313,
29,
277,
14,
70,
1313,
12,
267,
2538,
628,
8254,
3504,
1324,
1561,
570,
531,
272
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
199,
504,
2202,
492,
627,
199,
646,
747,
14,
515,
12,
16826,
12,
10157,
6986,
12,
10157,
25213,
199,
646,
9067,
265,
1208,
421,
199,
533,
30174,
265,
3834,
281,
837,
819,
347,
636,
826,
721,
277,
12,
1231,
304,
2043,
272,
291,
14,
5530,
265,
807,
275,
577,
6196,
1075,
4392,
63,
3817,
272,
291,
14,
1247,
513,
275,
942,
272,
291,
14,
2604,
275,
942,
272,
291,
14,
807,
912,
275,
756,
272,
291,
14,
10756,
912,
275,
756,
2286,
327,
1511,
436,
1475,
10269,
272,
308,
796,
709,
5326,
275,
10157,
6986,
14,
6986,
8,
6606,
534,
33,
1383,
297,
890,
4022,
1046,
9,
272,
5528,
63,
2992,
275,
791,
6226,
88,
356,
959,
12,
283,
6226,
89,
356,
959,
12,
283,
2441,
356,
16826,
14,
9894,
93,
272,
2397,
63,
2992,
275,
791,
6226,
88,
356,
959,
12,
283,
6226,
89,
356,
959,
12,
283,
2441,
356,
16826,
14,
9894,
12,
283,
4498,
356,
16826,
14,
56,
12,
20169,
283,
4441,
356,
413,
93,
272,
291,
14,
70,
1313,
2687,
360,
1872,
1584,
297,
11937,
2424,
8157,
19018,
1584,
297,
11937,
4737,
659,
326,
661,
2422,
1584,
1673,
10,
2795,
1333,
2286,
327,
8697,
15766,
2787,
272,
5528,
1943,
275,
16826,
14,
3160,
8,
1231,
9,
272,
16826,
14,
4259,
8,
3887,
1943,
12,
505,
534,
6200,
11932,
297,
673,
1414,
29,
277,
14,
912,
63,
807,
680,
1389,
3682,
3887,
63,
2992,
9,
272,
16826,
14,
4259,
8,
3887,
1943,
12,
505,
534,
6200,
23923,
297,
718,
1414,
29,
277,
14,
912,
63,
1247,
680,
1389,
3682,
3887,
63,
2992,
9,
272,
5528,
1943,
14,
1389,
8,
4498,
29,
15189,
1058,
14,
56,
12,
4441,
29,
17,
9,
2286,
327,
1453,
9067,
265,
2787,
272,
9067,
265,
1943,
275,
16826,
14,
3160,
8,
1231,
9,
272,
291,
14,
5530,
265,
2373,
275,
16826,
14,
1872,
8,
5530,
265,
1943,
12,
2063,
534,
6019,
297,
3333,
534,
18,
297,
3521,
4816,
534,
1027,
297,
4246,
29,
26052,
709,
5326,
9,
272,
291,
14,
5530,
265,
2373,
14,
1389,
3682,
2373,
63,
2992,
9,
272,
16826,
14,
4259,
8,
5530,
265,
1943,
12,
505,
534,
1799,
6162,
68,
2812,
297,
673,
1414,
29,
277,
14,
1074,
63,
5334,
680,
1389,
3682,
3887,
63,
2992,
9,
272,
9067,
265,
1943,
14,
1389,
8,
4498,
29,
15189,
1058,
14,
56,
12,
4441,
29,
17,
9,
2286,
327,
3504,
2787,
543,
15766,
641,
314,
2451,
272,
16826,
14,
4314,
8,
1231,
12,
505,
534,
5446,
3211,
9067,
265,
26,
1959,
1389,
8,
2441,
29,
15189,
1058,
14,
11422,
12,
288,
12514,
29,
15189,
1058,
14,
55,
12,
6226,
88,
29,
21,
9,
272,
3504,
1943,
275,
16826,
14,
3160,
8,
1231,
9,
272,
291,
14,
2416,
275,
16826,
14,
1296,
1977,
8,
2416,
1943,
12,
2063,
29,
1960,
12,
3333,
29,
24,
12,
4246,
29,
26052,
709,
5326,
9,
272,
291,
14,
2416,
14,
3409,
4827,
28,
1296,
1977,
5446,
1140,
358,
272,
291,
14,
2416,
14,
1389,
8,
2441,
29,
15189,
1058,
14,
9894,
12,
4498,
29,
15189,
1058,
14,
28784,
12,
4441,
29,
17,
12,
2151,
12514,
29,
15189,
1058,
14,
55,
12,
6226,
88,
29,
21,
12,
6226,
89,
29,
21,
9,
272,
5528,
1943,
275,
16826,
14,
3160,
8,
2416,
1943,
9,
272,
291,
14,
2117,
9633,
275,
16826,
14,
4259,
8,
3887,
1943,
12,
505,
534,
8229,
297,
288,
1174,
29,
15189,
1058,
14,
16205,
12,
1414,
29,
277,
14,
2117,
9,
272,
291,
14,
2117,
9633,
14,
1389,
8,
4498,
29,
15189,
1058,
14,
28784,
12,
6226,
88,
29,
21,
12,
6226,
89,
29,
21,
9,
272,
291,
14,
2759,
9633,
275,
16826,
14,
4259,
8,
3887,
1943,
12,
505,
534,
7738,
297,
288,
1174,
29,
15189,
1058,
14,
16205,
12,
1414,
29,
277,
14,
2759,
9,
272,
291,
14,
2759,
9633,
14,
1389,
8,
4498,
29,
15189,
1058,
14,
28784,
12,
6226,
88,
29,
21,
12,
6226,
89,
29,
21,
9,
272,
5528,
1943,
14,
1389,
8,
2441,
29,
15189,
1058,
14,
9894,
12,
6226,
88,
29,
21,
12,
6226,
89,
29,
21,
12,
11498,
29,
15189,
1058,
14,
55,
9,
272,
3504,
1943,
14,
1389,
8,
11498,
29,
15189,
1058,
14,
23471,
12,
4498,
29,
15189,
1058,
14,
28784,
12,
4441,
29,
17,
9,
339,
327,
2004,
4681,
737,
314,
9048,
272,
291,
14,
1205,
275,
16826,
14,
4314,
8,
1231,
12,
505,
13275,
272,
291,
14,
1205,
14,
1389,
8,
2441,
29,
15189,
1058,
14,
9894,
12,
11498,
29,
15189,
1058,
14,
55,
12,
6226,
88,
29,
21,
12,
6226,
89,
29,
21,
9,
2286,
327,
1104,
340,
2600,
570,
3495,
12,
436,
340,
880,
12,
2248,
652,
272,
340,
747,
14,
515,
14,
6292,
8,
277,
14,
5530,
265,
807,
304,
489,
291,
14,
9086,
275,
9067,
265,
1208,
14,
26019,
265,
2681,
8,
277,
14,
5530,
265,
807,
9,
489,
291,
14,
807,
912,
275,
715,
2126,
272,
327,
1104,
340,
2337,
1159,
282,
1453,
3522,
402,
1561,
12,
436,
340,
880,
12,
2248,
652,
272,
340,
747,
14,
515,
14,
6292,
8,
14211,
63,
20813,
304,
489,
543,
1551,
8,
14211,
63,
20813,
2584,
82,
358,
465,
289,
26,
4960,
367,
1004,
315,
289,
26,
288,
291,
14,
1247,
513,
14,
740,
8,
604,
14,
1913,
1012,
489,
291,
14,
10756,
912,
275,
715,
489,
291,
14,
739,
2184,
342,
2286,
291,
14,
873,
63,
1205,
342,
2043,
819,
347,
2248,
63,
807,
8,
277,
304,
272,
291,
14,
5530,
265,
807,
275,
10157,
25213,
14,
813,
1490,
1501,
8,
493,
1313,
29,
277,
14,
70,
1313,
12,
267,
2538,
628,
8254,
3504,
2600,
570,
531,
272,
340,
291,
14,
5530,
265,
807,
26,
489,
291,
14,
9086,
275,
9067,
265,
1208,
14,
26019,
265,
2681,
8,
277,
14,
5530,
265,
807,
9,
489,
291,
14,
807,
912,
275,
715,
489,
291,
14,
873,
63,
1205,
342,
8410,
523,
347,
2248,
63,
1247,
8,
277,
304,
272,
4325,
275,
10157,
25213,
14,
813,
1490,
1501,
8,
493,
1313,
29,
277,
14,
70,
1313,
12,
267,
2538,
628,
8254,
3504,
1324,
1561,
570,
531,
272,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
wkentaro/catkin_tools
|
catkin_tools/commands/catkin.py
|
4
|
8231
|
# Copyright 2014 Open Source Robotics Foundation, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import print_function
import argparse
import os
import pkg_resources
import sys
from catkin_tools.common import is_tty
from catkin_tools.config import get_verb_aliases
from catkin_tools.config import initialize_config
from catkin_tools.terminal_color import fmt
from catkin_tools.terminal_color import set_color
from catkin_tools.terminal_color import test_colors
CATKIN_COMMAND_VERB_GROUP = 'catkin_tools.commands.catkin.verbs'
def list_verbs():
verbs = []
for entry_point in pkg_resources.iter_entry_points(group=CATKIN_COMMAND_VERB_GROUP):
verbs.append(entry_point.name)
return verbs
def load_verb_description(verb_name):
for entry_point in pkg_resources.iter_entry_points(group=CATKIN_COMMAND_VERB_GROUP):
if entry_point.name == verb_name:
return entry_point.load()
def default_argument_preprocessor(args):
extras = {}
return args, extras
def create_subparsers(parser, verbs):
verbs = sorted(verbs)
verb_array_str = '[' + ' | '.join(verbs) + ']'
verb_list_str = 'Call `catkin VERB -h` for help on each verb listed below:\n'
for verb in verbs:
desc = load_verb_description(verb)
verb_list_str += '\n %s\t%s' % (desc['verb'], desc['description'])
subparser = parser.add_subparsers(
title='catkin command',
metavar=verb_array_str,
description=verb_list_str,
dest='verb'
)
argument_preprocessors = {}
for verb in verbs:
desc = load_verb_description(verb)
cmd_parser = subparser.add_parser(desc['verb'], description=desc['description'])
cmd_parser = desc['prepare_arguments'](cmd_parser)
cmd_parser.set_defaults(main=desc['main'])
if 'argument_preprocessor' in desc:
argument_preprocessors[verb] = desc['argument_preprocessor']
else:
argument_preprocessors[verb] = default_argument_preprocessor
return argument_preprocessors
def main(sysargs=None):
# Initialize config
try:
initialize_config()
except RuntimeError as exc:
sys.exit("Failed to initialize config: {0}".format(exc))
# Create a top level parser
parser = argparse.ArgumentParser(description="catkin command", formatter_class=argparse.RawDescriptionHelpFormatter)
add = parser.add_argument
add('-a', '--list-aliases', action="store_true", default=False,
help="Lists the current verb aliases and then quits, all other arguments are ignored")
add('--test-colors', action='store_true', default=False,
help="Prints a color test pattern to the screen and then quits, all other arguments are ignored")
color_control_group = parser.add_mutually_exclusive_group()
add = color_control_group.add_argument
add('--force-color', action='store_true', default=False,
help='Forces catkin to output in color, even when the terminal does not appear to support it.')
add('--no-color', action='store_true', default=False,
help='Forces catkin to not use color in the output, regardless of the detect terminal type.')
# Generate a list of verbs available
verbs = list_verbs()
# Create the subparsers for each verb and collect the argument preprocessors
argument_preprocessors = create_subparsers(parser, verbs)
# Get verb aliases
verb_aliases = get_verb_aliases()
# Setup sysargs
sysargs = sys.argv[1:] if sysargs is None else sysargs
cmd = os.path.basename(sys.argv[0])
# Get colors config
no_color = False
force_color = False
for arg in sysargs:
if arg == '--no-color':
no_color = True
if arg == '--force-color':
force_color = True
if no_color or not force_color and not is_tty(sys.stdout):
set_color(False)
# Check for --test-colors
for arg in sysargs:
if arg == '--test-colors':
test_colors()
sys.exit(0)
if not arg.startswith('-'):
break
# Check for --list-aliases
for arg in sysargs:
if arg == '--list-aliases' or arg == '-a':
for alias in sorted(list(verb_aliases.keys())):
print("{0}: {1}".format(alias, verb_aliases[alias]))
sys.exit(0)
if not arg.startswith('-'):
break
# Do alias expansion
expanding_verb_aliases = True
used_aliases = []
while expanding_verb_aliases:
expanding_verb_aliases = False
for index, arg in enumerate(sysargs):
if not arg.startswith('-'):
if arg in used_aliases:
print(fmt(
"@!@{gf}==>@| Expanding alias '@!@{yf}" +
arg +
"@|' was previously expanded, ignoring this time to prevent infinite recursion."
))
if arg in verb_aliases:
before = [] if index == 0 else sysargs[:index - 1]
after = [] if index == len(sysargs) else sysargs[index + 1:]
sysargs = before + verb_aliases[arg].split() + after
print(fmt(
"@!@{gf}==>@| Expanding alias "
"'@!@{yf}{alias}@|' "
"from '@{yf}{before} @!{alias}@{boldoff}{after}@|' "
"to '@{yf}{before} @!{expansion}@{boldoff}{after}@|'"
).format(
alias=arg,
expansion=verb_aliases[arg],
before=' '.join([cmd] + before),
after=(' '.join([''] + after) if after else '')
))
expanding_verb_aliases = True
# Prevent the alias from being used again, to prevent infinite recursion
used_aliases.append(arg)
del verb_aliases[arg]
break
# Determine the verb, splitting arguments into pre and post verb
verb = None
pre_verb_args = []
post_verb_args = []
for index, arg in enumerate(sysargs):
# If the arg does not start with a `-` then it is a positional argument
# The first positional argument must be the verb
if not arg.startswith('-'):
verb = arg
post_verb_args = sysargs[index + 1:]
break
# If the `-h` or `--help` option comes before the verb, parse_args
if arg in ['-h', '--help']:
parser.parse_args(sysargs)
# Otherwise it is a pre-verb option
pre_verb_args.append(arg)
# Error on no verb provided
if verb is None:
print(parser.format_usage())
sys.exit("Error: No verb provided.")
# Error on unknown verb provided
if verb not in verbs:
print(parser.format_usage())
sys.exit("Error: Unknown verb '{0}' provided.".format(verb))
# First allow the verb's argument preprocessor to strip any args
# and return any "extra" information it wants as a dict
processed_post_verb_args, extras = argument_preprocessors[verb](post_verb_args)
# Then allow argparse to process the left over post-verb arguments along
# with the pre-verb arguments and the verb itself
args = parser.parse_args(pre_verb_args + [verb] + processed_post_verb_args)
# Extend the argparse result with the extras from the preprocessor
for key, value in extras.items():
setattr(args, key, value)
# Finally call the subparser's main function with the processed args
# and the extras which the preprocessor may have returned
sys.exit(args.main(args) or 0)
|
apache-2.0
|
[
3,
1898,
6927,
3232,
5800,
6848,
656,
7769,
2752,
12,
3277,
14,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
3,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
3,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
258,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
199,
504,
636,
2443,
363,
492,
870,
63,
1593,
199,
199,
646,
7534,
199,
646,
747,
199,
646,
5496,
63,
4435,
199,
646,
984,
199,
199,
504,
6230,
19269,
63,
2537,
14,
2330,
492,
365,
63,
4707,
199,
199,
504,
6230,
19269,
63,
2537,
14,
888,
492,
664,
63,
17050,
63,
8602,
199,
504,
6230,
19269,
63,
2537,
14,
888,
492,
8265,
63,
888,
199,
199,
504,
6230,
19269,
63,
2537,
14,
12010,
63,
2326,
492,
7104,
199,
504,
6230,
19269,
63,
2537,
14,
12010,
63,
2326,
492,
663,
63,
2326,
199,
504,
6230,
19269,
63,
2537,
14,
12010,
63,
2326,
492,
511,
63,
7120,
199,
199,
11206,
43,
568,
63,
10761,
63,
2111,
34,
63,
7823,
275,
283,
3385,
19269,
63,
2537,
14,
4405,
14,
3385,
19269,
14,
422,
1533,
7,
421,
199,
318,
769,
63,
422,
1533,
837,
272,
809,
1533,
275,
942,
272,
367,
2397,
63,
1403,
315,
5496,
63,
4435,
14,
1661,
63,
2373,
63,
3438,
8,
923,
29,
11206,
43,
568,
63,
10761,
63,
2111,
34,
63,
7823,
304,
267,
809,
1533,
14,
740,
8,
2373,
63,
1403,
14,
354,
9,
272,
372,
809,
1533,
421,
199,
318,
2248,
63,
17050,
63,
1802,
8,
17050,
63,
354,
304,
272,
367,
2397,
63,
1403,
315,
5496,
63,
4435,
14,
1661,
63,
2373,
63,
3438,
8,
923,
29,
11206,
43,
568,
63,
10761,
63,
2111,
34,
63,
7823,
304,
267,
340,
2397,
63,
1403,
14,
354,
508,
16041,
63,
354,
26,
288,
372,
2397,
63,
1403,
14,
912,
342,
421,
199,
318,
849,
63,
2094,
63,
657,
6459,
8,
589,
304,
272,
13751,
275,
1052,
272,
372,
1249,
12,
13751,
421,
199,
318,
1218,
63,
954,
11531,
8,
2087,
12,
809,
1533,
304,
272,
809,
1533,
275,
3355,
8,
422,
1533,
9,
272,
16041,
63,
1144,
63,
495,
275,
22640,
435,
283,
1204,
1987,
904,
8,
422,
1533,
9,
435,
24840,
272,
16041,
63,
513,
63,
495,
275,
283,
2176,
658,
3385,
19269,
12348,
34,
446,
72,
64,
367,
1720,
641,
1924,
16041,
10532,
5084,
3427,
78,
7,
272,
367,
16041,
315,
809,
1533,
26,
267,
4328,
275,
2248,
63,
17050,
63,
1802,
8,
17050,
9,
267,
16041,
63,
513,
63,
495,
847,
1557,
78,
221,
450,
83,
60,
84,
5,
83,
7,
450,
334,
3257,
459,
17050,
995,
4328,
459,
1802,
1105,
339,
1007,
2087,
275,
1798,
14,
525,
63,
954,
11531,
8,
267,
2538,
534,
3385,
19269,
1414,
297,
267,
8214,
29,
17050,
63,
1144,
63,
495,
12,
267,
1369,
29,
17050,
63,
513,
63,
495,
12,
267,
2053,
534,
17050,
7,
272,
776,
339,
1423,
63,
657,
10547,
275,
1052,
339,
367,
16041,
315,
809,
1533,
26,
267,
4328,
275,
2248,
63,
17050,
63,
1802,
8,
17050,
9,
267,
2088,
63,
2087,
275,
1007,
2087,
14,
525,
63,
2087,
8,
3257,
459,
17050,
995,
1369,
29,
3257,
459,
1802,
1105,
267,
2088,
63,
2087,
275,
4328,
459,
6726,
63,
4958,
21407,
1760,
63,
2087,
9,
398,
2088,
63,
2087,
14,
409,
63,
4322,
8,
973,
29,
3257,
459,
973,
1105,
398,
340,
283,
2094,
63,
657,
6459,
7,
315,
4328,
26,
288,
1423,
63,
657,
10547,
59,
17050,
61,
275,
4328,
459,
2094,
63,
657,
6459,
418,
267,
587,
26,
288,
1423,
63,
657,
10547,
59,
17050,
61,
275,
849,
63,
2094,
63,
657,
6459,
339,
372,
1423,
63,
657,
10547,
421,
199,
318,
2446,
8,
1274,
589,
29,
403,
304,
272,
327,
11578,
1101,
272,
862,
26,
267,
8265,
63,
888,
342,
272,
871,
6064,
465,
3178,
26,
267,
984,
14,
2224,
480,
4276,
370,
8265,
1101,
26,
469,
16,
5469,
908,
8,
2804,
430,
339,
327,
2790,
282,
2746,
2166,
1798,
272,
1798,
275,
7534,
14,
10730,
8,
1802,
628,
3385,
19269,
1414,
401,
9698,
63,
533,
29,
18978,
14,
7963,
5831,
22779,
9,
272,
1050,
275,
1798,
14,
525,
63,
2094,
272,
1050,
3654,
65,
297,
2850,
513,
13,
8602,
297,
1595,
628,
1617,
63,
2052,
401,
849,
29,
797,
12,
267,
1720,
628,
15116,
314,
1453,
16041,
5481,
436,
2066,
2173,
1405,
12,
1006,
1163,
2368,
787,
5525,
531,
272,
1050,
4517,
396,
13,
7120,
297,
1595,
534,
1617,
63,
2052,
297,
849,
29,
797,
12,
267,
1720,
628,
26113,
282,
3164,
511,
3851,
370,
314,
6426,
436,
2066,
2173,
1405,
12,
1006,
1163,
2368,
787,
5525,
531,
272,
3164,
63,
2785,
63,
923,
275,
1798,
14,
525,
63,
25024,
63,
12730,
63,
923,
342,
272,
1050,
275,
3164,
63,
2785,
63,
923,
14,
525,
63,
2094,
272,
1050,
4517,
3990,
13,
2326,
297,
1595,
534,
1617,
63,
2052,
297,
849,
29,
797,
12,
267,
1720,
534,
1858,
823,
6230,
19269,
370,
1072,
315,
3164,
12,
2755,
1380,
314,
11167,
1630,
440,
7468,
370,
2291,
652,
2659,
272,
1050,
4517,
889,
13,
2326,
297,
1595,
534,
1617,
63,
2052,
297,
849,
29,
797,
12,
267,
1720,
534,
1858,
823,
6230,
19269,
370,
440,
675,
3164,
315,
314,
1072,
12,
15270,
402,
314,
9696,
11167,
730,
2659,
339,
327,
7958,
282,
769,
402,
809,
1533,
2808,
272,
809,
1533,
275,
769,
63,
422,
1533,
342,
339,
327,
2790,
314,
26763,
367,
1924,
16041,
436,
8775,
314,
1423,
876,
10547,
272,
1423,
63,
657,
10547,
275,
1218,
63,
954,
11531,
8,
2087,
12,
809,
1533,
9,
339,
327,
2372,
16041,
5481,
272
] |
[
1898,
6927,
3232,
5800,
6848,
656,
7769,
2752,
12,
3277,
14,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
3,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
3,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
258,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
199,
504,
636,
2443,
363,
492,
870,
63,
1593,
199,
199,
646,
7534,
199,
646,
747,
199,
646,
5496,
63,
4435,
199,
646,
984,
199,
199,
504,
6230,
19269,
63,
2537,
14,
2330,
492,
365,
63,
4707,
199,
199,
504,
6230,
19269,
63,
2537,
14,
888,
492,
664,
63,
17050,
63,
8602,
199,
504,
6230,
19269,
63,
2537,
14,
888,
492,
8265,
63,
888,
199,
199,
504,
6230,
19269,
63,
2537,
14,
12010,
63,
2326,
492,
7104,
199,
504,
6230,
19269,
63,
2537,
14,
12010,
63,
2326,
492,
663,
63,
2326,
199,
504,
6230,
19269,
63,
2537,
14,
12010,
63,
2326,
492,
511,
63,
7120,
199,
199,
11206,
43,
568,
63,
10761,
63,
2111,
34,
63,
7823,
275,
283,
3385,
19269,
63,
2537,
14,
4405,
14,
3385,
19269,
14,
422,
1533,
7,
421,
199,
318,
769,
63,
422,
1533,
837,
272,
809,
1533,
275,
942,
272,
367,
2397,
63,
1403,
315,
5496,
63,
4435,
14,
1661,
63,
2373,
63,
3438,
8,
923,
29,
11206,
43,
568,
63,
10761,
63,
2111,
34,
63,
7823,
304,
267,
809,
1533,
14,
740,
8,
2373,
63,
1403,
14,
354,
9,
272,
372,
809,
1533,
421,
199,
318,
2248,
63,
17050,
63,
1802,
8,
17050,
63,
354,
304,
272,
367,
2397,
63,
1403,
315,
5496,
63,
4435,
14,
1661,
63,
2373,
63,
3438,
8,
923,
29,
11206,
43,
568,
63,
10761,
63,
2111,
34,
63,
7823,
304,
267,
340,
2397,
63,
1403,
14,
354,
508,
16041,
63,
354,
26,
288,
372,
2397,
63,
1403,
14,
912,
342,
421,
199,
318,
849,
63,
2094,
63,
657,
6459,
8,
589,
304,
272,
13751,
275,
1052,
272,
372,
1249,
12,
13751,
421,
199,
318,
1218,
63,
954,
11531,
8,
2087,
12,
809,
1533,
304,
272,
809,
1533,
275,
3355,
8,
422,
1533,
9,
272,
16041,
63,
1144,
63,
495,
275,
22640,
435,
283,
1204,
1987,
904,
8,
422,
1533,
9,
435,
24840,
272,
16041,
63,
513,
63,
495,
275,
283,
2176,
658,
3385,
19269,
12348,
34,
446,
72,
64,
367,
1720,
641,
1924,
16041,
10532,
5084,
3427,
78,
7,
272,
367,
16041,
315,
809,
1533,
26,
267,
4328,
275,
2248,
63,
17050,
63,
1802,
8,
17050,
9,
267,
16041,
63,
513,
63,
495,
847,
1557,
78,
221,
450,
83,
60,
84,
5,
83,
7,
450,
334,
3257,
459,
17050,
995,
4328,
459,
1802,
1105,
339,
1007,
2087,
275,
1798,
14,
525,
63,
954,
11531,
8,
267,
2538,
534,
3385,
19269,
1414,
297,
267,
8214,
29,
17050,
63,
1144,
63,
495,
12,
267,
1369,
29,
17050,
63,
513,
63,
495,
12,
267,
2053,
534,
17050,
7,
272,
776,
339,
1423,
63,
657,
10547,
275,
1052,
339,
367,
16041,
315,
809,
1533,
26,
267,
4328,
275,
2248,
63,
17050,
63,
1802,
8,
17050,
9,
267,
2088,
63,
2087,
275,
1007,
2087,
14,
525,
63,
2087,
8,
3257,
459,
17050,
995,
1369,
29,
3257,
459,
1802,
1105,
267,
2088,
63,
2087,
275,
4328,
459,
6726,
63,
4958,
21407,
1760,
63,
2087,
9,
398,
2088,
63,
2087,
14,
409,
63,
4322,
8,
973,
29,
3257,
459,
973,
1105,
398,
340,
283,
2094,
63,
657,
6459,
7,
315,
4328,
26,
288,
1423,
63,
657,
10547,
59,
17050,
61,
275,
4328,
459,
2094,
63,
657,
6459,
418,
267,
587,
26,
288,
1423,
63,
657,
10547,
59,
17050,
61,
275,
849,
63,
2094,
63,
657,
6459,
339,
372,
1423,
63,
657,
10547,
421,
199,
318,
2446,
8,
1274,
589,
29,
403,
304,
272,
327,
11578,
1101,
272,
862,
26,
267,
8265,
63,
888,
342,
272,
871,
6064,
465,
3178,
26,
267,
984,
14,
2224,
480,
4276,
370,
8265,
1101,
26,
469,
16,
5469,
908,
8,
2804,
430,
339,
327,
2790,
282,
2746,
2166,
1798,
272,
1798,
275,
7534,
14,
10730,
8,
1802,
628,
3385,
19269,
1414,
401,
9698,
63,
533,
29,
18978,
14,
7963,
5831,
22779,
9,
272,
1050,
275,
1798,
14,
525,
63,
2094,
272,
1050,
3654,
65,
297,
2850,
513,
13,
8602,
297,
1595,
628,
1617,
63,
2052,
401,
849,
29,
797,
12,
267,
1720,
628,
15116,
314,
1453,
16041,
5481,
436,
2066,
2173,
1405,
12,
1006,
1163,
2368,
787,
5525,
531,
272,
1050,
4517,
396,
13,
7120,
297,
1595,
534,
1617,
63,
2052,
297,
849,
29,
797,
12,
267,
1720,
628,
26113,
282,
3164,
511,
3851,
370,
314,
6426,
436,
2066,
2173,
1405,
12,
1006,
1163,
2368,
787,
5525,
531,
272,
3164,
63,
2785,
63,
923,
275,
1798,
14,
525,
63,
25024,
63,
12730,
63,
923,
342,
272,
1050,
275,
3164,
63,
2785,
63,
923,
14,
525,
63,
2094,
272,
1050,
4517,
3990,
13,
2326,
297,
1595,
534,
1617,
63,
2052,
297,
849,
29,
797,
12,
267,
1720,
534,
1858,
823,
6230,
19269,
370,
1072,
315,
3164,
12,
2755,
1380,
314,
11167,
1630,
440,
7468,
370,
2291,
652,
2659,
272,
1050,
4517,
889,
13,
2326,
297,
1595,
534,
1617,
63,
2052,
297,
849,
29,
797,
12,
267,
1720,
534,
1858,
823,
6230,
19269,
370,
440,
675,
3164,
315,
314,
1072,
12,
15270,
402,
314,
9696,
11167,
730,
2659,
339,
327,
7958,
282,
769,
402,
809,
1533,
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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
rahuldhote/odoo
|
addons/mrp_repair/wizard/cancel_repair.py
|
384
|
3683
|
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp.osv import osv,fields
from openerp.tools.translate import _
class repair_cancel(osv.osv_memory):
_name = 'mrp.repair.cancel'
_description = 'Cancel Repair'
def cancel_repair(self, cr, uid, ids, context=None):
""" Cancels the repair
@param self: The object pointer.
@param cr: A database cursor
@param uid: ID of the user currently logged in
@param ids: List of IDs selected
@param context: A standard dictionary
@return:
"""
if context is None:
context = {}
record_id = context and context.get('active_id', False) or False
assert record_id, _('Active ID not Found')
repair_order_obj = self.pool.get('mrp.repair')
repair_line_obj = self.pool.get('mrp.repair.line')
repair_order = repair_order_obj.browse(cr, uid, record_id, context=context)
if repair_order.invoiced or repair_order.invoice_method == 'none':
repair_order_obj.action_cancel(cr, uid, [record_id], context=context)
else:
raise osv.except_osv(_('Warning!'),_('Repair order is not invoiced.'))
return {'type': 'ir.actions.act_window_close'}
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
""" Changes the view dynamically
@param self: The object pointer.
@param cr: A database cursor
@param uid: ID of the user currently logged in
@param context: A standard dictionary
@return: New arch of view.
"""
if context is None:
context = {}
res = super(repair_cancel, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar,submenu=False)
record_id = context and context.get('active_id', False) or False
active_model = context.get('active_model')
if not record_id or (active_model and active_model != 'mrp.repair'):
return res
repair_order = self.pool.get('mrp.repair').browse(cr, uid, record_id, context=context)
if not repair_order.invoiced:
res['arch'] = """
<form string="Cancel Repair" version="7.0">
<header>
<button name="cancel_repair" string="_Yes" type="object" class="oe_highlight"/>
or
<button string="Cancel" class="oe_link" special="cancel"/>
</header>
<label string="Do you want to continue?"/>
</form>
"""
return res
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
agpl-3.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
4605,
199,
3,
199,
3,
259,
7653,
12,
3232,
5800,
8259,
9274,
199,
3,
259,
1898,
334,
35,
9,
8353,
13,
6542,
11947,
12361,
8642,
1014,
921,
9864,
14,
1235,
10121,
199,
3,
199,
3,
259,
961,
2240,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
259,
652,
1334,
314,
2895,
402,
314,
1664,
4265,
1696,
1684,
844,
465,
199,
3,
259,
3267,
701,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
199,
3,
259,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
259,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
259,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
259,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
259,
1664,
4265,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
259,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
4265,
1696,
1684,
844,
199,
3,
259,
3180,
543,
642,
2240,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
3,
199,
4605,
199,
199,
504,
5166,
14,
4795,
492,
9506,
12,
955,
199,
504,
5166,
14,
2537,
14,
5275,
492,
485,
199,
199,
533,
27331,
63,
6406,
8,
4795,
14,
4795,
63,
4844,
304,
272,
485,
354,
275,
283,
17058,
14,
25279,
14,
6406,
7,
272,
485,
1802,
275,
283,
9083,
799,
3852,
7,
339,
347,
9311,
63,
25279,
8,
277,
12,
2467,
12,
1747,
12,
2762,
12,
1067,
29,
403,
304,
267,
408,
445,
554,
478,
314,
27331,
267,
768,
635,
291,
26,
710,
909,
7849,
14,
267,
768,
635,
2467,
26,
437,
3050,
3920,
267,
768,
635,
1747,
26,
2870,
402,
314,
922,
5544,
10367,
315,
267,
768,
635,
2762,
26,
3820,
402,
11449,
4895,
267,
768,
635,
1067,
26,
437,
4465,
2600,
267,
768,
1107,
26,
267,
408,
267,
340,
1067,
365,
488,
26,
288,
1067,
275,
1052,
267,
2777,
63,
344,
275,
1067,
436,
1067,
14,
362,
360,
2682,
63,
344,
297,
756,
9,
503,
756,
267,
702,
2777,
63,
344,
12,
4018,
7472,
2870,
440,
2643,
358,
267,
27331,
63,
1648,
63,
1113,
275,
291,
14,
2293,
14,
362,
360,
17058,
14,
25279,
358,
267,
27331,
63,
604,
63,
1113,
275,
291,
14,
2293,
14,
362,
360,
17058,
14,
25279,
14,
604,
358,
267,
27331,
63,
1648,
275,
27331,
63,
1648,
63,
1113,
14,
4570,
8,
1556,
12,
1747,
12,
2777,
63,
344,
12,
1067,
29,
1100,
9,
398,
340,
27331,
63,
1648,
14,
25614,
503,
27331,
63,
1648,
14,
5404,
63,
765,
508,
283,
3592,
356,
288,
27331,
63,
1648,
63,
1113,
14,
1287,
63,
6406,
8,
1556,
12,
1747,
12,
359,
3059,
63,
344,
467,
1067,
29,
1100,
9,
267,
587,
26,
288,
746,
9506,
14,
2590,
63,
4795,
6723,
3849,
15659,
11252,
497,
3852,
1865,
365,
440,
8485,
68,
12459,
398,
372,
791,
466,
356,
283,
723,
14,
3723,
14,
2442,
63,
3806,
63,
1600,
936,
339,
347,
1504,
63,
1345,
63,
362,
8,
277,
12,
2467,
12,
1747,
12,
2455,
63,
344,
29,
403,
12,
2455,
63,
466,
534,
964,
297,
1067,
29,
403,
12,
22483,
29,
797,
12,
1007,
4470,
29,
797,
304,
267,
408,
18784,
314,
2455,
18774,
267,
768,
635,
291,
26,
710,
909,
7849,
14,
267,
768,
635,
2467,
26,
437,
3050,
3920,
267,
768,
635,
1747,
26,
2870,
402,
314,
922,
5544,
10367,
315,
267,
768,
635,
1067,
26,
437,
4465,
2600,
267,
768,
1107,
26,
7053,
3819,
402,
2455,
14,
267,
408,
267,
340,
1067,
365,
488,
26,
288,
1067,
275,
1052,
267,
522,
275,
1613,
8,
25279,
63,
6406,
12,
291,
680,
955,
63,
1345,
63,
362,
8,
1556,
12,
1747,
12,
2455,
63,
344,
29,
1345,
63,
344,
12,
2455,
63,
466,
29,
1345,
63,
466,
12,
1067,
29,
1100,
12,
22483,
29,
13951,
12,
954,
4470,
29,
797,
9,
267,
2777,
63,
344,
275,
1067,
436,
1067,
14,
362,
360,
2682,
63,
344,
297,
756,
9,
503,
756,
267,
4702,
63,
1238,
275,
1067,
14,
362,
360,
2682,
63,
1238,
358,
398,
340,
440,
2777,
63,
344,
503,
334,
2682,
63,
1238,
436,
4702,
63,
1238,
1137,
283,
17058,
14,
25279,
735,
288,
372,
522,
398,
27331,
63,
1648,
275,
291,
14,
2293,
14,
362,
360,
17058,
14,
25279,
1959,
4570,
8,
1556,
12,
1747,
12,
2777,
63,
344,
12,
1067,
29,
1100,
9,
267,
340,
440,
27331,
63,
1648,
14,
25614,
26,
288,
522,
459,
1047,
418,
275,
408,
355,
665,
964,
1059,
628,
9083,
799,
3852,
2,
1015,
628,
23,
14,
16,
1743,
490,
665,
1291,
30,
717,
665,
3887,
536,
628,
6406,
63,
25279,
2,
1059,
19667,
12555,
2,
730,
628,
785,
2,
1021,
628,
13361,
63,
14337,
7897,
717,
503,
717,
665,
3887,
1059,
628,
9083,
2,
1021,
628,
13361,
63,
1073,
2,
4539,
628,
6406,
7897,
490,
3068,
1291,
30,
490,
665,
1302,
1059,
628,
2585,
1265,
2934,
370,
1980,
31,
7897,
355,
3068,
964,
30,
288,
408,
267,
372,
522,
421,
199,
3,
6695,
26,
10379,
26,
10558,
26,
6492,
29,
20,
26,
10503,
29,
20,
26,
10425,
29,
20,
26,
421,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
4605,
199,
3,
199,
3,
259,
7653,
12,
3232,
5800,
8259,
9274,
199,
3,
259,
1898,
334,
35,
9,
8353,
13,
6542,
11947,
12361,
8642,
1014,
921,
9864,
14,
1235,
10121,
199,
3,
199,
3,
259,
961,
2240,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
259,
652,
1334,
314,
2895,
402,
314,
1664,
4265,
1696,
1684,
844,
465,
199,
3,
259,
3267,
701,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
199,
3,
259,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
259,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
259,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
259,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
259,
1664,
4265,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
259,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
4265,
1696,
1684,
844,
199,
3,
259,
3180,
543,
642,
2240,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
3,
199,
4605,
199,
199,
504,
5166,
14,
4795,
492,
9506,
12,
955,
199,
504,
5166,
14,
2537,
14,
5275,
492,
485,
199,
199,
533,
27331,
63,
6406,
8,
4795,
14,
4795,
63,
4844,
304,
272,
485,
354,
275,
283,
17058,
14,
25279,
14,
6406,
7,
272,
485,
1802,
275,
283,
9083,
799,
3852,
7,
339,
347,
9311,
63,
25279,
8,
277,
12,
2467,
12,
1747,
12,
2762,
12,
1067,
29,
403,
304,
267,
408,
445,
554,
478,
314,
27331,
267,
768,
635,
291,
26,
710,
909,
7849,
14,
267,
768,
635,
2467,
26,
437,
3050,
3920,
267,
768,
635,
1747,
26,
2870,
402,
314,
922,
5544,
10367,
315,
267,
768,
635,
2762,
26,
3820,
402,
11449,
4895,
267,
768,
635,
1067,
26,
437,
4465,
2600,
267,
768,
1107,
26,
267,
408,
267,
340,
1067,
365,
488,
26,
288,
1067,
275,
1052,
267,
2777,
63,
344,
275,
1067,
436,
1067,
14,
362,
360,
2682,
63,
344,
297,
756,
9,
503,
756,
267,
702,
2777,
63,
344,
12,
4018,
7472,
2870,
440,
2643,
358,
267,
27331,
63,
1648,
63,
1113,
275,
291,
14,
2293,
14,
362,
360,
17058,
14,
25279,
358,
267,
27331,
63,
604,
63,
1113,
275,
291,
14,
2293,
14,
362,
360,
17058,
14,
25279,
14,
604,
358,
267,
27331,
63,
1648,
275,
27331,
63,
1648,
63,
1113,
14,
4570,
8,
1556,
12,
1747,
12,
2777,
63,
344,
12,
1067,
29,
1100,
9,
398,
340,
27331,
63,
1648,
14,
25614,
503,
27331,
63,
1648,
14,
5404,
63,
765,
508,
283,
3592,
356,
288,
27331,
63,
1648,
63,
1113,
14,
1287,
63,
6406,
8,
1556,
12,
1747,
12,
359,
3059,
63,
344,
467,
1067,
29,
1100,
9,
267,
587,
26,
288,
746,
9506,
14,
2590,
63,
4795,
6723,
3849,
15659,
11252,
497,
3852,
1865,
365,
440,
8485,
68,
12459,
398,
372,
791,
466,
356,
283,
723,
14,
3723,
14,
2442,
63,
3806,
63,
1600,
936,
339,
347,
1504,
63,
1345,
63,
362,
8,
277,
12,
2467,
12,
1747,
12,
2455,
63,
344,
29,
403,
12,
2455,
63,
466,
534,
964,
297,
1067,
29,
403,
12,
22483,
29,
797,
12,
1007,
4470,
29,
797,
304,
267,
408,
18784,
314,
2455,
18774,
267,
768,
635,
291,
26,
710,
909,
7849,
14,
267,
768,
635,
2467,
26,
437,
3050,
3920,
267,
768,
635,
1747,
26,
2870,
402,
314,
922,
5544,
10367,
315,
267,
768,
635,
1067,
26,
437,
4465,
2600,
267,
768,
1107,
26,
7053,
3819,
402,
2455,
14,
267,
408,
267,
340,
1067,
365,
488,
26,
288,
1067,
275,
1052,
267,
522,
275,
1613,
8,
25279,
63,
6406,
12,
291,
680,
955,
63,
1345,
63,
362,
8,
1556,
12,
1747,
12,
2455,
63,
344,
29,
1345,
63,
344,
12,
2455,
63,
466,
29,
1345,
63,
466,
12,
1067,
29,
1100,
12,
22483,
29,
13951,
12,
954,
4470,
29,
797,
9,
267,
2777,
63,
344,
275,
1067,
436,
1067,
14,
362,
360,
2682,
63,
344,
297,
756,
9,
503,
756,
267,
4702,
63,
1238,
275,
1067,
14,
362,
360,
2682,
63,
1238,
358,
398,
340,
440,
2777,
63,
344,
503,
334,
2682,
63,
1238,
436,
4702,
63,
1238,
1137,
283,
17058,
14,
25279,
735,
288,
372,
522,
398,
27331,
63,
1648,
275,
291,
14,
2293,
14,
362,
360,
17058,
14,
25279,
1959,
4570,
8,
1556,
12,
1747,
12,
2777,
63,
344,
12,
1067,
29,
1100,
9,
267,
340,
440,
27331,
63,
1648,
14,
25614,
26,
288,
522,
459,
1047,
418,
275,
408,
355,
665,
964,
1059,
628,
9083,
799,
3852,
2,
1015,
628,
23,
14,
16,
1743,
490,
665,
1291,
30,
717,
665,
3887,
536,
628,
6406,
63,
25279,
2,
1059,
19667,
12555,
2,
730,
628,
785,
2,
1021,
628,
13361,
63,
14337,
7897,
717,
503,
717,
665,
3887,
1059,
628,
9083,
2,
1021,
628,
13361,
63,
1073,
2,
4539,
628,
6406,
7897,
490,
3068,
1291,
30,
490,
665,
1302,
1059,
628,
2585,
1265,
2934,
370,
1980,
31,
7897,
355,
3068,
964,
30,
288,
408,
267,
372,
522,
421,
199,
3,
6695,
26,
10379,
26,
10558,
26,
6492,
29,
20,
26,
10503,
29,
20,
26,
10425,
29,
20,
26,
421,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
christoph-buente/phantomjs
|
src/qt/qtwebkit/Tools/TestResultServer/handlers/menu.py
|
129
|
2770
|
# Copyright (C) 2010 Google Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
from google.appengine.api import users
from google.appengine.ext import webapp
from google.appengine.ext.webapp import template
dashboards = [
["Results", "/dashboards/flakiness_dashboard.html"],
["Timeline", "/dashboards/timeline_explorer.html"],
["Treemap", "/dashboards/treemap.html"],
["Stats", "/dashboards/aggregate_results.html"],
]
menu = [
["List of test files", "/testfile"],
["List of results.json files", "/testfile?name=results.json"],
["Upload test file", "/testfile/uploadform"],
]
class Menu(webapp.RequestHandler):
def get(self):
user = users.get_current_user()
if user:
user_email = user.email()
login_text = "Sign out"
login_url = users.create_logout_url(self.request.uri)
else:
user_email = ""
login_text = "Sign in"
login_url = users.create_login_url(self.request.uri)
template_values = {
"user_email": user_email,
"login_text": login_text,
"login_url": login_url,
"menu": menu,
"dashboards": dashboards,
}
self.response.out.write(
template.render("templates/menu.html", template_values))
|
bsd-3-clause
|
[
3,
1898,
334,
35,
9,
7129,
4475,
3277,
14,
2900,
4481,
4644,
14,
199,
3,
199,
3,
10114,
436,
675,
315,
1350,
436,
3366,
4513,
12,
543,
503,
1928,
199,
3,
7100,
12,
787,
8211,
2741,
626,
314,
2569,
3704,
787,
199,
3,
7647,
26,
199,
3,
199,
3,
258,
627,
6823,
402,
1350,
1233,
1471,
8074,
314,
3432,
4248,
199,
3,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
14,
199,
3,
258,
627,
6823,
315,
3366,
1824,
1471,
9172,
314,
3432,
199,
3,
4248,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
199,
3,
315,
314,
3794,
436,
15,
269,
1163,
8418,
2741,
543,
314,
199,
3,
4084,
14,
199,
3,
258,
627,
11443,
314,
536,
402,
4475,
3277,
14,
6590,
314,
1561,
402,
2399,
199,
3,
8417,
1443,
506,
1202,
370,
10692,
503,
10016,
7585,
7131,
687,
199,
3,
642,
2032,
1928,
2488,
6791,
5313,
4983,
14,
199,
3,
199,
3,
5749,
4141,
2281,
7049,
6515,
2334,
5877,
8164,
2401,
6483,
199,
3,
298,
1179,
2281,
2,
2401,
1821,
7168,
1549,
5292,
2990,
12,
6931,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
2334,
5292,
2990,
1634,
3169,
2401,
3092,
2381,
199,
3,
437,
3115,
3104,
9315,
9706,
14,
1621,
4825,
6461,
7000,
2334,
5877,
199,
3,
11489,
1549,
6483,
6262,
7024,
2381,
1821,
8703,
12,
9168,
12,
9716,
12,
199,
3,
8820,
12,
9836,
12,
1549,
9110,
6736,
334,
6446,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
9838,
1634,
9103,
9764,
1549,
9714,
27,
9102,
1634,
4815,
12,
199,
3,
7126,
12,
1549,
9206,
27,
1549,
9748,
9831,
9,
9802,
9817,
2401,
5258,
1821,
199,
3,
9815,
1634,
5603,
12,
7061,
1621,
7066,
12,
9644,
5603,
12,
1549,
7056,
199,
3,
334,
6446,
9254,
1549,
7334,
9,
7043,
1621,
1821,
9683,
5738,
1634,
2334,
4815,
199,
3,
1634,
5749,
4141,
12,
9704,
8036,
9691,
1634,
2334,
9726,
1634,
9712,
9784,
14,
199,
199,
504,
6233,
14,
15358,
14,
1246,
492,
4390,
199,
504,
6233,
14,
15358,
14,
832,
492,
24812,
199,
504,
6233,
14,
15358,
14,
832,
14,
22632,
492,
1978,
199,
199,
30424,
275,
359,
272,
2097,
6579,
401,
3286,
30424,
15,
14163,
75,
9585,
63,
9743,
14,
1360,
2255,
272,
2097,
27097,
401,
3286,
30424,
15,
19369,
63,
16971,
3859,
14,
1360,
2255,
272,
2097,
3987,
1130,
401,
3286,
30424,
15,
2350,
1130,
14,
1360,
2255,
272,
2097,
8257,
401,
3286,
30424,
15,
7516,
63,
2604,
14,
1360,
2255,
199,
61,
199,
199,
4470,
275,
359,
272,
2097,
1296,
402,
511,
1584,
401,
3286,
21091,
2255,
272,
2097,
1296,
402,
2058,
14,
1001,
1584,
401,
3286,
21091,
31,
354,
29,
2604,
14,
1001,
2255,
272,
2097,
10301,
511,
570,
401,
3286,
21091,
15,
5064,
964,
2255,
199,
61,
421,
199,
533,
18281,
8,
22632,
14,
11149,
304,
272,
347,
664,
8,
277,
304,
267,
922,
275,
4390,
14,
362,
63,
1818,
63,
751,
342,
267,
340,
922,
26,
288,
922,
63,
2123,
275,
922,
14,
2123,
342,
288,
4676,
63,
505,
275,
298,
4940,
734,
2,
288,
4676,
63,
633,
275,
4390,
14,
981,
63,
11646,
63,
633,
8,
277,
14,
1069,
14,
2302,
9,
267,
587,
26,
288,
922,
63,
2123,
275,
3087,
288,
4676,
63,
505,
275,
298,
4940,
315,
2,
288,
4676,
63,
633,
275,
4390,
14,
981,
63,
2886,
63,
633,
8,
277,
14,
1069,
14,
2302,
9,
398,
1978,
63,
1459,
275,
469,
288,
298,
751,
63,
2123,
582,
922,
63,
2123,
12,
288,
298,
2886,
63,
505,
582,
4676,
63,
505,
12,
288,
298,
2886,
63,
633,
582,
4676,
63,
633,
12,
288,
298,
4470,
582,
6269,
12,
288,
298,
30424,
582,
11847,
19267,
12,
267,
789,
398,
291,
14,
1310,
14,
548,
14,
952,
8,
288,
1978,
14,
3352,
480,
5876,
15,
4470,
14,
1360,
401,
1978,
63,
1459,
430,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1898,
334,
35,
9,
7129,
4475,
3277,
14,
2900,
4481,
4644,
14,
199,
3,
199,
3,
10114,
436,
675,
315,
1350,
436,
3366,
4513,
12,
543,
503,
1928,
199,
3,
7100,
12,
787,
8211,
2741,
626,
314,
2569,
3704,
787,
199,
3,
7647,
26,
199,
3,
199,
3,
258,
627,
6823,
402,
1350,
1233,
1471,
8074,
314,
3432,
4248,
199,
3,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
14,
199,
3,
258,
627,
6823,
315,
3366,
1824,
1471,
9172,
314,
3432,
199,
3,
4248,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
199,
3,
315,
314,
3794,
436,
15,
269,
1163,
8418,
2741,
543,
314,
199,
3,
4084,
14,
199,
3,
258,
627,
11443,
314,
536,
402,
4475,
3277,
14,
6590,
314,
1561,
402,
2399,
199,
3,
8417,
1443,
506,
1202,
370,
10692,
503,
10016,
7585,
7131,
687,
199,
3,
642,
2032,
1928,
2488,
6791,
5313,
4983,
14,
199,
3,
199,
3,
5749,
4141,
2281,
7049,
6515,
2334,
5877,
8164,
2401,
6483,
199,
3,
298,
1179,
2281,
2,
2401,
1821,
7168,
1549,
5292,
2990,
12,
6931,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
2334,
5292,
2990,
1634,
3169,
2401,
3092,
2381,
199,
3,
437,
3115,
3104,
9315,
9706,
14,
1621,
4825,
6461,
7000,
2334,
5877,
199,
3,
11489,
1549,
6483,
6262,
7024,
2381,
1821,
8703,
12,
9168,
12,
9716,
12,
199,
3,
8820,
12,
9836,
12,
1549,
9110,
6736,
334,
6446,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
9838,
1634,
9103,
9764,
1549,
9714,
27,
9102,
1634,
4815,
12,
199,
3,
7126,
12,
1549,
9206,
27,
1549,
9748,
9831,
9,
9802,
9817,
2401,
5258,
1821,
199,
3,
9815,
1634,
5603,
12,
7061,
1621,
7066,
12,
9644,
5603,
12,
1549,
7056,
199,
3,
334,
6446,
9254,
1549,
7334,
9,
7043,
1621,
1821,
9683,
5738,
1634,
2334,
4815,
199,
3,
1634,
5749,
4141,
12,
9704,
8036,
9691,
1634,
2334,
9726,
1634,
9712,
9784,
14,
199,
199,
504,
6233,
14,
15358,
14,
1246,
492,
4390,
199,
504,
6233,
14,
15358,
14,
832,
492,
24812,
199,
504,
6233,
14,
15358,
14,
832,
14,
22632,
492,
1978,
199,
199,
30424,
275,
359,
272,
2097,
6579,
401,
3286,
30424,
15,
14163,
75,
9585,
63,
9743,
14,
1360,
2255,
272,
2097,
27097,
401,
3286,
30424,
15,
19369,
63,
16971,
3859,
14,
1360,
2255,
272,
2097,
3987,
1130,
401,
3286,
30424,
15,
2350,
1130,
14,
1360,
2255,
272,
2097,
8257,
401,
3286,
30424,
15,
7516,
63,
2604,
14,
1360,
2255,
199,
61,
199,
199,
4470,
275,
359,
272,
2097,
1296,
402,
511,
1584,
401,
3286,
21091,
2255,
272,
2097,
1296,
402,
2058,
14,
1001,
1584,
401,
3286,
21091,
31,
354,
29,
2604,
14,
1001,
2255,
272,
2097,
10301,
511,
570,
401,
3286,
21091,
15,
5064,
964,
2255,
199,
61,
421,
199,
533,
18281,
8,
22632,
14,
11149,
304,
272,
347,
664,
8,
277,
304,
267,
922,
275,
4390,
14,
362,
63,
1818,
63,
751,
342,
267,
340,
922,
26,
288,
922,
63,
2123,
275,
922,
14,
2123,
342,
288,
4676,
63,
505,
275,
298,
4940,
734,
2,
288,
4676,
63,
633,
275,
4390,
14,
981,
63,
11646,
63,
633,
8,
277,
14,
1069,
14,
2302,
9,
267,
587,
26,
288,
922,
63,
2123,
275,
3087,
288,
4676,
63,
505,
275,
298,
4940,
315,
2,
288,
4676,
63,
633,
275,
4390,
14,
981,
63,
2886,
63,
633,
8,
277,
14,
1069,
14,
2302,
9,
398,
1978,
63,
1459,
275,
469,
288,
298,
751,
63,
2123,
582,
922,
63,
2123,
12,
288,
298,
2886,
63,
505,
582,
4676,
63,
505,
12,
288,
298,
2886,
63,
633,
582,
4676,
63,
633,
12,
288,
298,
4470,
582,
6269,
12,
288,
298,
30424,
582,
11847,
19267,
12,
267,
789,
398,
291,
14,
1310,
14,
548,
14,
952,
8,
288,
1978,
14,
3352,
480,
5876,
15,
4470,
14,
1360,
401,
1978,
63,
1459,
430,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
dmaclay/python-smpp
|
test/pdu_hex_asserts.py
|
2
|
3710
|
########################################
pdu_json_0000000001 = '''{
"body": {
"mandatory_parameters": {
"data_coding": 0,
"dest_addr_npi": "ISDN",
"dest_addr_ton": "international",
"destination_addr": "555555555",
"esm_class": 0,
"priority_flag": 0,
"protocol_id": 0,
"registered_delivery": 0,
"replace_if_present_flag": 0,
"schedule_delivery_time": "",
"service_type": "",
"short_message": "Hello wikipedia",
"sm_default_msg_id": 0,
"sm_length": 15,
"source_addr": "555",
"source_addr_npi": "national",
"source_addr_ton": "national",
"validity_period": ""
},
"optional_parameters": [
{
"length": 0,
"tag": "0000",
"value": null
},
{
"length": 2,
"tag": "additional_status_info_text",
"value": "ef"
}
]
},
"header": {
"command_id": "submit_sm",
"command_length": 60,
"command_status": "ESME_ROK",
"sequence_number": 5
}
}'''
########################################
pdu_json_0000000002 = '''{
"body": {
"mandatory_parameters": {
"data_coding": 0,
"dest_address": [
{
"dest_addr_npi": "ISDN",
"dest_addr_ton": "international",
"dest_flag": 1,
"destination_addr": "e"
},
{
"dest_flag": 2,
"dl_name": "f"
}
],
"esm_class": 0,
"number_of_dests": 2,
"priority_flag": 0,
"protocol_id": 0,
"registered_delivery": 0,
"replace_if_present_flag": 0,
"schedule_delivery_time": "",
"service_type": "",
"short_message": null,
"sm_default_msg_id": 0,
"sm_length": 0,
"source_addr": "",
"source_addr_npi": "unknown",
"source_addr_ton": "unknown",
"validity_period": ""
},
"optional_parameters": [
{
"length": 2,
"tag": "dest_addr_subunit",
"value": 0
},
{
"length": 4,
"tag": "0000",
"value": "00000000"
}
]
},
"header": {
"command_id": "submit_multi",
"command_length": 0,
"command_status": "ESME_ROK",
"sequence_number": 0
}
}'''
########################################
pdu_json_0000000003 = '''{
"body": {
"mandatory_parameters": {
"message_id": "",
"no_unsuccess": 2,
"unsuccess_sme": [
{
"dest_addr_npi": "ISDN",
"dest_addr_ton": "international",
"destination_addr": "eee",
"error_status_code": 0
},
{
"dest_addr_npi": "ISDN",
"dest_addr_ton": "international",
"destination_addr": "fff",
"error_status_code": 0
}
]
}
},
"header": {
"command_id": "submit_multi_resp",
"command_length": 0,
"command_status": "ESME_ROK",
"sequence_number": 0
}
}'''
|
bsd-3-clause
|
[
199,
26634,
199,
25180,
63,
1001,
63,
3607,
614,
275,
1449,
91,
272,
298,
2030,
582,
469,
267,
298,
19900,
63,
3214,
582,
469,
288,
298,
576,
63,
1523,
582,
378,
12,
7205,
298,
2614,
63,
2697,
63,
78,
1038,
582,
298,
1311,
10872,
401,
7205,
298,
2614,
63,
2697,
63,
1860,
582,
298,
4404,
6279,
401,
7205,
298,
6881,
63,
2697,
582,
298,
19161,
1229,
15722,
401,
7205,
298,
397,
77,
63,
533,
582,
378,
12,
7205,
298,
6693,
63,
4173,
582,
378,
12,
7205,
298,
3922,
63,
344,
582,
378,
12,
7205,
298,
11616,
63,
14564,
582,
378,
12,
7205,
298,
1814,
63,
692,
63,
1881,
63,
4173,
582,
378,
12,
7205,
298,
7211,
63,
14564,
63,
521,
582,
4873,
7205,
298,
1364,
63,
466,
582,
4873,
7205,
298,
3612,
63,
1188,
582,
298,
6257,
336,
29386,
401,
7205,
298,
3300,
63,
885,
63,
1328,
63,
344,
582,
378,
12,
7205,
298,
3300,
63,
1267,
582,
4114,
12,
7205,
298,
1365,
63,
2697,
582,
298,
15722,
401,
7205,
298,
1365,
63,
2697,
63,
78,
1038,
582,
298,
26021,
401,
7205,
298,
1365,
63,
2697,
63,
1860,
582,
298,
26021,
401,
7205,
298,
31901,
63,
5191,
582,
3087,
267,
1660,
4960,
298,
4144,
63,
3214,
582,
359,
288,
469,
355,
298,
1267,
582,
378,
12,
8892,
298,
1450,
582,
298,
993,
401,
8892,
298,
585,
582,
2973,
288,
1660,
7205,
469,
355,
298,
1267,
582,
499,
12,
8892,
298,
1450,
582,
298,
8460,
63,
1205,
63,
815,
63,
505,
401,
8892,
298,
585,
582,
298,
2829,
2,
288,
789,
267,
1622,
272,
1660,
5591,
298,
1291,
582,
469,
267,
298,
1531,
63,
344,
582,
298,
7275,
63,
3300,
401,
4960,
298,
1531,
63,
1267,
582,
5212,
12,
4960,
298,
1531,
63,
1205,
582,
298,
654,
3635,
63,
1092,
43,
401,
4960,
298,
4041,
63,
1955,
582,
959,
272,
789,
199,
93,
2344,
199,
199,
26634,
199,
25180,
63,
1001,
63,
3607,
996,
275,
1449,
91,
272,
298,
2030,
582,
469,
267,
298,
19900,
63,
3214,
582,
469,
288,
298,
576,
63,
1523,
582,
378,
12,
7205,
298,
2614,
63,
1562,
582,
359,
355,
469,
490,
298,
2614,
63,
2697,
63,
78,
1038,
582,
298,
1311,
10872,
401,
15324,
298,
2614,
63,
2697,
63,
1860,
582,
298,
4404,
6279,
401,
15324,
298,
2614,
63,
4173,
582,
413,
12,
15324,
298,
6881,
63,
2697,
582,
298,
69,
2,
355,
1660,
8892,
469,
490,
298,
2614,
63,
4173,
582,
499,
12,
15324,
298,
5030,
63,
354,
582,
298,
70,
2,
355,
789,
288,
2156,
7205,
298,
397,
77,
63,
533,
582,
378,
12,
7205,
298,
1955,
63,
1618,
63,
2614,
83,
582,
499,
12,
7205,
298,
6693,
63,
4173,
582,
378,
12,
7205,
298,
3922,
63,
344,
582,
378,
12,
7205,
298,
11616,
63,
14564,
582,
378,
12,
7205,
298,
1814,
63,
692,
63,
1881,
63,
4173,
582,
378,
12,
7205,
298,
7211,
63,
14564,
63,
521,
582,
4873,
7205,
298,
1364,
63,
466,
582,
4873,
7205,
298,
3612,
63,
1188,
582,
2973,
12,
7205,
298,
3300,
63,
885,
63,
1328,
63,
344,
582,
378,
12,
7205,
298,
3300,
63,
1267,
582,
378,
12,
7205,
298,
1365,
63,
2697,
582,
4873,
7205,
298,
1365,
63,
2697,
63,
78,
1038,
582,
298,
5187,
401,
7205,
298,
1365,
63,
2697,
63,
1860,
582,
298,
5187,
401,
7205,
298,
31901,
63,
5191,
582,
3087,
267,
1660,
4960,
298,
4144,
63,
3214,
582,
359,
288,
469,
355,
298,
1267,
582,
499,
12,
8892,
298,
1450,
582,
298,
2614,
63,
2697,
63,
954,
3248,
401,
8892,
298,
585,
582,
378,
288,
1660,
7205,
469,
355,
298,
1267,
582,
841,
12,
8892,
298,
1450,
582,
298,
993,
401,
8892,
298,
585,
582,
298,
3607,
2,
288,
789,
267,
1622,
272,
1660,
5591,
298,
1291,
582,
469,
267,
298,
1531,
63,
344,
582,
298,
7275,
63,
3029,
401,
4960,
298,
1531,
63,
1267,
582,
378,
12,
4960,
298,
1531,
63,
1205,
582,
298,
654,
3635,
63,
1092,
43,
401,
4960,
298,
4041,
63,
1955,
582,
378,
272,
789,
199,
93,
2344,
199,
199,
26634,
199,
25180,
63,
1001,
63,
3607,
1644,
275,
1449,
91,
272,
298,
2030,
582,
469,
267,
298,
19900,
63,
3214,
582,
469,
288,
298,
1188,
63,
344,
582,
4873,
7205,
298,
889,
63,
324,
3742,
582,
499,
12,
7205,
298,
324,
3742,
63,
83,
278,
582,
359,
355,
469,
490,
298,
2614,
63,
2697,
63,
78,
1038,
582,
298,
1311,
10872,
401,
15324,
298,
2614,
63,
2697,
63,
1860,
582,
298,
4404,
6279,
401,
15324,
298,
6881,
63,
2697,
582,
298,
18777,
401,
15324,
298,
705,
63,
1205,
63,
600,
582,
378,
355,
1660,
8892,
469,
490,
298,
2614,
63,
2697,
63,
78,
1038,
582,
298,
1311,
10872,
401,
15324,
298,
2614,
63,
2697,
63,
1860,
582,
298,
4404,
6279,
401,
15324,
298,
6881,
63,
2697,
582,
298,
18190,
401,
15324,
298,
705,
63,
1205,
63,
600,
582,
378,
355,
789,
288,
1622,
267,
789,
272,
1660,
5591,
298,
1291,
582,
469,
267,
298,
1531,
63,
344,
582,
298,
7275,
63,
3029,
63,
4518,
401,
4960,
298,
1531,
63,
1267,
582,
378,
12,
4960,
298,
1531,
63,
1205,
582,
298,
654,
3635,
63,
1092,
43,
401,
4960,
298,
4041,
63,
1955,
582,
378,
272,
789,
199,
93,
2344,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
26634,
199,
25180,
63,
1001,
63,
3607,
614,
275,
1449,
91,
272,
298,
2030,
582,
469,
267,
298,
19900,
63,
3214,
582,
469,
288,
298,
576,
63,
1523,
582,
378,
12,
7205,
298,
2614,
63,
2697,
63,
78,
1038,
582,
298,
1311,
10872,
401,
7205,
298,
2614,
63,
2697,
63,
1860,
582,
298,
4404,
6279,
401,
7205,
298,
6881,
63,
2697,
582,
298,
19161,
1229,
15722,
401,
7205,
298,
397,
77,
63,
533,
582,
378,
12,
7205,
298,
6693,
63,
4173,
582,
378,
12,
7205,
298,
3922,
63,
344,
582,
378,
12,
7205,
298,
11616,
63,
14564,
582,
378,
12,
7205,
298,
1814,
63,
692,
63,
1881,
63,
4173,
582,
378,
12,
7205,
298,
7211,
63,
14564,
63,
521,
582,
4873,
7205,
298,
1364,
63,
466,
582,
4873,
7205,
298,
3612,
63,
1188,
582,
298,
6257,
336,
29386,
401,
7205,
298,
3300,
63,
885,
63,
1328,
63,
344,
582,
378,
12,
7205,
298,
3300,
63,
1267,
582,
4114,
12,
7205,
298,
1365,
63,
2697,
582,
298,
15722,
401,
7205,
298,
1365,
63,
2697,
63,
78,
1038,
582,
298,
26021,
401,
7205,
298,
1365,
63,
2697,
63,
1860,
582,
298,
26021,
401,
7205,
298,
31901,
63,
5191,
582,
3087,
267,
1660,
4960,
298,
4144,
63,
3214,
582,
359,
288,
469,
355,
298,
1267,
582,
378,
12,
8892,
298,
1450,
582,
298,
993,
401,
8892,
298,
585,
582,
2973,
288,
1660,
7205,
469,
355,
298,
1267,
582,
499,
12,
8892,
298,
1450,
582,
298,
8460,
63,
1205,
63,
815,
63,
505,
401,
8892,
298,
585,
582,
298,
2829,
2,
288,
789,
267,
1622,
272,
1660,
5591,
298,
1291,
582,
469,
267,
298,
1531,
63,
344,
582,
298,
7275,
63,
3300,
401,
4960,
298,
1531,
63,
1267,
582,
5212,
12,
4960,
298,
1531,
63,
1205,
582,
298,
654,
3635,
63,
1092,
43,
401,
4960,
298,
4041,
63,
1955,
582,
959,
272,
789,
199,
93,
2344,
199,
199,
26634,
199,
25180,
63,
1001,
63,
3607,
996,
275,
1449,
91,
272,
298,
2030,
582,
469,
267,
298,
19900,
63,
3214,
582,
469,
288,
298,
576,
63,
1523,
582,
378,
12,
7205,
298,
2614,
63,
1562,
582,
359,
355,
469,
490,
298,
2614,
63,
2697,
63,
78,
1038,
582,
298,
1311,
10872,
401,
15324,
298,
2614,
63,
2697,
63,
1860,
582,
298,
4404,
6279,
401,
15324,
298,
2614,
63,
4173,
582,
413,
12,
15324,
298,
6881,
63,
2697,
582,
298,
69,
2,
355,
1660,
8892,
469,
490,
298,
2614,
63,
4173,
582,
499,
12,
15324,
298,
5030,
63,
354,
582,
298,
70,
2,
355,
789,
288,
2156,
7205,
298,
397,
77,
63,
533,
582,
378,
12,
7205,
298,
1955,
63,
1618,
63,
2614,
83,
582,
499,
12,
7205,
298,
6693,
63,
4173,
582,
378,
12,
7205,
298,
3922,
63,
344,
582,
378,
12,
7205,
298,
11616,
63,
14564,
582,
378,
12,
7205,
298,
1814,
63,
692,
63,
1881,
63,
4173,
582,
378,
12,
7205,
298,
7211,
63,
14564,
63,
521,
582,
4873,
7205,
298,
1364,
63,
466,
582,
4873,
7205,
298,
3612,
63,
1188,
582,
2973,
12,
7205,
298,
3300,
63,
885,
63,
1328,
63,
344,
582,
378,
12,
7205,
298,
3300,
63,
1267,
582,
378,
12,
7205,
298,
1365,
63,
2697,
582,
4873,
7205,
298,
1365,
63,
2697,
63,
78,
1038,
582,
298,
5187,
401,
7205,
298,
1365,
63,
2697,
63,
1860,
582,
298,
5187,
401,
7205,
298,
31901,
63,
5191,
582,
3087,
267,
1660,
4960,
298,
4144,
63,
3214,
582,
359,
288,
469,
355,
298,
1267,
582,
499,
12,
8892,
298,
1450,
582,
298,
2614,
63,
2697,
63,
954,
3248,
401,
8892,
298,
585,
582,
378,
288,
1660,
7205,
469,
355,
298,
1267,
582,
841,
12,
8892,
298,
1450,
582,
298,
993,
401,
8892,
298,
585,
582,
298,
3607,
2,
288,
789,
267,
1622,
272,
1660,
5591,
298,
1291,
582,
469,
267,
298,
1531,
63,
344,
582,
298,
7275,
63,
3029,
401,
4960,
298,
1531,
63,
1267,
582,
378,
12,
4960,
298,
1531,
63,
1205,
582,
298,
654,
3635,
63,
1092,
43,
401,
4960,
298,
4041,
63,
1955,
582,
378,
272,
789,
199,
93,
2344,
199,
199,
26634,
199,
25180,
63,
1001,
63,
3607,
1644,
275,
1449,
91,
272,
298,
2030,
582,
469,
267,
298,
19900,
63,
3214,
582,
469,
288,
298,
1188,
63,
344,
582,
4873,
7205,
298,
889,
63,
324,
3742,
582,
499,
12,
7205,
298,
324,
3742,
63,
83,
278,
582,
359,
355,
469,
490,
298,
2614,
63,
2697,
63,
78,
1038,
582,
298,
1311,
10872,
401,
15324,
298,
2614,
63,
2697,
63,
1860,
582,
298,
4404,
6279,
401,
15324,
298,
6881,
63,
2697,
582,
298,
18777,
401,
15324,
298,
705,
63,
1205,
63,
600,
582,
378,
355,
1660,
8892,
469,
490,
298,
2614,
63,
2697,
63,
78,
1038,
582,
298,
1311,
10872,
401,
15324,
298,
2614,
63,
2697,
63,
1860,
582,
298,
4404,
6279,
401,
15324,
298,
6881,
63,
2697,
582,
298,
18190,
401,
15324,
298,
705,
63,
1205,
63,
600,
582,
378,
355,
789,
288,
1622,
267,
789,
272,
1660,
5591,
298,
1291,
582,
469,
267,
298,
1531,
63,
344,
582,
298,
7275,
63,
3029,
63,
4518,
401,
4960,
298,
1531,
63,
1267,
582,
378,
12,
4960,
298,
1531,
63,
1205,
582,
298,
654,
3635,
63,
1092,
43,
401,
4960,
298,
4041,
63,
1955,
582,
378,
272,
789,
199,
93,
2344,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
pku9104038/edx-platform
|
common/lib/xmodule/xmodule/tests/test_peer_grading.py
|
1
|
13961
|
import unittest
import json
import logging
from mock import Mock
from webob.multidict import MultiDict
from xblock.field_data import DictFieldData
from xblock.fields import ScopeIds
from xmodule.modulestore import Location
from xmodule.tests import get_test_system, get_test_descriptor_system
from xmodule.tests.test_util_open_ended import DummyModulestore
from xmodule.open_ended_grading_classes.peer_grading_service import MockPeerGradingService
from xmodule.peer_grading_module import PeerGradingModule, PeerGradingDescriptor, MAX_ALLOWED_FEEDBACK_LENGTH
from xmodule.modulestore.exceptions import ItemNotFoundError, NoPathToItem
log = logging.getLogger(__name__)
ORG = "edX"
COURSE = "open_ended"
class PeerGradingModuleTest(unittest.TestCase, DummyModulestore):
"""
Test peer grading xmodule at the unit level. More detailed tests are difficult, as the module relies on an
external grading service.
"""
problem_location = Location(["i4x", "edX", "open_ended", "peergrading",
"PeerGradingSample"])
coe_location = Location(["i4x", "edX", "open_ended", "combinedopenended", "SampleQuestion"])
calibrated_dict = {'location': "blah"}
coe_dict = {'location': coe_location.url()}
save_dict = MultiDict({
'location': "blah",
'submission_id': 1,
'submission_key': "",
'score': 1,
'feedback': "",
'submission_flagged': False,
'answer_unknown': False,
})
save_dict.extend(('rubric_scores[]', val) for val in (0, 1))
def get_module_system(self, descriptor):
test_system = get_test_system()
test_system.open_ended_grading_interface = None
return test_system
def setUp(self):
"""
Create a peer grading module from a test system
@return:
"""
self.setup_modulestore(COURSE)
self.peer_grading = self.get_module_from_location(self.problem_location, COURSE)
self.coe = self.get_module_from_location(self.coe_location, COURSE)
def test_module_closed(self):
"""
Test if peer grading is closed
@return:
"""
closed = self.peer_grading.closed()
self.assertFalse(closed)
def test_get_html(self):
"""
Test to see if the module can be rendered
@return:
"""
_html = self.peer_grading.get_html()
def test_get_data(self):
"""
Try getting data from the external grading service
@return:
"""
success, _data = self.peer_grading.query_data_for_location(self.problem_location.url())
self.assertTrue(success)
def test_get_score(self):
"""
Test getting the score
@return:
"""
score = self.peer_grading.get_score()
self.assertIsNone(score['score'])
def test_get_max_score(self):
"""
Test getting the max score
@return:
"""
max_score = self.peer_grading.max_score()
self.assertEquals(max_score, None)
def get_next_submission(self):
"""
Test to see if we can get the next mock submission
@return:
"""
success, _next_submission = self.peer_grading.get_next_submission({'location': 'blah'})
self.assertEqual(success, True)
def test_save_grade(self):
"""
Test if we can save the grade
@return:
"""
response = self.peer_grading.save_grade(self.save_dict)
self.assertEqual(response['success'], True)
def test_is_student_calibrated(self):
"""
Check to see if the student has calibrated yet
@return:
"""
response = self.peer_grading.is_student_calibrated(self.calibrated_dict)
self.assertTrue(response['success'])
def test_show_calibration_essay(self):
"""
Test showing the calibration essay
@return:
"""
response = self.peer_grading.show_calibration_essay(self.calibrated_dict)
self.assertTrue(response['success'])
def test_save_calibration_essay(self):
"""
Test saving the calibration essay
@return:
"""
response = self.peer_grading.save_calibration_essay(self.save_dict)
self.assertTrue(response['success'])
def test_peer_grading_problem(self):
"""
See if we can render a single problem
@return:
"""
response = self.peer_grading.peer_grading_problem(self.coe_dict)
self.assertTrue(response['success'])
def test___find_corresponding_module_for_location_exceptions(self):
"""
Unit test for the exception cases of __find_corresponding_module_for_location
Mainly for diff coverage
@return:
"""
with self.assertRaises(ItemNotFoundError):
self.peer_grading._find_corresponding_module_for_location(Location('i4x', 'a', 'b', 'c', 'd'))
def test_get_instance_state(self):
"""
Get the instance state dict
@return:
"""
self.peer_grading.get_instance_state()
def test_save_grade_with_long_feedback(self):
"""
Test if feedback is too long save_grade() should return error message.
"""
feedback_fragment = "This is very long feedback."
self.save_dict["feedback"] = feedback_fragment * (
(MAX_ALLOWED_FEEDBACK_LENGTH / len(feedback_fragment) + 1)
)
response = self.peer_grading.save_grade(self.save_dict)
# Should not succeed.
self.assertEqual(response['success'], False)
self.assertEqual(
response['error'],
"Feedback is too long, Max length is {0} characters.".format(
MAX_ALLOWED_FEEDBACK_LENGTH
)
)
class MockPeerGradingServiceProblemList(MockPeerGradingService):
def get_problem_list(self, course_id, grader_id):
return {'success': True,
'problem_list': [
{"num_graded": 3, "num_pending": 681, "num_required": 3, "location": "i4x://edX/open_ended/combinedopenended/SampleQuestion", "problem_name": "Peer-Graded Essay"},
]}
class PeerGradingModuleScoredTest(unittest.TestCase, DummyModulestore):
"""
Test peer grading xmodule at the unit level. More detailed tests are difficult, as the module relies on an
external grading service.
"""
problem_location = Location(
["i4x", "edX", "open_ended", "peergrading", "PeerGradingScored"]
)
def get_module_system(self, descriptor):
test_system = get_test_system()
test_system.open_ended_grading_interface = None
return test_system
def setUp(self):
"""
Create a peer grading module from a test system
@return:
"""
self.setup_modulestore(COURSE)
def test_metadata_load(self):
peer_grading = self.get_module_from_location(self.problem_location, COURSE)
self.assertFalse(peer_grading.closed())
def test_problem_list(self):
"""
Test to see if a peer grading problem list can be correctly initialized.
"""
# Initialize peer grading module.
peer_grading = self.get_module_from_location(self.problem_location, COURSE)
# Ensure that it cannot find any peer grading.
html = peer_grading.peer_grading()
self.assertNotIn("Peer-Graded", html)
# Swap for our mock class, which will find peer grading.
peer_grading.peer_gs = MockPeerGradingServiceProblemList()
html = peer_grading.peer_grading()
self.assertIn("Peer-Graded", html)
class PeerGradingModuleLinkedTest(unittest.TestCase, DummyModulestore):
"""
Test peer grading that is linked to an open ended module.
"""
problem_location = Location(["i4x", "edX", "open_ended", "peergrading",
"PeerGradingLinked"])
coe_location = Location(["i4x", "edX", "open_ended", "combinedopenended",
"SampleQuestion"])
def get_module_system(self, descriptor):
test_system = get_test_system()
test_system.open_ended_grading_interface = None
return test_system
def setUp(self):
"""
Create a peer grading module from a test system.
"""
self.setup_modulestore(COURSE)
@property
def field_data(self):
"""
Setup the proper field data for a peer grading module.
"""
return DictFieldData({
'data': '<peergrading/>',
'location': self.problem_location,
'use_for_single_location': True,
'link_to_location': self.coe_location.url(),
'graded': True,
})
@property
def scope_ids(self):
"""
Return the proper scope ids for the peer grading module.
"""
return ScopeIds(None, None, self.problem_location, self.problem_location)
def _create_peer_grading_descriptor_with_linked_problem(self):
# Initialize the peer grading module.
system = get_test_descriptor_system()
return system.construct_xblock_from_class(
PeerGradingDescriptor,
field_data=self.field_data,
scope_ids=self.scope_ids
)
def _create_peer_grading_with_linked_problem(self, location, valid_linked_descriptor=True):
"""
Create a peer grading problem with a linked location.
"""
# Mock the linked problem descriptor.
linked_descriptor = Mock()
linked_descriptor.location = location
# Mock the peer grading descriptor.
pg_descriptor = Mock()
pg_descriptor.location = self.problem_location
if valid_linked_descriptor:
pg_descriptor.get_required_module_descriptors = lambda: [linked_descriptor, ]
else:
pg_descriptor.get_required_module_descriptors = lambda: []
test_system = self.get_module_system(pg_descriptor)
# Initialize the peer grading module.
peer_grading = PeerGradingModule(
pg_descriptor,
test_system,
self.field_data,
self.scope_ids,
)
return peer_grading
def _get_descriptor_with_invalid_link(self, exception_to_raise):
"""
Ensure that a peer grading descriptor with an invalid link will return an empty list.
"""
# Create a descriptor, and make loading an item throw an error.
descriptor = self._create_peer_grading_descriptor_with_linked_problem()
descriptor.system.load_item = Mock(side_effect=exception_to_raise)
# Ensure that modules is a list of length 0.
modules = descriptor.get_required_module_descriptors()
self.assertIsInstance(modules, list)
self.assertEqual(len(modules), 0)
def test_descriptor_with_nopath(self):
"""
Test to see if a descriptor with a NoPathToItem error when trying to get
its linked module behaves properly.
"""
self._get_descriptor_with_invalid_link(NoPathToItem)
def test_descriptor_with_item_not_found(self):
"""
Test to see if a descriptor with an ItemNotFound error when trying to get
its linked module behaves properly.
"""
self._get_descriptor_with_invalid_link(ItemNotFoundError)
def test_invalid_link(self):
"""
Ensure that a peer grading problem with no linked locations stays in panel mode.
"""
# Setup the peer grading module with no linked locations.
peer_grading = self._create_peer_grading_with_linked_problem(self.coe_location, valid_linked_descriptor=False)
self.assertFalse(peer_grading.use_for_single_location_local)
self.assertTrue(peer_grading.use_for_single_location)
def test_linked_problem(self):
"""
Ensure that a peer grading problem with a linked location loads properly.
"""
# Setup the peer grading module with the proper linked location.
peer_grading = self._create_peer_grading_with_linked_problem(self.coe_location)
# Ensure that it is properly setup.
self.assertTrue(peer_grading.use_for_single_location)
def test_linked_ajax(self):
"""
Ensure that a peer grading problem with a linked location responds to ajax calls.
"""
# Setup the peer grading module with the proper linked location.
peer_grading = self._create_peer_grading_with_linked_problem(self.coe_location)
# If we specify a location, it will render the problem for that location.
data = peer_grading.handle_ajax('problem', {'location': self.coe_location})
self.assertTrue(json.loads(data)['success'])
# If we don't specify a location, it should use the linked location.
data = peer_grading.handle_ajax('problem', {})
self.assertTrue(json.loads(data)['success'])
def test_linked_score(self):
"""
Ensure that a peer grading problem with a linked location is properly scored.
"""
# Setup the peer grading module with the proper linked location.
peer_grading = self._create_peer_grading_with_linked_problem(self.coe_location)
score_dict = peer_grading.get_score()
self.assertEqual(score_dict['score'], 1)
self.assertEqual(score_dict['total'], 1)
def test_get_next_submission(self):
"""
Ensure that a peer grading problem with a linked location can get a submission to score.
"""
# Setup the peer grading module with the proper linked location.
peer_grading = self._create_peer_grading_with_linked_problem(self.coe_location)
data = peer_grading.handle_ajax('get_next_submission', {'location': self.coe_location})
self.assertEqual(json.loads(data)['submission_id'], 1)
|
agpl-3.0
|
[
646,
2882,
199,
646,
2022,
199,
646,
2050,
199,
504,
1683,
492,
4420,
199,
504,
14568,
14,
3029,
807,
492,
29393,
199,
199,
504,
12971,
14,
698,
63,
576,
492,
7448,
792,
1451,
199,
504,
12971,
14,
955,
492,
20488,
11506,
199,
199,
504,
9872,
14,
10012,
492,
12625,
199,
504,
9872,
14,
2219,
492,
664,
63,
396,
63,
2253,
12,
664,
63,
396,
63,
4120,
63,
2253,
199,
504,
9872,
14,
2219,
14,
396,
63,
1974,
63,
1490,
63,
8960,
492,
9762,
2377,
1617,
199,
504,
9872,
14,
1490,
63,
8960,
63,
16050,
63,
2888,
14,
7866,
63,
16050,
63,
1364,
492,
4420,
12566,
5761,
1098,
3167,
199,
504,
9872,
14,
7866,
63,
16050,
63,
578,
492,
11379,
281,
5761,
1098,
2377,
12,
11379,
281,
5761,
1098,
4311,
12,
9141,
63,
17350,
63,
18068,
7111,
63,
9127,
199,
504,
9872,
14,
10012,
14,
3924,
492,
7020,
10870,
12,
3091,
21271,
2081,
199,
199,
793,
275,
2050,
14,
5572,
3460,
354,
3368,
199,
199,
25797,
275,
298,
24852,
2,
199,
15552,
275,
298,
1490,
63,
8960,
2,
421,
199,
533,
11379,
281,
5761,
1098,
2377,
774,
8,
2796,
14,
1746,
12,
9762,
2377,
1617,
304,
272,
408,
272,
1379,
9104,
22815,
9872,
737,
314,
4137,
2166,
14,
221,
16917,
16212,
2295,
787,
29870,
12,
465,
314,
859,
25749,
641,
376,
272,
5957,
22815,
2435,
14,
272,
408,
272,
5160,
63,
1985,
275,
12625,
5234,
73,
20,
88,
401,
298,
24852,
401,
298,
1490,
63,
8960,
401,
298,
7866,
16050,
401,
639,
298,
12566,
5761,
1098,
8176,
3135,
272,
512,
69,
63,
1985,
275,
12625,
5234,
73,
20,
88,
401,
298,
24852,
401,
298,
1490,
63,
8960,
401,
298,
17583,
1490,
8960,
401,
298,
8176,
16778,
3135,
272,
12855,
12601,
63,
807,
275,
791,
1985,
356,
298,
12702,
3570,
272,
512,
69,
63,
807,
275,
791,
1985,
356,
512,
69,
63,
1985,
14,
633,
12737,
272,
3354,
63,
807,
275,
29393,
2561,
267,
283,
1985,
356,
298,
12702,
401,
267,
283,
12542,
63,
344,
356,
413,
12,
267,
283,
12542,
63,
498,
356,
4873,
267,
283,
3397,
356,
413,
12,
267,
283,
13485,
356,
4873,
267,
283,
12542,
63,
4173,
3046,
356,
756,
12,
267,
283,
5934,
63,
5187,
356,
756,
12,
272,
3828,
272,
3354,
63,
807,
14,
2880,
4725,
21586,
63,
7107,
59,
4300,
1139,
9,
367,
1139,
315,
334,
16,
12,
413,
430,
339,
347,
664,
63,
578,
63,
2253,
8,
277,
12,
5872,
304,
267,
511,
63,
2253,
275,
664,
63,
396,
63,
2253,
342,
267,
511,
63,
2253,
14,
1490,
63,
8960,
63,
16050,
63,
3266,
275,
488,
267,
372,
511,
63,
2253,
339,
347,
3613,
8,
277,
304,
267,
408,
267,
2790,
282,
9104,
22815,
859,
687,
282,
511,
2656,
267,
768,
1107,
26,
267,
408,
267,
291,
14,
2758,
63,
10012,
8,
15552,
9,
267,
291,
14,
7866,
63,
16050,
275,
291,
14,
362,
63,
578,
63,
504,
63,
1985,
8,
277,
14,
6462,
63,
1985,
12,
5099,
14302,
9,
267,
291,
14,
331,
69,
275,
291,
14,
362,
63,
578,
63,
504,
63,
1985,
8,
277,
14,
331,
69,
63,
1985,
12,
5099,
14302,
9,
339,
347,
511,
63,
578,
63,
5938,
8,
277,
304,
267,
408,
267,
1379,
340,
9104,
22815,
365,
6876,
267,
768,
1107,
26,
267,
408,
267,
6876,
275,
291,
14,
7866,
63,
16050,
14,
5938,
342,
267,
291,
14,
3334,
8,
5938,
9,
339,
347,
511,
63,
362,
63,
1360,
8,
277,
304,
267,
408,
267,
1379,
370,
1937,
340,
314,
859,
883,
506,
8018,
267,
768,
1107,
26,
267,
408,
267,
485,
1360,
275,
291,
14,
7866,
63,
16050,
14,
362,
63,
1360,
342,
339,
347,
511,
63,
362,
63,
576,
8,
277,
304,
267,
408,
267,
7649,
10232,
666,
687,
314,
5957,
22815,
2435,
267,
768,
1107,
26,
267,
408,
267,
3182,
12,
485,
576,
275,
291,
14,
7866,
63,
16050,
14,
1131,
63,
576,
63,
509,
63,
1985,
8,
277,
14,
6462,
63,
1985,
14,
633,
1012,
267,
291,
14,
1815,
8,
3742,
9,
339,
347,
511,
63,
362,
63,
3397,
8,
277,
304,
267,
408,
267,
1379,
10232,
314,
5396,
267,
768,
1107,
26,
267,
408,
267,
5396,
275,
291,
14,
7866,
63,
16050,
14,
362,
63,
3397,
342,
267,
291,
14,
7702,
8,
3397,
459,
3397,
1105,
339,
347,
511,
63,
362,
63,
988,
63,
3397,
8,
277,
304,
267,
408,
267,
1379,
10232,
314,
1390,
5396,
267,
768,
1107,
26,
267,
408,
267,
1390,
63,
3397,
275,
291,
14,
7866,
63,
16050,
14,
988,
63,
3397,
342,
267,
291,
14,
2947,
8,
988,
63,
3397,
12,
488,
9,
339,
347,
664,
63,
2184,
63,
12542,
8,
277,
304,
267,
408,
267,
1379,
370,
1937,
340,
781,
883,
664,
314,
2163,
1683,
13071,
267,
768,
1107,
26,
267,
408,
267,
3182,
12,
485,
2184,
63,
12542,
275,
291,
14,
7866,
63,
16050,
14,
362,
63,
2184,
63,
12542,
3252,
1985,
356,
283,
12702,
3071,
267,
291,
14,
629,
8,
3742,
12,
715,
9,
339,
347,
511,
63,
2117,
63,
4523,
8,
277,
304,
267,
408,
267,
1379,
340,
781,
883,
3354,
314,
16183,
267,
768,
1107,
26,
267,
408,
267,
1177,
275,
291,
14,
7866,
63,
16050,
14,
2117,
63,
4523,
8,
277,
14,
2117,
63,
807,
9,
267,
291,
14,
629,
8,
1310,
459,
3742,
995,
715,
9,
339,
347,
511,
63,
374,
63,
5500,
63,
15737,
12601,
8,
277,
304,
267,
408,
267,
2670,
370,
1937,
340,
314,
6474,
965,
12855,
12601,
5966,
267,
768,
1107,
26,
267,
408,
267,
1177,
275,
291,
14,
7866,
63,
16050,
14,
374,
63,
5500,
63,
15737,
12601,
8,
277,
14,
15737,
12601,
63,
807,
9,
267,
291,
14,
1815,
8,
1310,
459,
3742,
1105,
339,
347,
511,
63,
2384,
63,
25851,
63,
16709,
1187,
8,
277,
304,
267,
408,
267,
1379,
21207,
314,
25365,
325,
385,
1187,
267,
768,
1107,
26,
267,
408,
267,
1177,
275,
291,
14,
7866,
63,
16050,
14,
2384,
63,
25851,
63,
16709,
1187,
8,
277,
14,
15737,
12601,
63,
807,
9,
267,
291,
14,
1815,
8,
1310,
459,
3742,
1105,
339,
347,
511,
63,
2117,
63,
25851,
63,
16709,
1187,
8,
277,
304
] |
[
2882,
199,
646,
2022,
199,
646,
2050,
199,
504,
1683,
492,
4420,
199,
504,
14568,
14,
3029,
807,
492,
29393,
199,
199,
504,
12971,
14,
698,
63,
576,
492,
7448,
792,
1451,
199,
504,
12971,
14,
955,
492,
20488,
11506,
199,
199,
504,
9872,
14,
10012,
492,
12625,
199,
504,
9872,
14,
2219,
492,
664,
63,
396,
63,
2253,
12,
664,
63,
396,
63,
4120,
63,
2253,
199,
504,
9872,
14,
2219,
14,
396,
63,
1974,
63,
1490,
63,
8960,
492,
9762,
2377,
1617,
199,
504,
9872,
14,
1490,
63,
8960,
63,
16050,
63,
2888,
14,
7866,
63,
16050,
63,
1364,
492,
4420,
12566,
5761,
1098,
3167,
199,
504,
9872,
14,
7866,
63,
16050,
63,
578,
492,
11379,
281,
5761,
1098,
2377,
12,
11379,
281,
5761,
1098,
4311,
12,
9141,
63,
17350,
63,
18068,
7111,
63,
9127,
199,
504,
9872,
14,
10012,
14,
3924,
492,
7020,
10870,
12,
3091,
21271,
2081,
199,
199,
793,
275,
2050,
14,
5572,
3460,
354,
3368,
199,
199,
25797,
275,
298,
24852,
2,
199,
15552,
275,
298,
1490,
63,
8960,
2,
421,
199,
533,
11379,
281,
5761,
1098,
2377,
774,
8,
2796,
14,
1746,
12,
9762,
2377,
1617,
304,
272,
408,
272,
1379,
9104,
22815,
9872,
737,
314,
4137,
2166,
14,
221,
16917,
16212,
2295,
787,
29870,
12,
465,
314,
859,
25749,
641,
376,
272,
5957,
22815,
2435,
14,
272,
408,
272,
5160,
63,
1985,
275,
12625,
5234,
73,
20,
88,
401,
298,
24852,
401,
298,
1490,
63,
8960,
401,
298,
7866,
16050,
401,
639,
298,
12566,
5761,
1098,
8176,
3135,
272,
512,
69,
63,
1985,
275,
12625,
5234,
73,
20,
88,
401,
298,
24852,
401,
298,
1490,
63,
8960,
401,
298,
17583,
1490,
8960,
401,
298,
8176,
16778,
3135,
272,
12855,
12601,
63,
807,
275,
791,
1985,
356,
298,
12702,
3570,
272,
512,
69,
63,
807,
275,
791,
1985,
356,
512,
69,
63,
1985,
14,
633,
12737,
272,
3354,
63,
807,
275,
29393,
2561,
267,
283,
1985,
356,
298,
12702,
401,
267,
283,
12542,
63,
344,
356,
413,
12,
267,
283,
12542,
63,
498,
356,
4873,
267,
283,
3397,
356,
413,
12,
267,
283,
13485,
356,
4873,
267,
283,
12542,
63,
4173,
3046,
356,
756,
12,
267,
283,
5934,
63,
5187,
356,
756,
12,
272,
3828,
272,
3354,
63,
807,
14,
2880,
4725,
21586,
63,
7107,
59,
4300,
1139,
9,
367,
1139,
315,
334,
16,
12,
413,
430,
339,
347,
664,
63,
578,
63,
2253,
8,
277,
12,
5872,
304,
267,
511,
63,
2253,
275,
664,
63,
396,
63,
2253,
342,
267,
511,
63,
2253,
14,
1490,
63,
8960,
63,
16050,
63,
3266,
275,
488,
267,
372,
511,
63,
2253,
339,
347,
3613,
8,
277,
304,
267,
408,
267,
2790,
282,
9104,
22815,
859,
687,
282,
511,
2656,
267,
768,
1107,
26,
267,
408,
267,
291,
14,
2758,
63,
10012,
8,
15552,
9,
267,
291,
14,
7866,
63,
16050,
275,
291,
14,
362,
63,
578,
63,
504,
63,
1985,
8,
277,
14,
6462,
63,
1985,
12,
5099,
14302,
9,
267,
291,
14,
331,
69,
275,
291,
14,
362,
63,
578,
63,
504,
63,
1985,
8,
277,
14,
331,
69,
63,
1985,
12,
5099,
14302,
9,
339,
347,
511,
63,
578,
63,
5938,
8,
277,
304,
267,
408,
267,
1379,
340,
9104,
22815,
365,
6876,
267,
768,
1107,
26,
267,
408,
267,
6876,
275,
291,
14,
7866,
63,
16050,
14,
5938,
342,
267,
291,
14,
3334,
8,
5938,
9,
339,
347,
511,
63,
362,
63,
1360,
8,
277,
304,
267,
408,
267,
1379,
370,
1937,
340,
314,
859,
883,
506,
8018,
267,
768,
1107,
26,
267,
408,
267,
485,
1360,
275,
291,
14,
7866,
63,
16050,
14,
362,
63,
1360,
342,
339,
347,
511,
63,
362,
63,
576,
8,
277,
304,
267,
408,
267,
7649,
10232,
666,
687,
314,
5957,
22815,
2435,
267,
768,
1107,
26,
267,
408,
267,
3182,
12,
485,
576,
275,
291,
14,
7866,
63,
16050,
14,
1131,
63,
576,
63,
509,
63,
1985,
8,
277,
14,
6462,
63,
1985,
14,
633,
1012,
267,
291,
14,
1815,
8,
3742,
9,
339,
347,
511,
63,
362,
63,
3397,
8,
277,
304,
267,
408,
267,
1379,
10232,
314,
5396,
267,
768,
1107,
26,
267,
408,
267,
5396,
275,
291,
14,
7866,
63,
16050,
14,
362,
63,
3397,
342,
267,
291,
14,
7702,
8,
3397,
459,
3397,
1105,
339,
347,
511,
63,
362,
63,
988,
63,
3397,
8,
277,
304,
267,
408,
267,
1379,
10232,
314,
1390,
5396,
267,
768,
1107,
26,
267,
408,
267,
1390,
63,
3397,
275,
291,
14,
7866,
63,
16050,
14,
988,
63,
3397,
342,
267,
291,
14,
2947,
8,
988,
63,
3397,
12,
488,
9,
339,
347,
664,
63,
2184,
63,
12542,
8,
277,
304,
267,
408,
267,
1379,
370,
1937,
340,
781,
883,
664,
314,
2163,
1683,
13071,
267,
768,
1107,
26,
267,
408,
267,
3182,
12,
485,
2184,
63,
12542,
275,
291,
14,
7866,
63,
16050,
14,
362,
63,
2184,
63,
12542,
3252,
1985,
356,
283,
12702,
3071,
267,
291,
14,
629,
8,
3742,
12,
715,
9,
339,
347,
511,
63,
2117,
63,
4523,
8,
277,
304,
267,
408,
267,
1379,
340,
781,
883,
3354,
314,
16183,
267,
768,
1107,
26,
267,
408,
267,
1177,
275,
291,
14,
7866,
63,
16050,
14,
2117,
63,
4523,
8,
277,
14,
2117,
63,
807,
9,
267,
291,
14,
629,
8,
1310,
459,
3742,
995,
715,
9,
339,
347,
511,
63,
374,
63,
5500,
63,
15737,
12601,
8,
277,
304,
267,
408,
267,
2670,
370,
1937,
340,
314,
6474,
965,
12855,
12601,
5966,
267,
768,
1107,
26,
267,
408,
267,
1177,
275,
291,
14,
7866,
63,
16050,
14,
374,
63,
5500,
63,
15737,
12601,
8,
277,
14,
15737,
12601,
63,
807,
9,
267,
291,
14,
1815,
8,
1310,
459,
3742,
1105,
339,
347,
511,
63,
2384,
63,
25851,
63,
16709,
1187,
8,
277,
304,
267,
408,
267,
1379,
21207,
314,
25365,
325,
385,
1187,
267,
768,
1107,
26,
267,
408,
267,
1177,
275,
291,
14,
7866,
63,
16050,
14,
2384,
63,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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
ms-iot/python
|
cpython/Lib/ctypes/test/test_macholib.py
|
100
|
1830
|
import os
import sys
import unittest
# Bob Ippolito:
#
# Ok.. the code to find the filename for __getattr__ should look
# something like:
#
# import os
# from macholib.dyld import dyld_find
#
# def find_lib(name):
# possible = ['lib'+name+'.dylib', name+'.dylib',
# name+'.framework/'+name]
# for dylib in possible:
# try:
# return os.path.realpath(dyld_find(dylib))
# except ValueError:
# pass
# raise ValueError, "%s not found" % (name,)
#
# It'll have output like this:
#
# >>> find_lib('pthread')
# '/usr/lib/libSystem.B.dylib'
# >>> find_lib('z')
# '/usr/lib/libz.1.dylib'
# >>> find_lib('IOKit')
# '/System/Library/Frameworks/IOKit.framework/Versions/A/IOKit'
#
# -bob
from ctypes.macholib.dyld import dyld_find
def find_lib(name):
possible = ['lib'+name+'.dylib', name+'.dylib', name+'.framework/'+name]
for dylib in possible:
try:
return os.path.realpath(dyld_find(dylib))
except ValueError:
pass
raise ValueError("%s not found" % (name,))
class MachOTest(unittest.TestCase):
@unittest.skipUnless(sys.platform == "darwin", 'OSX-specific test')
def test_find(self):
self.assertEqual(find_lib('pthread'),
'/usr/lib/libSystem.B.dylib')
result = find_lib('z')
# Issue #21093: dyld default search path includes $HOME/lib and
# /usr/local/lib before /usr/lib, which caused test failures if
# a local copy of libz exists in one of them. Now ignore the head
# of the path.
self.assertRegex(result, r".*/lib/libz\..*.*\.dylib")
self.assertEqual(find_lib('IOKit'),
'/System/Library/Frameworks/IOKit.framework/Versions/A/IOKit')
if __name__ == "__main__":
unittest.main()
|
bsd-3-clause
|
[
646,
747,
199,
646,
984,
199,
646,
2882,
199,
199,
3,
699,
2873,
31045,
555,
317,
475,
26,
199,
3,
199,
3,
20049,
703,
314,
1233,
370,
2342,
314,
1788,
367,
636,
5675,
363,
1077,
3648,
199,
3,
6020,
2839,
26,
199,
3,
199,
3,
492,
747,
199,
3,
687,
610,
2239,
773,
14,
8161,
1447,
492,
13119,
1447,
63,
1623,
199,
3,
199,
3,
347,
2342,
63,
773,
8,
354,
304,
199,
3,
420,
3962,
275,
788,
773,
6828,
354,
18098,
22305,
297,
536,
18098,
22305,
297,
199,
3,
420,
536,
18098,
4857,
19047,
354,
61,
199,
3,
420,
367,
13119,
773,
315,
3962,
26,
199,
3,
3515,
862,
26,
199,
3,
4519,
372,
747,
14,
515,
14,
11091,
8,
8161,
1447,
63,
1623,
8,
22305,
430,
199,
3,
3515,
871,
1722,
26,
199,
3,
4519,
986,
199,
3,
420,
746,
1722,
12,
2071,
83,
440,
1911,
2,
450,
334,
354,
4258,
199,
3,
199,
3,
2779,
7171,
1172,
1072,
2839,
642,
26,
199,
3,
199,
3,
221,
1306,
2342,
63,
773,
360,
27869,
358,
199,
3,
1994,
2647,
15,
773,
15,
773,
3989,
14,
34,
14,
22305,
7,
199,
3,
221,
1306,
2342,
63,
773,
360,
90,
358,
199,
3,
1994,
2647,
15,
773,
15,
773,
90,
14,
17,
14,
22305,
7,
199,
3,
221,
1306,
2342,
63,
773,
360,
2090,
14591,
358,
199,
3,
1994,
3989,
15,
7424,
15,
30052,
15,
2090,
14591,
14,
4857,
15,
21167,
15,
33,
15,
2090,
14591,
7,
199,
3,
199,
3,
446,
7913,
199,
199,
504,
5577,
14,
391,
2239,
773,
14,
8161,
1447,
492,
13119,
1447,
63,
1623,
199,
199,
318,
2342,
63,
773,
8,
354,
304,
272,
3962,
275,
788,
773,
6828,
354,
18098,
22305,
297,
536,
18098,
22305,
297,
536,
18098,
4857,
19047,
354,
61,
272,
367,
13119,
773,
315,
3962,
26,
267,
862,
26,
288,
372,
747,
14,
515,
14,
11091,
8,
8161,
1447,
63,
1623,
8,
22305,
430,
267,
871,
1722,
26,
288,
986,
272,
746,
1722,
3647,
83,
440,
1911,
2,
450,
334,
354,
4641,
199,
199,
533,
30611,
47,
774,
8,
2796,
14,
1746,
304,
272,
768,
2796,
14,
11278,
8,
1274,
14,
3246,
508,
298,
13245,
401,
283,
25160,
13,
6100,
511,
358,
272,
347,
511,
63,
1623,
8,
277,
304,
398,
291,
14,
629,
8,
1623,
63,
773,
360,
27869,
659,
2490,
1994,
2647,
15,
773,
15,
773,
3989,
14,
34,
14,
22305,
358,
398,
754,
275,
2342,
63,
773,
360,
90,
358,
267,
327,
13383,
327,
12725,
3129,
26,
13119,
1447,
849,
2754,
931,
6952,
2672,
9524,
15,
773,
436,
267,
327,
1182,
2647,
15,
1832,
15,
773,
2544,
1182,
2647,
15,
773,
12,
1314,
18104,
511,
9081,
340,
267,
327,
282,
2257,
1331,
402,
1973,
90,
3495,
315,
1373,
402,
3062,
14,
7356,
3686,
314,
4854,
267,
327,
402,
314,
931,
14,
267,
291,
14,
31132,
8,
1099,
12,
519,
1674,
15870,
773,
15,
773,
90,
60,
703,
10,
24736,
22305,
531,
398,
291,
14,
629,
8,
1623,
63,
773,
360,
2090,
14591,
659,
2490,
1994,
3989,
15,
7424,
15,
30052,
15,
2090,
14591,
14,
4857,
15,
21167,
15,
33,
15,
2090,
14591,
358,
199,
199,
692,
636,
354,
363,
508,
4396,
973,
5727,
272,
2882,
14,
973,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
747,
199,
646,
984,
199,
646,
2882,
199,
199,
3,
699,
2873,
31045,
555,
317,
475,
26,
199,
3,
199,
3,
20049,
703,
314,
1233,
370,
2342,
314,
1788,
367,
636,
5675,
363,
1077,
3648,
199,
3,
6020,
2839,
26,
199,
3,
199,
3,
492,
747,
199,
3,
687,
610,
2239,
773,
14,
8161,
1447,
492,
13119,
1447,
63,
1623,
199,
3,
199,
3,
347,
2342,
63,
773,
8,
354,
304,
199,
3,
420,
3962,
275,
788,
773,
6828,
354,
18098,
22305,
297,
536,
18098,
22305,
297,
199,
3,
420,
536,
18098,
4857,
19047,
354,
61,
199,
3,
420,
367,
13119,
773,
315,
3962,
26,
199,
3,
3515,
862,
26,
199,
3,
4519,
372,
747,
14,
515,
14,
11091,
8,
8161,
1447,
63,
1623,
8,
22305,
430,
199,
3,
3515,
871,
1722,
26,
199,
3,
4519,
986,
199,
3,
420,
746,
1722,
12,
2071,
83,
440,
1911,
2,
450,
334,
354,
4258,
199,
3,
199,
3,
2779,
7171,
1172,
1072,
2839,
642,
26,
199,
3,
199,
3,
221,
1306,
2342,
63,
773,
360,
27869,
358,
199,
3,
1994,
2647,
15,
773,
15,
773,
3989,
14,
34,
14,
22305,
7,
199,
3,
221,
1306,
2342,
63,
773,
360,
90,
358,
199,
3,
1994,
2647,
15,
773,
15,
773,
90,
14,
17,
14,
22305,
7,
199,
3,
221,
1306,
2342,
63,
773,
360,
2090,
14591,
358,
199,
3,
1994,
3989,
15,
7424,
15,
30052,
15,
2090,
14591,
14,
4857,
15,
21167,
15,
33,
15,
2090,
14591,
7,
199,
3,
199,
3,
446,
7913,
199,
199,
504,
5577,
14,
391,
2239,
773,
14,
8161,
1447,
492,
13119,
1447,
63,
1623,
199,
199,
318,
2342,
63,
773,
8,
354,
304,
272,
3962,
275,
788,
773,
6828,
354,
18098,
22305,
297,
536,
18098,
22305,
297,
536,
18098,
4857,
19047,
354,
61,
272,
367,
13119,
773,
315,
3962,
26,
267,
862,
26,
288,
372,
747,
14,
515,
14,
11091,
8,
8161,
1447,
63,
1623,
8,
22305,
430,
267,
871,
1722,
26,
288,
986,
272,
746,
1722,
3647,
83,
440,
1911,
2,
450,
334,
354,
4641,
199,
199,
533,
30611,
47,
774,
8,
2796,
14,
1746,
304,
272,
768,
2796,
14,
11278,
8,
1274,
14,
3246,
508,
298,
13245,
401,
283,
25160,
13,
6100,
511,
358,
272,
347,
511,
63,
1623,
8,
277,
304,
398,
291,
14,
629,
8,
1623,
63,
773,
360,
27869,
659,
2490,
1994,
2647,
15,
773,
15,
773,
3989,
14,
34,
14,
22305,
358,
398,
754,
275,
2342,
63,
773,
360,
90,
358,
267,
327,
13383,
327,
12725,
3129,
26,
13119,
1447,
849,
2754,
931,
6952,
2672,
9524,
15,
773,
436,
267,
327,
1182,
2647,
15,
1832,
15,
773,
2544,
1182,
2647,
15,
773,
12,
1314,
18104,
511,
9081,
340,
267,
327,
282,
2257,
1331,
402,
1973,
90,
3495,
315,
1373,
402,
3062,
14,
7356,
3686,
314,
4854,
267,
327,
402,
314,
931,
14,
267,
291,
14,
31132,
8,
1099,
12,
519,
1674,
15870,
773,
15,
773,
90,
60,
703,
10,
24736,
22305,
531,
398,
291,
14,
629,
8,
1623,
63,
773,
360,
2090,
14591,
659,
2490,
1994,
3989,
15,
7424,
15,
30052,
15,
2090,
14591,
14,
4857,
15,
21167,
15,
33,
15,
2090,
14591,
358,
199,
199,
692,
636,
354,
363,
508,
4396,
973,
5727,
272,
2882,
14,
973,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
MaximNevrov/neutron
|
neutron/services/bgp/scheduler/bgp_dragent_scheduler.py
|
3
|
7889
|
# Copyright 2016 Huawei Technologies India Pvt. Ltd.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from oslo_db import exception as db_exc
from oslo_log import log as logging
from sqlalchemy.orm import exc
from sqlalchemy import sql
from neutron.db import agents_db
from neutron.db import bgp_db
from neutron.db import bgp_dragentscheduler_db as bgp_dras_db
from neutron._i18n import _LI, _LW
from neutron.scheduler import base_resource_filter
from neutron.scheduler import base_scheduler
from neutron.services.bgp.common import constants as bgp_consts
LOG = logging.getLogger(__name__)
BGP_SPEAKER_PER_DRAGENT = 1
class BgpDrAgentFilter(base_resource_filter.BaseResourceFilter):
def bind(self, context, agents, bgp_speaker_id):
"""Bind the BgpSpeaker to a BgpDrAgent."""
bound_agents = agents[:]
for agent in agents:
# saving agent_id to use it after rollback to avoid
# DetachedInstanceError
agent_id = agent.id
binding = bgp_dras_db.BgpSpeakerDrAgentBinding()
binding.agent_id = agent_id
binding.bgp_speaker_id = bgp_speaker_id
try:
with context.session.begin(subtransactions=True):
context.session.add(binding)
except db_exc.DBDuplicateEntry:
# it's totally ok, someone just did our job!
bound_agents.remove(agent)
LOG.info(_LI('BgpDrAgent %s already present'), agent_id)
LOG.debug('BgpSpeaker %(bgp_speaker_id)s is scheduled to be '
'hosted by BgpDrAgent %(agent_id)s',
{'bgp_speaker_id': bgp_speaker_id,
'agent_id': agent_id})
super(BgpDrAgentFilter, self).bind(context, bound_agents,
bgp_speaker_id)
def filter_agents(self, plugin, context, bgp_speaker):
"""Return the agents that can host the BgpSpeaker."""
agents_dict = self._get_bgp_speaker_hostable_dragents(
plugin, context, bgp_speaker)
if not agents_dict['hostable_agents'] or agents_dict['n_agents'] <= 0:
return {'n_agents': 0,
'hostable_agents': [],
'hosted_agents': []}
return agents_dict
def _get_active_dragents(self, plugin, context):
"""Return a list of active BgpDrAgents."""
with context.session.begin(subtransactions=True):
active_dragents = plugin.get_agents_db(
context, filters={
'agent_type': [bgp_consts.AGENT_TYPE_BGP_ROUTING],
'admin_state_up': [True]})
if not active_dragents:
return []
return active_dragents
def _get_num_dragents_hosting_bgp_speaker(self, bgp_speaker_id,
dragent_bindings):
return sum(1 if dragent_binding.bgp_speaker_id == bgp_speaker_id else 0
for dragent_binding in dragent_bindings)
def _get_bgp_speaker_hostable_dragents(self, plugin, context, bgp_speaker):
"""Return number of additional BgpDrAgents which will actually host
the given BgpSpeaker and a list of BgpDrAgents which can host the
given BgpSpeaker
"""
# only one BgpSpeaker can be hosted by a BgpDrAgent for now.
dragents_per_bgp_speaker = BGP_SPEAKER_PER_DRAGENT
dragent_bindings = plugin.get_dragent_bgp_speaker_bindings(context)
agents_hosting = [dragent_binding.agent_id
for dragent_binding in dragent_bindings]
num_dragents_hosting_bgp_speaker = (
self._get_num_dragents_hosting_bgp_speaker(bgp_speaker['id'],
dragent_bindings))
n_agents = dragents_per_bgp_speaker - num_dragents_hosting_bgp_speaker
if n_agents <= 0:
return {'n_agents': 0,
'hostable_agents': [],
'hosted_agents': []}
active_dragents = self._get_active_dragents(plugin, context)
hostable_dragents = [
agent for agent in set(active_dragents)
if agent.id not in agents_hosting and plugin.is_eligible_agent(
active=True, agent=agent)
]
if not hostable_dragents:
return {'n_agents': 0,
'hostable_agents': [],
'hosted_agents': []}
n_agents = min(len(hostable_dragents), n_agents)
return {'n_agents': n_agents,
'hostable_agents': hostable_dragents,
'hosted_agents': num_dragents_hosting_bgp_speaker}
class BgpDrAgentSchedulerBase(BgpDrAgentFilter):
def schedule_unscheduled_bgp_speakers(self, context, host):
"""Schedule unscheduled BgpSpeaker to a BgpDrAgent.
"""
LOG.debug('Started auto-scheduling on host %s', host)
with context.session.begin(subtransactions=True):
query = context.session.query(agents_db.Agent)
query = query.filter_by(
agent_type=bgp_consts.AGENT_TYPE_BGP_ROUTING,
host=host,
admin_state_up=sql.true())
try:
bgp_dragent = query.one()
except (exc.NoResultFound):
LOG.debug('No enabled BgpDrAgent on host %s', host)
return False
if agents_db.AgentDbMixin.is_agent_down(
bgp_dragent.heartbeat_timestamp):
LOG.warning(_LW('BgpDrAgent %s is down'), bgp_dragent.id)
return False
if self._is_bgp_speaker_hosted(context, bgp_dragent['id']):
# One BgpDrAgent can only host one BGP speaker
LOG.debug('BgpDrAgent already hosting a speaker on host %s. '
'Cannot schedule an another one', host)
return False
unscheduled_speakers = self._get_unscheduled_bgp_speakers(context)
if not unscheduled_speakers:
LOG.debug('Nothing to auto-schedule on host %s', host)
return False
self.bind(context, [bgp_dragent], unscheduled_speakers[0])
return True
def _is_bgp_speaker_hosted(self, context, agent_id):
speaker_binding_model = bgp_dras_db.BgpSpeakerDrAgentBinding
query = context.session.query(speaker_binding_model)
query = query.filter(speaker_binding_model.agent_id == agent_id)
return query.count() > 0
def _get_unscheduled_bgp_speakers(self, context):
"""BGP speakers that needs to be scheduled.
"""
no_agent_binding = ~sql.exists().where(
bgp_db.BgpSpeaker.id ==
bgp_dras_db.BgpSpeakerDrAgentBinding.bgp_speaker_id)
query = context.session.query(bgp_db.BgpSpeaker.id).filter(
no_agent_binding)
return [bgp_speaker_id_[0] for bgp_speaker_id_ in query]
class ChanceScheduler(base_scheduler.BaseChanceScheduler,
BgpDrAgentSchedulerBase):
def __init__(self):
super(ChanceScheduler, self).__init__(self)
class WeightScheduler(base_scheduler.BaseWeightScheduler,
BgpDrAgentSchedulerBase):
def __init__(self):
super(WeightScheduler, self).__init__(self)
|
apache-2.0
|
[
3,
1898,
7800,
869,
1458,
21431,
19215,
1010,
2391,
29053,
14,
12126,
14,
199,
3,
2900,
5924,
5702,
14,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
1265,
1443,
199,
3,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
2047,
1443,
3332,
199,
3,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
258,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
2428,
199,
3,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
1666,
314,
199,
3,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
1334,
314,
844,
14,
199,
199,
504,
11258,
63,
697,
492,
1919,
465,
1592,
63,
2804,
199,
504,
11258,
63,
793,
492,
943,
465,
2050,
199,
504,
8335,
14,
1025,
492,
3178,
199,
504,
8335,
492,
3875,
199,
199,
504,
8224,
14,
697,
492,
22867,
63,
697,
199,
504,
8224,
14,
697,
492,
16884,
63,
697,
199,
504,
8224,
14,
697,
492,
16884,
63,
14479,
484,
8874,
63,
697,
465,
16884,
63,
5012,
305,
63,
697,
199,
504,
8224,
423,
73,
1085,
78,
492,
485,
2673,
12,
485,
20145,
199,
504,
8224,
14,
8874,
492,
1300,
63,
1927,
63,
1541,
199,
504,
8224,
14,
8874,
492,
1300,
63,
8874,
199,
504,
8224,
14,
5950,
14,
10132,
14,
2330,
492,
5262,
465,
16884,
63,
20473,
199,
199,
4947,
275,
2050,
14,
5572,
3460,
354,
3368,
199,
27272,
63,
14179,
7872,
540,
63,
4227,
63,
4564,
14565,
275,
413,
421,
199,
533,
699,
4927,
21733,
7788,
4131,
8,
1095,
63,
1927,
63,
1541,
14,
1563,
4031,
4131,
304,
339,
347,
5398,
8,
277,
12,
1067,
12,
22867,
12,
16884,
63,
32263,
63,
344,
304,
267,
408,
8198,
314,
699,
4927,
51,
19838,
370,
282,
699,
4927,
21733,
7788,
1041,
267,
3914,
63,
14250,
275,
22867,
5873,
267,
367,
6631,
315,
22867,
26,
288,
327,
13369,
6631,
63,
344,
370,
675,
652,
2410,
16475,
370,
5126,
288,
327,
577,
386,
4583,
3244,
547,
288,
6631,
63,
344,
275,
6631,
14,
344,
288,
11696,
275,
16884,
63,
5012,
305,
63,
697,
14,
34,
4927,
51,
19838,
21733,
7788,
17490,
342,
288,
11696,
14,
4054,
63,
344,
275,
6631,
63,
344,
288,
11696,
14,
10132,
63,
32263,
63,
344,
275,
16884,
63,
32263,
63,
344,
288,
862,
26,
355,
543,
1067,
14,
1730,
14,
5037,
8,
954,
13754,
29,
549,
304,
490,
1067,
14,
1730,
14,
525,
8,
9140,
9,
288,
871,
1592,
63,
2804,
14,
2846,
14773,
3900,
26,
355,
327,
652,
1159,
12657,
1183,
4112,
12,
17122,
2951,
8103,
4154,
3906,
1,
355,
3914,
63,
14250,
14,
2168,
8,
4054,
9,
355,
5051,
14,
815,
1547,
2673,
360,
34,
4927,
21733,
7788,
450,
83,
2575,
3451,
659,
6631,
63,
344,
9,
288,
5051,
14,
1757,
360,
34,
4927,
51,
19838,
2818,
10132,
63,
32263,
63,
344,
9,
83,
365,
18416,
370,
506,
283,
1993,
283,
24127,
701,
699,
4927,
21733,
7788,
2818,
4054,
63,
344,
9,
83,
297,
1993,
791,
10132,
63,
32263,
63,
344,
356,
16884,
63,
32263,
63,
344,
12,
2432,
283,
4054,
63,
344,
356,
6631,
63,
344,
1552,
267,
1613,
8,
34,
4927,
21733,
7788,
4131,
12,
291,
680,
3409,
8,
1100,
12,
3914,
63,
14250,
12,
5644,
16884,
63,
32263,
63,
344,
9,
339,
347,
2457,
63,
14250,
8,
277,
12,
3589,
12,
1067,
12,
16884,
63,
32263,
304,
267,
408,
1767,
314,
22867,
626,
883,
1591,
314,
699,
4927,
51,
19838,
1041,
267,
22867,
63,
807,
275,
291,
423,
362,
63,
10132,
63,
32263,
63,
1102,
461,
63,
14479,
24871,
8,
288,
3589,
12,
1067,
12,
16884,
63,
32263,
9,
267,
340,
440,
22867,
63,
807,
459,
1102,
461,
63,
14250,
418,
503,
22867,
63,
807,
459,
78,
63,
14250,
418,
2695,
378,
26,
288,
372,
791,
78,
63,
14250,
356,
378,
12,
490,
283,
1102,
461,
63,
14250,
356,
990,
490,
283,
24127,
63,
14250,
356,
23455,
267,
372,
22867,
63,
807,
339,
347,
485,
362,
63,
2682,
63,
14479,
24871,
8,
277,
12,
3589,
12,
1067,
304,
267,
408,
1767,
282,
769,
402,
4702,
699,
4927,
21733,
7788,
83,
1041,
267,
543,
1067,
14,
1730,
14,
5037,
8,
954,
13754,
29,
549,
304,
288,
4702,
63,
14479,
24871,
275,
3589,
14,
362,
63,
14250,
63,
697,
8,
355,
1067,
12,
4766,
3126,
490,
283,
4054,
63,
466,
356,
359,
10132,
63,
20473,
14,
14565,
63,
2711,
63,
27272,
63,
14999,
1206,
467,
490,
283,
2113,
63,
929,
63,
384,
356,
359,
549,
13412,
288,
340,
440,
4702,
63,
14479,
24871,
26,
355,
372,
942,
267,
372,
4702,
63,
14479,
24871,
339,
347,
485,
362,
63,
1507,
63,
14479,
24871,
63,
29138,
63,
10132,
63,
32263,
8,
277,
12,
16884,
63,
32263,
63,
344,
12,
6343,
18981,
484,
63,
10880,
304,
267,
372,
3089,
8,
17,
340,
18981,
484,
63,
9140,
14,
10132,
63,
32263,
63,
344,
508,
16884,
63,
32263,
63,
344,
587,
378,
673,
367,
18981,
484,
63,
9140,
315,
18981,
484,
63,
10880,
9,
339,
347,
485,
362,
63,
10132,
63,
32263,
63,
1102,
461,
63,
14479,
24871,
8,
277,
12,
3589,
12,
1067,
12,
16884,
63,
32263,
304,
267,
408,
1767,
1329,
402,
4722,
699,
4927,
21733,
7788,
83,
1314,
911,
5965,
1591,
1779,
314,
1627,
699,
4927,
51,
19838,
436,
282,
769,
402,
699,
4927,
21733,
7788,
83,
1314,
883,
1591,
314,
1779,
1627,
699,
4927,
51,
19838,
267,
408,
267,
327,
1454,
1373,
699,
4927,
51,
19838,
883,
506,
28311,
701,
282,
699,
4927,
21733,
7788,
367,
3063,
14,
267,
18981,
24871,
63,
529,
63,
10132,
63,
32263,
275,
27893,
63,
14179,
7872,
540,
63,
4227,
63,
4564,
14565,
267,
18981,
484,
63,
10880,
275,
3589,
14,
362,
63,
14479,
484,
63,
10132,
63,
32263,
63,
10880,
8,
1100,
9,
267,
22867,
63,
29138,
275,
359,
14479,
484,
63,
9140,
14,
4054,
63,
344,
2079,
367,
18981,
484
] |
[
1898,
7800,
869,
1458,
21431,
19215,
1010,
2391,
29053,
14,
12126,
14,
199,
3,
2900,
5924,
5702,
14,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
1265,
1443,
199,
3,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
2047,
1443,
3332,
199,
3,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
258,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
2428,
199,
3,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
1666,
314,
199,
3,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
1334,
314,
844,
14,
199,
199,
504,
11258,
63,
697,
492,
1919,
465,
1592,
63,
2804,
199,
504,
11258,
63,
793,
492,
943,
465,
2050,
199,
504,
8335,
14,
1025,
492,
3178,
199,
504,
8335,
492,
3875,
199,
199,
504,
8224,
14,
697,
492,
22867,
63,
697,
199,
504,
8224,
14,
697,
492,
16884,
63,
697,
199,
504,
8224,
14,
697,
492,
16884,
63,
14479,
484,
8874,
63,
697,
465,
16884,
63,
5012,
305,
63,
697,
199,
504,
8224,
423,
73,
1085,
78,
492,
485,
2673,
12,
485,
20145,
199,
504,
8224,
14,
8874,
492,
1300,
63,
1927,
63,
1541,
199,
504,
8224,
14,
8874,
492,
1300,
63,
8874,
199,
504,
8224,
14,
5950,
14,
10132,
14,
2330,
492,
5262,
465,
16884,
63,
20473,
199,
199,
4947,
275,
2050,
14,
5572,
3460,
354,
3368,
199,
27272,
63,
14179,
7872,
540,
63,
4227,
63,
4564,
14565,
275,
413,
421,
199,
533,
699,
4927,
21733,
7788,
4131,
8,
1095,
63,
1927,
63,
1541,
14,
1563,
4031,
4131,
304,
339,
347,
5398,
8,
277,
12,
1067,
12,
22867,
12,
16884,
63,
32263,
63,
344,
304,
267,
408,
8198,
314,
699,
4927,
51,
19838,
370,
282,
699,
4927,
21733,
7788,
1041,
267,
3914,
63,
14250,
275,
22867,
5873,
267,
367,
6631,
315,
22867,
26,
288,
327,
13369,
6631,
63,
344,
370,
675,
652,
2410,
16475,
370,
5126,
288,
327,
577,
386,
4583,
3244,
547,
288,
6631,
63,
344,
275,
6631,
14,
344,
288,
11696,
275,
16884,
63,
5012,
305,
63,
697,
14,
34,
4927,
51,
19838,
21733,
7788,
17490,
342,
288,
11696,
14,
4054,
63,
344,
275,
6631,
63,
344,
288,
11696,
14,
10132,
63,
32263,
63,
344,
275,
16884,
63,
32263,
63,
344,
288,
862,
26,
355,
543,
1067,
14,
1730,
14,
5037,
8,
954,
13754,
29,
549,
304,
490,
1067,
14,
1730,
14,
525,
8,
9140,
9,
288,
871,
1592,
63,
2804,
14,
2846,
14773,
3900,
26,
355,
327,
652,
1159,
12657,
1183,
4112,
12,
17122,
2951,
8103,
4154,
3906,
1,
355,
3914,
63,
14250,
14,
2168,
8,
4054,
9,
355,
5051,
14,
815,
1547,
2673,
360,
34,
4927,
21733,
7788,
450,
83,
2575,
3451,
659,
6631,
63,
344,
9,
288,
5051,
14,
1757,
360,
34,
4927,
51,
19838,
2818,
10132,
63,
32263,
63,
344,
9,
83,
365,
18416,
370,
506,
283,
1993,
283,
24127,
701,
699,
4927,
21733,
7788,
2818,
4054,
63,
344,
9,
83,
297,
1993,
791,
10132,
63,
32263,
63,
344,
356,
16884,
63,
32263,
63,
344,
12,
2432,
283,
4054,
63,
344,
356,
6631,
63,
344,
1552,
267,
1613,
8,
34,
4927,
21733,
7788,
4131,
12,
291,
680,
3409,
8,
1100,
12,
3914,
63,
14250,
12,
5644,
16884,
63,
32263,
63,
344,
9,
339,
347,
2457,
63,
14250,
8,
277,
12,
3589,
12,
1067,
12,
16884,
63,
32263,
304,
267,
408,
1767,
314,
22867,
626,
883,
1591,
314,
699,
4927,
51,
19838,
1041,
267,
22867,
63,
807,
275,
291,
423,
362,
63,
10132,
63,
32263,
63,
1102,
461,
63,
14479,
24871,
8,
288,
3589,
12,
1067,
12,
16884,
63,
32263,
9,
267,
340,
440,
22867,
63,
807,
459,
1102,
461,
63,
14250,
418,
503,
22867,
63,
807,
459,
78,
63,
14250,
418,
2695,
378,
26,
288,
372,
791,
78,
63,
14250,
356,
378,
12,
490,
283,
1102,
461,
63,
14250,
356,
990,
490,
283,
24127,
63,
14250,
356,
23455,
267,
372,
22867,
63,
807,
339,
347,
485,
362,
63,
2682,
63,
14479,
24871,
8,
277,
12,
3589,
12,
1067,
304,
267,
408,
1767,
282,
769,
402,
4702,
699,
4927,
21733,
7788,
83,
1041,
267,
543,
1067,
14,
1730,
14,
5037,
8,
954,
13754,
29,
549,
304,
288,
4702,
63,
14479,
24871,
275,
3589,
14,
362,
63,
14250,
63,
697,
8,
355,
1067,
12,
4766,
3126,
490,
283,
4054,
63,
466,
356,
359,
10132,
63,
20473,
14,
14565,
63,
2711,
63,
27272,
63,
14999,
1206,
467,
490,
283,
2113,
63,
929,
63,
384,
356,
359,
549,
13412,
288,
340,
440,
4702,
63,
14479,
24871,
26,
355,
372,
942,
267,
372,
4702,
63,
14479,
24871,
339,
347,
485,
362,
63,
1507,
63,
14479,
24871,
63,
29138,
63,
10132,
63,
32263,
8,
277,
12,
16884,
63,
32263,
63,
344,
12,
6343,
18981,
484,
63,
10880,
304,
267,
372,
3089,
8,
17,
340,
18981,
484,
63,
9140,
14,
10132,
63,
32263,
63,
344,
508,
16884,
63,
32263,
63,
344,
587,
378,
673,
367,
18981,
484,
63,
9140,
315,
18981,
484,
63,
10880,
9,
339,
347,
485,
362,
63,
10132,
63,
32263,
63,
1102,
461,
63,
14479,
24871,
8,
277,
12,
3589,
12,
1067,
12,
16884,
63,
32263,
304,
267,
408,
1767,
1329,
402,
4722,
699,
4927,
21733,
7788,
83,
1314,
911,
5965,
1591,
1779,
314,
1627,
699,
4927,
51,
19838,
436,
282,
769,
402,
699,
4927,
21733,
7788,
83,
1314,
883,
1591,
314,
1779,
1627,
699,
4927,
51,
19838,
267,
408,
267,
327,
1454,
1373,
699,
4927,
51,
19838,
883,
506,
28311,
701,
282,
699,
4927,
21733,
7788,
367,
3063,
14,
267,
18981,
24871,
63,
529,
63,
10132,
63,
32263,
275,
27893,
63,
14179,
7872,
540,
63,
4227,
63,
4564,
14565,
267,
18981,
484,
63,
10880,
275,
3589,
14,
362,
63,
14479,
484,
63,
10132,
63,
32263,
63,
10880,
8,
1100,
9,
267,
22867,
63,
29138,
275,
359,
14479,
484,
63,
9140,
14,
4054,
63,
344,
2079,
367,
18981,
484,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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Copyright: (c) 2018, F5 Networks Inc.
# GNU General Public License v3.0 (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
import os
import json
import pytest
import sys
if sys.version_info < (2, 7):
pytestmark = pytest.mark.skip("F5 Ansible modules require Python >= 2.7")
from ansible.module_utils.basic import AnsibleModule
from ansible_collections.f5networks.f5_modules.plugins.modules.bigip_ssl_ocsp import (
ApiParameters, ModuleParameters, ModuleManager, ArgumentSpec
)
from ansible_collections.f5networks.f5_modules.tests.unit.compat import unittest
from ansible_collections.f5networks.f5_modules.tests.unit.compat.mock import Mock, patch
from ansible_collections.f5networks.f5_modules.tests.unit.modules.utils import set_module_args
fixture_path = os.path.join(os.path.dirname(__file__), 'fixtures')
fixture_data = {}
def load_fixture(name):
path = os.path.join(fixture_path, name)
if path in fixture_data:
return fixture_data[path]
with open(path) as f:
data = f.read()
try:
data = json.loads(data)
except Exception:
pass
fixture_data[path] = data
return data
class TestParameters(unittest.TestCase):
def test_module_parameters(self):
args = dict(
name='foo',
clock_skew=100,
connections_limit=101,
)
p = ModuleParameters(params=args)
assert p.name == 'foo'
assert p.clock_skew == 100
assert p.connections_limit == 101
def test_api_parameters(self):
args = load_fixture('load_sys_crypto_cert_validator_1.json')
p = ApiParameters(params=args)
assert p.name == 'asd'
assert p.clock_skew == 300
class TestManager(unittest.TestCase):
def setUp(self):
self.spec = ArgumentSpec()
self.p1 = patch('ansible_collections.f5networks.f5_modules.plugins.modules.bigip_ssl_ocsp.tmos_version')
self.m1 = self.p1.start()
self.m1.return_value = '13.0.0'
self.p3 = patch('ansible_collections.f5networks.f5_modules.plugins.modules.bigip_ssl_ocsp.send_teem')
self.m3 = self.p3.start()
self.m3.return_value = True
def tearDown(self):
self.p1.stop()
self.p3.stop()
def test_create(self, *args):
# Configure the arguments that would be sent to the Ansible module
set_module_args(dict(
name='foo',
clock_skew=100,
provider=dict(
server='localhost',
password='password',
user='admin'
)
))
module = AnsibleModule(
argument_spec=self.spec.argument_spec,
supports_check_mode=self.spec.supports_check_mode,
mutually_exclusive=self.spec.mutually_exclusive,
required_together=self.spec.required_together
)
mm = ModuleManager(module=module)
# Override methods to force specific logic in the module to happen
mm.exists = Mock(return_value=False)
mm.create_on_device = Mock(return_value=True)
results = mm.exec_module()
assert results['changed'] is True
|
mit
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
199,
3,
1898,
26,
334,
67,
9,
14894,
12,
481,
21,
17138,
3277,
14,
199,
3,
1664,
1696,
1684,
844,
373,
19,
14,
16,
334,
3239,
9685,
503,
4178,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
15,
11692,
13,
19,
14,
16,
14,
2424,
9,
199,
199,
504,
636,
2443,
363,
492,
334,
6116,
63,
646,
12,
4629,
12,
870,
63,
1593,
9,
199,
363,
6577,
363,
275,
730,
199,
199,
646,
747,
199,
646,
2022,
199,
646,
4613,
199,
646,
984,
199,
199,
692,
984,
14,
1023,
63,
815,
665,
334,
18,
12,
1520,
304,
272,
4613,
1657,
275,
4613,
14,
1657,
14,
2759,
480,
38,
21,
2622,
4621,
4409,
2018,
2356,
499,
14,
23,
531,
199,
199,
504,
3242,
14,
578,
63,
1208,
14,
4316,
492,
6953,
199,
199,
504,
3242,
63,
7882,
14,
70,
21,
7642,
14,
70,
21,
63,
3112,
14,
5265,
14,
3112,
14,
17833,
63,
4266,
63,
679,
681,
492,
334,
272,
31145,
12,
5673,
5976,
12,
24118,
12,
28405,
199,
9,
199,
504,
3242,
63,
7882,
14,
70,
21,
7642,
14,
70,
21,
63,
3112,
14,
2219,
14,
3248,
14,
5819,
492,
2882,
199,
504,
3242,
63,
7882,
14,
70,
21,
7642,
14,
70,
21,
63,
3112,
14,
2219,
14,
3248,
14,
5819,
14,
1805,
492,
4420,
12,
3371,
199,
504,
3242,
63,
7882,
14,
70,
21,
7642,
14,
70,
21,
63,
3112,
14,
2219,
14,
3248,
14,
3112,
14,
1208,
492,
663,
63,
578,
63,
589,
421,
199,
5997,
63,
515,
275,
747,
14,
515,
14,
904,
8,
736,
14,
515,
14,
3475,
3460,
493,
10139,
283,
8769,
358,
199,
5997,
63,
576,
275,
1052,
421,
199,
318,
2248,
63,
5997,
8,
354,
304,
272,
931,
275,
747,
14,
515,
14,
904,
8,
5997,
63,
515,
12,
536,
9,
339,
340,
931,
315,
10949,
63,
576,
26,
267,
372,
10949,
63,
576,
59,
515,
61,
339,
543,
1551,
8,
515,
9,
465,
289,
26,
267,
666,
275,
289,
14,
739,
342,
339,
862,
26,
267,
666,
275,
2022,
14,
3640,
8,
576,
9,
272,
871,
2186,
26,
267,
986,
339,
10949,
63,
576,
59,
515,
61,
275,
666,
272,
372,
666,
421,
199,
533,
1379,
5976,
8,
2796,
14,
1746,
304,
272,
347,
511,
63,
578,
63,
3214,
8,
277,
304,
267,
1249,
275,
1211,
8,
288,
536,
534,
1421,
297,
288,
12516,
63,
27424,
29,
1960,
12,
288,
6947,
63,
3097,
29,
4893,
12,
267,
776,
398,
299,
275,
5673,
5976,
8,
1162,
29,
589,
9,
267,
702,
299,
14,
354,
508,
283,
1421,
7,
267,
702,
299,
14,
9597,
63,
27424,
508,
2948,
267,
702,
299,
14,
7995,
63,
3097,
508,
14313,
339,
347,
511,
63,
1246,
63,
3214,
8,
277,
304,
267,
1249,
275,
2248,
63,
5997,
360,
912,
63,
1274,
63,
10316,
63,
4736,
63,
11034,
63,
17,
14,
1001,
358,
267,
299,
275,
31145,
8,
1162,
29,
589,
9,
267,
702,
299,
14,
354,
508,
283,
305,
68,
7,
267,
702,
299,
14,
9597,
63,
27424,
508,
9601,
421,
199,
533,
1379,
2988,
8,
2796,
14,
1746,
304,
339,
347,
3613,
8,
277,
304,
267,
291,
14,
1650,
275,
28405,
342,
267,
291,
14,
80,
17,
275,
3371,
360,
4853,
63,
7882,
14,
70,
21,
7642,
14,
70,
21,
63,
3112,
14,
5265,
14,
3112,
14,
17833,
63,
4266,
63,
679,
681,
14,
84,
16908,
63,
1023,
358,
267,
291,
14,
77,
17,
275,
291,
14,
80,
17,
14,
928,
342,
267,
291,
14,
77,
17,
14,
1107,
63,
585,
275,
283,
969,
14,
16,
14,
16,
7,
267,
291,
14,
80,
19,
275,
3371,
360,
4853,
63,
7882,
14,
70,
21,
7642,
14,
70,
21,
63,
3112,
14,
5265,
14,
3112,
14,
17833,
63,
4266,
63,
679,
681,
14,
2254,
63,
266,
5633,
358,
267,
291,
14,
77,
19,
275,
291,
14,
80,
19,
14,
928,
342,
267,
291,
14,
77,
19,
14,
1107,
63,
585,
275,
715,
339,
347,
6766,
8,
277,
304,
267,
291,
14,
80,
17,
14,
2379,
342,
267,
291,
14,
80,
19,
14,
2379,
342,
339,
347,
511,
63,
981,
8,
277,
12,
627,
589,
304,
267,
327,
15453,
314,
2368,
626,
3955,
506,
4847,
370,
314,
2622,
859,
267,
663,
63,
578,
63,
589,
8,
807,
8,
288,
536,
534,
1421,
297,
288,
12516,
63,
27424,
29,
1960,
12,
288,
5022,
29,
807,
8,
355,
1654,
534,
5967,
297,
355,
2505,
534,
2060,
297,
355,
922,
534,
2113,
7,
288,
776,
267,
5082,
398,
859,
275,
6953,
8,
288,
1423,
63,
1650,
29,
277,
14,
1650,
14,
2094,
63,
1650,
12,
288,
5171,
63,
1074,
63,
632,
29,
277,
14,
1650,
14,
9823,
63,
1074,
63,
632,
12,
288,
16108,
63,
12730,
29,
277,
14,
1650,
14,
25024,
63,
12730,
12,
288,
1415,
63,
6314,
29,
277,
14,
1650,
14,
2427,
63,
6314,
267,
776,
267,
8562,
275,
24118,
8,
578,
29,
578,
9,
398,
327,
11041,
3102,
370,
3542,
2488,
9661,
315,
314,
859,
370,
5992,
267,
8562,
14,
2444,
275,
4420,
8,
1107,
63,
585,
29,
797,
9,
267,
8562,
14,
981,
63,
265,
63,
1782,
275,
4420,
8,
1107,
63,
585,
29,
549,
9,
398,
2058,
275,
8562,
14,
1628,
63,
578,
342,
398,
702,
2058,
459,
2489,
418,
365,
715,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
199,
3,
1898,
26,
334,
67,
9,
14894,
12,
481,
21,
17138,
3277,
14,
199,
3,
1664,
1696,
1684,
844,
373,
19,
14,
16,
334,
3239,
9685,
503,
4178,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
15,
11692,
13,
19,
14,
16,
14,
2424,
9,
199,
199,
504,
636,
2443,
363,
492,
334,
6116,
63,
646,
12,
4629,
12,
870,
63,
1593,
9,
199,
363,
6577,
363,
275,
730,
199,
199,
646,
747,
199,
646,
2022,
199,
646,
4613,
199,
646,
984,
199,
199,
692,
984,
14,
1023,
63,
815,
665,
334,
18,
12,
1520,
304,
272,
4613,
1657,
275,
4613,
14,
1657,
14,
2759,
480,
38,
21,
2622,
4621,
4409,
2018,
2356,
499,
14,
23,
531,
199,
199,
504,
3242,
14,
578,
63,
1208,
14,
4316,
492,
6953,
199,
199,
504,
3242,
63,
7882,
14,
70,
21,
7642,
14,
70,
21,
63,
3112,
14,
5265,
14,
3112,
14,
17833,
63,
4266,
63,
679,
681,
492,
334,
272,
31145,
12,
5673,
5976,
12,
24118,
12,
28405,
199,
9,
199,
504,
3242,
63,
7882,
14,
70,
21,
7642,
14,
70,
21,
63,
3112,
14,
2219,
14,
3248,
14,
5819,
492,
2882,
199,
504,
3242,
63,
7882,
14,
70,
21,
7642,
14,
70,
21,
63,
3112,
14,
2219,
14,
3248,
14,
5819,
14,
1805,
492,
4420,
12,
3371,
199,
504,
3242,
63,
7882,
14,
70,
21,
7642,
14,
70,
21,
63,
3112,
14,
2219,
14,
3248,
14,
3112,
14,
1208,
492,
663,
63,
578,
63,
589,
421,
199,
5997,
63,
515,
275,
747,
14,
515,
14,
904,
8,
736,
14,
515,
14,
3475,
3460,
493,
10139,
283,
8769,
358,
199,
5997,
63,
576,
275,
1052,
421,
199,
318,
2248,
63,
5997,
8,
354,
304,
272,
931,
275,
747,
14,
515,
14,
904,
8,
5997,
63,
515,
12,
536,
9,
339,
340,
931,
315,
10949,
63,
576,
26,
267,
372,
10949,
63,
576,
59,
515,
61,
339,
543,
1551,
8,
515,
9,
465,
289,
26,
267,
666,
275,
289,
14,
739,
342,
339,
862,
26,
267,
666,
275,
2022,
14,
3640,
8,
576,
9,
272,
871,
2186,
26,
267,
986,
339,
10949,
63,
576,
59,
515,
61,
275,
666,
272,
372,
666,
421,
199,
533,
1379,
5976,
8,
2796,
14,
1746,
304,
272,
347,
511,
63,
578,
63,
3214,
8,
277,
304,
267,
1249,
275,
1211,
8,
288,
536,
534,
1421,
297,
288,
12516,
63,
27424,
29,
1960,
12,
288,
6947,
63,
3097,
29,
4893,
12,
267,
776,
398,
299,
275,
5673,
5976,
8,
1162,
29,
589,
9,
267,
702,
299,
14,
354,
508,
283,
1421,
7,
267,
702,
299,
14,
9597,
63,
27424,
508,
2948,
267,
702,
299,
14,
7995,
63,
3097,
508,
14313,
339,
347,
511,
63,
1246,
63,
3214,
8,
277,
304,
267,
1249,
275,
2248,
63,
5997,
360,
912,
63,
1274,
63,
10316,
63,
4736,
63,
11034,
63,
17,
14,
1001,
358,
267,
299,
275,
31145,
8,
1162,
29,
589,
9,
267,
702,
299,
14,
354,
508,
283,
305,
68,
7,
267,
702,
299,
14,
9597,
63,
27424,
508,
9601,
421,
199,
533,
1379,
2988,
8,
2796,
14,
1746,
304,
339,
347,
3613,
8,
277,
304,
267,
291,
14,
1650,
275,
28405,
342,
267,
291,
14,
80,
17,
275,
3371,
360,
4853,
63,
7882,
14,
70,
21,
7642,
14,
70,
21,
63,
3112,
14,
5265,
14,
3112,
14,
17833,
63,
4266,
63,
679,
681,
14,
84,
16908,
63,
1023,
358,
267,
291,
14,
77,
17,
275,
291,
14,
80,
17,
14,
928,
342,
267,
291,
14,
77,
17,
14,
1107,
63,
585,
275,
283,
969,
14,
16,
14,
16,
7,
267,
291,
14,
80,
19,
275,
3371,
360,
4853,
63,
7882,
14,
70,
21,
7642,
14,
70,
21,
63,
3112,
14,
5265,
14,
3112,
14,
17833,
63,
4266,
63,
679,
681,
14,
2254,
63,
266,
5633,
358,
267,
291,
14,
77,
19,
275,
291,
14,
80,
19,
14,
928,
342,
267,
291,
14,
77,
19,
14,
1107,
63,
585,
275,
715,
339,
347,
6766,
8,
277,
304,
267,
291,
14,
80,
17,
14,
2379,
342,
267,
291,
14,
80,
19,
14,
2379,
342,
339,
347,
511,
63,
981,
8,
277,
12,
627,
589,
304,
267,
327,
15453,
314,
2368,
626,
3955,
506,
4847,
370,
314,
2622,
859,
267,
663,
63,
578,
63,
589,
8,
807,
8,
288,
536,
534,
1421,
297,
288,
12516,
63,
27424,
29,
1960,
12,
288,
5022,
29,
807,
8,
355,
1654,
534,
5967,
297,
355,
2505,
534,
2060,
297,
355,
922,
534,
2113,
7,
288,
776,
267,
5082,
398,
859,
275,
6953,
8,
288,
1423,
63,
1650,
29,
277,
14,
1650,
14,
2094,
63,
1650,
12,
288,
5171,
63,
1074,
63,
632,
29,
277,
14,
1650,
14,
9823,
63,
1074,
63,
632,
12,
288,
16108,
63,
12730,
29,
277,
14,
1650,
14,
25024,
63,
12730,
12,
288,
1415,
63,
6314,
29,
277,
14,
1650,
14,
2427,
63,
6314,
267,
776,
267,
8562,
275,
24118,
8,
578,
29,
578,
9,
398,
327,
11041,
3102,
370,
3542,
2488,
9661,
315,
314,
859,
370,
5992,
267,
8562,
14,
2444,
275,
4420,
8,
1107,
63,
585,
29,
797,
9,
267,
8562,
14,
981,
63,
265,
63,
1782,
275,
4420,
8,
1107,
63,
585,
29,
549,
9,
398,
2058,
275,
8562,
14,
1628,
63,
578,
342,
398,
702,
2058,
459,
2489,
418,
365,
715,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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<sebastian.kornehl@asideas.de>
#
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
# import module snippets
ANSIBLE_METADATA = {'metadata_version': '1.0',
'status': ['preview'],
'supported_by': 'community'}
DOCUMENTATION = '''
---
module: datadog_monitor
short_description: Manages Datadog monitors
description:
- "Manages monitors within Datadog"
- "Options like described on http://docs.datadoghq.com/api/"
version_added: "2.0"
author: "Sebastian Kornehl (@skornehl)"
requirements: [datadog]
options:
api_key:
description: ["Your DataDog API key."]
required: true
app_key:
description: ["Your DataDog app key."]
required: true
state:
description: ["The designated state of the monitor."]
required: true
choices: ['present', 'absent', 'muted', 'unmuted']
tags:
description: ["A list of tags to associate with your monitor when creating or updating. This can help you categorize and filter monitors."]
required: false
default: None
version_added: "2.2"
type:
description:
- "The type of the monitor."
- The 'event alert'is available starting at Ansible 2.1
required: false
default: null
choices: ['metric alert', 'service check', 'event alert']
query:
description: ["The monitor query to notify on with syntax varying depending on what type of monitor you are creating."]
required: false
default: null
name:
description: ["The name of the alert."]
required: true
message:
description:
- A message to include with notifications for this monitor. Email notifications can be sent to specific users by using the same
'@username' notation as events. Monitor message template variables can be accessed by using double square brackets, i.e '[[' and ']]'.
required: false
default: null
silenced:
description: ["Dictionary of scopes to timestamps or None. Each scope will be muted until the given POSIX timestamp or forever if the value is None. "]
required: false
default: ""
notify_no_data:
description: ["A boolean indicating whether this monitor will notify when data stops reporting.."]
required: false
default: False
no_data_timeframe:
description:
- The number of minutes before a monitor will notify when data stops reporting. Must be at least 2x the monitor timeframe for metric
alerts or 2 minutes for service checks.
required: false
default: 2x timeframe for metric, 2 minutes for service
timeout_h:
description: ["The number of hours of the monitor not reporting data before it will automatically resolve from a triggered state."]
required: false
default: null
renotify_interval:
description:
- The number of minutes after the last notification before a monitor will re-notify on the current status. It will only re-notify if it's
not resolved.
required: false
default: null
escalation_message:
description:
- A message to include with a re-notification. Supports the '@username' notification we allow elsewhere. Not applicable if renotify_interval
is None
required: false
default: null
notify_audit:
description: ["A boolean indicating whether tagged users will be notified on changes to this monitor."]
required: false
default: False
thresholds:
description:
- A dictionary of thresholds by status. This option is only available for service checks and metric alerts. Because each of them can have
multiple thresholds, we don't define them directly in the query."]
required: false
default: {'ok': 1, 'critical': 1, 'warning': 1}
locked:
description: ["A boolean indicating whether changes to this monitor should be restricted to the creator or admins."]
required: false
default: False
version_added: "2.2"
require_full_window:
description:
- A boolean indicating whether this monitor needs a full window of data before it's evaluated. We highly recommend you set this to False for
sparse metrics, otherwise some evaluations will be skipped.
required: false
default: null
version_added: "2.3"
id:
description: ["The id of the alert. If set, will be used instead of the name to locate the alert."]
required: false
default: null
version_added: "2.3"
'''
EXAMPLES = '''
# Create a metric monitor
datadog_monitor:
type: "metric alert"
name: "Test monitor"
state: "present"
query: "datadog.agent.up.over('host:host1').last(2).count_by_status()"
message: "Host [[host.name]] with IP [[host.ip]] is failing to report to datadog."
api_key: "9775a026f1ca7d1c6c5af9d94d9595a4"
app_key: "87ce4a24b5553d2e482ea8a8500e71b8ad4554ff"
# Deletes a monitor
datadog_monitor:
name: "Test monitor"
state: "absent"
api_key: "9775a026f1ca7d1c6c5af9d94d9595a4"
app_key: "87ce4a24b5553d2e482ea8a8500e71b8ad4554ff"
# Mutes a monitor
datadog_monitor:
name: "Test monitor"
state: "mute"
silenced: '{"*":None}'
api_key: "9775a026f1ca7d1c6c5af9d94d9595a4"
app_key: "87ce4a24b5553d2e482ea8a8500e71b8ad4554ff"
# Unmutes a monitor
datadog_monitor:
name: "Test monitor"
state: "unmute"
api_key: "9775a026f1ca7d1c6c5af9d94d9595a4"
app_key: "87ce4a24b5553d2e482ea8a8500e71b8ad4554ff"
'''
# Import Datadog
try:
from datadog import initialize, api
HAS_DATADOG = True
except:
HAS_DATADOG = False
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.pycompat24 import get_exception
def main():
module = AnsibleModule(
argument_spec=dict(
api_key=dict(required=True, no_log=True),
app_key=dict(required=True, no_log=True),
state=dict(required=True, choises=['present', 'absent', 'mute', 'unmute']),
type=dict(required=False, choises=['metric alert', 'service check', 'event alert']),
name=dict(required=True),
query=dict(required=False),
message=dict(required=False, default=None),
silenced=dict(required=False, default=None, type='dict'),
notify_no_data=dict(required=False, default=False, type='bool'),
no_data_timeframe=dict(required=False, default=None),
timeout_h=dict(required=False, default=None),
renotify_interval=dict(required=False, default=None),
escalation_message=dict(required=False, default=None),
notify_audit=dict(required=False, default=False, type='bool'),
thresholds=dict(required=False, type='dict', default=None),
tags=dict(required=False, type='list', default=None),
locked=dict(required=False, default=False, type='bool'),
require_full_window=dict(required=False, default=None, type='bool'),
id=dict(required=False)
)
)
# Prepare Datadog
if not HAS_DATADOG:
module.fail_json(msg='datadogpy required for this module')
options = {
'api_key': module.params['api_key'],
'app_key': module.params['app_key']
}
initialize(**options)
# Check if api_key and app_key is correct or not
# if not, then fail here.
response = api.Monitor.get_all()
if isinstance(response, dict):
msg = response.get('errors', None)
if msg:
module.fail_json(msg="Failed to connect Datadog server using given app_key and api_key : {0}".format(msg[0]))
if module.params['state'] == 'present':
install_monitor(module)
elif module.params['state'] == 'absent':
delete_monitor(module)
elif module.params['state'] == 'mute':
mute_monitor(module)
elif module.params['state'] == 'unmute':
unmute_monitor(module)
def _fix_template_vars(message):
if message:
return message.replace('[[', '{{').replace(']]', '}}')
return message
def _get_monitor(module):
if module.params['id'] is not None:
monitor = api.Monitor.get(module.params['id'])
if 'errors' in monitor:
module.fail_json(msg="Failed to retrieve monitor with id %s, errors are %s" % (module.params['id'], str(monitor['errors'])))
return monitor
else:
monitors = api.Monitor.get_all()
for monitor in monitors:
if monitor['name'] == module.params['name']:
return monitor
return {}
def _post_monitor(module, options):
try:
kwargs = dict(type=module.params['type'], query=module.params['query'],
name=module.params['name'], message=_fix_template_vars(module.params['message']),
options=options)
if module.params['tags'] is not None:
kwargs['tags'] = module.params['tags']
msg = api.Monitor.create(**kwargs)
if 'errors' in msg:
module.fail_json(msg=str(msg['errors']))
else:
module.exit_json(changed=True, msg=msg)
except Exception:
e = get_exception()
module.fail_json(msg=str(e))
def _equal_dicts(a, b, ignore_keys):
ka = set(a).difference(ignore_keys)
kb = set(b).difference(ignore_keys)
return ka == kb and all(a[k] == b[k] for k in ka)
def _update_monitor(module, monitor, options):
try:
kwargs = dict(id=monitor['id'], query=module.params['query'],
name=module.params['name'], message=_fix_template_vars(module.params['message']),
options=options)
if module.params['tags'] is not None:
kwargs['tags'] = module.params['tags']
msg = api.Monitor.update(**kwargs)
if 'errors' in msg:
module.fail_json(msg=str(msg['errors']))
elif _equal_dicts(msg, monitor, ['creator', 'overall_state', 'modified', 'matching_downtimes', 'overall_state_modified']):
module.exit_json(changed=False, msg=msg)
else:
module.exit_json(changed=True, msg=msg)
except Exception:
e = get_exception()
module.fail_json(msg=str(e))
def install_monitor(module):
options = {
"silenced": module.params['silenced'],
"notify_no_data": module.boolean(module.params['notify_no_data']),
"no_data_timeframe": module.params['no_data_timeframe'],
"timeout_h": module.params['timeout_h'],
"renotify_interval": module.params['renotify_interval'],
"escalation_message": module.params['escalation_message'],
"notify_audit": module.boolean(module.params['notify_audit']),
"locked": module.boolean(module.params['locked']),
"require_full_window": module.params['require_full_window']
}
if module.params['type'] == "service check":
options["thresholds"] = module.params['thresholds'] or {'ok': 1, 'critical': 1, 'warning': 1}
if module.params['type'] == "metric alert" and module.params['thresholds'] is not None:
options["thresholds"] = module.params['thresholds']
monitor = _get_monitor(module)
if not monitor:
_post_monitor(module, options)
else:
_update_monitor(module, monitor, options)
def delete_monitor(module):
monitor = _get_monitor(module)
if not monitor:
module.exit_json(changed=False)
try:
msg = api.Monitor.delete(monitor['id'])
module.exit_json(changed=True, msg=msg)
except Exception:
e = get_exception()
module.fail_json(msg=str(e))
def mute_monitor(module):
monitor = _get_monitor(module)
if not monitor:
module.fail_json(msg="Monitor %s not found!" % module.params['name'])
elif monitor['options']['silenced']:
module.fail_json(msg="Monitor is already muted. Datadog does not allow to modify muted alerts, consider unmuting it first.")
elif (module.params['silenced'] is not None and len(set(monitor['options']['silenced']) - set(module.params['silenced'])) == 0):
module.exit_json(changed=False)
try:
if module.params['silenced'] is None or module.params['silenced'] == "":
msg = api.Monitor.mute(id=monitor['id'])
else:
msg = api.Monitor.mute(id=monitor['id'], silenced=module.params['silenced'])
module.exit_json(changed=True, msg=msg)
except Exception:
e = get_exception()
module.fail_json(msg=str(e))
def unmute_monitor(module):
monitor = _get_monitor(module)
if not monitor:
module.fail_json(msg="Monitor %s not found!" % module.params['name'])
elif not monitor['options']['silenced']:
module.exit_json(changed=False)
try:
msg = api.Monitor.unmute(monitor['id'])
module.exit_json(changed=True, msg=msg)
except Exception:
e = get_exception()
module.fail_json(msg=str(e))
if __name__ == '__main__':
main()
|
gpl-3.0
|
[
3381,
2647,
15,
1393,
15,
1548,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
3,
334,
67,
9,
6900,
12,
428,
2871,
1810,
5653,
1804,
269,
685,
15544,
665,
261,
66,
1810,
5653,
14,
75,
269,
685,
15544,
32,
28135,
305,
14,
271,
30,
199,
3,
199,
3,
961,
570,
365,
1777,
402,
2622,
199,
3,
199,
3,
2622,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
199,
3,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
844,
12,
503,
199,
3,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
2622,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
3,
3180,
543,
2622,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
3,
492,
859,
19484,
199,
199,
8490,
63,
8314,
275,
791,
2343,
63,
1023,
356,
283,
17,
14,
16,
297,
490,
283,
1205,
356,
788,
7780,
995,
490,
283,
4946,
63,
991,
356,
283,
9387,
936,
421,
199,
8948,
275,
1449,
199,
2595,
199,
578,
26,
6394,
30821,
63,
7157,
199,
3612,
63,
1802,
26,
21612,
577,
292,
30821,
26862,
199,
1802,
26,
199,
13,
298,
2395,
7441,
26862,
4453,
577,
292,
30821,
2,
199,
13,
298,
4558,
2839,
11736,
641,
1455,
921,
4757,
14,
4616,
30821,
21550,
14,
957,
15,
1246,
6687,
199,
1023,
63,
3270,
26,
298,
18,
14,
16,
2,
199,
2502,
26,
298,
1513,
66,
1810,
5653,
1804,
269,
685,
15544,
8593,
1339,
269,
685,
15544,
2924,
199,
7538,
26,
359,
4616,
30821,
61,
199,
1419,
26,
272,
2986,
63,
498,
26,
267,
1369,
26,
2097,
14398,
3918,
36,
974,
3261,
790,
14,
937,
267,
1415,
26,
2549,
272,
1145,
63,
498,
26,
267,
1369,
26,
2097,
14398,
3918,
36,
974,
1145,
790,
14,
937,
267,
1415,
26,
2549,
272,
1174,
26,
267,
1369,
26,
2097,
1918,
12899,
972,
1174,
402,
314,
8372,
14,
937,
267,
1415,
26,
2549,
267,
3415,
26,
788,
1881,
297,
283,
5575,
297,
283,
77,
4241,
297,
283,
324,
77,
4241,
418,
272,
3762,
26,
267,
1369,
26,
2097,
33,
769,
402,
3762,
370,
20133,
543,
2195,
8372,
1380,
6425,
503,
12928,
14,
961,
883,
1720,
1265,
7737,
269,
794,
436,
2457,
26862,
14,
937,
267,
1415,
26,
3055,
267,
849,
26,
488,
267,
1015,
63,
3270,
26,
298,
18,
14,
18,
2,
272,
730,
26,
267,
1369,
26,
288,
446,
298,
1918,
730,
402,
314,
8372,
2122,
288,
446,
710,
283,
1430,
10459,
7,
374,
2808,
6617,
737,
2622,
499,
14,
17,
267,
1415,
26,
3055,
267,
849,
26,
2973,
267,
3415,
26,
788,
5165,
10459,
297,
283,
1364,
1104,
297,
283,
1430,
10459,
418,
272,
1827,
26,
267,
1369,
26,
2097,
1918,
8372,
1827,
370,
11705,
641,
543,
6302,
17083,
316,
10298,
641,
4052,
730,
402,
8372,
1265,
787,
6425,
14,
937,
267,
1415,
26,
3055,
267,
849,
26,
2973,
272,
536,
26,
267,
1369,
26,
2097,
1918,
536,
402,
314,
10459,
14,
937,
267,
1415,
26,
2549,
272,
1245,
26,
267,
1369,
26,
288,
446,
437,
1245,
370,
2387,
543,
13116,
367,
642,
8372,
14,
11426,
13116,
883,
506,
4847,
370,
2488,
4390,
701,
1808,
314,
2011,
1598,
10267,
2473,
7,
15843,
465,
4474,
14,
26504,
1245,
1978,
2860,
883,
506,
13810,
701,
1808,
4270,
12386,
21873,
12,
284,
14,
69,
6730,
459,
436,
283,
2677,
1370,
267,
1415,
26,
3055,
267,
849,
26,
2973,
272,
9767,
78,
6867,
26,
267,
1369,
26,
2097,
11728,
402,
14570,
370,
22496,
503,
488,
14,
7048,
4194,
911,
506,
333,
4241,
5133,
314,
1627,
18169,
4913,
503,
28688,
340,
314,
574,
365,
488,
14,
32705,
267,
1415,
26,
3055,
267,
849,
26,
3087,
272,
11705,
63,
889,
63,
576,
26,
267,
1369,
26,
2097,
33,
5046,
9297,
3775,
642,
8372,
911,
11705,
1380,
666,
20922,
17290,
703,
937,
267,
1415,
26,
3055,
267,
849,
26,
756,
272,
949,
63,
576,
63,
521,
1943,
26,
267,
1369,
26,
288,
446,
710,
1329,
402,
9395,
2544,
282,
8372,
911,
11705,
1380,
666,
20922,
17290,
14,
9498,
506,
737,
5210,
499,
88,
314,
8372,
900,
1943,
367,
6370,
1598,
31529,
503,
499,
9395,
367,
2435,
5920,
14,
267,
1415,
26,
3055,
267,
849,
26,
499,
88,
900,
1943,
367,
6370,
12,
499,
9395,
367,
2435,
272,
2653,
63,
72,
26,
267,
1369,
26,
2097,
1918,
1329,
402,
10857,
402,
314,
8372,
440,
17290,
666,
2544,
652,
911,
5847,
7512,
687,
282,
15572,
1174,
14,
937,
267,
1415,
26,
3055,
267,
849,
26,
2973,
272,
295,
6814,
63,
4284,
26,
267,
1369,
26,
288,
446,
710,
1329,
402,
9395,
2410,
314,
2061,
6955,
2544,
282,
8372,
911,
295,
13,
6814,
641,
314,
1453,
2004,
14,
2779,
911,
1454,
295,
13,
6814,
340,
652,
1159,
1598,
440,
12152,
14,
267,
1415,
26,
3055,
267,
849,
26,
2973,
272,
325,
4732,
425,
63,
1188,
26,
267,
1369,
26,
288,
446,
437,
1245,
370,
2387,
543,
282,
295,
13,
6761,
14,
32090,
314,
10267,
2473,
7,
6955,
781,
2040,
25320,
14,
2832,
3964,
340,
295,
6814,
63,
4284,
1598,
365,
488,
267,
1415,
26,
3055,
267,
849,
26,
2973,
272,
11705,
63,
14274,
26,
267,
1369,
26,
2097,
33,
5046,
9297,
3775,
20018,
4390,
911,
506,
29535,
641,
4493,
370,
642,
8372,
14,
937,
267,
1415,
26,
3055,
267,
849,
26,
756,
272,
22757,
26,
267,
1369,
26,
288,
446,
437,
2600,
402,
22757,
701,
2004,
14,
961,
945,
365,
1454,
2808,
367,
2435,
5920,
436,
6370,
31529,
14,
13821,
1924,
402,
3062,
883,
1172,
1598,
3663,
22757,
12,
781,
2793,
1133,
5627,
3062,
5370,
315,
314,
1827,
14,
937,
267,
1415,
26,
3055,
267,
849,
26,
791,
745,
356,
413,
12,
283,
13138,
356,
413
] |
[
2647,
15,
1393,
15,
1548,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
3,
334,
67,
9,
6900,
12,
428,
2871,
1810,
5653,
1804,
269,
685,
15544,
665,
261,
66,
1810,
5653,
14,
75,
269,
685,
15544,
32,
28135,
305,
14,
271,
30,
199,
3,
199,
3,
961,
570,
365,
1777,
402,
2622,
199,
3,
199,
3,
2622,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
199,
3,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
844,
12,
503,
199,
3,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
2622,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
3,
3180,
543,
2622,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
3,
492,
859,
19484,
199,
199,
8490,
63,
8314,
275,
791,
2343,
63,
1023,
356,
283,
17,
14,
16,
297,
490,
283,
1205,
356,
788,
7780,
995,
490,
283,
4946,
63,
991,
356,
283,
9387,
936,
421,
199,
8948,
275,
1449,
199,
2595,
199,
578,
26,
6394,
30821,
63,
7157,
199,
3612,
63,
1802,
26,
21612,
577,
292,
30821,
26862,
199,
1802,
26,
199,
13,
298,
2395,
7441,
26862,
4453,
577,
292,
30821,
2,
199,
13,
298,
4558,
2839,
11736,
641,
1455,
921,
4757,
14,
4616,
30821,
21550,
14,
957,
15,
1246,
6687,
199,
1023,
63,
3270,
26,
298,
18,
14,
16,
2,
199,
2502,
26,
298,
1513,
66,
1810,
5653,
1804,
269,
685,
15544,
8593,
1339,
269,
685,
15544,
2924,
199,
7538,
26,
359,
4616,
30821,
61,
199,
1419,
26,
272,
2986,
63,
498,
26,
267,
1369,
26,
2097,
14398,
3918,
36,
974,
3261,
790,
14,
937,
267,
1415,
26,
2549,
272,
1145,
63,
498,
26,
267,
1369,
26,
2097,
14398,
3918,
36,
974,
1145,
790,
14,
937,
267,
1415,
26,
2549,
272,
1174,
26,
267,
1369,
26,
2097,
1918,
12899,
972,
1174,
402,
314,
8372,
14,
937,
267,
1415,
26,
2549,
267,
3415,
26,
788,
1881,
297,
283,
5575,
297,
283,
77,
4241,
297,
283,
324,
77,
4241,
418,
272,
3762,
26,
267,
1369,
26,
2097,
33,
769,
402,
3762,
370,
20133,
543,
2195,
8372,
1380,
6425,
503,
12928,
14,
961,
883,
1720,
1265,
7737,
269,
794,
436,
2457,
26862,
14,
937,
267,
1415,
26,
3055,
267,
849,
26,
488,
267,
1015,
63,
3270,
26,
298,
18,
14,
18,
2,
272,
730,
26,
267,
1369,
26,
288,
446,
298,
1918,
730,
402,
314,
8372,
2122,
288,
446,
710,
283,
1430,
10459,
7,
374,
2808,
6617,
737,
2622,
499,
14,
17,
267,
1415,
26,
3055,
267,
849,
26,
2973,
267,
3415,
26,
788,
5165,
10459,
297,
283,
1364,
1104,
297,
283,
1430,
10459,
418,
272,
1827,
26,
267,
1369,
26,
2097,
1918,
8372,
1827,
370,
11705,
641,
543,
6302,
17083,
316,
10298,
641,
4052,
730,
402,
8372,
1265,
787,
6425,
14,
937,
267,
1415,
26,
3055,
267,
849,
26,
2973,
272,
536,
26,
267,
1369,
26,
2097,
1918,
536,
402,
314,
10459,
14,
937,
267,
1415,
26,
2549,
272,
1245,
26,
267,
1369,
26,
288,
446,
437,
1245,
370,
2387,
543,
13116,
367,
642,
8372,
14,
11426,
13116,
883,
506,
4847,
370,
2488,
4390,
701,
1808,
314,
2011,
1598,
10267,
2473,
7,
15843,
465,
4474,
14,
26504,
1245,
1978,
2860,
883,
506,
13810,
701,
1808,
4270,
12386,
21873,
12,
284,
14,
69,
6730,
459,
436,
283,
2677,
1370,
267,
1415,
26,
3055,
267,
849,
26,
2973,
272,
9767,
78,
6867,
26,
267,
1369,
26,
2097,
11728,
402,
14570,
370,
22496,
503,
488,
14,
7048,
4194,
911,
506,
333,
4241,
5133,
314,
1627,
18169,
4913,
503,
28688,
340,
314,
574,
365,
488,
14,
32705,
267,
1415,
26,
3055,
267,
849,
26,
3087,
272,
11705,
63,
889,
63,
576,
26,
267,
1369,
26,
2097,
33,
5046,
9297,
3775,
642,
8372,
911,
11705,
1380,
666,
20922,
17290,
703,
937,
267,
1415,
26,
3055,
267,
849,
26,
756,
272,
949,
63,
576,
63,
521,
1943,
26,
267,
1369,
26,
288,
446,
710,
1329,
402,
9395,
2544,
282,
8372,
911,
11705,
1380,
666,
20922,
17290,
14,
9498,
506,
737,
5210,
499,
88,
314,
8372,
900,
1943,
367,
6370,
1598,
31529,
503,
499,
9395,
367,
2435,
5920,
14,
267,
1415,
26,
3055,
267,
849,
26,
499,
88,
900,
1943,
367,
6370,
12,
499,
9395,
367,
2435,
272,
2653,
63,
72,
26,
267,
1369,
26,
2097,
1918,
1329,
402,
10857,
402,
314,
8372,
440,
17290,
666,
2544,
652,
911,
5847,
7512,
687,
282,
15572,
1174,
14,
937,
267,
1415,
26,
3055,
267,
849,
26,
2973,
272,
295,
6814,
63,
4284,
26,
267,
1369,
26,
288,
446,
710,
1329,
402,
9395,
2410,
314,
2061,
6955,
2544,
282,
8372,
911,
295,
13,
6814,
641,
314,
1453,
2004,
14,
2779,
911,
1454,
295,
13,
6814,
340,
652,
1159,
1598,
440,
12152,
14,
267,
1415,
26,
3055,
267,
849,
26,
2973,
272,
325,
4732,
425,
63,
1188,
26,
267,
1369,
26,
288,
446,
437,
1245,
370,
2387,
543,
282,
295,
13,
6761,
14,
32090,
314,
10267,
2473,
7,
6955,
781,
2040,
25320,
14,
2832,
3964,
340,
295,
6814,
63,
4284,
1598,
365,
488,
267,
1415,
26,
3055,
267,
849,
26,
2973,
272,
11705,
63,
14274,
26,
267,
1369,
26,
2097,
33,
5046,
9297,
3775,
20018,
4390,
911,
506,
29535,
641,
4493,
370,
642,
8372,
14,
937,
267,
1415,
26,
3055,
267,
849,
26,
756,
272,
22757,
26,
267,
1369,
26,
288,
446,
437,
2600,
402,
22757,
701,
2004,
14,
961,
945,
365,
1454,
2808,
367,
2435,
5920,
436,
6370,
31529,
14,
13821,
1924,
402,
3062,
883,
1172,
1598,
3663,
22757,
12,
781,
2793,
1133,
5627,
3062,
5370,
315,
314,
1827,
14,
937,
267,
1415,
26,
3055,
267,
849,
26,
791,
745,
356,
413,
12,
283,
13138,
356,
413,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
miguelparaiso/OdooAccessible
|
addons/l10n_fr_rib/__init__.py
|
433
|
1046
|
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2011 Numérigraphe SARL.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import bank
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
agpl-3.0
|
[
3,
1882,
2644,
26,
2774,
13,
24,
1882,
199,
4605,
199,
3,
199,
3,
259,
7653,
12,
3232,
5800,
8259,
9274,
199,
3,
259,
1898,
334,
35,
9,
7760,
16817,
5741,
322,
926,
80,
426,
428,
689,
44,
14,
199,
3,
199,
3,
259,
961,
2240,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
259,
652,
1334,
314,
2895,
402,
314,
1664,
4265,
1696,
1684,
844,
465,
199,
3,
259,
3267,
701,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
199,
3,
259,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
259,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
259,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
259,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
259,
1664,
4265,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
259,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
4265,
1696,
1684,
844,
199,
3,
259,
3180,
543,
642,
2240,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
3,
199,
4605,
199,
199,
646,
16297,
199,
199,
3,
6695,
26,
10379,
26,
10558,
26,
6492,
29,
20,
26,
10503,
29,
20,
26,
10425,
29,
20,
26,
421,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1882,
2644,
26,
2774,
13,
24,
1882,
199,
4605,
199,
3,
199,
3,
259,
7653,
12,
3232,
5800,
8259,
9274,
199,
3,
259,
1898,
334,
35,
9,
7760,
16817,
5741,
322,
926,
80,
426,
428,
689,
44,
14,
199,
3,
199,
3,
259,
961,
2240,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
259,
652,
1334,
314,
2895,
402,
314,
1664,
4265,
1696,
1684,
844,
465,
199,
3,
259,
3267,
701,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
199,
3,
259,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
259,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
259,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
259,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
259,
1664,
4265,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
259,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
4265,
1696,
1684,
844,
199,
3,
259,
3180,
543,
642,
2240,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
3,
199,
4605,
199,
199,
646,
16297,
199,
199,
3,
6695,
26,
10379,
26,
10558,
26,
6492,
29,
20,
26,
10503,
29,
20,
26,
10425,
29,
20,
26,
421,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
zimmerle/gnuradio
|
gnuradio-core/src/lib/filter/generate_gr_freq_xlating_fir_filter_XXX.py
|
17
|
1493
|
#!/bin/env python
# -*- python -*-
#
# Copyright 2003,2004 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
# GNU Radio is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# GNU Radio is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GNU Radio; see the file COPYING. If not, write to
# the Free Software Foundation, Inc., 51 Franklin Street,
# Boston, MA 02110-1301, USA.
#
import re
from generate_utils import *
# files to generate
fx_signatures = [ 'scf', 'scc', 'fcf', 'fcc', 'ccf', 'ccc' ]
roots = ['gr_freq_xlating_fir_filter_XXX']
def expand_h_cc_i (root, code3):
d = init_dict (root, code3)
expand_template (d, root + '.h.t')
expand_template (d, root + '.cc.t')
expand_template (d, root + '.i.t')
def init_dict (root, code3):
name = re.sub ('X+', code3, root)
d = standard_dict (name, code3)
d['FIR_TYPE'] = 'gr_fir_' + i_code (code3) + 'cc'
return d
def generate ():
for r in roots:
for s in fx_signatures:
expand_h_cc_i (r, s)
if __name__ == '__main__':
generate ()
|
gpl-3.0
|
[
3381,
1393,
15,
1813,
2366,
199,
3,
1882,
2366,
1882,
199,
3,
199,
3,
1898,
13004,
12,
15431,
2868,
2290,
2752,
12,
3277,
14,
199,
3,
199,
3,
961,
570,
365,
1777,
402,
1664,
13514,
199,
3,
199,
3,
1664,
13514,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
199,
3,
314,
2868,
2290,
2752,
27,
1902,
1015,
650,
12,
503,
334,
292,
2195,
945,
9,
199,
3,
1263,
2945,
1015,
14,
199,
3,
199,
3,
1664,
13514,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
3,
3180,
543,
1664,
13514,
27,
1937,
314,
570,
9685,
14,
221,
982,
440,
12,
2218,
370,
199,
3,
314,
2868,
2290,
2752,
12,
3277,
2020,
8026,
11236,
14259,
12,
199,
3,
8226,
12,
4828,
11315,
13,
10067,
12,
8217,
14,
199,
3,
199,
199,
646,
295,
199,
504,
3550,
63,
1208,
492,
627,
199,
199,
3,
1584,
370,
3550,
199,
199,
12220,
63,
15132,
275,
359,
283,
27441,
297,
283,
551,
67,
297,
283,
70,
2177,
297,
283,
70,
2055,
297,
283,
31427,
297,
283,
19504,
7,
1622,
199,
199,
12065,
275,
788,
2587,
63,
5646,
63,
15455,
1958,
63,
1795,
63,
1541,
63,
13933,
418,
199,
199,
318,
6544,
63,
72,
63,
2055,
63,
73,
334,
1231,
12,
1233,
19,
304,
272,
366,
275,
4205,
63,
807,
334,
1231,
12,
1233,
19,
9,
272,
6544,
63,
1160,
334,
68,
12,
1738,
435,
1987,
72,
14,
84,
358,
272,
6544,
63,
1160,
334,
68,
12,
1738,
435,
1987,
2055,
14,
84,
358,
272,
6544,
63,
1160,
334,
68,
12,
1738,
435,
1987,
73,
14,
84,
358,
199,
199,
318,
4205,
63,
807,
334,
1231,
12,
1233,
19,
304,
272,
536,
275,
295,
14,
954,
661,
56,
7386,
1233,
19,
12,
1738,
9,
272,
366,
275,
4465,
63,
807,
334,
354,
12,
1233,
19,
9,
272,
366,
459,
1976,
50,
63,
2711,
418,
275,
283,
2587,
63,
1795,
8650,
435,
284,
63,
600,
334,
600,
19,
9,
435,
283,
2055,
7,
272,
372,
366,
421,
199,
318,
3550,
23390,
272,
367,
519,
315,
14361,
26,
267,
367,
308,
315,
28020,
63,
15132,
26,
288,
6544,
63,
72,
63,
2055,
63,
73,
334,
82,
12,
308,
9,
421,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
3550,
6248,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1393,
15,
1813,
2366,
199,
3,
1882,
2366,
1882,
199,
3,
199,
3,
1898,
13004,
12,
15431,
2868,
2290,
2752,
12,
3277,
14,
199,
3,
199,
3,
961,
570,
365,
1777,
402,
1664,
13514,
199,
3,
199,
3,
1664,
13514,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
199,
3,
314,
2868,
2290,
2752,
27,
1902,
1015,
650,
12,
503,
334,
292,
2195,
945,
9,
199,
3,
1263,
2945,
1015,
14,
199,
3,
199,
3,
1664,
13514,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
3,
3180,
543,
1664,
13514,
27,
1937,
314,
570,
9685,
14,
221,
982,
440,
12,
2218,
370,
199,
3,
314,
2868,
2290,
2752,
12,
3277,
2020,
8026,
11236,
14259,
12,
199,
3,
8226,
12,
4828,
11315,
13,
10067,
12,
8217,
14,
199,
3,
199,
199,
646,
295,
199,
504,
3550,
63,
1208,
492,
627,
199,
199,
3,
1584,
370,
3550,
199,
199,
12220,
63,
15132,
275,
359,
283,
27441,
297,
283,
551,
67,
297,
283,
70,
2177,
297,
283,
70,
2055,
297,
283,
31427,
297,
283,
19504,
7,
1622,
199,
199,
12065,
275,
788,
2587,
63,
5646,
63,
15455,
1958,
63,
1795,
63,
1541,
63,
13933,
418,
199,
199,
318,
6544,
63,
72,
63,
2055,
63,
73,
334,
1231,
12,
1233,
19,
304,
272,
366,
275,
4205,
63,
807,
334,
1231,
12,
1233,
19,
9,
272,
6544,
63,
1160,
334,
68,
12,
1738,
435,
1987,
72,
14,
84,
358,
272,
6544,
63,
1160,
334,
68,
12,
1738,
435,
1987,
2055,
14,
84,
358,
272,
6544,
63,
1160,
334,
68,
12,
1738,
435,
1987,
73,
14,
84,
358,
199,
199,
318,
4205,
63,
807,
334,
1231,
12,
1233,
19,
304,
272,
536,
275,
295,
14,
954,
661,
56,
7386,
1233,
19,
12,
1738,
9,
272,
366,
275,
4465,
63,
807,
334,
354,
12,
1233,
19,
9,
272,
366,
459,
1976,
50,
63,
2711,
418,
275,
283,
2587,
63,
1795,
8650,
435,
284,
63,
600,
334,
600,
19,
9,
435,
283,
2055,
7,
272,
372,
366,
421,
199,
318,
3550,
23390,
272,
367,
519,
315,
14361,
26,
267,
367,
308,
315,
28020,
63,
15132,
26,
288,
6544,
63,
72,
63,
2055,
63,
73,
334,
82,
12,
308,
9,
421,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
3550,
6248,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
albertoriva/bioscripts
|
bisconv.py
|
1
|
3205
|
#!/usr/bin/env python
import sys
import pysam
import os.path
import Script
def usage():
sys.stderr.write("""bisconv.py command [args...] - Extract aligned reads from BAM file based on conversion strand.
This program examines the ZS tag of the reads in a BAM file produced by BSMAP to identify reads
coming from conversion of the top or bottom strands. Commands:
-h, --help | Print this help message.
-v, --version | Display version number.
split <bamfile> <topfile> <botfile> | Write reads from top converted strand to <topfile>, and
| reads from bottom converted strand to <botfile>.
zs+ <bamfile> <topfile> | Write reads from top converted strand to <topfile>. If
| <topfile> is -, write to standard output.
zs- <bamfile> <botfile> | Write reads from bottom converted strand to <botfile>. If
| <botfile> is -, write to standard output.
Reads in <topfile> will only show C->T conversion, while reads in <botfile> will only show G->A
conversion.
If the output file is `-' or `/dev/stdout', output will be written to standard output
(useful for piping).
""")
P = Script.Script("bisconv.py", version="1.0", usage=usage)
## Code
def split(inbam, bamfile1, bamfile2):
nin = 0
nplus = 0
nminus = 0
inb = pysam.AlignmentFile(inbam, "rb")
bam1 = pysam.AlignmentFile(bamfile1, "wb", template=inb)
bam2 = pysam.AlignmentFile(bamfile2, "wb", template=inb)
try:
for read in inb.fetch():
nin += 1
zs = read.get_tag("ZS")
if zs[0] == '+':
bam1.write(read)
nplus += 1
else:
bam2.write(read)
nminus += 1
finally:
inb.close()
bam1.close()
bam2.close()
return (nin, nplus, nminus)
def extract(inbam, outbam, flag):
if outbam == "-":
outbam = "/dev/stdout"
nin = 0
nout = 0
inb = pysam.AlignmentFile(inbam, "rb")
bam = pysam.AlignmentFile(outbam, "wb", template=inb)
try:
for read in inb.fetch():
nin += 1
zs = read.get_tag("ZS")
if zs[0] == flag:
bam.write(read)
nout += 1
finally:
inb.close()
bam.close()
return (nin, nout)
if __name__ == "__main__":
args = sys.argv[1:]
P.standardOpts(args)
if len(args) == 0:
P.usage()
cmd = args[0]
if cmd == 'split':
if len(args) < 4:
P.errmsg(P.NOFILE)
(nin, nplus, nminus) = split(P.isFile(args[1]), args[2], args[3])
sys.stderr.write("Total: {}\nTop: {}\nBottom: {}\n".format(nin, nplus, nminus))
elif cmd == 'zs+':
if len(args) < 3:
P.errmsg(P.NOFILE)
(nin, nout) = extract(P.isFile(args[1]), args[2], '+')
sys.stderr.write("Total: {}\nTop: {}\n".format(nin, nout))
else:
if len(args) < 3:
P.errmsg(P.NOFILE)
(nin, nout) = extract(P.isfile(args[1]), args[2], '-')
sys.stderr.write("Total: {}\nBottom: {}\n".format(nin, nout))
|
gpl-3.0
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
199,
646,
984,
199,
646,
10382,
455,
199,
646,
747,
14,
515,
199,
199,
646,
14914,
199,
199,
318,
4503,
837,
272,
984,
14,
3083,
14,
952,
4852,
18797,
5598,
14,
647,
1414,
359,
589,
18737,
446,
12892,
22569,
11597,
687,
699,
1156,
570,
4079,
641,
8603,
620,
460,
14,
199,
199,
2765,
2240,
15735,
3746,
314,
3107,
51,
1947,
402,
314,
11597,
315,
282,
699,
1156,
570,
13584,
701,
699,
4029,
1282,
370,
10405,
11597,
221,
199,
7909,
687,
8603,
402,
314,
2746,
503,
9048,
620,
5915,
14,
5817,
83,
26,
199,
199,
13,
72,
12,
1553,
3437,
14516,
1204,
9101,
642,
1720,
1245,
14,
199,
13,
86,
12,
1553,
1023,
9668,
1204,
12175,
1015,
1329,
14,
199,
1294,
665,
21112,
493,
30,
665,
2119,
493,
30,
665,
3018,
493,
30,
1204,
6990,
11597,
687,
2746,
6702,
620,
460,
370,
665,
2119,
493,
6244,
436,
2511,
1204,
11597,
687,
9048,
6702,
620,
460,
370,
665,
3018,
493,
10827,
199,
31765,
11,
257,
665,
21112,
493,
30,
665,
2119,
493,
30,
3698,
1204,
6990,
11597,
687,
2746,
6702,
620,
460,
370,
665,
2119,
493,
10827,
982,
2511,
1204,
665,
2119,
493,
30,
365,
446,
12,
2218,
370,
4465,
1072,
14,
199,
31765,
13,
257,
665,
21112,
493,
30,
665,
3018,
493,
30,
3698,
1204,
6990,
11597,
687,
9048,
6702,
620,
460,
370,
665,
3018,
493,
10827,
982,
2511,
1204,
665,
3018,
493,
30,
365,
446,
12,
2218,
370,
4465,
1072,
14,
199,
199,
23614,
315,
665,
2119,
493,
30,
911,
1454,
2498,
445,
5118,
52,
8603,
12,
1830,
11597,
315,
665,
3018,
493,
30,
911,
1454,
2498,
598,
5118,
33,
199,
15083,
14,
199,
199,
3917,
314,
1072,
570,
365,
658,
15668,
503,
658,
15,
2374,
15,
2703,
297,
1072,
911,
506,
5313,
370,
4465,
1072,
199,
8,
1180,
1893,
367,
7305,
316,
680,
199,
199,
6141,
199,
199,
48,
275,
14914,
14,
5229,
480,
18797,
5598,
14,
647,
401,
1015,
628,
17,
14,
16,
401,
4503,
29,
3807,
9,
199,
199,
309,
5495,
199,
199,
318,
3715,
8,
262,
21112,
12,
330,
455,
493,
17,
12,
330,
455,
493,
18,
304,
272,
302,
262,
275,
378,
272,
980,
24879,
275,
378,
272,
302,
13084,
275,
378,
272,
315,
66,
275,
10382,
455,
14,
16613,
1173,
8,
262,
21112,
12,
298,
4848,
531,
272,
330,
455,
17,
275,
10382,
455,
14,
16613,
1173,
8,
21112,
493,
17,
12,
298,
6603,
401,
1978,
29,
262,
66,
9,
272,
330,
455,
18,
275,
10382,
455,
14,
16613,
1173,
8,
21112,
493,
18,
12,
298,
6603,
401,
1978,
29,
262,
66,
9,
272,
862,
26,
267,
367,
1586,
315,
315,
66,
14,
3535,
837,
288,
302,
262,
847,
413,
288,
1315,
83,
275,
1586,
14,
362,
63,
1450,
480,
26697,
531,
288,
340,
1315,
83,
59,
16,
61,
508,
6681,
356,
355,
330,
455,
17,
14,
952,
8,
739,
9,
355,
980,
24879,
847,
413,
288,
587,
26,
355,
330,
455,
18,
14,
952,
8,
739,
9,
355,
302,
13084,
847,
413,
272,
3753,
26,
267,
315,
66,
14,
1600,
342,
267,
330,
455,
17,
14,
1600,
342,
267,
330,
455,
18,
14,
1600,
342,
272,
372,
334,
28693,
12,
980,
24879,
12,
302,
13084,
9,
199,
199,
318,
5536,
8,
262,
21112,
12,
734,
21112,
12,
3305,
304,
272,
340,
734,
21112,
508,
30312,
267,
734,
21112,
275,
3286,
2374,
15,
2703,
2,
272,
302,
262,
275,
378,
272,
302,
548,
275,
378,
272,
315,
66,
275,
10382,
455,
14,
16613,
1173,
8,
262,
21112,
12,
298,
4848,
531,
272,
330,
455,
275,
10382,
455,
14,
16613,
1173,
8,
548,
21112,
12,
298,
6603,
401,
1978,
29,
262,
66,
9,
272,
862,
26,
267,
367,
1586,
315,
315,
66,
14,
3535,
837,
288,
302,
262,
847,
413,
288,
1315,
83,
275,
1586,
14,
362,
63,
1450,
480,
26697,
531,
288,
340,
1315,
83,
59,
16,
61,
508,
3305,
26,
355,
330,
455,
14,
952,
8,
739,
9,
355,
302,
548,
847,
413,
272,
3753,
26,
267,
315,
66,
14,
1600,
342,
267,
330,
455,
14,
1600,
342,
272,
372,
334,
28693,
12,
302,
548,
9,
199,
199,
692,
636,
354,
363,
508,
4396,
973,
5727,
272,
1249,
275,
984,
14,
3020,
59,
17,
2938,
272,
510,
14,
6807,
24429,
8,
589,
9,
339,
340,
822,
8,
589,
9,
508,
378,
26,
267,
510,
14,
3807,
342,
272,
2088,
275,
1249,
59,
16,
61,
272,
340,
2088,
508,
283,
1294,
356,
267,
340,
822,
8,
589,
9,
665,
841,
26,
288,
510,
14,
16024,
8,
48,
14,
2826,
3817,
9,
267,
334,
28693,
12,
980,
24879,
12,
302,
13084,
9,
275,
3715,
8,
48,
14,
374,
1173,
8,
589,
59,
17,
2522,
1249,
59,
18,
467,
1249,
59,
19,
566,
267,
984,
14,
3083,
14,
952,
480,
7316,
26,
22902,
78,
6105,
26,
22902,
78,
22886,
26,
22902,
78,
1674,
908,
8,
28693,
12,
980,
24879,
12,
302,
13084,
430,
272,
916,
2088,
508,
283,
31765,
11,
356,
267,
340,
822,
8,
589,
9,
665,
650,
26,
288,
510,
14,
16024,
8,
48,
14,
2826,
3817,
9,
267,
334,
28693,
12,
302,
548,
9,
275,
5536,
8,
48,
14,
374,
1173,
8,
589,
59,
17,
2522,
1249,
59,
18,
467,
6681,
358,
267,
984,
14,
3083,
14,
952,
480,
7316,
26,
22902,
78,
6105,
26,
22902,
78,
1674,
908,
8,
28693,
12,
302,
548,
430,
272,
587,
26,
267,
340,
822,
8,
589,
9,
665,
650,
26,
288,
510,
14,
16024,
8,
48,
14,
2826,
3817,
9,
267,
334,
28693,
12,
302,
548,
9,
275,
5536,
8,
48,
14,
6292,
8,
589,
59,
17,
2522,
1249,
59,
18,
467,
26942,
267,
984,
14,
3083,
14,
952,
480,
7316,
26,
22902,
78,
22886,
26,
22902,
78,
1674,
908,
8,
28693,
12,
302,
548,
430,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
199,
646,
984,
199,
646,
10382,
455,
199,
646,
747,
14,
515,
199,
199,
646,
14914,
199,
199,
318,
4503,
837,
272,
984,
14,
3083,
14,
952,
4852,
18797,
5598,
14,
647,
1414,
359,
589,
18737,
446,
12892,
22569,
11597,
687,
699,
1156,
570,
4079,
641,
8603,
620,
460,
14,
199,
199,
2765,
2240,
15735,
3746,
314,
3107,
51,
1947,
402,
314,
11597,
315,
282,
699,
1156,
570,
13584,
701,
699,
4029,
1282,
370,
10405,
11597,
221,
199,
7909,
687,
8603,
402,
314,
2746,
503,
9048,
620,
5915,
14,
5817,
83,
26,
199,
199,
13,
72,
12,
1553,
3437,
14516,
1204,
9101,
642,
1720,
1245,
14,
199,
13,
86,
12,
1553,
1023,
9668,
1204,
12175,
1015,
1329,
14,
199,
1294,
665,
21112,
493,
30,
665,
2119,
493,
30,
665,
3018,
493,
30,
1204,
6990,
11597,
687,
2746,
6702,
620,
460,
370,
665,
2119,
493,
6244,
436,
2511,
1204,
11597,
687,
9048,
6702,
620,
460,
370,
665,
3018,
493,
10827,
199,
31765,
11,
257,
665,
21112,
493,
30,
665,
2119,
493,
30,
3698,
1204,
6990,
11597,
687,
2746,
6702,
620,
460,
370,
665,
2119,
493,
10827,
982,
2511,
1204,
665,
2119,
493,
30,
365,
446,
12,
2218,
370,
4465,
1072,
14,
199,
31765,
13,
257,
665,
21112,
493,
30,
665,
3018,
493,
30,
3698,
1204,
6990,
11597,
687,
9048,
6702,
620,
460,
370,
665,
3018,
493,
10827,
982,
2511,
1204,
665,
3018,
493,
30,
365,
446,
12,
2218,
370,
4465,
1072,
14,
199,
199,
23614,
315,
665,
2119,
493,
30,
911,
1454,
2498,
445,
5118,
52,
8603,
12,
1830,
11597,
315,
665,
3018,
493,
30,
911,
1454,
2498,
598,
5118,
33,
199,
15083,
14,
199,
199,
3917,
314,
1072,
570,
365,
658,
15668,
503,
658,
15,
2374,
15,
2703,
297,
1072,
911,
506,
5313,
370,
4465,
1072,
199,
8,
1180,
1893,
367,
7305,
316,
680,
199,
199,
6141,
199,
199,
48,
275,
14914,
14,
5229,
480,
18797,
5598,
14,
647,
401,
1015,
628,
17,
14,
16,
401,
4503,
29,
3807,
9,
199,
199,
309,
5495,
199,
199,
318,
3715,
8,
262,
21112,
12,
330,
455,
493,
17,
12,
330,
455,
493,
18,
304,
272,
302,
262,
275,
378,
272,
980,
24879,
275,
378,
272,
302,
13084,
275,
378,
272,
315,
66,
275,
10382,
455,
14,
16613,
1173,
8,
262,
21112,
12,
298,
4848,
531,
272,
330,
455,
17,
275,
10382,
455,
14,
16613,
1173,
8,
21112,
493,
17,
12,
298,
6603,
401,
1978,
29,
262,
66,
9,
272,
330,
455,
18,
275,
10382,
455,
14,
16613,
1173,
8,
21112,
493,
18,
12,
298,
6603,
401,
1978,
29,
262,
66,
9,
272,
862,
26,
267,
367,
1586,
315,
315,
66,
14,
3535,
837,
288,
302,
262,
847,
413,
288,
1315,
83,
275,
1586,
14,
362,
63,
1450,
480,
26697,
531,
288,
340,
1315,
83,
59,
16,
61,
508,
6681,
356,
355,
330,
455,
17,
14,
952,
8,
739,
9,
355,
980,
24879,
847,
413,
288,
587,
26,
355,
330,
455,
18,
14,
952,
8,
739,
9,
355,
302,
13084,
847,
413,
272,
3753,
26,
267,
315,
66,
14,
1600,
342,
267,
330,
455,
17,
14,
1600,
342,
267,
330,
455,
18,
14,
1600,
342,
272,
372,
334,
28693,
12,
980,
24879,
12,
302,
13084,
9,
199,
199,
318,
5536,
8,
262,
21112,
12,
734,
21112,
12,
3305,
304,
272,
340,
734,
21112,
508,
30312,
267,
734,
21112,
275,
3286,
2374,
15,
2703,
2,
272,
302,
262,
275,
378,
272,
302,
548,
275,
378,
272,
315,
66,
275,
10382,
455,
14,
16613,
1173,
8,
262,
21112,
12,
298,
4848,
531,
272,
330,
455,
275,
10382,
455,
14,
16613,
1173,
8,
548,
21112,
12,
298,
6603,
401,
1978,
29,
262,
66,
9,
272,
862,
26,
267,
367,
1586,
315,
315,
66,
14,
3535,
837,
288,
302,
262,
847,
413,
288,
1315,
83,
275,
1586,
14,
362,
63,
1450,
480,
26697,
531,
288,
340,
1315,
83,
59,
16,
61,
508,
3305,
26,
355,
330,
455,
14,
952,
8,
739,
9,
355,
302,
548,
847,
413,
272,
3753,
26,
267,
315,
66,
14,
1600,
342,
267,
330,
455,
14,
1600,
342,
272,
372,
334,
28693,
12,
302,
548,
9,
199,
199,
692,
636,
354,
363,
508,
4396,
973,
5727,
272,
1249,
275,
984,
14,
3020,
59,
17,
2938,
272,
510,
14,
6807,
24429,
8,
589,
9,
339,
340,
822,
8,
589,
9,
508,
378,
26,
267,
510,
14,
3807,
342,
272,
2088,
275,
1249,
59,
16,
61,
272,
340,
2088,
508,
283,
1294,
356,
267,
340,
822,
8,
589,
9,
665,
841,
26,
288,
510,
14,
16024,
8,
48,
14,
2826,
3817,
9,
267,
334,
28693,
12,
980,
24879,
12,
302,
13084,
9,
275,
3715,
8,
48,
14,
374,
1173,
8,
589,
59,
17,
2522,
1249,
59,
18,
467,
1249,
59,
19,
566,
267,
984,
14,
3083,
14,
952,
480,
7316,
26,
22902,
78,
6105,
26,
22902,
78,
22886,
26,
22902,
78,
1674,
908,
8,
28693,
12,
980,
24879,
12,
302,
13084,
430,
272,
916,
2088,
508,
283,
31765,
11,
356,
267,
340,
822,
8,
589,
9,
665,
650,
26,
288,
510,
14,
16024,
8,
48,
14,
2826,
3817,
9,
267,
334,
28693,
12,
302,
548,
9,
275,
5536,
8,
48,
14,
374,
1173,
8,
589,
59,
17,
2522,
1249,
59,
18,
467,
6681,
358,
267,
984,
14,
3083,
14,
952,
480,
7316,
26,
22902,
78,
6105,
26,
22902,
78,
1674,
908,
8,
28693,
12,
302,
548,
430,
272,
587,
26,
267,
340,
822,
8,
589,
9,
665,
650,
26,
288,
510,
14,
16024,
8,
48,
14,
2826,
3817,
9,
267,
334,
28693,
12,
302,
548,
9,
275,
5536,
8,
48,
14,
6292,
8,
589,
59,
17,
2522,
1249,
59,
18,
467,
26942,
267,
984,
14,
3083,
14,
952,
480,
7316,
26,
22902,
78,
22886,
26,
22902,
78,
1674,
908,
8,
28693,
12,
302,
548,
430,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
osrg/ryu
|
ryu/tests/unit/ofproto/test_parser_v10.py
|
10
|
170013
|
# Copyright (C) 2012 Nippon Telegraph and Telephone Corporation.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# vim: tabstop=4 shiftwidth=4 softtabstop=4
import unittest
import logging
import six
from nose.tools import *
from ryu.ofproto.ofproto_v1_0_parser import *
from ryu.ofproto.nx_actions import *
from ryu.ofproto import ofproto_v1_0_parser
from ryu.lib import addrconv
LOG = logging.getLogger('test_ofproto_v10')
class TestOFPPhyPort(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.OFPPhyPort
"""
# OFP_PHY_PORT_PACK_STR
# '!H6s16sIIIIII'... port_no, hw_addr, name, config, state
# curr, advertised, supported, peer
port_no = {'buf': b'\xe7\x6b', 'val': 59243}
hw_addr = '52:54:54:10:20:99'
name = b'name'.ljust(16)
config = {'buf': b'\x84\xb6\x8c\x53', 'val': 2226555987}
state = {'buf': b'\x64\x07\xfb\xc9', 'val': 1678244809}
curr = {'buf': b'\xa9\xe8\x0a\x2b', 'val': 2850556459}
advertised = {'buf': b'\x78\xb9\x7b\x72', 'val': 2025421682}
supported = {'buf': b'\x7e\x65\x68\xad', 'val': 2120575149}
peer = {'buf': b'\xa4\x5b\x8b\xed', 'val': 2757463021}
buf = port_no['buf'] \
+ addrconv.mac.text_to_bin(hw_addr) \
+ name \
+ config['buf'] \
+ state['buf'] \
+ curr['buf'] \
+ advertised['buf'] \
+ supported['buf'] \
+ peer['buf']
c = OFPPhyPort(port_no['val'],
hw_addr,
name,
config['val'],
state['val'],
curr['val'],
advertised['val'],
supported['val'],
peer['val'])
def setUp(self):
pass
def tearDown(self):
pass
def test_init(self):
eq_(self.port_no['val'], self.c.port_no)
eq_(self.hw_addr, self.c.hw_addr)
eq_(self.name, self.c.name)
eq_(self.config['val'], self.c.config)
eq_(self.state['val'], self.c.state)
eq_(self.curr['val'], self.c.curr)
eq_(self.advertised['val'], self.c.advertised)
eq_(self.supported['val'], self.c.supported)
eq_(self.peer['val'], self.c.peer)
def test_parser(self):
res = self.c.parser(self.buf, 0)
eq_(self.port_no['val'], res.port_no)
eq_(self.hw_addr, res.hw_addr)
eq_(self.name, res.name)
eq_(self.config['val'], res.config)
eq_(self.state['val'], res.state)
eq_(self.curr['val'], res.curr)
eq_(self.advertised['val'], res.advertised)
eq_(self.supported['val'], res.supported)
eq_(self.peer['val'], res.peer)
class TestOFPMatch(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.OFPMatch
"""
# OFP_MATCH_PACK_STR
# '!IH6s6sHBxHBB2xIIHH'...wildcards, in_port, dl_src, dl_dst, dl_vlan,
# dl_vlan_pcp, dl_type, nw_tos, nw_proto,
# nw_src, nw_dst, tp_src, tp_dst
wildcards = {'buf': b'\x00\x02\x10\x00', 'val': 135168}
in_port = {'buf': b'\x37\x8b', 'val': 14219}
dl_src = {'buf': b'\x52\x54\x54\x10\x20\x99',
'human': '52:54:54:10:20:99'}
dl_dst = {'buf': b'\x61\x31\x50\x6d\xc9\xe5',
'human': '61:31:50:6d:c9:e5'}
dl_vlan = {'buf': b'\xc1\xf9', 'val': 49657}
dl_vlan_pcp = {'buf': b'\x79', 'val': 121}
zfill0 = b'\x00'
dl_type = {'buf': b'\xa6\x9e', 'val': 42654}
nw_tos = {'buf': b'\xde', 'val': 222}
nw_proto = {'buf': b'\xe5', 'val': 229}
zfil11 = b'\x00' * 2
nw_src = {'buf': b'\x1b\x6d\x8d\x4b', 'val': 460164427,
'human': '27.109.141.75'}
nw_dst = {'buf': b'\xab\x25\xe1\x20', 'val': 2871386400,
'human': '171.37.225.32'}
tp_src = {'buf': b'\xd5\xc3', 'val': 54723}
tp_dst = {'buf': b'\x78\xb9', 'val': 30905}
buf = wildcards['buf'] \
+ in_port['buf'] \
+ dl_src['buf'] \
+ dl_dst['buf'] \
+ dl_vlan['buf'] \
+ dl_vlan_pcp['buf'] \
+ zfill0 \
+ dl_type['buf'] \
+ nw_tos['buf'] \
+ nw_proto['buf'] \
+ zfil11 \
+ nw_src['buf'] \
+ nw_dst['buf'] \
+ tp_src['buf'] \
+ tp_dst['buf']
def _get_obj(self, dl_src, dl_dst):
c = OFPMatch(self.wildcards['val'],
self.in_port['val'],
dl_src,
dl_dst,
self.dl_vlan['val'],
self.dl_vlan_pcp['val'],
self.dl_type['val'],
self.nw_tos['val'],
self.nw_proto['val'],
self.nw_src['val'],
self.nw_dst['val'],
self.tp_src['val'],
self.tp_dst['val'])
return c
def setUp(self):
pass
def tearDown(self):
pass
def test_init(self):
c = self._get_obj(self.dl_src['buf'], self.dl_dst['buf'])
eq_(self.wildcards['val'], c.wildcards)
eq_(self.in_port['val'], c.in_port)
eq_(self.dl_src['buf'], c.dl_src)
eq_(self.dl_dst['buf'], c.dl_dst)
eq_(self.dl_vlan['val'], c.dl_vlan)
eq_(self.dl_vlan_pcp['val'], c.dl_vlan_pcp)
eq_(self.dl_type['val'], c.dl_type)
eq_(self.nw_tos['val'], c.nw_tos)
eq_(self.nw_proto['val'], c.nw_proto)
eq_(self.nw_src['val'], c.nw_src)
eq_(self.nw_dst['val'], c.nw_dst)
eq_(self.tp_src['val'], c.tp_src)
eq_(self.tp_dst['val'], c.tp_dst)
def test_init_zero(self):
c = self._get_obj(0, 0)
eq_(mac.DONTCARE, c.dl_src)
eq_(mac.DONTCARE, c.dl_dst)
def test_parse(self):
c = self._get_obj(self.dl_src['buf'], self.dl_dst['buf'])
res = c.parse(self.buf, 0)
eq_(self.wildcards['val'], res.wildcards)
eq_(self.in_port['val'], res.in_port)
eq_(self.dl_src['buf'], res.dl_src)
eq_(self.dl_dst['buf'], res.dl_dst)
eq_(self.dl_vlan['val'], res.dl_vlan)
eq_(self.dl_vlan_pcp['val'], res.dl_vlan_pcp)
eq_(self.dl_type['val'], res.dl_type)
eq_(self.nw_tos['val'], res.nw_tos)
eq_(self.nw_proto['val'], res.nw_proto)
eq_(self.nw_src['val'], res.nw_src)
eq_(self.nw_dst['val'], res.nw_dst)
eq_(self.tp_src['val'], res.tp_src)
eq_(self.tp_dst['val'], res.tp_dst)
def test_serialize(self):
buf = bytearray()
c = self._get_obj(self.dl_src['buf'], self.dl_dst['buf'])
c.serialize(buf, 0)
fmt = ofproto.OFP_MATCH_PACK_STR
res = struct.unpack_from(fmt, six.binary_type(buf))
eq_(self.wildcards['val'], res[0])
eq_(self.in_port['val'], res[1])
eq_(self.dl_src['buf'], res[2])
eq_(self.dl_dst['buf'], res[3])
eq_(self.dl_vlan['val'], res[4])
eq_(self.dl_vlan_pcp['val'], res[5])
eq_(self.dl_type['val'], res[6])
eq_(self.nw_tos['val'], res[7])
eq_(self.nw_proto['val'], res[8])
eq_(self.nw_src['val'], res[9])
eq_(self.nw_dst['val'], res[10])
eq_(self.tp_src['val'], res[11])
eq_(self.tp_dst['val'], res[12])
def test_getitem(self):
c = self._get_obj(self.dl_src['buf'], self.dl_dst['buf'])
eq_(self.wildcards['val'], c["wildcards"])
eq_(self.in_port['val'], c["in_port"])
eq_(self.dl_src['human'], c["dl_src"])
eq_(self.dl_dst['human'], c["dl_dst"])
eq_(self.dl_vlan['val'], c["dl_vlan"])
eq_(self.dl_vlan_pcp['val'], c["dl_vlan_pcp"])
eq_(self.dl_type['val'], c["dl_type"])
eq_(self.nw_tos['val'], c["nw_tos"])
eq_(self.nw_proto['val'], c["nw_proto"])
eq_(self.nw_src['human'], c["nw_src"])
eq_(self.nw_dst['human'], c["nw_dst"])
eq_(self.tp_src['val'], c["tp_src"])
eq_(self.tp_dst['val'], c["tp_dst"])
class TestOFPActionHeader(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.OFPActionHeader
"""
# OFP_ACTION_HEADER_PACK_STR
# '!HH4x'...type, len, zfill
type = {'buf': b'\x00\x02', 'val': ofproto.OFPAT_SET_VLAN_PCP}
len = {'buf': b'\x00\x08', 'val': ofproto.OFP_ACTION_HEADER_SIZE}
zfill = b'\x00' * 4
buf = type['buf'] \
+ len['buf'] \
+ zfill
c = OFPActionHeader(type['val'], len['val'])
def setUp(self):
pass
def tearDown(self):
pass
def test_init(self):
eq_(self.type['val'], self.c.type)
eq_(self.len['val'], self.c.len)
def test_serialize(self):
buf = bytearray()
self.c.serialize(buf, 0)
fmt = ofproto.OFP_ACTION_HEADER_PACK_STR
res = struct.unpack(fmt, six.binary_type(buf))
eq_(self.type['val'], res[0])
eq_(self.len['val'], res[1])
class TestOFPActionOutput(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.OFPActionOutput
"""
# OFP_ACTION_OUTPUT_PACK_STR
# '!HHHH'...type, len, port, max_len
type_ = {'buf': b'\x00\x00', 'val': ofproto.OFPAT_OUTPUT}
len_ = {'buf': b'\x00\x08', 'val': ofproto.OFP_ACTION_OUTPUT_SIZE}
port = {'buf': b'\x19\xce', 'val': 6606}
max_len = {'buf': b'\x00\x08', 'val': ofproto.OFP_ACTION_OUTPUT_SIZE}
buf = type_['buf'] \
+ len_['buf'] \
+ port['buf'] \
+ max_len['buf']
c = OFPActionOutput(port['val'], max_len['val'])
def setUp(self):
pass
def tearDown(self):
pass
def test_init(self):
eq_(self.port['val'], self.c.port)
eq_(self.max_len['val'], self.c.max_len)
def test_parser(self):
res = self.c.parser(self.buf, 0)
eq_(self.port['val'], res.port)
eq_(self.max_len['val'], res.max_len)
@raises(AssertionError)
def test_parser_check_type(self):
type_ = {'buf': b'\x00\x01', 'val': 1}
buf = type_['buf'] \
+ self.len_['buf'] \
+ self.port['buf'] \
+ self.max_len['buf']
self.c.parser(buf, 0)
@raises(AssertionError)
def test_parser_check_len(self):
len_ = {'buf': b'\x00\x07', 'val': 7}
buf = self.type_['buf'] \
+ len_['buf'] \
+ self.port['buf'] \
+ self.max_len['buf']
self.c.parser(buf, 0)
def test_serialize(self):
buf = bytearray()
self.c.serialize(buf, 0)
fmt = ofproto.OFP_ACTION_OUTPUT_PACK_STR
res = struct.unpack(fmt, six.binary_type(buf))
eq_(self.type_['val'], res[0])
eq_(self.len_['val'], res[1])
eq_(self.port['val'], res[2])
eq_(self.max_len['val'], res[3])
class TestOFPActionVlanVid(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.OFPActionVlanVid
"""
# OFP_ACTION_VLAN_VID_PACK_STR
# '!HHH2x'...type, len, vlan_vid, zfill
type_ = {'buf': b'\x00\x01', 'val': ofproto.OFPAT_SET_VLAN_VID}
len_ = {'buf': b'\x00\x08', 'val': ofproto.OFP_ACTION_VLAN_VID_SIZE}
vlan_vid = {'buf': b'\x3c\x0e', 'val': 15374}
zfill = b'\x00' * 2
buf = type_['buf'] \
+ len_['buf'] \
+ vlan_vid['buf'] \
+ zfill
c = OFPActionVlanVid(vlan_vid['val'])
def setUp(self):
pass
def tearDown(self):
pass
def test_init(self):
eq_(self.vlan_vid['val'], self.c.vlan_vid)
def test_parser(self):
res = self.c.parser(self.buf, 0)
eq_(self.vlan_vid['val'], res.vlan_vid)
@raises(AssertionError)
def test_parser_check_type(self):
type_ = {'buf': b'\x00\x02', 'val': 2}
buf = type_['buf'] \
+ self.len_['buf'] \
+ self.vlan_vid['buf'] \
+ self.zfill
self.c.parser(buf, 0)
@raises(AssertionError)
def test_parser_check_len(self):
len_ = {'buf': b'\x00\x07', 'val': 7}
buf = self.type_['buf'] \
+ len_['buf'] \
+ self.vlan_vid['buf'] \
+ self.zfill
self.c.parser(buf, 0)
def test_serialize(self):
buf = bytearray()
self.c.serialize(buf, 0)
fmt = ofproto.OFP_ACTION_VLAN_VID_PACK_STR
res = struct.unpack(fmt, six.binary_type(buf))
eq_(self.type_['val'], res[0])
eq_(self.len_['val'], res[1])
eq_(self.vlan_vid['val'], res[2])
class TestOFPActionVlanPcp(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.OFPActionVlanPcp
"""
# OFP_ACTION_VLAN_PCP_PACK_STR
# '!HHB3x'...type, len, vlan_pcp, zfill
type_ = {'buf': b'\x00\x02', 'val': ofproto.OFPAT_SET_VLAN_PCP}
len_ = {'buf': b'\x00\x08', 'val': ofproto.OFP_ACTION_VLAN_PCP_SIZE}
vlan_pcp = {'buf': b'\x1c', 'val': 28}
zfill = b'\x00' * 3
buf = type_['buf'] \
+ len_['buf'] \
+ vlan_pcp['buf'] \
+ zfill
c = OFPActionVlanPcp(vlan_pcp['val'])
def setUp(self):
pass
def tearDown(self):
pass
def test_init(self):
eq_(self.vlan_pcp['val'], self.c.vlan_pcp)
def test_parser(self):
res = self.c.parser(self.buf, 0)
eq_(self.vlan_pcp['val'], res.vlan_pcp)
@raises(AssertionError)
def test_parser_check_type(self):
type_ = {'buf': b'\x00\x01', 'val': 1}
buf = type_['buf'] \
+ self.len_['buf'] \
+ self.vlan_pcp['buf'] \
+ self.zfill
self.c.parser(buf, 0)
@raises(AssertionError)
def test_parser_check_len(self):
len_ = {'buf': b'\x00\x07', 'val': 7}
buf = self.type_['buf'] \
+ len_['buf'] \
+ self.vlan_pcp['buf'] \
+ self.zfill
self.c.parser(buf, 0)
def test_serialize(self):
buf = bytearray()
self.c.serialize(buf, 0)
fmt = ofproto.OFP_ACTION_VLAN_PCP_PACK_STR
res = struct.unpack(fmt, six.binary_type(buf))
eq_(self.type_['val'], res[0])
eq_(self.len_['val'], res[1])
eq_(self.vlan_pcp['val'], res[2])
class TestOFPActionStripVlan(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.OFPActionStripVlan
"""
# OFP_ACTION_HEADER_PACK_STR
# '!HH4x'...type, len, zfill
type_ = {'buf': b'\x00\x03', 'val': ofproto.OFPAT_STRIP_VLAN}
len_ = {'buf': b'\x00\x08', 'val': ofproto.OFP_ACTION_HEADER_SIZE}
zfill = b'\x00' * 4
buf = type_['buf'] \
+ len_['buf'] \
+ zfill
c = OFPActionStripVlan()
def setUp(self):
pass
def tearDown(self):
pass
def test_init(self):
pass
def test_parser(self):
ok_(self.c.parser(self.buf, 0))
@raises(AssertionError)
def test_parser_check_type(self):
type_ = {'buf': b'\x00\x01', 'val': 1}
buf = type_['buf'] \
+ self.len_['buf'] \
+ self.zfill
self.c.parser(buf, 0)
@raises(AssertionError)
def test_parser_check_len(self):
len_ = {'buf': b'\x00\x07', 'val': 7}
buf = self.type_['buf'] \
+ len_['buf'] \
+ self.zfill
self.c.parser(buf, 0)
class TestOFPActionSetDlSrc(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.OFPActionSetDlSrc
"""
# OFP_ACTION_DL_ADDR_PACK_STR
# '!HH6s6x'...type, len, dl_addr, zfill
type_ = {'buf': b'\x00\x04', 'val': ofproto.OFPAT_SET_DL_SRC}
len_ = {'buf': b'\x00\x10', 'val': ofproto.OFP_ACTION_DL_ADDR_SIZE}
dl_addr = b'\x0e\xde\x27\xce\xc6\xcf'
zfill = b'\x00' * 6
buf = type_['buf'] \
+ len_['buf'] \
+ dl_addr \
+ zfill
c = OFPActionSetDlSrc(dl_addr)
def setUp(self):
pass
def tearDown(self):
pass
def test_init(self):
eq_(self.dl_addr, self.c.dl_addr)
def test_parser_type_src(self):
res = self.c.parser(self.buf, 0)
eq_(self.dl_addr, res.dl_addr)
def test_parser_type_dst(self):
type_ = {'buf': b'\x00\x05', 'val': ofproto.OFPAT_SET_DL_DST}
buf = type_['buf'] \
+ self.len_['buf'] \
+ self.dl_addr \
+ self.zfill
res = self.c.parser(buf, 0)
eq_(self.dl_addr, res.dl_addr)
@raises(AssertionError)
def test_parser_check_type(self):
type_ = {'buf': b'\x00\x06', 'val': 6}
buf = type_['buf'] \
+ self.len_['buf'] \
+ self.dl_addr \
+ self.zfill
res = self.c.parser(buf, 0)
@raises(AssertionError)
def test_parser_check_len(self):
len_ = {'buf': b'\x00\x07', 'val': 7}
buf = self.type_['buf'] \
+ len_['buf'] \
+ self.dl_addr \
+ self.zfill
res = self.c.parser(buf, 0)
def test_serialize(self):
buf = bytearray()
self.c.serialize(buf, 0)
fmt = ofproto.OFP_ACTION_DL_ADDR_PACK_STR
res = struct.unpack(fmt, six.binary_type(buf))
eq_(self.type_['val'], res[0])
eq_(self.len_['val'], res[1])
eq_(self.dl_addr, res[2])
class TestOFPActionSetDlDst(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.OFPActionSetDlDst
"""
# OFP_ACTION_DL_ADDR_PACK_STR
# '!HH6s6x'...type, len, dl_addr, zfill
type_ = {'buf': b'\x00\x05', 'val': ofproto.OFPAT_SET_DL_DST}
len_ = {'buf': b'\x00\x10', 'val': ofproto.OFP_ACTION_DL_ADDR_SIZE}
dl_addr = b'\x37\x48\x38\x9a\xf4\x28'
zfill = b'\x00' * 6
buf = type_['buf'] \
+ len_['buf'] \
+ dl_addr \
+ zfill
c = OFPActionSetDlDst(dl_addr)
def setUp(self):
pass
def tearDown(self):
pass
def test_init(self):
eq_(self.dl_addr, self.c.dl_addr)
def test_parser_type_dst(self):
res = self.c.parser(self.buf, 0)
eq_(self.dl_addr, res.dl_addr)
def test_parser_type_src(self):
type_ = {'buf': b'\x00\x04', 'val': ofproto.OFPAT_SET_DL_SRC}
buf = type_['buf'] \
+ self.len_['buf'] \
+ self.dl_addr \
+ self.zfill
res = self.c.parser(buf, 0)
eq_(self.dl_addr, res.dl_addr)
@raises(AssertionError)
def test_parser_check_type(self):
type_ = {'buf': b'\x00\x06', 'val': 6}
buf = type_['buf'] \
+ self.len_['buf'] \
+ self.dl_addr \
+ self.zfill
res = self.c.parser(buf, 0)
@raises(AssertionError)
def test_parser_check_len(self):
len_ = {'buf': b'\x00\x07', 'val': 7}
buf = self.type_['buf'] \
+ len_['buf'] \
+ self.dl_addr \
+ self.zfill
res = self.c.parser(buf, 0)
def test_serialize(self):
buf = bytearray()
self.c.serialize(buf, 0)
fmt = ofproto.OFP_ACTION_DL_ADDR_PACK_STR
res = struct.unpack(fmt, six.binary_type(buf))
eq_(self.type_['val'], res[0])
eq_(self.len_['val'], res[1])
eq_(self.dl_addr, res[2])
class TestOFPActionSetNwSrc(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.OFPActionSetNwSrc
"""
# OFP_ACTION_NW_ADDR_PACK_STR
# '!HHI'...type, len, nw_addr
type_ = {'buf': b'\x00\x06', 'val': ofproto.OFPAT_SET_NW_SRC}
len_ = {'buf': b'\x00\x08', 'val': ofproto.OFP_ACTION_NW_ADDR_SIZE}
nw_addr = {'buf': b'\xc0\xa8\x7a\x0a', 'val': 3232266762}
buf = type_['buf'] \
+ len_['buf'] \
+ nw_addr['buf']
c = OFPActionSetNwSrc(nw_addr['val'])
def setUp(self):
pass
def tearDown(self):
pass
def test_init(self):
eq_(self.nw_addr['val'], self.c.nw_addr)
def test_parser_src(self):
res = self.c.parser(self.buf, 0)
eq_(self.nw_addr['val'], res.nw_addr)
def test_parser_dst(self):
type_ = {'buf': b'\x00\x07', 'val': ofproto.OFPAT_SET_NW_DST}
buf = type_['buf'] \
+ self.len_['buf'] \
+ self.nw_addr['buf']
res = self.c.parser(buf, 0)
eq_(self.nw_addr['val'], res.nw_addr)
@raises(AssertionError)
def test_parser_check_type(self):
type_ = {'buf': b'\x00\x05', 'val': 5}
buf = type_['buf'] \
+ self.len_['buf'] \
+ self.nw_addr['buf']
self.c.parser(buf, 0)
@raises(AssertionError)
def test_parser_check_len(self):
len_ = {'buf': b'\x00\x10', 'val': 16}
buf = self.type_['buf'] \
+ len_['buf'] \
+ self.nw_addr['buf']
self.c.parser(buf, 0)
def test_serialize(self):
buf = bytearray()
self.c.serialize(buf, 0)
fmt = ofproto.OFP_ACTION_NW_ADDR_PACK_STR
res = struct.unpack(fmt, six.binary_type(buf))
eq_(self.type_['val'], res[0])
eq_(self.len_['val'], res[1])
eq_(self.nw_addr['val'], res[2])
class TestOFPActionSetNwDst(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.OFPActionSetNwDst
"""
# OFP_ACTION_NW_ADDR_PACK_STR
# '!HHI'...type, len, nw_addr
type_ = {'buf': b'\x00\x07', 'val': ofproto.OFPAT_SET_NW_DST}
len_ = {'buf': b'\x00\x08', 'val': ofproto.OFP_ACTION_NW_ADDR_SIZE}
nw_addr = {'buf': b'\xc0\xa8\x7a\x0a', 'val': 3232266762}
buf = type_['buf'] \
+ len_['buf'] \
+ nw_addr['buf']
c = OFPActionSetNwDst(nw_addr['val'])
def setUp(self):
pass
def tearDown(self):
pass
def test_init(self):
eq_(self.nw_addr['val'], self.c.nw_addr)
def test_parser_dst(self):
res = self.c.parser(self.buf, 0)
eq_(self.nw_addr['val'], res.nw_addr)
def test_parser_src(self):
type_ = {'buf': b'\x00\x06', 'val': ofproto.OFPAT_SET_NW_SRC}
buf = type_['buf'] \
+ self.len_['buf'] \
+ self.nw_addr['buf']
res = self.c.parser(buf, 0)
eq_(self.nw_addr['val'], res.nw_addr)
@raises(AssertionError)
def test_parser_check_type(self):
type_ = {'buf': b'\x00\x05', 'val': 5}
buf = type_['buf'] \
+ self.len_['buf'] \
+ self.nw_addr['buf']
self.c.parser(buf, 0)
@raises(AssertionError)
def test_parser_check_len(self):
len_ = {'buf': b'\x00\x10', 'val': 16}
buf = self.type_['buf'] \
+ len_['buf'] \
+ self.nw_addr['buf']
self.c.parser(buf, 0)
def test_serialize(self):
buf = bytearray()
self.c.serialize(buf, 0)
fmt = ofproto.OFP_ACTION_NW_ADDR_PACK_STR
res = struct.unpack(fmt, six.binary_type(buf))
eq_(self.type_['val'], res[0])
eq_(self.len_['val'], res[1])
eq_(self.nw_addr['val'], res[2])
class TestOFPActionSetNwTos(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.OFPActionSetNwTos
"""
# OFP_ACTION_NW_TOS_PACK_STR
# '!HHB3x'...type, len, tos, zfill
type_ = {'buf': b'\x00\x08', 'val': ofproto.OFPAT_SET_NW_TOS}
len_ = {'buf': b'\x00\x08', 'val': ofproto.OFP_ACTION_NW_TOS_SIZE}
tos = {'buf': b'\xb6', 'val': 182}
zfill = b'\x00' * 3
buf = type_['buf'] \
+ len_['buf'] \
+ tos['buf'] \
+ zfill
c = OFPActionSetNwTos(tos['val'])
def setUp(self):
pass
def tearDown(self):
pass
def test_init(self):
eq_(self.tos['val'], self.c.tos)
def test_parser(self):
res = self.c.parser(self.buf, 0)
eq_(self.tos['val'], res.tos)
@raises(AssertionError)
def test_parser_check_type(self):
type_ = {'buf': b'\x00\x05', 'val': 5}
buf = type_['buf'] \
+ self.len_['buf'] \
+ self.tos['buf'] \
+ self.zfill
self.c.parser(buf, 0)
@raises(AssertionError)
def test_parser_check_len(self):
len_ = {'buf': b'\x00\x07', 'val': 7}
buf = self.type_['buf'] \
+ len_['buf'] \
+ self.tos['buf'] \
+ self.zfill
self.c.parser(buf, 0)
def test_serialize(self):
buf = bytearray()
self.c.serialize(buf, 0)
fmt = ofproto.OFP_ACTION_NW_TOS_PACK_STR
res = struct.unpack(fmt, six.binary_type(buf))
eq_(self.type_['val'], res[0])
eq_(self.len_['val'], res[1])
eq_(self.tos['val'], res[2])
class TestOFPActionSetTpSrc(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.OFPActionSetTpSrc
"""
# OFP_ACTION_TP_PORT_PACK_STR
# '!HHH2x'...type, len, tp, zfill
type_ = {'buf': b'\x00\x09', 'val': ofproto.OFPAT_SET_TP_SRC}
len_ = {'buf': b'\x00\x08', 'val': ofproto.OFP_ACTION_TP_PORT_SIZE}
tp = {'buf': b'\x07\xf1', 'val': 2033}
zfill = b'\x00' * 2
buf = type_['buf'] \
+ len_['buf'] \
+ tp['buf'] \
+ zfill
c = OFPActionSetTpSrc(tp['val'])
def setUp(self):
pass
def tearDown(self):
pass
def test_init(self):
eq_(self.tp['val'], self.c.tp)
def test_parser_src(self):
res = self.c.parser(self.buf, 0)
eq_(self.tp['val'], res.tp)
def test_parser_dst(self):
type_ = {'buf': b'\x00\x0a', 'val': ofproto.OFPAT_SET_TP_DST}
buf = type_['buf'] \
+ self.len_['buf'] \
+ self.tp['buf'] \
+ self.zfill
res = self.c.parser(self.buf, 0)
eq_(self.tp['val'], res.tp)
@raises(AssertionError)
def test_parser_check_type(self):
type_ = {'buf': b'\x00\x07', 'val': 7}
buf = type_['buf'] \
+ self.len_['buf'] \
+ self.tp['buf'] \
+ self.zfill
self.c.parser(buf, 0)
@raises(AssertionError)
def test_parser_check_len(self):
len_ = {'buf': b'\x00\x07', 'val': 7}
buf = self.type_['buf'] \
+ len_['buf'] \
+ self.tp['buf'] \
+ self.zfill
self.c.parser(buf, 0)
def test_serialize(self):
buf = bytearray()
self.c.serialize(buf, 0)
fmt = ofproto.OFP_ACTION_TP_PORT_PACK_STR
res = struct.unpack(fmt, six.binary_type(buf))
eq_(self.type_['val'], res[0])
eq_(self.len_['val'], res[1])
eq_(self.tp['val'], res[2])
class TestOFPActionSetTpDst(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.OFPActionSetTpDst
"""
# OFP_ACTION_TP_PORT_PACK_STR
# '!HHH2x'...type, len, tp, zfill
type_ = {'buf': b'\x00\x0a', 'val': ofproto.OFPAT_SET_TP_DST}
len_ = {'buf': b'\x00\x08', 'val': ofproto.OFP_ACTION_TP_PORT_SIZE}
tp = {'buf': b'\x06\x6d', 'val': 1645}
zfill = b'\x00' * 2
buf = type_['buf'] \
+ len_['buf'] \
+ tp['buf'] \
+ zfill
c = OFPActionSetTpDst(tp['val'])
def setUp(self):
pass
def tearDown(self):
pass
def test_init(self):
eq_(self.tp['val'], self.c.tp)
def test_parser_dst(self):
res = self.c.parser(self.buf, 0)
eq_(self.tp['val'], res.tp)
def test_parser_src(self):
type_ = {'buf': b'\x00\x09', 'val': ofproto.OFPAT_SET_TP_SRC}
buf = type_['buf'] \
+ self.len_['buf'] \
+ self.tp['buf'] \
+ self.zfill
res = self.c.parser(buf, 0)
eq_(self.tp['val'], res.tp)
@raises(AssertionError)
def test_parser_check_type(self):
type_ = {'buf': b'\x00\x10', 'val': 16}
buf = type_['buf'] \
+ self.len_['buf'] \
+ self.tp['buf'] \
+ self.zfill
self.c.parser(buf, 0)
@raises(AssertionError)
def test_parser_check_len(self):
len_ = {'buf': b'\x00\x07', 'val': 7}
buf = self.type_['buf'] \
+ len_['buf'] \
+ self.tp['buf'] \
+ self.zfill
self.c.parser(buf, 0)
def test_serialize(self):
buf = bytearray()
self.c.serialize(buf, 0)
fmt = ofproto.OFP_ACTION_TP_PORT_PACK_STR
res = struct.unpack(fmt, six.binary_type(buf))
eq_(self.type_['val'], res[0])
eq_(self.len_['val'], res[1])
eq_(self.tp['val'], res[2])
class TestOFPActionEnqueue(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.OFPActionEnqueue
"""
# OFP_ACTION_ENQUEUE_PACK_STR
# '!HHH6xI'...type_, len_, port, zfill, queue_id
type_ = {'buf': b'\x00\x0b', 'val': ofproto.OFPAT_ENQUEUE}
len_ = {'buf': b'\x00\x10', 'val': ofproto.OFP_ACTION_ENQUEUE_SIZE}
port = {'buf': b'\x04\x55', 'val': 1109}
zfill = b'\x00' * 6
queue_id = {'buf': b'\x0a\x5b\x03\x5e', 'val': 173736798}
buf = type_['buf'] \
+ len_['buf'] \
+ port['buf'] \
+ zfill \
+ queue_id['buf']
c = OFPActionEnqueue(port['val'], queue_id['val'])
def setUp(self):
pass
def tearDown(self):
pass
def test_init(self):
eq_(self.port['val'], self.c.port)
eq_(self.queue_id['val'], self.c.queue_id)
def test_parser(self):
res = self.c.parser(self.buf, 0)
eq_(self.port['val'], res.port)
eq_(self.queue_id['val'], res.queue_id)
@raises(AssertionError)
def test_parser_check_type(self):
type_ = {'buf': b'\x00\x0a', 'val': 10}
buf = type_['buf'] \
+ self.len_['buf'] \
+ self.port['buf'] \
+ self.zfill \
+ self.queue_id['buf']
self.c.parser(buf, 0)
@raises(AssertionError)
def test_parser_check_len(self):
len_ = {'buf': b'\x00\x05', 'val': 5}
buf = self.type_['buf'] \
+ len_['buf'] \
+ self.port['buf'] \
+ self.zfill \
+ self.queue_id['buf']
self.c.parser(buf, 0)
def test_serialize(self):
buf = bytearray()
self.c.serialize(buf, 0)
fmt = ofproto.OFP_ACTION_ENQUEUE_PACK_STR
res = struct.unpack(fmt, six.binary_type(buf))
eq_(self.type_['val'], res[0])
eq_(self.len_['val'], res[1])
eq_(self.port['val'], res[2])
eq_(self.queue_id['val'], res[3])
class TestNXActionResubmit(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.NXActionResubmit
"""
# NX_ACTION_RESUBMIT_PACK_STR
# '!HHIHHB3x'...type, len, vendor, subtype, in_port, table, zfill
type_ = {'buf': b'\xff\xff', 'val': ofproto.OFPAT_VENDOR}
len_ = {'buf': b'\x00\x10', 'val': ofproto.NX_ACTION_RESUBMIT_SIZE}
vendor = {'buf': b'\x00\x00\x23\x20', 'val': 8992}
subtype = {'buf': b'\x00\x01', 'val': 1}
in_port = {'buf': b'\x0a\x4c', 'val': 2636}
table = {'buf': b'\x52', 'val': 82}
zfill = b'\x00' * 3
buf = type_['buf'] \
+ len_['buf'] \
+ vendor['buf'] \
+ subtype['buf'] \
+ in_port['buf'] \
+ table['buf'] \
+ zfill
c = NXActionResubmit(in_port['val'])
def setUp(self):
pass
def tearDown(self):
pass
def test_init(self):
eq_(self.subtype['val'], self.c.subtype)
eq_(self.in_port['val'], self.c.in_port)
def test_parser(self):
res = OFPActionVendor.parser(self.buf, 0)
eq_(self.type_['val'], res.type)
eq_(self.len_['val'], res.len)
eq_(self.in_port['val'], res.in_port)
def test_serialize(self):
buf = bytearray()
self.c.serialize(buf, 0)
fmt = ofproto.NX_ACTION_RESUBMIT_PACK_STR
res = struct.unpack(fmt, six.binary_type(buf))
eq_(self.type_['val'], res[0])
eq_(self.len_['val'], res[1])
eq_(self.vendor['val'], res[2])
eq_(self.subtype['val'], res[3])
eq_(self.in_port['val'], res[4])
class TestNXActionResubmitTable(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.NXActionResubmitTable
"""
# NX_ACTION_RESUBMIT_PACK_STR
# '!HHIHHB3x'...type, len, vendor, subtype, in_port, table, zfill
type_ = {'buf': b'\xff\xff', 'val': ofproto.OFPAT_VENDOR}
len_ = {'buf': b'\x00\x10', 'val': ofproto.NX_ACTION_RESUBMIT_SIZE}
vendor = {'buf': b'\x00\x00\x23\x20', 'val': 8992}
subtype = {'buf': b'\x00\x0e', 'val': 14}
in_port = {'buf': b'\x0a\x4c', 'val': 2636}
table_id = {'buf': b'\x52', 'val': 82}
zfill = b'\x00' * 3
buf = type_['buf'] \
+ len_['buf'] \
+ vendor['buf'] \
+ subtype['buf'] \
+ in_port['buf'] \
+ table_id['buf'] \
+ zfill
c = NXActionResubmitTable(in_port['val'], table_id['val'])
def setUp(self):
pass
def tearDown(self):
pass
def test_init(self):
eq_(self.subtype['val'], self.c.subtype)
eq_(self.in_port['val'], self.c.in_port)
eq_(self.table_id['val'], self.c.table_id)
def test_parser(self):
res = OFPActionVendor.parser(self.buf, 0)
eq_(self.type_['val'], res.type)
eq_(self.len_['val'], res.len)
eq_(self.in_port['val'], res.in_port)
eq_(self.table_id['val'], res.table_id)
def test_serialize(self):
buf = bytearray()
self.c.serialize(buf, 0)
fmt = ofproto.NX_ACTION_RESUBMIT_PACK_STR
res = struct.unpack(fmt, six.binary_type(buf))
eq_(self.type_['val'], res[0])
eq_(self.len_['val'], res[1])
eq_(self.vendor['val'], res[2])
eq_(self.subtype['val'], res[3])
eq_(self.in_port['val'], res[4])
eq_(self.table_id['val'], res[5])
class TestNXActionSetTunnel(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.NXActionSetTunnel
"""
# NX_ACTION_SET_TUNNEL_PACK_STR
# '!HHIH2xI'...type, len, vendor, subtype, zfill, tun_id
type_ = {'buf': b'\xff\xff', 'val': ofproto.OFPAT_VENDOR}
len_ = {'buf': b'\x00\x10', 'val': ofproto.NX_ACTION_SET_TUNNEL_SIZE}
vendor = {'buf': b'\x00\x00\x23\x20', 'val': 8992}
subtype = {'buf': b'\x00\x02', 'val': 2}
zfill = b'\x00' * 2
tun_id = {'buf': b'\x01\x6f\x01\xd0', 'val': 24052176}
buf = type_['buf'] \
+ len_['buf'] \
+ vendor['buf'] \
+ subtype['buf'] \
+ zfill \
+ tun_id['buf']
c = NXActionSetTunnel(tun_id['val'])
def setUp(self):
pass
def tearDown(self):
pass
def test_init(self):
eq_(self.subtype['val'], self.c.subtype)
eq_(self.tun_id['val'], self.c.tun_id)
def test_parse(self):
res = OFPActionVendor.parser(self.buf, 0)
eq_(self.type_['val'], res.type)
eq_(self.len_['val'], res.len)
eq_(self.tun_id['val'], res.tun_id)
def test_serialize(self):
buf = bytearray()
self.c.serialize(buf, 0)
fmt = ofproto.NX_ACTION_SET_TUNNEL_PACK_STR
res = struct.unpack(fmt, six.binary_type(buf))
eq_(self.type_['val'], res[0])
eq_(self.len_['val'], res[1])
eq_(self.vendor['val'], res[2])
eq_(self.subtype['val'], res[3])
eq_(self.tun_id['val'], res[4])
class TestNXActionSetQueue(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.NXActionSetQueue
"""
# NX_ACTION_SET_QUEUE_PACK_STR
# '!HHIH2xI'...type, len, vendor, subtype, zfill, queue_id
type_ = {'buf': b'\xff\xff', 'val': ofproto.OFPAT_VENDOR}
len_ = {'buf': b'\x00\x10', 'val': ofproto.NX_ACTION_SET_TUNNEL_SIZE}
vendor = {'buf': b'\x00\x00\x23\x20',
'val': ofproto_common.NX_EXPERIMENTER_ID}
subtype = {'buf': b'\x00\x04', 'val': ofproto.NXAST_SET_QUEUE}
zfill = b'\x00' * 2
queue_id = {'buf': b'\xde\xbe\xc5\x18', 'val': 3737044248}
buf = type_['buf'] \
+ len_['buf'] \
+ vendor['buf'] \
+ subtype['buf'] \
+ zfill \
+ queue_id['buf']
c = NXActionSetQueue(queue_id['val'])
def setUp(self):
pass
def tearDown(self):
pass
def test_init(self):
eq_(self.subtype['val'], self.c.subtype)
eq_(self.queue_id['val'], self.c.queue_id)
def test_parser(self):
res = OFPActionVendor.parser(self.buf, 0)
eq_(self.type_['val'], res.type)
eq_(self.len_['val'], res.len)
eq_(self.queue_id['val'], res.queue_id)
def test_serialize(self):
buf = bytearray()
self.c.serialize(buf, 0)
fmt = ofproto.NX_ACTION_SET_QUEUE_PACK_STR
res = struct.unpack(fmt, six.binary_type(buf))
eq_(self.type_['val'], res[0])
eq_(self.len_['val'], res[1])
eq_(self.vendor['val'], res[2])
eq_(self.subtype['val'], res[3])
eq_(self.queue_id['val'], res[4])
class TestNXActionPopQueue(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.NXActionPopQueue
"""
# NX_ACTION_POP_QUEUE_PACK_STR
# '!HHIH6x'...type, len, vendor, subtype, zfill
type_ = {'buf': b'\xff\xff', 'val': ofproto.OFPAT_VENDOR}
len_ = {'buf': b'\x00\x10', 'val': ofproto.NX_ACTION_SET_TUNNEL_SIZE}
vendor = {'buf': b'\x00\x00\x23\x20',
'val': ofproto_common.NX_EXPERIMENTER_ID}
subtype = {'buf': b'\x00\x05', 'val': ofproto.NXAST_POP_QUEUE}
zfill = b'\x00' * 6
buf = type_['buf'] \
+ len_['buf'] \
+ vendor['buf'] \
+ subtype['buf'] \
+ zfill
c = NXActionPopQueue()
def setUp(self):
pass
def tearDown(self):
pass
def test_init(self):
eq_(self.subtype['val'], self.c.subtype)
def test_parser(self):
res = OFPActionVendor.parser(self.buf, 0)
eq_(self.type_['val'], res.type)
eq_(self.len_['val'], res.len)
eq_(self.subtype['val'], res.subtype)
def test_serialize(self):
buf = bytearray()
self.c.serialize(buf, 0)
fmt = ofproto.NX_ACTION_POP_QUEUE_PACK_STR
res = struct.unpack(fmt, six.binary_type(buf))
eq_(self.type_['val'], res[0])
eq_(self.len_['val'], res[1])
eq_(self.vendor['val'], res[2])
eq_(self.subtype['val'], res[3])
class TestNXActionRegMove(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.NXActionRegMove
"""
# NX_ACTION_REG_MOVE_PACK_STR
# '!HHIHHHHII'...type_, len_, vendor, subtype, n_bits,
# src_ofs, dst_ofs, src, dst
type_ = {'buf': b'\xff\xff', 'val': ofproto.OFPAT_VENDOR}
len_ = {'buf': b'\x00\x18', 'val': ofproto.NX_ACTION_REG_MOVE_SIZE}
vendor = {'buf': b'\x00\x00\x23\x20',
'val': ofproto_common.NX_EXPERIMENTER_ID}
subtype = {'buf': b'\x00\x06', 'val': ofproto.NXAST_REG_MOVE}
n_bits = {'buf': b'\x3d\x98', 'val': 15768}
src_ofs = {'buf': b'\xf3\xa3', 'val': 62371}
dst_ofs = {'buf': b'\xdc\x67', 'val': 56423}
src_field = {'buf': b'\x00\x01\x00\x04', 'val': "reg0", "val2": 65540}
dst_field = {'buf': b'\x00\x01\x02\x04', 'val': "reg1", "val2": 66052}
buf = type_['buf'] \
+ len_['buf'] \
+ vendor['buf'] \
+ subtype['buf'] \
+ n_bits['buf'] \
+ src_ofs['buf'] \
+ dst_ofs['buf'] \
+ src_field['buf'] \
+ dst_field['buf']
c = NXActionRegMove(src_field['val'],
dst_field['val'],
n_bits['val'],
src_ofs['val'],
dst_ofs['val'])
def setUp(self):
pass
def tearDown(self):
pass
def test_init(self):
eq_(self.subtype['val'], self.c.subtype)
eq_(self.src_field['val'], self.c.src_field)
eq_(self.dst_field['val'], self.c.dst_field)
eq_(self.n_bits['val'], self.c.n_bits)
eq_(self.src_field['val'], self.c.src_field)
eq_(self.dst_field['val'], self.c.dst_field)
def test_parser(self):
res = OFPActionVendor.parser(self.buf, 0)
eq_(self.type_['val'], res.type)
eq_(self.len_['val'], res.len)
eq_(self.subtype['val'], res.subtype)
eq_(self.src_ofs['val'], res.src_ofs)
eq_(self.dst_ofs['val'], res.dst_ofs)
eq_(self.n_bits['val'], res.n_bits)
eq_(self.src_field['val'], res.src_field)
eq_(self.dst_field['val'], res.dst_field)
def test_serialize(self):
buf = bytearray()
self.c.serialize(buf, 0)
fmt = ofproto.NX_ACTION_REG_MOVE_PACK_STR
res = struct.unpack(fmt, six.binary_type(buf))
eq_(self.type_['val'], res[0])
eq_(self.len_['val'], res[1])
eq_(self.vendor['val'], res[2])
eq_(self.subtype['val'], res[3])
eq_(self.n_bits['val'], res[4])
eq_(self.src_ofs['val'], res[5])
eq_(self.dst_ofs['val'], res[6])
eq_(self.src_field['val2'], res[7])
eq_(self.dst_field['val2'], res[8])
class TestNXActionRegLoad(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.NXActionRegLoad
"""
# NX_ACTION_REG_LOAD_PACK_STR
# '!HHIHHIQ'...type_, len_, vendor, subtype,
# ofs_nbits, dst, value
type_ = {'buf': b'\xff\xff', 'val': ofproto.OFPAT_VENDOR}
len_ = {'buf': b'\x00\x18', 'val': ofproto.NX_ACTION_REG_MOVE_SIZE}
vendor = {'buf': b'\x00\x00\x23\x20',
'val': ofproto_common.NX_EXPERIMENTER_ID}
subtype = {'buf': b'\x00\x07', 'val': ofproto.NXAST_REG_LOAD}
ofs_nbits = {'buf': b'\x3d\x98', 'val': 15768}
dst = {'buf': b'\x00\x01\x00\x04', 'val': "reg0", "val2": 65540}
value = {'buf': b'\x33\x51\xcd\x43\x25\x28\x18\x99',
'val': 3697962457317775513}
start = 246
end = 270
buf = type_['buf'] \
+ len_['buf'] \
+ vendor['buf'] \
+ subtype['buf'] \
+ ofs_nbits['buf'] \
+ dst['buf'] \
+ value['buf']
c = NXActionRegLoad(ofs_nbits['val'],
dst['val'],
value['val'])
def setUp(self):
pass
def tearDown(self):
pass
def test_init(self):
eq_(self.subtype['val'], self.c.subtype)
eq_(self.ofs_nbits['val'], self.c.ofs_nbits)
eq_(self.dst['val'], self.c.dst)
eq_(self.value['val'], self.c.value)
def test_parser(self):
res = OFPActionVendor.parser(self.buf, 0)
eq_(self.type_['val'], res.type)
eq_(self.len_['val'], res.len)
eq_(self.ofs_nbits['val'], self.c.ofs_nbits)
eq_(self.dst['val'], res.dst)
eq_(self.value['val'], res.value)
def test_serialize(self):
buf = bytearray()
self.c.serialize(buf, 0)
fmt = ofproto.NX_ACTION_REG_LOAD_PACK_STR
res = struct.unpack(fmt, six.binary_type(buf))
eq_(self.type_['val'], res[0])
eq_(self.len_['val'], res[1])
eq_(self.vendor['val'], res[2])
eq_(self.subtype['val'], res[3])
eq_(self.ofs_nbits['val'], res[4])
eq_(self.dst['val2'], res[5])
eq_(self.value['val'], res[6])
class TestNXActionSetTunnel64(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.NXActionSetTunnel64
"""
# NX_ACTION_SET_TUNNEL64_PACK_STR
# '!HHIH6xQ'...type, len, vendor, subtype, zfill, tun_id
type_ = {'buf': b'\xff\xff', 'val': ofproto.OFPAT_VENDOR}
len_ = {'buf': b'\x00\x18', 'val': ofproto.NX_ACTION_SET_TUNNEL64_SIZE}
vendor = {'buf': b'\x00\x00\x23\x20',
'val': ofproto_common.NX_EXPERIMENTER_ID}
subtype = {'buf': b'\x00\x09', 'val': ofproto.NXAST_SET_TUNNEL64}
zfill = b'\x00' * 6
tun_id = {'buf': b'\x6e\x01\xa6\xea\x7e\x36\x1d\xd9',
'val': 7926800345218817497}
buf = type_['buf'] \
+ len_['buf'] \
+ vendor['buf'] \
+ subtype['buf'] \
+ zfill \
+ tun_id['buf']
c = NXActionSetTunnel64(tun_id['val'])
def setUp(self):
pass
def tearDown(self):
pass
def test_init(self):
eq_(self.subtype['val'], self.c.subtype)
eq_(self.tun_id['val'], self.c.tun_id)
def test_parser(self):
res = OFPActionVendor.parser(self.buf, 0)
eq_(self.type_['val'], res.type)
eq_(self.len_['val'], res.len)
eq_(self.subtype['val'], res.subtype)
eq_(self.tun_id['val'], res.tun_id)
def test_serialize(self):
buf = bytearray()
self.c.serialize(buf, 0)
fmt = ofproto.NX_ACTION_SET_TUNNEL64_PACK_STR
res = struct.unpack(fmt, six.binary_type(buf))
eq_(self.type_['val'], res[0])
eq_(self.len_['val'], res[1])
eq_(self.vendor['val'], res[2])
eq_(self.subtype['val'], res[3])
eq_(self.tun_id['val'], res[4])
class TestNXActionMultipath(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.NXActionMultipath
"""
# NX_ACTION_MULTIPATH_PACK_STR
# '!HHIHHH2xHHI2xHI'...type, len, vendor, subtype, fields, basis, zfill
# algorithm, max_link, arg, zfill, ofs_nbits, dst
type_ = {'buf': b'\xff\xff', 'val': ofproto.OFPAT_VENDOR}
len_ = {'buf': b'\x00\x20', 'val': ofproto.NX_ACTION_MULTIPATH_SIZE}
vendor = {'buf': b'\x00\x00\x23\x20',
'val': ofproto_common.NX_EXPERIMENTER_ID}
subtype = {'buf': b'\x00\x0a', 'val': ofproto.NXAST_MULTIPATH}
fields = {'buf': b'\x6d\xf5', 'val': 28149}
basis = {'buf': b'\x7c\x0a', 'val': 31754}
zfill0 = b'\x00' * 2
algorithm = {'buf': b'\x82\x1d', 'val': 33309}
max_link = {'buf': b'\x06\x2b', 'val': 1579}
arg = {'buf': b'\x18\x79\x41\xc8', 'val': 410599880}
zfill1 = b'\x00' * 2
ofs_nbits = {'buf': b'\xa9\x9a', 'val': 43418}
dst = {'buf': b'\x00\x01\x00\x04', 'val': "reg0", 'val2': 65540}
start = 678
end = 704
buf = type_['buf'] \
+ len_['buf'] \
+ vendor['buf'] \
+ subtype['buf'] \
+ fields['buf'] \
+ basis['buf'] \
+ zfill0 \
+ algorithm['buf'] \
+ max_link['buf'] \
+ arg['buf'] \
+ zfill1 \
+ ofs_nbits['buf'] \
+ dst['buf']
c = NXActionMultipath(fields['val'],
basis['val'],
algorithm['val'],
max_link['val'],
arg['val'],
ofs_nbits['val'],
dst['val'])
def setUp(self):
pass
def tearDown(self):
pass
def test_init(self):
eq_(self.subtype['val'], self.c.subtype)
eq_(self.fields['val'], self.c.fields)
eq_(self.basis['val'], self.c.basis)
eq_(self.algorithm['val'], self.c.algorithm)
eq_(self.max_link['val'], self.c.max_link)
eq_(self.arg['val'], self.c.arg)
eq_(self.ofs_nbits['val'], self.c.ofs_nbits)
eq_(self.dst['val'], self.c.dst)
def test_parser(self):
res = OFPActionVendor.parser(self.buf, 0)
eq_(self.type_['val'], res.type)
eq_(self.len_['val'], res.len)
eq_(self.subtype['val'], res.subtype)
eq_(self.fields['val'], res.fields)
eq_(self.basis['val'], res.basis)
eq_(self.algorithm['val'], res.algorithm)
eq_(self.max_link['val'], res.max_link)
eq_(self.arg['val'], res.arg)
eq_(self.ofs_nbits['val'], res.ofs_nbits)
eq_(self.dst['val'], res.dst)
def test_serialize(self):
buf = bytearray()
self.c.serialize(buf, 0)
fmt = ofproto.NX_ACTION_MULTIPATH_PACK_STR
res = struct.unpack(fmt, six.binary_type(buf))
eq_(self.type_['val'], res[0])
eq_(self.len_['val'], res[1])
eq_(self.vendor['val'], res[2])
eq_(self.subtype['val'], res[3])
eq_(self.fields['val'], res[4])
eq_(self.basis['val'], res[5])
eq_(self.algorithm['val'], res[6])
eq_(self.max_link['val'], res[7])
eq_(self.arg['val'], res[8])
eq_(self.ofs_nbits['val'], res[9])
eq_(self.dst['val2'], res[10])
class TestNXActionBundle(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.NXActionBundle
"""
# NX_ACTION_BUNDLE_PACK_STR
# '!HHIHHHHIHHI4x'...type, len, vendor, subtype, algorithm,
# fields, basis, slave_type, n_slaves,
# ofs_nbits, dst, zfill
type_ = {'buf': b'\xff\xff', 'val': ofproto.OFPAT_VENDOR}
len_ = {'buf': b'\x00\x28', 'val': (ofproto.NX_ACTION_BUNDLE_SIZE + 8)}
vendor = {'buf': b'\x00\x00\x23\x20',
'val': ofproto_common.NX_EXPERIMENTER_ID}
subtype = {'buf': b'\x00\x0c', 'val': ofproto.NXAST_BUNDLE}
algorithm = {'buf': b'\x51\xa7', 'val': 20903}
fields = {'buf': b'\xf8\xef', 'val': 63727}
basis = {'buf': b'\xfd\x6f', 'val': 64879}
slave_type = {'buf': b'\x7c\x51\x0f\xe0', 'val': 2085687264}
n_slaves = {'buf': b'\x00\x02', 'val': 2}
ofs_nbits = {'buf': b'\x00\x00', 'val': 0}
dst = {'buf': b'\x00\x00\x00\x00', 'val': 0}
zfill = b'\x00' * 4
slaves_buf = (b'\x00\x01', b'\x00\x02')
slaves_val = (1, 2)
_len = len_['val'] + len(slaves_val) * 2
_len += (_len % 8)
buf = type_['buf'] \
+ len_['buf'] \
+ vendor['buf'] \
+ subtype['buf'] \
+ algorithm['buf'] \
+ fields['buf'] \
+ basis['buf'] \
+ slave_type['buf'] \
+ n_slaves['buf'] \
+ ofs_nbits['buf'] \
+ dst['buf'] \
+ zfill \
+ slaves_buf[0] \
+ slaves_buf[1]
c = NXActionBundle(algorithm['val'],
fields['val'],
basis['val'],
slave_type['val'],
n_slaves['val'],
ofs_nbits['val'],
dst['val'],
slaves_val)
def setUp(self):
pass
def tearDown(self):
pass
def test_init(self):
eq_(self.subtype['val'], self.c.subtype)
eq_(self.algorithm['val'], self.c.algorithm)
eq_(self.fields['val'], self.c.fields)
eq_(self.basis['val'], self.c.basis)
eq_(self.slave_type['val'], self.c.slave_type)
eq_(self.n_slaves['val'], self.c.n_slaves)
eq_(self.ofs_nbits['val'], self.c.ofs_nbits)
eq_(self.dst['val'], self.c.dst)
# slaves
slaves = self.c.slaves
eq_(self.slaves_val[0], slaves[0])
eq_(self.slaves_val[1], slaves[1])
def test_parser(self):
res = OFPActionVendor.parser(self.buf, 0)
eq_(self.type_['val'], res.type)
eq_(self.len_['val'], res.len)
eq_(self.subtype['val'], res.subtype)
eq_(self.algorithm['val'], res.algorithm)
eq_(self.fields['val'], res.fields)
eq_(self.basis['val'], res.basis)
eq_(self.slave_type['val'], res.slave_type)
eq_(self.n_slaves['val'], res.n_slaves)
eq_(self.ofs_nbits['val'], res.ofs_nbits)
eq_(self.dst['val'], res.dst)
# slaves
slaves = res.slaves
eq_(self.slaves_val[0], slaves[0])
eq_(self.slaves_val[1], slaves[1])
def test_serialize(self):
buf = bytearray()
self.c.serialize(buf, 0)
fmt = '!' \
+ ofproto.NX_ACTION_BUNDLE_PACK_STR.replace('!', '') \
+ 'HH4x'
res = struct.unpack(fmt, six.binary_type(buf))
eq_(self.type_['val'], res[0])
eq_(self.len_['val'], res[1])
eq_(self.vendor['val'], res[2])
eq_(self.subtype['val'], res[3])
eq_(self.algorithm['val'], res[4])
eq_(self.fields['val'], res[5])
eq_(self.basis['val'], res[6])
eq_(self.slave_type['val'], res[7])
eq_(self.n_slaves['val'], res[8])
eq_(self.ofs_nbits['val'], res[9])
eq_(self.dst['val'], res[10])
class TestNXActionBundleLoad(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.NXActionBundleLoad
"""
# NX_ACTION_BUNDLE_PACK_STR
# '!HHIHHHHIHHI4x'...type, len, vendor, subtype, algorithm,
# fields, basis, slave_type, n_slaves,
# ofs_nbits, dst, zfill
type_ = {'buf': b'\xff\xff', 'val': ofproto.OFPAT_VENDOR}
len_ = {'buf': b'\x00\x28', 'val': (ofproto.NX_ACTION_BUNDLE_SIZE + 8)}
vendor = {'buf': b'\x00\x00\x23\x20',
'val': ofproto_common.NX_EXPERIMENTER_ID}
subtype = {'buf': b'\x00\x0d', 'val': ofproto.NXAST_BUNDLE_LOAD}
algorithm = {'buf': b'\x83\x15', 'val': 33557}
fields = {'buf': b'\xc2\x7a', 'val': 49786}
basis = {'buf': b'\x86\x18', 'val': 34328}
slave_type = {'buf': b'\x18\x42\x0b\x55', 'val': 406981461}
n_slaves = {'buf': b'\x00\x02', 'val': 2}
ofs_nbits = {'buf': b'\xd2\x9d', 'val': 53917}
dst = {'buf': b'\x00\x01\x00\x04', 'val': "reg0", 'val2': 65540}
zfill = b'\x00' * 4
slaves_buf = (b'\x00\x01', b'\x00\x02')
slaves_val = (1, 2)
_len = len_['val'] + len(slaves_val) * 2
_len += (_len % 8)
buf = type_['buf'] \
+ len_['buf'] \
+ vendor['buf'] \
+ subtype['buf'] \
+ algorithm['buf'] \
+ fields['buf'] \
+ basis['buf'] \
+ slave_type['buf'] \
+ n_slaves['buf'] \
+ ofs_nbits['buf'] \
+ dst['buf'] \
+ zfill \
+ slaves_buf[0] \
+ slaves_buf[1]
c = NXActionBundleLoad(algorithm['val'],
fields['val'],
basis['val'],
slave_type['val'],
n_slaves['val'],
ofs_nbits['val'],
dst['val'],
slaves_val)
def setUp(self):
pass
def tearDown(self):
pass
def test_init(self):
eq_(self.subtype['val'], self.c.subtype)
eq_(self.algorithm['val'], self.c.algorithm)
eq_(self.fields['val'], self.c.fields)
eq_(self.basis['val'], self.c.basis)
eq_(self.slave_type['val'], self.c.slave_type)
eq_(self.n_slaves['val'], self.c.n_slaves)
eq_(self.ofs_nbits['val'], self.c.ofs_nbits)
eq_(self.dst['val'], self.c.dst)
# slaves
slaves = self.c.slaves
eq_(self.slaves_val[0], slaves[0])
eq_(self.slaves_val[1], slaves[1])
def test_parser(self):
res = OFPActionVendor.parser(self.buf, 0)
eq_(self.type_['val'], res.type)
eq_(self.len_['val'], res.len)
eq_(self.subtype['val'], res.subtype)
eq_(self.algorithm['val'], res.algorithm)
eq_(self.fields['val'], res.fields)
eq_(self.basis['val'], res.basis)
eq_(self.slave_type['val'], res.slave_type)
eq_(self.n_slaves['val'], res.n_slaves)
eq_(self.ofs_nbits['val'], res.ofs_nbits)
eq_(self.dst['val'], res.dst)
# slaves
slaves = res.slaves
eq_(self.slaves_val[0], slaves[0])
eq_(self.slaves_val[1], slaves[1])
def test_serialize(self):
buf = bytearray()
self.c.serialize(buf, 0)
fmt = '!' \
+ ofproto.NX_ACTION_BUNDLE_PACK_STR.replace('!', '') \
+ 'HH4x'
res = struct.unpack(fmt, six.binary_type(buf))
eq_(self.type_['val'], res[0])
eq_(self.len_['val'], res[1])
eq_(self.vendor['val'], res[2])
eq_(self.subtype['val'], res[3])
eq_(self.algorithm['val'], res[4])
eq_(self.fields['val'], res[5])
eq_(self.basis['val'], res[6])
eq_(self.slave_type['val'], res[7])
eq_(self.n_slaves['val'], res[8])
eq_(self.ofs_nbits['val'], res[9])
eq_(self.dst['val2'], res[10])
class TestNXActionOutputReg(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.NXActionOutputReg
"""
# NX_ACTION_OUTPUT_REG_PACK_STR
# '!HHIHHIH6x'...type, len, vendor, subtype, ofs_nbits,
# src, max_len, zfill
type_ = {'buf': b'\xff\xff', 'val': ofproto.OFPAT_VENDOR}
len_ = {'buf': b'\x00\x18', 'val': ofproto.NX_ACTION_OUTPUT_REG_SIZE}
vendor = {'buf': b'\x00\x00\x23\x20',
'val': ofproto_common.NX_EXPERIMENTER_ID}
subtype = {'buf': b'\x00\x0f', 'val': ofproto.NXAST_OUTPUT_REG}
ofs_nbits = {'buf': b'\xfe\x78', 'val': 65144}
src = {'buf': b'\x00\x01\x00\x04', 'val': "reg0", 'val2': 65540}
max_len = {'buf': b'\x00\x08', 'val': ofproto.OFP_ACTION_OUTPUT_SIZE}
zfill = b'\x00' * 6
buf = type_['buf'] \
+ len_['buf'] \
+ vendor['buf'] \
+ subtype['buf'] \
+ ofs_nbits['buf'] \
+ src['buf'] \
+ max_len['buf'] \
+ zfill
c = NXActionOutputReg(ofs_nbits['val'],
src['val'],
max_len['val'])
def setUp(self):
pass
def tearDown(self):
pass
def test_init(self):
eq_(self.subtype['val'], self.c.subtype)
eq_(self.ofs_nbits['val'], self.c.ofs_nbits)
eq_(self.src['val'], self.c.src)
eq_(self.max_len['val'], self.c.max_len)
def test_parser(self):
res = OFPActionVendor.parser(self.buf, 0)
eq_(self.type_['val'], res.type)
eq_(self.len_['val'], res.len)
eq_(self.subtype['val'], res.subtype)
eq_(self.ofs_nbits['val'], self.c.ofs_nbits)
eq_(self.src['val'], res.src)
eq_(self.max_len['val'], res.max_len)
def test_serialize(self):
buf = bytearray()
self.c.serialize(buf, 0)
fmt = ofproto.NX_ACTION_OUTPUT_REG_PACK_STR
res = struct.unpack(fmt, six.binary_type(buf))
eq_(self.type_['val'], res[0])
eq_(self.len_['val'], res[1])
eq_(self.vendor['val'], res[2])
eq_(self.subtype['val'], res[3])
eq_(self.ofs_nbits['val'], res[4])
eq_(self.src['val2'], res[5])
eq_(self.max_len['val'], res[6])
class TestNXActionExit(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.NXActionExit
"""
# NX_ACTION_HEADER_PACK_STR
# '!HHIH'...type, len, vendor, subtype
type_ = {'buf': b'\xff\xff', 'val': ofproto.OFPAT_VENDOR}
len_ = {'buf': b'\x00\x10', 'val': ofproto.NX_ACTION_HEADER_SIZE}
vendor = {'buf': b'\x00\x00\x23\x20',
'val': ofproto_common.NX_EXPERIMENTER_ID}
subtype = {'buf': b'\x00\x11', 'val': ofproto.NXAST_EXIT}
zfill = b'\x00' * 6
buf = type_['buf'] \
+ len_['buf'] \
+ vendor['buf'] \
+ subtype['buf'] \
+ zfill
c = NXActionExit()
def setUp(self):
pass
def tearDown(self):
pass
def test_init(self):
eq_(self.subtype['val'], self.c.subtype)
def test_parser(self):
res = OFPActionVendor.parser(self.buf, 0)
eq_(self.type_['val'], res.type)
eq_(self.len_['val'], res.len)
eq_(self.subtype['val'], res.subtype)
def test_serialize(self):
buf = bytearray()
self.c.serialize(buf, 0)
fmt = ofproto.NX_ACTION_HEADER_PACK_STR
res = struct.unpack(fmt, six.binary_type(buf))
eq_(self.type_['val'], res[0])
eq_(self.len_['val'], res[1])
eq_(self.vendor['val'], res[2])
eq_(self.subtype['val'], res[3])
class TestOFPDescStats(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.OFPDescStats
"""
# OFP_DESC_STATS_PACK_STR
# '!256s256s256s32s256s'...mfr_desc, hw_desc, sw_desc, serial_num, dp_desc
mfr_desc = b'mfr_desc'.ljust(256)
hw_desc = b'hw_desc'.ljust(256)
sw_desc = b'sw_desc'.ljust(256)
serial_num = b'serial_num'.ljust(32)
dp_desc = b'dp_desc'.ljust(256)
buf = mfr_desc \
+ hw_desc \
+ sw_desc \
+ serial_num \
+ dp_desc
c = OFPDescStats(mfr_desc, hw_desc, sw_desc, serial_num, dp_desc)
def setUp(self):
pass
def tearDown(self):
pass
def test_init(self):
eq_(self.mfr_desc, self.c.mfr_desc)
eq_(self.hw_desc, self.c.hw_desc)
eq_(self.sw_desc, self.c.sw_desc)
eq_(self.serial_num, self.c.serial_num)
eq_(self.dp_desc, self.c.dp_desc)
def test_parser(self):
res = self.c.parser(self.buf, 0)
eq_(self.mfr_desc, self.mfr_desc)
eq_(self.hw_desc, self.hw_desc)
eq_(self.sw_desc, self.sw_desc)
eq_(self.serial_num, self.serial_num)
eq_(self.dp_desc, self.dp_desc)
class TestOFPFlowStats(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.OFPFlowStats
"""
# OFP_FLOW_STATS_0_PACK_STR
# '!HBx'...length, table_id, zfill
length = {'buf': b'\x00\x58', 'val': 88}
length_append_action = {'buf': b'\x00\x60', 'val': 96}
table_id = {'buf': b'\x51', 'val': 81}
zfill_0 = b'\x00'
# OFP_MATCH_PACK_STR
# '!IH6s6sHBxHBB2xIIHH'...
match = b'\x97\x7c\xa6\x1e' \
+ b'\x5e\xa0' \
+ b'\x7a\x3e\xed\x30\x4a\x90' \
+ b'\x96\x8e\x67\xbe\x2f\xe2' \
+ b'\xb1\x81' \
+ b'\xbe' \
+ b'\x00' \
+ b'\x01\xab' \
+ b'\x42' \
+ b'\xfe' \
+ b'\x00\x00' \
+ b'\xa4\x5d\x5c\x42' \
+ b'\xa2\x5c\x2e\x05' \
+ b'\x5a\x94' \
+ b'\x64\xd4'
# OFP_FLOW_STATS_1_PACK_STR
# '!IIHHH6xQQQ'...duration_sec, duration_nsec, priority,
# idle_timeout, hard_timeout, zfill,
# cookie, packet_count, byte_count
duration_sec = {'buf': b'\x94\x19\xb3\xd2', 'val': 2484712402}
duration_nsec = {'buf': b'\xee\x66\xcf\x7c', 'val': 3999715196}
priority = {'buf': b'\xe1\xc0', 'val': 57792}
idle_timeout = {'buf': b'\x8e\x10', 'val': 36368}
hard_timeout = {'buf': b'\xd4\x99', 'val': 54425}
zfill_1 = b'\x00\x00\x00\x00\x00\x00'
cookie = {'buf': b'\x0b\x01\xe8\xe5\xf0\x84\x8a\xe0',
'val': 793171083674290912}
packet_count = {'buf': b'\x47\x5c\xc6\x05\x28\xff\x7c\xdb',
'val': 5142202600015232219}
byte_count = {'buf': b'\x24\xe9\x4b\xee\xcb\x57\xd9\xc3',
'val': 2659740543924820419}
# <action>_PACK_STR...type_, len_ [others...]
type = {'buf': b'\x00\x00', 'val': ofproto.OFPAT_OUTPUT}
len = {'buf': b'\x00\x08', 'val': ofproto.OFP_ACTION_OUTPUT_SIZE}
port = {'buf': b'\x59\x2a', 'val': 22826}
max_len = {'buf': b'\x00\x08', 'val': ofproto.OFP_ACTION_OUTPUT_SIZE}
action = (type, len, port, max_len)
ACTION_TYPE = 0
ACTION_LEN = 1
ACTION_PORT = 2
ACTION_MAX_LEN = 3
c = OFPFlowStats()
def setUp(self):
pass
def tearDown(self):
pass
def test_init(self):
pass
def _parser(self, action=None):
buf = self.table_id['buf'] \
+ self.zfill_0 \
+ self.match \
+ self.duration_sec['buf'] \
+ self.duration_nsec['buf'] \
+ self.priority['buf'] \
+ self.idle_timeout['buf'] \
+ self.hard_timeout['buf'] \
+ self.zfill_1 \
+ self.cookie['buf'] \
+ self.packet_count['buf'] \
+ self.byte_count['buf']
if not action:
buf = self.length['buf'] + buf
else:
buf = self.length_append_action['buf'] + buf
for a in self.action:
buf = buf + a['buf']
return self.c.parser(buf, 0)
def test_parser(self):
res = self._parser()
eq_(self.length['val'], res.length)
eq_(self.table_id['val'], res.table_id)
eq_(self.duration_sec['val'], res.duration_sec)
eq_(self.duration_nsec['val'], res.duration_nsec)
eq_(self.priority['val'], res.priority)
eq_(self.idle_timeout['val'], res.idle_timeout)
eq_(self.hard_timeout['val'], res.hard_timeout)
eq_(self.cookie['val'], res.cookie)
eq_(self.packet_count['val'], res.packet_count)
eq_(self.byte_count['val'], res.byte_count)
def test_parser_append_actions(self):
res = self._parser(True).actions[0]
eq_(self.action[self.ACTION_TYPE]['val'], res.type)
eq_(self.action[self.ACTION_LEN]['val'], res.len)
eq_(self.action[self.ACTION_PORT]['val'], res.port)
eq_(self.action[self.ACTION_MAX_LEN]['val'], res.max_len)
class TestOFPAggregateStats(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.OFPAggregateStats
"""
# OFP_AGGREGATE_STATS_REPLY_PACK_STR
# '!QQI4x'...packet_count, byte_count, flow_count, zfill
packet_count = {'buf': b'\x43\x95\x1b\xfb\x0f\xf6\xa7\xdd',
'val': 4869829337189623773}
byte_count = {'buf': b'\x36\xda\x2d\x80\x2a\x95\x35\xdd',
'val': 3952521651464517085}
flow_count = {'buf': b'\xc3\x0d\xc3\xed', 'val': 3272459245}
zfill = b'\x00' * 4
buf = packet_count['buf'] \
+ byte_count['buf'] \
+ flow_count['buf'] \
+ zfill
c = OFPAggregateStats(packet_count['val'],
byte_count['val'],
flow_count['val'])
def setUp(self):
pass
def tearDown(self):
pass
def test_init(self):
eq_(self.packet_count['val'], self.c.packet_count)
eq_(self.byte_count['val'], self.c.byte_count)
eq_(self.flow_count['val'], self.c.flow_count)
def test_parser(self):
res = self.c.parser(self.buf, 0)
eq_(self.packet_count['val'], res.packet_count)
eq_(self.byte_count['val'], res.byte_count)
eq_(self.flow_count['val'], res.flow_count)
class TestOFPTableStats(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.OFPTableStats
"""
# OFP_TABLE_STATS_PACK_STR
# '!B3x32sIIIQQ'...table_id, zfill, name, wildcards, max_entries,
# active_count, lookup_count, matched_count
table_id = {'buf': b'\x5b', 'val': 91}
zfill = b'\x00' * 3
name = b'name'.ljust(32)
wildcards = {'buf': b'\xc5\xaf\x6e\x12', 'val': 3316608530}
max_entries = {'buf': b'\x95\x6c\x78\x4d', 'val': 2506913869}
active_count = {'buf': b'\x78\xac\xa8\x1e', 'val': 2024581150}
lookup_count = {'buf': b'\x40\x1d\x9c\x39\x19\xec\xd4\x1c',
'val': 4620020561814017052}
matched_count = {'buf': b'\x27\x35\x02\xb6\xc5\x5e\x17\x65',
'val': 2825167325263435621}
buf = table_id['buf'] \
+ zfill \
+ name \
+ wildcards['buf'] \
+ max_entries['buf'] \
+ active_count['buf'] \
+ lookup_count['buf'] \
+ matched_count['buf']
c = OFPTableStats(table_id['val'],
name,
wildcards['val'],
max_entries['val'],
active_count['val'],
lookup_count['val'],
matched_count['val'])
def setUp(self):
pass
def tearDown(self):
pass
def test_init(self):
eq_(self.table_id['val'], self.c.table_id)
eq_(self.name, self.c.name)
eq_(self.wildcards['val'], self.c.wildcards)
eq_(self.max_entries['val'], self.c.max_entries)
eq_(self.active_count['val'], self.c.active_count)
eq_(self.lookup_count['val'], self.c.lookup_count)
eq_(self.matched_count['val'], self.c.matched_count)
def test_parser(self):
res = self.c.parser(self.buf, 0)
eq_(self.table_id['val'], res.table_id)
eq_(self.name, res.name)
eq_(self.wildcards['val'], res.wildcards)
eq_(self.max_entries['val'], res.max_entries)
eq_(self.active_count['val'], res.active_count)
eq_(self.lookup_count['val'], res.lookup_count)
eq_(self.matched_count['val'], res.matched_count)
class TestOFPPortStats(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.OFPPortStats
"""
# OFP_PORT_STATS_PACK_STR
# '!H6xQQQQQQQQQQQQ'... port_no, zfill, rx_packets, tx_packets,
# rx_bytes, tx_bytes, rx_dropped, tx_dropped,
# rx_errors, tx_errors, rx_frame_err,
# rx_over_err, rx_crc_err, collisions
port_no = {'buf': b'\xe7\x6b', 'val': 59243}
zfill = b'\x00' * 6
rx_packets = {'buf': b'\x53\x44\x36\x61\xc4\x86\xc0\x37',
'val': 5999980397101236279}
tx_packets = {'buf': b'\x27\xa4\x41\xd7\xd4\x53\x9e\x42',
'val': 2856480458895760962}
rx_bytes = {'buf': b'\x55\xa1\x38\x60\x43\x97\x0d\x89',
'val': 6170274950576278921}
tx_bytes = {'buf': b'\x77\xe1\xd5\x63\x18\xae\x63\xaa',
'val': 8638420181865882538}
rx_dropped = {'buf': b'\x60\xe6\x20\x01\x24\xda\x4e\x5a',
'val': 6982303461569875546}
tx_dropped = {'buf': b'\x09\x2d\x5d\x71\x71\xb6\x8e\xc7',
'val': 661287462113808071}
rx_errors = {'buf': b'\x2f\x7e\x35\xb3\x66\x3c\x19\x0d',
'val': 3422231811478788365}
tx_errors = {'buf': b'\x57\x32\x08\x2f\x88\x32\x40\x6b',
'val': 6283093430376743019}
rx_frame_err = {'buf': b'\x0c\x28\x6f\xad\xce\x66\x6e\x8b',
'val': 876072919806406283}
rx_over_err = {'buf': b'\x5a\x90\x8f\x9b\xfc\x82\x2e\xa0',
'val': 6525873760178941600}
rx_crc_err = {'buf': b'\x73\x3a\x71\x17\xd6\x74\x69\x47',
'val': 8303073210207070535}
collisions = {'buf': b'\x2f\x52\x0c\x79\x96\x03\x6e\x79',
'val': 3409801584220270201}
buf = port_no['buf'] \
+ zfill \
+ rx_packets['buf'] \
+ tx_packets['buf'] \
+ rx_bytes['buf'] \
+ tx_bytes['buf'] \
+ rx_dropped['buf'] \
+ tx_dropped['buf'] \
+ rx_errors['buf'] \
+ tx_errors['buf'] \
+ rx_frame_err['buf'] \
+ rx_over_err['buf'] \
+ rx_crc_err['buf'] \
+ collisions['buf']
c = OFPPortStats(port_no['val'],
rx_packets['val'],
tx_packets['val'],
rx_bytes['val'],
tx_bytes['val'],
rx_dropped['val'],
tx_dropped['val'],
rx_errors['val'],
tx_errors['val'],
rx_frame_err['val'],
rx_over_err['val'],
rx_crc_err['val'],
collisions['val'])
def setUp(self):
pass
def tearDown(self):
pass
def test_init(self):
eq_(self.port_no['val'], self.c.port_no)
eq_(self.rx_packets['val'], self.c.rx_packets)
eq_(self.tx_packets['val'], self.c.tx_packets)
eq_(self.rx_bytes['val'], self.c.rx_bytes)
eq_(self.tx_bytes['val'], self.c.tx_bytes)
eq_(self.rx_dropped['val'], self.c.rx_dropped)
eq_(self.tx_dropped['val'], self.c.tx_dropped)
eq_(self.rx_errors['val'], self.c.rx_errors)
eq_(self.tx_errors['val'], self.c.tx_errors)
eq_(self.rx_frame_err['val'], self.c.rx_frame_err)
eq_(self.rx_over_err['val'], self.c.rx_over_err)
eq_(self.rx_crc_err['val'], self.c.rx_crc_err)
eq_(self.collisions['val'], self.c.collisions)
def test_parser(self):
res = self.c.parser(self.buf, 0)
eq_(self.port_no['val'], res.port_no)
eq_(self.rx_packets['val'], res.rx_packets)
eq_(self.tx_packets['val'], res.tx_packets)
eq_(self.rx_bytes['val'], res.rx_bytes)
eq_(self.tx_bytes['val'], res.tx_bytes)
eq_(self.rx_dropped['val'], res.rx_dropped)
eq_(self.tx_dropped['val'], res.tx_dropped)
eq_(self.rx_errors['val'], res.rx_errors)
eq_(self.tx_errors['val'], res.tx_errors)
eq_(self.rx_frame_err['val'], res.rx_frame_err)
eq_(self.rx_over_err['val'], res.rx_over_err)
eq_(self.rx_crc_err['val'], res.rx_crc_err)
eq_(self.collisions['val'], res.collisions)
class TestOFPQueueStats(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.OFPQueueStats
"""
# OFP_QUEUE_STATS_PACK_STR
# '!H2xIQQQ...port_no, queue_id, tx_bytes, tx_packets, tx_errors
port_no = {'buf': b'\xe7\x6b', 'val': 59243}
zfill = b'\x00' * 2
queue_id = {'buf': b'\x2a\xa8\x7f\x32', 'val': 715685682}
tx_bytes = {'buf': b'\x77\xe1\xd5\x63\x18\xae\x63\xaa',
'val': 8638420181865882538}
tx_packets = {'buf': b'\x27\xa4\x41\xd7\xd4\x53\x9e\x42',
'val': 2856480458895760962}
tx_errors = {'buf': b'\x57\x32\x08\x2f\x88\x32\x40\x6b',
'val': 6283093430376743019}
c = OFPQueueStats(port_no['val'],
queue_id['val'],
tx_bytes['val'],
tx_packets['val'],
tx_errors['val'])
buf = port_no['buf'] \
+ zfill \
+ queue_id['buf'] \
+ tx_bytes['buf'] \
+ tx_packets['buf'] \
+ tx_errors['buf']
def setUp(self):
pass
def tearDown(self):
pass
def test_init(self):
eq_(self.port_no['val'], self.c.port_no)
eq_(self.queue_id['val'], self.c.queue_id)
eq_(self.tx_bytes['val'], self.c.tx_bytes)
eq_(self.tx_packets['val'], self.c.tx_packets)
eq_(self.tx_errors['val'], self.c.tx_errors)
def test_parser(self):
res = self.c.parser(self.buf, 0)
eq_(self.port_no['val'], res.port_no)
eq_(self.queue_id['val'], res.queue_id)
eq_(self.tx_bytes['val'], res.tx_bytes)
eq_(self.tx_packets['val'], res.tx_packets)
eq_(self.tx_errors['val'], res.tx_errors)
class TestOFPVendorStats(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.OFPVendorStats
"""
specific_data = 'specific_data'
specific_data_after = 'data'
offset = specific_data.find(specific_data_after)
c = OFPVendorStats(specific_data)
def setUp(self):
pass
def tearDown(self):
pass
def test_init(self):
eq_(self.specific_data, self.c.specific_data)
def test_parser(self):
res = self.c.parser(self.specific_data, self.offset)
eq_(self.specific_data_after, res.specific_data)
class TestOFPQueuePropNone(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.OFPQueuePropNone
"""
# OFP_QUEUE_PROP_HEADER_PACK_STR
# '!HH4x'...property_, len_
property = {'buf': b'\x00\x00', 'val': ofproto.OFPQT_NONE}
len = {'buf': b'\x00\x08', 'val': ofproto.OFP_QUEUE_PROP_HEADER_SIZE}
zfill = b'\x00' * 4
c = OFPQueuePropNone()
def setUp(self):
pass
def tearDown(self):
pass
def test_init(self):
cls = OFPQueuePropHeader._QUEUE_PROPERTIES[self.c.cls_prop_type]
eq_(self.property['val'], self.c.cls_prop_type)
eq_(self.property['val'], self.c.property)
eq_(self.property['val'], cls.cls_prop_type)
eq_(self.len['val'], self.c.cls_prop_len)
eq_(self.len['val'], self.c.len)
eq_(self.len['val'], cls.cls_prop_len)
def test_parser(self):
buf = self.property['buf'] \
+ self.len['buf'] \
+ self.zfill
ok_(self.c.parser(buf, 0))
class TestOFPQueuePropMinRate(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.OFPQueuePropMinRate
"""
# OFP_QUEUE_PROP_MIN_RATE_PACK_STR
# '!H6x'...rate
rate = {'buf': b'\x00\x01', 'val': ofproto.OFPQT_MIN_RATE}
len = {'buf': b'\x00\x10', 'val': ofproto.OFP_QUEUE_PROP_MIN_RATE_SIZE}
zfill = b'\x00' * 6
buf = rate['buf'] \
+ zfill
c = OFPQueuePropMinRate(rate['val'])
def setUp(self):
pass
def tearDown(self):
pass
def test_init(self):
cls = OFPQueuePropHeader._QUEUE_PROPERTIES[self.c.cls_prop_type]
eq_(self.rate['val'], self.c.cls_prop_type)
eq_(self.rate['val'], self.c.rate)
eq_(self.rate['val'], cls.cls_prop_type)
eq_(self.len['val'], self.c.cls_prop_len)
eq_(self.len['val'], cls.cls_prop_len)
def test_parser(self):
res = self.c.parser(self.buf, 0)
eq_(self.rate['val'], res.rate)
class TestOFPPacketQueue(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.OFPPacketQueue
"""
# OFP_PACKET_QUEUE_PQCK_STR
# '!IH2x'...queue_id, len_, zfill
queue_id = {'buf': b'\x4d\x4b\x3a\xd1', 'val': 1296775889}
len_ = {'buf': b'\x00\x08',
'val': ofproto.OFP_QUEUE_PROP_HEADER_SIZE}
zfill = b'\x00' * 2
buf = queue_id['buf'] \
+ len_['buf'] \
+ zfill
c = OFPPacketQueue(queue_id['val'],
len_['val'])
def setUp(self):
pass
def tearDown(self):
pass
def test_init(self):
eq_(self.queue_id['val'], self.c.queue_id)
eq_(self.len_['val'], self.c.len)
def test_parser(self):
res = self.c.parser(self.buf, 0)
eq_(self.queue_id['val'], res.queue_id)
eq_(self.len_['val'], res.len)
def test_parser_append_prop(self):
# OFP_QUEUE_PROP_HEADER_PACK_STR + OFP_QUEUE_PROP_MIN_RATE_PACK_STR
# '!HH4xH6x'...type, len, zfill, rate, zfill
len_ = {'buf': b'\x00\x10',
'val': ofproto.OFP_QUEUE_PROP_MIN_RATE_SIZE}
a_type = {'buf': b'\x00\x01', 'val': ofproto.OFPQT_MIN_RATE}
a_len = {'buf': b'\x00\x10',
'val': ofproto.OFP_QUEUE_PROP_MIN_RATE_SIZE}
a_zfill0 = b'\x00' * 4
a_rate = {'buf': b'\x00\x01', 'val': ofproto.OFPQT_MIN_RATE}
a_zfill1 = b'\x00' * 6
buf = self.queue_id['buf'] \
+ len_['buf'] \
+ self.zfill \
+ a_type['buf'] \
+ a_len['buf'] \
+ a_zfill0 \
+ a_rate['buf'] \
+ a_zfill1
res = self.c.parser(buf, 0)
eq_(self.queue_id['val'], res.queue_id)
eq_(len_['val'], res.len)
append_cls = res.properties[0]
eq_(a_type['val'], append_cls.property)
eq_(a_len['val'], append_cls.len)
eq_(a_rate['val'], append_cls.rate)
class TestOFPHello(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.OFPHello
"""
def setUp(self):
pass
def tearDown(self):
pass
def test_init(self):
pass
def test_parser(self):
version = ofproto.OFP_VERSION
msg_type = ofproto.OFPT_HELLO
msg_len = ofproto.OFP_HEADER_SIZE
xid = 2183948390
data = b'\x00\x01\x02\x03'
fmt = ofproto.OFP_HEADER_PACK_STR
buf = struct.pack(fmt, version, msg_type, msg_len, xid) \
+ data
res = OFPHello.parser(object, version, msg_type, msg_len, xid,
bytearray(buf))
eq_(version, res.version)
eq_(msg_type, res.msg_type)
eq_(msg_len, res.msg_len)
eq_(xid, res.xid)
eq_(six.binary_type(buf), six.binary_type(res.buf))
def test_serialize(self):
class Datapath(object):
ofproto = ofproto # copy to class attribute
ofproto_parser = ofproto_v1_0_parser
c = OFPHello(Datapath)
c.serialize()
eq_(ofproto.OFP_VERSION, c.version)
eq_(ofproto.OFPT_HELLO, c.msg_type)
eq_(0, c.xid)
class TestOFPErrorMsg(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.OFPErrorMsg
"""
def setUp(self):
pass
def tearDown(self):
pass
def test_init(self):
pass
def test_parser(self):
version = {'buf': b'\x01', 'val': ofproto.OFP_VERSION}
msg_type = {'buf': b'\x01', 'val': ofproto.OFPT_ERROR}
msg_len = {'buf': b'\x00\x0c',
'val': ofproto.OFP_ERROR_MSG_SIZE}
xid = {'buf': b'\x87\x8b\x26\x7c', 'val': 2274043516}
type = {'buf': b'\xab\x3e', 'val': 43838}
code = {'buf': b'\x5d\x3c', 'val': 23868}
data = b'Error Message.'
buf = version['buf'] \
+ msg_type['buf'] \
+ msg_len['buf'] \
+ xid['buf'] \
+ type['buf'] \
+ code['buf'] \
+ data
res = OFPErrorMsg.parser(object,
version['val'],
msg_type['val'],
msg_len['val'],
xid['val'],
buf)
eq_(version['val'], res.version)
eq_(msg_type['val'], res.msg_type)
eq_(msg_len['val'], res.msg_len)
eq_(xid['val'], res.xid)
eq_(type['val'], res.type)
eq_(code['val'], res.code)
eq_(data, res.data)
def test_serialize(self):
class Datapath(object):
ofproto = ofproto # copy to class attribute
ofproto_parser = ofproto_v1_0_parser
type = 1306
code = 13774
data = b'Error Message.'
c = OFPErrorMsg(Datapath)
c.type = type
c.code = code
c.data = data
c.serialize()
eq_(ofproto.OFP_VERSION, c.version)
eq_(ofproto.OFPT_ERROR, c.msg_type)
eq_(0, c.xid)
fmt = '!' \
+ ofproto.OFP_HEADER_PACK_STR.replace('!', '') \
+ ofproto.OFP_ERROR_MSG_PACK_STR.replace('!', '') \
+ str(len(data)) + 's'
res = struct.unpack(fmt, six.binary_type(c.buf))
eq_(ofproto.OFP_VERSION, res[0])
eq_(ofproto.OFPT_ERROR, res[1])
eq_(len(c.buf), res[2])
eq_(0, res[3])
eq_(type, res[4])
eq_(code, res[5])
eq_(data, res[6])
class TestOFPEchoRequest(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.OFPEchoRequest
"""
def setUp(self):
pass
def tearDown(self):
pass
def test_init(self):
pass
def test_parser(self):
version = {'buf': b'\x01', 'val': ofproto.OFP_VERSION}
msg_type = {'buf': b'\x02', 'val': ofproto.OFPT_ECHO_REQUEST}
msg_len = {'buf': b'\x00\x08',
'val': ofproto.OFP_HEADER_SIZE}
xid = {'buf': b'\x84\x47\xef\x3f', 'val': 2219306815}
data = b'Request Message.'
buf = version['buf'] \
+ msg_type['buf'] \
+ msg_len['buf'] \
+ xid['buf'] \
+ data
res = OFPEchoRequest.parser(object,
version['val'],
msg_type['val'],
msg_len['val'],
xid['val'],
buf)
eq_(version['val'], res.version)
eq_(msg_type['val'], res.msg_type)
eq_(msg_len['val'], res.msg_len)
eq_(xid['val'], res.xid)
eq_(data, res.data)
def test_serialize(self):
class Datapath(object):
ofproto = ofproto # copy to class attribute
ofproto_parser = ofproto_v1_0_parser
data = b'Request Message.'
c = OFPEchoRequest(Datapath)
c.data = data
c.serialize()
eq_(ofproto.OFP_VERSION, c.version)
eq_(ofproto.OFPT_ECHO_REQUEST, c.msg_type)
eq_(0, c.xid)
fmt = '!' \
+ ofproto.OFP_HEADER_PACK_STR.replace('!', '') \
+ str(len(data)) + 's'
res = struct.unpack(fmt, six.binary_type(c.buf))
eq_(ofproto.OFP_VERSION, res[0])
eq_(ofproto.OFPT_ECHO_REQUEST, res[1])
eq_(len(c.buf), res[2])
eq_(0, res[3])
eq_(data, res[4])
class TestOFPEchoReply(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.OFPEchoReply
"""
def setUp(self):
pass
def tearDown(self):
pass
def test_init(self):
pass
def test_parser(self):
version = {'buf': b'\x01', 'val': ofproto.OFP_VERSION}
msg_type = {'buf': b'\x03', 'val': ofproto.OFPT_ECHO_REPLY}
msg_len = {'buf': b'\x00\x08',
'val': ofproto.OFP_HEADER_SIZE}
xid = {'buf': b'\x6e\x21\x3e\x62', 'val': 1847672418}
data = b'Reply Message.'
buf = version['buf'] \
+ msg_type['buf'] \
+ msg_len['buf'] \
+ xid['buf'] \
+ data
res = OFPEchoReply.parser(object,
version['val'],
msg_type['val'],
msg_len['val'],
xid['val'],
buf)
eq_(version['val'], res.version)
eq_(msg_type['val'], res.msg_type)
eq_(msg_len['val'], res.msg_len)
eq_(xid['val'], res.xid)
eq_(data, res.data)
def test_serialize(self):
class Datapath(object):
ofproto = ofproto # copy to class attribute
ofproto_parser = ofproto_v1_0_parser
data = b'Reply Message.'
c = OFPEchoReply(Datapath)
c.data = data
c.serialize()
eq_(ofproto.OFP_VERSION, c.version)
eq_(ofproto.OFPT_ECHO_REPLY, c.msg_type)
eq_(0, c.xid)
fmt = '!' \
+ ofproto.OFP_HEADER_PACK_STR.replace('!', '') \
+ str(len(data)) + 's'
res = struct.unpack(fmt, six.binary_type(c.buf))
eq_(ofproto.OFP_VERSION, res[0])
eq_(ofproto.OFPT_ECHO_REPLY, res[1])
eq_(len(c.buf), res[2])
eq_(0, res[3])
eq_(data, res[4])
class TestOFPVendor(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.OFPVendor
"""
def setUp(self):
pass
def tearDown(self):
pass
def test_init(self):
pass
def test_parser(self):
version = {'buf': b'\x01', 'val': ofproto.OFP_VERSION}
msg_type = {'buf': b'\x04', 'val': ofproto.OFPT_VENDOR}
msg_len = {'buf': b'\x00\x0c',
'val': ofproto.OFP_VENDOR_HEADER_SIZE}
xid = {'buf': b'\x05\x45\xdf\x18', 'val': 88465176}
vendor = {'buf': b'\x53\xea\x25\x3e', 'val': 1407853886}
data = b'Vendor Message.'
buf = version['buf'] \
+ msg_type['buf'] \
+ msg_len['buf'] \
+ xid['buf'] \
+ vendor['buf'] \
+ data
res = OFPVendor.parser(object,
version['val'],
msg_type['val'],
msg_len['val'],
xid['val'],
buf)
eq_(version['val'], res.version)
eq_(msg_type['val'], res.msg_type)
eq_(msg_len['val'], res.msg_len)
eq_(xid['val'], res.xid)
eq_(vendor['val'], res.vendor)
eq_(data, res.data)
def test_serialize(self):
class Datapath(object):
ofproto = ofproto # copy to class attribute
ofproto_parser = ofproto_v1_0_parser
vendor = {'buf': b'\x38\x4b\xf9\x6c', 'val': 944503148}
data = b'Reply Message.'
c = OFPVendor(Datapath)
c.vendor = vendor['val']
c.data = data
c.serialize()
eq_(ofproto.OFP_VERSION, c.version)
eq_(ofproto.OFPT_VENDOR, c.msg_type)
eq_(0, c.xid)
eq_(vendor['val'], c.vendor)
fmt = '!' \
+ ofproto.OFP_HEADER_PACK_STR.replace('!', '') \
+ ofproto.OFP_VENDOR_HEADER_PACK_STR.replace('!', '') \
+ str(len(data)) + 's'
res = struct.unpack(fmt, six.binary_type(c.buf))
eq_(ofproto.OFP_VERSION, res[0])
eq_(ofproto.OFPT_VENDOR, res[1])
eq_(len(c.buf), res[2])
eq_(0, res[3])
eq_(vendor['val'], res[4])
eq_(data, res[5])
# class TestNXTRequest(unittest.TestCase):
class TestNiciraHeader(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.NiciraHeader
"""
def setUp(self):
pass
def tearDown(self):
pass
def test_init(self):
subtype = ofproto.NXT_FLOW_MOD_TABLE_ID
c = NiciraHeader(object, subtype)
eq_(subtype, c.subtype)
def test_parser(self):
# Not used.
pass
def test_serialize(self):
class Datapath(object):
ofproto = ofproto # copy to class attribute
ofproto_parser = ofproto_v1_0_parser
data = b'Reply Message.'
subtype = ofproto.NXT_FLOW_MOD_TABLE_ID
c = NiciraHeader(Datapath, subtype)
c.data = data
c.serialize()
eq_(ofproto.OFP_VERSION, c.version)
eq_(ofproto.OFPT_VENDOR, c.msg_type)
eq_(0, c.xid)
eq_(ofproto_common.NX_EXPERIMENTER_ID, c.vendor)
fmt = '!' \
+ ofproto.OFP_HEADER_PACK_STR.replace('!', '') \
+ ofproto.NICIRA_HEADER_PACK_STR.replace('!', '') \
+ str(len(data)) + 's'
res = struct.unpack(fmt, six.binary_type(c.buf))
eq_(ofproto.OFP_VERSION, res[0])
eq_(ofproto.OFPT_VENDOR, res[1])
eq_(len(c.buf), res[2])
eq_(0, res[3])
eq_(ofproto_common.NX_EXPERIMENTER_ID, res[4])
eq_(subtype, res[5])
eq_(data, res[6])
class TestNXTSetFlowFormat(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.NXTSetFlowFormat
"""
def setUp(self):
pass
def tearDown(self):
pass
def test_init(self):
flow_format = {'buf': b'\xdc\x6b\xf5\x24', 'val': 3698062628}
c = NXTSetFlowFormat(object, flow_format['val'])
eq_(flow_format['val'], c.format)
def test_parser(self):
# Not used.
pass
def test_serialize(self):
class Datapath(object):
ofproto = ofproto # copy to class attribute
ofproto_parser = ofproto_v1_0_parser
flow_format = {'buf': b'\x5a\x4e\x59\xad', 'val': 1515084205}
c = NXTSetFlowFormat(Datapath, flow_format['val'])
c.serialize()
eq_(ofproto.OFP_VERSION, c.version)
eq_(ofproto.OFPT_VENDOR, c.msg_type)
eq_(0, c.xid)
eq_(ofproto_common.NX_EXPERIMENTER_ID, c.vendor)
fmt = '!' \
+ ofproto.OFP_HEADER_PACK_STR.replace('!', '') \
+ ofproto.NICIRA_HEADER_PACK_STR.replace('!', '') \
+ ofproto.NX_SET_FLOW_FORMAT_PACK_STR.replace('!', '')
res = struct.unpack(fmt, six.binary_type(c.buf))
eq_(ofproto.OFP_VERSION, res[0])
eq_(ofproto.OFPT_VENDOR, res[1])
eq_(len(c.buf), res[2])
eq_(0, res[3])
eq_(ofproto_common.NX_EXPERIMENTER_ID, res[4])
eq_(ofproto.NXT_SET_FLOW_FORMAT, res[5])
eq_(flow_format['val'], res[6])
class TestNXTFlowMod(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.NXTFlowMod
"""
# NX_FLOW_MOD_PACK_STR
# '!Q4HI3H6x'...cokkie, command, idle_timeout, head_timeout,
# priority, buffer_id, out_port, flags, rule, zfill
cookie = {'buf': b'\x04\x56\x27\xad\xbd\x43\xd6\x83',
'val': 312480851306993283}
command = {'buf': b'\x61\xaa', 'val': 25002}
idle_timeout = {'buf': b'\x4e\xff', 'val': 20223}
hard_timeout = {'buf': b'\x80\x16', 'val': 32790}
priority = {'buf': b'\x70\x5f', 'val': 28767}
buffer_id = {'buf': b'\x7b\x97\x3a\x09', 'val': 2073508361}
out_port = {'buf': b'\x11\x7d', 'val': 4477}
flags = {'buf': b'\x5c\xb9', 'val': 23737}
rule = nx_match.ClsRule()
zfill = b'\x00' * 6
port = {'buf': b'\x2a\xe0', 'val': 10976}
actions = [OFPActionOutput(port['val'])]
def _get_obj(self, append_action=False):
class Datapath(object):
ofproto = ofproto # copy to class attribute
ofproto_parser = ofproto_v1_0_parser
actions = None
if append_action:
actions = self.actions
c = NXTFlowMod(Datapath,
self.cookie['val'],
self.command['val'],
self.idle_timeout['val'],
self.hard_timeout['val'],
self.priority['val'],
self.buffer_id['val'],
self.out_port['val'],
self.flags['val'],
self.rule,
actions)
return c
def setUp(self):
pass
def tearDown(self):
pass
def test_init(self):
c = self._get_obj()
eq_(self.cookie['val'], c.cookie)
eq_(self.command['val'], c.command)
eq_(self.idle_timeout['val'], c.idle_timeout)
eq_(self.hard_timeout['val'], c.hard_timeout)
eq_(self.priority['val'], c.priority)
eq_(self.buffer_id['val'], c.buffer_id)
eq_(self.out_port['val'], c.out_port)
eq_(self.flags['val'], c.flags)
eq_(self.rule.__hash__(), c.rule.__hash__())
def test_init_append_actions(self):
c = self._get_obj(True)
action = c.actions[0]
eq_(ofproto.OFPAT_OUTPUT, action.type)
eq_(ofproto.OFP_ACTION_OUTPUT_SIZE, action.len)
eq_(self.port['val'], action.port)
def test_parser(self):
# Not used.
pass
def test_serialize(self):
c = self._get_obj()
c.serialize()
eq_(ofproto.OFP_VERSION, c.version)
eq_(ofproto.OFPT_VENDOR, c.msg_type)
eq_(0, c.xid)
eq_(ofproto_common.NX_EXPERIMENTER_ID, c.vendor)
fmt = '!' \
+ ofproto.OFP_HEADER_PACK_STR.replace('!', '') \
+ ofproto.NICIRA_HEADER_PACK_STR.replace('!', '') \
+ ofproto.NX_FLOW_MOD_PACK_STR.replace('!', '')
res = struct.unpack(fmt, six.binary_type(c.buf))
eq_(ofproto.OFP_VERSION, res[0])
eq_(ofproto.OFPT_VENDOR, res[1])
eq_(len(c.buf), res[2])
eq_(0, res[3])
eq_(ofproto_common.NX_EXPERIMENTER_ID, res[4])
eq_(ofproto.NXT_FLOW_MOD, res[5])
eq_(self.cookie['val'], res[6])
eq_(self.command['val'], res[7])
eq_(self.idle_timeout['val'], res[8])
eq_(self.hard_timeout['val'], res[9])
eq_(self.priority['val'], res[10])
eq_(self.buffer_id['val'], res[11])
eq_(self.out_port['val'], res[12])
eq_(self.flags['val'], res[13])
def test_serialize_append_actions(self):
c = self._get_obj(True)
c.serialize()
eq_(ofproto.OFP_VERSION, c.version)
eq_(ofproto.OFPT_VENDOR, c.msg_type)
eq_(0, c.xid)
eq_(ofproto_common.NX_EXPERIMENTER_ID, c.vendor)
fmt = '!' \
+ ofproto.OFP_HEADER_PACK_STR.replace('!', '') \
+ ofproto.NICIRA_HEADER_PACK_STR.replace('!', '') \
+ ofproto.NX_FLOW_MOD_PACK_STR.replace('!', '') \
+ ofproto.OFP_ACTION_OUTPUT_PACK_STR.replace('!', '')
res = struct.unpack(fmt, six.binary_type(c.buf))
eq_(ofproto.OFP_VERSION, res[0])
eq_(ofproto.OFPT_VENDOR, res[1])
eq_(len(c.buf), res[2])
eq_(0, res[3])
eq_(ofproto_common.NX_EXPERIMENTER_ID, res[4])
eq_(ofproto.NXT_FLOW_MOD, res[5])
eq_(self.cookie['val'], res[6])
eq_(self.command['val'], res[7])
eq_(self.idle_timeout['val'], res[8])
eq_(self.hard_timeout['val'], res[9])
eq_(self.priority['val'], res[10])
eq_(self.buffer_id['val'], res[11])
eq_(self.out_port['val'], res[12])
eq_(self.flags['val'], res[13])
# action
eq_(0, res[14])
eq_(ofproto.OFPAT_OUTPUT, res[15])
eq_(ofproto.OFP_ACTION_OUTPUT_SIZE, res[16])
eq_(self.port['val'], res[17])
eq_(0xffe5, res[18])
class TestNXTRoleRequest(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.NXTRoleRequest
"""
# NX_ROLE_PACK_STR
# '!I'...role
role = {'buf': b'\x62\x81\x27\x61', 'val': 1652631393}
class Datapath(object):
ofproto = ofproto # copy to class attribute
ofproto_parser = ofproto_v1_0_parser
c = NXTRoleRequest(Datapath, role['val'])
def setUp(self):
pass
def tearDown(self):
pass
def test_init(self):
eq_(self.role['val'], self.c.role)
def test_parser(self):
# Not used.
pass
def test_serialize(self):
self.c.serialize()
eq_(ofproto.OFP_VERSION, self.c.version)
eq_(ofproto.OFPT_VENDOR, self.c.msg_type)
eq_(0, self.c.xid)
eq_(ofproto_common.NX_EXPERIMENTER_ID, self.c.vendor)
fmt = '!' \
+ ofproto.OFP_HEADER_PACK_STR.replace('!', '') \
+ ofproto.NICIRA_HEADER_PACK_STR.replace('!', '') \
+ ofproto.NX_ROLE_PACK_STR.replace('!', '')
res = struct.unpack(fmt, six.binary_type(self.c.buf))
eq_(ofproto.OFP_VERSION, res[0])
eq_(ofproto.OFPT_VENDOR, res[1])
eq_(len(self.c.buf), res[2])
eq_(0, res[3])
eq_(ofproto_common.NX_EXPERIMENTER_ID, res[4])
eq_(ofproto.NXT_ROLE_REQUEST, res[5])
eq_(self.role['val'], res[6])
class TestNXTFlowModTableId(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.NXTFlowModTableId
"""
# NX_FLOW_MOD_TABLE_ID_PACK_STR
# '!B7x'...set_, zfill
set_ = {'buf': b'\x71', 'val': 113}
zfill = b'\x00' * 7
class Datapath(object):
ofproto = ofproto # copy to class attribute
ofproto_parser = ofproto_v1_0_parser
c = NXTFlowModTableId(Datapath, set_['val'])
def setUp(self):
pass
def tearDown(self):
pass
def test_init(self):
eq_(self.set_['val'], self.c.set)
def test_parser(self):
# Not used.
pass
def test_serialize(self):
self.c.serialize()
eq_(ofproto.OFP_VERSION, self.c.version)
eq_(ofproto.OFPT_VENDOR, self.c.msg_type)
eq_(0, self.c.xid)
eq_(ofproto_common.NX_EXPERIMENTER_ID, self.c.vendor)
fmt = '!' \
+ ofproto.OFP_HEADER_PACK_STR.replace('!', '') \
+ ofproto.NICIRA_HEADER_PACK_STR.replace('!', '') \
+ ofproto.NX_FLOW_MOD_TABLE_ID_PACK_STR.replace('!', '')
res = struct.unpack(fmt, six.binary_type(self.c.buf))
eq_(ofproto.OFP_VERSION, res[0])
eq_(ofproto.OFPT_VENDOR, res[1])
eq_(len(self.c.buf), res[2])
eq_(0, res[3])
eq_(ofproto_common.NX_EXPERIMENTER_ID, res[4])
eq_(ofproto.NXT_FLOW_MOD_TABLE_ID, res[5])
eq_(self.set_['val'], res[6])
class TestOFPSwitchFeatures(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.OFPSwitchFeatures
"""
class Datapath(object):
ofproto = ofproto # copy to class attribute
ofproto_parser = ofproto_v1_0_parser
c = OFPSwitchFeatures(Datapath)
def setUp(self):
pass
def tearDown(self):
pass
def test_init(self):
pass
def test_parser(self):
version = {'buf': b'\x01', 'val': ofproto.OFP_VERSION}
msg_type = {'buf': b'\x06', 'val': ofproto.OFPT_FEATURES_REPLY}
msg_len_val = ofproto.OFP_SWITCH_FEATURES_SIZE \
+ ofproto.OFP_PHY_PORT_SIZE
msg_len = {'buf': b'\x00\x4c', 'val': msg_len_val}
xid = {'buf': b'\xcc\x0a\x41\xd4', 'val': 3423224276}
# OFP_SWITCH_FEATURES_PACK_STR
# '!QIB3xII'...datapath_id, n_buffers, n_tables,
# zfill, capabilities, actions
datapath_id = {'buf': b'\x11\xa3\x72\x63\x61\xde\x39\x81',
'val': 1270985291017894273}
n_buffers = {'buf': b'\x80\x14\xd7\xf6', 'val': 2148849654}
n_tables = {'buf': b'\xe4', 'val': 228}
zfill = b'\x00' * 3
capabilities = {'buf': b'\x69\x4f\xe4\xc2', 'val': 1766843586}
actions = {'buf': b'\x78\x06\xd9\x0c', 'val': 2013714700}
# OFP_PHY_PORT_PACK_STR
# '!H6s16sIIIIII'... port_no, hw_addr, name, config, state
# curr, advertised, supported, peer
port_no = {'buf': b'\xe7\x6b', 'val': 59243}
hw_addr = '3c:d1:2b:8d:3f:d6'
name = b'name'.ljust(16)
config = {'buf': b'\x84\xb6\x8c\x53', 'val': 2226555987}
state = {'buf': b'\x64\x07\xfb\xc9', 'val': 1678244809}
curr = {'buf': b'\xa9\xe8\x0a\x2b', 'val': 2850556459}
advertised = {'buf': b'\x78\xb9\x7b\x72', 'val': 2025421682}
supported = {'buf': b'\x7e\x65\x68\xad', 'val': 2120575149}
peer = {'buf': b'\xa4\x5b\x8b\xed', 'val': 2757463021}
buf = version['buf'] \
+ msg_type['buf'] \
+ msg_len['buf'] \
+ xid['buf'] \
+ datapath_id['buf'] \
+ n_buffers['buf'] \
+ n_tables['buf'] \
+ zfill \
+ capabilities['buf'] \
+ actions['buf'] \
+ port_no['buf'] \
+ addrconv.mac.text_to_bin(hw_addr) \
+ name \
+ config['buf'] \
+ state['buf'] \
+ curr['buf'] \
+ advertised['buf'] \
+ supported['buf'] \
+ peer['buf']
res = OFPSwitchFeatures.parser(object,
version['val'],
msg_type['val'],
msg_len['val'],
xid['val'],
buf)
eq_(version['val'], res.version)
eq_(msg_type['val'], res.msg_type)
eq_(msg_len['val'], res.msg_len)
eq_(xid['val'], res.xid)
eq_(datapath_id['val'], res.datapath_id)
eq_(n_buffers['val'], res.n_buffers)
eq_(n_tables['val'], res.n_tables)
eq_(capabilities['val'], res.capabilities)
eq_(actions['val'], res.actions)
# port
port = res.ports[port_no['val']]
eq_(port_no['val'], port.port_no)
eq_(hw_addr, hw_addr)
eq_(name, port.name)
eq_(config['val'], port.config)
eq_(state['val'], port.state)
eq_(curr['val'], port.curr)
eq_(advertised['val'], port.advertised)
eq_(supported['val'], port.supported)
eq_(peer['val'], port.peer)
def test_serialize(self):
# Not used.
pass
class TestOFPPortStatus(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.OFPPortStatus
"""
class Datapath(object):
ofproto = ofproto # copy to class attribute
ofproto_parser = ofproto_v1_0_parser
c = OFPPortStatus(Datapath)
def setUp(self):
pass
def tearDown(self):
pass
def test_init(self):
pass
def test_parser(self):
version = {'buf': b'\x01', 'val': ofproto.OFP_VERSION}
msg_type = {'buf': b'\x0c', 'val': ofproto.OFPT_PORT_STATUS}
msg_len = {'buf': b'\x00\x40',
'val': ofproto.OFP_PORT_STATUS_SIZE}
xid = {'buf': b'\x06\x27\x8b\x7b', 'val': 103254907}
# OFP_PORT_STATUS_PACK_STR
# '!B7xH6s16sIIIIII'...reason, zfill, port_no, hw_addr,
# name, config, state, curr,
# advertised, supported, peer
reason = {'buf': b'\x71', 'val': 113}
zfill = b'\x00' * 7
port_no = {'buf': b'\x48\xd8', 'val': 18648}
hw_addr = '41:f7:a3:52:8f:6b'
name = b'name'.ljust(16)
config = {'buf': b'\xae\x73\x90\xec', 'val': 2926809324}
state = {'buf': b'\x41\x37\x32\x1d', 'val': 1094136349}
curr = {'buf': b'\xa9\x47\x13\x2c', 'val': 2840007468}
advertised = {'buf': b'\xce\x6b\x4a\x87', 'val': 3463137927}
supported = {'buf': b'\xb8\x06\x65\xa1', 'val': 3087426977}
peer = {'buf': b'\x6a\x11\x52\x39', 'val': 1779520057}
buf = version['buf'] \
+ msg_type['buf'] \
+ msg_len['buf'] \
+ xid['buf'] \
+ reason['buf'] \
+ zfill \
+ port_no['buf'] \
+ addrconv.mac.text_to_bin(hw_addr) \
+ name \
+ config['buf'] \
+ state['buf'] \
+ curr['buf'] \
+ advertised['buf'] \
+ supported['buf'] \
+ peer['buf']
res = OFPPortStatus.parser(object,
version['val'],
msg_type['val'],
msg_len['val'],
xid['val'],
buf)
eq_(version['val'], res.version)
eq_(msg_type['val'], res.msg_type)
eq_(msg_len['val'], res.msg_len)
eq_(xid['val'], res.xid)
eq_(reason['val'], res.reason)
# desc
desc = res.desc
eq_(port_no['val'], desc.port_no)
eq_(hw_addr, desc.hw_addr)
eq_(name, desc.name)
eq_(config['val'], desc.config)
eq_(state['val'], desc.state)
eq_(curr['val'], desc.curr)
eq_(advertised['val'], desc.advertised)
eq_(supported['val'], desc.supported)
eq_(peer['val'], desc.peer)
def test_serialize(self):
# Not used.
pass
class TestOFPPacketIn(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.OFPPacketIn
"""
class Datapath(object):
ofproto = ofproto # copy to class attribute
ofproto_parser = ofproto_v1_0_parser
c = OFPPacketIn(Datapath)
def setUp(self):
pass
def tearDown(self):
pass
def test_init(self):
pass
def _test_parser(self, padding=False):
version = {'buf': b'\x01', 'val': ofproto.OFP_VERSION}
msg_type = {'buf': b'\x0a', 'val': ofproto.OFPT_PACKET_IN}
msg_len = {'buf': b'\x00\x14',
'val': ofproto.OFP_PACKET_IN_SIZE}
xid = {'buf': b'\xd0\x23\x8c\x34', 'val': 3491990580}
# OFP_PACKET_IN_PACK_STR
# '!IHHBx2x'...buffer_id, total_len,
# in_port, reason, zfill, data
buffer_id = {'buf': b'\xae\x73\x90\xec', 'val': 2926809324}
total_len = {'buf': b'\x00\x10', 'val': 16}
in_port = {'buf': b'\x08\x42', 'val': 2114}
reason = {'buf': b'\x43', 'val': 67}
zfill = b'\x00' * 1
if padding:
data = b'PACKET IN'.ljust(20)
else:
data = b'PACKET IN'.ljust(16)
buf = version['buf'] \
+ msg_type['buf'] \
+ msg_len['buf'] \
+ xid['buf'] \
+ buffer_id['buf'] \
+ total_len['buf'] \
+ in_port['buf'] \
+ reason['buf'] \
+ zfill \
+ data
res = OFPPacketIn.parser(object,
version['val'],
msg_type['val'],
msg_len['val'],
xid['val'],
buf)
eq_(version['val'], res.version)
eq_(msg_type['val'], res.msg_type)
eq_(msg_len['val'], res.msg_len)
eq_(xid['val'], res.xid)
eq_(buffer_id['val'], res.buffer_id)
eq_(total_len['val'], res.total_len)
eq_(in_port['val'], res.in_port)
eq_(reason['val'], res.reason)
eq_(data[0:16], res.data)
return True
def test_parser(self):
ok_(self._test_parser())
def test_parser_padding(self):
ok_(self._test_parser(True))
def test_serialize(self):
# Not used.
pass
class TestOFPGetConfigReply(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.OFPGetConfigReply
"""
class Datapath(object):
ofproto = ofproto # copy to class attribute
ofproto_parser = ofproto_v1_0_parser
c = OFPGetConfigReply(Datapath)
def setUp(self):
pass
def tearDown(self):
pass
def test_init(self):
pass
def test_parser(self):
version = {'buf': b'\x01', 'val': ofproto.OFP_VERSION}
msg_type = {'buf': b'\x0a', 'val': ofproto.OFPT_GET_CONFIG_REPLY}
msg_len = {'buf': b'\x00\x14',
'val': ofproto.OFP_SWITCH_CONFIG_SIZE}
xid = {'buf': b'\x94\xc4\xd2\xcd', 'val': 2495926989}
# OFP_SWITCH_CONFIG_PACK_STR
# '!HH'...flags, miss_send_len
flags = {'buf': b'\xa0\xe2', 'val': 41186}
miss_send_len = {'buf': b'\x36\x0e', 'val': 13838}
buf = version['buf'] \
+ msg_type['buf'] \
+ msg_len['buf'] \
+ xid['buf'] \
+ flags['buf'] \
+ miss_send_len['buf']
res = OFPGetConfigReply.parser(object,
version['val'],
msg_type['val'],
msg_len['val'],
xid['val'],
buf)
eq_(version['val'], res.version)
eq_(msg_type['val'], res.msg_type)
eq_(msg_len['val'], res.msg_len)
eq_(xid['val'], res.xid)
eq_(flags['val'], res.flags)
eq_(miss_send_len['val'], res.miss_send_len)
def test_serialize(self):
# Not used.
pass
class TestOFPBarrierReply(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.OFPBarrierReply
"""
class Datapath(object):
ofproto = ofproto # copy to class attribute
ofproto_parser = ofproto_v1_0_parser
c = OFPBarrierReply(Datapath)
def setUp(self):
pass
def tearDown(self):
pass
def test_init(self):
pass
def test_parser(self):
version = {'buf': b'\x01', 'val': ofproto.OFP_VERSION}
msg_type = {'buf': b'\x13', 'val': ofproto.OFPT_BARRIER_REPLY}
msg_len = {'buf': b'\x00\x08',
'val': ofproto.OFP_HEADER_SIZE}
xid = {'buf': b'\x66\xc4\xc3\xac', 'val': 1724171180}
buf = version['buf'] \
+ msg_type['buf'] \
+ msg_len['buf'] \
+ xid['buf']
res = OFPBarrierReply.parser(object,
version['val'],
msg_type['val'],
msg_len['val'],
xid['val'],
buf)
eq_(version['val'], res.version)
eq_(msg_type['val'], res.msg_type)
eq_(msg_len['val'], res.msg_len)
eq_(xid['val'], res.xid)
def test_serialize(self):
# Not used.
pass
class TestOFPFlowRemoved(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.OFPFlowRemoved
"""
class Datapath(object):
ofproto = ofproto # copy to class attribute
ofproto_parser = ofproto_v1_0_parser
c = OFPFlowRemoved(Datapath)
def setUp(self):
pass
def tearDown(self):
pass
def test_init(self):
pass
def test_parser(self):
version = {'buf': b'\x01', 'val': ofproto.OFP_VERSION}
msg_type = {'buf': b'\x0a', 'val': ofproto.OFPT_FLOW_REMOVED}
msg_len = {'buf': b'\x00\x14',
'val': ofproto.OFP_FLOW_REMOVED_SIZE}
xid = {'buf': b'\x94\xc4\xd2\xcd', 'val': 2495926989}
buf = version['buf'] \
+ msg_type['buf'] \
+ msg_len['buf'] \
+ xid['buf']
# OFP_MATCH_PACK_STR
# '!IH6s6sHBxHBB2xIIHH'...wildcards, in_port, dl_src, dl_dst, dl_vlan,
# dl_vlan_pcp, dl_type, nw_tos, nw_proto,
# nw_src, nw_dst, tp_src, tp_dst
wildcards = {'buf': b'\xd2\x71\x25\x23', 'val': 3530630435}
in_port = {'buf': b'\x37\x8b', 'val': 14219}
dl_src = b'\x7f\x85\xc4\x70\x12\xda'
dl_dst = b'\x0a\x51\x17\x58\xb0\xbb'
dl_vlan = {'buf': b'\xc1\xf9', 'val': 49657}
dl_vlan_pcp = {'buf': b'\x79', 'val': 121}
zfill0 = b'\x00'
dl_type = {'buf': b'\xa6\x9e', 'val': 42654}
nw_tos = {'buf': b'\xde', 'val': 222}
nw_proto = {'buf': b'\xe5', 'val': 229}
zfil11 = b'\x00' * 2
nw_src = {'buf': b'\x1b\x6d\x8d\x4b', 'val': 460164427}
nw_dst = {'buf': b'\xab\x25\xe1\x20', 'val': 2871386400}
tp_src = {'buf': b'\xd5\xc3', 'val': 54723}
tp_dst = {'buf': b'\x78\xb9', 'val': 30905}
buf += wildcards['buf'] \
+ in_port['buf'] \
+ dl_src \
+ dl_dst \
+ dl_vlan['buf'] \
+ dl_vlan_pcp['buf'] \
+ zfill0 \
+ dl_type['buf'] \
+ nw_tos['buf'] \
+ nw_proto['buf'] \
+ zfil11 \
+ nw_src['buf'] \
+ nw_dst['buf'] \
+ tp_src['buf'] \
+ tp_dst['buf']
# OFP_FLOW_REMOVED_PACK_STR0
# '!QHBxIIH2xQQ'...cookie, priority, reason, zfill,
# duration_sec, duration_nsec, idle_timeout,
# zfill, packet_count, byte_count
cookie = {'buf': b'\x02\x79\xba\x00\xef\xab\xee\x44',
'val': 178378173441633860}
priority = {'buf': b'\x02\xce', 'val': 718}
reason = {'buf': b'\xa9', 'val': 169}
zfill0 = b'\x00' * 1
duration_sec = {'buf': b'\x86\x24\xa3\xba', 'val': 2250548154}
duration_nsec = {'buf': b'\x94\x94\xc2\x23', 'val': 2492776995}
idle_timeout = {'buf': b'\xeb\x7c', 'val': 60284}
zfill1 = b'\x00' * 2
packet_count = {'buf': b'\x5a\x0d\xf2\x03\x8e\x0a\xbb\x8d',
'val': 6489108735192644493}
byte_count = {'buf': b'\x65\xc8\xd3\x72\x51\xb5\xbb\x7c',
'val': 7334344481123449724}
buf += cookie['buf'] \
+ priority['buf'] \
+ reason['buf'] \
+ zfill0 \
+ duration_sec['buf'] \
+ duration_nsec['buf'] \
+ idle_timeout['buf'] \
+ zfill1 \
+ packet_count['buf'] \
+ byte_count['buf']
res = OFPFlowRemoved.parser(object,
version['val'],
msg_type['val'],
msg_len['val'],
xid['val'],
buf)
eq_(version['val'], res.version)
eq_(msg_type['val'], res.msg_type)
eq_(msg_len['val'], res.msg_len)
eq_(xid['val'], res.xid)
eq_(cookie['val'], res.cookie)
eq_(priority['val'], res.priority)
eq_(reason['val'], res.reason)
eq_(duration_sec['val'], res.duration_sec)
eq_(duration_nsec['val'], res.duration_nsec)
eq_(idle_timeout['val'], res.idle_timeout)
eq_(packet_count['val'], res.packet_count)
eq_(byte_count['val'], res.byte_count)
# match
match = res.match
eq_(wildcards['val'], match.wildcards)
eq_(in_port['val'], match.in_port)
eq_(dl_src, match.dl_src)
eq_(dl_dst, match.dl_dst)
eq_(dl_vlan['val'], match.dl_vlan)
eq_(dl_vlan_pcp['val'], match.dl_vlan_pcp)
eq_(dl_type['val'], match.dl_type)
eq_(nw_tos['val'], match.nw_tos)
eq_(nw_proto['val'], match.nw_proto)
eq_(nw_src['val'], match.nw_src)
eq_(nw_dst['val'], match.nw_dst)
eq_(tp_src['val'], match.tp_src)
eq_(tp_dst['val'], match.tp_dst)
def test_serialize(self):
# Not used.
pass
class TestOFPQueueGetConfigReply(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.OFPQueueGetConfigReply
"""
class Datapath(object):
ofproto = ofproto # copy to class attribute
ofproto_parser = ofproto_v1_0_parser
c = OFPQueueGetConfigReply(Datapath)
def setUp(self):
pass
def tearDown(self):
pass
def test_init(self):
pass
def test_parser(self):
version = {'buf': b'\x01', 'val': ofproto.OFP_VERSION}
msg_type = {'buf': b'\x0a',
'val': ofproto.OFPT_QUEUE_GET_CONFIG_REPLY}
msg_len_val = ofproto.OFP_QUEUE_GET_CONFIG_REPLY_SIZE \
+ ofproto.OFP_PACKET_QUEUE_SIZE
msg_len = {'buf': b'\x00\x14', 'val': msg_len_val}
xid = {'buf': b'\x94\xc4\xd2\xcd', 'val': 2495926989}
buf = version['buf'] \
+ msg_type['buf'] \
+ msg_len['buf'] \
+ xid['buf']
# OFP_QUEUE_GET_CONFIG_REPLY_PACK_STR
# '!H6x'...port, zfill
port = {'buf': b'\xfe\x66', 'val': 65126}
zfill = b'\x00' * 6
buf += port['buf'] \
+ zfill
# OFP_PACKET_QUEUE_PQCK_STR
# '!IH2x'...queue_id, len_, zfill
queue_id = {'buf': b'\x4d\x4b\x3a\xd1', 'val': 1296775889}
len_ = {'buf': b'\x00\x08',
'val': ofproto.OFP_QUEUE_PROP_HEADER_SIZE}
zfill = b'\x00' * 2
buf += queue_id['buf'] \
+ len_['buf'] \
+ zfill
res = OFPQueueGetConfigReply.parser(object,
version['val'],
msg_type['val'],
msg_len['val'],
xid['val'],
buf)
eq_(version['val'], res.version)
eq_(msg_type['val'], res.msg_type)
eq_(msg_len['val'], res.msg_len)
eq_(xid['val'], res.xid)
eq_(port['val'], res.port)
# queue
queue = res.queues[0]
eq_(queue_id['val'], queue.queue_id)
eq_(len_['val'], queue.len)
def test_serialize(self):
# Not used.
pass
class TestOFPDescStatsReply(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.OFPDescStatsReply
"""
class Datapath(object):
ofproto = ofproto # copy to class attribute
ofproto_parser = ofproto_v1_0_parser
c = OFPDescStatsReply(Datapath)
def setUp(self):
pass
def tearDown(self):
pass
def test_init(self):
pass
def test_parser(self):
version = {'buf': b'\x01', 'val': ofproto.OFP_VERSION}
msg_type = {'buf': b'\x11', 'val': ofproto.OFPT_STATS_REPLY}
msg_len_val = ofproto.OFP_STATS_MSG_SIZE \
+ ofproto.OFP_DESC_STATS_SIZE
msg_len = {'buf': b'\x04\x38', 'val': msg_len_val}
xid = {'buf': b'\x94\xc4\xd2\xcd', 'val': 2495926989}
buf = version['buf'] \
+ msg_type['buf'] \
+ msg_len['buf'] \
+ xid['buf']
# OFP_STATS_MSG_PACK_STR
# '!HH'...type_, flags
type_ = {'buf': b'\x00\x00', 'val': ofproto.OFPST_DESC}
flags = {'buf': b'\x30\xd9', 'val': 12505}
buf += type_['buf'] \
+ flags['buf']
# stats_type_cls = OFPDescStats
# OFP_DESC_STATS_PACK_STR
# '!256s256s256s32s256s'...mfr_desc, hw_desc, sw_desc,
# serial_num, dp_desc
mfr_desc = b'mfr_desc'.ljust(256)
hw_desc = b'hw_desc'.ljust(256)
sw_desc = b'sw_desc'.ljust(256)
serial_num = b'serial_num'.ljust(32)
dp_desc = b'dp_desc'.ljust(256)
buf += mfr_desc \
+ hw_desc \
+ sw_desc \
+ serial_num \
+ dp_desc
res = OFPDescStatsReply.parser(object,
version['val'],
msg_type['val'],
msg_len['val'],
xid['val'],
buf)
eq_(version['val'], res.version)
eq_(msg_type['val'], res.msg_type)
eq_(msg_len['val'], res.msg_len)
eq_(xid['val'], res.xid)
eq_(type_['val'], res.type)
eq_(flags['val'], res.flags)
# body
body = res.body
eq_(mfr_desc, body.mfr_desc)
eq_(hw_desc, body.hw_desc)
eq_(sw_desc, body.sw_desc)
eq_(serial_num, body.serial_num)
eq_(dp_desc, body.dp_desc)
def test_serialize(self):
# Not used.
pass
class TestOFPFlowStatsReply(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.OFPFlowStatsReply
"""
class Datapath(object):
ofproto = ofproto # copy to class attribute
ofproto_parser = ofproto_v1_0_parser
c = OFPFlowStatsReply(Datapath)
def setUp(self):
pass
def tearDown(self):
pass
def test_init(self):
pass
def test_parser(self):
version = {'buf': b'\x01', 'val': ofproto.OFP_VERSION}
msg_type = {'buf': b'\x11', 'val': ofproto.OFPT_STATS_REPLY}
msg_len_val = ofproto.OFP_STATS_MSG_SIZE \
+ ofproto.OFP_FLOW_STATS_SIZE
msg_len = {'buf': b'\x00\x64', 'val': msg_len_val}
xid = {'buf': b'\x94\xc4\xd2\xcd', 'val': 2495926989}
buf = version['buf'] \
+ msg_type['buf'] \
+ msg_len['buf'] \
+ xid['buf']
# OFP_STATS_MSG_PACK_STR
# '!HH'...type_, flags
type_ = {'buf': b'\x00\x01', 'val': ofproto.OFPST_FLOW}
flags = {'buf': b'\x95\xf4', 'val': 38388}
buf += type_['buf'] \
+ flags['buf']
# stats_type_cls = OFPFlowStats
# OFP_FLOW_STATS_0_PACK_STR
# '!HBx'...length, table_id, zfill
length = {'buf': b'\x00\x60', 'val': 96}
table_id = {'buf': b'\x51', 'val': 81}
zfill = b'\x00'
buf += length['buf'] \
+ table_id['buf'] \
+ zfill
# OFP_MATCH_PACK_STR
# '!IH6s6sHBxHBB2xIIHH'...
match = b'\x97\x7c\xa6\x1e' \
+ b'\x5e\xa0' \
+ b'\x70\x17\xdc\x80\x59\x9e' \
+ b'\x79\xc6\x56\x87\x92\x28' \
+ b'\xb1\x81' \
+ b'\xbe' \
+ b'\x00' \
+ b'\x01\xab' \
+ b'\x42' \
+ b'\xfe' \
+ b'\x00\x00' \
+ b'\xa4\x5d\x5c\x42' \
+ b'\xa2\x5c\x2e\x05' \
+ b'\x5a\x94' \
+ b'\x64\xd4'
buf += match
# OFP_FLOW_STATS_1_PACK_STR
# '!IIHHH6xQQQ'...duration_sec, duration_nsec, priority,
# idle_timeout, hard_timeout, zfill,
# cookie, packet_count, byte_count
duration_sec = {'buf': b'\x94\x19\xb3\xd2', 'val': 2484712402}
duration_nsec = {'buf': b'\xee\x66\xcf\x7c', 'val': 3999715196}
priority = {'buf': b'\xe1\xc0', 'val': 57792}
idle_timeout = {'buf': b'\x8e\x10', 'val': 36368}
hard_timeout = {'buf': b'\xd4\x99', 'val': 54425}
zfill = b'\x00' * 6
cookie = {'buf': b'\x0b\x01\xe8\xe5\xf0\x84\x8a\xe0',
'val': 793171083674290912}
packet_count = {'buf': b'\x47\x5c\xc6\x05\x28\xff\x7c\xdb',
'val': 5142202600015232219}
byte_count = {'buf': b'\x24\xe9\x4b\xee\xcb\x57\xd9\xc3',
'val': 2659740543924820419}
buf += duration_sec['buf']
buf += duration_nsec['buf']
buf += priority['buf']
buf += idle_timeout['buf']
buf += hard_timeout['buf']
buf += zfill
buf += cookie['buf']
buf += packet_count['buf']
buf += byte_count['buf']
# <action>_PACK_STR...type_, len_ [others...]
type = {'buf': b'\x00\x00', 'val': ofproto.OFPAT_OUTPUT}
len = {'buf': b'\x00\x08',
'val': ofproto.OFP_ACTION_OUTPUT_SIZE}
port = {'buf': b'\x59\x2a', 'val': 22826}
max_len = {'buf': b'\x00\x08',
'val': ofproto.OFP_ACTION_OUTPUT_SIZE}
buf += type['buf'] \
+ len['buf'] \
+ port['buf'] \
+ max_len['buf']
res = OFPFlowStatsReply.parser(object,
version['val'],
msg_type['val'],
msg_len['val'],
xid['val'],
buf)
eq_(version['val'], res.version)
eq_(msg_type['val'], res.msg_type)
eq_(msg_len['val'], res.msg_len)
eq_(xid['val'], res.xid)
eq_(type_['val'], res.type)
eq_(flags['val'], res.flags)
# body
body = res.body[0]
eq_(length['val'], body.length)
eq_(table_id['val'], body.table_id)
eq_(duration_sec['val'], body.duration_sec)
eq_(duration_nsec['val'], body.duration_nsec)
eq_(priority['val'], body.priority)
eq_(idle_timeout['val'], body.idle_timeout)
eq_(hard_timeout['val'], body.hard_timeout)
eq_(cookie['val'], body.cookie)
eq_(packet_count['val'], body.packet_count)
eq_(byte_count['val'], body.byte_count)
# action
action = body.actions[0]
eq_(type['val'], action.type)
eq_(len['val'], action.len)
eq_(port['val'], action.port)
eq_(max_len['val'], action.max_len)
def test_serialize(self):
# Not used.
pass
class TestOFPAggregateStatsReply(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.OFPAggregateStatsReply
"""
class Datapath(object):
ofproto = ofproto # copy to class attribute
ofproto_parser = ofproto_v1_0_parser
c = OFPAggregateStatsReply(Datapath)
def setUp(self):
pass
def tearDown(self):
pass
def test_init(self):
pass
def test_parser(self):
version = {'buf': b'\x01', 'val': ofproto.OFP_VERSION}
msg_type = {'buf': b'\x11', 'val': ofproto.OFPT_STATS_REPLY}
msg_len_val = ofproto.OFP_STATS_MSG_SIZE \
+ ofproto.OFP_AGGREGATE_STATS_REPLY_SIZE
msg_len = {'buf': b'\x00\x4c', 'val': msg_len_val}
xid = {'buf': b'\xc6\xd6\xce\x38', 'val': 3335966264}
buf = version['buf'] \
+ msg_type['buf'] \
+ msg_len['buf'] \
+ xid['buf']
# OFP_STATS_MSG_PACK_STR
# '!HH'...type_, flags
type_ = {'buf': b'\x00\x02', 'val': ofproto.OFPST_AGGREGATE}
flags = {'buf': b'\x65\x66', 'val': 25958}
buf += type_['buf'] \
+ flags['buf']
# stats_type_cls = OFPAggregateStats
# OFP_AGGREGATE_STATS_REPLY_PACK_STR
# '!QQI4x'...packet_count, byte_count, flow_count, zfill
packet_count = {'buf': b'\x43\x95\x1b\xfb\x0f\xf6\xa7\xdd',
'val': 4869829337189623773}
byte_count = {'buf': b'\x36\xda\x2d\x80\x2a\x95\x35\xdd',
'val': 3952521651464517085}
flow_count = {'buf': b'\xc3\x0d\xc3\xed', 'val': 3272459245}
zfill = b'\x00' * 4
buf += packet_count['buf'] \
+ byte_count['buf'] \
+ flow_count['buf'] \
+ zfill
res = OFPAggregateStatsReply.parser(object,
version['val'],
msg_type['val'],
msg_len['val'],
xid['val'],
buf)
eq_(version['val'], res.version)
eq_(msg_type['val'], res.msg_type)
eq_(msg_len['val'], res.msg_len)
eq_(xid['val'], res.xid)
eq_(type_['val'], res.type)
eq_(flags['val'], res.flags)
# body
body = res.body[0]
eq_(packet_count['val'], body.packet_count)
eq_(byte_count['val'], body.byte_count)
eq_(flow_count['val'], body.flow_count)
def test_serialize(self):
# Not used.
pass
class TestOFPTableStatsReply(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.OFPTableStatsReply
"""
class Datapath(object):
ofproto = ofproto # copy to class attribute
ofproto_parser = ofproto_v1_0_parser
c = OFPTableStatsReply(Datapath)
def setUp(self):
pass
def tearDown(self):
pass
def test_init(self):
pass
def test_parser(self):
version = {'buf': b'\x01', 'val': ofproto.OFP_VERSION}
msg_type = {'buf': b'\x11', 'val': ofproto.OFPT_STATS_REPLY}
msg_len_val = ofproto.OFP_STATS_MSG_SIZE \
+ ofproto.OFP_TABLE_STATS_SIZE
msg_len = {'buf': b'\x00\x4c', 'val': msg_len_val}
xid = {'buf': b'\xd6\xb4\x8d\xe6', 'val': 3602157030}
buf = version['buf'] \
+ msg_type['buf'] \
+ msg_len['buf'] \
+ xid['buf']
# OFP_STATS_MSG_PACK_STR
# '!HH'...type_, flags
type_ = {'buf': b'\x00\x03', 'val': ofproto.OFPST_TABLE}
flags = {'buf': b'\xb3\xf0', 'val': 46064}
buf += type_['buf'] \
+ flags['buf']
# stats_type_cls = OFPTableStats
# OFP_TABLE_STATS_PACK_STR
# '!B3x32sIIIQQ'...table_id, zfill, name, wildcards, max_entries,
# active_count, lookup_count, matched_count
table_id = {'buf': b'\x5b', 'val': 91}
zfill = b'\x00' * 3
name = b'name'.ljust(32)
wildcards = {'buf': b'\xc5\xaf\x6e\x12', 'val': 3316608530}
max_entries = {'buf': b'\x95\x6c\x78\x4d', 'val': 2506913869}
active_count = {'buf': b'\x78\xac\xa8\x1e', 'val': 2024581150}
lookup_count = {'buf': b'\x40\x1d\x9c\x39\x19\xec\xd4\x1c',
'val': 4620020561814017052}
matched_count = {'buf': b'\x27\x35\x02\xb6\xc5\x5e\x17\x65',
'val': 2825167325263435621}
buf += table_id['buf'] \
+ zfill \
+ name \
+ wildcards['buf'] \
+ max_entries['buf'] \
+ active_count['buf'] \
+ lookup_count['buf'] \
+ matched_count['buf']
res = OFPTableStatsReply.parser(object,
version['val'],
msg_type['val'],
msg_len['val'],
xid['val'],
buf)
eq_(version['val'], res.version)
eq_(msg_type['val'], res.msg_type)
eq_(msg_len['val'], res.msg_len)
eq_(xid['val'], res.xid)
eq_(type_['val'], res.type)
eq_(flags['val'], res.flags)
# body
body = res.body[0]
eq_(table_id['val'], body.table_id)
eq_(name, body.name)
eq_(wildcards['val'], body.wildcards)
eq_(max_entries['val'], body.max_entries)
eq_(active_count['val'], body.active_count)
eq_(lookup_count['val'], body.lookup_count)
eq_(matched_count['val'], body.matched_count)
def test_serialize(self):
# Not used.
pass
class TestOFPPortStatsReply(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.OFPPortStatsReply
"""
class Datapath(object):
ofproto = ofproto # copy to class attribute
ofproto_parser = ofproto_v1_0_parser
c = OFPPortStatsReply(Datapath)
def setUp(self):
pass
def tearDown(self):
pass
def test_init(self):
pass
def test_parser(self):
version = {'buf': b'\x01', 'val': ofproto.OFP_VERSION}
msg_type = {'buf': b'\x11', 'val': ofproto.OFPT_STATS_REPLY}
msg_len_val = ofproto.OFP_STATS_MSG_SIZE \
+ ofproto.OFP_PORT_STATS_SIZE
msg_len = {'buf': b'\x00\x74', 'val': msg_len_val}
xid = {'buf': b'\xc2\xaf\x3d\xff', 'val': 3266264575}
buf = version['buf'] \
+ msg_type['buf'] \
+ msg_len['buf'] \
+ xid['buf']
# OFP_STATS_MSG_PACK_STR
# '!HH'...type_, flags
type_ = {'buf': b'\x00\x04', 'val': ofproto.OFPST_PORT}
flags = {'buf': b'\xda\xde', 'val': 56030}
buf += type_['buf'] \
+ flags['buf']
# stats_type_cls = OFPPortStats
# OFP_PORT_STATS_PACK_STR
# '!H6xQQQQQQQQQQQQ'... port_no, zfill, rx_packets, tx_packets,
# rx_bytes, tx_bytes, rx_dropped, tx_dropped,
# rx_errors, tx_errors, rx_frame_err,
# rx_over_err, rx_crc_err, collisions
port_no = {'buf': b'\xe7\x6b', 'val': 59243}
zfill = b'\x00' * 6
rx_packets = {'buf': b'\x53\x44\x36\x61\xc4\x86\xc0\x37',
'val': 5999980397101236279}
tx_packets = {'buf': b'\x27\xa4\x41\xd7\xd4\x53\x9e\x42',
'val': 2856480458895760962}
rx_bytes = {'buf': b'\x55\xa1\x38\x60\x43\x97\x0d\x89',
'val': 6170274950576278921}
tx_bytes = {'buf': b'\x77\xe1\xd5\x63\x18\xae\x63\xaa',
'val': 8638420181865882538}
rx_dropped = {'buf': b'\x60\xe6\x20\x01\x24\xda\x4e\x5a',
'val': 6982303461569875546}
tx_dropped = {'buf': b'\x09\x2d\x5d\x71\x71\xb6\x8e\xc7',
'val': 661287462113808071}
rx_errors = {'buf': b'\x2f\x7e\x35\xb3\x66\x3c\x19\x0d',
'val': 3422231811478788365}
tx_errors = {'buf': b'\x57\x32\x08\x2f\x88\x32\x40\x6b',
'val': 6283093430376743019}
rx_frame_err = {'buf': b'\x0c\x28\x6f\xad\xce\x66\x6e\x8b',
'val': 876072919806406283}
rx_over_err = {'buf': b'\x5a\x90\x8f\x9b\xfc\x82\x2e\xa0',
'val': 6525873760178941600}
rx_crc_err = {'buf': b'\x73\x3a\x71\x17\xd6\x74\x69\x47',
'val': 8303073210207070535}
collisions = {'buf': b'\x2f\x52\x0c\x79\x96\x03\x6e\x79',
'val': 3409801584220270201}
buf += port_no['buf'] \
+ zfill \
+ rx_packets['buf'] \
+ tx_packets['buf'] \
+ rx_bytes['buf'] \
+ tx_bytes['buf'] \
+ rx_dropped['buf'] \
+ tx_dropped['buf'] \
+ rx_errors['buf'] \
+ tx_errors['buf'] \
+ rx_frame_err['buf'] \
+ rx_over_err['buf'] \
+ rx_crc_err['buf'] \
+ collisions['buf']
res = OFPPortStatsReply.parser(object,
version['val'],
msg_type['val'],
msg_len['val'],
xid['val'],
buf)
eq_(version['val'], res.version)
eq_(msg_type['val'], res.msg_type)
eq_(msg_len['val'], res.msg_len)
eq_(xid['val'], res.xid)
eq_(type_['val'], res.type)
eq_(flags['val'], res.flags)
# body
body = res.body[0]
eq_(port_no['val'], body.port_no)
eq_(rx_packets['val'], body.rx_packets)
eq_(tx_packets['val'], body.tx_packets)
eq_(rx_bytes['val'], body.rx_bytes)
eq_(tx_bytes['val'], body.tx_bytes)
eq_(rx_dropped['val'], body.rx_dropped)
eq_(tx_dropped['val'], body.tx_dropped)
eq_(rx_errors['val'], body.rx_errors)
eq_(tx_errors['val'], body.tx_errors)
eq_(rx_frame_err['val'], body.rx_frame_err)
eq_(rx_over_err['val'], body.rx_over_err)
eq_(rx_crc_err['val'], body.rx_crc_err)
eq_(collisions['val'], body.collisions)
def test_serialize(self):
# Not used.
pass
class TestOFPQueueStatsReply(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.OFPQueueStatsReply
"""
class Datapath(object):
ofproto = ofproto # copy to class attribute
ofproto_parser = ofproto_v1_0_parser
c = OFPQueueStatsReply(Datapath)
def setUp(self):
pass
def tearDown(self):
pass
def test_init(self):
pass
def test_parser(self):
version = {'buf': b'\x01', 'val': ofproto.OFP_VERSION}
msg_type = {'buf': b'\x11', 'val': ofproto.OFPT_STATS_REPLY}
msg_len_val = ofproto.OFP_STATS_MSG_SIZE \
+ ofproto.OFP_QUEUE_STATS_SIZE
msg_len = {'buf': b'\x00\x2c', 'val': msg_len_val}
xid = {'buf': b'\x19\xfc\x28\x6c', 'val': 435955820}
buf = version['buf'] \
+ msg_type['buf'] \
+ msg_len['buf'] \
+ xid['buf']
# OFP_STATS_MSG_PACK_STR
# '!HH'...type_, flags
type_ = {'buf': b'\x00\x05', 'val': ofproto.OFPST_QUEUE}
flags = {'buf': b'\x3b\x2b', 'val': 15147}
buf += type_['buf'] \
+ flags['buf']
# stats_type_cls = OFPQueueStats
# OFP_QUEUE_STATS_PACK_STR
# '!H2xIQQQ...port_no, queue_id, tx_bytes, tx_packets, tx_errors
port_no = {'buf': b'\xe7\x6b', 'val': 59243}
zfill = b'\x00' * 2
queue_id = {'buf': b'\x2a\xa8\x7f\x32', 'val': 715685682}
tx_bytes = {'buf': b'\x77\xe1\xd5\x63\x18\xae\x63\xaa',
'val': 8638420181865882538}
tx_packets = {'buf': b'\x27\xa4\x41\xd7\xd4\x53\x9e\x42',
'val': 2856480458895760962}
tx_errors = {'buf': b'\x57\x32\x08\x2f\x88\x32\x40\x6b',
'val': 6283093430376743019}
buf += port_no['buf'] \
+ zfill \
+ queue_id['buf'] \
+ tx_bytes['buf'] \
+ tx_packets['buf'] \
+ tx_errors['buf']
res = OFPQueueStatsReply.parser(object,
version['val'],
msg_type['val'],
msg_len['val'],
xid['val'],
buf)
eq_(version['val'], res.version)
eq_(msg_type['val'], res.msg_type)
eq_(msg_len['val'], res.msg_len)
eq_(xid['val'], res.xid)
eq_(type_['val'], res.type)
eq_(flags['val'], res.flags)
# body
body = res.body[0]
eq_(port_no['val'], body.port_no)
eq_(queue_id['val'], body.queue_id)
eq_(tx_bytes['val'], body.tx_bytes)
eq_(tx_packets['val'], body.tx_packets)
eq_(tx_errors['val'], body.tx_errors)
def test_serialize(self):
# Not used.
pass
class TestOFPVendorStatsReply(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.OFPVendorStatsReply
"""
class Datapath(object):
ofproto = ofproto # copy to class attribute
ofproto_parser = ofproto_v1_0_parser
c = OFPVendorStatsReply(Datapath)
def setUp(self):
pass
def tearDown(self):
pass
def test_init(self):
pass
def test_parser(self):
version = {'buf': b'\x01', 'val': ofproto.OFP_VERSION}
msg_type = {'buf': b'\x11', 'val': ofproto.OFPT_STATS_REPLY}
# ofproto.OFP_STATS_MSG_SIZE + len(specific_data)
msg_len = {'buf': b'\x00\x18',
'val': ofproto.OFP_STATS_MSG_SIZE + 12}
xid = {'buf': b'\x94\xc4\xd2\xcd', 'val': 2495926989}
buf = version['buf'] \
+ msg_type['buf'] \
+ msg_len['buf'] \
+ xid['buf']
# OFP_STATS_MSG_PACK_STR
# '!HH'...type_, flags
type_ = {'buf': b'\xff\xff', 'val': ofproto.OFPST_VENDOR}
flags = {'buf': b'\x30\xd9', 'val': 12505}
buf += type_['buf'] \
+ flags['buf']
# stats_type_cls = OFPVendorStats
specific_data = b'specific_data'
buf += specific_data
res = OFPVendorStatsReply.parser(object,
version['val'],
msg_type['val'],
msg_len['val'],
xid['val'],
buf)
eq_(version['val'], res.version)
eq_(msg_type['val'], res.msg_type)
eq_(msg_len['val'], res.msg_len)
eq_(xid['val'], res.xid)
eq_(type_['val'], res.type)
eq_(flags['val'], res.flags)
# body
body = res.body[0]
eq_(specific_data, body)
def test_serialize(self):
# Not used.
pass
class TestOFPFeaturesRequest(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.OFPFeaturesRequest
"""
class Datapath(object):
ofproto = ofproto # copy to class attribute
ofproto_parser = ofproto_v1_0_parser
c = OFPFeaturesRequest(Datapath)
def setUp(self):
pass
def tearDown(self):
pass
def test_init(self):
pass
def test_parser(self):
# Not used.
pass
def test_serialize(self):
self.c.serialize()
eq_(ofproto.OFP_VERSION, self.c.version)
eq_(ofproto.OFPT_FEATURES_REQUEST, self.c.msg_type)
eq_(0, self.c.xid)
fmt = ofproto.OFP_HEADER_PACK_STR
res = struct.unpack(fmt, six.binary_type(self.c.buf))
eq_(ofproto.OFP_VERSION, res[0])
eq_(ofproto.OFPT_FEATURES_REQUEST, res[1])
eq_(len(self.c.buf), res[2])
eq_(0, res[3])
class TestOFPGetConfigRequest(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.OFPGetConfigRequest
"""
class Datapath(object):
ofproto = ofproto # copy to class attribute
ofproto_parser = ofproto_v1_0_parser
c = OFPGetConfigRequest(Datapath)
def setUp(self):
pass
def tearDown(self):
pass
def test_init(self):
pass
def test_parser(self):
# Not used.
pass
def test_serialize(self):
self.c.serialize()
eq_(ofproto.OFP_VERSION, self.c.version)
eq_(ofproto.OFPT_GET_CONFIG_REQUEST, self.c.msg_type)
eq_(0, self.c.xid)
fmt = ofproto.OFP_HEADER_PACK_STR
res = struct.unpack(fmt, six.binary_type(self.c.buf))
eq_(ofproto.OFP_VERSION, res[0])
eq_(ofproto.OFPT_GET_CONFIG_REQUEST, res[1])
eq_(len(self.c.buf), res[2])
eq_(0, res[3])
class TestOFPSetConfig(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.OFPSetConfig
"""
class Datapath(object):
ofproto = ofproto # copy to class attribute
ofproto_parser = ofproto_v1_0_parser
# OFP_SWITCH_CONFIG_PACK_STR
# '!HH'...flags, miss_send_len
flags = {'buf': b'\xa0\xe2', 'val': 41186}
miss_send_len = {'buf': b'\x36\x0e', 'val': 13838}
c = OFPSetConfig(Datapath,
flags['val'],
miss_send_len['val'])
def setUp(self):
pass
def tearDown(self):
pass
def test_init(self):
eq_(self.flags['val'], self.c.flags)
eq_(self.miss_send_len['val'], self.c.miss_send_len)
def test_parser(self):
# Not used.
pass
def test_serialize(self):
self.c.serialize()
eq_(ofproto.OFP_VERSION, self.c.version)
eq_(ofproto.OFPT_SET_CONFIG, self.c.msg_type)
eq_(0, self.c.xid)
fmt = '!' \
+ ofproto.OFP_HEADER_PACK_STR.replace('!', '') \
+ ofproto.OFP_SWITCH_CONFIG_PACK_STR.replace('!', '')
res = struct.unpack(fmt, six.binary_type(self.c.buf))
eq_(ofproto.OFP_VERSION, res[0])
eq_(ofproto.OFPT_SET_CONFIG, res[1])
eq_(len(self.c.buf), res[2])
eq_(0, res[3])
eq_(self.flags['val'], res[4])
eq_(self.miss_send_len['val'], res[5])
class TestOFPPacketOut(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.OFPPacketOut
"""
port = 0x2ae0
actions = [OFPActionOutput(port, max_len=0)]
def setUp(self):
pass
def tearDown(self):
pass
def _get_obj(self, buffer_id, in_port, data=None):
class Datapath(object):
ofproto = ofproto # copy to class attribute
ofproto_parser = ofproto_v1_0_parser
c = OFPPacketOut(Datapath,
buffer_id,
in_port,
self.actions,
data)
return c
def test_init(self):
buffer_id = 0xffffffff
in_port = 0x40455
data = 'Message'
c = self._get_obj(buffer_id, in_port, data)
eq_(buffer_id, c.buffer_id)
eq_(in_port, c.in_port)
eq_(data, c.data)
def test_parser(self):
# Not used.
pass
def test_serialize(self):
buffer_id = 0xffffffff
in_port = 0x9e07
data = b'Message'
c = self._get_obj(buffer_id, in_port, data)
c.serialize()
eq_(ofproto.OFP_VERSION, c.version)
eq_(ofproto.OFPT_PACKET_OUT, c.msg_type)
eq_(0, c.xid)
fmt = '!' \
+ ofproto.OFP_HEADER_PACK_STR.replace('!', '') \
+ ofproto.OFP_PACKET_OUT_PACK_STR.replace('!', '') \
+ ofproto.OFP_ACTION_OUTPUT_PACK_STR.replace('!', '') \
+ str(len(data)) + 's'
res = struct.unpack(fmt, six.binary_type(c.buf))
# OFP_HEADER_PACK_STR
eq_(ofproto.OFP_VERSION, res[0])
eq_(ofproto.OFPT_PACKET_OUT, res[1])
eq_(len(c.buf), res[2])
eq_(0, res[3])
# OFP_PACKET_OUT_PACK_STR
eq_(buffer_id, res[4])
eq_(in_port, res[5])
eq_(ofproto.OFP_ACTION_OUTPUT_SIZE, res[6])
# OFP_ACTION_OUTPUT_PACK_STR
eq_(ofproto.OFPAT_OUTPUT, res[7])
eq_(ofproto.OFP_ACTION_OUTPUT_SIZE, res[8])
eq_(self.port, res[9])
eq_(0, res[10])
# data
eq_(data, res[11])
@raises(AssertionError)
def test_serialize_check_buffer_id(self):
buffer_id = 0xffffff00
in_port = 0xaa92
data = 'Message'
c = self._get_obj(buffer_id, in_port, data)
c.serialize()
class TestOFPFlowMod(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.OFPFlowMod
"""
# OFP_FLOW_MOD_PACK_STR0
# '!QHHHHIHH'...cookie, command, idle_timeout, hard_timeout,
# priority, buffer_id, out_port, flags
cookie = {'buf': b'\x1d\x86\xce\x6e\x8d\xc0\xbe\xa8',
'val': 2127614848199081640}
command = {'buf': b'\xe1\x55', 'val': 57685}
idle_timeout = {'buf': b'\xf3\x6d', 'val': 62317}
hard_timeout = {'buf': b'\x1c\xc5', 'val': 7365}
priority = {'buf': b'\x9c\xe3', 'val': 40163}
buffer_id = {'buf': b'\xf0\xa1\x80\x33', 'val': 4037115955}
out_port = {'buf': b'\xfe\x0d', 'val': 65037}
flags = {'buf': b'\x00\x87', 'val': 135}
# OFP_MATCH_PACK_STR
# '!IH6s6sHBxHBB2xIIHH'...wildcards, in_port, dl_src, dl_dst, dl_vlan,
# dl_vlan_pcp, dl_type, nw_tos, nw_proto,
# nw_src, nw_dst, tp_src, tp_dst
wildcards = {'buf': b'\xd2\x71\x25\x23', 'val': 3530630435}
in_port = {'buf': b'\x37\x8b', 'val': 14219}
dl_src = b'\xdf\xcf\xe1\x5d\xcf\xc0'
dl_dst = b'\x76\xb3\xfb\xc6\x21\x2f'
dl_vlan = {'buf': b'\xc1\xf9', 'val': 49657}
dl_vlan_pcp = {'buf': b'\x79', 'val': 121}
zfill0 = b'\x00'
dl_type = {'buf': b'\xa6\x9e', 'val': 42654}
nw_tos = {'buf': b'\xde', 'val': 222}
nw_proto = {'buf': b'\xe5', 'val': 229}
zfil11 = b'\x00' * 2
nw_src = {'buf': b'\x1b\x6d\x8d\x4b', 'val': 460164427}
nw_dst = {'buf': b'\xab\x25\xe1\x20', 'val': 2871386400}
tp_src = {'buf': b'\xd5\xc3', 'val': 54723}
tp_dst = {'buf': b'\x78\xb9', 'val': 30905}
match = OFPMatch(wildcards['val'],
in_port['val'],
dl_src,
dl_dst,
dl_vlan['val'],
dl_vlan_pcp['val'],
dl_type['val'],
nw_tos['val'],
nw_proto['val'],
nw_src['val'],
nw_dst['val'],
tp_src['val'],
tp_dst['val'])
port = 0x2ae0
actions = [OFPActionOutput(port, max_len=1000)]
def setUp(self):
pass
def tearDown(self):
pass
def _get_obj(self, actions=None):
class Datapath(object):
ofproto = ofproto # copy to class attribute
ofproto_parser = ofproto_v1_0_parser
c = OFPFlowMod(Datapath,
self.match,
self.cookie['val'],
self.command['val'],
self.idle_timeout['val'],
self.hard_timeout['val'],
self.priority['val'],
self.buffer_id['val'],
self.out_port['val'],
self.flags['val'],
actions)
return c
def test_init(self):
c = self._get_obj()
eq_(self.cookie['val'], c.cookie)
eq_(self.command['val'], c.command)
eq_(self.idle_timeout['val'], c.idle_timeout)
eq_(self.hard_timeout['val'], c.hard_timeout)
eq_(self.priority['val'], c.priority)
eq_(self.buffer_id['val'], c.buffer_id)
eq_(self.out_port['val'], c.out_port)
eq_(self.flags['val'], c.flags)
def test_init_actions(self):
c = self._get_obj(self.actions)
action = c.actions[0]
eq_(self.port, action.port)
def test_parser(self):
# Not used.
pass
def test_serialize(self):
c = self._get_obj(self.actions)
c.serialize()
eq_(ofproto.OFP_VERSION, c.version)
eq_(ofproto.OFPT_FLOW_MOD, c.msg_type)
eq_(0, c.xid)
fmt = '!' \
+ ofproto.OFP_HEADER_PACK_STR.replace('!', '') \
+ ofproto.OFP_MATCH_PACK_STR.replace('!', '') \
+ ofproto.OFP_FLOW_MOD_PACK_STR0.replace('!', '') \
+ ofproto.OFP_ACTION_OUTPUT_PACK_STR.replace('!', '')
res = struct.unpack(fmt, six.binary_type(c.buf))
# OFP_HEADER_PACK_STR
eq_(ofproto.OFP_VERSION, res[0])
eq_(ofproto.OFPT_FLOW_MOD, res[1])
eq_(len(c.buf), res[2])
eq_(0, res[3])
# OFP_MATCH_PACK_STR
eq_(self.wildcards['val'], res[4])
eq_(self.in_port['val'], res[5])
eq_(self.dl_src, res[6])
eq_(self.dl_dst, res[7])
eq_(self.dl_vlan['val'], res[8])
eq_(self.dl_vlan_pcp['val'], res[9])
eq_(self.dl_type['val'], res[10])
eq_(self.nw_tos['val'], res[11])
eq_(self.nw_proto['val'], res[12])
eq_(self.nw_src['val'], res[13])
eq_(self.nw_dst['val'], res[14])
eq_(self.tp_src['val'], res[15])
eq_(self.tp_dst['val'], res[16])
# OFP_FLOW_MOD_PACK_STR0
eq_(self.cookie['val'], res[17])
eq_(self.command['val'], res[18])
eq_(self.idle_timeout['val'], res[19])
eq_(self.hard_timeout['val'], res[20])
eq_(self.priority['val'], res[21])
eq_(self.buffer_id['val'], res[22])
eq_(self.out_port['val'], res[23])
eq_(self.flags['val'], res[24])
# OFP_ACTION_OUTPUT_PACK_STR
eq_(ofproto.OFPAT_OUTPUT, res[25])
eq_(ofproto.OFP_ACTION_OUTPUT_SIZE, res[26])
eq_(self.port, res[27])
eq_(1000, res[28])
class TestOFPBarrierRequest(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.OFPBarrierRequest
"""
class Datapath(object):
ofproto = ofproto # copy to class attribute
ofproto_parser = ofproto_v1_0_parser
c = OFPBarrierRequest(Datapath)
def setUp(self):
pass
def tearDown(self):
pass
def test_init(self):
pass
def test_parser(self):
# Not used.
pass
def test_serialize(self):
self.c.serialize()
eq_(ofproto.OFP_VERSION, self.c.version)
eq_(ofproto.OFPT_BARRIER_REQUEST, self.c.msg_type)
eq_(0, self.c.xid)
fmt = ofproto.OFP_HEADER_PACK_STR
res = struct.unpack(fmt, six.binary_type(self.c.buf))
eq_(ofproto.OFP_VERSION, res[0])
eq_(ofproto.OFPT_BARRIER_REQUEST, res[1])
eq_(len(self.c.buf), res[2])
eq_(0, res[3])
class TestOFPQueueGetConfigRequest(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.OFPQueueGetConfigRequest
"""
class Datapath(object):
ofproto = ofproto # copy to class attribute
ofproto_parser = ofproto_v1_0_parser
# OFP_QUEUE_GET_CONFIG_REQUEST_PACK_STR
# '!H2x'...port, zfill
port = {'buf': b'\xa0\xe2', 'val': 41186}
zfill = b'\x00' * 2
c = OFPQueueGetConfigRequest(Datapath,
port['val'])
def setUp(self):
pass
def tearDown(self):
pass
def test_init(self):
eq_(self.port['val'], self.c.port)
def test_parser(self):
# Not used.
pass
def test_serialize(self):
self.c.serialize()
eq_(ofproto.OFP_VERSION, self.c.version)
eq_(ofproto.OFPT_QUEUE_GET_CONFIG_REQUEST, self.c.msg_type)
eq_(0, self.c.xid)
a = ofproto.OFP_HEADER_PACK_STR.replace('!', '')
b = ofproto.OFP_QUEUE_GET_CONFIG_REQUEST_PACK_STR.replace('!', '')
fmt = '!' + a + b
res = struct.unpack(fmt, six.binary_type(self.c.buf))
eq_(ofproto.OFP_VERSION, res[0])
eq_(ofproto.OFPT_QUEUE_GET_CONFIG_REQUEST, res[1])
eq_(len(self.c.buf), res[2])
eq_(0, res[3])
eq_(self.port['val'], res[4])
class TestOFPDescStatsRequest(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.OFPDescStatsRequest
"""
class Datapath(object):
ofproto = ofproto # copy to class attribute
ofproto_parser = ofproto_v1_0_parser
flags = {'buf': b'\x00\x00', 'val': 0}
c = OFPDescStatsRequest(Datapath, flags['val'])
def setUp(self):
pass
def tearDown(self):
pass
def test_init(self):
eq_(ofproto.OFPST_DESC, self.c.type)
eq_(self.flags['val'], self.c.flags)
def test_parser(self):
# Not used.
pass
def test_serialize(self):
self.c.serialize()
eq_(ofproto.OFP_VERSION, self.c.version)
eq_(ofproto.OFPT_STATS_REQUEST, self.c.msg_type)
eq_(0, self.c.xid)
fmt = '!' \
+ ofproto.OFP_HEADER_PACK_STR.replace('!', '') \
+ ofproto.OFP_STATS_MSG_PACK_STR.replace('!', '')
res = struct.unpack(fmt, six.binary_type(self.c.buf))
# OFP_HEADER_PACK_STR
eq_(ofproto.OFP_VERSION, res[0])
eq_(ofproto.OFPT_STATS_REQUEST, res[1])
eq_(len(self.c.buf), res[2])
eq_(0, res[3])
# OFP_STATS_MSG_PACK_STR
eq_(ofproto.OFPST_DESC, res[4])
eq_(self.flags['val'], res[5])
class TestOFPFlowStatsRequest(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.OFPFlowStatsRequest
"""
class Datapath(object):
ofproto = ofproto # copy to class attribute
ofproto_parser = ofproto_v1_0_parser
flags = {'buf': b'\x00\x00', 'val': 0}
# OFP_MATCH_PACK_STR
# '!IH6s6sHBxHBB2xIIHH'...wildcards, in_port, dl_src, dl_dst, dl_vlan,
# dl_vlan_pcp, dl_type, nw_tos, nw_proto,
# nw_src, nw_dst, tp_src, tp_dst
wildcards = {'buf': b'\xd2\x71\x25\x23', 'val': 3530630435}
in_port = {'buf': b'\x37\x8b', 'val': 14219}
dl_src = b'\x58\xd0\x8a\x69\xa4\xfc'
dl_dst = b'\xb6\xe2\xef\xb1\xa6\x2d'
dl_vlan = {'buf': b'\xc1\xf9', 'val': 49657}
dl_vlan_pcp = {'buf': b'\x79', 'val': 121}
zfill0 = b'\x00'
dl_type = {'buf': b'\xa6\x9e', 'val': 42654}
nw_tos = {'buf': b'\xde', 'val': 222}
nw_proto = {'buf': b'\xe5', 'val': 229}
zfil11 = b'\x00' * 2
nw_src = {'buf': b'\x1b\x6d\x8d\x4b', 'val': 460164427}
nw_dst = {'buf': b'\xab\x25\xe1\x20', 'val': 2871386400}
tp_src = {'buf': b'\xd5\xc3', 'val': 54723}
tp_dst = {'buf': b'\x78\xb9', 'val': 30905}
match = OFPMatch(wildcards['val'],
in_port['val'],
dl_src,
dl_dst,
dl_vlan['val'],
dl_vlan_pcp['val'],
dl_type['val'],
nw_tos['val'],
nw_proto['val'],
nw_src['val'],
nw_dst['val'],
tp_src['val'],
tp_dst['val'])
# OFP_FLOW_STATS_REQUEST_ID_PORT_STR
# '!BxH'...table_id, zfill, out_port
table_id = {'buf': b'\xd1', 'val': 209}
zfill = b'\x00' * 1
out_port = {'buf': b'\xe4\x9a', 'val': 58522}
c = OFPFlowStatsRequest(Datapath,
flags['val'],
match,
table_id['val'],
out_port['val'])
def setUp(self):
pass
def tearDown(self):
pass
def test_init(self):
eq_(ofproto.OFPST_FLOW, self.c.type)
eq_(self.flags['val'], self.c.flags)
eq_(self.table_id['val'], self.c.table_id)
eq_(self.out_port['val'], self.c.out_port)
# match
match = self.c.match
eq_(self.match.__hash__(), match.__hash__())
def test_parser(self):
# Not used.
pass
def test_serialize(self):
self.c.serialize()
eq_(ofproto.OFP_VERSION, self.c.version)
eq_(ofproto.OFPT_STATS_REQUEST, self.c.msg_type)
eq_(0, self.c.xid)
fmt = '!' \
+ ofproto.OFP_HEADER_PACK_STR.replace('!', '') \
+ ofproto.OFP_STATS_MSG_PACK_STR.replace('!', '') \
+ ofproto.OFP_MATCH_PACK_STR.replace('!', '') \
+ ofproto.OFP_FLOW_STATS_REQUEST_ID_PORT_STR.replace('!', '')
res = struct.unpack(fmt, six.binary_type(self.c.buf))
# OFP_HEADER_PACK_STR
eq_(ofproto.OFP_VERSION, res[0])
eq_(ofproto.OFPT_STATS_REQUEST, res[1])
eq_(len(self.c.buf), res[2])
eq_(0, res[3])
# OFP_STATS_MSG_PACK_STR
eq_(ofproto.OFPST_FLOW, res[4])
eq_(self.flags['val'], res[5])
# OFP_MATCH_PACK_STR
eq_(self.wildcards['val'], res[6])
eq_(self.in_port['val'], res[7])
eq_(self.dl_src, res[8])
eq_(self.dl_dst, res[9])
eq_(self.dl_vlan['val'], res[10])
eq_(self.dl_vlan_pcp['val'], res[11])
eq_(self.dl_type['val'], res[12])
eq_(self.nw_tos['val'], res[13])
eq_(self.nw_proto['val'], res[14])
eq_(self.nw_src['val'], res[15])
eq_(self.nw_dst['val'], res[16])
eq_(self.tp_src['val'], res[17])
eq_(self.tp_dst['val'], res[18])
# OFP_FLOW_STATS_REQUEST_ID_PORT_STR
eq_(self.table_id['val'], res[19])
eq_(self.out_port['val'], res[20])
class TestOFPAggregateStatsRequest(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.OFPAggregateStatsRequest
"""
class Datapath(object):
ofproto = ofproto # copy to class attribute
ofproto_parser = ofproto_v1_0_parser
flags = {'buf': b'\x00\x00', 'val': 0}
# OFP_MATCH_PACK_STR
# '!IH6s6sHBxHBB2xIIHH'...wildcards, in_port, dl_src, dl_dst, dl_vlan,
# dl_vlan_pcp, dl_type, nw_tos, nw_proto,
# nw_src, nw_dst, tp_src, tp_dst
wildcards = {'buf': b'\xea\x66\x4a\xd4', 'val': 3932572372}
in_port = {'buf': b'\x64\xac', 'val': 25772}
dl_src = b'\x90\x13\x60\x5e\x20\x4d'
dl_dst = b'\xb5\x5d\x14\x5e\xb9\x22'
dl_vlan = {'buf': b'\x8b\xeb', 'val': 35819}
dl_vlan_pcp = {'buf': b'\xe8', 'val': 232}
zfill0 = b'\x00'
dl_type = {'buf': b'\62\xc9', 'val': 25289}
nw_tos = {'buf': b'\xb5', 'val': 181}
nw_proto = {'buf': b'\xc4', 'val': 196}
zfil11 = b'\x00' * 2
nw_src = {'buf': b'\xb7\xd1\xb7\xef', 'val': 3083974639}
nw_dst = {'buf': b'\x7c\xc6\x18\x15', 'val': 2093357077}
tp_src = {'buf': b'\x26\x9a', 'val': 9882}
tp_dst = {'buf': b'\x7a\x89', 'val': 31369}
match = OFPMatch(wildcards['val'],
in_port['val'],
dl_src,
dl_dst,
dl_vlan['val'],
dl_vlan_pcp['val'],
dl_type['val'],
nw_tos['val'],
nw_proto['val'],
nw_src['val'],
nw_dst['val'],
tp_src['val'],
tp_dst['val'])
# OFP_FLOW_STATS_REQUEST_ID_PORT_STR
# '!BxH'...table_id, zfill, out_port
table_id = {'buf': b'\xd1', 'val': 209}
zfill = b'\x00' * 1
out_port = {'buf': b'\xb5\xe8', 'val': 46568}
c = OFPAggregateStatsRequest(Datapath,
flags['val'],
match,
table_id['val'],
out_port['val'])
def setUp(self):
pass
def tearDown(self):
pass
def test_init(self):
eq_(ofproto.OFPST_AGGREGATE, self.c.type)
eq_(self.flags['val'], self.c.flags)
eq_(self.table_id['val'], self.c.table_id)
eq_(self.out_port['val'], self.c.out_port)
# match
match = self.c.match
eq_(self.match.__hash__(), match.__hash__())
def test_parser(self):
# Not used.
pass
def test_serialize(self):
self.c.serialize()
eq_(ofproto.OFP_VERSION, self.c.version)
eq_(ofproto.OFPT_STATS_REQUEST, self.c.msg_type)
eq_(0, self.c.xid)
fmt = '!' \
+ ofproto.OFP_HEADER_PACK_STR.replace('!', '') \
+ ofproto.OFP_STATS_MSG_PACK_STR.replace('!', '') \
+ ofproto.OFP_MATCH_PACK_STR.replace('!', '') \
+ ofproto.OFP_FLOW_STATS_REQUEST_ID_PORT_STR.replace('!', '')
res = struct.unpack(fmt, six.binary_type(self.c.buf))
# OFP_HEADER_PACK_STR
eq_(ofproto.OFP_VERSION, res[0])
eq_(ofproto.OFPT_STATS_REQUEST, res[1])
eq_(len(self.c.buf), res[2])
eq_(0, res[3])
# OFP_STATS_MSG_PACK_STR
eq_(ofproto.OFPST_AGGREGATE, res[4])
eq_(self.flags['val'], res[5])
# OFP_MATCH_PACK_STR
eq_(self.wildcards['val'], res[6])
eq_(self.in_port['val'], res[7])
eq_(self.dl_src, res[8])
eq_(self.dl_dst, res[9])
eq_(self.dl_vlan['val'], res[10])
eq_(self.dl_vlan_pcp['val'], res[11])
eq_(self.dl_type['val'], res[12])
eq_(self.nw_tos['val'], res[13])
eq_(self.nw_proto['val'], res[14])
eq_(self.nw_src['val'], res[15])
eq_(self.nw_dst['val'], res[16])
eq_(self.tp_src['val'], res[17])
eq_(self.tp_dst['val'], res[18])
# OFP_FLOW_STATS_REQUEST_ID_PORT_STR
eq_(self.table_id['val'], res[19])
eq_(self.out_port['val'], res[20])
class TestOFPTableStatsRequest(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.OFPTableStatsRequest
"""
class Datapath(object):
ofproto = ofproto # copy to class attribute
ofproto_parser = ofproto_v1_0_parser
flags = {'buf': b'\x00\x00', 'val': 0}
c = OFPTableStatsRequest(Datapath, flags['val'])
def setUp(self):
pass
def tearDown(self):
pass
def test_init(self):
eq_(ofproto.OFPST_TABLE, self.c.type)
eq_(self.flags['val'], self.c.flags)
def test_parser(self):
# Not used.
pass
def test_serialize(self):
self.c.serialize()
eq_(ofproto.OFP_VERSION, self.c.version)
eq_(ofproto.OFPT_STATS_REQUEST, self.c.msg_type)
eq_(0, self.c.xid)
fmt = '!' \
+ ofproto.OFP_HEADER_PACK_STR.replace('!', '') \
+ ofproto.OFP_STATS_MSG_PACK_STR.replace('!', '')
res = struct.unpack(fmt, six.binary_type(self.c.buf))
# OFP_HEADER_PACK_STR
eq_(ofproto.OFP_VERSION, res[0])
eq_(ofproto.OFPT_STATS_REQUEST, res[1])
eq_(len(self.c.buf), res[2])
eq_(0, res[3])
# OFP_STATS_MSG_PACK_STR
eq_(ofproto.OFPST_TABLE, res[4])
eq_(self.flags['val'], res[5])
class TestOFPPortStatsRequest(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.OFPPortStatsRequest
"""
class Datapath(object):
ofproto = ofproto # copy to class attribute
ofproto_parser = ofproto_v1_0_parser
flags = {'buf': b'\x00\x00', 'val': 0}
# OFP_PORT_STATS_REQUEST_PACK_STR
# '!H6x'...port_no, zfill
port_no = {'buf': b'\x6d\x27', 'val': 27943}
c = OFPPortStatsRequest(Datapath,
flags['val'],
port_no['val'])
def setUp(self):
pass
def tearDown(self):
pass
def test_init(self):
eq_(ofproto.OFPST_PORT, self.c.type)
eq_(self.flags['val'], self.c.flags)
eq_(self.port_no['val'], self.c.port_no)
def test_parser(self):
# Not used.
pass
def test_serialize(self):
self.c.serialize()
eq_(ofproto.OFP_VERSION, self.c.version)
eq_(ofproto.OFPT_STATS_REQUEST, self.c.msg_type)
eq_(0, self.c.xid)
fmt = '!' \
+ ofproto.OFP_HEADER_PACK_STR.replace('!', '') \
+ ofproto.OFP_STATS_MSG_PACK_STR.replace('!', '') \
+ ofproto.OFP_PORT_STATS_REQUEST_PACK_STR.replace('!', '')
res = struct.unpack(fmt, six.binary_type(self.c.buf))
# OFP_HEADER_PACK_STR
eq_(ofproto.OFP_VERSION, res[0])
eq_(ofproto.OFPT_STATS_REQUEST, res[1])
eq_(len(self.c.buf), res[2])
eq_(0, res[3])
# OFP_STATS_MSG_PACK_STR
eq_(ofproto.OFPST_PORT, res[4])
eq_(self.flags['val'], res[5])
# OFP_PORT_STATS_REQUEST_PACK_STR
eq_(self.port_no['val'], res[6])
class TestOFPQueueStatsRequest(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.OFPQueueStatsRequest
"""
class Datapath(object):
ofproto = ofproto # copy to class attribute
ofproto_parser = ofproto_v1_0_parser
flags = {'buf': b'\x00\x00', 'val': 0}
# OFP_QUEUE_STATS_REQUEST_PACK_STR
# '!HxxI'...port_no, zfill, zfill, queue_id
port_no = {'buf': b'\x0c\x2d', 'val': 3117}
queue_id = {'buf': b'\x1b\xe6\xba\x36', 'val': 468105782}
c = OFPQueueStatsRequest(Datapath,
flags['val'],
port_no['val'],
queue_id['val'])
def setUp(self):
pass
def tearDown(self):
pass
def test_init(self):
eq_(ofproto.OFPST_QUEUE, self.c.type)
eq_(self.flags['val'], self.c.flags)
eq_(self.port_no['val'], self.c.port_no)
eq_(self.queue_id['val'], self.c.queue_id)
def test_parser(self):
# Not used.
pass
def test_serialize(self):
self.c.serialize()
eq_(ofproto.OFP_VERSION, self.c.version)
eq_(ofproto.OFPT_STATS_REQUEST, self.c.msg_type)
eq_(0, self.c.xid)
fmt = '!' \
+ ofproto.OFP_HEADER_PACK_STR.replace('!', '') \
+ ofproto.OFP_STATS_MSG_PACK_STR.replace('!', '') \
+ ofproto.OFP_QUEUE_STATS_REQUEST_PACK_STR.replace('!', '')
res = struct.unpack(fmt, six.binary_type(self.c.buf))
# OFP_HEADER_PACK_STR
eq_(ofproto.OFP_VERSION, res[0])
eq_(ofproto.OFPT_STATS_REQUEST, res[1])
eq_(len(self.c.buf), res[2])
eq_(0, res[3])
# OFP_STATS_MSG_PACK_STR
eq_(ofproto.OFPST_QUEUE, res[4])
eq_(self.flags['val'], res[5])
# OFP_QUEUE_STATS_REQUEST_PACK_STR
eq_(self.port_no['val'], res[6])
eq_(self.queue_id['val'], res[7])
class TestOFPVendorStatsRequest(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.OFPVendorStatsRequest
"""
class Datapath(object):
ofproto = ofproto # copy to class attribute
ofproto_parser = ofproto_v1_0_parser
flags = {'buf': b'\x00\x00', 'val': 0}
# OFP_VENDOR_STATS_MSG_PACK_STR
# '!I'...vendor
vendor = {'buf': b'\xff\xff\xff\xff', 'val': ofproto.OFPAT_VENDOR}
specific_data = b'specific_data'
c = OFPVendorStatsRequest(Datapath,
flags['val'],
vendor['val'],
specific_data)
def setUp(self):
pass
def tearDown(self):
pass
def test_init(self):
eq_(ofproto.OFPST_VENDOR, self.c.type)
eq_(self.flags['val'], self.c.flags)
eq_(self.vendor['val'], self.c.vendor)
eq_(self.specific_data, self.c.specific_data)
def test_parser(self):
# Not used.
pass
def test_serialize(self):
self.c.serialize()
eq_(ofproto.OFP_VERSION, self.c.version)
eq_(ofproto.OFPT_STATS_REQUEST, self.c.msg_type)
eq_(0, self.c.xid)
fmt = '!' \
+ ofproto.OFP_HEADER_PACK_STR.replace('!', '') \
+ ofproto.OFP_STATS_MSG_PACK_STR.replace('!', '') \
+ ofproto.OFP_VENDOR_STATS_MSG_PACK_STR.replace('!', '') \
+ str(len(self.specific_data)) + 's'
res = struct.unpack(fmt, six.binary_type(self.c.buf))
# OFP_HEADER_PACK_STR
eq_(ofproto.OFP_VERSION, res[0])
eq_(ofproto.OFPT_STATS_REQUEST, res[1])
eq_(len(self.c.buf), res[2])
eq_(0, res[3])
# OFP_STATS_MSG_PACK_STR
eq_(ofproto.OFPST_VENDOR, res[4])
eq_(self.flags['val'], res[5])
# OFP_VENDOR_STATS_MSG_PACK_STR
eq_(self.vendor['val'], res[6])
# specific_data
eq_(self.specific_data, res[7])
|
apache-2.0
|
[
3,
1898,
334,
35,
9,
6029,
653,
711,
678,
23884,
2180,
436,
23884,
9339,
11098,
14,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
3,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
3,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
259,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
199,
3,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
199,
3,
6695,
26,
20849,
29,
20,
20105,
29,
20,
25966,
29,
20,
199,
199,
646,
2882,
199,
646,
2050,
199,
646,
3816,
199,
504,
11354,
14,
2537,
492,
627,
199,
504,
25494,
14,
15129,
14,
15129,
63,
86,
17,
63,
16,
63,
2087,
492,
627,
199,
504,
25494,
14,
15129,
14,
7343,
63,
3723,
492,
627,
199,
504,
25494,
14,
15129,
492,
14122,
63,
86,
17,
63,
16,
63,
2087,
199,
504,
25494,
14,
773,
492,
5552,
5598,
421,
199,
4947,
275,
2050,
14,
5572,
360,
396,
63,
15129,
63,
86,
709,
358,
421,
199,
533,
1379,
6733,
6678,
4313,
8,
2796,
14,
1746,
304,
272,
408,
1379,
1930,
367,
14122,
63,
86,
17,
63,
16,
63,
2087,
14,
6733,
6678,
4313,
272,
408,
339,
327,
16563,
63,
9791,
57,
63,
3657,
63,
6961,
63,
3027,
272,
327,
14597,
40,
22,
83,
975,
83,
8921,
8921,
8921,
7,
1396,
1844,
63,
889,
12,
12073,
63,
2697,
12,
536,
12,
1101,
12,
1174,
272,
327,
8540,
8230,
12,
19613,
939,
12,
3748,
12,
9104,
272,
1844,
63,
889,
275,
791,
1436,
356,
330,
1154,
1845,
23,
60,
88,
22,
66,
297,
283,
637,
356,
8155,
13440,
93,
272,
12073,
63,
2697,
275,
283,
2528,
26,
1477,
26,
1477,
26,
709,
26,
1165,
26,
1020,
7,
272,
536,
275,
330,
7,
354,
1370,
19996,
8,
975,
9,
272,
1101,
275,
791,
1436,
356,
330,
1154,
88,
1349,
60,
1774,
22,
60,
88,
24,
67,
60,
88,
2481,
297,
283,
637,
356,
26485,
10027,
1427,
1555,
93,
272,
1174,
275,
791,
1436,
356,
330,
1154,
88,
772,
60,
88,
1780,
60,
10272,
60,
1812,
25,
297,
283,
637,
356,
413,
17237,
11603,
11782,
93,
272,
8230,
275,
791,
1436,
356,
330,
1154,
1800,
25,
60,
1845,
24,
60,
88,
16,
65,
60,
88,
18,
66,
297,
283,
637,
356,
7294,
1400,
1229,
772,
1427,
93,
272,
19613,
939,
275,
791,
1436,
356,
330,
1154,
88,
2277,
60,
1774,
25,
60,
88,
23,
66,
60,
88,
2819,
297,
283,
637,
356,
3388,
821,
2260,
975,
2564,
93,
272,
3748,
275,
791,
1436,
356,
330,
1154,
88,
23,
69,
60,
88,
2182,
60,
88,
2333,
60,
10135,
297,
283,
637,
356,
499,
6708,
14781,
10721,
93,
272,
9104,
275,
791,
1436,
356,
330,
1154,
1800,
20,
60,
88,
21,
66,
60,
88,
24,
66,
60,
7887,
297,
283,
637,
356,
499,
2194,
1342,
2766,
15385,
93,
339,
4123,
275,
1844,
63,
889,
459,
1436,
418,
971,
267,
435,
5552,
5598,
14,
3088,
14,
505,
63,
475,
63,
1393,
8,
8090,
63,
2697,
9,
971,
267,
435,
536,
971,
267,
435,
1101,
459,
1436,
418,
971,
267,
435,
1174,
459,
1436,
418,
971,
267,
435,
8230,
459,
1436,
418,
971,
267,
435,
19613,
939,
459,
1436,
418,
971,
267,
435,
3748,
459,
1436,
418,
971,
267,
435,
9104,
459,
1436,
418,
339,
286,
275,
16563,
6678,
4313,
8,
719,
63,
889,
459,
637,
995,
673,
12073,
63,
2697,
12,
673,
536,
12,
673,
1101,
459,
637,
995,
673,
1174,
459,
637,
995,
673,
8230,
459,
637,
995,
673,
19613,
939,
459,
637,
995,
673,
3748,
459,
637,
995,
673,
9104,
459,
637,
1105,
339,
347,
3613,
8,
277,
304,
267,
986,
339,
347,
6766,
8,
277,
304,
267,
986,
339,
347,
511,
63,
826,
8,
277,
304,
267,
3850,
2531,
277,
14,
719,
63,
889,
459,
637,
995,
291,
14,
67,
14,
719,
63,
889,
9,
267,
3850,
2531,
277,
14,
8090,
63,
2697,
12,
291,
14,
67,
14,
8090,
63,
2697,
9,
267,
3850,
2531,
277,
14,
354,
12,
291,
14,
67,
14,
354,
9,
267,
3850,
2531,
277,
14,
888,
459,
637,
995,
291,
14,
67,
14,
888,
9,
267,
3850,
2531,
277,
14,
929,
459,
637,
995,
291,
14,
67,
14,
929,
9,
267,
3850,
2531,
277,
14,
9808,
459,
637,
995,
291,
14,
67,
14,
9808,
9,
267,
3850,
2531,
277,
14,
24576,
939,
459,
637,
995,
291,
14,
67,
14,
24576,
939,
9,
267,
3850,
2531,
277,
14,
4946,
459,
637,
995,
291,
14,
67,
14,
4946,
9,
267,
3850,
2531,
277,
14,
7866,
459,
637,
995,
291,
14,
67,
14,
7866,
9,
339,
347,
511,
63,
2087,
8,
277,
304,
267,
522,
275,
291,
14,
67,
14,
2087,
8,
277,
14,
1436,
12,
378,
9,
398,
3850,
2531,
277,
14,
719,
63,
889,
459,
637,
995,
522,
14,
719,
63,
889,
9,
267,
3850,
2531,
277,
14,
8090,
63,
2697,
12,
522,
14,
8090,
63,
2697,
9,
267,
3850,
2531,
277,
14,
354,
12,
522,
14,
354,
9,
267,
3850,
2531,
277,
14,
888,
459,
637,
995,
522,
14,
888,
9,
267,
3850,
2531,
277,
14,
929,
459,
637,
995,
522,
14,
929,
9,
267,
3850,
2531,
277,
14,
9808,
459,
637,
995,
522,
14,
9808,
9,
267,
3850,
2531,
277,
14,
24576,
939,
459,
637,
995,
522,
14,
24576,
939,
9,
267,
3850,
2531,
277,
14,
4946,
459,
637,
995,
522,
14,
4946,
9,
267,
3850,
2531,
277,
14,
7866,
459,
637,
995,
522,
14,
7866,
9,
421,
199,
533,
1379,
6733,
4486,
8,
2796,
14,
1746,
304,
272,
408,
1379,
1930,
367,
14122,
63,
86,
17,
63,
16,
63,
2087,
14,
6733,
4486,
272,
408,
339,
327,
16563,
63,
14747,
63
] |
[
1898,
334,
35,
9,
6029,
653,
711,
678,
23884,
2180,
436,
23884,
9339,
11098,
14,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
3,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
3,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
259,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
199,
3,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
199,
3,
6695,
26,
20849,
29,
20,
20105,
29,
20,
25966,
29,
20,
199,
199,
646,
2882,
199,
646,
2050,
199,
646,
3816,
199,
504,
11354,
14,
2537,
492,
627,
199,
504,
25494,
14,
15129,
14,
15129,
63,
86,
17,
63,
16,
63,
2087,
492,
627,
199,
504,
25494,
14,
15129,
14,
7343,
63,
3723,
492,
627,
199,
504,
25494,
14,
15129,
492,
14122,
63,
86,
17,
63,
16,
63,
2087,
199,
504,
25494,
14,
773,
492,
5552,
5598,
421,
199,
4947,
275,
2050,
14,
5572,
360,
396,
63,
15129,
63,
86,
709,
358,
421,
199,
533,
1379,
6733,
6678,
4313,
8,
2796,
14,
1746,
304,
272,
408,
1379,
1930,
367,
14122,
63,
86,
17,
63,
16,
63,
2087,
14,
6733,
6678,
4313,
272,
408,
339,
327,
16563,
63,
9791,
57,
63,
3657,
63,
6961,
63,
3027,
272,
327,
14597,
40,
22,
83,
975,
83,
8921,
8921,
8921,
7,
1396,
1844,
63,
889,
12,
12073,
63,
2697,
12,
536,
12,
1101,
12,
1174,
272,
327,
8540,
8230,
12,
19613,
939,
12,
3748,
12,
9104,
272,
1844,
63,
889,
275,
791,
1436,
356,
330,
1154,
1845,
23,
60,
88,
22,
66,
297,
283,
637,
356,
8155,
13440,
93,
272,
12073,
63,
2697,
275,
283,
2528,
26,
1477,
26,
1477,
26,
709,
26,
1165,
26,
1020,
7,
272,
536,
275,
330,
7,
354,
1370,
19996,
8,
975,
9,
272,
1101,
275,
791,
1436,
356,
330,
1154,
88,
1349,
60,
1774,
22,
60,
88,
24,
67,
60,
88,
2481,
297,
283,
637,
356,
26485,
10027,
1427,
1555,
93,
272,
1174,
275,
791,
1436,
356,
330,
1154,
88,
772,
60,
88,
1780,
60,
10272,
60,
1812,
25,
297,
283,
637,
356,
413,
17237,
11603,
11782,
93,
272,
8230,
275,
791,
1436,
356,
330,
1154,
1800,
25,
60,
1845,
24,
60,
88,
16,
65,
60,
88,
18,
66,
297,
283,
637,
356,
7294,
1400,
1229,
772,
1427,
93,
272,
19613,
939,
275,
791,
1436,
356,
330,
1154,
88,
2277,
60,
1774,
25,
60,
88,
23,
66,
60,
88,
2819,
297,
283,
637,
356,
3388,
821,
2260,
975,
2564,
93,
272,
3748,
275,
791,
1436,
356,
330,
1154,
88,
23,
69,
60,
88,
2182,
60,
88,
2333,
60,
10135,
297,
283,
637,
356,
499,
6708,
14781,
10721,
93,
272,
9104,
275,
791,
1436,
356,
330,
1154,
1800,
20,
60,
88,
21,
66,
60,
88,
24,
66,
60,
7887,
297,
283,
637,
356,
499,
2194,
1342,
2766,
15385,
93,
339,
4123,
275,
1844,
63,
889,
459,
1436,
418,
971,
267,
435,
5552,
5598,
14,
3088,
14,
505,
63,
475,
63,
1393,
8,
8090,
63,
2697,
9,
971,
267,
435,
536,
971,
267,
435,
1101,
459,
1436,
418,
971,
267,
435,
1174,
459,
1436,
418,
971,
267,
435,
8230,
459,
1436,
418,
971,
267,
435,
19613,
939,
459,
1436,
418,
971,
267,
435,
3748,
459,
1436,
418,
971,
267,
435,
9104,
459,
1436,
418,
339,
286,
275,
16563,
6678,
4313,
8,
719,
63,
889,
459,
637,
995,
673,
12073,
63,
2697,
12,
673,
536,
12,
673,
1101,
459,
637,
995,
673,
1174,
459,
637,
995,
673,
8230,
459,
637,
995,
673,
19613,
939,
459,
637,
995,
673,
3748,
459,
637,
995,
673,
9104,
459,
637,
1105,
339,
347,
3613,
8,
277,
304,
267,
986,
339,
347,
6766,
8,
277,
304,
267,
986,
339,
347,
511,
63,
826,
8,
277,
304,
267,
3850,
2531,
277,
14,
719,
63,
889,
459,
637,
995,
291,
14,
67,
14,
719,
63,
889,
9,
267,
3850,
2531,
277,
14,
8090,
63,
2697,
12,
291,
14,
67,
14,
8090,
63,
2697,
9,
267,
3850,
2531,
277,
14,
354,
12,
291,
14,
67,
14,
354,
9,
267,
3850,
2531,
277,
14,
888,
459,
637,
995,
291,
14,
67,
14,
888,
9,
267,
3850,
2531,
277,
14,
929,
459,
637,
995,
291,
14,
67,
14,
929,
9,
267,
3850,
2531,
277,
14,
9808,
459,
637,
995,
291,
14,
67,
14,
9808,
9,
267,
3850,
2531,
277,
14,
24576,
939,
459,
637,
995,
291,
14,
67,
14,
24576,
939,
9,
267,
3850,
2531,
277,
14,
4946,
459,
637,
995,
291,
14,
67,
14,
4946,
9,
267,
3850,
2531,
277,
14,
7866,
459,
637,
995,
291,
14,
67,
14,
7866,
9,
339,
347,
511,
63,
2087,
8,
277,
304,
267,
522,
275,
291,
14,
67,
14,
2087,
8,
277,
14,
1436,
12,
378,
9,
398,
3850,
2531,
277,
14,
719,
63,
889,
459,
637,
995,
522,
14,
719,
63,
889,
9,
267,
3850,
2531,
277,
14,
8090,
63,
2697,
12,
522,
14,
8090,
63,
2697,
9,
267,
3850,
2531,
277,
14,
354,
12,
522,
14,
354,
9,
267,
3850,
2531,
277,
14,
888,
459,
637,
995,
522,
14,
888,
9,
267,
3850,
2531,
277,
14,
929,
459,
637,
995,
522,
14,
929,
9,
267,
3850,
2531,
277,
14,
9808,
459,
637,
995,
522,
14,
9808,
9,
267,
3850,
2531,
277,
14,
24576,
939,
459,
637,
995,
522,
14,
24576,
939,
9,
267,
3850,
2531,
277,
14,
4946,
459,
637,
995,
522,
14,
4946,
9,
267,
3850,
2531,
277,
14,
7866,
459,
637,
995,
522,
14,
7866,
9,
421,
199,
533,
1379,
6733,
4486,
8,
2796,
14,
1746,
304,
272,
408,
1379,
1930,
367,
14122,
63,
86,
17,
63,
16,
63,
2087,
14,
6733,
4486,
272,
408,
339,
327,
16563,
63,
14747,
63,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
akash1808/nova_test_latest
|
nova/console/fake.py
|
114
|
1615
|
# Copyright (c) 2010 OpenStack Foundation
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
"""Fake ConsoleProxy driver for tests."""
class FakeConsoleProxy(object):
"""Fake ConsoleProxy driver."""
@property
def console_type(self):
return 'fake'
def setup_console(self, context, console):
"""Sets up actual proxies."""
pass
def teardown_console(self, context, console):
"""Tears down actual proxies."""
pass
def init_host(self):
"""Start up any config'ed consoles on start."""
pass
def generate_password(self, length=8):
"""Returns random console password."""
return 'fakepass'
def get_port(self, context):
"""Get available port for consoles that need one."""
return 5999
def fix_pool_password(self, password):
"""Trim password to length, and any other massaging."""
return password
def fix_console_password(self, password):
"""Trim password to length, and any other massaging."""
return password
|
apache-2.0
|
[
3,
1898,
334,
67,
9,
7129,
14260,
2752,
199,
3,
2900,
5924,
5702,
14,
199,
3,
199,
3,
259,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
1265,
1443,
199,
3,
259,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
2047,
1443,
3332,
199,
3,
259,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
260,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
259,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
259,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
2428,
199,
3,
259,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
1666,
314,
199,
3,
259,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
259,
1334,
314,
844,
14,
199,
199,
624,
8249,
19809,
4936,
5253,
367,
2295,
1041,
421,
199,
533,
7777,
9270,
4936,
8,
785,
304,
272,
408,
8249,
19809,
4936,
5253,
1041,
339,
768,
1829,
272,
347,
8559,
63,
466,
8,
277,
304,
267,
372,
283,
3183,
7,
339,
347,
3272,
63,
6614,
8,
277,
12,
1067,
12,
8559,
304,
267,
408,
9899,
1536,
3503,
14942,
1041,
267,
986,
339,
347,
17558,
63,
6614,
8,
277,
12,
1067,
12,
8559,
304,
267,
408,
52,
2210,
83,
3224,
3503,
14942,
1041,
267,
986,
339,
347,
4205,
63,
1102,
8,
277,
304,
267,
408,
3162,
1536,
1263,
1101,
7,
379,
406,
1152,
2978,
641,
1343,
1041,
267,
986,
339,
347,
3550,
63,
2060,
8,
277,
12,
2582,
29,
24,
304,
267,
408,
3407,
2196,
8559,
2505,
1041,
267,
372,
283,
3183,
1529,
7,
339,
347,
664,
63,
719,
8,
277,
12,
1067,
304,
267,
408,
1002,
2808,
1844,
367,
406,
1152,
2978,
626,
1929,
1373,
1041,
267,
372,
959,
5637,
339,
347,
5325,
63,
2293,
63,
2060,
8,
277,
12,
2505,
304,
267,
408,
31081,
2505,
370,
2582,
12,
436,
1263,
1163,
12250,
7407,
1041,
267,
372,
2505,
339,
347,
5325,
63,
6614,
63,
2060,
8,
277,
12,
2505,
304,
267,
408,
31081,
2505,
370,
2582,
12,
436,
1263,
1163,
12250,
7407,
1041,
267,
372,
2505,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1898,
334,
67,
9,
7129,
14260,
2752,
199,
3,
2900,
5924,
5702,
14,
199,
3,
199,
3,
259,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
1265,
1443,
199,
3,
259,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
2047,
1443,
3332,
199,
3,
259,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
260,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
259,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
259,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
2428,
199,
3,
259,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
1666,
314,
199,
3,
259,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
259,
1334,
314,
844,
14,
199,
199,
624,
8249,
19809,
4936,
5253,
367,
2295,
1041,
421,
199,
533,
7777,
9270,
4936,
8,
785,
304,
272,
408,
8249,
19809,
4936,
5253,
1041,
339,
768,
1829,
272,
347,
8559,
63,
466,
8,
277,
304,
267,
372,
283,
3183,
7,
339,
347,
3272,
63,
6614,
8,
277,
12,
1067,
12,
8559,
304,
267,
408,
9899,
1536,
3503,
14942,
1041,
267,
986,
339,
347,
17558,
63,
6614,
8,
277,
12,
1067,
12,
8559,
304,
267,
408,
52,
2210,
83,
3224,
3503,
14942,
1041,
267,
986,
339,
347,
4205,
63,
1102,
8,
277,
304,
267,
408,
3162,
1536,
1263,
1101,
7,
379,
406,
1152,
2978,
641,
1343,
1041,
267,
986,
339,
347,
3550,
63,
2060,
8,
277,
12,
2582,
29,
24,
304,
267,
408,
3407,
2196,
8559,
2505,
1041,
267,
372,
283,
3183,
1529,
7,
339,
347,
664,
63,
719,
8,
277,
12,
1067,
304,
267,
408,
1002,
2808,
1844,
367,
406,
1152,
2978,
626,
1929,
1373,
1041,
267,
372,
959,
5637,
339,
347,
5325,
63,
2293,
63,
2060,
8,
277,
12,
2505,
304,
267,
408,
31081,
2505,
370,
2582,
12,
436,
1263,
1163,
12250,
7407,
1041,
267,
372,
2505,
339,
347,
5325,
63,
6614,
63,
2060,
8,
277,
12,
2505,
304,
267,
408,
31081,
2505,
370,
2582,
12,
436,
1263,
1163,
12250,
7407,
1041,
267,
372,
2505,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
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ake/lettercounter
|
django-norel-env/lib/python2.7/site-packages/django/contrib/admin/bin/compress.py
|
193
|
1958
|
#!/usr/bin/env python
import os
import optparse
import subprocess
import sys
js_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'static', 'admin', 'js')
def main():
usage = "usage: %prog [file1..fileN]"
description = """With no file paths given this script will automatically
compress all jQuery-based files of the admin app. Requires the Google Closure
Compiler library and Java version 6 or later."""
parser = optparse.OptionParser(usage, description=description)
parser.add_option("-c", dest="compiler", default="~/bin/compiler.jar",
help="path to Closure Compiler jar file")
parser.add_option("-v", "--verbose",
action="store_true", dest="verbose")
parser.add_option("-q", "--quiet",
action="store_false", dest="verbose")
(options, args) = parser.parse_args()
compiler = os.path.expanduser(options.compiler)
if not os.path.exists(compiler):
sys.exit("Google Closure compiler jar file %s not found. Please use the -c option to specify the path." % compiler)
if not args:
if options.verbose:
sys.stdout.write("No filenames given; defaulting to admin scripts\n")
args = [os.path.join(js_path, f) for f in [
"actions.js", "collapse.js", "inlines.js", "prepopulate.js"]]
for arg in args:
if not arg.endswith(".js"):
arg = arg + ".js"
to_compress = os.path.expanduser(arg)
if os.path.exists(to_compress):
to_compress_min = "%s.min.js" % "".join(arg.rsplit(".js"))
cmd = "java -jar %s --js %s --js_output_file %s" % (compiler, to_compress, to_compress_min)
if options.verbose:
sys.stdout.write("Running: %s\n" % cmd)
subprocess.call(cmd.split())
else:
sys.stdout.write("File %s not found. Sure it exists?\n" % to_compress)
if __name__ == '__main__':
main()
|
mit
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
646,
747,
199,
646,
8691,
199,
646,
3873,
199,
646,
984,
199,
199,
3596,
63,
515,
275,
747,
14,
515,
14,
904,
8,
736,
14,
515,
14,
3475,
8,
736,
14,
515,
14,
3475,
3460,
493,
22159,
283,
1986,
297,
283,
2113,
297,
283,
3596,
358,
199,
199,
318,
2446,
837,
272,
4503,
275,
298,
3807,
26,
450,
6595,
359,
493,
17,
703,
493,
46,
8480,
272,
1369,
275,
408,
3007,
949,
570,
3792,
1627,
642,
2884,
911,
5847,
199,
6447,
1006,
1335,
3227,
13,
6788,
1584,
402,
314,
4628,
1145,
14,
15127,
314,
4475,
5980,
3253,
199,
9131,
3555,
436,
9586,
1015,
1227,
503,
2945,
1041,
272,
1798,
275,
8691,
14,
14553,
8,
3807,
12,
1369,
29,
1802,
9,
272,
1798,
14,
525,
63,
1422,
6096,
67,
401,
2053,
628,
5772,
401,
849,
628,
94,
15,
1393,
15,
5772,
14,
7338,
401,
1993,
1720,
628,
515,
370,
5980,
3253,
27154,
16290,
570,
531,
272,
1798,
14,
525,
63,
1422,
6096,
86,
401,
4320,
3832,
401,
1993,
1595,
628,
1617,
63,
2052,
401,
2053,
628,
3832,
531,
272,
1798,
14,
525,
63,
1422,
6096,
81,
401,
4320,
10243,
401,
1993,
1595,
628,
1617,
63,
3910,
401,
2053,
628,
3832,
531,
272,
334,
1419,
12,
1249,
9,
275,
1798,
14,
1122,
63,
589,
342,
339,
6365,
275,
747,
14,
515,
14,
12131,
8,
1419,
14,
5772,
9,
272,
340,
440,
747,
14,
515,
14,
2444,
8,
5772,
304,
267,
984,
14,
2224,
480,
13266,
5980,
3253,
6365,
16290,
570,
450,
83,
440,
1911,
14,
7754,
675,
314,
446,
67,
945,
370,
4165,
314,
931,
2122,
450,
6365,
9,
339,
340,
440,
1249,
26,
267,
340,
1511,
14,
3832,
26,
288,
984,
14,
2703,
14,
952,
480,
1944,
6203,
1627,
27,
849,
316,
370,
4628,
10554,
60,
78,
531,
267,
1249,
275,
359,
736,
14,
515,
14,
904,
8,
3596,
63,
515,
12,
289,
9,
367,
289,
315,
359,
288,
298,
3723,
14,
3596,
401,
298,
20681,
14,
3596,
401,
298,
26739,
14,
3596,
401,
298,
657,
13817,
14,
3596,
15261,
339,
367,
1680,
315,
1249,
26,
267,
340,
440,
1680,
14,
4130,
9520,
3596,
2349,
288,
1680,
275,
1680,
435,
3680,
3596,
2,
267,
370,
63,
6447,
275,
747,
14,
515,
14,
12131,
8,
1273,
9,
267,
340,
747,
14,
515,
14,
2444,
8,
475,
63,
6447,
304,
288,
370,
63,
6447,
63,
827,
275,
2071,
83,
14,
827,
14,
3596,
2,
450,
10587,
904,
8,
1273,
14,
13490,
9520,
3596,
2237,
288,
2088,
275,
298,
6138,
446,
7338,
450,
83,
1553,
3596,
450,
83,
1553,
3596,
63,
1199,
63,
493,
450,
83,
2,
450,
334,
5772,
12,
370,
63,
6447,
12,
370,
63,
6447,
63,
827,
9,
288,
340,
1511,
14,
3832,
26,
355,
984,
14,
2703,
14,
952,
480,
9602,
26,
450,
83,
60,
78,
2,
450,
2088,
9,
288,
3873,
14,
1250,
8,
1760,
14,
1294,
1012,
267,
587,
26,
288,
984,
14,
2703,
14,
952,
480,
1173,
450,
83,
440,
1911,
14,
428,
608,
652,
3495,
8995,
78,
2,
450,
370,
63,
6447,
9,
199,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
2446,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
646,
747,
199,
646,
8691,
199,
646,
3873,
199,
646,
984,
199,
199,
3596,
63,
515,
275,
747,
14,
515,
14,
904,
8,
736,
14,
515,
14,
3475,
8,
736,
14,
515,
14,
3475,
3460,
493,
22159,
283,
1986,
297,
283,
2113,
297,
283,
3596,
358,
199,
199,
318,
2446,
837,
272,
4503,
275,
298,
3807,
26,
450,
6595,
359,
493,
17,
703,
493,
46,
8480,
272,
1369,
275,
408,
3007,
949,
570,
3792,
1627,
642,
2884,
911,
5847,
199,
6447,
1006,
1335,
3227,
13,
6788,
1584,
402,
314,
4628,
1145,
14,
15127,
314,
4475,
5980,
3253,
199,
9131,
3555,
436,
9586,
1015,
1227,
503,
2945,
1041,
272,
1798,
275,
8691,
14,
14553,
8,
3807,
12,
1369,
29,
1802,
9,
272,
1798,
14,
525,
63,
1422,
6096,
67,
401,
2053,
628,
5772,
401,
849,
628,
94,
15,
1393,
15,
5772,
14,
7338,
401,
1993,
1720,
628,
515,
370,
5980,
3253,
27154,
16290,
570,
531,
272,
1798,
14,
525,
63,
1422,
6096,
86,
401,
4320,
3832,
401,
1993,
1595,
628,
1617,
63,
2052,
401,
2053,
628,
3832,
531,
272,
1798,
14,
525,
63,
1422,
6096,
81,
401,
4320,
10243,
401,
1993,
1595,
628,
1617,
63,
3910,
401,
2053,
628,
3832,
531,
272,
334,
1419,
12,
1249,
9,
275,
1798,
14,
1122,
63,
589,
342,
339,
6365,
275,
747,
14,
515,
14,
12131,
8,
1419,
14,
5772,
9,
272,
340,
440,
747,
14,
515,
14,
2444,
8,
5772,
304,
267,
984,
14,
2224,
480,
13266,
5980,
3253,
6365,
16290,
570,
450,
83,
440,
1911,
14,
7754,
675,
314,
446,
67,
945,
370,
4165,
314,
931,
2122,
450,
6365,
9,
339,
340,
440,
1249,
26,
267,
340,
1511,
14,
3832,
26,
288,
984,
14,
2703,
14,
952,
480,
1944,
6203,
1627,
27,
849,
316,
370,
4628,
10554,
60,
78,
531,
267,
1249,
275,
359,
736,
14,
515,
14,
904,
8,
3596,
63,
515,
12,
289,
9,
367,
289,
315,
359,
288,
298,
3723,
14,
3596,
401,
298,
20681,
14,
3596,
401,
298,
26739,
14,
3596,
401,
298,
657,
13817,
14,
3596,
15261,
339,
367,
1680,
315,
1249,
26,
267,
340,
440,
1680,
14,
4130,
9520,
3596,
2349,
288,
1680,
275,
1680,
435,
3680,
3596,
2,
267,
370,
63,
6447,
275,
747,
14,
515,
14,
12131,
8,
1273,
9,
267,
340,
747,
14,
515,
14,
2444,
8,
475,
63,
6447,
304,
288,
370,
63,
6447,
63,
827,
275,
2071,
83,
14,
827,
14,
3596,
2,
450,
10587,
904,
8,
1273,
14,
13490,
9520,
3596,
2237,
288,
2088,
275,
298,
6138,
446,
7338,
450,
83,
1553,
3596,
450,
83,
1553,
3596,
63,
1199,
63,
493,
450,
83,
2,
450,
334,
5772,
12,
370,
63,
6447,
12,
370,
63,
6447,
63,
827,
9,
288,
340,
1511,
14,
3832,
26,
355,
984,
14,
2703,
14,
952,
480,
9602,
26,
450,
83,
60,
78,
2,
450,
2088,
9,
288,
3873,
14,
1250,
8,
1760,
14,
1294,
1012,
267,
587,
26,
288,
984,
14,
2703,
14,
952,
480,
1173,
450,
83,
440,
1911,
14,
428,
608,
652,
3495,
8995,
78,
2,
450,
370,
63,
6447,
9,
199,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
2446,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32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0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
sergio-incaser/odoo
|
addons/bus/bus.py
|
325
|
7324
|
# -*- coding: utf-8 -*-
import datetime
import json
import logging
import select
import threading
import time
import random
import simplejson
import openerp
from openerp.osv import osv, fields
from openerp.http import request
from openerp.tools.misc import DEFAULT_SERVER_DATETIME_FORMAT
_logger = logging.getLogger(__name__)
TIMEOUT = 50
#----------------------------------------------------------
# Bus
#----------------------------------------------------------
def json_dump(v):
return simplejson.dumps(v, separators=(',', ':'))
def hashable(key):
if isinstance(key, list):
key = tuple(key)
return key
class ImBus(osv.Model):
_name = 'bus.bus'
_columns = {
'id' : fields.integer('Id'),
'create_date' : fields.datetime('Create date'),
'channel' : fields.char('Channel'),
'message' : fields.char('Message'),
}
def gc(self, cr, uid):
timeout_ago = datetime.datetime.utcnow()-datetime.timedelta(seconds=TIMEOUT*2)
domain = [('create_date', '<', timeout_ago.strftime(DEFAULT_SERVER_DATETIME_FORMAT))]
ids = self.search(cr, openerp.SUPERUSER_ID, domain)
self.unlink(cr, openerp.SUPERUSER_ID, ids)
def sendmany(self, cr, uid, notifications):
channels = set()
for channel, message in notifications:
channels.add(channel)
values = {
"channel" : json_dump(channel),
"message" : json_dump(message)
}
self.pool['bus.bus'].create(cr, openerp.SUPERUSER_ID, values)
cr.commit()
if random.random() < 0.01:
self.gc(cr, uid)
if channels:
with openerp.sql_db.db_connect('postgres').cursor() as cr2:
cr2.execute("notify imbus, %s", (json_dump(list(channels)),))
def sendone(self, cr, uid, channel, message):
self.sendmany(cr, uid, [[channel, message]])
def poll(self, cr, uid, channels, last=0):
# first poll return the notification in the 'buffer'
if last == 0:
timeout_ago = datetime.datetime.utcnow()-datetime.timedelta(seconds=TIMEOUT)
domain = [('create_date', '>', timeout_ago.strftime(DEFAULT_SERVER_DATETIME_FORMAT))]
else:
# else returns the unread notifications
domain = [('id','>',last)]
channels = [json_dump(c) for c in channels]
domain.append(('channel','in',channels))
notifications = self.search_read(cr, openerp.SUPERUSER_ID, domain)
return [{"id":notif["id"], "channel": simplejson.loads(notif["channel"]), "message":simplejson.loads(notif["message"])} for notif in notifications]
class ImDispatch(object):
def __init__(self):
self.channels = {}
def poll(self, dbname, channels, last, timeout=TIMEOUT):
# Dont hang ctrl-c for a poll request, we need to bypass private
# attribute access because we dont know before starting the thread that
# it will handle a longpolling request
if not openerp.evented:
current = threading.current_thread()
current._Thread__daemonic = True
# rename the thread to avoid tests waiting for a longpolling
current.setName("openerp.longpolling.request.%s" % current.ident)
registry = openerp.registry(dbname)
# immediatly returns if past notifications exist
with registry.cursor() as cr:
notifications = registry['bus.bus'].poll(cr, openerp.SUPERUSER_ID, channels, last)
# or wait for future ones
if not notifications:
event = self.Event()
for c in channels:
self.channels.setdefault(hashable(c), []).append(event)
try:
event.wait(timeout=timeout)
with registry.cursor() as cr:
notifications = registry['bus.bus'].poll(cr, openerp.SUPERUSER_ID, channels, last)
except Exception:
# timeout
pass
return notifications
def loop(self):
""" Dispatch postgres notifications to the relevant polling threads/greenlets """
_logger.info("Bus.loop listen imbus on db postgres")
with openerp.sql_db.db_connect('postgres').cursor() as cr:
conn = cr._cnx
cr.execute("listen imbus")
cr.commit();
while True:
if select.select([conn], [], [], TIMEOUT) == ([],[],[]):
pass
else:
conn.poll()
channels = []
while conn.notifies:
channels.extend(json.loads(conn.notifies.pop().payload))
# dispatch to local threads/greenlets
events = set()
for c in channels:
events.update(self.channels.pop(hashable(c),[]))
for e in events:
e.set()
def run(self):
while True:
try:
self.loop()
except Exception, e:
_logger.exception("Bus.loop error, sleep and retry")
time.sleep(TIMEOUT)
def start(self):
if openerp.evented:
# gevent mode
import gevent
self.Event = gevent.event.Event
gevent.spawn(self.run)
elif openerp.multi_process:
# disabled in prefork mode
return
else:
# threaded mode
self.Event = threading.Event
t = threading.Thread(name="%s.Bus" % __name__, target=self.run)
t.daemon = True
t.start()
return self
dispatch = ImDispatch().start()
#----------------------------------------------------------
# Controller
#----------------------------------------------------------
class Controller(openerp.http.Controller):
""" Examples:
openerp.jsonRpc('/longpolling/poll','call',{"channels":["c1"],last:0}).then(function(r){console.log(r)});
openerp.jsonRpc('/longpolling/send','call',{"channel":"c1","message":"m1"});
openerp.jsonRpc('/longpolling/send','call',{"channel":"c2","message":"m2"});
"""
@openerp.http.route('/longpolling/send', type="json", auth="public")
def send(self, channel, message):
if not isinstance(channel, basestring):
raise Exception("bus.Bus only string channels are allowed.")
registry, cr, uid, context = request.registry, request.cr, request.session.uid, request.context
return registry['bus.bus'].sendone(cr, uid, channel, message)
# override to add channels
def _poll(self, dbname, channels, last, options):
request.cr.close()
request._cr = None
return dispatch.poll(dbname, channels, last)
@openerp.http.route('/longpolling/poll', type="json", auth="public")
def poll(self, channels, last, options=None):
if options is None:
options = {}
if not dispatch:
raise Exception("bus.Bus unavailable")
if [c for c in channels if not isinstance(c, basestring)]:
print channels
raise Exception("bus.Bus only string channels are allowed.")
return self._poll(request.db, channels, last, options)
# vim:et:
|
agpl-3.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
646,
2197,
199,
646,
2022,
199,
646,
2050,
199,
646,
3504,
199,
646,
5796,
199,
646,
900,
199,
646,
2196,
199,
199,
646,
13804,
199,
646,
5166,
199,
504,
5166,
14,
4795,
492,
9506,
12,
1504,
199,
504,
5166,
14,
1014,
492,
1056,
199,
504,
5166,
14,
2537,
14,
9923,
492,
6186,
63,
6613,
63,
12488,
63,
4807,
199,
199,
63,
2921,
275,
2050,
14,
5572,
3460,
354,
3368,
199,
199,
8899,
275,
5238,
199,
199,
30346,
199,
3,
18573,
199,
30346,
199,
318,
2022,
63,
2724,
8,
86,
304,
272,
372,
13804,
14,
4180,
8,
86,
12,
17658,
2687,
23324,
7596,
1333,
199,
199,
318,
21197,
8,
498,
304,
272,
340,
1228,
8,
498,
12,
769,
304,
267,
790,
275,
2008,
8,
498,
9,
272,
372,
790,
199,
199,
533,
473,
77,
12106,
8,
4795,
14,
1685,
304,
272,
485,
354,
275,
283,
5610,
14,
5610,
7,
272,
485,
3406,
275,
469,
267,
283,
344,
7,
520,
1504,
14,
4115,
360,
1304,
659,
267,
283,
981,
63,
602,
7,
520,
1504,
14,
2083,
360,
2499,
1434,
659,
267,
283,
2775,
7,
520,
1504,
14,
1560,
360,
5358,
659,
267,
283,
1188,
7,
520,
1504,
14,
1560,
360,
2209,
659,
272,
789,
339,
347,
9486,
8,
277,
12,
2467,
12,
1747,
304,
267,
2653,
63,
14315,
275,
2197,
14,
2083,
14,
10779,
22251,
2083,
14,
7473,
8,
4515,
29,
8899,
10,
18,
9,
267,
2881,
275,
4274,
981,
63,
602,
297,
30243,
2653,
63,
14315,
14,
6205,
8,
3472,
63,
6613,
63,
12488,
63,
4807,
10524,
267,
2762,
221,
275,
291,
14,
1733,
8,
1556,
12,
5166,
14,
20710,
63,
998,
12,
2881,
9,
267,
291,
14,
7162,
8,
1556,
12,
5166,
14,
20710,
63,
998,
12,
2762,
9,
339,
347,
3222,
3479,
8,
277,
12,
2467,
12,
1747,
12,
13116,
304,
267,
9245,
275,
663,
342,
267,
367,
3623,
12,
1245,
315,
13116,
26,
288,
9245,
14,
525,
8,
2775,
9,
288,
1338,
275,
469,
355,
298,
2775,
2,
520,
2022,
63,
2724,
8,
2775,
395,
355,
298,
1188,
2,
520,
2022,
63,
2724,
8,
1188,
9,
288,
789,
288,
291,
14,
2293,
459,
5610,
14,
5610,
2278,
981,
8,
1556,
12,
5166,
14,
20710,
63,
998,
12,
1338,
9,
288,
2467,
14,
3543,
342,
288,
340,
2196,
14,
2355,
342,
665,
378,
14,
614,
26,
355,
291,
14,
9493,
8,
1556,
12,
1747,
9,
267,
340,
9245,
26,
288,
543,
5166,
14,
3009,
63,
697,
14,
697,
63,
2242,
360,
10675,
1959,
3937,
342,
465,
2467,
18,
26,
355,
2467,
18,
14,
2526,
480,
6814,
3416,
5610,
12,
450,
83,
401,
334,
1001,
63,
2724,
8,
513,
8,
6324,
1826,
430,
339,
347,
3222,
368,
8,
277,
12,
2467,
12,
1747,
12,
3623,
12,
1245,
304,
267,
291,
14,
2254,
3479,
8,
1556,
12,
1747,
12,
3474,
2775,
12,
1245,
3934,
339,
347,
11271,
8,
277,
12,
2467,
12,
1747,
12,
9245,
12,
2061,
29,
16,
304,
267,
327,
1642,
11271,
372,
314,
6955,
315,
314,
283,
2738,
7,
267,
340,
2061,
508,
378,
26,
288,
2653,
63,
14315,
275,
2197,
14,
2083,
14,
10779,
22251,
2083,
14,
7473,
8,
4515,
29,
8899,
9,
288,
2881,
275,
4274,
981,
63,
602,
297,
26120,
2653,
63,
14315,
14,
6205,
8,
3472,
63,
6613,
63,
12488,
63,
4807,
10524,
267,
587,
26,
288,
327,
587,
2529,
314,
625,
739,
13116,
288,
2881,
275,
4274,
344,
1673,
4206,
2019,
1874,
267,
9245,
275,
359,
1001,
63,
2724,
8,
67,
9,
367,
286,
315,
9245,
61,
267,
2881,
14,
740,
4725,
2775,
1673,
262,
297,
6324,
430,
267,
13116,
275,
291,
14,
1733,
63,
739,
8,
1556,
12,
5166,
14,
20710,
63,
998,
12,
2881,
9,
267,
372,
16870,
344,
582,
27795,
905,
344,
2255,
298,
2775,
582,
13804,
14,
3640,
8,
27795,
905,
2775,
10252,
298,
1188,
582,
4129,
1001,
14,
3640,
8,
27795,
905,
1188,
3135,
93,
367,
32081,
315,
13116,
61,
199,
199,
533,
473,
77,
20628,
8,
785,
304,
272,
347,
636,
826,
721,
277,
304,
267,
291,
14,
6324,
275,
1052,
339,
347,
11271,
8,
277,
12,
21842,
12,
9245,
12,
2061,
12,
2653,
29,
8899,
304,
267,
327,
577,
1888,
30084,
15427,
13,
67,
367,
282,
11271,
1056,
12,
781,
1929,
370,
21115,
5726,
267,
327,
2225,
2879,
2952,
781,
21542,
5715,
2544,
6617,
314,
2462,
626,
267,
327,
652,
911,
2429,
282,
1846,
17154,
1056,
267,
340,
440,
5166,
14,
12056,
471,
26,
288,
1453,
275,
5796,
14,
1818,
63,
2671,
342,
288,
1453,
423,
4436,
363,
10824,
530,
275,
715,
288,
327,
11441,
314,
2462,
370,
5126,
2295,
10923,
367,
282,
1846,
17154,
288,
1453,
14,
18347,
480,
11267,
14,
2809,
17154,
14,
1069,
4111,
83,
2,
450,
1453,
14,
5425,
9,
398,
7086,
275,
5166,
14,
5189,
8,
13238,
9,
398,
327,
3416,
3700,
292,
590,
2529,
340,
13541,
13116,
2187,
267,
543,
7086,
14,
3937,
342,
465,
2467,
26,
288,
13116,
275,
7086,
459,
5610,
14,
5610,
2278,
6843,
8,
1556,
12,
5166,
14,
20710,
63,
998,
12,
9245,
12,
2061,
9,
267,
327,
503,
3618,
367,
6466,
7869,
267,
340,
440,
13116,
26,
288,
1566,
275,
291,
14,
2390,
342,
288,
367,
286,
315,
9245,
26,
355,
291,
14,
6324,
14,
5486,
8,
24596,
8,
67,
395,
15364,
740,
8,
1430,
9,
288,
862,
26,
355,
1566,
14,
2573,
8,
2593,
29,
2593,
9,
355,
543,
7086,
14,
3937,
342,
465,
2467,
26,
490,
13116,
275,
7086,
459,
5610,
14,
5610,
2278,
6843,
8,
1556,
12,
5166,
14,
20710,
63,
998,
12,
9245,
12,
2061,
9,
288,
871,
2186,
26,
355,
327,
2653,
355,
986,
267,
372,
13116,
339,
347,
4438,
8,
277,
304,
267,
408,
28626,
19533,
13116,
370,
314,
12082,
12353,
7183,
15,
7731,
16537,
408,
267,
485,
2921,
14,
815,
480,
12106,
14,
3813,
6938,
3416,
5610,
641,
1592,
19533,
531,
267,
543,
5166,
14,
3009,
63,
697,
14,
697,
63,
2242,
360,
10675,
1959,
3937,
342,
465,
2467,
26,
288,
2557,
275,
2467,
423,
6413,
88,
288,
2467,
14,
2526,
480,
5859,
3416,
5610,
531,
288,
2467,
14,
3543,
7303,
288,
1830
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
646,
2197,
199,
646,
2022,
199,
646,
2050,
199,
646,
3504,
199,
646,
5796,
199,
646,
900,
199,
646,
2196,
199,
199,
646,
13804,
199,
646,
5166,
199,
504,
5166,
14,
4795,
492,
9506,
12,
1504,
199,
504,
5166,
14,
1014,
492,
1056,
199,
504,
5166,
14,
2537,
14,
9923,
492,
6186,
63,
6613,
63,
12488,
63,
4807,
199,
199,
63,
2921,
275,
2050,
14,
5572,
3460,
354,
3368,
199,
199,
8899,
275,
5238,
199,
199,
30346,
199,
3,
18573,
199,
30346,
199,
318,
2022,
63,
2724,
8,
86,
304,
272,
372,
13804,
14,
4180,
8,
86,
12,
17658,
2687,
23324,
7596,
1333,
199,
199,
318,
21197,
8,
498,
304,
272,
340,
1228,
8,
498,
12,
769,
304,
267,
790,
275,
2008,
8,
498,
9,
272,
372,
790,
199,
199,
533,
473,
77,
12106,
8,
4795,
14,
1685,
304,
272,
485,
354,
275,
283,
5610,
14,
5610,
7,
272,
485,
3406,
275,
469,
267,
283,
344,
7,
520,
1504,
14,
4115,
360,
1304,
659,
267,
283,
981,
63,
602,
7,
520,
1504,
14,
2083,
360,
2499,
1434,
659,
267,
283,
2775,
7,
520,
1504,
14,
1560,
360,
5358,
659,
267,
283,
1188,
7,
520,
1504,
14,
1560,
360,
2209,
659,
272,
789,
339,
347,
9486,
8,
277,
12,
2467,
12,
1747,
304,
267,
2653,
63,
14315,
275,
2197,
14,
2083,
14,
10779,
22251,
2083,
14,
7473,
8,
4515,
29,
8899,
10,
18,
9,
267,
2881,
275,
4274,
981,
63,
602,
297,
30243,
2653,
63,
14315,
14,
6205,
8,
3472,
63,
6613,
63,
12488,
63,
4807,
10524,
267,
2762,
221,
275,
291,
14,
1733,
8,
1556,
12,
5166,
14,
20710,
63,
998,
12,
2881,
9,
267,
291,
14,
7162,
8,
1556,
12,
5166,
14,
20710,
63,
998,
12,
2762,
9,
339,
347,
3222,
3479,
8,
277,
12,
2467,
12,
1747,
12,
13116,
304,
267,
9245,
275,
663,
342,
267,
367,
3623,
12,
1245,
315,
13116,
26,
288,
9245,
14,
525,
8,
2775,
9,
288,
1338,
275,
469,
355,
298,
2775,
2,
520,
2022,
63,
2724,
8,
2775,
395,
355,
298,
1188,
2,
520,
2022,
63,
2724,
8,
1188,
9,
288,
789,
288,
291,
14,
2293,
459,
5610,
14,
5610,
2278,
981,
8,
1556,
12,
5166,
14,
20710,
63,
998,
12,
1338,
9,
288,
2467,
14,
3543,
342,
288,
340,
2196,
14,
2355,
342,
665,
378,
14,
614,
26,
355,
291,
14,
9493,
8,
1556,
12,
1747,
9,
267,
340,
9245,
26,
288,
543,
5166,
14,
3009,
63,
697,
14,
697,
63,
2242,
360,
10675,
1959,
3937,
342,
465,
2467,
18,
26,
355,
2467,
18,
14,
2526,
480,
6814,
3416,
5610,
12,
450,
83,
401,
334,
1001,
63,
2724,
8,
513,
8,
6324,
1826,
430,
339,
347,
3222,
368,
8,
277,
12,
2467,
12,
1747,
12,
3623,
12,
1245,
304,
267,
291,
14,
2254,
3479,
8,
1556,
12,
1747,
12,
3474,
2775,
12,
1245,
3934,
339,
347,
11271,
8,
277,
12,
2467,
12,
1747,
12,
9245,
12,
2061,
29,
16,
304,
267,
327,
1642,
11271,
372,
314,
6955,
315,
314,
283,
2738,
7,
267,
340,
2061,
508,
378,
26,
288,
2653,
63,
14315,
275,
2197,
14,
2083,
14,
10779,
22251,
2083,
14,
7473,
8,
4515,
29,
8899,
9,
288,
2881,
275,
4274,
981,
63,
602,
297,
26120,
2653,
63,
14315,
14,
6205,
8,
3472,
63,
6613,
63,
12488,
63,
4807,
10524,
267,
587,
26,
288,
327,
587,
2529,
314,
625,
739,
13116,
288,
2881,
275,
4274,
344,
1673,
4206,
2019,
1874,
267,
9245,
275,
359,
1001,
63,
2724,
8,
67,
9,
367,
286,
315,
9245,
61,
267,
2881,
14,
740,
4725,
2775,
1673,
262,
297,
6324,
430,
267,
13116,
275,
291,
14,
1733,
63,
739,
8,
1556,
12,
5166,
14,
20710,
63,
998,
12,
2881,
9,
267,
372,
16870,
344,
582,
27795,
905,
344,
2255,
298,
2775,
582,
13804,
14,
3640,
8,
27795,
905,
2775,
10252,
298,
1188,
582,
4129,
1001,
14,
3640,
8,
27795,
905,
1188,
3135,
93,
367,
32081,
315,
13116,
61,
199,
199,
533,
473,
77,
20628,
8,
785,
304,
272,
347,
636,
826,
721,
277,
304,
267,
291,
14,
6324,
275,
1052,
339,
347,
11271,
8,
277,
12,
21842,
12,
9245,
12,
2061,
12,
2653,
29,
8899,
304,
267,
327,
577,
1888,
30084,
15427,
13,
67,
367,
282,
11271,
1056,
12,
781,
1929,
370,
21115,
5726,
267,
327,
2225,
2879,
2952,
781,
21542,
5715,
2544,
6617,
314,
2462,
626,
267,
327,
652,
911,
2429,
282,
1846,
17154,
1056,
267,
340,
440,
5166,
14,
12056,
471,
26,
288,
1453,
275,
5796,
14,
1818,
63,
2671,
342,
288,
1453,
423,
4436,
363,
10824,
530,
275,
715,
288,
327,
11441,
314,
2462,
370,
5126,
2295,
10923,
367,
282,
1846,
17154,
288,
1453,
14,
18347,
480,
11267,
14,
2809,
17154,
14,
1069,
4111,
83,
2,
450,
1453,
14,
5425,
9,
398,
7086,
275,
5166,
14,
5189,
8,
13238,
9,
398,
327,
3416,
3700,
292,
590,
2529,
340,
13541,
13116,
2187,
267,
543,
7086,
14,
3937,
342,
465,
2467,
26,
288,
13116,
275,
7086,
459,
5610,
14,
5610,
2278,
6843,
8,
1556,
12,
5166,
14,
20710,
63,
998,
12,
9245,
12,
2061,
9,
267,
327,
503,
3618,
367,
6466,
7869,
267,
340,
440,
13116,
26,
288,
1566,
275,
291,
14,
2390,
342,
288,
367,
286,
315,
9245,
26,
355,
291,
14,
6324,
14,
5486,
8,
24596,
8,
67,
395,
15364,
740,
8,
1430,
9,
288,
862,
26,
355,
1566,
14,
2573,
8,
2593,
29,
2593,
9,
355,
543,
7086,
14,
3937,
342,
465,
2467,
26,
490,
13116,
275,
7086,
459,
5610,
14,
5610,
2278,
6843,
8,
1556,
12,
5166,
14,
20710,
63,
998,
12,
9245,
12,
2061,
9,
288,
871,
2186,
26,
355,
327,
2653,
355,
986,
267,
372,
13116,
339,
347,
4438,
8,
277,
304,
267,
408,
28626,
19533,
13116,
370,
314,
12082,
12353,
7183,
15,
7731,
16537,
408,
267,
485,
2921,
14,
815,
480,
12106,
14,
3813,
6938,
3416,
5610,
641,
1592,
19533,
531,
267,
543,
5166,
14,
3009,
63,
697,
14,
697,
63,
2242,
360,
10675,
1959,
3937,
342,
465,
2467,
26,
288,
2557,
275,
2467,
423,
6413,
88,
288,
2467,
14,
2526,
480,
5859,
3416,
5610,
531,
288,
2467,
14,
3543,
7303,
288,
1830,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
onyx-intl/ak98_kernel
|
scripts/tracing/draw_functrace.py
|
14676
|
3560
|
#!/usr/bin/python
"""
Copyright 2008 (c) Frederic Weisbecker <fweisbec@gmail.com>
Licensed under the terms of the GNU GPL License version 2
This script parses a trace provided by the function tracer in
kernel/trace/trace_functions.c
The resulted trace is processed into a tree to produce a more human
view of the call stack by drawing textual but hierarchical tree of
calls. Only the functions's names and the the call time are provided.
Usage:
Be sure that you have CONFIG_FUNCTION_TRACER
# mount -t debugfs nodev /sys/kernel/debug
# echo function > /sys/kernel/debug/tracing/current_tracer
$ cat /sys/kernel/debug/tracing/trace_pipe > ~/raw_trace_func
Wait some times but not too much, the script is a bit slow.
Break the pipe (Ctrl + Z)
$ scripts/draw_functrace.py < raw_trace_func > draw_functrace
Then you have your drawn trace in draw_functrace
"""
import sys, re
class CallTree:
""" This class provides a tree representation of the functions
call stack. If a function has no parent in the kernel (interrupt,
syscall, kernel thread...) then it is attached to a virtual parent
called ROOT.
"""
ROOT = None
def __init__(self, func, time = None, parent = None):
self._func = func
self._time = time
if parent is None:
self._parent = CallTree.ROOT
else:
self._parent = parent
self._children = []
def calls(self, func, calltime):
""" If a function calls another one, call this method to insert it
into the tree at the appropriate place.
@return: A reference to the newly created child node.
"""
child = CallTree(func, calltime, self)
self._children.append(child)
return child
def getParent(self, func):
""" Retrieve the last parent of the current node that
has the name given by func. If this function is not
on a parent, then create it as new child of root
@return: A reference to the parent.
"""
tree = self
while tree != CallTree.ROOT and tree._func != func:
tree = tree._parent
if tree == CallTree.ROOT:
child = CallTree.ROOT.calls(func, None)
return child
return tree
def __repr__(self):
return self.__toString("", True)
def __toString(self, branch, lastChild):
if self._time is not None:
s = "%s----%s (%s)\n" % (branch, self._func, self._time)
else:
s = "%s----%s\n" % (branch, self._func)
i = 0
if lastChild:
branch = branch[:-1] + " "
while i < len(self._children):
if i != len(self._children) - 1:
s += "%s" % self._children[i].__toString(branch +\
" |", False)
else:
s += "%s" % self._children[i].__toString(branch +\
" |", True)
i += 1
return s
class BrokenLineException(Exception):
"""If the last line is not complete because of the pipe breakage,
we want to stop the processing and ignore this line.
"""
pass
class CommentLineException(Exception):
""" If the line is a comment (as in the beginning of the trace file),
just ignore it.
"""
pass
def parseLine(line):
line = line.strip()
if line.startswith("#"):
raise CommentLineException
m = re.match("[^]]+?\\] +([0-9.]+): (\\w+) <-(\\w+)", line)
if m is None:
raise BrokenLineException
return (m.group(1), m.group(2), m.group(3))
def main():
CallTree.ROOT = CallTree("Root (Nowhere)", None, None)
tree = CallTree.ROOT
for line in sys.stdin:
try:
calltime, callee, caller = parseLine(line)
except BrokenLineException:
break
except CommentLineException:
continue
tree = tree.getParent(caller)
tree = tree.calls(callee, calltime)
print CallTree.ROOT
if __name__ == "__main__":
main()
|
gpl-2.0
|
[
3381,
2647,
15,
1393,
15,
1548,
199,
199,
624,
199,
7384,
9079,
334,
67,
9,
481,
21919,
1567,
2136,
374,
1235,
22043,
665,
70,
1129,
374,
24554,
32,
6799,
14,
957,
30,
199,
31661,
1334,
314,
2895,
402,
314,
1664,
14629,
844,
1015,
499,
199,
199,
2765,
2884,
19953,
282,
3307,
2741,
701,
314,
805,
29140,
315,
199,
4989,
15,
3446,
15,
3446,
63,
5777,
14,
67,
199,
1918,
522,
30355,
3307,
365,
7686,
1901,
282,
3123,
370,
7389,
282,
1655,
11779,
199,
1345,
402,
314,
1240,
3464,
701,
17455,
25884,
1325,
24787,
3123,
402,
199,
5352,
14,
5972,
314,
3423,
1159,
1561,
436,
314,
314,
1240,
900,
787,
2741,
14,
199,
199,
7692,
26,
199,
198,
3655,
3238,
626,
1265,
1172,
15869,
63,
15476,
63,
1766,
1348,
540,
199,
198,
3,
10760,
446,
84,
3105,
2319,
1031,
86,
1182,
1274,
15,
4989,
15,
1757,
199,
198,
3,
11343,
805,
690,
1182,
1274,
15,
4989,
15,
1757,
15,
21635,
15,
1818,
63,
16825,
199,
198,
4,
6230,
1182,
1274,
15,
4989,
15,
1757,
15,
21635,
15,
3446,
63,
4990,
690,
6146,
15,
1773,
63,
3446,
63,
1532,
199,
198,
7536,
2005,
5431,
1325,
440,
4634,
8298,
12,
314,
2884,
365,
282,
4546,
11999,
14,
199,
198,
13948,
314,
5200,
334,
9778,
435,
3107,
9,
199,
198,
4,
10554,
15,
5485,
63,
31939,
5986,
14,
647,
665,
3066,
63,
3446,
63,
1532,
690,
5954,
63,
31939,
5986,
199,
198,
28226,
1265,
1172,
2195,
19341,
3307,
315,
5954,
63,
31939,
5986,
199,
624,
421,
199,
646,
984,
12,
295,
199,
199,
533,
23491,
26,
199,
198,
624,
961,
1021,
6571,
282,
3123,
6025,
402,
314,
3423,
507,
198,
1250,
3464,
14,
982,
282,
805,
965,
949,
1676,
315,
314,
5114,
334,
20172,
12,
507,
198,
19444,
12,
5114,
2462,
11965,
2066,
652,
365,
10102,
370,
282,
5791,
1676,
507,
198,
3527,
16547,
14,
199,
198,
624,
199,
198,
5441,
275,
488,
421,
198,
318,
636,
826,
721,
277,
12,
2562,
12,
900,
275,
488,
12,
1676,
275,
488,
304,
507,
198,
277,
423,
1532,
275,
2562,
507,
198,
277,
423,
521,
275,
900,
507,
198,
692,
1676,
365,
488,
26,
686,
198,
277,
423,
1708,
275,
23491,
14,
5441,
507,
198,
2836,
26,
686,
198,
277,
423,
1708,
275,
1676,
507,
198,
277,
423,
3223,
275,
942,
421,
198,
318,
4882,
8,
277,
12,
2562,
12,
1240,
521,
304,
507,
198,
624,
982,
282,
805,
4882,
4573,
1373,
12,
1240,
642,
1083,
370,
5518,
652,
686,
198,
9924,
314,
3123,
737,
314,
5827,
4192,
14,
686,
198,
32,
1107,
26,
437,
3659,
370,
314,
13903,
2737,
1982,
1031,
14,
507,
198,
624,
507,
198,
1739,
275,
23491,
8,
1532,
12,
1240,
521,
12,
291,
9,
507,
198,
277,
423,
3223,
14,
740,
8,
1739,
9,
507,
198,
1107,
1982,
421,
198,
318,
664,
6652,
8,
277,
12,
2562,
304,
507,
198,
624,
13939,
314,
2061,
1676,
402,
314,
1453,
1031,
626,
686,
198,
1989,
314,
536,
1627,
701,
2562,
14,
982,
642,
805,
365,
440,
686,
198,
265,
282,
1676,
12,
2066,
1218,
652,
465,
892,
1982,
402,
1738,
686,
198,
32,
1107,
26,
437,
3659,
370,
314,
1676,
14,
507,
198,
624,
507,
198,
2350,
275,
291,
507,
198,
6710,
3123,
1137,
23491,
14,
5441,
436,
3123,
423,
1532,
1137,
2562,
26,
686,
198,
2350,
275,
3123,
423,
1708,
507,
198,
692,
3123,
508,
23491,
14,
5441,
26,
686,
198,
1739,
275,
23491,
14,
5441,
14,
5352,
8,
1532,
12,
488,
9,
686,
198,
1107,
1982,
507,
198,
1107,
3123,
421,
198,
318,
636,
2722,
721,
277,
304,
507,
198,
1107,
291,
855,
16695,
12398,
715,
9,
421,
198,
318,
636,
16695,
8,
277,
12,
5246,
12,
2061,
3493,
304,
507,
198,
692,
291,
423,
521,
365,
440,
488,
26,
686,
198,
83,
275,
2071,
83,
375,
5,
83,
4366,
83,
2862,
78,
2,
450,
334,
4694,
12,
291,
423,
1532,
12,
291,
423,
521,
9,
507,
198,
2836,
26,
686,
198,
83,
275,
2071,
83,
375,
5,
83,
60,
78,
2,
450,
334,
4694,
12,
291,
423,
1532,
9,
2742,
198,
73,
275,
378,
507,
198,
692,
2061,
3493,
26,
686,
198,
4694,
275,
5246,
4439,
17,
61,
435,
298,
298,
507,
198,
6710,
284,
665,
822,
8,
277,
423,
3223,
304,
686,
198,
692,
284,
1137,
822,
8,
277,
423,
3223,
9,
446,
413,
26,
1585,
198,
83,
847,
2071,
83,
2,
450,
291,
423,
3223,
59,
73,
17979,
16695,
8,
4694,
17992,
11674,
198,
2,
259,
1204,
401,
756,
9,
686,
198,
2836,
26,
1585,
198,
83,
847,
2071,
83,
2,
450,
291,
423,
3223,
59,
73,
17979,
16695,
8,
4694,
17992,
11674,
198,
2,
259,
1204,
401,
715,
9,
686,
198,
73,
847,
413,
507,
198,
1107,
308,
199,
199,
533,
23804,
29969,
8,
1726,
304,
199,
198,
624,
3917,
314,
2061,
1004,
365,
440,
4890,
2952,
402,
314,
5200,
2059,
474,
12,
21979,
781,
2934,
370,
3631,
314,
6661,
436,
3686,
642,
1004,
14,
199,
198,
624,
199,
198,
1529,
199,
199,
533,
6819,
29969,
8,
1726,
304,
199,
198,
624,
982,
314,
1004,
365,
282,
3721,
334,
305,
315,
314,
9608,
402,
314,
3307,
570,
395,
6722,
2951,
3686,
652,
14,
199,
198,
624,
199,
198,
1529,
421,
199,
318,
2198,
3049,
8,
604,
304,
199,
198,
604,
275,
1004,
14,
1913,
342,
199,
198,
692,
1004,
14,
2460,
10064,
2349,
507,
198,
3730,
6819,
29969,
199,
198,
77,
275,
295,
14,
1431,
480,
4735,
2677,
23778,
1103,
61,
435,
779,
16,
13,
25,
32455,
304,
334,
1103,
87,
8771,
665,
15426,
1103,
87,
11,
4186,
1004,
9,
199,
198,
692,
333,
365,
488,
26,
507,
198,
3730,
23804,
29969,
199,
198,
1107,
334,
77,
14,
923,
8,
17,
395,
333,
14,
923,
8,
18,
395,
333,
14,
923,
8,
19,
430,
421,
199,
318,
2446,
837,
199,
198,
2176,
3987,
14,
5441,
275,
23491,
480,
6405,
334,
14351,
1681,
4186,
488,
12,
488,
9,
199,
198,
2350,
275,
23491,
14,
5441,
421,
198,
509,
1004,
315,
984,
14,
6626,
26,
507,
198,
893,
26,
686,
198,
1250,
521,
12,
3213,
18387,
12,
8025,
275,
2198,
3049,
8,
604
] |
[
2647,
15,
1393,
15,
1548,
199,
199,
624,
199,
7384,
9079,
334,
67,
9,
481,
21919,
1567,
2136,
374,
1235,
22043,
665,
70,
1129,
374,
24554,
32,
6799,
14,
957,
30,
199,
31661,
1334,
314,
2895,
402,
314,
1664,
14629,
844,
1015,
499,
199,
199,
2765,
2884,
19953,
282,
3307,
2741,
701,
314,
805,
29140,
315,
199,
4989,
15,
3446,
15,
3446,
63,
5777,
14,
67,
199,
1918,
522,
30355,
3307,
365,
7686,
1901,
282,
3123,
370,
7389,
282,
1655,
11779,
199,
1345,
402,
314,
1240,
3464,
701,
17455,
25884,
1325,
24787,
3123,
402,
199,
5352,
14,
5972,
314,
3423,
1159,
1561,
436,
314,
314,
1240,
900,
787,
2741,
14,
199,
199,
7692,
26,
199,
198,
3655,
3238,
626,
1265,
1172,
15869,
63,
15476,
63,
1766,
1348,
540,
199,
198,
3,
10760,
446,
84,
3105,
2319,
1031,
86,
1182,
1274,
15,
4989,
15,
1757,
199,
198,
3,
11343,
805,
690,
1182,
1274,
15,
4989,
15,
1757,
15,
21635,
15,
1818,
63,
16825,
199,
198,
4,
6230,
1182,
1274,
15,
4989,
15,
1757,
15,
21635,
15,
3446,
63,
4990,
690,
6146,
15,
1773,
63,
3446,
63,
1532,
199,
198,
7536,
2005,
5431,
1325,
440,
4634,
8298,
12,
314,
2884,
365,
282,
4546,
11999,
14,
199,
198,
13948,
314,
5200,
334,
9778,
435,
3107,
9,
199,
198,
4,
10554,
15,
5485,
63,
31939,
5986,
14,
647,
665,
3066,
63,
3446,
63,
1532,
690,
5954,
63,
31939,
5986,
199,
198,
28226,
1265,
1172,
2195,
19341,
3307,
315,
5954,
63,
31939,
5986,
199,
624,
421,
199,
646,
984,
12,
295,
199,
199,
533,
23491,
26,
199,
198,
624,
961,
1021,
6571,
282,
3123,
6025,
402,
314,
3423,
507,
198,
1250,
3464,
14,
982,
282,
805,
965,
949,
1676,
315,
314,
5114,
334,
20172,
12,
507,
198,
19444,
12,
5114,
2462,
11965,
2066,
652,
365,
10102,
370,
282,
5791,
1676,
507,
198,
3527,
16547,
14,
199,
198,
624,
199,
198,
5441,
275,
488,
421,
198,
318,
636,
826,
721,
277,
12,
2562,
12,
900,
275,
488,
12,
1676,
275,
488,
304,
507,
198,
277,
423,
1532,
275,
2562,
507,
198,
277,
423,
521,
275,
900,
507,
198,
692,
1676,
365,
488,
26,
686,
198,
277,
423,
1708,
275,
23491,
14,
5441,
507,
198,
2836,
26,
686,
198,
277,
423,
1708,
275,
1676,
507,
198,
277,
423,
3223,
275,
942,
421,
198,
318,
4882,
8,
277,
12,
2562,
12,
1240,
521,
304,
507,
198,
624,
982,
282,
805,
4882,
4573,
1373,
12,
1240,
642,
1083,
370,
5518,
652,
686,
198,
9924,
314,
3123,
737,
314,
5827,
4192,
14,
686,
198,
32,
1107,
26,
437,
3659,
370,
314,
13903,
2737,
1982,
1031,
14,
507,
198,
624,
507,
198,
1739,
275,
23491,
8,
1532,
12,
1240,
521,
12,
291,
9,
507,
198,
277,
423,
3223,
14,
740,
8,
1739,
9,
507,
198,
1107,
1982,
421,
198,
318,
664,
6652,
8,
277,
12,
2562,
304,
507,
198,
624,
13939,
314,
2061,
1676,
402,
314,
1453,
1031,
626,
686,
198,
1989,
314,
536,
1627,
701,
2562,
14,
982,
642,
805,
365,
440,
686,
198,
265,
282,
1676,
12,
2066,
1218,
652,
465,
892,
1982,
402,
1738,
686,
198,
32,
1107,
26,
437,
3659,
370,
314,
1676,
14,
507,
198,
624,
507,
198,
2350,
275,
291,
507,
198,
6710,
3123,
1137,
23491,
14,
5441,
436,
3123,
423,
1532,
1137,
2562,
26,
686,
198,
2350,
275,
3123,
423,
1708,
507,
198,
692,
3123,
508,
23491,
14,
5441,
26,
686,
198,
1739,
275,
23491,
14,
5441,
14,
5352,
8,
1532,
12,
488,
9,
686,
198,
1107,
1982,
507,
198,
1107,
3123,
421,
198,
318,
636,
2722,
721,
277,
304,
507,
198,
1107,
291,
855,
16695,
12398,
715,
9,
421,
198,
318,
636,
16695,
8,
277,
12,
5246,
12,
2061,
3493,
304,
507,
198,
692,
291,
423,
521,
365,
440,
488,
26,
686,
198,
83,
275,
2071,
83,
375,
5,
83,
4366,
83,
2862,
78,
2,
450,
334,
4694,
12,
291,
423,
1532,
12,
291,
423,
521,
9,
507,
198,
2836,
26,
686,
198,
83,
275,
2071,
83,
375,
5,
83,
60,
78,
2,
450,
334,
4694,
12,
291,
423,
1532,
9,
2742,
198,
73,
275,
378,
507,
198,
692,
2061,
3493,
26,
686,
198,
4694,
275,
5246,
4439,
17,
61,
435,
298,
298,
507,
198,
6710,
284,
665,
822,
8,
277,
423,
3223,
304,
686,
198,
692,
284,
1137,
822,
8,
277,
423,
3223,
9,
446,
413,
26,
1585,
198,
83,
847,
2071,
83,
2,
450,
291,
423,
3223,
59,
73,
17979,
16695,
8,
4694,
17992,
11674,
198,
2,
259,
1204,
401,
756,
9,
686,
198,
2836,
26,
1585,
198,
83,
847,
2071,
83,
2,
450,
291,
423,
3223,
59,
73,
17979,
16695,
8,
4694,
17992,
11674,
198,
2,
259,
1204,
401,
715,
9,
686,
198,
73,
847,
413,
507,
198,
1107,
308,
199,
199,
533,
23804,
29969,
8,
1726,
304,
199,
198,
624,
3917,
314,
2061,
1004,
365,
440,
4890,
2952,
402,
314,
5200,
2059,
474,
12,
21979,
781,
2934,
370,
3631,
314,
6661,
436,
3686,
642,
1004,
14,
199,
198,
624,
199,
198,
1529,
199,
199,
533,
6819,
29969,
8,
1726,
304,
199,
198,
624,
982,
314,
1004,
365,
282,
3721,
334,
305,
315,
314,
9608,
402,
314,
3307,
570,
395,
6722,
2951,
3686,
652,
14,
199,
198,
624,
199,
198,
1529,
421,
199,
318,
2198,
3049,
8,
604,
304,
199,
198,
604,
275,
1004,
14,
1913,
342,
199,
198,
692,
1004,
14,
2460,
10064,
2349,
507,
198,
3730,
6819,
29969,
199,
198,
77,
275,
295,
14,
1431,
480,
4735,
2677,
23778,
1103,
61,
435,
779,
16,
13,
25,
32455,
304,
334,
1103,
87,
8771,
665,
15426,
1103,
87,
11,
4186,
1004,
9,
199,
198,
692,
333,
365,
488,
26,
507,
198,
3730,
23804,
29969,
199,
198,
1107,
334,
77,
14,
923,
8,
17,
395,
333,
14,
923,
8,
18,
395,
333,
14,
923,
8,
19,
430,
421,
199,
318,
2446,
837,
199,
198,
2176,
3987,
14,
5441,
275,
23491,
480,
6405,
334,
14351,
1681,
4186,
488,
12,
488,
9,
199,
198,
2350,
275,
23491,
14,
5441,
421,
198,
509,
1004,
315,
984,
14,
6626,
26,
507,
198,
893,
26,
686,
198,
1250,
521,
12,
3213,
18387,
12,
8025,
275,
2198,
3049,
8,
604,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
kidaa30/spacewalk
|
client/rhel/rhn-client-tools/test/testRhnChannel.py
|
36
|
1826
|
#!/usr/bin/python
import sys
import settestpath
from up2date_client import rhnChannel
# lots of useful util methods for building/tearing down
# test enviroments...
import testutils
import unittest
def write(blip):
sys.stdout.write("\n|%s|\n" % blip)
class testRhnChannel(unittest.TestCase):
def setUp(self):
self.__setupData()
testutils.setupConfig("channelTest1")
def tearDown(self):
testutils.restoreConfig()
def __setupData(self):
self.channelListDetails = [
{'last_modified': '20030502050933',
'description': '',
'name': 'Red Hat Linux 9 i386',
'local_channel': '0',
'arch': 'channel-ia32',
'parent_channel': '',
'summary': 'Red Hat Linux 9 (Shrike) i386',
'org_id': '',
'id': '63',
'label': 'redhat-linux-i386-9'}]
def testGetChannelDetails(self):
"rhnChannel.GetChannelDetails"
res = rhnChannel.getChannelDetails()
# the last modified will change a lot, so
# dont bother checking it...
write(res)
write(self.channelListDetails)
for i in res[0].keys():
if i == "last_modified":
continue
self.assertEqual(res[0][i], self.channelListDetails[0][i])
def testGetChannels(self):
"Test rhnChannel.getChannels()"
res = rhnChannel.getChannels()
write(res)
def testUpdateChannels(self):
"Test rhnChannel.updateChannels"
channels = rhnChannel.getChannels()
res = rhnChannel.updateChannels(channels)
def suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(testRhnChannel))
return suite
if __name__ == "__main__":
unittest.main(defaultTest="suite")
|
gpl-2.0
|
[
3381,
2647,
15,
1393,
15,
1548,
199,
199,
646,
984,
199,
199,
646,
663,
396,
515,
199,
199,
504,
1536,
18,
602,
63,
1258,
492,
25535,
5358,
199,
3,
24213,
402,
2997,
4884,
3102,
367,
10015,
15,
266,
9332,
3224,
199,
3,
511,
655,
433,
293,
1470,
1396,
199,
646,
511,
1208,
199,
199,
646,
2882,
421,
199,
318,
2218,
8,
66,
3587,
304,
272,
984,
14,
2703,
14,
952,
4582,
78,
15287,
83,
6113,
78,
2,
450,
330,
3587,
9,
421,
199,
533,
511,
50,
6164,
5358,
8,
2796,
14,
1746,
304,
272,
347,
3613,
8,
277,
304,
267,
291,
855,
2758,
1451,
342,
267,
511,
1208,
14,
2758,
2028,
480,
2775,
774,
17,
531,
339,
347,
6766,
8,
277,
304,
267,
511,
1208,
14,
8011,
2028,
342,
339,
347,
636,
2758,
1451,
8,
277,
304,
267,
291,
14,
2775,
1296,
11347,
275,
359,
288,
791,
2019,
63,
5540,
356,
283,
1840,
11565,
10173,
6576,
1153,
297,
1467,
283,
1802,
356,
3260,
1467,
283,
354,
356,
283,
10858,
13002,
10130,
1749,
284,
8040,
297,
1467,
283,
1832,
63,
2775,
356,
283,
16,
297,
1467,
283,
1047,
356,
283,
2775,
13,
4674,
708,
297,
1467,
283,
1708,
63,
2775,
356,
3260,
1467,
283,
4705,
356,
283,
10858,
13002,
10130,
1749,
334,
2662,
322,
415,
9,
284,
8040,
297,
1467,
283,
1308,
63,
344,
356,
3260,
1467,
283,
344,
356,
283,
2766,
297,
1467,
283,
1302,
356,
283,
17164,
13,
5135,
13,
73,
8040,
13,
25,
20623,
339,
347,
19970,
5358,
11347,
8,
277,
304,
267,
298,
82,
6164,
5358,
14,
29646,
11347,
2,
267,
522,
275,
25535,
5358,
14,
362,
5358,
11347,
342,
267,
327,
314,
2061,
6042,
911,
1570,
282,
13918,
12,
880,
267,
327,
21542,
26962,
7907,
652,
1396,
267,
2218,
8,
470,
9,
267,
2218,
8,
277,
14,
2775,
1296,
11347,
9,
267,
367,
284,
315,
522,
59,
16,
1055,
1612,
837,
288,
340,
284,
508,
298,
2019,
63,
5540,
582,
355,
1980,
288,
291,
14,
629,
8,
470,
59,
16,
1527,
73,
467,
291,
14,
2775,
1296,
11347,
59,
16,
1527,
73,
566,
2378,
347,
19970,
27138,
8,
277,
304,
267,
298,
774,
25535,
5358,
14,
362,
27138,
16493,
267,
522,
275,
25535,
5358,
14,
362,
27138,
342,
398,
2218,
8,
470,
9,
339,
347,
511,
4152,
27138,
8,
277,
304,
267,
298,
774,
25535,
5358,
14,
873,
27138,
2,
267,
9245,
275,
25535,
5358,
14,
362,
27138,
342,
267,
522,
275,
25535,
5358,
14,
873,
27138,
8,
6324,
9,
199,
199,
318,
5241,
837,
272,
5241,
275,
2882,
14,
10591,
342,
272,
5241,
14,
15714,
8,
2796,
14,
18275,
8,
396,
50,
6164,
5358,
430,
272,
372,
5241,
199,
199,
692,
636,
354,
363,
508,
4396,
973,
5727,
272,
2882,
14,
973,
8,
885,
774,
628,
5768,
531,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
2647,
15,
1393,
15,
1548,
199,
199,
646,
984,
199,
199,
646,
663,
396,
515,
199,
199,
504,
1536,
18,
602,
63,
1258,
492,
25535,
5358,
199,
3,
24213,
402,
2997,
4884,
3102,
367,
10015,
15,
266,
9332,
3224,
199,
3,
511,
655,
433,
293,
1470,
1396,
199,
646,
511,
1208,
199,
199,
646,
2882,
421,
199,
318,
2218,
8,
66,
3587,
304,
272,
984,
14,
2703,
14,
952,
4582,
78,
15287,
83,
6113,
78,
2,
450,
330,
3587,
9,
421,
199,
533,
511,
50,
6164,
5358,
8,
2796,
14,
1746,
304,
272,
347,
3613,
8,
277,
304,
267,
291,
855,
2758,
1451,
342,
267,
511,
1208,
14,
2758,
2028,
480,
2775,
774,
17,
531,
339,
347,
6766,
8,
277,
304,
267,
511,
1208,
14,
8011,
2028,
342,
339,
347,
636,
2758,
1451,
8,
277,
304,
267,
291,
14,
2775,
1296,
11347,
275,
359,
288,
791,
2019,
63,
5540,
356,
283,
1840,
11565,
10173,
6576,
1153,
297,
1467,
283,
1802,
356,
3260,
1467,
283,
354,
356,
283,
10858,
13002,
10130,
1749,
284,
8040,
297,
1467,
283,
1832,
63,
2775,
356,
283,
16,
297,
1467,
283,
1047,
356,
283,
2775,
13,
4674,
708,
297,
1467,
283,
1708,
63,
2775,
356,
3260,
1467,
283,
4705,
356,
283,
10858,
13002,
10130,
1749,
334,
2662,
322,
415,
9,
284,
8040,
297,
1467,
283,
1308,
63,
344,
356,
3260,
1467,
283,
344,
356,
283,
2766,
297,
1467,
283,
1302,
356,
283,
17164,
13,
5135,
13,
73,
8040,
13,
25,
20623,
339,
347,
19970,
5358,
11347,
8,
277,
304,
267,
298,
82,
6164,
5358,
14,
29646,
11347,
2,
267,
522,
275,
25535,
5358,
14,
362,
5358,
11347,
342,
267,
327,
314,
2061,
6042,
911,
1570,
282,
13918,
12,
880,
267,
327,
21542,
26962,
7907,
652,
1396,
267,
2218,
8,
470,
9,
267,
2218,
8,
277,
14,
2775,
1296,
11347,
9,
267,
367,
284,
315,
522,
59,
16,
1055,
1612,
837,
288,
340,
284,
508,
298,
2019,
63,
5540,
582,
355,
1980,
288,
291,
14,
629,
8,
470,
59,
16,
1527,
73,
467,
291,
14,
2775,
1296,
11347,
59,
16,
1527,
73,
566,
2378,
347,
19970,
27138,
8,
277,
304,
267,
298,
774,
25535,
5358,
14,
362,
27138,
16493,
267,
522,
275,
25535,
5358,
14,
362,
27138,
342,
398,
2218,
8,
470,
9,
339,
347,
511,
4152,
27138,
8,
277,
304,
267,
298,
774,
25535,
5358,
14,
873,
27138,
2,
267,
9245,
275,
25535,
5358,
14,
362,
27138,
342,
267,
522,
275,
25535,
5358,
14,
873,
27138,
8,
6324,
9,
199,
199,
318,
5241,
837,
272,
5241,
275,
2882,
14,
10591,
342,
272,
5241,
14,
15714,
8,
2796,
14,
18275,
8,
396,
50,
6164,
5358,
430,
272,
372,
5241,
199,
199,
692,
636,
354,
363,
508,
4396,
973,
5727,
272,
2882,
14,
973,
8,
885,
774,
628,
5768,
531,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
Mattze96/youtube-dl
|
youtube_dl/extractor/ivi.py
|
107
|
7231
|
# encoding: utf-8
from __future__ import unicode_literals
import re
import json
from .common import InfoExtractor
from ..compat import (
compat_urllib_request,
)
from ..utils import (
ExtractorError,
)
class IviIE(InfoExtractor):
IE_DESC = 'ivi.ru'
IE_NAME = 'ivi'
_VALID_URL = r'https?://(?:www\.)?ivi\.ru/(?:watch/(?:[^/]+/)?|video/player\?.*?videoId=)(?P<id>\d+)'
_TESTS = [
# Single movie
{
'url': 'http://www.ivi.ru/watch/53141',
'md5': '6ff5be2254e796ed346251d117196cf4',
'info_dict': {
'id': '53141',
'ext': 'mp4',
'title': 'Иван Васильевич меняет профессию',
'description': 'md5:b924063ea1677c8fe343d8a72ac2195f',
'duration': 5498,
'thumbnail': 'http://thumbs.ivi.ru/f20.vcp.digitalaccess.ru/contents/d/1/c3c885163a082c29bceeb7b5a267a6.jpg',
},
'skip': 'Only works from Russia',
},
# Serial's serie
{
'url': 'http://www.ivi.ru/watch/dvoe_iz_lartsa/9549',
'md5': '221f56b35e3ed815fde2df71032f4b3e',
'info_dict': {
'id': '9549',
'ext': 'mp4',
'title': 'Двое из ларца - Серия 1',
'duration': 2655,
'thumbnail': 'http://thumbs.ivi.ru/f15.vcp.digitalaccess.ru/contents/8/4/0068dc0677041f3336b7c2baad8fc0.jpg',
},
'skip': 'Only works from Russia',
}
]
# Sorted by quality
_known_formats = ['MP4-low-mobile', 'MP4-mobile', 'FLV-lo', 'MP4-lo', 'FLV-hi', 'MP4-hi', 'MP4-SHQ']
# Sorted by size
_known_thumbnails = ['Thumb-120x90', 'Thumb-160', 'Thumb-640x480']
def _extract_description(self, html):
m = re.search(r'<meta name="description" content="(?P<description>[^"]+)"/>', html)
return m.group('description') if m is not None else None
def _extract_comment_count(self, html):
m = re.search('(?s)<a href="#" id="view-comments" class="action-button dim gradient">\s*Комментарии:\s*(?P<commentcount>\d+)\s*</a>', html)
return int(m.group('commentcount')) if m is not None else 0
def _real_extract(self, url):
video_id = self._match_id(url)
api_url = 'http://api.digitalaccess.ru/api/json/'
data = {
'method': 'da.content.get',
'params': [
video_id, {
'site': 's183',
'referrer': 'http://www.ivi.ru/watch/%s' % video_id,
'contentid': video_id
}
]
}
request = compat_urllib_request.Request(api_url, json.dumps(data))
video_json_page = self._download_webpage(
request, video_id, 'Downloading video JSON')
video_json = json.loads(video_json_page)
if 'error' in video_json:
error = video_json['error']
if error['origin'] == 'NoRedisValidData':
raise ExtractorError('Video %s does not exist' % video_id, expected=True)
raise ExtractorError(
'Unable to download video %s: %s' % (video_id, error['message']),
expected=True)
result = video_json['result']
formats = [{
'url': x['url'],
'format_id': x['content_format'],
'preference': self._known_formats.index(x['content_format']),
} for x in result['files'] if x['content_format'] in self._known_formats]
self._sort_formats(formats)
if not formats:
raise ExtractorError('No media links available for %s' % video_id)
duration = result['duration']
compilation = result['compilation']
title = result['title']
title = '%s - %s' % (compilation, title) if compilation is not None else title
previews = result['preview']
previews.sort(key=lambda fmt: self._known_thumbnails.index(fmt['content_format']))
thumbnail = previews[-1]['url'] if len(previews) > 0 else None
video_page = self._download_webpage(url, video_id, 'Downloading video page')
description = self._extract_description(video_page)
comment_count = self._extract_comment_count(video_page)
return {
'id': video_id,
'title': title,
'thumbnail': thumbnail,
'description': description,
'duration': duration,
'comment_count': comment_count,
'formats': formats,
}
class IviCompilationIE(InfoExtractor):
IE_DESC = 'ivi.ru compilations'
IE_NAME = 'ivi:compilation'
_VALID_URL = r'https?://(?:www\.)?ivi\.ru/watch/(?!\d+)(?P<compilationid>[a-z\d_-]+)(?:/season(?P<seasonid>\d+))?$'
_TESTS = [{
'url': 'http://www.ivi.ru/watch/dvoe_iz_lartsa',
'info_dict': {
'id': 'dvoe_iz_lartsa',
'title': 'Двое из ларца (2006 - 2008)',
},
'playlist_mincount': 24,
}, {
'url': 'http://www.ivi.ru/watch/dvoe_iz_lartsa/season1',
'info_dict': {
'id': 'dvoe_iz_lartsa/season1',
'title': 'Двое из ларца (2006 - 2008) 1 сезон',
},
'playlist_mincount': 12,
}]
def _extract_entries(self, html, compilation_id):
return [self.url_result('http://www.ivi.ru/watch/%s/%s' % (compilation_id, serie), 'Ivi')
for serie in re.findall(r'<strong><a href="/watch/%s/(\d+)">(?:[^<]+)</a></strong>' % compilation_id, html)]
def _real_extract(self, url):
mobj = re.match(self._VALID_URL, url)
compilation_id = mobj.group('compilationid')
season_id = mobj.group('seasonid')
if season_id is not None: # Season link
season_page = self._download_webpage(url, compilation_id, 'Downloading season %s web page' % season_id)
playlist_id = '%s/season%s' % (compilation_id, season_id)
playlist_title = self._html_search_meta('title', season_page, 'title')
entries = self._extract_entries(season_page, compilation_id)
else: # Compilation link
compilation_page = self._download_webpage(url, compilation_id, 'Downloading compilation web page')
playlist_id = compilation_id
playlist_title = self._html_search_meta('title', compilation_page, 'title')
seasons = re.findall(r'<a href="/watch/%s/season(\d+)">[^<]+</a>' % compilation_id, compilation_page)
if len(seasons) == 0: # No seasons in this compilation
entries = self._extract_entries(compilation_page, compilation_id)
else:
entries = []
for season_id in seasons:
season_page = self._download_webpage(
'http://www.ivi.ru/watch/%s/season%s' % (compilation_id, season_id),
compilation_id, 'Downloading season %s web page' % season_id)
entries.extend(self._extract_entries(season_page, compilation_id))
return self.playlist_result(entries, playlist_id, playlist_title)
|
unlicense
|
[
3,
2644,
26,
2774,
13,
24,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
646,
295,
199,
646,
2022,
199,
199,
504,
1275,
2330,
492,
21298,
199,
504,
2508,
5819,
492,
334,
272,
8434,
63,
4078,
63,
1069,
12,
199,
9,
199,
504,
2508,
1208,
492,
334,
272,
19783,
12,
199,
9,
421,
199,
533,
473,
433,
4332,
8,
18283,
304,
272,
15292,
63,
15119,
275,
283,
73,
433,
14,
6558,
7,
272,
15292,
63,
2339,
275,
283,
73,
433,
7,
272,
485,
5600,
63,
2632,
275,
519,
7,
2859,
24524,
1544,
20316,
73,
433,
4537,
6558,
32576,
6821,
32576,
26285,
15,
5547,
92,
3722,
15,
6147,
29635,
6697,
3722,
1304,
29,
18168,
48,
28,
344,
3072,
68,
29600,
339,
485,
7569,
275,
359,
267,
327,
13050,
14360,
267,
469,
288,
283,
633,
356,
283,
1014,
921,
1544,
14,
73,
433,
14,
6558,
15,
6821,
15,
2481,
12735,
297,
288,
283,
1064,
21,
356,
283,
22,
556,
21,
1235,
18,
8306,
69,
21655,
379,
12583,
12140,
68,
7362,
10800,
2177,
20,
297,
288,
283,
815,
63,
807,
356,
469,
355,
283,
344,
356,
283,
2481,
12735,
297,
355,
283,
832,
356,
283,
311,
20,
297,
355,
283,
1213,
356,
283,
141,
247,
19630,
21674,
7038,
241,
5657,
8474,
6500,
10356,
16961,
15578,
111,
6500,
19277,
7038,
121,
18624,
14978,
30160,
19820,
7753,
5806,
31815,
6286,
8474,
8474,
6500,
31235,
297,
355,
283,
1802,
356,
283,
1064,
21,
26,
66,
30666,
22653,
4489,
975,
1138,
67,
24,
771,
14761,
68,
24,
65,
2819,
645,
8867,
21,
70,
297,
355,
283,
5553,
356,
959,
20537,
12,
355,
283,
8311,
356,
283,
1014,
921,
273,
23135,
14,
73,
433,
14,
6558,
15,
70,
1165,
14,
86,
1850,
14,
25888,
2732,
14,
6558,
15,
4407,
15,
68,
15,
17,
15,
67,
19,
67,
15889,
11931,
65,
19171,
67,
1398,
66,
301,
2871,
23,
66,
21,
65,
13406,
65,
22,
14,
8476,
297,
288,
1660,
288,
283,
2759,
356,
283,
5903,
5419,
687,
820,
527,
10971,
297,
267,
1660,
267,
327,
11973,
1159,
542,
11317,
267,
469,
288,
283,
633,
356,
283,
1014,
921,
1544,
14,
73,
433,
14,
6558,
15,
6821,
15,
68,
2392,
69,
63,
565,
63,
76,
580,
2231,
15,
25,
15419,
297,
288,
283,
1064,
21,
356,
283,
11564,
70,
1367,
66,
1276,
69,
19,
379,
28250,
70,
271,
18,
1587,
26072,
708,
70,
20,
66,
19,
69,
297,
288,
283,
815,
63,
807,
356,
469,
355,
283,
344,
356,
283,
25,
15419,
297,
355,
283,
832,
356,
283,
311,
20,
297,
355,
283,
1213,
356,
283,
141,
243,
19630,
5806,
6286,
221,
16863,
116,
7038,
120,
27559,
25827,
5657,
446,
7038,
95,
21273,
6500,
14978,
413,
297,
355,
283,
5553,
356,
7875,
1229,
12,
355,
283,
8311,
356,
283,
1014,
921,
273,
23135,
14,
73,
433,
14,
6558,
15,
70,
1046,
14,
86,
1850,
14,
25888,
2732,
14,
6558,
15,
4407,
15,
24,
15,
20,
15,
30715,
3833,
1690,
1138,
10531,
70,
1153,
1344,
66,
23,
67,
18,
2470,
350,
24,
3003,
16,
14,
8476,
297,
288,
1660,
288,
283,
2759,
356,
283,
5903,
5419,
687,
820,
527,
10971,
297,
267,
789,
272,
1622,
339,
327,
27432,
701,
11030,
272,
485,
3159,
63,
6321,
275,
788,
1658,
20,
13,
674,
13,
11375,
297,
283,
1658,
20,
13,
11375,
297,
283,
3143,
54,
13,
320,
297,
283,
1658,
20,
13,
320,
297,
283,
3143,
54,
13,
5812,
297,
283,
1658,
20,
13,
5812,
297,
283,
1658,
20,
13,
3234,
49,
418,
339,
327,
27432,
701,
1568,
272,
485,
3159,
63,
8311,
83,
275,
788,
2719,
4295,
13,
6708,
88,
2710,
297,
283,
2719,
4295,
13,
8488,
297,
283,
2719,
4295,
13,
12021,
88,
21853,
418,
339,
347,
485,
5005,
63,
1802,
8,
277,
12,
3517,
304,
267,
333,
275,
295,
14,
1733,
8,
82,
7601,
2024,
536,
628,
1802,
2,
1564,
628,
2229,
48,
28,
1802,
13489,
937,
20415,
3133,
297,
3517,
9,
267,
372,
333,
14,
923,
360,
1802,
358,
340,
333,
365,
440,
488,
587,
488,
339,
347,
485,
5005,
63,
3349,
63,
835,
8,
277,
12,
3517,
304,
267,
333,
275,
295,
14,
1733,
28353,
83,
21528,
65,
4369,
13476,
2,
1305,
628,
1345,
13,
6223,
2,
1021,
628,
1287,
13,
3887,
8134,
6709,
14559,
83,
10,
141,
249,
32334,
23000,
18624,
7413,
27559,
6500,
6500,
3427,
83,
30957,
48,
28,
3349,
835,
3072,
68,
13439,
83,
10,
1108,
65,
4206,
3517,
9,
267,
372,
1109,
8,
77,
14,
923,
360,
3349,
835,
1333,
340,
333,
365,
440,
488,
587,
378,
339,
347,
485,
3093,
63,
5005,
8,
277,
12,
1166,
304,
267,
3991,
63,
344,
275,
291,
423,
1431,
63,
344,
8,
633,
9,
398,
2986,
63,
633,
275,
283,
1014,
921,
1246,
14,
25888,
2732,
14,
6558,
15,
1246,
15,
1001,
4805,
398,
666,
275,
469,
288,
283,
765,
356,
283,
983,
14,
1317,
14,
362,
297,
288,
283,
1162,
356,
359,
355,
3991,
63,
344,
12,
469,
490,
283,
2124,
356,
283,
83,
12363,
297,
490,
283,
21928,
3859,
356,
283,
1014,
921,
1544,
14,
73,
433,
14,
6558,
15,
6821,
3149,
83,
7,
450,
3991,
63,
344,
12,
490,
283,
388,
724,
5700,
356,
3991,
63,
344,
355,
789,
288,
1622,
267,
789,
398,
1056,
275,
8434,
63,
4078,
63,
1069,
14,
2017,
8,
1246,
63,
633,
12,
2022,
14,
4180,
8,
576,
430,
398,
3991,
63,
1001,
63,
1606,
275,
291,
423,
4249,
63,
12022,
8,
288,
1056,
12,
3991,
63,
344,
12,
283,
18085,
3991,
4840,
358,
267,
3991,
63,
1001,
275,
2022,
14,
3640,
8,
3722,
63,
1001,
63,
1606,
9,
398,
340,
283,
705,
7,
315,
3991,
63,
1001,
26,
288,
1125,
275,
3991,
63,
1001,
459,
705,
418,
288,
340,
1125,
459,
6493,
418,
508,
283,
1944,
29605,
3490,
1451,
356,
355,
746,
19783,
360,
9166,
450,
83,
1630,
440,
2187,
7,
450,
3991,
63,
344,
12,
1420,
29,
549,
9,
288,
746,
19783,
8,
355,
283,
6005,
370,
5235,
3991,
450,
83,
26,
450,
83,
7,
450,
334,
3722,
63,
344,
12,
1125,
459,
1188,
3815,
355,
1420,
29,
549,
9,
398,
754,
275,
3991,
63,
1001,
459,
1099
] |
[
2644,
26,
2774,
13,
24,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
646,
295,
199,
646,
2022,
199,
199,
504,
1275,
2330,
492,
21298,
199,
504,
2508,
5819,
492,
334,
272,
8434,
63,
4078,
63,
1069,
12,
199,
9,
199,
504,
2508,
1208,
492,
334,
272,
19783,
12,
199,
9,
421,
199,
533,
473,
433,
4332,
8,
18283,
304,
272,
15292,
63,
15119,
275,
283,
73,
433,
14,
6558,
7,
272,
15292,
63,
2339,
275,
283,
73,
433,
7,
272,
485,
5600,
63,
2632,
275,
519,
7,
2859,
24524,
1544,
20316,
73,
433,
4537,
6558,
32576,
6821,
32576,
26285,
15,
5547,
92,
3722,
15,
6147,
29635,
6697,
3722,
1304,
29,
18168,
48,
28,
344,
3072,
68,
29600,
339,
485,
7569,
275,
359,
267,
327,
13050,
14360,
267,
469,
288,
283,
633,
356,
283,
1014,
921,
1544,
14,
73,
433,
14,
6558,
15,
6821,
15,
2481,
12735,
297,
288,
283,
1064,
21,
356,
283,
22,
556,
21,
1235,
18,
8306,
69,
21655,
379,
12583,
12140,
68,
7362,
10800,
2177,
20,
297,
288,
283,
815,
63,
807,
356,
469,
355,
283,
344,
356,
283,
2481,
12735,
297,
355,
283,
832,
356,
283,
311,
20,
297,
355,
283,
1213,
356,
283,
141,
247,
19630,
21674,
7038,
241,
5657,
8474,
6500,
10356,
16961,
15578,
111,
6500,
19277,
7038,
121,
18624,
14978,
30160,
19820,
7753,
5806,
31815,
6286,
8474,
8474,
6500,
31235,
297,
355,
283,
1802,
356,
283,
1064,
21,
26,
66,
30666,
22653,
4489,
975,
1138,
67,
24,
771,
14761,
68,
24,
65,
2819,
645,
8867,
21,
70,
297,
355,
283,
5553,
356,
959,
20537,
12,
355,
283,
8311,
356,
283,
1014,
921,
273,
23135,
14,
73,
433,
14,
6558,
15,
70,
1165,
14,
86,
1850,
14,
25888,
2732,
14,
6558,
15,
4407,
15,
68,
15,
17,
15,
67,
19,
67,
15889,
11931,
65,
19171,
67,
1398,
66,
301,
2871,
23,
66,
21,
65,
13406,
65,
22,
14,
8476,
297,
288,
1660,
288,
283,
2759,
356,
283,
5903,
5419,
687,
820,
527,
10971,
297,
267,
1660,
267,
327,
11973,
1159,
542,
11317,
267,
469,
288,
283,
633,
356,
283,
1014,
921,
1544,
14,
73,
433,
14,
6558,
15,
6821,
15,
68,
2392,
69,
63,
565,
63,
76,
580,
2231,
15,
25,
15419,
297,
288,
283,
1064,
21,
356,
283,
11564,
70,
1367,
66,
1276,
69,
19,
379,
28250,
70,
271,
18,
1587,
26072,
708,
70,
20,
66,
19,
69,
297,
288,
283,
815,
63,
807,
356,
469,
355,
283,
344,
356,
283,
25,
15419,
297,
355,
283,
832,
356,
283,
311,
20,
297,
355,
283,
1213,
356,
283,
141,
243,
19630,
5806,
6286,
221,
16863,
116,
7038,
120,
27559,
25827,
5657,
446,
7038,
95,
21273,
6500,
14978,
413,
297,
355,
283,
5553,
356,
7875,
1229,
12,
355,
283,
8311,
356,
283,
1014,
921,
273,
23135,
14,
73,
433,
14,
6558,
15,
70,
1046,
14,
86,
1850,
14,
25888,
2732,
14,
6558,
15,
4407,
15,
24,
15,
20,
15,
30715,
3833,
1690,
1138,
10531,
70,
1153,
1344,
66,
23,
67,
18,
2470,
350,
24,
3003,
16,
14,
8476,
297,
288,
1660,
288,
283,
2759,
356,
283,
5903,
5419,
687,
820,
527,
10971,
297,
267,
789,
272,
1622,
339,
327,
27432,
701,
11030,
272,
485,
3159,
63,
6321,
275,
788,
1658,
20,
13,
674,
13,
11375,
297,
283,
1658,
20,
13,
11375,
297,
283,
3143,
54,
13,
320,
297,
283,
1658,
20,
13,
320,
297,
283,
3143,
54,
13,
5812,
297,
283,
1658,
20,
13,
5812,
297,
283,
1658,
20,
13,
3234,
49,
418,
339,
327,
27432,
701,
1568,
272,
485,
3159,
63,
8311,
83,
275,
788,
2719,
4295,
13,
6708,
88,
2710,
297,
283,
2719,
4295,
13,
8488,
297,
283,
2719,
4295,
13,
12021,
88,
21853,
418,
339,
347,
485,
5005,
63,
1802,
8,
277,
12,
3517,
304,
267,
333,
275,
295,
14,
1733,
8,
82,
7601,
2024,
536,
628,
1802,
2,
1564,
628,
2229,
48,
28,
1802,
13489,
937,
20415,
3133,
297,
3517,
9,
267,
372,
333,
14,
923,
360,
1802,
358,
340,
333,
365,
440,
488,
587,
488,
339,
347,
485,
5005,
63,
3349,
63,
835,
8,
277,
12,
3517,
304,
267,
333,
275,
295,
14,
1733,
28353,
83,
21528,
65,
4369,
13476,
2,
1305,
628,
1345,
13,
6223,
2,
1021,
628,
1287,
13,
3887,
8134,
6709,
14559,
83,
10,
141,
249,
32334,
23000,
18624,
7413,
27559,
6500,
6500,
3427,
83,
30957,
48,
28,
3349,
835,
3072,
68,
13439,
83,
10,
1108,
65,
4206,
3517,
9,
267,
372,
1109,
8,
77,
14,
923,
360,
3349,
835,
1333,
340,
333,
365,
440,
488,
587,
378,
339,
347,
485,
3093,
63,
5005,
8,
277,
12,
1166,
304,
267,
3991,
63,
344,
275,
291,
423,
1431,
63,
344,
8,
633,
9,
398,
2986,
63,
633,
275,
283,
1014,
921,
1246,
14,
25888,
2732,
14,
6558,
15,
1246,
15,
1001,
4805,
398,
666,
275,
469,
288,
283,
765,
356,
283,
983,
14,
1317,
14,
362,
297,
288,
283,
1162,
356,
359,
355,
3991,
63,
344,
12,
469,
490,
283,
2124,
356,
283,
83,
12363,
297,
490,
283,
21928,
3859,
356,
283,
1014,
921,
1544,
14,
73,
433,
14,
6558,
15,
6821,
3149,
83,
7,
450,
3991,
63,
344,
12,
490,
283,
388,
724,
5700,
356,
3991,
63,
344,
355,
789,
288,
1622,
267,
789,
398,
1056,
275,
8434,
63,
4078,
63,
1069,
14,
2017,
8,
1246,
63,
633,
12,
2022,
14,
4180,
8,
576,
430,
398,
3991,
63,
1001,
63,
1606,
275,
291,
423,
4249,
63,
12022,
8,
288,
1056,
12,
3991,
63,
344,
12,
283,
18085,
3991,
4840,
358,
267,
3991,
63,
1001,
275,
2022,
14,
3640,
8,
3722,
63,
1001,
63,
1606,
9,
398,
340,
283,
705,
7,
315,
3991,
63,
1001,
26,
288,
1125,
275,
3991,
63,
1001,
459,
705,
418,
288,
340,
1125,
459,
6493,
418,
508,
283,
1944,
29605,
3490,
1451,
356,
355,
746,
19783,
360,
9166,
450,
83,
1630,
440,
2187,
7,
450,
3991,
63,
344,
12,
1420,
29,
549,
9,
288,
746,
19783,
8,
355,
283,
6005,
370,
5235,
3991,
450,
83,
26,
450,
83,
7,
450,
334,
3722,
63,
344,
12,
1125,
459,
1188,
3815,
355,
1420,
29,
549,
9,
398,
754,
275,
3991,
63,
1001,
459,
1099,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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014-2016 Jesús Espino <jespinog@gmail.com>
# Copyright (C) 2014-2016 David Barragán <bameda@dbarragan.com>
# Copyright (C) 2014-2016 Alejandro Alonso <alejandro.alonso@kaleidos.net>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# NOTE: This file is useful to translate default projects templates. Remember update
# when taiga/projects/fixtures/initial_project_templates.json change.
from django.utils.translation import ugettext as _
##########################
## Default template information
##########################
# Translators: Name of scrum project template.
_("Scrum")
# Translators: Description of scrum project template.
_("The agile product backlog in Scrum is a prioritized features list, containing short descriptions of all functionality desired in the product. When applying Scrum, it's not necessary to start a project with a lengthy, upfront effort to document all requirements. The Scrum product backlog is then allowed to grow and change as more is learned about the product and its customers")
# Translators: Name of kanban project template.
_("Kanban")
# Translators: Description of kanban project template.
_("Kanban is a method for managing knowledge work with an emphasis on just-in-time delivery while not overloading the team members. In this approach, the process, from definition of a task to its delivery to the customer, is displayed for participants to see and team members pull work from a queue.")
##########################
## US Points
##########################
# Translators: User story point value (value = undefined)
_("?")
# Translators: User story point value (value = 0)
_("0")
# Translators: User story point value (value = 0.5)
_("1/2")
# Translators: User story point value (value = 1)
_("1")
# Translators: User story point value (value = 2)
_("2")
# Translators: User story point value (value = 3)
_("3")
# Translators: User story point value (value = 5)
_("5")
# Translators: User story point value (value = 8)
_("8")
# Translators: User story point value (value = 10)
_("10")
# Translators: User story point value (value = 13)
_("13")
# Translators: User story point value (value = 20)
_("20")
# Translators: User story point value (value = 40)
_("40")
##########################
## US Statuses
##########################
# Translators: User story status
_("New")
# Translators: User story status
_("Ready")
# Translators: User story status
_("In progress")
# Translators: User story status
_("Ready for test")
# Translators: User story status
_("Done")
# Translators: User story status
_("Archived")
##########################
## Task Statuses
##########################
# Translators: Task status
_("New")
# Translators: Task status
_("In progress")
# Translators: Task status
_("Ready for test")
# Translators: Task status
_("Closed")
# Translators: Task status
_("Needs Info")
##########################
## Issue Statuses
##########################
# Translators: Issue status
_("New")
# Translators: Issue status
_("In progress")
# Translators: Issue status
_("Ready for test")
# Translators: Issue status
_("Closed")
# Translators: Issue status
_("Needs Info")
# Translators: Issue status
_("Postponed")
# Translators: Issue status
_("Rejected")
##########################
## Issue Statuses
##########################
# Translators: Issue type
_("Bug")
# Translators: Issue type
_("Question")
# Translators: Issue type
_("Enhancement")
##########################
## Priorities
##########################
# Translators: Issue priority
_("Low")
# Translators: Issue priority
_("Normal")
# Translators: Issue priority
_("High")
##########################
## Severities
##########################
# Translators: Issue severity
_("Wishlist")
# Translators: Issue severity
_("Minor")
# Translators: Issue severity
_("Normal")
# Translators: Issue severity
_("Important")
# Translators: Issue severity
_("Critical")
##########################
## Roles
##########################
# Translators: User role
_("UX")
# Translators: User role
_("Design")
# Translators: User role
_("Front")
# Translators: User role
_("Back")
# Translators: User role
_("Product Owner")
# Translators: User role
_("Stakeholder")
|
mit
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
1898,
334,
35,
9,
6927,
13,
9261,
6061,
17885,
437,
343,
3210,
72,
665,
8445,
14249,
32,
8445,
14249,
14,
15291,
30,
199,
3,
1898,
334,
35,
9,
6927,
13,
9261,
1603,
397,
24602,
83,
662,
681,
10175,
665,
74,
397,
7751,
974,
32,
6799,
14,
957,
30,
199,
3,
1898,
334,
35,
9,
6927,
13,
9261,
20232,
12377,
2527,
11302,
78,
665,
66,
313,
983,
32,
697,
285,
2527,
290,
14,
957,
30,
199,
3,
1898,
334,
35,
9,
6927,
13,
9261,
6832,
74,
460,
293,
4580,
265,
1152,
665,
1895,
74,
460,
293,
14,
279,
265,
1152,
32,
75,
1895,
344,
736,
14,
846,
30,
199,
3,
961,
2240,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
652,
1334,
314,
2895,
402,
314,
1664,
4265,
1696,
1684,
844,
465,
199,
3,
3267,
701,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
199,
3,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
1664,
4265,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
4265,
1696,
1684,
844,
199,
3,
3180,
543,
642,
2240,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
199,
3,
6944,
26,
961,
570,
365,
2997,
370,
9028,
849,
11336,
7009,
14,
31859,
1678,
199,
3,
755,
1380,
3052,
29055,
15,
6776,
15,
8769,
15,
2747,
63,
1715,
63,
5876,
14,
1001,
1570,
14,
199,
199,
504,
1639,
14,
1208,
14,
6893,
492,
10366,
465,
485,
421,
199,
6565,
309,
199,
309,
3758,
1978,
2556,
199,
6565,
309,
199,
199,
3,
26355,
26,
2812,
402,
19270,
453,
2199,
1978,
14,
199,
14332,
51,
1556,
453,
531,
199,
3,
26355,
26,
11994,
402,
19270,
453,
2199,
1978,
14,
199,
14332,
1918,
1839,
441,
3336,
1771,
793,
315,
428,
1556,
453,
365,
282,
6791,
5277,
7068,
4534,
769,
12,
3035,
3974,
18714,
402,
1006,
9330,
6387,
315,
314,
3336,
14,
3979,
18876,
428,
1556,
453,
12,
652,
1159,
440,
5784,
370,
1343,
282,
2199,
543,
282,
2582,
89,
12,
1536,
14708,
28058,
370,
2213,
1006,
9760,
14,
710,
428,
1556,
453,
3336,
1771,
793,
365,
2066,
4370,
370,
20772,
436,
1570,
465,
1655,
365,
12537,
379,
3595,
314,
3336,
436,
2399,
286,
28078,
531,
199,
199,
3,
26355,
26,
2812,
402,
1022,
290,
13206,
2199,
1978,
14,
199,
14332,
43,
290,
13206,
531,
199,
3,
26355,
26,
11994,
402,
1022,
290,
13206,
2199,
1978,
14,
199,
14332,
43,
290,
13206,
365,
282,
1083,
367,
28453,
29105,
1736,
543,
376,
9052,
24059,
641,
2951,
13,
262,
13,
521,
18719,
1830,
440,
1806,
8786,
314,
8099,
7556,
14,
1010,
642,
18140,
12,
314,
2112,
12,
687,
5492,
402,
282,
2120,
370,
2399,
18719,
370,
314,
15229,
12,
365,
9080,
367,
623,
20989,
370,
1937,
436,
8099,
7556,
10299,
1736,
687,
282,
4126,
2685,
421,
199,
6565,
309,
199,
309,
19635,
32598,
199,
6565,
309,
199,
199,
3,
26355,
26,
2876,
19222,
2376,
574,
334,
585,
275,
10942,
9,
199,
14332,
18582,
199,
3,
26355,
26,
2876,
19222,
2376,
574,
334,
585,
275,
378,
9,
199,
14332,
16,
531,
199,
3,
26355,
26,
2876,
19222,
2376,
574,
334,
585,
275,
378,
14,
21,
9,
199,
14332,
17,
15,
18,
531,
199,
3,
26355,
26,
2876,
19222,
2376,
574,
334,
585,
275,
413,
9,
199,
14332,
17,
531,
199,
3,
26355,
26,
2876,
19222,
2376,
574,
334,
585,
275,
499,
9,
199,
14332,
18,
531,
199,
3,
26355,
26,
2876,
19222,
2376,
574,
334,
585,
275,
650,
9,
199,
14332,
19,
531,
199,
3,
26355,
26,
2876,
19222,
2376,
574,
334,
585,
275,
959,
9,
199,
14332,
21,
531,
199,
3,
26355,
26,
2876,
19222,
2376,
574,
334,
585,
275,
1695,
9,
199,
14332,
24,
531,
199,
3,
26355,
26,
2876,
19222,
2376,
574,
334,
585,
275,
1616,
9,
199,
14332,
709,
531,
199,
3,
26355,
26,
2876,
19222,
2376,
574,
334,
585,
275,
4944,
9,
199,
14332,
969,
531,
199,
3,
26355,
26,
2876,
19222,
2376,
574,
334,
585,
275,
3388,
9,
199,
14332,
1165,
531,
199,
3,
26355,
26,
2876,
19222,
2376,
574,
334,
585,
275,
6335,
9,
199,
14332,
2167,
531,
421,
199,
6565,
309,
199,
309,
19635,
27673,
5589,
199,
6565,
309,
199,
199,
3,
26355,
26,
2876,
19222,
2004,
199,
14332,
4665,
531,
199,
199,
3,
26355,
26,
2876,
19222,
2004,
199,
14332,
17960,
531,
199,
199,
3,
26355,
26,
2876,
19222,
2004,
199,
14332,
607,
6696,
531,
199,
199,
3,
26355,
26,
2876,
19222,
2004,
199,
14332,
17960,
367,
511,
531,
199,
199,
3,
26355,
26,
2876,
19222,
2004,
199,
14332,
10759,
531,
199,
199,
3,
26355,
26,
2876,
19222,
2004,
199,
14332,
8438,
12905,
531,
421,
199,
6565,
309,
199,
309,
8495,
27673,
5589,
199,
6565,
309,
199,
199,
3,
26355,
26,
8495,
2004,
199,
14332,
4665,
531,
199,
3,
26355,
26,
8495,
2004,
199,
14332,
607,
6696,
531,
199,
3,
26355,
26,
8495,
2004,
199,
14332,
17960,
367,
511,
531,
199,
3,
26355,
26,
8495,
2004,
199,
14332,
15190,
531,
199,
3,
26355,
26,
8495,
2004,
199,
14332,
28390,
10332,
531,
421,
199,
6565,
309,
199,
309,
13383,
27673,
5589,
199,
6565,
309,
199,
199,
3,
26355,
26,
13383,
2004,
199,
14332,
4665,
531,
199,
3,
26355,
26,
13383,
2004,
199,
14332,
607,
6696,
531,
199,
3,
26355,
26,
13383,
2004,
199,
14332,
17960,
367,
511,
531,
199,
3,
26355,
26,
13383,
2004,
199,
14332,
15190,
531,
199,
3,
26355,
26,
13383,
2004,
199,
14332,
28390,
10332,
531,
199,
3,
26355,
26,
13383,
2004,
199,
14332,
6564,
80,
28918,
531,
199,
3,
26355,
26,
13383,
2004,
199,
14332,
497,
8553,
531,
421,
199,
6565,
309,
199,
309,
13383,
27673,
5589,
199,
6565,
309,
199,
199,
3,
26355,
26,
13383,
730
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
1898,
334,
35,
9,
6927,
13,
9261,
6061,
17885,
437,
343,
3210,
72,
665,
8445,
14249,
32,
8445,
14249,
14,
15291,
30,
199,
3,
1898,
334,
35,
9,
6927,
13,
9261,
1603,
397,
24602,
83,
662,
681,
10175,
665,
74,
397,
7751,
974,
32,
6799,
14,
957,
30,
199,
3,
1898,
334,
35,
9,
6927,
13,
9261,
20232,
12377,
2527,
11302,
78,
665,
66,
313,
983,
32,
697,
285,
2527,
290,
14,
957,
30,
199,
3,
1898,
334,
35,
9,
6927,
13,
9261,
6832,
74,
460,
293,
4580,
265,
1152,
665,
1895,
74,
460,
293,
14,
279,
265,
1152,
32,
75,
1895,
344,
736,
14,
846,
30,
199,
3,
961,
2240,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
652,
1334,
314,
2895,
402,
314,
1664,
4265,
1696,
1684,
844,
465,
199,
3,
3267,
701,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
199,
3,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
1664,
4265,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
4265,
1696,
1684,
844,
199,
3,
3180,
543,
642,
2240,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
199,
3,
6944,
26,
961,
570,
365,
2997,
370,
9028,
849,
11336,
7009,
14,
31859,
1678,
199,
3,
755,
1380,
3052,
29055,
15,
6776,
15,
8769,
15,
2747,
63,
1715,
63,
5876,
14,
1001,
1570,
14,
199,
199,
504,
1639,
14,
1208,
14,
6893,
492,
10366,
465,
485,
421,
199,
6565,
309,
199,
309,
3758,
1978,
2556,
199,
6565,
309,
199,
199,
3,
26355,
26,
2812,
402,
19270,
453,
2199,
1978,
14,
199,
14332,
51,
1556,
453,
531,
199,
3,
26355,
26,
11994,
402,
19270,
453,
2199,
1978,
14,
199,
14332,
1918,
1839,
441,
3336,
1771,
793,
315,
428,
1556,
453,
365,
282,
6791,
5277,
7068,
4534,
769,
12,
3035,
3974,
18714,
402,
1006,
9330,
6387,
315,
314,
3336,
14,
3979,
18876,
428,
1556,
453,
12,
652,
1159,
440,
5784,
370,
1343,
282,
2199,
543,
282,
2582,
89,
12,
1536,
14708,
28058,
370,
2213,
1006,
9760,
14,
710,
428,
1556,
453,
3336,
1771,
793,
365,
2066,
4370,
370,
20772,
436,
1570,
465,
1655,
365,
12537,
379,
3595,
314,
3336,
436,
2399,
286,
28078,
531,
199,
199,
3,
26355,
26,
2812,
402,
1022,
290,
13206,
2199,
1978,
14,
199,
14332,
43,
290,
13206,
531,
199,
3,
26355,
26,
11994,
402,
1022,
290,
13206,
2199,
1978,
14,
199,
14332,
43,
290,
13206,
365,
282,
1083,
367,
28453,
29105,
1736,
543,
376,
9052,
24059,
641,
2951,
13,
262,
13,
521,
18719,
1830,
440,
1806,
8786,
314,
8099,
7556,
14,
1010,
642,
18140,
12,
314,
2112,
12,
687,
5492,
402,
282,
2120,
370,
2399,
18719,
370,
314,
15229,
12,
365,
9080,
367,
623,
20989,
370,
1937,
436,
8099,
7556,
10299,
1736,
687,
282,
4126,
2685,
421,
199,
6565,
309,
199,
309,
19635,
32598,
199,
6565,
309,
199,
199,
3,
26355,
26,
2876,
19222,
2376,
574,
334,
585,
275,
10942,
9,
199,
14332,
18582,
199,
3,
26355,
26,
2876,
19222,
2376,
574,
334,
585,
275,
378,
9,
199,
14332,
16,
531,
199,
3,
26355,
26,
2876,
19222,
2376,
574,
334,
585,
275,
378,
14,
21,
9,
199,
14332,
17,
15,
18,
531,
199,
3,
26355,
26,
2876,
19222,
2376,
574,
334,
585,
275,
413,
9,
199,
14332,
17,
531,
199,
3,
26355,
26,
2876,
19222,
2376,
574,
334,
585,
275,
499,
9,
199,
14332,
18,
531,
199,
3,
26355,
26,
2876,
19222,
2376,
574,
334,
585,
275,
650,
9,
199,
14332,
19,
531,
199,
3,
26355,
26,
2876,
19222,
2376,
574,
334,
585,
275,
959,
9,
199,
14332,
21,
531,
199,
3,
26355,
26,
2876,
19222,
2376,
574,
334,
585,
275,
1695,
9,
199,
14332,
24,
531,
199,
3,
26355,
26,
2876,
19222,
2376,
574,
334,
585,
275,
1616,
9,
199,
14332,
709,
531,
199,
3,
26355,
26,
2876,
19222,
2376,
574,
334,
585,
275,
4944,
9,
199,
14332,
969,
531,
199,
3,
26355,
26,
2876,
19222,
2376,
574,
334,
585,
275,
3388,
9,
199,
14332,
1165,
531,
199,
3,
26355,
26,
2876,
19222,
2376,
574,
334,
585,
275,
6335,
9,
199,
14332,
2167,
531,
421,
199,
6565,
309,
199,
309,
19635,
27673,
5589,
199,
6565,
309,
199,
199,
3,
26355,
26,
2876,
19222,
2004,
199,
14332,
4665,
531,
199,
199,
3,
26355,
26,
2876,
19222,
2004,
199,
14332,
17960,
531,
199,
199,
3,
26355,
26,
2876,
19222,
2004,
199,
14332,
607,
6696,
531,
199,
199,
3,
26355,
26,
2876,
19222,
2004,
199,
14332,
17960,
367,
511,
531,
199,
199,
3,
26355,
26,
2876,
19222,
2004,
199,
14332,
10759,
531,
199,
199,
3,
26355,
26,
2876,
19222,
2004,
199,
14332,
8438,
12905,
531,
421,
199,
6565,
309,
199,
309,
8495,
27673,
5589,
199,
6565,
309,
199,
199,
3,
26355,
26,
8495,
2004,
199,
14332,
4665,
531,
199,
3,
26355,
26,
8495,
2004,
199,
14332,
607,
6696,
531,
199,
3,
26355,
26,
8495,
2004,
199,
14332,
17960,
367,
511,
531,
199,
3,
26355,
26,
8495,
2004,
199,
14332,
15190,
531,
199,
3,
26355,
26,
8495,
2004,
199,
14332,
28390,
10332,
531,
421,
199,
6565,
309,
199,
309,
13383,
27673,
5589,
199,
6565,
309,
199,
199,
3,
26355,
26,
13383,
2004,
199,
14332,
4665,
531,
199,
3,
26355,
26,
13383,
2004,
199,
14332,
607,
6696,
531,
199,
3,
26355,
26,
13383,
2004,
199,
14332,
17960,
367,
511,
531,
199,
3,
26355,
26,
13383,
2004,
199,
14332,
15190,
531,
199,
3,
26355,
26,
13383,
2004,
199,
14332,
28390,
10332,
531,
199,
3,
26355,
26,
13383,
2004,
199,
14332,
6564,
80,
28918,
531,
199,
3,
26355,
26,
13383,
2004,
199,
14332,
497,
8553,
531,
421,
199,
6565,
309,
199,
309,
13383,
27673,
5589,
199,
6565,
309,
199,
199,
3,
26355,
26,
13383,
730,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
Sentdex/pygta5
|
models.py
|
1
|
47729
|
'''
Copyright 2015 Google Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
'''
import tflearn
from tflearn.layers.conv import conv_2d, max_pool_2d,avg_pool_2d, conv_3d, max_pool_3d, avg_pool_3d
from tflearn.layers.core import input_data, dropout, fully_connected
from tflearn.layers.estimator import regression
from tflearn.layers.normalization import local_response_normalization
from tflearn.layers.merge_ops import merge
#used in v0.03-v0.06+
def otherception3(width, height, frame_count, lr, output=9, model_name = 'otherception.model', device = 'gpu', num = '0'):
with tf.device('/{}:{}'.format(device,num)):
network = input_data(shape=[None, width, height,3], name='input')
conv1_7_7 = conv_2d(network, 64, 28, strides=4, activation='relu', name = 'conv1_7_7_s2')
pool1_3_3 = max_pool_2d(conv1_7_7, 9,strides=4)
pool1_3_3 = local_response_normalization(pool1_3_3)
conv2_3_3_reduce = conv_2d(pool1_3_3, 64,1, activation='relu',name = 'conv2_3_3_reduce')
conv2_3_3 = conv_2d(conv2_3_3_reduce, 192,12, activation='relu', name='conv2_3_3')
conv2_3_3 = local_response_normalization(conv2_3_3)
pool2_3_3 = max_pool_2d(conv2_3_3, kernel_size=12, strides=2, name='pool2_3_3_s2')
inception_3a_1_1 = conv_2d(pool2_3_3, 64, 1, activation='relu', name='inception_3a_1_1')
inception_3a_3_3_reduce = conv_2d(pool2_3_3, 96,1, activation='relu', name='inception_3a_3_3_reduce')
inception_3a_3_3 = conv_2d(inception_3a_3_3_reduce, 128,filter_size=12, activation='relu', name = 'inception_3a_3_3')
inception_3a_5_5_reduce = conv_2d(pool2_3_3,16, filter_size=1,activation='relu', name ='inception_3a_5_5_reduce' )
inception_3a_5_5 = conv_2d(inception_3a_5_5_reduce, 32, filter_size=15, activation='relu', name= 'inception_3a_5_5')
inception_3a_pool = max_pool_2d(pool2_3_3, kernel_size=12, strides=1, )
inception_3a_pool_1_1 = conv_2d(inception_3a_pool, 32, filter_size=1, activation='relu', name='inception_3a_pool_1_1')
# merge the inception_3a__
inception_3a_output = merge([inception_3a_1_1, inception_3a_3_3, inception_3a_5_5, inception_3a_pool_1_1], mode='concat', axis=3)
inception_3b_1_1 = conv_2d(inception_3a_output, 128,filter_size=1,activation='relu', name= 'inception_3b_1_1' )
inception_3b_3_3_reduce = conv_2d(inception_3a_output, 128, filter_size=1, activation='relu', name='inception_3b_3_3_reduce')
inception_3b_3_3 = conv_2d(inception_3b_3_3_reduce, 192, filter_size=9, activation='relu',name='inception_3b_3_3')
inception_3b_5_5_reduce = conv_2d(inception_3a_output, 32, filter_size=1, activation='relu', name = 'inception_3b_5_5_reduce')
inception_3b_5_5 = conv_2d(inception_3b_5_5_reduce, 96, filter_size=15, name = 'inception_3b_5_5')
inception_3b_pool = max_pool_2d(inception_3a_output, kernel_size=12, strides=1, name='inception_3b_pool')
inception_3b_pool_1_1 = conv_2d(inception_3b_pool, 64, filter_size=1,activation='relu', name='inception_3b_pool_1_1')
#merge the inception_3b_*
inception_3b_output = merge([inception_3b_1_1, inception_3b_3_3, inception_3b_5_5, inception_3b_pool_1_1], mode='concat',axis=3,name='inception_3b_output')
pool3_3_3 = max_pool_2d(inception_3b_output, kernel_size=3, strides=2, name='pool3_3_3')
inception_4a_1_1 = conv_2d(pool3_3_3, 192, filter_size=1, activation='relu', name='inception_4a_1_1')
inception_4a_3_3_reduce = conv_2d(pool3_3_3, 96, filter_size=1, activation='relu', name='inception_4a_3_3_reduce')
inception_4a_3_3 = conv_2d(inception_4a_3_3_reduce, 208, filter_size=3, activation='relu', name='inception_4a_3_3')
inception_4a_5_5_reduce = conv_2d(pool3_3_3, 16, filter_size=1, activation='relu', name='inception_4a_5_5_reduce')
inception_4a_5_5 = conv_2d(inception_4a_5_5_reduce, 48, filter_size=5, activation='relu', name='inception_4a_5_5')
inception_4a_pool = max_pool_2d(pool3_3_3, kernel_size=3, strides=1, name='inception_4a_pool')
inception_4a_pool_1_1 = conv_2d(inception_4a_pool, 64, filter_size=1, activation='relu', name='inception_4a_pool_1_1')
inception_4a_output = merge([inception_4a_1_1, inception_4a_3_3, inception_4a_5_5, inception_4a_pool_1_1], mode='concat', axis=3, name='inception_4a_output')
inception_4b_1_1 = conv_2d(inception_4a_output, 160, filter_size=1, activation='relu', name='inception_4a_1_1')
inception_4b_3_3_reduce = conv_2d(inception_4a_output, 112, filter_size=1, activation='relu', name='inception_4b_3_3_reduce')
inception_4b_3_3 = conv_2d(inception_4b_3_3_reduce, 224, filter_size=3, activation='relu', name='inception_4b_3_3')
inception_4b_5_5_reduce = conv_2d(inception_4a_output, 24, filter_size=1, activation='relu', name='inception_4b_5_5_reduce')
inception_4b_5_5 = conv_2d(inception_4b_5_5_reduce, 64, filter_size=5, activation='relu', name='inception_4b_5_5')
inception_4b_pool = max_pool_2d(inception_4a_output, kernel_size=3, strides=1, name='inception_4b_pool')
inception_4b_pool_1_1 = conv_2d(inception_4b_pool, 64, filter_size=1, activation='relu', name='inception_4b_pool_1_1')
inception_4b_output = merge([inception_4b_1_1, inception_4b_3_3, inception_4b_5_5, inception_4b_pool_1_1], mode='concat', axis=3, name='inception_4b_output')
inception_4c_1_1 = conv_2d(inception_4b_output, 128, filter_size=1, activation='relu',name='inception_4c_1_1')
inception_4c_3_3_reduce = conv_2d(inception_4b_output, 128, filter_size=1, activation='relu', name='inception_4c_3_3_reduce')
inception_4c_3_3 = conv_2d(inception_4c_3_3_reduce, 256, filter_size=3, activation='relu', name='inception_4c_3_3')
inception_4c_5_5_reduce = conv_2d(inception_4b_output, 24, filter_size=1, activation='relu', name='inception_4c_5_5_reduce')
inception_4c_5_5 = conv_2d(inception_4c_5_5_reduce, 64, filter_size=5, activation='relu', name='inception_4c_5_5')
inception_4c_pool = max_pool_2d(inception_4b_output, kernel_size=3, strides=1)
inception_4c_pool_1_1 = conv_2d(inception_4c_pool, 64, filter_size=1, activation='relu', name='inception_4c_pool_1_1')
inception_4c_output = merge([inception_4c_1_1, inception_4c_3_3, inception_4c_5_5, inception_4c_pool_1_1], mode='concat', axis=3,name='inception_4c_output')
inception_4d_1_1 = conv_2d(inception_4c_output, 112, filter_size=1, activation='relu', name='inception_4d_1_1')
inception_4d_3_3_reduce = conv_2d(inception_4c_output, 144, filter_size=1, activation='relu', name='inception_4d_3_3_reduce')
inception_4d_3_3 = conv_2d(inception_4d_3_3_reduce, 288, filter_size=3, activation='relu', name='inception_4d_3_3')
inception_4d_5_5_reduce = conv_2d(inception_4c_output, 32, filter_size=1, activation='relu', name='inception_4d_5_5_reduce')
inception_4d_5_5 = conv_2d(inception_4d_5_5_reduce, 64, filter_size=5, activation='relu', name='inception_4d_5_5')
inception_4d_pool = max_pool_2d(inception_4c_output, kernel_size=3, strides=1, name='inception_4d_pool')
inception_4d_pool_1_1 = conv_2d(inception_4d_pool, 64, filter_size=1, activation='relu', name='inception_4d_pool_1_1')
inception_4d_output = merge([inception_4d_1_1, inception_4d_3_3, inception_4d_5_5, inception_4d_pool_1_1], mode='concat', axis=3, name='inception_4d_output')
inception_4e_1_1 = conv_2d(inception_4d_output, 256, filter_size=1, activation='relu', name='inception_4e_1_1')
inception_4e_3_3_reduce = conv_2d(inception_4d_output, 160, filter_size=1, activation='relu', name='inception_4e_3_3_reduce')
inception_4e_3_3 = conv_2d(inception_4e_3_3_reduce, 320, filter_size=3, activation='relu', name='inception_4e_3_3')
inception_4e_5_5_reduce = conv_2d(inception_4d_output, 32, filter_size=1, activation='relu', name='inception_4e_5_5_reduce')
inception_4e_5_5 = conv_2d(inception_4e_5_5_reduce, 128, filter_size=5, activation='relu', name='inception_4e_5_5')
inception_4e_pool = max_pool_2d(inception_4d_output, kernel_size=3, strides=1, name='inception_4e_pool')
inception_4e_pool_1_1 = conv_2d(inception_4e_pool, 128, filter_size=1, activation='relu', name='inception_4e_pool_1_1')
inception_4e_output = merge([inception_4e_1_1, inception_4e_3_3, inception_4e_5_5,inception_4e_pool_1_1],axis=3, mode='concat')
pool4_3_3 = max_pool_2d(inception_4e_output, kernel_size=3, strides=2, name='pool_3_3')
inception_5a_1_1 = conv_2d(pool4_3_3, 256, filter_size=1, activation='relu', name='inception_5a_1_1')
inception_5a_3_3_reduce = conv_2d(pool4_3_3, 160, filter_size=1, activation='relu', name='inception_5a_3_3_reduce')
inception_5a_3_3 = conv_2d(inception_5a_3_3_reduce, 320, filter_size=3, activation='relu', name='inception_5a_3_3')
inception_5a_5_5_reduce = conv_2d(pool4_3_3, 32, filter_size=1, activation='relu', name='inception_5a_5_5_reduce')
inception_5a_5_5 = conv_2d(inception_5a_5_5_reduce, 128, filter_size=5, activation='relu', name='inception_5a_5_5')
inception_5a_pool = max_pool_2d(pool4_3_3, kernel_size=3, strides=1, name='inception_5a_pool')
inception_5a_pool_1_1 = conv_2d(inception_5a_pool, 128, filter_size=1,activation='relu', name='inception_5a_pool_1_1')
inception_5a_output = merge([inception_5a_1_1, inception_5a_3_3, inception_5a_5_5, inception_5a_pool_1_1], axis=3,mode='concat')
inception_5b_1_1 = conv_2d(inception_5a_output, 384, filter_size=1,activation='relu', name='inception_5b_1_1')
inception_5b_3_3_reduce = conv_2d(inception_5a_output, 192, filter_size=1, activation='relu', name='inception_5b_3_3_reduce')
inception_5b_3_3 = conv_2d(inception_5b_3_3_reduce, 384, filter_size=3,activation='relu', name='inception_5b_3_3')
inception_5b_5_5_reduce = conv_2d(inception_5a_output, 48, filter_size=1, activation='relu', name='inception_5b_5_5_reduce')
inception_5b_5_5 = conv_2d(inception_5b_5_5_reduce,128, filter_size=5, activation='relu', name='inception_5b_5_5' )
inception_5b_pool = max_pool_2d(inception_5a_output, kernel_size=3, strides=1, name='inception_5b_pool')
inception_5b_pool_1_1 = conv_2d(inception_5b_pool, 128, filter_size=1, activation='relu', name='inception_5b_pool_1_1')
inception_5b_output = merge([inception_5b_1_1, inception_5b_3_3, inception_5b_5_5, inception_5b_pool_1_1], axis=3, mode='concat')
pool5_7_7 = avg_pool_2d(inception_5b_output, kernel_size=7, strides=1)
pool5_7_7 = dropout(pool5_7_7, 0.4)
loss = fully_connected(pool5_7_7, output,activation='softmax')
network = regression(loss, optimizer='momentum',
loss='categorical_crossentropy',
learning_rate=lr, name='targets')
model = tflearn.DNN(network,
max_checkpoints=0, tensorboard_verbose=0,tensorboard_dir='log')
return model
def resnext(width, height, frame_count, lr, output=9, model_name = 'sentnet_color.model'):
net = input_data(shape=[None, width, height, 3], name='input')
net = tflearn.conv_2d(net, 16, 3, regularizer='L2', weight_decay=0.0001)
net = tflearn.layers.conv.resnext_block(net, n, 16, 32)
net = tflearn.resnext_block(net, 1, 32, 32, downsample=True)
net = tflearn.resnext_block(net, n-1, 32, 32)
net = tflearn.resnext_block(net, 1, 64, 32, downsample=True)
net = tflearn.resnext_block(net, n-1, 64, 32)
net = tflearn.batch_normalization(net)
net = tflearn.activation(net, 'relu')
net = tflearn.global_avg_pool(net)
# Regression
net = tflearn.fully_connected(net, output, activation='softmax')
opt = tflearn.Momentum(0.1, lr_decay=0.1, decay_step=32000, staircase=True)
net = tflearn.regression(net, optimizer=opt,
loss='categorical_crossentropy')
model = tflearn.DNN(net,
max_checkpoints=0, tensorboard_verbose=0, tensorboard_dir='log')
return model
def sentnet_color_2d(width, height, frame_count, lr, output=9, model_name = 'sentnet_color.model'):
network = input_data(shape=[None, width, height, 3], name='input')
network = conv_2d(network, 96, 11, strides=4, activation='relu')
network = max_pool_2d(network, 3, strides=2)
network = local_response_normalization(network)
network = conv_2d(network, 256, 5, activation='relu')
network = max_pool_2d(network, 3, strides=2)
network = local_response_normalization(network)
network = conv_2d(network, 384, 3, activation='relu')
network = conv_2d(network, 384, 3, activation='relu')
network = conv_2d(network, 256, 3, activation='relu')
network = max_pool_2d(network, 3, strides=2)
network = conv_2d(network, 256, 5, activation='relu')
network = max_pool_2d(network, 3, strides=2)
network = local_response_normalization(network)
network = conv_2d(network, 384, 3, activation='relu')
network = conv_2d(network, 384, 3, activation='relu')
network = conv_2d(network, 256, 3, activation='relu')
network = max_pool_2d(network, 3, strides=2)
network = local_response_normalization(network)
network = fully_connected(network, 4096, activation='tanh')
network = dropout(network, 0.5)
network = fully_connected(network, 4096, activation='tanh')
network = dropout(network, 0.5)
network = fully_connected(network, 4096, activation='tanh')
network = dropout(network, 0.5)
network = fully_connected(network, 4096, activation='tanh')
network = dropout(network, 0.5)
network = fully_connected(network, output, activation='softmax')
network = regression(network, optimizer='momentum',
loss='categorical_crossentropy',
learning_rate=lr, name='targets')
model = tflearn.DNN(network,
max_checkpoints=0, tensorboard_verbose=0, tensorboard_dir='log')
return model
def inception_v3(width, height, frame_count, lr, output=9, model_name = 'sentnet_color.model'):
network = input_data(shape=[None, width, height,3], name='input')
conv1_7_7 = conv_2d(network, 64, 7, strides=2, activation='relu', name = 'conv1_7_7_s2')
pool1_3_3 = max_pool_2d(conv1_7_7, 3,strides=2)
pool1_3_3 = local_response_normalization(pool1_3_3)
conv2_3_3_reduce = conv_2d(pool1_3_3, 64,1, activation='relu',name = 'conv2_3_3_reduce')
conv2_3_3 = conv_2d(conv2_3_3_reduce, 192,3, activation='relu', name='conv2_3_3')
conv2_3_3 = local_response_normalization(conv2_3_3)
pool2_3_3 = max_pool_2d(conv2_3_3, kernel_size=3, strides=2, name='pool2_3_3_s2')
inception_3a_1_1 = conv_2d(pool2_3_3, 64, 1, activation='relu', name='inception_3a_1_1')
inception_3a_3_3_reduce = conv_2d(pool2_3_3, 96,1, activation='relu', name='inception_3a_3_3_reduce')
inception_3a_3_3 = conv_2d(inception_3a_3_3_reduce, 128,filter_size=3, activation='relu', name = 'inception_3a_3_3')
inception_3a_5_5_reduce = conv_2d(pool2_3_3,16, filter_size=1,activation='relu', name ='inception_3a_5_5_reduce' )
inception_3a_5_5 = conv_2d(inception_3a_5_5_reduce, 32, filter_size=5, activation='relu', name= 'inception_3a_5_5')
inception_3a_pool = max_pool_2d(pool2_3_3, kernel_size=3, strides=1, )
inception_3a_pool_1_1 = conv_2d(inception_3a_pool, 32, filter_size=1, activation='relu', name='inception_3a_pool_1_1')
# merge the inception_3a__
inception_3a_output = merge([inception_3a_1_1, inception_3a_3_3, inception_3a_5_5, inception_3a_pool_1_1], mode='concat', axis=3)
inception_3b_1_1 = conv_2d(inception_3a_output, 128,filter_size=1,activation='relu', name= 'inception_3b_1_1' )
inception_3b_3_3_reduce = conv_2d(inception_3a_output, 128, filter_size=1, activation='relu', name='inception_3b_3_3_reduce')
inception_3b_3_3 = conv_2d(inception_3b_3_3_reduce, 192, filter_size=3, activation='relu',name='inception_3b_3_3')
inception_3b_5_5_reduce = conv_2d(inception_3a_output, 32, filter_size=1, activation='relu', name = 'inception_3b_5_5_reduce')
inception_3b_5_5 = conv_2d(inception_3b_5_5_reduce, 96, filter_size=5, name = 'inception_3b_5_5')
inception_3b_pool = max_pool_2d(inception_3a_output, kernel_size=3, strides=1, name='inception_3b_pool')
inception_3b_pool_1_1 = conv_2d(inception_3b_pool, 64, filter_size=1,activation='relu', name='inception_3b_pool_1_1')
#merge the inception_3b_*
inception_3b_output = merge([inception_3b_1_1, inception_3b_3_3, inception_3b_5_5, inception_3b_pool_1_1], mode='concat',axis=3,name='inception_3b_output')
pool3_3_3 = max_pool_2d(inception_3b_output, kernel_size=3, strides=2, name='pool3_3_3')
inception_4a_1_1 = conv_2d(pool3_3_3, 192, filter_size=1, activation='relu', name='inception_4a_1_1')
inception_4a_3_3_reduce = conv_2d(pool3_3_3, 96, filter_size=1, activation='relu', name='inception_4a_3_3_reduce')
inception_4a_3_3 = conv_2d(inception_4a_3_3_reduce, 208, filter_size=3, activation='relu', name='inception_4a_3_3')
inception_4a_5_5_reduce = conv_2d(pool3_3_3, 16, filter_size=1, activation='relu', name='inception_4a_5_5_reduce')
inception_4a_5_5 = conv_2d(inception_4a_5_5_reduce, 48, filter_size=5, activation='relu', name='inception_4a_5_5')
inception_4a_pool = max_pool_2d(pool3_3_3, kernel_size=3, strides=1, name='inception_4a_pool')
inception_4a_pool_1_1 = conv_2d(inception_4a_pool, 64, filter_size=1, activation='relu', name='inception_4a_pool_1_1')
inception_4a_output = merge([inception_4a_1_1, inception_4a_3_3, inception_4a_5_5, inception_4a_pool_1_1], mode='concat', axis=3, name='inception_4a_output')
inception_4b_1_1 = conv_2d(inception_4a_output, 160, filter_size=1, activation='relu', name='inception_4a_1_1')
inception_4b_3_3_reduce = conv_2d(inception_4a_output, 112, filter_size=1, activation='relu', name='inception_4b_3_3_reduce')
inception_4b_3_3 = conv_2d(inception_4b_3_3_reduce, 224, filter_size=3, activation='relu', name='inception_4b_3_3')
inception_4b_5_5_reduce = conv_2d(inception_4a_output, 24, filter_size=1, activation='relu', name='inception_4b_5_5_reduce')
inception_4b_5_5 = conv_2d(inception_4b_5_5_reduce, 64, filter_size=5, activation='relu', name='inception_4b_5_5')
inception_4b_pool = max_pool_2d(inception_4a_output, kernel_size=3, strides=1, name='inception_4b_pool')
inception_4b_pool_1_1 = conv_2d(inception_4b_pool, 64, filter_size=1, activation='relu', name='inception_4b_pool_1_1')
inception_4b_output = merge([inception_4b_1_1, inception_4b_3_3, inception_4b_5_5, inception_4b_pool_1_1], mode='concat', axis=3, name='inception_4b_output')
inception_4c_1_1 = conv_2d(inception_4b_output, 128, filter_size=1, activation='relu',name='inception_4c_1_1')
inception_4c_3_3_reduce = conv_2d(inception_4b_output, 128, filter_size=1, activation='relu', name='inception_4c_3_3_reduce')
inception_4c_3_3 = conv_2d(inception_4c_3_3_reduce, 256, filter_size=3, activation='relu', name='inception_4c_3_3')
inception_4c_5_5_reduce = conv_2d(inception_4b_output, 24, filter_size=1, activation='relu', name='inception_4c_5_5_reduce')
inception_4c_5_5 = conv_2d(inception_4c_5_5_reduce, 64, filter_size=5, activation='relu', name='inception_4c_5_5')
inception_4c_pool = max_pool_2d(inception_4b_output, kernel_size=3, strides=1)
inception_4c_pool_1_1 = conv_2d(inception_4c_pool, 64, filter_size=1, activation='relu', name='inception_4c_pool_1_1')
inception_4c_output = merge([inception_4c_1_1, inception_4c_3_3, inception_4c_5_5, inception_4c_pool_1_1], mode='concat', axis=3,name='inception_4c_output')
inception_4d_1_1 = conv_2d(inception_4c_output, 112, filter_size=1, activation='relu', name='inception_4d_1_1')
inception_4d_3_3_reduce = conv_2d(inception_4c_output, 144, filter_size=1, activation='relu', name='inception_4d_3_3_reduce')
inception_4d_3_3 = conv_2d(inception_4d_3_3_reduce, 288, filter_size=3, activation='relu', name='inception_4d_3_3')
inception_4d_5_5_reduce = conv_2d(inception_4c_output, 32, filter_size=1, activation='relu', name='inception_4d_5_5_reduce')
inception_4d_5_5 = conv_2d(inception_4d_5_5_reduce, 64, filter_size=5, activation='relu', name='inception_4d_5_5')
inception_4d_pool = max_pool_2d(inception_4c_output, kernel_size=3, strides=1, name='inception_4d_pool')
inception_4d_pool_1_1 = conv_2d(inception_4d_pool, 64, filter_size=1, activation='relu', name='inception_4d_pool_1_1')
inception_4d_output = merge([inception_4d_1_1, inception_4d_3_3, inception_4d_5_5, inception_4d_pool_1_1], mode='concat', axis=3, name='inception_4d_output')
inception_4e_1_1 = conv_2d(inception_4d_output, 256, filter_size=1, activation='relu', name='inception_4e_1_1')
inception_4e_3_3_reduce = conv_2d(inception_4d_output, 160, filter_size=1, activation='relu', name='inception_4e_3_3_reduce')
inception_4e_3_3 = conv_2d(inception_4e_3_3_reduce, 320, filter_size=3, activation='relu', name='inception_4e_3_3')
inception_4e_5_5_reduce = conv_2d(inception_4d_output, 32, filter_size=1, activation='relu', name='inception_4e_5_5_reduce')
inception_4e_5_5 = conv_2d(inception_4e_5_5_reduce, 128, filter_size=5, activation='relu', name='inception_4e_5_5')
inception_4e_pool = max_pool_2d(inception_4d_output, kernel_size=3, strides=1, name='inception_4e_pool')
inception_4e_pool_1_1 = conv_2d(inception_4e_pool, 128, filter_size=1, activation='relu', name='inception_4e_pool_1_1')
inception_4e_output = merge([inception_4e_1_1, inception_4e_3_3, inception_4e_5_5,inception_4e_pool_1_1],axis=3, mode='concat')
pool4_3_3 = max_pool_2d(inception_4e_output, kernel_size=3, strides=2, name='pool_3_3')
inception_5a_1_1 = conv_2d(pool4_3_3, 256, filter_size=1, activation='relu', name='inception_5a_1_1')
inception_5a_3_3_reduce = conv_2d(pool4_3_3, 160, filter_size=1, activation='relu', name='inception_5a_3_3_reduce')
inception_5a_3_3 = conv_2d(inception_5a_3_3_reduce, 320, filter_size=3, activation='relu', name='inception_5a_3_3')
inception_5a_5_5_reduce = conv_2d(pool4_3_3, 32, filter_size=1, activation='relu', name='inception_5a_5_5_reduce')
inception_5a_5_5 = conv_2d(inception_5a_5_5_reduce, 128, filter_size=5, activation='relu', name='inception_5a_5_5')
inception_5a_pool = max_pool_2d(pool4_3_3, kernel_size=3, strides=1, name='inception_5a_pool')
inception_5a_pool_1_1 = conv_2d(inception_5a_pool, 128, filter_size=1,activation='relu', name='inception_5a_pool_1_1')
inception_5a_output = merge([inception_5a_1_1, inception_5a_3_3, inception_5a_5_5, inception_5a_pool_1_1], axis=3,mode='concat')
inception_5b_1_1 = conv_2d(inception_5a_output, 384, filter_size=1,activation='relu', name='inception_5b_1_1')
inception_5b_3_3_reduce = conv_2d(inception_5a_output, 192, filter_size=1, activation='relu', name='inception_5b_3_3_reduce')
inception_5b_3_3 = conv_2d(inception_5b_3_3_reduce, 384, filter_size=3,activation='relu', name='inception_5b_3_3')
inception_5b_5_5_reduce = conv_2d(inception_5a_output, 48, filter_size=1, activation='relu', name='inception_5b_5_5_reduce')
inception_5b_5_5 = conv_2d(inception_5b_5_5_reduce,128, filter_size=5, activation='relu', name='inception_5b_5_5' )
inception_5b_pool = max_pool_2d(inception_5a_output, kernel_size=3, strides=1, name='inception_5b_pool')
inception_5b_pool_1_1 = conv_2d(inception_5b_pool, 128, filter_size=1, activation='relu', name='inception_5b_pool_1_1')
inception_5b_output = merge([inception_5b_1_1, inception_5b_3_3, inception_5b_5_5, inception_5b_pool_1_1], axis=3, mode='concat')
pool5_7_7 = avg_pool_2d(inception_5b_output, kernel_size=7, strides=1)
pool5_7_7 = dropout(pool5_7_7, 0.4)
loss = fully_connected(pool5_7_7, output,activation='softmax')
network = regression(loss, optimizer='momentum',
loss='categorical_crossentropy',
learning_rate=lr, name='targets')
model = tflearn.DNN(network,
max_checkpoints=0, tensorboard_verbose=0,tensorboard_dir='log')
return model
def inception_v3_3d(width, height, frame_count, lr, output=9, model_name = 'sentnet_color.model'):
network = input_data(shape=[None, width, height,3, 1], name='input')
conv1_7_7 = conv_3d(network, 64, 7, strides=2, activation='relu', name = 'conv1_7_7_s2')
pool1_3_3 = max_pool_3d(conv1_7_7, 3,strides=2)
#pool1_3_3 = local_response_normalization(pool1_3_3)
conv2_3_3_reduce = conv_3d(pool1_3_3, 64,1, activation='relu',name = 'conv2_3_3_reduce')
conv2_3_3 = conv_3d(conv2_3_3_reduce, 192,3, activation='relu', name='conv2_3_3')
#conv2_3_3 = local_response_normalization(conv2_3_3)
pool2_3_3 = max_pool_3d(conv2_3_3, kernel_size=3, strides=2, name='pool2_3_3_s2')
inception_3a_1_1 = conv_3d(pool2_3_3, 64, 1, activation='relu', name='inception_3a_1_1')
inception_3a_3_3_reduce = conv_3d(pool2_3_3, 96,1, activation='relu', name='inception_3a_3_3_reduce')
inception_3a_3_3 = conv_3d(inception_3a_3_3_reduce, 128,filter_size=3, activation='relu', name = 'inception_3a_3_3')
inception_3a_5_5_reduce = conv_3d(pool2_3_3,16, filter_size=1,activation='relu', name ='inception_3a_5_5_reduce' )
inception_3a_5_5 = conv_3d(inception_3a_5_5_reduce, 32, filter_size=5, activation='relu', name= 'inception_3a_5_5')
inception_3a_pool = max_pool_3d(pool2_3_3, kernel_size=3, strides=1, )
inception_3a_pool_1_1 = conv_3d(inception_3a_pool, 32, filter_size=1, activation='relu', name='inception_3a_pool_1_1')
# merge the inception_3a__
inception_3a_output = merge([inception_3a_1_1, inception_3a_3_3, inception_3a_5_5, inception_3a_pool_1_1], mode='concat', axis=4)
inception_3b_1_1 = conv_3d(inception_3a_output, 128,filter_size=1,activation='relu', name= 'inception_3b_1_1' )
inception_3b_3_3_reduce = conv_3d(inception_3a_output, 128, filter_size=1, activation='relu', name='inception_3b_3_3_reduce')
inception_3b_3_3 = conv_3d(inception_3b_3_3_reduce, 192, filter_size=3, activation='relu',name='inception_3b_3_3')
inception_3b_5_5_reduce = conv_3d(inception_3a_output, 32, filter_size=1, activation='relu', name = 'inception_3b_5_5_reduce')
inception_3b_5_5 = conv_3d(inception_3b_5_5_reduce, 96, filter_size=5, name = 'inception_3b_5_5')
inception_3b_pool = max_pool_3d(inception_3a_output, kernel_size=3, strides=1, name='inception_3b_pool')
inception_3b_pool_1_1 = conv_3d(inception_3b_pool, 64, filter_size=1,activation='relu', name='inception_3b_pool_1_1')
#merge the inception_3b_*
inception_3b_output = merge([inception_3b_1_1, inception_3b_3_3, inception_3b_5_5, inception_3b_pool_1_1], mode='concat',axis=4,name='inception_3b_output')
pool3_3_3 = max_pool_3d(inception_3b_output, kernel_size=3, strides=2, name='pool3_3_3')
inception_4a_1_1 = conv_3d(pool3_3_3, 192, filter_size=1, activation='relu', name='inception_4a_1_1')
inception_4a_3_3_reduce = conv_3d(pool3_3_3, 96, filter_size=1, activation='relu', name='inception_4a_3_3_reduce')
inception_4a_3_3 = conv_3d(inception_4a_3_3_reduce, 208, filter_size=3, activation='relu', name='inception_4a_3_3')
inception_4a_5_5_reduce = conv_3d(pool3_3_3, 16, filter_size=1, activation='relu', name='inception_4a_5_5_reduce')
inception_4a_5_5 = conv_3d(inception_4a_5_5_reduce, 48, filter_size=5, activation='relu', name='inception_4a_5_5')
inception_4a_pool = max_pool_3d(pool3_3_3, kernel_size=3, strides=1, name='inception_4a_pool')
inception_4a_pool_1_1 = conv_3d(inception_4a_pool, 64, filter_size=1, activation='relu', name='inception_4a_pool_1_1')
inception_4a_output = merge([inception_4a_1_1, inception_4a_3_3, inception_4a_5_5, inception_4a_pool_1_1], mode='concat', axis=4, name='inception_4a_output')
inception_4b_1_1 = conv_3d(inception_4a_output, 160, filter_size=1, activation='relu', name='inception_4a_1_1')
inception_4b_3_3_reduce = conv_3d(inception_4a_output, 112, filter_size=1, activation='relu', name='inception_4b_3_3_reduce')
inception_4b_3_3 = conv_3d(inception_4b_3_3_reduce, 224, filter_size=3, activation='relu', name='inception_4b_3_3')
inception_4b_5_5_reduce = conv_3d(inception_4a_output, 24, filter_size=1, activation='relu', name='inception_4b_5_5_reduce')
inception_4b_5_5 = conv_3d(inception_4b_5_5_reduce, 64, filter_size=5, activation='relu', name='inception_4b_5_5')
inception_4b_pool = max_pool_3d(inception_4a_output, kernel_size=3, strides=1, name='inception_4b_pool')
inception_4b_pool_1_1 = conv_3d(inception_4b_pool, 64, filter_size=1, activation='relu', name='inception_4b_pool_1_1')
inception_4b_output = merge([inception_4b_1_1, inception_4b_3_3, inception_4b_5_5, inception_4b_pool_1_1], mode='concat', axis=4, name='inception_4b_output')
inception_4c_1_1 = conv_3d(inception_4b_output, 128, filter_size=1, activation='relu',name='inception_4c_1_1')
inception_4c_3_3_reduce = conv_3d(inception_4b_output, 128, filter_size=1, activation='relu', name='inception_4c_3_3_reduce')
inception_4c_3_3 = conv_3d(inception_4c_3_3_reduce, 256, filter_size=3, activation='relu', name='inception_4c_3_3')
inception_4c_5_5_reduce = conv_3d(inception_4b_output, 24, filter_size=1, activation='relu', name='inception_4c_5_5_reduce')
inception_4c_5_5 = conv_3d(inception_4c_5_5_reduce, 64, filter_size=5, activation='relu', name='inception_4c_5_5')
inception_4c_pool = max_pool_3d(inception_4b_output, kernel_size=3, strides=1)
inception_4c_pool_1_1 = conv_3d(inception_4c_pool, 64, filter_size=1, activation='relu', name='inception_4c_pool_1_1')
inception_4c_output = merge([inception_4c_1_1, inception_4c_3_3, inception_4c_5_5, inception_4c_pool_1_1], mode='concat', axis=4,name='inception_4c_output')
inception_4d_1_1 = conv_3d(inception_4c_output, 112, filter_size=1, activation='relu', name='inception_4d_1_1')
inception_4d_3_3_reduce = conv_3d(inception_4c_output, 144, filter_size=1, activation='relu', name='inception_4d_3_3_reduce')
inception_4d_3_3 = conv_3d(inception_4d_3_3_reduce, 288, filter_size=3, activation='relu', name='inception_4d_3_3')
inception_4d_5_5_reduce = conv_3d(inception_4c_output, 32, filter_size=1, activation='relu', name='inception_4d_5_5_reduce')
inception_4d_5_5 = conv_3d(inception_4d_5_5_reduce, 64, filter_size=5, activation='relu', name='inception_4d_5_5')
inception_4d_pool = max_pool_3d(inception_4c_output, kernel_size=3, strides=1, name='inception_4d_pool')
inception_4d_pool_1_1 = conv_3d(inception_4d_pool, 64, filter_size=1, activation='relu', name='inception_4d_pool_1_1')
inception_4d_output = merge([inception_4d_1_1, inception_4d_3_3, inception_4d_5_5, inception_4d_pool_1_1], mode='concat', axis=4, name='inception_4d_output')
inception_4e_1_1 = conv_3d(inception_4d_output, 256, filter_size=1, activation='relu', name='inception_4e_1_1')
inception_4e_3_3_reduce = conv_3d(inception_4d_output, 160, filter_size=1, activation='relu', name='inception_4e_3_3_reduce')
inception_4e_3_3 = conv_3d(inception_4e_3_3_reduce, 320, filter_size=3, activation='relu', name='inception_4e_3_3')
inception_4e_5_5_reduce = conv_3d(inception_4d_output, 32, filter_size=1, activation='relu', name='inception_4e_5_5_reduce')
inception_4e_5_5 = conv_3d(inception_4e_5_5_reduce, 128, filter_size=5, activation='relu', name='inception_4e_5_5')
inception_4e_pool = max_pool_3d(inception_4d_output, kernel_size=3, strides=1, name='inception_4e_pool')
inception_4e_pool_1_1 = conv_3d(inception_4e_pool, 128, filter_size=1, activation='relu', name='inception_4e_pool_1_1')
inception_4e_output = merge([inception_4e_1_1, inception_4e_3_3, inception_4e_5_5,inception_4e_pool_1_1],axis=4, mode='concat')
pool4_3_3 = max_pool_3d(inception_4e_output, kernel_size=3, strides=2, name='pool_3_3')
inception_5a_1_1 = conv_3d(pool4_3_3, 256, filter_size=1, activation='relu', name='inception_5a_1_1')
inception_5a_3_3_reduce = conv_3d(pool4_3_3, 160, filter_size=1, activation='relu', name='inception_5a_3_3_reduce')
inception_5a_3_3 = conv_3d(inception_5a_3_3_reduce, 320, filter_size=3, activation='relu', name='inception_5a_3_3')
inception_5a_5_5_reduce = conv_3d(pool4_3_3, 32, filter_size=1, activation='relu', name='inception_5a_5_5_reduce')
inception_5a_5_5 = conv_3d(inception_5a_5_5_reduce, 128, filter_size=5, activation='relu', name='inception_5a_5_5')
inception_5a_pool = max_pool_3d(pool4_3_3, kernel_size=3, strides=1, name='inception_5a_pool')
inception_5a_pool_1_1 = conv_3d(inception_5a_pool, 128, filter_size=1,activation='relu', name='inception_5a_pool_1_1')
inception_5a_output = merge([inception_5a_1_1, inception_5a_3_3, inception_5a_5_5, inception_5a_pool_1_1], axis=4,mode='concat')
inception_5b_1_1 = conv_3d(inception_5a_output, 384, filter_size=1,activation='relu', name='inception_5b_1_1')
inception_5b_3_3_reduce = conv_3d(inception_5a_output, 192, filter_size=1, activation='relu', name='inception_5b_3_3_reduce')
inception_5b_3_3 = conv_3d(inception_5b_3_3_reduce, 384, filter_size=3,activation='relu', name='inception_5b_3_3')
inception_5b_5_5_reduce = conv_3d(inception_5a_output, 48, filter_size=1, activation='relu', name='inception_5b_5_5_reduce')
inception_5b_5_5 = conv_3d(inception_5b_5_5_reduce,128, filter_size=5, activation='relu', name='inception_5b_5_5' )
inception_5b_pool = max_pool_3d(inception_5a_output, kernel_size=3, strides=1, name='inception_5b_pool')
inception_5b_pool_1_1 = conv_3d(inception_5b_pool, 128, filter_size=1, activation='relu', name='inception_5b_pool_1_1')
inception_5b_output = merge([inception_5b_1_1, inception_5b_3_3, inception_5b_5_5, inception_5b_pool_1_1], axis=4, mode='concat')
pool5_7_7 = avg_pool_3d(inception_5b_output, kernel_size=7, strides=1)
pool5_7_7 = dropout(pool5_7_7, 0.4)
loss = fully_connected(pool5_7_7, output,activation='softmax')
network = regression(loss, optimizer='momentum',
loss='categorical_crossentropy',
learning_rate=lr, name='targets')
model = tflearn.DNN(network, checkpoint_path=model_name,
max_checkpoints=1, tensorboard_verbose=0,tensorboard_dir='log')
return model
def sentnet_LSTM_gray(width, height, frame_count, lr, output=9):
network = input_data(shape=[None, width, height], name='input')
#network = tflearn.input_data(shape=[None, 28, 28], name='input')
network = tflearn.lstm(network, 128, return_seq=True)
network = tflearn.lstm(network, 128)
network = tflearn.fully_connected(network, 9, activation='softmax')
network = tflearn.regression(network, optimizer='adam',
loss='categorical_crossentropy', name="output1")
model = tflearn.DNN(network, checkpoint_path='model_lstm',
max_checkpoints=1, tensorboard_verbose=0, tensorboard_dir='log')
return model
def sentnet_color(width, height, frame_count, lr, output=9, model_name = 'sentnet_color.model'):
network = input_data(shape=[None, width, height,3, 1], name='input')
network = conv_3d(network, 96, 11, strides=4, activation='relu')
network = max_pool_3d(network, 3, strides=2)
#network = local_response_normalization(network)
network = conv_3d(network, 256, 5, activation='relu')
network = max_pool_3d(network, 3, strides=2)
#network = local_response_normalization(network)
network = conv_3d(network, 384, 3, activation='relu')
network = conv_3d(network, 384, 3, activation='relu')
network = conv_3d(network, 256, 3, activation='relu')
network = max_pool_3d(network, 3, strides=2)
network = conv_3d(network, 256, 5, activation='relu')
network = max_pool_3d(network, 3, strides=2)
#network = local_response_normalization(network)
network = conv_3d(network, 384, 3, activation='relu')
network = conv_3d(network, 384, 3, activation='relu')
network = conv_3d(network, 256, 3, activation='relu')
network = max_pool_3d(network, 3, strides=2)
#network = local_response_normalization(network)
network = fully_connected(network, 4096, activation='tanh')
network = dropout(network, 0.5)
network = fully_connected(network, 4096, activation='tanh')
network = dropout(network, 0.5)
network = fully_connected(network, 4096, activation='tanh')
network = dropout(network, 0.5)
network = fully_connected(network, 4096, activation='tanh')
network = dropout(network, 0.5)
network = fully_connected(network, output, activation='softmax')
network = regression(network, optimizer='momentum',
loss='categorical_crossentropy',
learning_rate=lr, name='targets')
model = tflearn.DNN(network, checkpoint_path=model_name,
max_checkpoints=1, tensorboard_verbose=0, tensorboard_dir='log')
return model
def sentnet_frames(width, height, frame_count, lr, output=9):
network = input_data(shape=[None, width, height,frame_count, 1], name='input')
network = conv_3d(network, 96, 11, strides=4, activation='relu')
network = max_pool_3d(network, 3, strides=2)
#network = local_response_normalization(network)
network = conv_3d(network, 256, 5, activation='relu')
network = max_pool_3d(network, 3, strides=2)
#network = local_response_normalization(network)
network = conv_3d(network, 384, 3, activation='relu')
network = conv_3d(network, 384, 3, activation='relu')
network = conv_3d(network, 256, 3, activation='relu')
network = max_pool_3d(network, 3, strides=2)
network = conv_3d(network, 256, 5, activation='relu')
network = max_pool_3d(network, 3, strides=2)
#network = local_response_normalization(network)
network = conv_3d(network, 384, 3, activation='relu')
network = conv_3d(network, 384, 3, activation='relu')
network = conv_3d(network, 256, 3, activation='relu')
network = max_pool_3d(network, 3, strides=2)
#network = local_response_normalization(network)
network = fully_connected(network, 4096, activation='tanh')
network = dropout(network, 0.5)
network = fully_connected(network, 4096, activation='tanh')
network = dropout(network, 0.5)
network = fully_connected(network, 4096, activation='tanh')
network = dropout(network, 0.5)
network = fully_connected(network, 4096, activation='tanh')
network = dropout(network, 0.5)
network = fully_connected(network, output, activation='softmax')
network = regression(network, optimizer='momentum',
loss='categorical_crossentropy',
learning_rate=lr, name='targets')
model = tflearn.DNN(network, checkpoint_path='model_alexnet',
max_checkpoints=1, tensorboard_verbose=0, tensorboard_dir='log')
return model
def sentnet2(width, height, frame_count, lr, output=9):
network = input_data(shape=[None, width, height, frame_count, 1], name='input')
network = conv_3d(network, 96, 11, strides=4, activation='relu')
network = max_pool_3d(network, 3, strides=2)
#network = local_response_normalization(network)
network = conv_3d(network, 256, 5, activation='relu')
network = max_pool_3d(network, 3, strides=2)
#network = local_response_normalization(network)
network = conv_3d(network, 384, 3, activation='relu')
network = conv_3d(network, 384, 3, activation='relu')
network = conv_3d(network, 256, 3, activation='relu')
network = max_pool_3d(network, 3, strides=2)
#network = local_response_normalization(network)
network = fully_connected(network, 4096, activation='tanh')
network = dropout(network, 0.5)
network = fully_connected(network, 4096, activation='tanh')
network = dropout(network, 0.5)
network = fully_connected(network, 3, activation='softmax')
network = regression(network, optimizer='momentum',
loss='categorical_crossentropy',
learning_rate=lr, name='targets')
model = tflearn.DNN(network, checkpoint_path='model_alexnet',
max_checkpoints=1, tensorboard_verbose=0, tensorboard_dir='log')
return model
def sentnet(width, height, frame_count, lr, output=9):
network = input_data(shape=[None, width, height, frame_count, 1], name='input')
network = conv_3d(network, 96, 11, strides=4, activation='relu')
network = avg_pool_3d(network, 3, strides=2)
#network = local_response_normalization(network)
network = conv_3d(network, 256, 5, activation='relu')
network = avg_pool_3d(network, 3, strides=2)
#network = local_response_normalization(network)
network = conv_3d(network, 384, 3, activation='relu')
network = conv_3d(network, 384, 3, activation='relu')
network = conv_3d(network, 256, 3, activation='relu')
network = max_pool_3d(network, 3, strides=2)
network = conv_3d(network, 256, 5, activation='relu')
network = avg_pool_3d(network, 3, strides=2)
#network = local_response_normalization(network)
network = conv_3d(network, 384, 3, activation='relu')
network = conv_3d(network, 384, 3, activation='relu')
network = conv_3d(network, 256, 3, activation='relu')
network = avg_pool_3d(network, 3, strides=2)
#network = local_response_normalization(network)
network = fully_connected(network, 4096, activation='tanh')
network = dropout(network, 0.5)
network = fully_connected(network, 4096, activation='tanh')
network = dropout(network, 0.5)
network = fully_connected(network, 4096, activation='tanh')
network = dropout(network, 0.5)
network = fully_connected(network, 4096, activation='tanh')
network = dropout(network, 0.5)
network = fully_connected(network, output, activation='softmax')
network = regression(network, optimizer='momentum',
loss='categorical_crossentropy',
learning_rate=lr, name='targets')
model = tflearn.DNN(network, checkpoint_path='model_alexnet',
max_checkpoints=1, tensorboard_verbose=0, tensorboard_dir='log')
return model
def alexnet2(width, height, lr, output=3):
network = input_data(shape=[None, width, height, 1], name='input')
network = conv_2d(network, 96, 11, strides=4, activation='relu')
network = max_pool_2d(network, 3, strides=2)
network = local_response_normalization(network)
network = conv_2d(network, 256, 5, activation='relu')
network = max_pool_2d(network, 3, strides=2)
network = local_response_normalization(network)
network = conv_2d(network, 384, 3, activation='relu')
network = conv_2d(network, 384, 3, activation='relu')
network = conv_2d(network, 256, 3, activation='relu')
network = max_pool_2d(network, 3, strides=2)
network = conv_2d(network, 256, 5, activation='relu')
network = max_pool_2d(network, 3, strides=2)
network = local_response_normalization(network)
network = conv_2d(network, 384, 3, activation='relu')
network = conv_2d(network, 384, 3, activation='relu')
network = conv_2d(network, 256, 3, activation='relu')
network = max_pool_2d(network, 3, strides=2)
network = local_response_normalization(network)
network = fully_connected(network, 4096, activation='tanh')
network = dropout(network, 0.5)
network = fully_connected(network, 4096, activation='tanh')
network = dropout(network, 0.5)
network = fully_connected(network, 4096, activation='tanh')
network = dropout(network, 0.5)
network = fully_connected(network, 4096, activation='tanh')
network = dropout(network, 0.5)
network = fully_connected(network, output, activation='softmax')
network = regression(network, optimizer='momentum',
loss='categorical_crossentropy',
learning_rate=lr, name='targets')
model = tflearn.DNN(network, checkpoint_path='model_alexnet',
max_checkpoints=1, tensorboard_verbose=0, tensorboard_dir='log')
return model
def sentnet_v0(width, height, frame_count, lr, output=9):
network = input_data(shape=[None, width, height, frame_count, 1], name='input')
network = conv_3d(network, 96, 11, strides=4, activation='relu')
network = max_pool_3d(network, 3, strides=2)
#network = local_response_normalization(network)
network = conv_3d(network, 256, 5, activation='relu')
network = max_pool_3d(network, 3, strides=2)
#network = local_response_normalization(network)
network = conv_3d(network, 384, 3, 3, activation='relu')
network = conv_3d(network, 384, 3, 3, activation='relu')
network = conv_3d(network, 256, 3, 3, activation='relu')
network = max_pool_3d(network, 3, strides=2)
#network = local_response_normalization(network)
network = fully_connected(network, 4096, activation='tanh')
network = dropout(network, 0.5)
network = fully_connected(network, 4096, activation='tanh')
network = dropout(network, 0.5)
network = fully_connected(network, output, activation='softmax')
network = regression(network, optimizer='momentum',
loss='categorical_crossentropy',
learning_rate=lr, name='targets')
model = tflearn.DNN(network, checkpoint_path='model_alexnet',
max_checkpoints=1, tensorboard_verbose=0, tensorboard_dir='log')
return model
def alexnet(width, height, lr, output=3):
network = input_data(shape=[None, width, height, 1], name='input')
network = conv_2d(network, 96, 11, strides=4, activation='relu')
network = max_pool_2d(network, 3, strides=2)
network = local_response_normalization(network)
network = conv_2d(network, 256, 5, activation='relu')
network = max_pool_2d(network, 3, strides=2)
network = local_response_normalization(network)
network = conv_2d(network, 384, 3, activation='relu')
network = conv_2d(network, 384, 3, activation='relu')
network = conv_2d(network, 256, 3, activation='relu')
network = max_pool_2d(network, 3, strides=2)
network = local_response_normalization(network)
network = fully_connected(network, 4096, activation='tanh')
network = dropout(network, 0.5)
network = fully_connected(network, 4096, activation='tanh')
network = dropout(network, 0.5)
network = fully_connected(network, output, activation='softmax')
network = regression(network, optimizer='momentum',
loss='categorical_crossentropy',
learning_rate=lr, name='targets')
model = tflearn.DNN(network, checkpoint_path='model_alexnet',
max_checkpoints=1, tensorboard_verbose=0, tensorboard_dir='log')
return model
|
gpl-3.0
|
[
2344,
199,
7384,
6900,
4475,
3277,
14,
2900,
5924,
5702,
14,
199,
199,
31661,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
13297,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
5556,
1443,
3332,
282,
1331,
402,
314,
844,
737,
8410,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
199,
5524,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
16832,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
29946,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
9295,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3097,
1298,
1334,
314,
844,
14,
199,
2344,
199,
199,
646,
2833,
4643,
199,
504,
2833,
4643,
14,
4359,
14,
5598,
492,
8260,
63,
18,
68,
12,
1390,
63,
2293,
63,
18,
68,
12,
8595,
63,
2293,
63,
18,
68,
12,
8260,
63,
19,
68,
12,
1390,
63,
2293,
63,
19,
68,
12,
12402,
63,
2293,
63,
19,
68,
199,
504,
2833,
4643,
14,
4359,
14,
1018,
492,
1324,
63,
576,
12,
19795,
12,
9999,
63,
7113,
199,
504,
2833,
4643,
14,
4359,
14,
8627,
492,
10864,
199,
504,
2833,
4643,
14,
4359,
14,
22384,
492,
2257,
63,
1310,
63,
22384,
199,
504,
2833,
4643,
14,
4359,
14,
5628,
63,
1483,
492,
5389,
199,
199,
3,
2972,
315,
373,
16,
14,
1644,
13,
86,
16,
14,
1690,
11,
199,
318,
1163,
814,
19,
8,
2063,
12,
4569,
12,
2787,
63,
835,
12,
13645,
12,
1072,
29,
25,
12,
1402,
63,
354,
275,
283,
1848,
814,
14,
1238,
297,
2243,
275,
283,
6477,
297,
1967,
275,
283,
16,
735,
272,
543,
2833,
14,
1782,
2336,
2440,
26,
11123,
908,
8,
1782,
12,
1507,
2298,
267,
2784,
275,
1324,
63,
576,
8,
1392,
1524,
403,
12,
3462,
12,
4569,
12,
19,
467,
536,
534,
1210,
358,
267,
8260,
17,
63,
23,
63,
23,
275,
8260,
63,
18,
68,
8,
1200,
12,
5049,
12,
7294,
12,
11883,
29,
20,
12,
10361,
534,
12833,
297,
536,
275,
283,
5598,
17,
63,
23,
63,
23,
63,
83,
18,
358,
267,
4203,
17,
63,
19,
63,
19,
275,
1390,
63,
2293,
63,
18,
68,
8,
5598,
17,
63,
23,
63,
23,
12,
1749,
12,
16759,
29,
20,
9,
267,
4203,
17,
63,
19,
63,
19,
275,
2257,
63,
1310,
63,
22384,
8,
2293,
17,
63,
19,
63,
19,
9,
267,
8260,
18,
63,
19,
63,
19,
63,
5270,
275,
8260,
63,
18,
68,
8,
2293,
17,
63,
19,
63,
19,
12,
5049,
12,
17,
12,
10361,
534,
12833,
297,
354,
275,
283,
5598,
18,
63,
19,
63,
19,
63,
5270,
358,
267,
8260,
18,
63,
19,
63,
19,
275,
8260,
63,
18,
68,
8,
5598,
18,
63,
19,
63,
19,
63,
5270,
12,
13567,
12,
713,
12,
10361,
534,
12833,
297,
536,
534,
5598,
18,
63,
19,
63,
19,
358,
267,
8260,
18,
63,
19,
63,
19,
275,
2257,
63,
1310,
63,
22384,
8,
5598,
18,
63,
19,
63,
19,
9,
267,
4203,
18,
63,
19,
63,
19,
275,
1390,
63,
2293,
63,
18,
68,
8,
5598,
18,
63,
19,
63,
19,
12,
5114,
63,
890,
29,
713,
12,
11883,
29,
18,
12,
536,
534,
2293,
18,
63,
19,
63,
19,
63,
83,
18,
358,
267,
315,
814,
63,
19,
65,
63,
17,
63,
17,
275,
8260,
63,
18,
68,
8,
2293,
18,
63,
19,
63,
19,
12,
5049,
12,
413,
12,
10361,
534,
12833,
297,
536,
534,
262,
814,
63,
19,
65,
63,
17,
63,
17,
358,
267,
315,
814,
63,
19,
65,
63,
19,
63,
19,
63,
5270,
275,
8260,
63,
18,
68,
8,
2293,
18,
63,
19,
63,
19,
12,
15580,
12,
17,
12,
10361,
534,
12833,
297,
536,
534,
262,
814,
63,
19,
65,
63,
19,
63,
19,
63,
5270,
358,
267,
315,
814,
63,
19,
65,
63,
19,
63,
19,
275,
8260,
63,
18,
68,
8,
262,
814,
63,
19,
65,
63,
19,
63,
19,
63,
5270,
12,
7960,
12,
1541,
63,
890,
29,
713,
12,
221,
10361,
534,
12833,
297,
536,
275,
283,
262,
814,
63,
19,
65,
63,
19,
63,
19,
358,
267,
315,
814,
63,
19,
65,
63,
21,
63,
21,
63,
5270,
275,
8260,
63,
18,
68,
8,
2293,
18,
63,
19,
63,
19,
12,
975,
12,
2457,
63,
890,
29,
17,
12,
12312,
534,
12833,
297,
536,
275,
7,
262,
814,
63,
19,
65,
63,
21,
63,
21,
63,
5270,
7,
776,
267,
315,
814,
63,
19,
65,
63,
21,
63,
21,
275,
8260,
63,
18,
68,
8,
262,
814,
63,
19,
65,
63,
21,
63,
21,
63,
5270,
12,
4337,
12,
2457,
63,
890,
29,
1046,
12,
10361,
534,
12833,
297,
536,
29,
283,
262,
814,
63,
19,
65,
63,
21,
63,
21,
358,
267,
315,
814,
63,
19,
65,
63,
2293,
275,
1390,
63,
2293,
63,
18,
68,
8,
2293,
18,
63,
19,
63,
19,
12,
5114,
63,
890,
29,
713,
12,
11883,
29,
17,
12,
776,
267,
315,
814,
63,
19,
65,
63,
2293,
63,
17,
63,
17,
275,
8260,
63,
18,
68,
8,
262,
814,
63,
19,
65,
63,
2293,
12,
4337,
12,
2457,
63,
890,
29,
17,
12,
10361,
534,
12833,
297,
536,
534,
262,
814,
63,
19,
65,
63,
2293,
63,
17,
63,
17,
358,
398,
327,
5389,
314,
315,
814,
63,
19,
65,
363,
267,
315,
814,
63,
19,
65,
63,
1199,
275,
5389,
779,
262,
814,
63,
19,
65,
63,
17,
63,
17,
12,
315,
814,
63,
19,
65,
63,
19,
63,
19,
12,
315,
814,
63,
19,
65,
63,
21,
63,
21,
12,
315,
814,
63,
19,
65,
63,
2293,
63,
17,
63,
17,
467,
818,
534,
9419,
297,
3114,
29,
19,
9,
398,
315,
814,
63,
19,
66,
63,
17,
63,
17,
275,
8260,
63,
18,
68,
8,
262,
814,
63,
19,
65,
63,
1199,
12,
7960,
12,
1541,
63,
890,
29,
17,
12,
12312,
534,
12833,
297,
536,
29,
283,
262,
814,
63,
19,
66,
63,
17,
63,
17,
7,
776,
267,
315,
814,
63,
19
] |
[
199,
7384,
6900,
4475,
3277,
14,
2900,
5924,
5702,
14,
199,
199,
31661,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
13297,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
5556,
1443,
3332,
282,
1331,
402,
314,
844,
737,
8410,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
199,
5524,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
16832,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
29946,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
9295,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3097,
1298,
1334,
314,
844,
14,
199,
2344,
199,
199,
646,
2833,
4643,
199,
504,
2833,
4643,
14,
4359,
14,
5598,
492,
8260,
63,
18,
68,
12,
1390,
63,
2293,
63,
18,
68,
12,
8595,
63,
2293,
63,
18,
68,
12,
8260,
63,
19,
68,
12,
1390,
63,
2293,
63,
19,
68,
12,
12402,
63,
2293,
63,
19,
68,
199,
504,
2833,
4643,
14,
4359,
14,
1018,
492,
1324,
63,
576,
12,
19795,
12,
9999,
63,
7113,
199,
504,
2833,
4643,
14,
4359,
14,
8627,
492,
10864,
199,
504,
2833,
4643,
14,
4359,
14,
22384,
492,
2257,
63,
1310,
63,
22384,
199,
504,
2833,
4643,
14,
4359,
14,
5628,
63,
1483,
492,
5389,
199,
199,
3,
2972,
315,
373,
16,
14,
1644,
13,
86,
16,
14,
1690,
11,
199,
318,
1163,
814,
19,
8,
2063,
12,
4569,
12,
2787,
63,
835,
12,
13645,
12,
1072,
29,
25,
12,
1402,
63,
354,
275,
283,
1848,
814,
14,
1238,
297,
2243,
275,
283,
6477,
297,
1967,
275,
283,
16,
735,
272,
543,
2833,
14,
1782,
2336,
2440,
26,
11123,
908,
8,
1782,
12,
1507,
2298,
267,
2784,
275,
1324,
63,
576,
8,
1392,
1524,
403,
12,
3462,
12,
4569,
12,
19,
467,
536,
534,
1210,
358,
267,
8260,
17,
63,
23,
63,
23,
275,
8260,
63,
18,
68,
8,
1200,
12,
5049,
12,
7294,
12,
11883,
29,
20,
12,
10361,
534,
12833,
297,
536,
275,
283,
5598,
17,
63,
23,
63,
23,
63,
83,
18,
358,
267,
4203,
17,
63,
19,
63,
19,
275,
1390,
63,
2293,
63,
18,
68,
8,
5598,
17,
63,
23,
63,
23,
12,
1749,
12,
16759,
29,
20,
9,
267,
4203,
17,
63,
19,
63,
19,
275,
2257,
63,
1310,
63,
22384,
8,
2293,
17,
63,
19,
63,
19,
9,
267,
8260,
18,
63,
19,
63,
19,
63,
5270,
275,
8260,
63,
18,
68,
8,
2293,
17,
63,
19,
63,
19,
12,
5049,
12,
17,
12,
10361,
534,
12833,
297,
354,
275,
283,
5598,
18,
63,
19,
63,
19,
63,
5270,
358,
267,
8260,
18,
63,
19,
63,
19,
275,
8260,
63,
18,
68,
8,
5598,
18,
63,
19,
63,
19,
63,
5270,
12,
13567,
12,
713,
12,
10361,
534,
12833,
297,
536,
534,
5598,
18,
63,
19,
63,
19,
358,
267,
8260,
18,
63,
19,
63,
19,
275,
2257,
63,
1310,
63,
22384,
8,
5598,
18,
63,
19,
63,
19,
9,
267,
4203,
18,
63,
19,
63,
19,
275,
1390,
63,
2293,
63,
18,
68,
8,
5598,
18,
63,
19,
63,
19,
12,
5114,
63,
890,
29,
713,
12,
11883,
29,
18,
12,
536,
534,
2293,
18,
63,
19,
63,
19,
63,
83,
18,
358,
267,
315,
814,
63,
19,
65,
63,
17,
63,
17,
275,
8260,
63,
18,
68,
8,
2293,
18,
63,
19,
63,
19,
12,
5049,
12,
413,
12,
10361,
534,
12833,
297,
536,
534,
262,
814,
63,
19,
65,
63,
17,
63,
17,
358,
267,
315,
814,
63,
19,
65,
63,
19,
63,
19,
63,
5270,
275,
8260,
63,
18,
68,
8,
2293,
18,
63,
19,
63,
19,
12,
15580,
12,
17,
12,
10361,
534,
12833,
297,
536,
534,
262,
814,
63,
19,
65,
63,
19,
63,
19,
63,
5270,
358,
267,
315,
814,
63,
19,
65,
63,
19,
63,
19,
275,
8260,
63,
18,
68,
8,
262,
814,
63,
19,
65,
63,
19,
63,
19,
63,
5270,
12,
7960,
12,
1541,
63,
890,
29,
713,
12,
221,
10361,
534,
12833,
297,
536,
275,
283,
262,
814,
63,
19,
65,
63,
19,
63,
19,
358,
267,
315,
814,
63,
19,
65,
63,
21,
63,
21,
63,
5270,
275,
8260,
63,
18,
68,
8,
2293,
18,
63,
19,
63,
19,
12,
975,
12,
2457,
63,
890,
29,
17,
12,
12312,
534,
12833,
297,
536,
275,
7,
262,
814,
63,
19,
65,
63,
21,
63,
21,
63,
5270,
7,
776,
267,
315,
814,
63,
19,
65,
63,
21,
63,
21,
275,
8260,
63,
18,
68,
8,
262,
814,
63,
19,
65,
63,
21,
63,
21,
63,
5270,
12,
4337,
12,
2457,
63,
890,
29,
1046,
12,
10361,
534,
12833,
297,
536,
29,
283,
262,
814,
63,
19,
65,
63,
21,
63,
21,
358,
267,
315,
814,
63,
19,
65,
63,
2293,
275,
1390,
63,
2293,
63,
18,
68,
8,
2293,
18,
63,
19,
63,
19,
12,
5114,
63,
890,
29,
713,
12,
11883,
29,
17,
12,
776,
267,
315,
814,
63,
19,
65,
63,
2293,
63,
17,
63,
17,
275,
8260,
63,
18,
68,
8,
262,
814,
63,
19,
65,
63,
2293,
12,
4337,
12,
2457,
63,
890,
29,
17,
12,
10361,
534,
12833,
297,
536,
534,
262,
814,
63,
19,
65,
63,
2293,
63,
17,
63,
17,
358,
398,
327,
5389,
314,
315,
814,
63,
19,
65,
363,
267,
315,
814,
63,
19,
65,
63,
1199,
275,
5389,
779,
262,
814,
63,
19,
65,
63,
17,
63,
17,
12,
315,
814,
63,
19,
65,
63,
19,
63,
19,
12,
315,
814,
63,
19,
65,
63,
21,
63,
21,
12,
315,
814,
63,
19,
65,
63,
2293,
63,
17,
63,
17,
467,
818,
534,
9419,
297,
3114,
29,
19,
9,
398,
315,
814,
63,
19,
66,
63,
17,
63,
17,
275,
8260,
63,
18,
68,
8,
262,
814,
63,
19,
65,
63,
1199,
12,
7960,
12,
1541,
63,
890,
29,
17,
12,
12312,
534,
12833,
297,
536,
29,
283,
262,
814,
63,
19,
66,
63,
17,
63,
17,
7,
776,
267,
315,
814,
63,
19,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
akshayaurora/kivy
|
kivy/uix/recyclelayout.py
|
10
|
12070
|
"""
RecycleLayout
=============
.. versionadded:: 1.10.0
.. warning::
This module is highly experimental, its API may change in the future and
the documentation is not complete at this time.
"""
from kivy.uix.recycleview.layout import RecycleLayoutManagerBehavior
from kivy.uix.layout import Layout
from kivy.properties import ObjectProperty, StringProperty
from kivy.factory import Factory
__all__ = ('RecycleLayout', )
class RecycleLayout(RecycleLayoutManagerBehavior, Layout):
"""
RecycleLayout provides the default layout for RecycleViews.
"""
default_size = ObjectProperty((100, 100))
'''size as in w, h. They each can be None.
'''
key_size = StringProperty(None, allownone=True)
default_size_hint = ObjectProperty((None, None))
key_size_hint = StringProperty(None, allownone=True)
default_size_hint_min = ObjectProperty((None, None))
key_size_hint_min = StringProperty(None, allownone=True)
default_size_hint_max = ObjectProperty((None, None))
key_size_hint_max = StringProperty(None, allownone=True)
default_pos_hint = ObjectProperty({})
key_pos_hint = StringProperty(None, allownone=True)
initial_size = ObjectProperty((100, 100))
view_opts = []
_size_needs_update = False
_changed_views = []
view_indices = {}
def __init__(self, **kwargs):
self.view_indices = {}
self._updated_views = []
self._trigger_layout = self._catch_layout_trigger
super(RecycleLayout, self).__init__(**kwargs)
def attach_recycleview(self, rv):
super(RecycleLayout, self).attach_recycleview(rv)
if rv:
fbind = self.fbind
fbind('default_size', rv.refresh_from_data)
fbind('key_size', rv.refresh_from_data)
fbind('default_size_hint', rv.refresh_from_data)
fbind('key_size_hint', rv.refresh_from_data)
fbind('default_size_hint_min', rv.refresh_from_data)
fbind('key_size_hint_min', rv.refresh_from_data)
fbind('default_size_hint_max', rv.refresh_from_data)
fbind('key_size_hint_max', rv.refresh_from_data)
fbind('default_pos_hint', rv.refresh_from_data)
fbind('key_pos_hint', rv.refresh_from_data)
def detach_recycleview(self):
rv = self.recycleview
if rv:
funbind = self.funbind
funbind('default_size', rv.refresh_from_data)
funbind('key_size', rv.refresh_from_data)
funbind('default_size_hint', rv.refresh_from_data)
funbind('key_size_hint', rv.refresh_from_data)
funbind('default_size_hint_min', rv.refresh_from_data)
funbind('key_size_hint_min', rv.refresh_from_data)
funbind('default_size_hint_max', rv.refresh_from_data)
funbind('key_size_hint_max', rv.refresh_from_data)
funbind('default_pos_hint', rv.refresh_from_data)
funbind('key_pos_hint', rv.refresh_from_data)
super(RecycleLayout, self).detach_recycleview()
def _catch_layout_trigger(self, instance=None, value=None):
rv = self.recycleview
if rv is None:
return
idx = self.view_indices.get(instance)
if idx is not None:
if self._size_needs_update:
return
opt = self.view_opts[idx]
if (instance.size == opt['size'] and
instance.size_hint == opt['size_hint'] and
instance.size_hint_min == opt['size_hint_min'] and
instance.size_hint_max == opt['size_hint_max'] and
instance.pos_hint == opt['pos_hint']):
return
self._size_needs_update = True
rv.refresh_from_layout(view_size=True)
else:
rv.refresh_from_layout()
def compute_sizes_from_data(self, data, flags):
if [f for f in flags if not f]:
# at least one changed data unpredictably
self.clear_layout()
opts = self.view_opts = [None for _ in data]
else:
opts = self.view_opts
changed = False
for flag in flags:
for k, v in flag.items():
changed = True
if k == 'removed':
del opts[v]
elif k == 'appended':
opts.extend([None, ] * (v.stop - v.start))
elif k == 'inserted':
opts.insert(v, None)
elif k == 'modified':
start, stop, step = v.start, v.stop, v.step
r = range(start, stop) if step is None else \
range(start, stop, step)
for i in r:
opts[i] = None
else:
raise Exception('Unrecognized data flag {}'.format(k))
if changed:
self.clear_layout()
assert len(data) == len(opts)
ph_key = self.key_pos_hint
ph_def = self.default_pos_hint
sh_key = self.key_size_hint
sh_def = self.default_size_hint
sh_min_key = self.key_size_hint_min
sh_min_def = self.default_size_hint_min
sh_max_key = self.key_size_hint_max
sh_max_def = self.default_size_hint_max
s_key = self.key_size
s_def = self.default_size
viewcls_def = self.viewclass
viewcls_key = self.key_viewclass
iw, ih = self.initial_size
sh = []
for i, item in enumerate(data):
if opts[i] is not None:
continue
ph = ph_def if ph_key is None else item.get(ph_key, ph_def)
ph = item.get('pos_hint', ph)
sh = sh_def if sh_key is None else item.get(sh_key, sh_def)
sh = item.get('size_hint', sh)
sh = [item.get('size_hint_x', sh[0]),
item.get('size_hint_y', sh[1])]
sh_min = sh_min_def if sh_min_key is None else item.get(sh_min_key,
sh_min_def)
sh_min = item.get('size_hint_min', sh_min)
sh_min = [item.get('size_hint_min_x', sh_min[0]),
item.get('size_hint_min_y', sh_min[1])]
sh_max = sh_max_def if sh_max_key is None else item.get(sh_max_key,
sh_max_def)
sh_max = item.get('size_hint_max', sh_max)
sh_max = [item.get('size_hint_max_x', sh_max[0]),
item.get('size_hint_max_y', sh_max[1])]
s = s_def if s_key is None else item.get(s_key, s_def)
s = item.get('size', s)
w, h = s = item.get('width', s[0]), item.get('height', s[1])
viewcls = None
if viewcls_key is not None:
viewcls = item.get(viewcls_key)
if viewcls is not None:
viewcls = getattr(Factory, viewcls)
if viewcls is None:
viewcls = viewcls_def
opts[i] = {
'size': [(iw if w is None else w), (ih if h is None else h)],
'size_hint': sh, 'size_hint_min': sh_min,
'size_hint_max': sh_max, 'pos': None, 'pos_hint': ph,
'viewclass': viewcls, 'width_none': w is None,
'height_none': h is None}
def compute_layout(self, data, flags):
self._size_needs_update = False
opts = self.view_opts
changed = []
for widget, index in self.view_indices.items():
opt = opts[index]
s = opt['size']
w, h = sn = list(widget.size)
sh = opt['size_hint']
shnw, shnh = shn = list(widget.size_hint)
sh_min = opt['size_hint_min']
shn_min = list(widget.size_hint_min)
sh_max = opt['size_hint_max']
shn_max = list(widget.size_hint_max)
ph = opt['pos_hint']
phn = dict(widget.pos_hint)
if s != sn or sh != shn or ph != phn or sh_min != shn_min or \
sh_max != shn_max:
changed.append((index, widget, s, sn, sh, shn, sh_min, shn_min,
sh_max, shn_max, ph, phn))
if shnw is None:
if shnh is None:
opt['size'] = sn
else:
opt['size'] = [w, s[1]]
elif shnh is None:
opt['size'] = [s[0], h]
opt['size_hint'] = shn
opt['size_hint_min'] = shn_min
opt['size_hint_max'] = shn_max
opt['pos_hint'] = phn
if [f for f in flags if not f]: # need to redo everything
self._changed_views = []
else:
self._changed_views = changed if changed else None
def do_layout(self, *largs):
assert False
def set_visible_views(self, indices, data, viewport):
view_opts = self.view_opts
new, remaining, old = self.recycleview.view_adapter.set_visible_views(
indices, data, view_opts)
remove = self.remove_widget
view_indices = self.view_indices
for _, widget in old:
remove(widget)
del view_indices[widget]
# first update the sizing info so that when we update the size
# the widgets are not bound and won't trigger a re-layout
refresh_view_layout = self.refresh_view_layout
for index, widget in new:
# make sure widget is added first so that any sizing updates
# will be recorded
opt = view_opts[index].copy()
del opt['width_none']
del opt['height_none']
refresh_view_layout(index, opt, widget, viewport)
# then add all the visible widgets, which binds size/size_hint
add = self.add_widget
for index, widget in new:
# add to the container if it's not already done
view_indices[widget] = index
if widget.parent is None:
add(widget)
# finally, make sure if the size has changed to cause a re-layout
changed = False
for index, widget in new:
opt = view_opts[index]
if (changed or widget.size == opt['size'] and
widget.size_hint == opt['size_hint'] and
widget.size_hint_min == opt['size_hint_min'] and
widget.size_hint_max == opt['size_hint_max'] and
widget.pos_hint == opt['pos_hint']):
continue
changed = True
if changed:
# we could use LayoutChangeException here, but refresh_views in rv
# needs to be updated to watch for it in the layout phase
self._size_needs_update = True
self.recycleview.refresh_from_layout(view_size=True)
def refresh_view_layout(self, index, layout, view, viewport):
opt = self.view_opts[index].copy()
width_none = opt.pop('width_none')
height_none = opt.pop('height_none')
opt.update(layout)
w, h = opt['size']
shw, shh = opt['size_hint']
if shw is None and width_none:
w = None
if shh is None and height_none:
h = None
opt['size'] = w, h
super(RecycleLayout, self).refresh_view_layout(
index, opt, view, viewport)
def remove_views(self):
super(RecycleLayout, self).remove_views()
self.clear_widgets()
self.view_indices = {}
def remove_view(self, view, index):
super(RecycleLayout, self).remove_view(view, index)
self.remove_widget(view)
del self.view_indices[view]
def clear_layout(self):
super(RecycleLayout, self).clear_layout()
self.clear_widgets()
self.view_indices = {}
self._size_needs_update = False
|
mit
|
[
624,
199,
497,
7612,
4798,
199,
9152,
199,
199,
703,
7445,
447,
413,
14,
709,
14,
16,
199,
199,
703,
5721,
447,
272,
961,
859,
365,
4721,
590,
22820,
12,
2399,
3261,
1443,
1570,
315,
314,
6466,
436,
272,
314,
3794,
365,
440,
4890,
737,
642,
900,
14,
199,
624,
199,
199,
504,
17227,
14,
24263,
14,
264,
7612,
1345,
14,
4209,
492,
799,
7612,
4798,
2988,
25361,
199,
504,
17227,
14,
24263,
14,
4209,
492,
25604,
199,
504,
17227,
14,
3282,
492,
6935,
3697,
12,
2624,
3697,
199,
504,
17227,
14,
3702,
492,
23616,
199,
199,
363,
452,
363,
275,
661,
497,
7612,
4798,
297,
776,
421,
199,
533,
799,
7612,
4798,
8,
497,
7612,
4798,
2988,
25361,
12,
25604,
304,
272,
408,
272,
799,
7612,
4798,
6571,
314,
849,
7054,
367,
799,
7612,
21180,
14,
272,
408,
339,
849,
63,
890,
275,
6935,
3697,
1332,
1960,
12,
2948,
430,
272,
1449,
890,
465,
315,
336,
12,
394,
14,
9322,
1924,
883,
506,
488,
14,
272,
1449,
272,
790,
63,
890,
275,
2624,
3697,
8,
403,
12,
2040,
3592,
29,
549,
9,
272,
849,
63,
890,
63,
6479,
275,
6935,
3697,
1332,
403,
12,
488,
430,
272,
790,
63,
890,
63,
6479,
275,
2624,
3697,
8,
403,
12,
2040,
3592,
29,
549,
9,
272,
849,
63,
890,
63,
6479,
63,
827,
275,
6935,
3697,
1332,
403,
12,
488,
430,
272,
790,
63,
890,
63,
6479,
63,
827,
275,
2624,
3697,
8,
403,
12,
2040,
3592,
29,
549,
9,
272,
849,
63,
890,
63,
6479,
63,
988,
275,
6935,
3697,
1332,
403,
12,
488,
430,
272,
790,
63,
890,
63,
6479,
63,
988,
275,
2624,
3697,
8,
403,
12,
2040,
3592,
29,
549,
9,
272,
849,
63,
1712,
63,
6479,
275,
6935,
3697,
14079,
272,
790,
63,
1712,
63,
6479,
275,
2624,
3697,
8,
403,
12,
2040,
3592,
29,
549,
9,
272,
2536,
63,
890,
275,
6935,
3697,
1332,
1960,
12,
2948,
430,
339,
2455,
63,
3291,
275,
942,
339,
485,
890,
63,
10065,
63,
873,
275,
756,
272,
485,
2489,
63,
4196,
275,
942,
339,
2455,
63,
4108,
275,
1052,
339,
347,
636,
826,
721,
277,
12,
1011,
958,
304,
267,
291,
14,
1345,
63,
4108,
275,
1052,
267,
291,
423,
5334,
63,
4196,
275,
942,
267,
291,
423,
7631,
63,
4209,
275,
291,
423,
9341,
63,
4209,
63,
7631,
267,
1613,
8,
497,
7612,
4798,
12,
291,
2843,
826,
14155,
958,
9,
339,
347,
6554,
63,
264,
7612,
1345,
8,
277,
12,
4336,
304,
267,
1613,
8,
497,
7612,
4798,
12,
291,
680,
5040,
63,
264,
7612,
1345,
8,
6310,
9,
267,
340,
4336,
26,
288,
289,
3409,
275,
291,
14,
70,
3409,
288,
289,
3409,
360,
885,
63,
890,
297,
4336,
14,
6635,
63,
504,
63,
576,
9,
288,
289,
3409,
360,
498,
63,
890,
297,
4336,
14,
6635,
63,
504,
63,
576,
9,
288,
289,
3409,
360,
885,
63,
890,
63,
6479,
297,
4336,
14,
6635,
63,
504,
63,
576,
9,
288,
289,
3409,
360,
498,
63,
890,
63,
6479,
297,
4336,
14,
6635,
63,
504,
63,
576,
9,
288,
289,
3409,
360,
885,
63,
890,
63,
6479,
63,
827,
297,
4336,
14,
6635,
63,
504,
63,
576,
9,
288,
289,
3409,
360,
498,
63,
890,
63,
6479,
63,
827,
297,
4336,
14,
6635,
63,
504,
63,
576,
9,
288,
289,
3409,
360,
885,
63,
890,
63,
6479,
63,
988,
297,
4336,
14,
6635,
63,
504,
63,
576,
9,
288,
289,
3409,
360,
498,
63,
890,
63,
6479,
63,
988,
297,
4336,
14,
6635,
63,
504,
63,
576,
9,
288,
289,
3409,
360,
885,
63,
1712,
63,
6479,
297,
4336,
14,
6635,
63,
504,
63,
576,
9,
288,
289,
3409,
360,
498,
63,
1712,
63,
6479,
297,
4336,
14,
6635,
63,
504,
63,
576,
9,
339,
347,
21236,
63,
264,
7612,
1345,
8,
277,
304,
267,
4336,
275,
291,
14,
264,
7612,
1345,
267,
340,
4336,
26,
288,
9627,
3409,
275,
291,
14,
7036,
3409,
288,
9627,
3409,
360,
885,
63,
890,
297,
4336,
14,
6635,
63,
504,
63,
576,
9,
288,
9627,
3409,
360,
498,
63,
890,
297,
4336,
14,
6635,
63,
504,
63,
576,
9,
288,
9627,
3409,
360,
885,
63,
890,
63,
6479,
297,
4336,
14,
6635,
63,
504,
63,
576,
9,
288,
9627,
3409,
360,
498,
63,
890,
63,
6479,
297,
4336,
14,
6635,
63,
504,
63,
576,
9,
288,
9627,
3409,
360,
885,
63,
890,
63,
6479,
63,
827,
297,
4336,
14,
6635,
63,
504,
63,
576,
9,
288,
9627,
3409,
360,
498,
63,
890,
63,
6479,
63,
827,
297,
4336,
14,
6635,
63,
504,
63,
576,
9,
288,
9627,
3409,
360,
885,
63,
890,
63,
6479,
63,
988,
297,
4336,
14,
6635,
63,
504,
63,
576,
9,
288,
9627,
3409,
360,
498,
63,
890,
63,
6479,
63,
988,
297,
4336,
14,
6635,
63,
504,
63,
576,
9,
288,
9627,
3409,
360,
885,
63,
1712,
63,
6479,
297,
4336,
14,
6635,
63,
504,
63,
576,
9,
288,
9627,
3409,
360,
498,
63,
1712,
63,
6479,
297,
4336,
14,
6635,
63,
504,
63,
576,
9,
267,
1613,
8,
497,
7612,
4798,
12,
291,
680,
14481,
63,
264,
7612,
1345,
342,
339,
347,
485,
9341,
63,
4209,
63,
7631,
8,
277,
12,
1256,
29,
403,
12,
574,
29,
403,
304,
267,
4336,
275,
291,
14,
264,
7612,
1345,
267,
340,
4336,
365,
488,
26,
288,
372,
398,
4280,
275,
291,
14,
1345,
63,
4108,
14,
362,
8,
842,
9,
267,
340,
4280,
365,
440,
488,
26,
288,
340,
291,
423,
890,
63,
10065,
63,
873,
26,
355,
372,
288,
2450,
275,
291,
14,
1345,
63,
3291,
59,
2996,
61,
288,
340,
334,
842,
14,
890,
508,
2450,
459,
890,
418,
436,
490,
1256,
14,
890,
63,
6479,
508,
2450,
459,
890,
63,
6479,
418,
436,
490,
1256,
14,
890,
63,
6479,
63,
827,
508,
2450,
459,
890,
63,
6479,
63,
827,
418,
436,
490,
1256,
14,
890,
63,
6479,
63,
988,
508,
2450,
459,
890,
63,
6479,
63,
988,
418,
436,
490,
1256,
14,
1712,
63,
6479,
508,
2450,
459,
1712,
63,
6479,
9090,
355,
372,
288,
291,
423,
890,
63,
10065,
63,
873,
275,
715,
288
] |
[
199,
497,
7612,
4798,
199,
9152,
199,
199,
703,
7445,
447,
413,
14,
709,
14,
16,
199,
199,
703,
5721,
447,
272,
961,
859,
365,
4721,
590,
22820,
12,
2399,
3261,
1443,
1570,
315,
314,
6466,
436,
272,
314,
3794,
365,
440,
4890,
737,
642,
900,
14,
199,
624,
199,
199,
504,
17227,
14,
24263,
14,
264,
7612,
1345,
14,
4209,
492,
799,
7612,
4798,
2988,
25361,
199,
504,
17227,
14,
24263,
14,
4209,
492,
25604,
199,
504,
17227,
14,
3282,
492,
6935,
3697,
12,
2624,
3697,
199,
504,
17227,
14,
3702,
492,
23616,
199,
199,
363,
452,
363,
275,
661,
497,
7612,
4798,
297,
776,
421,
199,
533,
799,
7612,
4798,
8,
497,
7612,
4798,
2988,
25361,
12,
25604,
304,
272,
408,
272,
799,
7612,
4798,
6571,
314,
849,
7054,
367,
799,
7612,
21180,
14,
272,
408,
339,
849,
63,
890,
275,
6935,
3697,
1332,
1960,
12,
2948,
430,
272,
1449,
890,
465,
315,
336,
12,
394,
14,
9322,
1924,
883,
506,
488,
14,
272,
1449,
272,
790,
63,
890,
275,
2624,
3697,
8,
403,
12,
2040,
3592,
29,
549,
9,
272,
849,
63,
890,
63,
6479,
275,
6935,
3697,
1332,
403,
12,
488,
430,
272,
790,
63,
890,
63,
6479,
275,
2624,
3697,
8,
403,
12,
2040,
3592,
29,
549,
9,
272,
849,
63,
890,
63,
6479,
63,
827,
275,
6935,
3697,
1332,
403,
12,
488,
430,
272,
790,
63,
890,
63,
6479,
63,
827,
275,
2624,
3697,
8,
403,
12,
2040,
3592,
29,
549,
9,
272,
849,
63,
890,
63,
6479,
63,
988,
275,
6935,
3697,
1332,
403,
12,
488,
430,
272,
790,
63,
890,
63,
6479,
63,
988,
275,
2624,
3697,
8,
403,
12,
2040,
3592,
29,
549,
9,
272,
849,
63,
1712,
63,
6479,
275,
6935,
3697,
14079,
272,
790,
63,
1712,
63,
6479,
275,
2624,
3697,
8,
403,
12,
2040,
3592,
29,
549,
9,
272,
2536,
63,
890,
275,
6935,
3697,
1332,
1960,
12,
2948,
430,
339,
2455,
63,
3291,
275,
942,
339,
485,
890,
63,
10065,
63,
873,
275,
756,
272,
485,
2489,
63,
4196,
275,
942,
339,
2455,
63,
4108,
275,
1052,
339,
347,
636,
826,
721,
277,
12,
1011,
958,
304,
267,
291,
14,
1345,
63,
4108,
275,
1052,
267,
291,
423,
5334,
63,
4196,
275,
942,
267,
291,
423,
7631,
63,
4209,
275,
291,
423,
9341,
63,
4209,
63,
7631,
267,
1613,
8,
497,
7612,
4798,
12,
291,
2843,
826,
14155,
958,
9,
339,
347,
6554,
63,
264,
7612,
1345,
8,
277,
12,
4336,
304,
267,
1613,
8,
497,
7612,
4798,
12,
291,
680,
5040,
63,
264,
7612,
1345,
8,
6310,
9,
267,
340,
4336,
26,
288,
289,
3409,
275,
291,
14,
70,
3409,
288,
289,
3409,
360,
885,
63,
890,
297,
4336,
14,
6635,
63,
504,
63,
576,
9,
288,
289,
3409,
360,
498,
63,
890,
297,
4336,
14,
6635,
63,
504,
63,
576,
9,
288,
289,
3409,
360,
885,
63,
890,
63,
6479,
297,
4336,
14,
6635,
63,
504,
63,
576,
9,
288,
289,
3409,
360,
498,
63,
890,
63,
6479,
297,
4336,
14,
6635,
63,
504,
63,
576,
9,
288,
289,
3409,
360,
885,
63,
890,
63,
6479,
63,
827,
297,
4336,
14,
6635,
63,
504,
63,
576,
9,
288,
289,
3409,
360,
498,
63,
890,
63,
6479,
63,
827,
297,
4336,
14,
6635,
63,
504,
63,
576,
9,
288,
289,
3409,
360,
885,
63,
890,
63,
6479,
63,
988,
297,
4336,
14,
6635,
63,
504,
63,
576,
9,
288,
289,
3409,
360,
498,
63,
890,
63,
6479,
63,
988,
297,
4336,
14,
6635,
63,
504,
63,
576,
9,
288,
289,
3409,
360,
885,
63,
1712,
63,
6479,
297,
4336,
14,
6635,
63,
504,
63,
576,
9,
288,
289,
3409,
360,
498,
63,
1712,
63,
6479,
297,
4336,
14,
6635,
63,
504,
63,
576,
9,
339,
347,
21236,
63,
264,
7612,
1345,
8,
277,
304,
267,
4336,
275,
291,
14,
264,
7612,
1345,
267,
340,
4336,
26,
288,
9627,
3409,
275,
291,
14,
7036,
3409,
288,
9627,
3409,
360,
885,
63,
890,
297,
4336,
14,
6635,
63,
504,
63,
576,
9,
288,
9627,
3409,
360,
498,
63,
890,
297,
4336,
14,
6635,
63,
504,
63,
576,
9,
288,
9627,
3409,
360,
885,
63,
890,
63,
6479,
297,
4336,
14,
6635,
63,
504,
63,
576,
9,
288,
9627,
3409,
360,
498,
63,
890,
63,
6479,
297,
4336,
14,
6635,
63,
504,
63,
576,
9,
288,
9627,
3409,
360,
885,
63,
890,
63,
6479,
63,
827,
297,
4336,
14,
6635,
63,
504,
63,
576,
9,
288,
9627,
3409,
360,
498,
63,
890,
63,
6479,
63,
827,
297,
4336,
14,
6635,
63,
504,
63,
576,
9,
288,
9627,
3409,
360,
885,
63,
890,
63,
6479,
63,
988,
297,
4336,
14,
6635,
63,
504,
63,
576,
9,
288,
9627,
3409,
360,
498,
63,
890,
63,
6479,
63,
988,
297,
4336,
14,
6635,
63,
504,
63,
576,
9,
288,
9627,
3409,
360,
885,
63,
1712,
63,
6479,
297,
4336,
14,
6635,
63,
504,
63,
576,
9,
288,
9627,
3409,
360,
498,
63,
1712,
63,
6479,
297,
4336,
14,
6635,
63,
504,
63,
576,
9,
267,
1613,
8,
497,
7612,
4798,
12,
291,
680,
14481,
63,
264,
7612,
1345,
342,
339,
347,
485,
9341,
63,
4209,
63,
7631,
8,
277,
12,
1256,
29,
403,
12,
574,
29,
403,
304,
267,
4336,
275,
291,
14,
264,
7612,
1345,
267,
340,
4336,
365,
488,
26,
288,
372,
398,
4280,
275,
291,
14,
1345,
63,
4108,
14,
362,
8,
842,
9,
267,
340,
4280,
365,
440,
488,
26,
288,
340,
291,
423,
890,
63,
10065,
63,
873,
26,
355,
372,
288,
2450,
275,
291,
14,
1345,
63,
3291,
59,
2996,
61,
288,
340,
334,
842,
14,
890,
508,
2450,
459,
890,
418,
436,
490,
1256,
14,
890,
63,
6479,
508,
2450,
459,
890,
63,
6479,
418,
436,
490,
1256,
14,
890,
63,
6479,
63,
827,
508,
2450,
459,
890,
63,
6479,
63,
827,
418,
436,
490,
1256,
14,
890,
63,
6479,
63,
988,
508,
2450,
459,
890,
63,
6479,
63,
988,
418,
436,
490,
1256,
14,
1712,
63,
6479,
508,
2450,
459,
1712,
63,
6479,
9090,
355,
372,
288,
291,
423,
890,
63,
10065,
63,
873,
275,
715,
288,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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from ctypes import addressof, byref, c_double, c_void_p
from django.contrib.gis.gdal.base import GDALBase
from django.contrib.gis.gdal.driver import Driver
from django.contrib.gis.gdal.error import GDALException
from django.contrib.gis.gdal.prototypes import raster as capi
from django.contrib.gis.gdal.raster.band import BandList
from django.contrib.gis.gdal.raster.const import GDAL_RESAMPLE_ALGORITHMS
from django.contrib.gis.gdal.srs import SpatialReference, SRSException
from django.contrib.gis.geometry.regex import json_regex
from django.utils import six
from django.utils.encoding import (
force_bytes, force_text, python_2_unicode_compatible,
)
from django.utils.functional import cached_property
class TransformPoint(list):
indices = {
'origin': (0, 3),
'scale': (1, 5),
'skew': (2, 4),
}
def __init__(self, raster, prop):
x = raster.geotransform[self.indices[prop][0]]
y = raster.geotransform[self.indices[prop][1]]
list.__init__(self, [x, y])
self._raster = raster
self._prop = prop
@property
def x(self):
return self[0]
@x.setter
def x(self, value):
gtf = self._raster.geotransform
gtf[self.indices[self._prop][0]] = value
self._raster.geotransform = gtf
@property
def y(self):
return self[1]
@y.setter
def y(self, value):
gtf = self._raster.geotransform
gtf[self.indices[self._prop][1]] = value
self._raster.geotransform = gtf
@python_2_unicode_compatible
class GDALRaster(GDALBase):
"""
Wraps a raster GDAL Data Source object.
"""
def __init__(self, ds_input, write=False):
self._write = 1 if write else 0
Driver.ensure_registered()
# Preprocess json inputs. This converts json strings to dictionaries,
# which are parsed below the same way as direct dictionary inputs.
if isinstance(ds_input, six.string_types) and json_regex.match(ds_input):
ds_input = json.loads(ds_input)
# If input is a valid file path, try setting file as source.
if isinstance(ds_input, six.string_types):
if not os.path.exists(ds_input):
raise GDALException('Unable to read raster source input "{}"'.format(ds_input))
try:
# GDALOpen will auto-detect the data source type.
self._ptr = capi.open_ds(force_bytes(ds_input), self._write)
except GDALException as err:
raise GDALException('Could not open the datasource at "{}" ({}).'.format(ds_input, err))
elif isinstance(ds_input, dict):
# A new raster needs to be created in write mode
self._write = 1
# Create driver (in memory by default)
driver = Driver(ds_input.get('driver', 'MEM'))
# For out of memory drivers, check filename argument
if driver.name != 'MEM' and 'name' not in ds_input:
raise GDALException('Specify name for creation of raster with driver "{}".'.format(driver.name))
# Check if width and height where specified
if 'width' not in ds_input or 'height' not in ds_input:
raise GDALException('Specify width and height attributes for JSON or dict input.')
# Check if srid was specified
if 'srid' not in ds_input:
raise GDALException('Specify srid for JSON or dict input.')
# Create GDAL Raster
self._ptr = capi.create_ds(
driver._ptr,
force_bytes(ds_input.get('name', '')),
ds_input['width'],
ds_input['height'],
ds_input.get('nr_of_bands', len(ds_input.get('bands', []))),
ds_input.get('datatype', 6),
None
)
# Set band data if provided
for i, band_input in enumerate(ds_input.get('bands', [])):
band = self.bands[i]
band.data(band_input['data'])
if 'nodata_value' in band_input:
band.nodata_value = band_input['nodata_value']
# Set SRID
self.srs = ds_input.get('srid')
# Set additional properties if provided
if 'origin' in ds_input:
self.origin.x, self.origin.y = ds_input['origin']
if 'scale' in ds_input:
self.scale.x, self.scale.y = ds_input['scale']
if 'skew' in ds_input:
self.skew.x, self.skew.y = ds_input['skew']
elif isinstance(ds_input, c_void_p):
# Instantiate the object using an existing pointer to a gdal raster.
self._ptr = ds_input
else:
raise GDALException('Invalid data source input type: "{}".'.format(type(ds_input)))
def __del__(self):
if self._ptr and capi:
capi.close_ds(self._ptr)
def __str__(self):
return self.name
def __repr__(self):
"""
Short-hand representation because WKB may be very large.
"""
return '<Raster object at %s>' % hex(addressof(self._ptr))
def _flush(self):
"""
Flush all data from memory into the source file if it exists.
The data that needs flushing are geotransforms, coordinate systems,
nodata_values and pixel values. This function will be called
automatically wherever it is needed.
"""
# Raise an Exception if the value is being changed in read mode.
if not self._write:
raise GDALException('Raster needs to be opened in write mode to change values.')
capi.flush_ds(self._ptr)
@property
def name(self):
"""
Returns the name of this raster. Corresponds to filename
for file-based rasters.
"""
return force_text(capi.get_ds_description(self._ptr))
@cached_property
def driver(self):
"""
Returns the GDAL Driver used for this raster.
"""
ds_driver = capi.get_ds_driver(self._ptr)
return Driver(ds_driver)
@property
def width(self):
"""
Width (X axis) in pixels.
"""
return capi.get_ds_xsize(self._ptr)
@property
def height(self):
"""
Height (Y axis) in pixels.
"""
return capi.get_ds_ysize(self._ptr)
@property
def srs(self):
"""
Returns the SpatialReference used in this GDALRaster.
"""
try:
wkt = capi.get_ds_projection_ref(self._ptr)
if not wkt:
return None
return SpatialReference(wkt, srs_type='wkt')
except SRSException:
return None
@srs.setter
def srs(self, value):
"""
Sets the spatial reference used in this GDALRaster. The input can be
a SpatialReference or any parameter accepted by the SpatialReference
constructor.
"""
if isinstance(value, SpatialReference):
srs = value
elif isinstance(value, six.integer_types + six.string_types):
srs = SpatialReference(value)
else:
raise ValueError('Could not create a SpatialReference from input.')
capi.set_ds_projection_ref(self._ptr, srs.wkt.encode())
self._flush()
@property
def geotransform(self):
"""
Returns the geotransform of the data source.
Returns the default geotransform if it does not exist or has not been
set previously. The default is [0.0, 1.0, 0.0, 0.0, 0.0, -1.0].
"""
# Create empty ctypes double array for data
gtf = (c_double * 6)()
capi.get_ds_geotransform(self._ptr, byref(gtf))
return list(gtf)
@geotransform.setter
def geotransform(self, values):
"Sets the geotransform for the data source."
if sum([isinstance(x, (int, float)) for x in values]) != 6:
raise ValueError('Geotransform must consist of 6 numeric values.')
# Create ctypes double array with input and write data
values = (c_double * 6)(*values)
capi.set_ds_geotransform(self._ptr, byref(values))
self._flush()
@property
def origin(self):
"""
Coordinates of the raster origin.
"""
return TransformPoint(self, 'origin')
@property
def scale(self):
"""
Pixel scale in units of the raster projection.
"""
return TransformPoint(self, 'scale')
@property
def skew(self):
"""
Skew of pixels (rotation parameters).
"""
return TransformPoint(self, 'skew')
@property
def extent(self):
"""
Returns the extent as a 4-tuple (xmin, ymin, xmax, ymax).
"""
# Calculate boundary values based on scale and size
xval = self.origin.x + self.scale.x * self.width
yval = self.origin.y + self.scale.y * self.height
# Calculate min and max values
xmin = min(xval, self.origin.x)
xmax = max(xval, self.origin.x)
ymin = min(yval, self.origin.y)
ymax = max(yval, self.origin.y)
return xmin, ymin, xmax, ymax
@property
def bands(self):
return BandList(self)
def warp(self, ds_input, resampling='NearestNeighbour', max_error=0.0):
"""
Returns a warped GDALRaster with the given input characteristics.
The input is expected to be a dictionary containing the parameters
of the target raster. Allowed values are width, height, SRID, origin,
scale, skew, datatype, driver, and name (filename).
By default, the warp functions keeps all parameters equal to the values
of the original source raster. For the name of the target raster, the
name of the source raster will be used and appended with
_copy. + source_driver_name.
In addition, the resampling algorithm can be specified with the "resampling"
input parameter. The default is NearestNeighbor. For a list of all options
consult the GDAL_RESAMPLE_ALGORITHMS constant.
"""
# Get the parameters defining the geotransform, srid, and size of the raster
if 'width' not in ds_input:
ds_input['width'] = self.width
if 'height' not in ds_input:
ds_input['height'] = self.height
if 'srid' not in ds_input:
ds_input['srid'] = self.srs.srid
if 'origin' not in ds_input:
ds_input['origin'] = self.origin
if 'scale' not in ds_input:
ds_input['scale'] = self.scale
if 'skew' not in ds_input:
ds_input['skew'] = self.skew
# Get the driver, name, and datatype of the target raster
if 'driver' not in ds_input:
ds_input['driver'] = self.driver.name
if 'name' not in ds_input:
ds_input['name'] = self.name + '_copy.' + self.driver.name
if 'datatype' not in ds_input:
ds_input['datatype'] = self.bands[0].datatype()
# Set the number of bands
ds_input['nr_of_bands'] = len(self.bands)
# Create target raster
target = GDALRaster(ds_input, write=True)
# Copy nodata values to warped raster
for index, band in enumerate(self.bands):
target.bands[index].nodata_value = band.nodata_value
# Select resampling algorithm
algorithm = GDAL_RESAMPLE_ALGORITHMS[resampling]
# Reproject image
capi.reproject_image(
self._ptr, self.srs.wkt.encode(),
target._ptr, target.srs.wkt.encode(),
algorithm, 0.0, max_error,
c_void_p(), c_void_p(), c_void_p()
)
# Make sure all data is written to file
target._flush()
return target
def transform(self, srid, driver=None, name=None, resampling='NearestNeighbour',
max_error=0.0):
"""
Returns a copy of this raster reprojected into the given SRID.
"""
# Convert the resampling algorithm name into an algorithm id
algorithm = GDAL_RESAMPLE_ALGORITHMS[resampling]
# Instantiate target spatial reference system
target_srs = SpatialReference(srid)
# Create warped virtual dataset in the target reference system
target = capi.auto_create_warped_vrt(
self._ptr, self.srs.wkt.encode(), target_srs.wkt.encode(),
algorithm, max_error, c_void_p()
)
target = GDALRaster(target)
# Construct the target warp dictionary from the virtual raster
data = {
'srid': srid,
'width': target.width,
'height': target.height,
'origin': [target.origin.x, target.origin.y],
'scale': [target.scale.x, target.scale.y],
'skew': [target.skew.x, target.skew.y],
}
# Set the driver and filepath if provided
if driver:
data['driver'] = driver
if name:
data['name'] = name
# Warp the raster into new srid
return self.warp(data, resampling=resampling, max_error=max_error)
|
bsd-3-clause
|
[
646,
2022,
199,
646,
747,
199,
504,
5577,
492,
2287,
1618,
12,
15968,
12,
286,
63,
3157,
12,
286,
63,
1647,
63,
80,
199,
199,
504,
1639,
14,
2828,
14,
5668,
14,
11600,
14,
1095,
492,
15801,
1563,
199,
504,
1639,
14,
2828,
14,
5668,
14,
11600,
14,
3090,
492,
19447,
199,
504,
1639,
14,
2828,
14,
5668,
14,
11600,
14,
705,
492,
15801,
1726,
199,
504,
1639,
14,
2828,
14,
5668,
14,
11600,
14,
16141,
83,
492,
19775,
465,
13648,
199,
504,
1639,
14,
2828,
14,
5668,
14,
11600,
14,
20876,
14,
7877,
492,
27709,
1296,
199,
504,
1639,
14,
2828,
14,
5668,
14,
11600,
14,
20876,
14,
1297,
492,
15801,
63,
3830,
10818,
63,
26613,
726,
1571,
3053,
199,
504,
1639,
14,
2828,
14,
5668,
14,
11600,
14,
12722,
492,
24324,
12,
12765,
21686,
199,
504,
1639,
14,
2828,
14,
5668,
14,
7660,
14,
3821,
492,
2022,
63,
3821,
199,
504,
1639,
14,
1208,
492,
3816,
199,
504,
1639,
14,
1208,
14,
2991,
492,
334,
272,
3542,
63,
2394,
12,
3542,
63,
505,
12,
2366,
63,
18,
63,
2975,
63,
6490,
12,
199,
9,
199,
504,
1639,
14,
1208,
14,
15481,
492,
6328,
63,
1829,
421,
199,
533,
19463,
3428,
8,
513,
304,
272,
4918,
275,
469,
267,
283,
6493,
356,
334,
16,
12,
650,
395,
267,
283,
3467,
356,
334,
17,
12,
959,
395,
267,
283,
27424,
356,
334,
18,
12,
841,
395,
272,
789,
339,
347,
636,
826,
721,
277,
12,
19775,
12,
5931,
304,
267,
671,
275,
19775,
14,
303,
357,
1320,
964,
59,
277,
14,
4108,
59,
4469,
1527,
16,
2677,
267,
612,
275,
19775,
14,
303,
357,
1320,
964,
59,
277,
14,
4108,
59,
4469,
1527,
17,
2677,
267,
769,
855,
826,
721,
277,
12,
359,
88,
12,
612,
566,
267,
291,
423,
20876,
275,
19775,
267,
291,
423,
4469,
275,
5931,
339,
768,
1829,
272,
347,
671,
8,
277,
304,
267,
372,
291,
59,
16,
61,
339,
768,
88,
14,
8345,
272,
347,
671,
8,
277,
12,
574,
304,
267,
486,
3249,
275,
291,
423,
20876,
14,
303,
357,
1320,
964,
267,
486,
3249,
59,
277,
14,
4108,
59,
277,
423,
4469,
1527,
16,
2677,
275,
574,
267,
291,
423,
20876,
14,
303,
357,
1320,
964,
275,
486,
3249,
339,
768,
1829,
272,
347,
612,
8,
277,
304,
267,
372,
291,
59,
17,
61,
339,
768,
89,
14,
8345,
272,
347,
612,
8,
277,
12,
574,
304,
267,
486,
3249,
275,
291,
423,
20876,
14,
303,
357,
1320,
964,
267,
486,
3249,
59,
277,
14,
4108,
59,
277,
423,
4469,
1527,
17,
2677,
275,
574,
267,
291,
423,
20876,
14,
303,
357,
1320,
964,
275,
486,
3249,
421,
199,
32,
1548,
63,
18,
63,
2975,
63,
6490,
199,
533,
15801,
13284,
8,
17835,
1563,
304,
272,
408,
272,
644,
8146,
282,
19775,
15801,
3918,
5800,
909,
14,
272,
408,
272,
347,
636,
826,
721,
277,
12,
6364,
63,
1210,
12,
2218,
29,
797,
304,
267,
291,
423,
952,
275,
413,
340,
2218,
587,
378,
267,
19447,
14,
7505,
63,
11616,
342,
398,
327,
5543,
1412,
2022,
4153,
14,
961,
15373,
2022,
3326,
370,
11196,
12,
267,
327,
1314,
787,
4565,
5084,
314,
2011,
4340,
465,
4125,
2600,
4153,
14,
267,
340,
1228,
8,
795,
63,
1210,
12,
3816,
14,
875,
63,
1313,
9,
436,
2022,
63,
3821,
14,
1431,
8,
795,
63,
1210,
304,
288,
6364,
63,
1210,
275,
2022,
14,
3640,
8,
795,
63,
1210,
9,
398,
327,
982,
1324,
365,
282,
1686,
570,
931,
12,
862,
4260,
570,
465,
1350,
14,
267,
340,
1228,
8,
795,
63,
1210,
12,
3816,
14,
875,
63,
1313,
304,
288,
340,
440,
747,
14,
515,
14,
2444,
8,
795,
63,
1210,
304,
355,
746,
15801,
1726,
360,
6005,
370,
1586,
19775,
1350,
1324,
28168,
1370,
908,
8,
795,
63,
1210,
430,
288,
862,
26,
355,
327,
15801,
4299,
911,
2599,
13,
13552,
314,
666,
1350,
730,
14,
355,
291,
423,
4695,
275,
13648,
14,
1490,
63,
795,
8,
3990,
63,
2394,
8,
795,
63,
1210,
395,
291,
423,
952,
9,
288,
871,
15801,
1726,
465,
2329,
26,
355,
746,
15801,
1726,
360,
6531,
440,
1551,
314,
29289,
737,
28168,
334,
2440,
680,
1370,
908,
8,
795,
63,
1210,
12,
2329,
430,
267,
916,
1228,
8,
795,
63,
1210,
12,
1211,
304,
288,
327,
437,
892,
19775,
4839,
370,
506,
2737,
315,
2218,
818,
288,
291,
423,
952,
275,
413,
953,
327,
2790,
5253,
334,
262,
4402,
701,
849,
9,
288,
5253,
275,
19447,
8,
795,
63,
1210,
14,
362,
360,
3090,
297,
283,
10293,
1333,
953,
327,
2104,
734,
402,
4402,
19016,
12,
1104,
1788,
1423,
288,
340,
5253,
14,
354,
1137,
283,
10293,
7,
436,
283,
354,
7,
440,
315,
6364,
63,
1210,
26,
355,
746,
15801,
1726,
360,
17768,
536,
367,
7143,
402,
19775,
543,
5253,
11491,
1674,
1370,
908,
8,
3090,
14,
354,
430,
953,
327,
2670,
340,
3462,
436,
4569,
2382,
2013,
288,
340,
283,
2063,
7,
440,
315,
6364,
63,
1210,
503,
283,
3333,
7,
440,
315,
6364,
63,
1210,
26,
355,
746,
15801,
1726,
360,
17768,
3462,
436,
4569,
3004,
367,
4840,
503,
1211,
1324,
2659,
953,
327,
2670,
340,
15627,
1990,
2013,
288,
340,
283,
10498,
7,
440,
315,
6364,
63,
1210,
26,
355,
746,
15801,
1726,
360,
17768,
15627,
367,
4840,
503,
1211,
1324,
2659,
953,
327,
2790,
15801,
820,
2311,
288,
291,
423,
4695,
275,
13648,
14,
981,
63,
795,
8,
355,
5253,
423,
4695,
12,
355,
3542,
63,
2394,
8,
795,
63,
1210,
14,
362,
360,
354,
297,
283,
3855,
355,
6364,
63,
1210,
459,
2063,
995,
355,
6364,
63,
1210,
459,
3333,
995,
355,
6364,
63,
1210,
14,
362,
360,
7865,
63,
1618,
63,
23086,
297,
822,
8,
795,
63,
1210,
14,
362,
360,
23086,
297,
942,
11508,
355,
6364,
63,
1210,
14,
362,
360,
14184,
297,
1227,
395,
355,
488,
288,
776,
953,
327,
2494,
10981,
666,
340,
2741,
288,
367,
284,
12,
10981,
63,
1210,
315,
3874,
8,
795,
63,
1210,
14,
362,
360,
23086,
297,
3073,
304,
355,
10981,
275,
291,
14,
23086,
59,
73,
61,
355,
10981,
14,
576,
8,
7877,
63,
1210
] |
[
2022,
199,
646,
747,
199,
504,
5577,
492,
2287,
1618,
12,
15968,
12,
286,
63,
3157,
12,
286,
63,
1647,
63,
80,
199,
199,
504,
1639,
14,
2828,
14,
5668,
14,
11600,
14,
1095,
492,
15801,
1563,
199,
504,
1639,
14,
2828,
14,
5668,
14,
11600,
14,
3090,
492,
19447,
199,
504,
1639,
14,
2828,
14,
5668,
14,
11600,
14,
705,
492,
15801,
1726,
199,
504,
1639,
14,
2828,
14,
5668,
14,
11600,
14,
16141,
83,
492,
19775,
465,
13648,
199,
504,
1639,
14,
2828,
14,
5668,
14,
11600,
14,
20876,
14,
7877,
492,
27709,
1296,
199,
504,
1639,
14,
2828,
14,
5668,
14,
11600,
14,
20876,
14,
1297,
492,
15801,
63,
3830,
10818,
63,
26613,
726,
1571,
3053,
199,
504,
1639,
14,
2828,
14,
5668,
14,
11600,
14,
12722,
492,
24324,
12,
12765,
21686,
199,
504,
1639,
14,
2828,
14,
5668,
14,
7660,
14,
3821,
492,
2022,
63,
3821,
199,
504,
1639,
14,
1208,
492,
3816,
199,
504,
1639,
14,
1208,
14,
2991,
492,
334,
272,
3542,
63,
2394,
12,
3542,
63,
505,
12,
2366,
63,
18,
63,
2975,
63,
6490,
12,
199,
9,
199,
504,
1639,
14,
1208,
14,
15481,
492,
6328,
63,
1829,
421,
199,
533,
19463,
3428,
8,
513,
304,
272,
4918,
275,
469,
267,
283,
6493,
356,
334,
16,
12,
650,
395,
267,
283,
3467,
356,
334,
17,
12,
959,
395,
267,
283,
27424,
356,
334,
18,
12,
841,
395,
272,
789,
339,
347,
636,
826,
721,
277,
12,
19775,
12,
5931,
304,
267,
671,
275,
19775,
14,
303,
357,
1320,
964,
59,
277,
14,
4108,
59,
4469,
1527,
16,
2677,
267,
612,
275,
19775,
14,
303,
357,
1320,
964,
59,
277,
14,
4108,
59,
4469,
1527,
17,
2677,
267,
769,
855,
826,
721,
277,
12,
359,
88,
12,
612,
566,
267,
291,
423,
20876,
275,
19775,
267,
291,
423,
4469,
275,
5931,
339,
768,
1829,
272,
347,
671,
8,
277,
304,
267,
372,
291,
59,
16,
61,
339,
768,
88,
14,
8345,
272,
347,
671,
8,
277,
12,
574,
304,
267,
486,
3249,
275,
291,
423,
20876,
14,
303,
357,
1320,
964,
267,
486,
3249,
59,
277,
14,
4108,
59,
277,
423,
4469,
1527,
16,
2677,
275,
574,
267,
291,
423,
20876,
14,
303,
357,
1320,
964,
275,
486,
3249,
339,
768,
1829,
272,
347,
612,
8,
277,
304,
267,
372,
291,
59,
17,
61,
339,
768,
89,
14,
8345,
272,
347,
612,
8,
277,
12,
574,
304,
267,
486,
3249,
275,
291,
423,
20876,
14,
303,
357,
1320,
964,
267,
486,
3249,
59,
277,
14,
4108,
59,
277,
423,
4469,
1527,
17,
2677,
275,
574,
267,
291,
423,
20876,
14,
303,
357,
1320,
964,
275,
486,
3249,
421,
199,
32,
1548,
63,
18,
63,
2975,
63,
6490,
199,
533,
15801,
13284,
8,
17835,
1563,
304,
272,
408,
272,
644,
8146,
282,
19775,
15801,
3918,
5800,
909,
14,
272,
408,
272,
347,
636,
826,
721,
277,
12,
6364,
63,
1210,
12,
2218,
29,
797,
304,
267,
291,
423,
952,
275,
413,
340,
2218,
587,
378,
267,
19447,
14,
7505,
63,
11616,
342,
398,
327,
5543,
1412,
2022,
4153,
14,
961,
15373,
2022,
3326,
370,
11196,
12,
267,
327,
1314,
787,
4565,
5084,
314,
2011,
4340,
465,
4125,
2600,
4153,
14,
267,
340,
1228,
8,
795,
63,
1210,
12,
3816,
14,
875,
63,
1313,
9,
436,
2022,
63,
3821,
14,
1431,
8,
795,
63,
1210,
304,
288,
6364,
63,
1210,
275,
2022,
14,
3640,
8,
795,
63,
1210,
9,
398,
327,
982,
1324,
365,
282,
1686,
570,
931,
12,
862,
4260,
570,
465,
1350,
14,
267,
340,
1228,
8,
795,
63,
1210,
12,
3816,
14,
875,
63,
1313,
304,
288,
340,
440,
747,
14,
515,
14,
2444,
8,
795,
63,
1210,
304,
355,
746,
15801,
1726,
360,
6005,
370,
1586,
19775,
1350,
1324,
28168,
1370,
908,
8,
795,
63,
1210,
430,
288,
862,
26,
355,
327,
15801,
4299,
911,
2599,
13,
13552,
314,
666,
1350,
730,
14,
355,
291,
423,
4695,
275,
13648,
14,
1490,
63,
795,
8,
3990,
63,
2394,
8,
795,
63,
1210,
395,
291,
423,
952,
9,
288,
871,
15801,
1726,
465,
2329,
26,
355,
746,
15801,
1726,
360,
6531,
440,
1551,
314,
29289,
737,
28168,
334,
2440,
680,
1370,
908,
8,
795,
63,
1210,
12,
2329,
430,
267,
916,
1228,
8,
795,
63,
1210,
12,
1211,
304,
288,
327,
437,
892,
19775,
4839,
370,
506,
2737,
315,
2218,
818,
288,
291,
423,
952,
275,
413,
953,
327,
2790,
5253,
334,
262,
4402,
701,
849,
9,
288,
5253,
275,
19447,
8,
795,
63,
1210,
14,
362,
360,
3090,
297,
283,
10293,
1333,
953,
327,
2104,
734,
402,
4402,
19016,
12,
1104,
1788,
1423,
288,
340,
5253,
14,
354,
1137,
283,
10293,
7,
436,
283,
354,
7,
440,
315,
6364,
63,
1210,
26,
355,
746,
15801,
1726,
360,
17768,
536,
367,
7143,
402,
19775,
543,
5253,
11491,
1674,
1370,
908,
8,
3090,
14,
354,
430,
953,
327,
2670,
340,
3462,
436,
4569,
2382,
2013,
288,
340,
283,
2063,
7,
440,
315,
6364,
63,
1210,
503,
283,
3333,
7,
440,
315,
6364,
63,
1210,
26,
355,
746,
15801,
1726,
360,
17768,
3462,
436,
4569,
3004,
367,
4840,
503,
1211,
1324,
2659,
953,
327,
2670,
340,
15627,
1990,
2013,
288,
340,
283,
10498,
7,
440,
315,
6364,
63,
1210,
26,
355,
746,
15801,
1726,
360,
17768,
15627,
367,
4840,
503,
1211,
1324,
2659,
953,
327,
2790,
15801,
820,
2311,
288,
291,
423,
4695,
275,
13648,
14,
981,
63,
795,
8,
355,
5253,
423,
4695,
12,
355,
3542,
63,
2394,
8,
795,
63,
1210,
14,
362,
360,
354,
297,
283,
3855,
355,
6364,
63,
1210,
459,
2063,
995,
355,
6364,
63,
1210,
459,
3333,
995,
355,
6364,
63,
1210,
14,
362,
360,
7865,
63,
1618,
63,
23086,
297,
822,
8,
795,
63,
1210,
14,
362,
360,
23086,
297,
942,
11508,
355,
6364,
63,
1210,
14,
362,
360,
14184,
297,
1227,
395,
355,
488,
288,
776,
953,
327,
2494,
10981,
666,
340,
2741,
288,
367,
284,
12,
10981,
63,
1210,
315,
3874,
8,
795,
63,
1210,
14,
362,
360,
23086,
297,
3073,
304,
355,
10981,
275,
291,
14,
23086,
59,
73,
61,
355,
10981,
14,
576,
8,
7877,
63,
1210,
0
] |
[
1,
1,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p/qiime
|
tests/test_truncate_reverse_primer.py
|
15
|
15531
|
#!/usr/bin/env python
# File created February 29, 2012
from __future__ import division
__author__ = "William Walters"
__copyright__ = "Copyright 2011, The QIIME Project"
__credits__ = ["William Walters"]
__license__ = "GPL"
__version__ = "1.9.1-dev"
__maintainer__ = "William Walters"
__email__ = "William.A.Walters@colorado.edu"
from os.path import exists, join, basename
from os import close
from shutil import rmtree
from tempfile import mkdtemp, mkstemp
from unittest import TestCase, main
from qiime.util import create_dir
from skbio.util import remove_files
from qiime.truncate_reverse_primer import get_rev_primer_seqs,\
get_output_filepaths, truncate_rev_primers, truncate_reverse_primer
from skbio.sequence import BiologicalSequenceError
class FakeOutFile(object):
def __init__(self):
self.data = ""
def write(self, s):
self.data += s
class TruncateRemoveReversePrimerTests(TestCase):
""" Unit tests for the truncate_reverse_primers.py module """
def setUp(self):
# create the temporary input files that will be used
self._files_to_remove = []
self.sample_fasta_file1_data = sample_fasta_file1
self.sample_fasta_file_bad_labels_data =\
sample_fasta_file_bad_labels
self.sample_mapping_file1_data = sample_mapping_file1
self.sample_mapping_file_no_revprimer_header =\
sample_mapping_file_no_revprimer_header
self.sample_mapping_file_bad_revprimer =\
sample_mapping_file_bad_revprimer
self.expected_truncation_default_settings =\
expected_truncation_default_settings
self.expected_truncation_zero_mismatches =\
expected_truncation_zero_mismatches
self.expected_truncation_zero_mismatches_truncate_remove =\
expected_truncation_zero_mismatches_truncate_remove
fd, self.fasta_fp = mkstemp(prefix='fasta_seqs_',
suffix='.fna')
close(fd)
seq_file = open(self.fasta_fp, 'w')
seq_file.write(self.sample_fasta_file1_data)
seq_file.close()
fd, self.fasta_badlabels_fp = mkstemp(prefix="fasta_seqs_badlabels_",
suffix=".fna")
close(fd)
seq_file = open(self.fasta_badlabels_fp, "w")
seq_file.write(self.sample_fasta_file_bad_labels_data)
seq_file.close()
fd, self.mapping_fp = mkstemp(prefix='sample_mapping_',
suffix='.txt')
close(fd)
mapping_file = open(self.mapping_fp, "w")
mapping_file.write(self.sample_mapping_file1_data)
mapping_file.close()
fd, self.mapping_bad_header_fp = mkstemp(
prefix='sample_mapping_badheader_',
suffix=".txt")
close(fd)
mapping_file = open(self.mapping_bad_header_fp, "w")
mapping_file.write(self.sample_mapping_file_no_revprimer_header)
mapping_file.close()
fd, self.mapping_bad_primer_fp = mkstemp(
prefix='sample_mapping_badprimer_',
suffix=".txt")
close(fd)
mapping_file = open(self.mapping_bad_primer_fp, "w")
mapping_file.write(self.sample_mapping_file_bad_revprimer)
mapping_file.close()
self.output_dir = mkdtemp()
self.output_dir += '/'
create_dir(self.output_dir)
self._files_to_remove =\
[self.fasta_fp, self.mapping_fp, self.mapping_bad_header_fp,
self.mapping_bad_primer_fp, self.fasta_badlabels_fp]
def tearDown(self):
if self._files_to_remove:
remove_files(self._files_to_remove)
if exists(self.output_dir):
rmtree(self.output_dir)
def test_get_rev_primer_seqs(self):
""" Builds dict of reverse primers from mapping file """
actual_rev_primers = get_rev_primer_seqs(open(self.mapping_fp, "U"))
expected_rev_primers = {'PC.481': ['CTCTCCG'], 'PC.634': ['CTCTCAG'],
'PC.635': ['CTCTCAG'], 'PC.636': ['CTCTCAG'], 'PC.354': ['CTCTCAG',
'TTCTCRG']}
self.assertEqual(actual_rev_primers, expected_rev_primers)
def test_get_rev_primer_seqs_errors(self):
"""Raises errors with invalid mapping file """
# Raises error if missing ReversePrimer column
with open(self.mapping_bad_header_fp, "U") as f:
self.assertRaises(KeyError, get_rev_primer_seqs, f)
# Raises error if invalid characters in primer
with open(self.mapping_bad_primer_fp, "U") as f:
self.assertRaises(BiologicalSequenceError, get_rev_primer_seqs, f)
def test_get_output_filepaths(self):
""" Properly returns output filepaths """
actual_fna_fp, actual_log_fp = get_output_filepaths(".",
'/home/tests/seqs.fna')
expected_fna_fp = "./seqs_rev_primer_truncated.fna"
expected_log_fp = "./rev_primer_truncation.log"
self.assertEqual(actual_fna_fp, expected_fna_fp)
self.assertEqual(actual_log_fp, expected_log_fp)
def test_truncate_rev_primers(self):
""" Properly truncates remove primers """
out_f = FakeOutFile()
rev_primers = {'PC.481': ['CTCTCCG'], 'PC.634': ['CTCTCAG'],
'PC.635': ['CTCTCAG'], 'PC.636': ['CTCTCAG'], 'PC.354': ['CTCTCAG']}
# Use default options, all sequences should get truncated and written
log_data = truncate_rev_primers(open(self.fasta_fp, "U"),
out_f, rev_primers)
expected_log_data = {'seqs_written': 5, 'total_seqs': 6,
'sample_id_not_found': 0, 'reverse_primer_not_found': 0}
self.assertEqual(log_data, expected_log_data)
# Note that because these are short sequences, two mismatches allows
# for a very short truncation of one of the sequences
self.assertEqual(out_f.data, self.expected_truncation_default_settings)
# With zero mismatches will not truncate all seqs
out_f = FakeOutFile()
# Use default options, all sequences should get truncated and written
log_data = truncate_rev_primers(open(self.fasta_fp, "U"),
out_f, rev_primers, primer_mismatches=0)
expected_log_data = {'seqs_written': 5, 'total_seqs': 6,
'sample_id_not_found': 0, 'reverse_primer_not_found': 2}
self.assertEqual(log_data, expected_log_data)
# With zero mismatches allowed, 2 seqs should not be truncated
self.assertEqual(out_f.data, self.expected_truncation_zero_mismatches)
# With zero mismatches and truncate_remove option, should only write
# 3 of the sequences
out_f = FakeOutFile()
log_data = truncate_rev_primers(open(self.fasta_fp, "U"),
out_f, rev_primers, truncate_option="truncate_remove",
primer_mismatches=0)
expected_log_data = {'seqs_written': 3, 'total_seqs': 6,
'sample_id_not_found': 0, 'reverse_primer_not_found': 2}
self.assertEqual(log_data, expected_log_data)
# With zero mismatches allowed, 3 seqs total should be written
self.assertEqual(out_f.data,
self.expected_truncation_zero_mismatches_truncate_remove)
# Should count sample ids not found in log
out_f = FakeOutFile()
rev_primers = {'PC.481': ['CTCTCCG'], 'PC.634': ['CTCTCAG'],
'PC.635': ['CTCTCAG'], 'PC.636': ['CTCTCAG'], 'PC.354': ['CTCTCAG']}
# Use default options, all sequences should get truncated and written
log_data = truncate_rev_primers(open(self.fasta_badlabels_fp, "U"),
out_f, rev_primers)
expected_log_data = {'seqs_written': 5, 'total_seqs': 5,
'sample_id_not_found': 5, 'reverse_primer_not_found': 0}
self.assertEqual(log_data, expected_log_data)
# No matches to sample IDs, so sequences are written unmodified
self.assertEqual(out_f.data, self.sample_fasta_file_bad_labels_data)
def test_truncate_reverse_primer(self):
""" Overall module functionality test """
truncate_reverse_primer(self.fasta_fp, self.mapping_fp,
self.output_dir, truncate_option='truncate_only', primer_mismatches=2)
output_log_fp = open(join(self.output_dir,
"rev_primer_truncation.log"), "U")
actual_log_lines = [line.strip() for line in output_log_fp]
# Because filepaths used are recorded, need the tmp filepaths
expected_log_lines = ['Details for removal of reverse primers',
'Original fasta filepath: %s' % self.fasta_fp,
'Total seqs in fasta: 6',
'Mapping filepath: %s' % self.mapping_fp,
'Truncation option: truncate_only',
'Mismatches allowed: 2',
'Total seqs written: 5',
'SampleIDs not found: 0',
'Reverse primers not found: 0']
self.assertEqual(actual_log_lines, expected_log_lines)
expected_fna_fp = basename(self.fasta_fp.replace('.fna', '')) +\
"_rev_primer_truncated.fna"
fasta_fp = open(join(self.output_dir, expected_fna_fp), "U")
actual_fasta_output = [line.strip() for line in fasta_fp]
self.assertEqual(actual_fasta_output,
self.expected_truncation_default_settings.strip().split('\n'))
sample_fasta_file1 = """>PC.634_1 FLP3FBN01ELBSX orig_bc=ACAGAGTCGGCT new_bc=ACAGAGTCGGCT bc_diffs=0
CTGGGCCGTGTCTCAGTCCCAATGTGGCCGTTTACCCTCTCAGGCCGGCTAC
>PC.634_2 FLP3FBN01EG8AX orig_bc=ACAGAGTCGGCT new_bc=ACAGAGTCGGCT bc_diffs=0
TTGGACCGTGTCTCAGTTCCAATGTGGGGGCCTTCCCTCTCAGAACCCCTATC
>PC.354_3 FLP3FBN01EEWKD orig_bc=AGCACGAGCCTA new_bc=AGCACGAGCCTA bc_diffs=0
TTGGGCCGTGTCTCAGTCCCAATGTGGCCGATCAGTCTCTTAACTCGGCTAT
>PC.481_4 FLP3FBN01DEHK3 orig_bc=ACCAGCGACTAG new_bc=ACCAGCGACTAG bc_diffs=0
CTGGGCCGTGTCTCAGTCCCAATGTGGCCGTTCAACCTCTCAGTCCGGCTAC
>PC.634_5 FLP3FBN01DGFYQ orig_bc=ACAGAGTCGGCT new_bc=ACAGAGTCGGCT bc_diffs=0
TTGGGCCGTGTCTCAGTCCCAATGTGGCCGTTCACCCTCTCAGGCCGGCTAC
>PC.634_6 RevPrimerAtStart FLP3FBN01DGFYQ orig_bc=ACAGAGTCGGCT new_bc=ACAGAGTCGGCT bc_diffs=0
CTCTCAGCACCGTTTGGGCCGTGTCTCAGTCCCAATGTGGCCGTTCACC
"""
sample_fasta_file_bad_labels = """>CaptHammer_1 FLP3FBN01ELBSX orig_bc=ACAGAGTCGGCT new_bc=ACAGAGTCGGCT bc_diffs=0
CTGGGCCGTGTCTCAGTCCCAATGTGGCCGTTTACCCTCTCAGGCCGGCTAC
>JohnnySnow_2 FLP3FBN01EG8AX orig_bc=ACAGAGTCGGCT new_bc=ACAGAGTCGGCT bc_diffs=0
TTGGACCGTGTCTCAGTTCCAATGTGGGGGCCTTCCCTCTCAGAACCCCTATC
>BadHorse_3 FLP3FBN01EEWKD orig_bc=AGCACGAGCCTA new_bc=AGCACGAGCCTA bc_diffs=0
TTGGGCCGTGTCTCAGTCCCAATGTGGCCGATCAGTCTCTTAACTCGGCTAT
>Moist_4 FLP3FBN01DEHK3 orig_bc=ACCAGCGACTAG new_bc=ACCAGCGACTAG bc_diffs=0
CTGGGCCGTGTCTCAGTCCCAATGTGGCCGTTCAACCTCTCAGTCCGGCTAC
>DrHorrible_5 FLP3FBN01DGFYQ orig_bc=ACAGAGTCGGCT new_bc=ACAGAGTCGGCT bc_diffs=0
TTGGGCCGTGTCTCAGTCCCAATGTGGCCGTTCACCCTCTCAGGCCGGCTAC
"""
expected_truncation_default_settings = """>PC.634_1 FLP3FBN01ELBSX orig_bc=ACAGAGTCGGCT new_bc=ACAGAGTCGGCT bc_diffs=0
CTGGGCCGTGTCTCAGTCCCAATGTGGCCGTTTACC
>PC.634_2 FLP3FBN01EG8AX orig_bc=ACAGAGTCGGCT new_bc=ACAGAGTCGGCT bc_diffs=0
TTGGACCGTGTCTCAGTTCCAATGTGGGGGCCTTCC
>PC.354_3 FLP3FBN01EEWKD orig_bc=AGCACGAGCCTA new_bc=AGCACGAGCCTA bc_diffs=0
TTGGGCCGT
>PC.481_4 FLP3FBN01DEHK3 orig_bc=ACCAGCGACTAG new_bc=ACCAGCGACTAG bc_diffs=0
CTGGGCCGTGTCTCAGTCCCAATGTGGCCGTTCAAC
>PC.634_5 FLP3FBN01DGFYQ orig_bc=ACAGAGTCGGCT new_bc=ACAGAGTCGGCT bc_diffs=0
TTGGGCCGTGTCTCAGTCCCAATGTGGCCGTTCACC
"""
expected_truncation_zero_mismatches = """>PC.634_1 FLP3FBN01ELBSX orig_bc=ACAGAGTCGGCT new_bc=ACAGAGTCGGCT bc_diffs=0
CTGGGCCGTGTCTCAGTCCCAATGTGGCCGTTTACC
>PC.634_2 FLP3FBN01EG8AX orig_bc=ACAGAGTCGGCT new_bc=ACAGAGTCGGCT bc_diffs=0
TTGGACCGTGTCTCAGTTCCAATGTGGGGGCCTTCC
>PC.354_3 FLP3FBN01EEWKD orig_bc=AGCACGAGCCTA new_bc=AGCACGAGCCTA bc_diffs=0
TTGGGCCGTGTCTCAGTCCCAATGTGGCCGATCAGTCTCTTAACTCGGCTAT
>PC.481_4 FLP3FBN01DEHK3 orig_bc=ACCAGCGACTAG new_bc=ACCAGCGACTAG bc_diffs=0
CTGGGCCGTGTCTCAGTCCCAATGTGGCCGTTCAACCTCTCAGTCCGGCTAC
>PC.634_5 FLP3FBN01DGFYQ orig_bc=ACAGAGTCGGCT new_bc=ACAGAGTCGGCT bc_diffs=0
TTGGGCCGTGTCTCAGTCCCAATGTGGCCGTTCACC
"""
expected_truncation_zero_mismatches_truncate_remove = """>PC.634_1 FLP3FBN01ELBSX orig_bc=ACAGAGTCGGCT new_bc=ACAGAGTCGGCT bc_diffs=0
CTGGGCCGTGTCTCAGTCCCAATGTGGCCGTTTACC
>PC.634_2 FLP3FBN01EG8AX orig_bc=ACAGAGTCGGCT new_bc=ACAGAGTCGGCT bc_diffs=0
TTGGACCGTGTCTCAGTTCCAATGTGGGGGCCTTCC
>PC.634_5 FLP3FBN01DGFYQ orig_bc=ACAGAGTCGGCT new_bc=ACAGAGTCGGCT bc_diffs=0
TTGGGCCGTGTCTCAGTCCCAATGTGGCCGTTCACC
"""
sample_mapping_file1 = """#SampleID BarcodeSequence LinkerPrimerSequence Treatment DOB ReversePrimer Description
"#Example mapping file for the QIIME analysis package. These 9 samples are from a study of the effects of exercise and diet on mouse cardiac physiology (Crawford, et al, PNAS, 2009)."
PC.354 AGCACGAGCCTA YATGCTGCCTCCCGTAGGAGT Control 20061218 CTGAGAG,CYGAGAA Control_mouse_I.D._354
PC.481 ACCAGCGACTAG YATGCTGCCTCCCGTAGGAGT Control 20070314 CGGAGAG Control_mouse_I.D._481
PC.634 ACAGAGTCGGCT &&&YATGCTGCCTCCCGTAGGAGT Fast 20080116 CTGAGAG Fasting_mouse_I.D._634
PC.635 ACCGCAGAGTCA YATGCTGCCTCCCGTAGGAGT Fast 20080116 CTGAGAG Fasting_mouse_I.D._635
PC.636 ACGGTGAGTGTC YATGCTGCCTCCCGTAGGAGT Fast 20080116 CTGAGAG Fasting_mouse_I.D._636"""
sample_mapping_file_no_revprimer_header = """#SampleID BarcodeSequence LinkerPrimerSequence Treatment DOB XXXX Description
"#Example mapping file for the QIIME analysis package. These 9 samples are from a study of the effects of exercise and diet on mouse cardiac physiology (Crawford, et al, PNAS, 2009)."
PC.354 AGCACGAGCCTA YATGCTGCCTCCCGTAGGAGT Control 20061218 CTGAGAG Control_mouse_I.D._354
PC.481 ACCAGCGACTAG YATGCTGCCTCCCGTAGGAGT Control 20070314 CGGAGAG Control_mouse_I.D._481
PC.634 ACAGAGTCGGCT YATGCTGCCTCCCGTAGGAGT Fast 20080116 CTGAGAG Fasting_mouse_I.D._634
PC.635 ACCGCAGAGTCA YATGCTGCCTCCCGTAGGAGT Fast 20080116 CTGAGAG Fasting_mouse_I.D._635
PC.636 ACGGTGAGTGTC YATGCTGCCTCCCGTAGGAGT Fast 20080116 CTGAGAG Fasting_mouse_I.D._636"""
sample_mapping_file_bad_revprimer = """#SampleID BarcodeSequence LinkerPrimerSequence Treatment DOB ReversePrimer Description
"#Example mapping file for the QIIME analysis package. These 9 samples are from a study of the effects of exercise and diet on mouse cardiac physiology (Crawford, et al, PNAS, 2009)."
PC.354 AGCACGAGCCTA YATGCTGCCTCCCGTAGGAGT Control 20061218 CTGAGAG Control_mouse_I.D._354
PC.481 ACCAGCGACTAG YATGCTGCCTCCCGTAGGAGT Control 20070314 CGGAGAG Control_mouse_I.D._481
PC.634 ACAGAGTCGGCT YATGCTGCCTCCCGTAGGAGT Fast 20080116 CTGAGAG Fasting_mouse_I.D._634
PC.635 ACCGCAGAGTCA YATGCTGCCTCCCGTAGGAGT Fast 20080116 CTGAGXG Fasting_mouse_I.D._635
PC.636 ACGGTGAGTGTC YATGCTGCCTCCCGTAGGAGT Fast 20080116 CTGAGAG Fasting_mouse_I.D._636"""
if __name__ == '__main__':
main()
|
gpl-2.0
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
3,
3814,
2737,
21141,
26709,
7349,
12,
6029,
199,
504,
636,
2443,
363,
492,
4629,
199,
199,
363,
2502,
363,
275,
298,
55,
8148,
455,
644,
31185,
2,
199,
363,
7307,
363,
275,
298,
7384,
7760,
12,
710,
1413,
41,
3465,
7290,
2,
199,
363,
22461,
363,
275,
2097,
55,
8148,
455,
644,
31185,
937,
199,
363,
1682,
363,
275,
298,
12006,
2,
199,
363,
1023,
363,
275,
298,
17,
14,
25,
14,
17,
13,
2374,
2,
199,
363,
26665,
363,
275,
298,
55,
8148,
455,
644,
31185,
2,
199,
363,
2123,
363,
275,
298,
55,
8148,
455,
14,
33,
14,
55,
31185,
32,
2326,
5129,
14,
8654,
2,
199,
199,
504,
747,
14,
515,
492,
3495,
12,
4263,
12,
9593,
199,
504,
747,
492,
4002,
199,
504,
5145,
492,
20978,
199,
504,
5549,
492,
31781,
12,
333,
6080,
808,
199,
199,
504,
2882,
492,
7640,
12,
2446,
199,
504,
31402,
1036,
14,
1974,
492,
1218,
63,
694,
199,
504,
11448,
2308,
14,
1974,
492,
2813,
63,
1725,
199,
199,
504,
31402,
1036,
14,
12517,
63,
4471,
63,
1359,
2626,
492,
664,
63,
4964,
63,
1359,
2626,
63,
19467,
4202,
272,
664,
63,
1199,
63,
493,
3771,
12,
14547,
63,
4964,
63,
12446,
2393,
12,
14547,
63,
4471,
63,
1359,
2626,
199,
199,
504,
11448,
2308,
14,
4041,
492,
699,
2308,
7954,
5826,
547,
199,
199,
533,
7777,
2204,
1173,
8,
785,
304,
339,
347,
636,
826,
721,
277,
304,
267,
291,
14,
576,
275,
3087,
339,
347,
2218,
8,
277,
12,
308,
304,
267,
291,
14,
576,
847,
308,
421,
199,
533,
25594,
1411,
5587,
14987,
4562,
2626,
2925,
8,
1746,
304,
339,
408,
12008,
2295,
367,
314,
14547,
63,
4471,
63,
12446,
2393,
14,
647,
859,
408,
339,
347,
3613,
8,
277,
304,
267,
327,
1218,
314,
7937,
1324,
1584,
626,
911,
506,
1202,
398,
291,
423,
1725,
63,
475,
63,
2168,
275,
942,
398,
291,
14,
3271,
63,
20309,
63,
493,
17,
63,
576,
275,
2690,
63,
20309,
63,
493,
17,
267,
291,
14,
3271,
63,
20309,
63,
493,
63,
4087,
63,
3512,
63,
576,
26447,
288,
2690,
63,
20309,
63,
493,
63,
4087,
63,
3512,
398,
291,
14,
3271,
63,
4745,
63,
493,
17,
63,
576,
275,
2690,
63,
4745,
63,
493,
17,
267,
291,
14,
3271,
63,
4745,
63,
493,
63,
889,
63,
4964,
1359,
2626,
63,
1291,
26447,
288,
2690,
63,
4745,
63,
493,
63,
889,
63,
4964,
1359,
2626,
63,
1291,
267,
291,
14,
3271,
63,
4745,
63,
493,
63,
4087,
63,
4964,
1359,
2626,
26447,
288,
2690,
63,
4745,
63,
493,
63,
4087,
63,
4964,
1359,
2626,
267,
291,
14,
2062,
63,
454,
324,
1063,
63,
885,
63,
1751,
26447,
288,
1420,
63,
454,
324,
1063,
63,
885,
63,
1751,
267,
291,
14,
2062,
63,
454,
324,
1063,
63,
4262,
63,
1292,
6742,
26447,
288,
1420,
63,
454,
324,
1063,
63,
4262,
63,
1292,
6742,
267,
291,
14,
2062,
63,
454,
324,
1063,
63,
4262,
63,
1292,
6742,
63,
12517,
63,
2168,
26447,
288,
1420,
63,
454,
324,
1063,
63,
4262,
63,
1292,
6742,
63,
12517,
63,
2168,
398,
6111,
12,
291,
14,
20309,
63,
3997,
275,
333,
6080,
808,
8,
1861,
534,
20309,
63,
19467,
14474,
2511,
4739,
15637,
2324,
65,
358,
267,
4002,
8,
2592,
9,
267,
5412,
63,
493,
275,
1551,
8,
277,
14,
20309,
63,
3997,
12,
283,
87,
358,
267,
5412,
63,
493,
14,
952,
8,
277,
14,
3271,
63,
20309,
63,
493,
17,
63,
576,
9,
267,
5412,
63,
493,
14,
1600,
342,
398,
6111,
12,
291,
14,
20309,
63,
4087,
3512,
63,
3997,
275,
333,
6080,
808,
8,
1861,
628,
20309,
63,
19467,
63,
4087,
3512,
29808,
6343,
4739,
25356,
2324,
65,
531,
267,
4002,
8,
2592,
9,
267,
5412,
63,
493,
275,
1551,
8,
277,
14,
20309,
63,
4087,
3512,
63,
3997,
12,
298,
87,
531,
267,
5412,
63,
493,
14,
952,
8,
277,
14,
3271,
63,
20309,
63,
493,
63,
4087,
63,
3512,
63,
576,
9,
267,
5412,
63,
493,
14,
1600,
342,
398,
6111,
12,
291,
14,
4745,
63,
3997,
275,
333,
6080,
808,
8,
1861,
534,
3271,
63,
4745,
14474,
4228,
4739,
15637,
2424,
358,
267,
4002,
8,
2592,
9,
267,
4412,
63,
493,
275,
1551,
8,
277,
14,
4745,
63,
3997,
12,
298,
87,
531,
267,
4412,
63,
493,
14,
952,
8,
277,
14,
3271,
63,
4745,
63,
493,
17,
63,
576,
9,
267,
4412,
63,
493,
14,
1600,
342,
398,
6111,
12,
291,
14,
4745,
63,
4087,
63,
1291,
63,
3997,
275,
333,
6080,
808,
8,
3147,
2403,
534,
3271,
63,
4745,
63,
4087,
1291,
14474,
3147,
4739,
25356,
2424,
531,
267,
4002,
8,
2592,
9,
267,
4412,
63,
493,
275,
1551,
8,
277,
14,
4745,
63,
4087,
63,
1291,
63,
3997,
12,
298,
87,
531,
267,
4412,
63,
493,
14,
952,
8,
277,
14,
3271,
63,
4745,
63,
493,
63,
889,
63,
4964,
1359,
2626,
63,
1291,
9,
267,
4412,
63,
493,
14,
1600,
342,
398,
6111,
12,
291,
14,
4745,
63,
4087,
63,
1359,
2626,
63,
3997,
275,
333,
6080,
808,
8,
3147,
2403,
534,
3271,
63,
4745,
63,
4087,
1359,
2626,
14474,
3147,
4739,
25356,
2424,
531,
267,
4002,
8,
2592,
9,
267,
4412,
63,
493,
275,
1551,
8,
277,
14,
4745,
63,
4087,
63,
1359,
2626,
63,
3997,
12,
298,
87,
531,
267,
4412,
63,
493,
14,
952,
8,
277,
14,
3271,
63,
4745,
63,
493,
63,
4087,
63,
4964,
1359,
2626,
9,
267,
4412,
63,
493,
14,
1600,
342,
398,
291,
14,
1199,
63,
694,
275,
31781,
342,
267,
291,
14,
1199,
63,
694,
847,
7324,
398,
1218,
63,
694,
8,
277,
14,
1199,
63,
694,
9,
398,
291,
423,
1725,
63,
475,
63,
2168,
26447,
288,
359,
277,
14,
20309,
63,
3997,
12,
291,
14,
4745,
63,
3997,
12,
291,
14,
4745,
63,
4087,
63,
1291,
63,
3997,
12,
1467,
291,
14,
4745,
63,
4087,
63,
1359,
2626,
63,
3997,
12,
291,
14,
20309,
63,
4087,
3512,
63,
3997,
61,
339,
347,
6766,
8,
277,
304,
267,
340,
291,
423,
1725,
63,
475,
63,
2168,
26,
288,
2813,
63
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
3,
3814,
2737,
21141,
26709,
7349,
12,
6029,
199,
504,
636,
2443,
363,
492,
4629,
199,
199,
363,
2502,
363,
275,
298,
55,
8148,
455,
644,
31185,
2,
199,
363,
7307,
363,
275,
298,
7384,
7760,
12,
710,
1413,
41,
3465,
7290,
2,
199,
363,
22461,
363,
275,
2097,
55,
8148,
455,
644,
31185,
937,
199,
363,
1682,
363,
275,
298,
12006,
2,
199,
363,
1023,
363,
275,
298,
17,
14,
25,
14,
17,
13,
2374,
2,
199,
363,
26665,
363,
275,
298,
55,
8148,
455,
644,
31185,
2,
199,
363,
2123,
363,
275,
298,
55,
8148,
455,
14,
33,
14,
55,
31185,
32,
2326,
5129,
14,
8654,
2,
199,
199,
504,
747,
14,
515,
492,
3495,
12,
4263,
12,
9593,
199,
504,
747,
492,
4002,
199,
504,
5145,
492,
20978,
199,
504,
5549,
492,
31781,
12,
333,
6080,
808,
199,
199,
504,
2882,
492,
7640,
12,
2446,
199,
504,
31402,
1036,
14,
1974,
492,
1218,
63,
694,
199,
504,
11448,
2308,
14,
1974,
492,
2813,
63,
1725,
199,
199,
504,
31402,
1036,
14,
12517,
63,
4471,
63,
1359,
2626,
492,
664,
63,
4964,
63,
1359,
2626,
63,
19467,
4202,
272,
664,
63,
1199,
63,
493,
3771,
12,
14547,
63,
4964,
63,
12446,
2393,
12,
14547,
63,
4471,
63,
1359,
2626,
199,
199,
504,
11448,
2308,
14,
4041,
492,
699,
2308,
7954,
5826,
547,
199,
199,
533,
7777,
2204,
1173,
8,
785,
304,
339,
347,
636,
826,
721,
277,
304,
267,
291,
14,
576,
275,
3087,
339,
347,
2218,
8,
277,
12,
308,
304,
267,
291,
14,
576,
847,
308,
421,
199,
533,
25594,
1411,
5587,
14987,
4562,
2626,
2925,
8,
1746,
304,
339,
408,
12008,
2295,
367,
314,
14547,
63,
4471,
63,
12446,
2393,
14,
647,
859,
408,
339,
347,
3613,
8,
277,
304,
267,
327,
1218,
314,
7937,
1324,
1584,
626,
911,
506,
1202,
398,
291,
423,
1725,
63,
475,
63,
2168,
275,
942,
398,
291,
14,
3271,
63,
20309,
63,
493,
17,
63,
576,
275,
2690,
63,
20309,
63,
493,
17,
267,
291,
14,
3271,
63,
20309,
63,
493,
63,
4087,
63,
3512,
63,
576,
26447,
288,
2690,
63,
20309,
63,
493,
63,
4087,
63,
3512,
398,
291,
14,
3271,
63,
4745,
63,
493,
17,
63,
576,
275,
2690,
63,
4745,
63,
493,
17,
267,
291,
14,
3271,
63,
4745,
63,
493,
63,
889,
63,
4964,
1359,
2626,
63,
1291,
26447,
288,
2690,
63,
4745,
63,
493,
63,
889,
63,
4964,
1359,
2626,
63,
1291,
267,
291,
14,
3271,
63,
4745,
63,
493,
63,
4087,
63,
4964,
1359,
2626,
26447,
288,
2690,
63,
4745,
63,
493,
63,
4087,
63,
4964,
1359,
2626,
267,
291,
14,
2062,
63,
454,
324,
1063,
63,
885,
63,
1751,
26447,
288,
1420,
63,
454,
324,
1063,
63,
885,
63,
1751,
267,
291,
14,
2062,
63,
454,
324,
1063,
63,
4262,
63,
1292,
6742,
26447,
288,
1420,
63,
454,
324,
1063,
63,
4262,
63,
1292,
6742,
267,
291,
14,
2062,
63,
454,
324,
1063,
63,
4262,
63,
1292,
6742,
63,
12517,
63,
2168,
26447,
288,
1420,
63,
454,
324,
1063,
63,
4262,
63,
1292,
6742,
63,
12517,
63,
2168,
398,
6111,
12,
291,
14,
20309,
63,
3997,
275,
333,
6080,
808,
8,
1861,
534,
20309,
63,
19467,
14474,
2511,
4739,
15637,
2324,
65,
358,
267,
4002,
8,
2592,
9,
267,
5412,
63,
493,
275,
1551,
8,
277,
14,
20309,
63,
3997,
12,
283,
87,
358,
267,
5412,
63,
493,
14,
952,
8,
277,
14,
3271,
63,
20309,
63,
493,
17,
63,
576,
9,
267,
5412,
63,
493,
14,
1600,
342,
398,
6111,
12,
291,
14,
20309,
63,
4087,
3512,
63,
3997,
275,
333,
6080,
808,
8,
1861,
628,
20309,
63,
19467,
63,
4087,
3512,
29808,
6343,
4739,
25356,
2324,
65,
531,
267,
4002,
8,
2592,
9,
267,
5412,
63,
493,
275,
1551,
8,
277,
14,
20309,
63,
4087,
3512,
63,
3997,
12,
298,
87,
531,
267,
5412,
63,
493,
14,
952,
8,
277,
14,
3271,
63,
20309,
63,
493,
63,
4087,
63,
3512,
63,
576,
9,
267,
5412,
63,
493,
14,
1600,
342,
398,
6111,
12,
291,
14,
4745,
63,
3997,
275,
333,
6080,
808,
8,
1861,
534,
3271,
63,
4745,
14474,
4228,
4739,
15637,
2424,
358,
267,
4002,
8,
2592,
9,
267,
4412,
63,
493,
275,
1551,
8,
277,
14,
4745,
63,
3997,
12,
298,
87,
531,
267,
4412,
63,
493,
14,
952,
8,
277,
14,
3271,
63,
4745,
63,
493,
17,
63,
576,
9,
267,
4412,
63,
493,
14,
1600,
342,
398,
6111,
12,
291,
14,
4745,
63,
4087,
63,
1291,
63,
3997,
275,
333,
6080,
808,
8,
3147,
2403,
534,
3271,
63,
4745,
63,
4087,
1291,
14474,
3147,
4739,
25356,
2424,
531,
267,
4002,
8,
2592,
9,
267,
4412,
63,
493,
275,
1551,
8,
277,
14,
4745,
63,
4087,
63,
1291,
63,
3997,
12,
298,
87,
531,
267,
4412,
63,
493,
14,
952,
8,
277,
14,
3271,
63,
4745,
63,
493,
63,
889,
63,
4964,
1359,
2626,
63,
1291,
9,
267,
4412,
63,
493,
14,
1600,
342,
398,
6111,
12,
291,
14,
4745,
63,
4087,
63,
1359,
2626,
63,
3997,
275,
333,
6080,
808,
8,
3147,
2403,
534,
3271,
63,
4745,
63,
4087,
1359,
2626,
14474,
3147,
4739,
25356,
2424,
531,
267,
4002,
8,
2592,
9,
267,
4412,
63,
493,
275,
1551,
8,
277,
14,
4745,
63,
4087,
63,
1359,
2626,
63,
3997,
12,
298,
87,
531,
267,
4412,
63,
493,
14,
952,
8,
277,
14,
3271,
63,
4745,
63,
493,
63,
4087,
63,
4964,
1359,
2626,
9,
267,
4412,
63,
493,
14,
1600,
342,
398,
291,
14,
1199,
63,
694,
275,
31781,
342,
267,
291,
14,
1199,
63,
694,
847,
7324,
398,
1218,
63,
694,
8,
277,
14,
1199,
63,
694,
9,
398,
291,
423,
1725,
63,
475,
63,
2168,
26447,
288,
359,
277,
14,
20309,
63,
3997,
12,
291,
14,
4745,
63,
3997,
12,
291,
14,
4745,
63,
4087,
63,
1291,
63,
3997,
12,
1467,
291,
14,
4745,
63,
4087,
63,
1359,
2626,
63,
3997,
12,
291,
14,
20309,
63,
4087,
3512,
63,
3997,
61,
339,
347,
6766,
8,
277,
304,
267,
340,
291,
423,
1725,
63,
475,
63,
2168,
26,
288,
2813,
63,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
rubenvereecken/pokemongo-api
|
POGOProtos/Enums/CameraInterpolation_pb2.py
|
16
|
2450
|
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: POGOProtos/Enums/CameraInterpolation.proto
import sys
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
from google.protobuf.internal import enum_type_wrapper
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message
from google.protobuf import reflection as _reflection
from google.protobuf import symbol_database as _symbol_database
from google.protobuf import descriptor_pb2
# @@protoc_insertion_point(imports)
_sym_db = _symbol_database.Default()
DESCRIPTOR = _descriptor.FileDescriptor(
name='POGOProtos/Enums/CameraInterpolation.proto',
package='POGOProtos.Enums',
syntax='proto3',
serialized_pb=_b('\n*POGOProtos/Enums/CameraInterpolation.proto\x12\x10POGOProtos.Enums*\x96\x01\n\x13\x43\x61meraInterpolation\x12\x12\n\x0e\x43\x41M_INTERP_CUT\x10\x00\x12\x15\n\x11\x43\x41M_INTERP_LINEAR\x10\x01\x12\x15\n\x11\x43\x41M_INTERP_SMOOTH\x10\x02\x12%\n!CAM_INTERP_SMOOTH_ROT_LINEAR_MOVE\x10\x03\x12\x16\n\x12\x43\x41M_INTERP_DEPENDS\x10\x04\x62\x06proto3')
)
_sym_db.RegisterFileDescriptor(DESCRIPTOR)
_CAMERAINTERPOLATION = _descriptor.EnumDescriptor(
name='CameraInterpolation',
full_name='POGOProtos.Enums.CameraInterpolation',
filename=None,
file=DESCRIPTOR,
values=[
_descriptor.EnumValueDescriptor(
name='CAM_INTERP_CUT', index=0, number=0,
options=None,
type=None),
_descriptor.EnumValueDescriptor(
name='CAM_INTERP_LINEAR', index=1, number=1,
options=None,
type=None),
_descriptor.EnumValueDescriptor(
name='CAM_INTERP_SMOOTH', index=2, number=2,
options=None,
type=None),
_descriptor.EnumValueDescriptor(
name='CAM_INTERP_SMOOTH_ROT_LINEAR_MOVE', index=3, number=3,
options=None,
type=None),
_descriptor.EnumValueDescriptor(
name='CAM_INTERP_DEPENDS', index=4, number=4,
options=None,
type=None),
],
containing_type=None,
options=None,
serialized_start=65,
serialized_end=215,
)
_sym_db.RegisterEnumDescriptor(_CAMERAINTERPOLATION)
CameraInterpolation = enum_type_wrapper.EnumTypeWrapper(_CAMERAINTERPOLATION)
CAM_INTERP_CUT = 0
CAM_INTERP_LINEAR = 1
CAM_INTERP_SMOOTH = 2
CAM_INTERP_SMOOTH_ROT_LINEAR_MOVE = 3
CAM_INTERP_DEPENDS = 4
DESCRIPTOR.enum_types_by_name['CameraInterpolation'] = _CAMERAINTERPOLATION
# @@protoc_insertion_point(module_scope)
|
mit
|
[
3,
17065,
701,
314,
4113,
3335,
6365,
14,
221,
3506,
2845,
24981,
1,
199,
3,
1350,
26,
3625,
23114,
15,
5081,
83,
15,
18425,
32653,
14,
2625,
199,
199,
646,
984,
199,
63,
66,
29,
1274,
14,
1023,
63,
815,
59,
16,
61,
28,
19,
436,
334,
2734,
671,
26,
88,
9,
503,
334,
2734,
671,
26,
88,
14,
2143,
360,
10378,
17,
1333,
199,
504,
6233,
14,
7204,
14,
4672,
492,
4952,
63,
466,
63,
5029,
199,
504,
6233,
14,
7204,
492,
5872,
465,
485,
4120,
199,
504,
6233,
14,
7204,
492,
1245,
465,
485,
1188,
199,
504,
6233,
14,
7204,
492,
25572,
465,
485,
14906,
199,
504,
6233,
14,
7204,
492,
5272,
63,
4659,
465,
485,
5155,
63,
4659,
199,
504,
6233,
14,
7204,
492,
5872,
63,
3317,
18,
199,
3,
13365,
16311,
63,
14739,
63,
1403,
8,
12775,
9,
199,
199,
63,
3840,
63,
697,
275,
485,
5155,
63,
4659,
14,
2698,
342,
6905,
199,
7580,
275,
485,
4120,
14,
23859,
8,
523,
536,
534,
26676,
15,
5081,
83,
15,
18425,
32653,
14,
2625,
297,
523,
2559,
534,
26676,
14,
5081,
83,
297,
523,
6302,
534,
2625,
19,
297,
523,
6380,
63,
3317,
3699,
66,
2258,
78,
10,
26676,
15,
5081,
83,
15,
18425,
32653,
14,
2625,
60,
88,
713,
60,
88,
709,
26676,
14,
5081,
83,
7590,
88,
2534,
60,
88,
614,
60,
78,
60,
88,
969,
60,
88,
2824,
60,
88,
2976,
278,
345,
32653,
60,
88,
713,
60,
88,
713,
60,
78,
60,
88,
16,
69,
60,
88,
2824,
60,
88,
2953,
45,
63,
3843,
48,
63,
24678,
60,
88,
709,
60,
88,
383,
60,
88,
713,
60,
88,
1046,
60,
78,
60,
88,
845,
60,
88,
2824,
60,
88,
2953,
45,
63,
3843,
48,
63,
6174,
689,
60,
88,
709,
60,
88,
614,
60,
88,
713,
60,
88,
1046,
60,
78,
60,
88,
845,
60,
88,
2824,
60,
88,
2953,
45,
63,
3843,
48,
63,
51,
2679,
22949,
60,
88,
709,
60,
88,
996,
60,
88,
713,
27744,
78,
1,
29932,
63,
3843,
48,
63,
51,
2679,
22949,
63,
31075,
63,
6174,
689,
63,
16207,
60,
88,
709,
60,
88,
1644,
60,
88,
713,
60,
88,
975,
60,
78,
60,
88,
713,
60,
88,
2824,
60,
88,
2953,
45,
63,
3843,
48,
63,
10814,
20853,
60,
88,
709,
60,
88,
966,
60,
88,
2789,
60,
88,
1690,
2625,
19,
358,
199,
9,
199,
63,
3840,
63,
697,
14,
7099,
23859,
8,
7580,
9,
199,
199,
63,
29932,
540,
33,
3843,
32713,
2594,
275,
485,
4120,
14,
5081,
4311,
8,
523,
536,
534,
18425,
32653,
297,
523,
2615,
63,
354,
534,
26676,
14,
5081,
83,
14,
18425,
32653,
297,
523,
1788,
29,
403,
12,
523,
570,
29,
7580,
12,
523,
1338,
1524,
272,
485,
4120,
14,
19629,
8,
489,
536,
534,
29932,
63,
3843,
48,
63,
24678,
297,
1478,
29,
16,
12,
1329,
29,
16,
12,
489,
1511,
29,
403,
12,
489,
730,
29,
403,
395,
272,
485,
4120,
14,
19629,
8,
489,
536,
534,
29932,
63,
3843,
48,
63,
6174,
689,
297,
1478,
29,
17,
12,
1329,
29,
17,
12,
489,
1511,
29,
403,
12,
489,
730,
29,
403,
395,
272,
485,
4120,
14,
19629,
8,
489,
536,
534,
29932,
63,
3843,
48,
63,
51,
2679,
22949,
297,
1478,
29,
18,
12,
1329,
29,
18,
12,
489,
1511,
29,
403,
12,
489,
730,
29,
403,
395,
272,
485,
4120,
14,
19629,
8,
489,
536,
534,
29932,
63,
3843,
48,
63,
51,
2679,
22949,
63,
31075,
63,
6174,
689,
63,
16207,
297,
1478,
29,
19,
12,
1329,
29,
19,
12,
489,
1511,
29,
403,
12,
489,
730,
29,
403,
395,
272,
485,
4120,
14,
19629,
8,
489,
536,
534,
29932,
63,
3843,
48,
63,
10814,
20853,
297,
1478,
29,
20,
12,
1329,
29,
20,
12,
489,
1511,
29,
403,
12,
489,
730,
29,
403,
395,
523,
2156,
523,
3035,
63,
466,
29,
403,
12,
523,
1511,
29,
403,
12,
523,
6380,
63,
928,
29,
2182,
12,
523,
6380,
63,
500,
29,
7842,
12,
199,
9,
199,
63,
3840,
63,
697,
14,
7099,
5081,
4311,
1547,
29932,
540,
33,
3843,
32713,
2594,
9,
199,
199,
18425,
32653,
275,
4952,
63,
466,
63,
5029,
14,
5081,
804,
4590,
1547,
29932,
540,
33,
3843,
32713,
2594,
9,
199,
29932,
63,
3843,
48,
63,
24678,
275,
378,
199,
29932,
63,
3843,
48,
63,
6174,
689,
275,
413,
199,
29932,
63,
3843,
48,
63,
51,
2679,
22949,
275,
499,
199,
29932,
63,
3843,
48,
63,
51,
2679,
22949,
63,
31075,
63,
6174,
689,
63,
16207,
275,
650,
199,
29932,
63,
3843,
48,
63,
10814,
20853,
275,
841,
421,
199,
7580,
14,
4869,
63,
1313,
63,
991,
63,
354,
459,
18425,
32653,
418,
275,
485,
29932,
540,
33,
3843,
32713,
2594,
421,
199,
3,
13365,
16311,
63,
14739,
63,
1403,
8,
578,
63,
2645,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
17065,
701,
314,
4113,
3335,
6365,
14,
221,
3506,
2845,
24981,
1,
199,
3,
1350,
26,
3625,
23114,
15,
5081,
83,
15,
18425,
32653,
14,
2625,
199,
199,
646,
984,
199,
63,
66,
29,
1274,
14,
1023,
63,
815,
59,
16,
61,
28,
19,
436,
334,
2734,
671,
26,
88,
9,
503,
334,
2734,
671,
26,
88,
14,
2143,
360,
10378,
17,
1333,
199,
504,
6233,
14,
7204,
14,
4672,
492,
4952,
63,
466,
63,
5029,
199,
504,
6233,
14,
7204,
492,
5872,
465,
485,
4120,
199,
504,
6233,
14,
7204,
492,
1245,
465,
485,
1188,
199,
504,
6233,
14,
7204,
492,
25572,
465,
485,
14906,
199,
504,
6233,
14,
7204,
492,
5272,
63,
4659,
465,
485,
5155,
63,
4659,
199,
504,
6233,
14,
7204,
492,
5872,
63,
3317,
18,
199,
3,
13365,
16311,
63,
14739,
63,
1403,
8,
12775,
9,
199,
199,
63,
3840,
63,
697,
275,
485,
5155,
63,
4659,
14,
2698,
342,
6905,
199,
7580,
275,
485,
4120,
14,
23859,
8,
523,
536,
534,
26676,
15,
5081,
83,
15,
18425,
32653,
14,
2625,
297,
523,
2559,
534,
26676,
14,
5081,
83,
297,
523,
6302,
534,
2625,
19,
297,
523,
6380,
63,
3317,
3699,
66,
2258,
78,
10,
26676,
15,
5081,
83,
15,
18425,
32653,
14,
2625,
60,
88,
713,
60,
88,
709,
26676,
14,
5081,
83,
7590,
88,
2534,
60,
88,
614,
60,
78,
60,
88,
969,
60,
88,
2824,
60,
88,
2976,
278,
345,
32653,
60,
88,
713,
60,
88,
713,
60,
78,
60,
88,
16,
69,
60,
88,
2824,
60,
88,
2953,
45,
63,
3843,
48,
63,
24678,
60,
88,
709,
60,
88,
383,
60,
88,
713,
60,
88,
1046,
60,
78,
60,
88,
845,
60,
88,
2824,
60,
88,
2953,
45,
63,
3843,
48,
63,
6174,
689,
60,
88,
709,
60,
88,
614,
60,
88,
713,
60,
88,
1046,
60,
78,
60,
88,
845,
60,
88,
2824,
60,
88,
2953,
45,
63,
3843,
48,
63,
51,
2679,
22949,
60,
88,
709,
60,
88,
996,
60,
88,
713,
27744,
78,
1,
29932,
63,
3843,
48,
63,
51,
2679,
22949,
63,
31075,
63,
6174,
689,
63,
16207,
60,
88,
709,
60,
88,
1644,
60,
88,
713,
60,
88,
975,
60,
78,
60,
88,
713,
60,
88,
2824,
60,
88,
2953,
45,
63,
3843,
48,
63,
10814,
20853,
60,
88,
709,
60,
88,
966,
60,
88,
2789,
60,
88,
1690,
2625,
19,
358,
199,
9,
199,
63,
3840,
63,
697,
14,
7099,
23859,
8,
7580,
9,
199,
199,
63,
29932,
540,
33,
3843,
32713,
2594,
275,
485,
4120,
14,
5081,
4311,
8,
523,
536,
534,
18425,
32653,
297,
523,
2615,
63,
354,
534,
26676,
14,
5081,
83,
14,
18425,
32653,
297,
523,
1788,
29,
403,
12,
523,
570,
29,
7580,
12,
523,
1338,
1524,
272,
485,
4120,
14,
19629,
8,
489,
536,
534,
29932,
63,
3843,
48,
63,
24678,
297,
1478,
29,
16,
12,
1329,
29,
16,
12,
489,
1511,
29,
403,
12,
489,
730,
29,
403,
395,
272,
485,
4120,
14,
19629,
8,
489,
536,
534,
29932,
63,
3843,
48,
63,
6174,
689,
297,
1478,
29,
17,
12,
1329,
29,
17,
12,
489,
1511,
29,
403,
12,
489,
730,
29,
403,
395,
272,
485,
4120,
14,
19629,
8,
489,
536,
534,
29932,
63,
3843,
48,
63,
51,
2679,
22949,
297,
1478,
29,
18,
12,
1329,
29,
18,
12,
489,
1511,
29,
403,
12,
489,
730,
29,
403,
395,
272,
485,
4120,
14,
19629,
8,
489,
536,
534,
29932,
63,
3843,
48,
63,
51,
2679,
22949,
63,
31075,
63,
6174,
689,
63,
16207,
297,
1478,
29,
19,
12,
1329,
29,
19,
12,
489,
1511,
29,
403,
12,
489,
730,
29,
403,
395,
272,
485,
4120,
14,
19629,
8,
489,
536,
534,
29932,
63,
3843,
48,
63,
10814,
20853,
297,
1478,
29,
20,
12,
1329,
29,
20,
12,
489,
1511,
29,
403,
12,
489,
730,
29,
403,
395,
523,
2156,
523,
3035,
63,
466,
29,
403,
12,
523,
1511,
29,
403,
12,
523,
6380,
63,
928,
29,
2182,
12,
523,
6380,
63,
500,
29,
7842,
12,
199,
9,
199,
63,
3840,
63,
697,
14,
7099,
5081,
4311,
1547,
29932,
540,
33,
3843,
32713,
2594,
9,
199,
199,
18425,
32653,
275,
4952,
63,
466,
63,
5029,
14,
5081,
804,
4590,
1547,
29932,
540,
33,
3843,
32713,
2594,
9,
199,
29932,
63,
3843,
48,
63,
24678,
275,
378,
199,
29932,
63,
3843,
48,
63,
6174,
689,
275,
413,
199,
29932,
63,
3843,
48,
63,
51,
2679,
22949,
275,
499,
199,
29932,
63,
3843,
48,
63,
51,
2679,
22949,
63,
31075,
63,
6174,
689,
63,
16207,
275,
650,
199,
29932,
63,
3843,
48,
63,
10814,
20853,
275,
841,
421,
199,
7580,
14,
4869,
63,
1313,
63,
991,
63,
354,
459,
18425,
32653,
418,
275,
485,
29932,
540,
33,
3843,
32713,
2594,
421,
199,
3,
13365,
16311,
63,
14739,
63,
1403,
8,
578,
63,
2645,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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