several minor fixes

This commit is contained in:
Romain Bignon 2010-11-11 21:04:34 +01:00
commit 1fce063052

View file

@ -37,7 +37,7 @@ __all__ = ['PriorityConnection']
class PriorityConnection(Optimization): class PriorityConnection(Optimization):
CONFIG = ValuesDict(ValueInt('minimal', label='Minimal of godchilds', default=5), CONFIG = ValuesDict(ValueInt('minimal', label='Minimal of godchilds', default=5),
Value('domain', label='Domain to use for fake accounts emails', default='aum.example.com'), Value('domain', label='Domain to use for fake accounts emails', default='aum.example.com'),
Value('interval', label='Interval of checks (seconds)', default=3600) ValueInt('interval', label='Interval of checks (seconds)', default=3600)
) )
def __init__(self, sched, storage, browser): def __init__(self, sched, storage, browser):
@ -110,7 +110,7 @@ class PriorityConnection(Optimization):
# We'll check later # We'll check later
return return
missing_godchilds = self.config['minimal'] - nb_godchilds missing_godchilds = int(self.config['minimal']) - nb_godchilds
if missing_godchilds <= 0: if missing_godchilds <= 0:
return return
@ -128,7 +128,7 @@ class PriorityConnection(Optimization):
sex= 1, #slut sex= 1, #slut
birthday_d= random.randint(1,28), birthday_d= random.randint(1,28),
birthday_m= random.randint(1,12), birthday_m= random.randint(1,12),
birthday_y= random.randint(1970, 1990), birthday_y= random.randint(1975, 1990),
zipcode= 75001, zipcode= 75001,
country= 'fr', country= 'fr',
godfather= my_id) godfather= my_id)
@ -153,25 +153,31 @@ class PriorityConnection(Optimization):
self.logger.info('Fake account "%s" created (godfather=%s)' % (name, my_id)) self.logger.info('Fake account "%s" created (godfather=%s)' % (name, my_id))
def activity_fakes(self): def activity_fakes(self):
fakes = self.storage.get('priority_connection', 'fakes', default={}) try:
while 1: fakes = self.storage.get('priority_connection', 'fakes', default={})
name = random.choice(fakes.keys()) if len(fakes) == 0:
fake = fakes[name] return
try: while 1:
browser = AuMBrowser(fake['username'], fake['password'], proxy=self.browser.proxy) name = random.choice(fakes.keys())
except (AdopteBanned,BrowserIncorrectPassword), e: fake = fakes[name]
self.warning('Fake %s can\'t login: %s' % (name, e)) try:
continue browser = AuMBrowser(fake['username'], fake['password'], proxy=self.browser.proxy)
except (AdopteBanned,BrowserIncorrectPassword), e:
self.warning('Fake %s can\'t login: %s' % (name, e))
continue
profiles = browser.search_profiles(country="fr", profiles = browser.search_profiles(country="fr",
dist='10', dist='10',
save=True) save=True)
id = profiles.pop() id = profiles.pop()
profile = browser.get_profile(id) profile = browser.get_profile(id)
# bad rate # bad rate
for i in xrange(4): for i in xrange(4):
browser.rate(profile.get_id(), i, 0.6) browser.rate(profile.get_id(), i, 0.6)
# deblock # deblock
browser.deblock(profile.get_id()) browser.deblock(profile.get_id())
return return
except BrowserUnavailable:
# don't care
pass