def get_max_client(self): registry = queryUtility(IRegistry) maxui_settings = registry.forInterface(IMAXUISettings, check=False) maxclient = MaxClient(maxui_settings.max_server, maxui_settings.oauth_server) maxclient.setActor(maxui_settings.max_restricted_username) maxclient.setToken(maxui_settings.max_restricted_token) return maxclient
def run(self): print("") print(" Welcome, You're about to add a new max instance to {}.".format(self.options.instancesfile)) print(" Please tell me:") print("") valid_new_section = False max_name = None while not valid_new_section: if max_name is not None: max_name = raw_input(" > Ooops!, there is already an instance with this name, try again:") else: max_name = raw_input(" > The name of the max instance (same as domain): ") new_section_name = max_name valid_new_section = not self.instances.has_section(new_section_name) precalculated_max_server = '{}/{}'.format(self.common.get('max', 'server'), max_name) max_server = raw_input(" > The base url of the max server [{}]: ".format(precalculated_max_server)) if not max_server: max_server = precalculated_max_server precalculated_oauth_server = '{}/{}'.format(self.common.get('oauth', 'server'), max_name) max_oauth_server = raw_input(" > The base url of the oauth server [{}]: ".format(precalculated_oauth_server)) if not max_oauth_server: max_oauth_server = precalculated_oauth_server max_hashtag = raw_input(" > The hashtag to track on twitter (without #): ") language = raw_input(" > The language used in push notification literals [ca]: ") if not language: language = 'ca' max_user = raw_input(" > The restricted user: "******" > ") sys.stdout.flush() max_token = max_client.login(max_user) self.instances.add_section(new_section_name) self.instances.set(new_section_name, 'hashtag', max_hashtag) self.instances.set(new_section_name, 'server', max_server) self.instances.set(new_section_name, 'oauth_server', max_oauth_server) self.instances.set(new_section_name, 'restricted_user', max_user) self.instances.set(new_section_name, 'restricted_user_token', max_token) self.instances.set(new_section_name, 'language', language) self.instances.write(open(self.options.instancesfile, 'w')) print("") print(" Changes written to {}".format(self.options.instancesfile)) print("")
def __init__(self): conf_dir = os.path.dirname(__file__) self.restricted_username = '******' self.restricted_token = 'uj5v4XrWMxGP25CN3pAE39mYCL7cwBMV' self.config = ConfigParser.ConfigParser() self.config.read(os.path.join(conf_dir, "maxbunny.ini")) self.maxservers_settings = [maxserver for maxserver in self.config.sections() if maxserver.startswith('max_')] # Instantiate a maxclient for each maxserver self.maxclients = {} for maxserver in self.maxservers_settings: maxclient = MaxClient(url=self.config.get(maxserver, 'server'), oauth_server=self.config.get(maxserver, 'oauth_server')) maxclient.setActor(self.restricted_username) maxclient.setToken(self.restricted_token) self.maxclients[maxserver] = maxclient self.ios_session = Session()
class Connector(object): """ Provides API methods for accessing LDAP authentication information.""" def __init__(self, registry, oauth_server, legacy_mode): self.registry = registry self.oauth_server = oauth_server self.legacy_mode = legacy_mode self.client = MaxClient(oauth_server=self.oauth_server) def authenticate(self, login, password): """ Given a username and a password, try to autheticate against Osiris server. """ try: token = self.client.getToken(login, password) return [login, token] except AttributeError: return None
def __init__(self, registry, oauth_server, legacy_mode): self.registry = registry self.oauth_server = oauth_server self.legacy_mode = legacy_mode self.client = MaxClient(oauth_server=self.oauth_server)
from maxclient import MaxClient import threading import json import time import datetime from random import choice, randint # server = 'capricornius2.upc.es' # server = 'max.beta.upcnet.es' server = 'http://147.83.193.90' max = MaxClient(server) # Afegim 30000 usuaris numUsuaris = 3000 numActivitat = 10000 ALLOWED_CHARACTERS = 'abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ0123456789' MESSAGE_LENGTH = 140 class creaUsuaris(threading.Thread): def __init__(self, numUsuaris): self.numUsuaris = numUsuaris threading.Thread.__init__(self) def run(self): for usuari in range(self.numUsuaris): print "Creant usuari %s" % str(usuari) max.addUser('usuari' + str(usuari))