class Chat_window(object):
    """ Chat window """
    def __init__(self, frame):
        self.frame = Frame(frame)
        self.frame.pack()
        self.agent = Agent()
        self.login = Login(self)
        self.logout = None
        self.chat = None

    def init_chat(self, ):
        """ Initializes a chat widgets after login """
        self.chat = Chat(self)

    def login_agent(self, firstname, lastname, password, start_location):
        self.agent.login("https://login.agni.lindenlab.com/cgi-bin/login.cgi",
                         firstname=firstname,
                         lastname=lastname,
                         password=password,
                         start_location=start_location,
                         connect_region=True)
        while self.agent.connected == False:
            api.sleep(0)
        while self.agent.region.connected == False:
            api.sleep(0)
        while connected:
            api.sleep(0)

    def tear_down(self):
        """ Tears down chat widgets and logout widget after logout """
        self.chat.frame.pack_forget()
 def __init__(self, frame):
     self.frame = Frame(frame)
     self.frame.pack()
     self.agent = Agent()
     self.login = Login(self)
     self.logout = None
     self.chat = None
Exemple #3
0
    def setUp(self):

        self.legacy_loginuri = 'http://localhost:12345/cgi-bin/login.cgi'
        self.ogp_loginuri = 'http://localhost:12345/auth.cgi'
        self.firstname = 'firstname'
        self.lastname = 'lastname'
        self.password = '******'

        self.client = Agent()
Exemple #4
0
 def setUp(self):
     self.settings = Settings()
     self.agent = Agent()
     self.appearance = AppearanceManager(self.agent, settings=self.settings)
     self.agent.agent_id = UUID("01234567-89ab-cdef-0123-456789abcdef")
     self.agent.session_id = UUID("fedcba98-7654-3210-fedc-ba9876543210")
     self.agent.region = DummyRegion()
def login():
    """ login an to a login endpoint """ 

    parser = OptionParser(usage="usage: %prog [options] firstname lastname")

    logger = logging.getLogger("client.example")

    parser.add_option("-l", "--loginuri", dest="loginuri", default="https://login.aditi.lindenlab.com/cgi-bin/login.cgi",
                      help="specified the target loginuri")
    parser.add_option("-r", "--region", dest="region", default=None,
                      help="specifies the region (regionname/x/y/z) to connect to")
    parser.add_option("-q", "--quiet", dest="verbose", default=True, action="store_false",
                    help="enable verbose mode")
    parser.add_option("-p", "--password", dest="password", default=None,
                      help="specifies password instead of being prompted for one")


    (options, args) = parser.parse_args()

    if len(args) != 2:
        parser.error("Expected arguments: firstname lastname")

    if options.verbose:
        console = logging.StreamHandler()
        console.setLevel(logging.DEBUG) # seems to be a no op, set it for the logger
        formatter = logging.Formatter('%(asctime)-30s%(name)-30s: %(levelname)-8s %(message)s')
        console.setFormatter(formatter)
        logging.getLogger('').addHandler(console)

        # setting the level for the handler above seems to be a no-op
        # it needs to be set for the logger, here the root logger
        # otherwise it is NOTSET(=0) which means to log nothing.
        logging.getLogger('').setLevel(logging.DEBUG)
    else:
        print "Attention: This script will print nothing if you use -q. So it might be boring to use it like that ;-)"

    # example from a pure agent perspective

    #grab a password!
    if options.password:
        password = options.password
    else:
        password = getpass.getpass()

    # let's disable inventory handling for this example
    settings = Settings()
    settings.ENABLE_INVENTORY_MANAGEMENT = False
    settings.ENABLE_EQ_LOGGING = False
    settings.ENABLE_CAPS_LOGGING = False

    #First, initialize the agent
    client = Agent(settings = settings)

    # Now let's log it in
    try:
        api.spawn(client.login, options.loginuri, args[0], args[1], password, start_location = options.region, connect_region = True)
    except LoginError, error:
        sys.exit()
    def test_onObjectUpdate_selected(self):

        self.object_store.agent = Agent()
        fake_uuid = UUID()
        fake_uuid.random()
        packet = Message(
            'ObjectUpdate', Block('RegionData', RegionHandle=0,
                                  TimeDilation=0),
            Block('ObjectData',
                  ID=1,
                  State=1,
                  FullID=fake_uuid,
                  CRC=0,
                  PCode=0,
                  Material=0,
                  ClickAction=0,
                  Scale=Vector3(X=0.0, Y=0.0, Z=0.0),
                  ObjectData='',
                  ParentID=fake_uuid,
                  UpdateFlags=0,
                  ProfileCurve=0,
                  PathBegin=0.0,
                  PathEnd=0.0,
                  PathScaleX=0.0,
                  PathScaleY=0.0,
                  PathShearX=0.0,
                  PathShearY=0.0,
                  PathTwist=-1,
                  PathTwistBegin=-1,
                  PathRadiusOffset=-1,
                  PathTaperX=-1,
                  PathTaperY=-1,
                  PathRevolutions=0,
                  PathSkew=-1,
                  ProfileBegin=0,
                  ProfileEnd=0,
                  ProfileHollow=0,
                  TextureEntry='',
                  TextureAnim='',
                  NameValue='Test',
                  Data='',
                  Text='',
                  TextColor=0x0,
                  MedialURL=''))

        def callback(payload):
            self.data.append("foo")

        object_handler = self.object_store.agent.events_handler.register(
            "ObjectSelected")
        object_handler.subscribe(callback)
        self.object_store.region.message_handler.handle(packet)
        self.assertTrue(self.data.pop, "foo")
Exemple #7
0
    def initialize_agent(self):
        # let's disable inventory handling for this example
        settings = Settings()
        settings.ENABLE_APPEARANCE_MANAGEMENT = False
        settings.ENABLE_INVENTORY_MANAGEMENT = False
        settings.ENABLE_EQ_LOGGING = True
        settings.ENABLE_CAPS_LOGGING = False
        settings.ENABLE_REGION_EVENT_QUEUE = True
        settings.REGION_EVENT_QUEUE_POLL_INTERVAL = 5

        #First, initialize the agent
        client = Agent(settings=settings, handle_signals=False)
        self.client = client
        return client
Exemple #8
0
def login_request(request,
                  firstname=None,
                  lastname=None,
                  password=None,
                  error_message=None):

    if request.POST:
        firstname = request.POST['firstname']
        lastname = request.POST['lastname']
        password = request.POST['password']

    try:

        bot_settings = Settings()

        bot_settings.ENABLE_INVENTORY_MANAGEMENT = True
        bot_settings.ENABLE_COMMUNICATIONS_TRACKING = False
        bot_settings.ENABLE_OBJECT_TRACKING = False
        bot_settings.ENABLE_UDP_LOGGING = True
        bot_settings.ENABLE_EQ_LOGGING = True
        bot_settings.ENABLE_CAPS_LOGGING = True
        bot_settings.MULTIPLE_SIM_CONNECTIONS = False

        client = Agent(settings=bot_settings, handle_signals=False)
        #raise LoginError('this is BS')

        api.spawn(client.login,
                  'https://login.aditi.lindenlab.com/cgi-bin/login.cgi',
                  firstname, lastname, password)

        now = time.time()
        start = now

        while now - start < 15:
            api.sleep()

    except LoginError, e:

        error_message = e

        return HttpResponse(
            'would like to show the login form again, with any error message that\'s appropriate, like: %s'
            % (error_message))
Exemple #9
0
# standard
import unittest
import getpass, logging
from optparse import OptionParser
import time

# pyogp
from pyogp.lib.client.agent import Agent
from pyogp.lib.client.enums import DeRezDestination, AssetType, \
     InventoryType, WearablesIndex
from pyogp.lib.base.datatypes import UUID, Vector3

# related
from eventlet import api

client = Agent()


class Semaphore(object):
    """
    Basic semaphore to allow the serialization of the tests
    """
    waiting = True
    timed_out = False

    def wait(self, time_out=0):
        start = now = time.time()
        while self.waiting and now - start <= time_out:
            api.sleep(0)
            now = time.time()
        if now - start > time_out:
    settings.ENABLE_INVENTORY_MANAGEMENT = True
    settings.ENABLE_COMMUNICATIONS_TRACKING = False
    settings.ENABLE_OBJECT_TRACKING = False
    settings.ENABLE_UDP_LOGGING =True
    settings.ENABLE_EQ_LOGGING = True
    settings.ENABLE_CAPS_LOGGING = True
    settings.MULTIPLE_SIM_CONNECTIONS = False
    settings.ACCEPT_INVENTORY_OFFERS = True

    agents = []

    # Now let's prime the accounts for login
    for params in clients:
        #First, initialize the agent
        agents.append(Agent(settings, params[0], params[1], params[2]))

    agentmanager = AgentManager()
    agentmanager.initialize(agents)

    #print 'Storing agents:'
    #for agent in agentmanager.agents:
        #print '\t' + agentmanager.agents[agent].Name()

    # log them in
    for key in agentmanager.agents:
        agentmanager.login(key, options.loginuri, options.region)

############ WORKING HERE
    # allow 10 seconds for agents to connect
    Wait(10)
def login():
    """ login an to a login endpoint """ 

    parser = OptionParser(usage="usage: %prog [options] firstname lastname")

    logger = logging.getLogger("client.example")

    parser.add_option("-l", "--loginuri", dest="loginuri", default="https://login.aditi.lindenlab.com/cgi-bin/login.cgi",
                      help="specified the target loginuri")
    parser.add_option("-r", "--region", dest="region", default=None,
                      help="specifies the region (regionname/x/y/z) to connect to")
    parser.add_option("-q", "--quiet", dest="verbose", default=True, action="store_false",
                    help="enable verbose mode")
    parser.add_option("-s", "--search", dest="search", default=None,
                    help="inventory item to search for an rez (optional)")
    parser.add_option("-p", "--password", dest="password", default=None,
                      help="specifies password instead of being prompted for one")

    (options, args) = parser.parse_args()

    if len(args) != 2:
        parser.error("Expected arguments: firstname lastname")

    if options.verbose:
        console = logging.StreamHandler()
        console.setLevel(logging.DEBUG) # seems to be a no op, set it for the logger
        formatter = logging.Formatter('%(asctime)-30s%(name)-30s: %(levelname)-8s %(message)s')
        console.setFormatter(formatter)
        logging.getLogger('').addHandler(console)

        # setting the level for the handler above seems to be a no-op
        # it needs to be set for the logger, here the root logger
        # otherwise it is NOTSET(=0) which means to log nothing.
        logging.getLogger('').setLevel(logging.DEBUG)
    else:
        print "Attention: This script will print nothing if you use -q. So it might be boring to use it like that ;-)"

    # example from a pure agent perspective

    #grab a password!
    #grab a password!
    if options.password:
        password = options.password
    else:
        password = getpass.getpass()

    # let's disable object tracking for this example
    settings = Settings()
    settings.ENABLE_OBJECT_TRACKING = False

    #First, initialize the agent
    client = Agent(settings = settings)

    # Now let's log it in
    api.spawn(client.login, options.loginuri, args[0], args[1], password, start_location = options.region, connect_region = True)

    # wait for the agent to connect to it's region
    while client.connected == False:
        api.sleep(0)

    while client.region.connected == False:
        api.sleep(0)

    # for folders whose parent = root folder aka My Inventory, request their contents
    [client.inventory._request_folder_contents(folder.FolderID) for folder in client.inventory.folders if folder.ParentID == client.inventory.inventory_root.FolderID]

    #while client.running:
        #api.sleep(0)

    # next, let's wait 30 seconds and FetchInventory for items we know about
    now = time.time()
    start = now
    while now - start < 5 and client.running:
        api.sleep()
        now = time.time()


    if options.search != None:
        # and next, let's search the inventory by name
        matches = client.inventory.search_inventory(name = options.search)

        # now, if we have a match, let's try and rez the first matching object
        item_to_rez = matches[0]
        print item_to_rez.__dict__
        print dir(item_to_rez)

        item_to_rez.rez_object(client)

    # next, let's wait another 30 seconds then bail
    now = time.time()
    start = now
    while now - start < 30 and client.running:
        api.sleep()

    client.logout()

    print ''
    print ''
    print 'At this point, we have an Agent object, Inventory dirs, and with a Region attribute'
    print 'Agent attributes:'
    for attr in client.__dict__:
        print attr, ':\t\t\t',  client.__dict__[attr]
    print ''
    print ''
    print 'Inventory: %s folders' % len(client.inventory.folders)
    for inv_folder in client.inventory.folders:
        print 'Inventory Folder', ':\t\t\t',  inv_folder.Name
        for item in inv_folder.inventory:
            print '    ', item.Name
    print ''
    print ''
    print 'Region attributes:'
    for attr in client.region.__dict__:
        print attr, ':\t\t\t',  client.region.__dict__[attr]
def login():
    """ login an to a login endpoint """

    parser = OptionParser(usage="usage: %prog [options] firstname lastname")

    logger = logging.getLogger("client.example")

    parser.add_option(
        "-l",
        "--loginuri",
        dest="loginuri",
        default="https://login.aditi.lindenlab.com/cgi-bin/login.cgi",
        help="specified the target loginuri")
    parser.add_option(
        "-r",
        "--region",
        dest="region",
        default=None,
        help="specifies the region (regionname/x/y/z) to connect to")
    parser.add_option("-q",
                      "--quiet",
                      dest="verbose",
                      default=True,
                      action="store_false",
                      help="enable verbose mode")
    parser.add_option(
        "-p",
        "--password",
        dest="password",
        default=None,
        help="specifies password instead of being prompted for one")

    (options, args) = parser.parse_args()

    if len(args) != 2:
        parser.error("Expected arguments: firstname lastname")

    if options.verbose:
        console = logging.StreamHandler()
        console.setLevel(
            logging.DEBUG)  # seems to be a no op, set it for the logger
        formatter = logging.Formatter(
            '%(asctime)-30s%(name)-30s: %(levelname)-8s %(message)s')
        console.setFormatter(formatter)
        logging.getLogger('').addHandler(console)

        # setting the level for the handler above seems to be a no-op
        # it needs to be set for the logger, here the root logger
        # otherwise it is NOTSET(=0) which means to log nothing.
        logging.getLogger('').setLevel(logging.DEBUG)
    else:
        print "Attention: This script will print nothing if you use -q. So it might be boring to use it like that ;-)"

    # example from a pure agent perspective

    #grab a password!
    if options.password:
        password = options.password
    else:
        password = getpass.getpass()

    # let's disable inventory handling for this example
    settings = Settings()
    settings.ENABLE_INVENTORY_MANAGEMENT = False
    settings.ENABLE_EQ_LOGGING = False
    settings.ENABLE_CAPS_LOGGING = False

    #First, initialize the agent
    client = Agent(settings=settings)

    # Now let's log it in
    api.spawn(client.login,
              options.loginuri,
              args[0],
              args[1],
              password,
              start_location=options.region,
              connect_region=True)

    # wait for the agent to connect to it's region
    while client.connected == False:
        api.sleep(0)

    while client.region.connected == False:
        api.sleep(0)

    # do sample script specific stuff here
    # in this case we create a box

    waiter = Wait(5)

    for i in range(len(object_names)):
        client.region.objects.create_default_box(GroupID=client.ActiveGroupID,
                                                 relative_position=((i + 1), 0,
                                                                    0))

    waiter = Wait(5)

    # let's see what's nearby
    objects_nearby = client.region.objects.find_objects_within_radius(20)

    for item in objects_nearby:
        item.select(client)

    waiter = Wait(15)

    for item in objects_nearby:
        item.deselect(client)

    my_objects = client.region.objects.my_objects()

    print 'Hey! Will try to set object names'
    print 'Hey! Will try to set permissions.'

    i = 0
    for item in my_objects:
        fixed_name = object_names[i]
        print ' for LocalID %s : %s ' % (item.LocalID, fixed_name)
        item.set_object_name(client, fixed_name)
        if fixed_name == 'Alpha':
            item.set_object_transfer_only_permissions(client)
        elif fixed_name == 'Bravo':
            item.set_object_copy_transfer_permissions(client)
        elif fixed_name == 'Charlie':
            item.set_object_mod_transfer_permissions(client)
        elif fixed_name == 'Delta':
            item.set_object_full_permissions(client)
        elif fixed_name == 'Echo':
            item.set_object_copy_only_permissions(client)
        elif fixed_name == 'Foxtrot':
            item.set_object_copy_mod_permissions(client)
        else:
            print "Name Does Not Match!"
        i = i + 1
        waiter = Wait(2)
        item.take(client)

    waiter = Wait(30)

    while client.running:
        api.sleep(0)

    print ''
    print ''
    print 'At this point, we have an Agent object, Inventory dirs, and with a Region attribute'
    print 'Agent attributes:'
    for attr in client.__dict__:
        print attr, ':\t\t\t', client.__dict__[attr]
    print ''
    print ''
    print 'Objects being tracked: %s' % len(client.region.objects.object_store)
    print ''
    print ''
    states = {}
    for _object in client.region.objects.object_store:
        if _object.State == 0:
            #items = _object.__dict__.items()
            #items.sort()
            print 'Object attributes'
            for attr in _object.__dict__:
                print '\t\t%s:\t\t%s' % (attr, _object.__dict__[attr])
            print ''
        else:
            if states.has_key(_object.State):
                states[_object.State] += 1
            else:
                states[_object.State] = 1
    print ''
    print 'Object states I don\'t care about atm'
    for state in states:
        print '\t State: ', state, '\tFrequency: ', states[state]
    print ''
    print ''
    for _avatar in client.region.objects.avatar_store:
        print 'LocalID:', _avatar.LocalID, '\tUUID: ', _avatar.FullID, '\tNameValue: ', _avatar.NameValue, '\tPosition: ', _avatar.Position
    print ''
    print ''
    print 'Region attributes:'
    for attr in client.region.__dict__:
        print attr, ':\t\t\t', client.region.__dict__[attr]
Exemple #13
0
def login():
    """ login an to a login endpoint """

    parser = OptionParser(usage="usage: %prog [options] firstname lastname")

    logger = logging.getLogger("client.example")

    parser.add_option(
        "-l",
        "--loginuri",
        dest="loginuri",
        default="https://login.aditi.lindenlab.com/cgi-bin/login.cgi",
        help="specified the target loginuri")
    parser.add_option(
        "-r",
        "--region",
        dest="region",
        default=None,
        help="specifies the region (regionname/x/y/z) to connect to")
    parser.add_option("-q",
                      "--quiet",
                      dest="verbose",
                      default=True,
                      action="store_false",
                      help="enable verbose mode")
    parser.add_option(
        "-p",
        "--password",
        dest="password",
        default=None,
        help="specifies password instead of being prompted for one")

    (options, args) = parser.parse_args()

    if len(args) != 2:
        parser.error("Expected arguments: firstname lastname")

    if options.verbose:
        console = logging.StreamHandler()
        console.setLevel(
            logging.DEBUG)  # seems to be a no op, set it for the logger
        formatter = logging.Formatter(
            '%(asctime)-30s%(name)-30s: %(levelname)-8s %(message)s')
        console.setFormatter(formatter)
        logging.getLogger('').addHandler(console)

        # setting the level for the handler above seems to be a no-op
        # it needs to be set for the logger, here the root logger
        # otherwise it is NOTSET(=0) which means to log nothing.
        logging.getLogger('').setLevel(logging.DEBUG)
    else:
        print "Attention: This script will print nothing if you use -q. So it might be boring to use it like that ;-)"

    # example from a pure agent perspective
    print 'we are going to try and group chat with the agent\'s active group. set one active, or get the uuid and create a new script that does it for you!'
    print ''
    print 'This only works on unix like machines ATM.'

    #grab a password!
    if options.password:
        password = options.password
    else:
        password = getpass.getpass()

    # let's disable inventory handling for this example
    settings = Settings()
    settings.ENABLE_INVENTORY_MANAGEMENT = False
    settings.ENABLE_OBJECT_TRACKING = False
    settings.ENABLE_COMMUNICATIONS_TRACKING = True
    settings.ENABLE_UDP_LOGGING = False
    settings.ENABLE_EQ_LOGGING = False
    settings.ENABLE_CAPS_LOGGING = False

    #First, initialize the agent
    client = Agent(settings=settings)

    # Now let's log it in
    api.spawn(client.login,
              options.loginuri,
              args[0],
              args[1],
              password,
              start_location=options.region,
              connect_region=True)

    # wait for the agent to connect to it's region
    while client.connected == False:
        api.sleep(0)

    while client.region.connected == False:
        api.sleep(0)

    # wait 10 seconds, hoping group data populates by then
    Wait(10)

    # do sample script specific stuff here

    chat_group = client.group_manager.get_group(client.ActiveGroupID)

    # until the implementation is done, add the agent to the group object
    chat_group.agent = client

    print ''
    print 'I know, this interface is not an interface, you\'ll see, just type when prompted. Saijanai, sounds like you are up for a wx application. Hit Escape to trigger the message prompt.'

    if chat_group != None:
        chaty_kathy = MockChatInterface(
            client, chat_group.chat)  # this object is l-a-m-e
        chaty_kathy.start()
    else:
        print "We failed to find the group to start chat session :(. Continuing"

    while client.running:
        api.sleep(0)

    print ''
    print ''
    print 'At this point, we have an Agent object, Inventory dirs, and with a Region attribute'
    print 'Agent attributes:'
    for attr in client.__dict__:
        print attr, ':\t\t\t', client.__dict__[attr]
    print ''
    print ''
    print 'Known Groups:'
    for group in client.group_manager.group_store:
        print ':\t\t\t', group.GroupName
        for attr in group.__dict__:
            print '\t\t\t\t', attr, ':\t', group.__dict__[attr]
Exemple #14
0
def login():
    """ login an to a login endpoint """

    parser = OptionParser(usage="usage: %prog [options] firstname lastname")

    logger = logging.getLogger("client.example")

    parser.add_option(
        "-l",
        "--loginuri",
        dest="loginuri",
        default="https://login.aditi.lindenlab.com/cgi-bin/login.cgi",
        help="specified the target loginuri")
    parser.add_option("-r",
                      "--region",
                      dest="region",
                      default=None,
                      help="specifies the region to connect to")
    #http://ec2-75-101-203-98.compute-1.amazonaws.com:9000
    parser.add_option("-q",
                      "--quiet",
                      dest="verbose",
                      default=True,
                      action="store_false",
                      help="enable verbose mode")
    parser.add_option(
        "-p",
        "--password",
        dest="password",
        default=None,
        help="specifies password instead of being prompted for one")

    (options, args) = parser.parse_args()

    if len(args) != 2:
        parser.error("Expected arguments: firstname lastname")

    if options.verbose:
        console = logging.StreamHandler()
        console.setLevel(
            logging.DEBUG)  # seems to be a no op, set it for the logger
        formatter = logging.Formatter(
            '%(asctime)-30s%(name)-30s: %(levelname)-8s %(message)s')
        console.setFormatter(formatter)
        logging.getLogger('').addHandler(console)

        # setting the level for the handler above seems to be a no-op
        # it needs to be set for the logger, here the root logger
        # otherwise it is NOTSET(=0) which means to log nothing.
        logging.getLogger('').setLevel(logging.DEBUG)
    else:
        print "Attention: This script will print nothing if you use -q. So it might be boring to use it like that ;-)"

    # example from a pure agent perspective

    #grab a password!
    password = getpass.getpass()

    # let's disable inventory handling for this example
    settings = Settings()
    settings.ENABLE_INVENTORY_MANAGEMENT = False
    settings.ENABLE_EQ_LOGGING = False
    settings.ENABLE_CAPS_LOGGING = False

    #First, initialize the agent
    client = Agent(settings=settings)

    # Now let's log it in
    api.spawn(client.login,
              options.loginuri,
              args[0],
              args[1],
              password,
              start_location=options.region,
              connect_region=True)

    # wait for the agent to connect to it's region
    while client.connected == False:
        api.sleep(0)

    while client.region.connected == False:
        api.sleep(0)

    # in this case, wait for the client.Position to become populated, as we need to rez a box
    # relative to our current position
    while client.Position == (0.0, 0.0, 0.0):
        api.sleep(10)

    # do sample script specific stuff here

    client.region.objects.create_default_box(GroupID=client.ActiveGroupID)

    while client.running:
        api.sleep(0)

    print ''
    print ''
    print 'At this point, we have an Agent object, Inventory dirs, and with a Region attribute'
    print 'Agent attributes:'
    for attr in client.__dict__:
        print attr, ':\t\t\t', client.__dict__[attr]
    print ''
    print ''
    print 'Objects being tracked: %s' % len(client.region.objects.object_store)
    print ''
    print ''
    states = {}
    for _object in client.region.objects.object_store:
        if _object.State != None:
            print 'LocalID:', _object.LocalID, '\tUUID: ', _object.FullID, '\tState: ', _object.State, '\tPosition: ', _object.Position
        else:
            if states.has_key(_object.State):
                states[_object.State] += 1
            else:
                states[_object.State] = 1
    print ''
    print 'Object states I don\'t care about atm'
    for state in states:
        print '\t State: ', state, '\tFrequency: ', states[state]
    print ''
    print ''
    print 'Avatars being tracked: %s' % len(client.region.objects.avatar_store)
    print ''
    print ''
    for _avatar in client.region.objects.avatar_store:
        print 'ID:', _avatar.LocalID, '\tUUID: ', _avatar.FullID, '\tNameValue: ', _avatar.NameValue, '\tPosition: ', _avatar.Position
    print ''
    print ''
    print 'Region attributes:'
    for attr in client.region.__dict__:
        print attr, ':\t\t\t', client.region.__dict__[attr]
def login():
    """ login an to a login endpoint """

    parser = OptionParser(usage="usage: %prog [options] firstname lastname")

    logger = logging.getLogger("client.example")

    parser.add_option(
        "-l",
        "--loginuri",
        dest="loginuri",
        default="https://login.aditi.lindenlab.com/cgi-bin/login.cgi",
        help="specified the target loginuri")
    parser.add_option(
        "-r",
        "--region",
        dest="region",
        default=None,
        help="specifies the region (regionname/x/y/z) to connect to")
    parser.add_option("-q",
                      "--quiet",
                      dest="verbose",
                      default=True,
                      action="store_false",
                      help="enable verbose mode")
    parser.add_option(
        "-p",
        "--password",
        dest="password",
        default=None,
        help="specifies password instead of being prompted for one")

    (options, args) = parser.parse_args()

    if len(args) != 2:
        parser.error("Expected arguments: firstname lastname")

    if options.verbose:
        console = logging.StreamHandler()
        console.setLevel(
            logging.DEBUG)  # seems to be a no op, set it for the logger
        formatter = logging.Formatter(
            '%(asctime)-30s%(name)-30s: %(levelname)-8s %(message)s')
        console.setFormatter(formatter)
        logging.getLogger('').addHandler(console)

        # setting the level for the handler above seems to be a no-op
        # it needs to be set for the logger, here the root logger
        # otherwise it is NOTSET(=0) which means to log nothing.
        logging.getLogger('').setLevel(logging.DEBUG)
    else:
        print "Attention: This script will print nothing if you use -q. So it might be boring to use it like that ;-)"

    # example from a pure agent perspective

    #grab a password!
    if options.password:
        password = options.password
    else:
        password = getpass.getpass()

    # prep instance settings
    settings = Settings()

    settings.ENABLE_INVENTORY_MANAGEMENT = False
    settings.ENABLE_COMMUNICATIONS_TRACKING = False
    settings.ENABLE_OBJECT_TRACKING = False
    settings.ENABLE_UDP_LOGGING = True
    settings.ENABLE_EQ_LOGGING = True
    settings.ENABLE_CAPS_LOGGING = True
    settings.MULTIPLE_SIM_CONNECTIONS = False

    #First, initialize the agent
    client = Agent(settings)

    # Now let's log it in
    api.spawn(client.login,
              options.loginuri,
              args[0],
              args[1],
              password,
              start_location=options.region,
              connect_region=True)

    # wait for the agent to connect to it's region
    while client.connected == False:
        api.sleep(0)

    while client.region.connected == False:
        api.sleep(0)

    while client.running:
        api.sleep(0)
    print ''
    print ''
    print 'At this point, we have an Agent object, Inventory dirs, and with a Region attribute'
    print 'Agent attributes:'
    for attr in client.__dict__:
        print attr, ':\t\t\t', client.__dict__[attr]
    print ''
    print ''
    print 'Region attributes:'
    for attr in client.region.__dict__:
        print attr, ':\t\t\t', client.region.__dict__[attr]
Exemple #16
0
def login():
    """ login an to a login endpoint """

    parser = OptionParser(usage="usage: %prog [options] firstname lastname")

    logger = logging.getLogger("client.example")

    parser.add_option(
        "-l",
        "--loginuri",
        dest="loginuri",
        default="https://login.aditi.lindenlab.com/cgi-bin/login.cgi",
        help="specified the target loginuri")
    parser.add_option(
        "-r",
        "--region",
        dest="region",
        default=None,
        help="specifies the region (regionname/x/y/z) to connect to")
    parser.add_option("-q",
                      "--quiet",
                      dest="verbose",
                      default=True,
                      action="store_false",
                      help="enable verbose mode")
    parser.add_option(
        "-p",
        "--password",
        dest="password",
        default=None,
        help="specifies password instead of being prompted for one")

    (options, args) = parser.parse_args()

    if len(args) != 2:
        parser.error("Expected arguments: firstname lastname")

    if options.verbose:
        console = logging.StreamHandler()
        console.setLevel(
            logging.DEBUG)  # seems to be a no op, set it for the logger
        formatter = logging.Formatter(
            '%(asctime)-30s%(name)-30s: %(levelname)-8s %(message)s')
        console.setFormatter(formatter)
        logging.getLogger('').addHandler(console)

        # setting the level for the handler above seems to be a no-op
        # it needs to be set for the logger, here the root logger
        # otherwise it is NOTSET(=0) which means to log nothing.
        logging.getLogger('').setLevel(logging.DEBUG)
    else:
        print "Attention: This script will print nothing if you use -q. So it might be boring to use it like that ;-)"

    # example from a pure agent perspective

    #grab a password!
    if options.password:
        password = options.password
    else:
        password = getpass.getpass()

    #First, initialize the agent
    client = Agent()

    # Now let's log it in
    client.login(options.loginuri,
                 args[0],
                 args[1],
                 password,
                 start_location=options.region)

    print ''
    print ''
    print 'At this point, we have only an Agent object'
    print 'Agent attributes:'
    for attr in client.__dict__:
        print attr, ':\t\t\t', client.__dict__[attr]
Exemple #17
0
class TestAgent(unittest.TestCase):
    def setUp(self):

        self.legacy_loginuri = 'http://localhost:12345/cgi-bin/login.cgi'
        self.ogp_loginuri = 'http://localhost:12345/auth.cgi'
        self.firstname = 'firstname'
        self.lastname = 'lastname'
        self.password = '******'

        self.client = Agent()

    def tearDown(self):

        pass

    def test_agent_legacy_login_via_variables(self):

        # override the network client with the mock client pointed at the mock login handler
        self.loginhandler = MockXMLRPC(MockXMLRPCLogin(), self.legacy_loginuri)

        self.client.login(self.legacy_loginuri,
                          self.firstname,
                          self.lastname,
                          self.password,
                          start_location='start',
                          handler=self.loginhandler,
                          connect_region=False)

        self.assertEquals(
            self.client.login_response, {
                'region_y': '256',
                'region_x': '256',
                'first_name': '"first"',
                'secure_session_id': '00000000-0000-0000-0000-000000000000',
                'sim_ip': '127.0.0.1',
                'agent_access': 'M',
                'circuit_code': '600000000',
                'look_at':
                '[r0.9963859999999999939,r-0.084939700000000006863,r0]',
                'session_id': '00000000-0000-0000-0000-000000000000',
                'udp_blacklist':
                'EnableSimulator,TeleportFinish,CrossedRegion',
                'seed_capability':
                'https://somesim:12043/cap/00000000-0000-0000-0000-000000000000',
                'agent_id': '00000000-0000-0000-0000-000000000000',
                'last_name': 'last',
                'inventory_host': 'someinvhost',
                'start_location': 'last',
                'sim_port': '13001',
                'message': 'message',
                'login': '******',
                'seconds_since_epoch': '1234567890'
            })

    def test_agent_legacy_login_via_params(self):

        # override the network client with the mock client pointed at the mock login handler
        self.loginhandler = MockXMLRPC(MockXMLRPCLogin(), self.legacy_loginuri)

        login_params = LegacyLoginParams(self.firstname, self.lastname,
                                         self.password)

        self.client.login(self.legacy_loginuri,
                          login_params=login_params,
                          start_location='start',
                          handler=self.loginhandler,
                          connect_region=False)

        self.assertEquals(
            self.client.login_response, {
                'region_y': '256',
                'region_x': '256',
                'first_name': '"first"',
                'secure_session_id': '00000000-0000-0000-0000-000000000000',
                'sim_ip': '127.0.0.1',
                'agent_access': 'M',
                'circuit_code': '600000000',
                'look_at':
                '[r0.9963859999999999939,r-0.084939700000000006863,r0]',
                'session_id': '00000000-0000-0000-0000-000000000000',
                'udp_blacklist':
                'EnableSimulator,TeleportFinish,CrossedRegion',
                'seed_capability':
                'https://somesim:12043/cap/00000000-0000-0000-0000-000000000000',
                'agent_id': '00000000-0000-0000-0000-000000000000',
                'last_name': 'last',
                'inventory_host': 'someinvhost',
                'start_location': 'last',
                'sim_port': '13001',
                'message': 'message',
                'login': '******',
                'seconds_since_epoch': '1234567890'
            })

    def test_agent_ogp_login_via_variables(self):

        # override the network client with the mock client pointed at the mock login handler
        self.loginhandler = MockupClient(MockAgentDomainLogin())

        self.client.login(self.ogp_loginuri,
                          self.firstname,
                          self.lastname,
                          self.password,
                          start_location='start',
                          handler=self.loginhandler,
                          connect_region=False)

        self.assertEquals(
            self.client.login_response, {
                'agent_seed_capability': 'http://127.0.0.1:12345/seed_cap',
                'authenticated': True
            })

    def test_agent_ogp_login_via_params(self):

        # override the network client with the mock client pointed at the mock login handler
        self.loginhandler = MockupClient(MockAgentDomainLogin())

        login_params = OGPLoginParams(self.firstname, self.lastname,
                                      self.password)

        self.client.login(self.ogp_loginuri,
                          self.firstname,
                          self.lastname,
                          self.password,
                          start_location='start',
                          handler=self.loginhandler,
                          connect_region=False)

        self.assertEquals(
            self.client.login_response, {
                'agent_seed_capability': 'http://127.0.0.1:12345/seed_cap',
                'authenticated': True
            })

    def test_agent_login_no_account_info(self):

        self.assertRaises(LoginError, self.client.login, self.ogp_loginuri)

    def test_legacy_get_login_params(self):

        self.client.grid_type = 'Legacy'
        params = self.client._get_login_params(self.firstname, self.lastname,
                                               self.password)

        self.assertEquals(
            type(params),
            type(
                LegacyLoginParams(self.firstname, self.lastname,
                                  self.password)))

    def test_ogp_get_login_params(self):

        self.client.grid_type = 'OGP'
        params = self.client._get_login_params(self.firstname, self.lastname,
                                               self.password)

        self.assertEquals(
            type(params),
            type(OGPLoginParams(self.firstname, self.lastname, self.password)))

    '''
    def test_failed_legacy_login(self):

        # ToDo: enable mne when you can get me working, it's 'correct',
        # but not raising the error properly?

        self.password = '******'

        # override the network client with the mock client pointed at the mock login handler
        self.loginhandler = MockXMLRPC(MockXMLRPCLogin(), self.legacy_loginuri)  

        self.assertRaises(LoginError, self.client.login, self.legacy_loginuri, self.firstname, self.lastname, self.password, start_location = 'start', handler = self.loginhandler)
    '''

    def test_agent_home_class(self):

        home_string = "{'region_handle':[r261120, r247040], 'position':[r171.622, r148.26, r79.3938], 'look_at':[r0, r1, r0]}"

        home = Home(home_string)

        # Note: have not yet worked out precision on floats. Kinda need to
        self.assertEquals(home.region_handle, [261120, 247040])
        self.assertEquals(home.position.X, 171.62200000000001)
        self.assertEquals(home.position.Y, 148.25999999999999)
        self.assertEquals(home.position.Z, 79.393799999999999)
        self.assertEquals(home.look_at.X, 0)
        self.assertEquals(home.look_at.Y, 1)
        self.assertEquals(home.look_at.Z, 0)
        self.assertEquals(home.global_x, 261120)
        self.assertEquals(home.global_y, 247040)
def login():
    """ login an to a login endpoint """

    parser = OptionParser(usage="usage: %prog [options] firstname lastname")

    logger = logging.getLogger("client.example")

    parser.add_option(
        "-l",
        "--loginuri",
        dest="loginuri",
        default="https://login.aditi.lindenlab.com/cgi-bin/login.cgi",
        help="specified the target loginuri")
    parser.add_option(
        "-r",
        "--region",
        dest="region",
        default=None,
        help="specifies the region (regionname/x/y/z) to connect to")
    parser.add_option("-u",
                      "--uuid",
                      dest="uuid",
                      default="00000000-0000-0000-0000-000000000000",
                      help="uuid of the agent to send an instant message to")
    parser.add_option("-q",
                      "--quiet",
                      dest="verbose",
                      default=True,
                      action="store_false",
                      help="enable verbose mode")
    parser.add_option(
        "-p",
        "--password",
        dest="password",
        default=None,
        help="specifies password instead of being prompted for one")

    (options, args) = parser.parse_args()

    if len(args) != 2:
        parser.error("Expected arguments: firstname lastname")

    if options.verbose:
        console = logging.StreamHandler()
        formatter = logging.Formatter(
            '%(asctime)-30s%(name)-30s: %(levelname)-8s %(message)s')
        console.setFormatter(formatter)
        logging.getLogger('').addHandler(console)
        logging.getLogger('').setLevel(logging.DEBUG)
    else:
        print "Attention: This script will print nothing if you use -q. So it might be boring to use it like that ;-)"

    # example from a pure agent perspective

    #grab a password!
    if options.password:
        password = options.password
    else:
        password = getpass.getpass()

    # let's disable inventory handling for this example
    settings = Settings()
    settings.ENABLE_INVENTORY_MANAGEMENT = False
    settings.ENABLE_OBJECT_TRACKING = False

    #First, initialize the agent
    client = Agent(settings=settings)

    # Now let's log it in
    api.spawn(client.login,
              options.loginuri,
              args[0],
              args[1],
              password,
              start_location=options.region,
              connect_region=True)

    # wait for the agent to connect
    while client.connected == False:
        api.sleep(0)

    # let things settle down
    while client.Position == None:
        api.sleep(0)

    # do sample script specific stuff here

    # set up callbacks if they come in handy
    im_handler = client.events_handler.register('InstantMessageReceived')
    im_handler.subscribe(chat_handler)

    im_handler = client.events_handler.register('ChatReceived')
    im_handler.subscribe(chat_handler)

    client.say("Hi, I'm a bot!")

    client.instant_message(options.uuid,
                           "Look, I can even speak to you in IM-ese")
    client.instant_message(options.uuid, "I can even send 2 messages!")

    while client.running:
        api.sleep(0)

    print ''
    print ''
    print 'At this point, we have an Agent object, Inventory dirs, and with a Region attribute'
    print 'Agent attributes:'
    for attr in client.__dict__:
        print attr, ':\t\t\t', client.__dict__[attr]
    print ''
    print ''
    print 'Region attributes:'
    for attr in client.region.__dict__:
        print attr, ':\t\t\t', client.region.__dict__[attr]
Exemple #19
0
def login():
    """ login an to a login endpoint """

    parser = OptionParser(usage="usage: %prog [options] firstname lastname")

    logger = logging.getLogger("client.example")

    parser.add_option(
        "-l",
        "--loginuri",
        dest="loginuri",
        default="https://login.aditi.lindenlab.com/cgi-bin/login.cgi",
        help="specified the target loginuri")
    parser.add_option(
        "-r",
        "--region",
        dest="region",
        default=None,
        help="specifies the region (regionname/x/y/z) to connect to")
    parser.add_option("-q",
                      "--quiet",
                      dest="verbose",
                      default=True,
                      action="store_false",
                      help="enable verbose mode")
    parser.add_option("-t",
                      "--to_agent_id",
                      dest="to_agent_id",
                      default=None,
                      help="agent id to offer inventory to (required)")
    parser.add_option(
        "-s",
        "--search",
        dest="search",
        default=None,
        help=
        "name of inventory item to search for and transfer to account number 2"
    )
    parser.add_option(
        "-p",
        "--password",
        dest="password",
        default=None,
        help="specifies password instead of being prompted for one")

    (options, args) = parser.parse_args()

    if len(args) != 2:
        parser.error("Expected arguments: firstname lastname")

    if options.to_agent_id == None:
        parser.error("Missing required target agent id")

    if options.verbose:
        console = logging.StreamHandler()
        console.setLevel(
            logging.DEBUG)  # seems to be a no op, set it for the logger
        formatter = logging.Formatter(
            '%(asctime)-30s%(name)-30s: %(levelname)-8s %(message)s')
        console.setFormatter(formatter)
        logging.getLogger('').addHandler(console)

        # setting the level for the handler above seems to be a no-op
        # it needs to be set for the logger, here the root logger
        # otherwise it is NOTSET(=0) which means to log nothing.
        logging.getLogger('').setLevel(logging.DEBUG)
    else:
        print "Attention: This script will print nothing if you use -q. So it might be boring to use it like that ;-)"

    # prep instance settings
    settings = Settings()

    settings.ENABLE_INVENTORY_MANAGEMENT = True
    settings.ENABLE_COMMUNICATIONS_TRACKING = False
    settings.ENABLE_OBJECT_TRACKING = False
    settings.ENABLE_UDP_LOGGING = True
    settings.ENABLE_EQ_LOGGING = True
    settings.ENABLE_CAPS_LOGGING = True
    settings.MULTIPLE_SIM_CONNECTIONS = False

    #grab a password!
    if options.password:
        password = options.password
    else:
        password = getpass.getpass()

    #First, initialize the agent
    client = Agent(settings=settings)

    api.spawn(client.login,
              options.loginuri,
              args[0],
              args[1],
              password,
              start_location=options.region,
              connect_region=True)

    # wait for the agent to connect to it's region
    while client.connected == False:
        api.sleep(0)

    while client.region.connected == False:
        api.sleep(0)


############ WORKING HERE

# for folders whose parent = root folder aka My Inventory, request their contents
    [
        client.inventory._request_folder_contents(folder.FolderID)
        for folder in client.inventory.folders
        if folder.ParentID == client.inventory.inventory_root.FolderID
    ]

    #while client.running:
    #api.sleep(0)

    # next, let's wait 5 seconds and FetchInventory for items we know about
    Wait(10)

    if options.search != None:
        # and next, let's search the inventory by name
        matches = client.inventory.search_inventory(name=options.search)

        # now, if we have a match, let's try and rez the first matching object
        item_to_give = matches[0]

        print ''
        print ''
        print ''
        print ''
        print "Found item to give to another agent: %s" % (str(
            item_to_give.__dict__))
        print ''
        print ''
        print ''
        print ''

        client.inventory.give_inventory(item_to_give.ItemID,
                                        options.to_agent_id)

    while client.running:
        api.sleep(0)
def login():
    """ login an to a login endpoint """

    parser = OptionParser(usage="usage: %prog [options] firstname lastname")

    logger = logging.getLogger("client.example")

    parser.add_option(
        "-l",
        "--loginuri",
        dest="loginuri",
        default="https://login.aditi.lindenlab.com/cgi-bin/login.cgi",
        help="specified the target loginuri")
    parser.add_option(
        "-r",
        "--region",
        dest="region",
        default=None,
        help="specifies the region (regionname/x/y/z) to connect to")
    parser.add_option("-q",
                      "--quiet",
                      dest="verbose",
                      default=True,
                      action="store_false",
                      help="enable verbose mode")
    parser.add_option(
        "-p",
        "--password",
        dest="password",
        default=None,
        help="specifies password instead of being prompted for one")

    (options, args) = parser.parse_args()

    if len(args) != 2:
        parser.error("Expected arguments: firstname lastname")

    if options.verbose:
        console = logging.StreamHandler()
        console.setLevel(
            logging.DEBUG)  # seems to be a no op, set it for the logger
        formatter = logging.Formatter(
            '%(asctime)-30s%(name)-30s: %(levelname)-8s %(message)s')
        console.setFormatter(formatter)
        logging.getLogger('').addHandler(console)

        # setting the level for the handler above seems to be a no-op
        # it needs to be set for the logger, here the root logger
        # otherwise it is NOTSET(=0) which means to log nothing.
        logging.getLogger('').setLevel(logging.DEBUG)
    else:
        print "Attention: This script will print nothing if you use -q. So it might be boring to use it like that ;-)"

    # example from a pure agent perspective

    #grab a password!
    if options.password:
        password = options.password
    else:
        password = getpass.getpass()

    # let's disable inventory handling for this example
    settings = Settings()
    settings.ENABLE_INVENTORY_MANAGEMENT = False
    settings.ENABLE_EQ_LOGGING = False
    settings.ENABLE_CAPS_LOGGING = False

    #First, initialize the agent
    client = Agent(settings=settings)

    # Now let's log it in
    api.spawn(client.login,
              options.loginuri,
              args[0],
              args[1],
              password,
              start_location=options.region,
              connect_region=True)

    # wait for the agent to connect to it's region
    while client.connected == False:
        api.sleep(0)

    while client.region.connected == False:
        api.sleep(0)

    # do sample script specific stuff here

    # wait 30 seconds from some object data to come in
    now = time.time()
    start = now
    while now - start < 15 and client.running:
        api.sleep()
        now = time.time()

    # let's see what's nearby
    objects_nearby = client.region.objects.find_objects_within_radius(20)

    for item in objects_nearby:
        item.select(client)

    # print matches

    while client.running:
        api.sleep(0)

    print ''
    print ''
    print 'At this point, we have an Agent object, Inventory dirs, and with a Region attribute'
    print 'Agent attributes:'
    for attr in client.__dict__:
        print attr, ':\t\t\t', client.__dict__[attr]
    print ''
    print ''
    print 'Objects being tracked: %s' % len(client.region.objects.object_store)
    print ''
    print ''
    states = {}
    for _object in client.region.objects.object_store:
        if _object.State == 0:
            #items = _object.__dict__.items()
            #items.sort()
            print 'Object attributes'
            for attr in _object.__dict__:
                print '\t\t%s:\t\t%s' % (attr, _object.__dict__[attr])
            print ''
        else:
            if states.has_key(_object.State):
                states[_object.State] += 1
            else:
                states[_object.State] = 1
    print ''
    print 'Object states I don\'t care about atm'
    for state in states:
        print '\t State: ', state, '\tFrequency: ', states[state]
    print ''
    print ''
    print 'Avatars being tracked: %s' % len(client.region.objects.avatar_store)
    print ''
    print ''
    for _avatar in client.region.objects.avatar_store:
        print 'ID:', _avatar.LocalID, '\tUUID: ', _avatar.FullID, '\tNameValue: ', _avatar.NameValue, '\tPosition: ', _avatar.Position
    print ''
    print ''
    print 'Region attributes:'
    for attr in client.region.__dict__:
        print attr, ':\t\t\t', client.region.__dict__[attr]
Exemple #21
0
def login():
    """ login an to a login endpoint """

    parser = OptionParser(usage="usage: %prog [options] firstname lastname")

    logger = logging.getLogger("client.example")

    parser.add_option(
        "-l",
        "--loginuri",
        dest="loginuri",
        default="https://login.aditi.lindenlab.com/cgi-bin/login.cgi",
        help="specified the target loginuri")
    parser.add_option(
        "-r",
        "--region",
        dest="region",
        default=None,
        help="specifies the region (regionname/x/y/z) to connect to")
    parser.add_option("-q",
                      "--quiet",
                      dest="verbose",
                      default=True,
                      action="store_false",
                      help="enable verbose mode")
    parser.add_option(
        "-p",
        "--password",
        dest="password",
        default=None,
        help="specifies password instead of being prompted for one")

    (options, args) = parser.parse_args()

    if len(args) != 2:
        parser.error("Expected arguments: firstname lastname")

    if options.verbose:
        console = logging.StreamHandler()
        console.setLevel(
            logging.DEBUG)  # seems to be a no op, set it for the logger
        formatter = logging.Formatter(
            '%(asctime)-30s%(name)-30s: %(levelname)-8s %(message)s')
        console.setFormatter(formatter)
        logging.getLogger('').addHandler(console)

        # setting the level for the handler above seems to be a no-op
        # it needs to be set for the logger, here the root logger
        # otherwise it is NOTSET(=0) which means to log nothing.
        logging.getLogger('').setLevel(logging.DEBUG)
    else:
        print "Attention: This script will print nothing if you use -q. So it might be boring to use it like that ;-)"

    # example from a pure agent perspective

    #grab a password!
    if options.password:
        password = options.password
    else:
        password = getpass.getpass()

    # prep instance settings
    settings = Settings()

    settings.ENABLE_INVENTORY_MANAGEMENT = False
    settings.ENABLE_COMMUNICATIONS_TRACKING = False
    settings.ENABLE_OBJECT_TRACKING = False
    settings.ENABLE_UDP_LOGGING = True
    settings.ENABLE_EQ_LOGGING = True
    settings.ENABLE_CAPS_LOGGING = True
    settings.MULTIPLE_SIM_CONNECTIONS = False
    settings.ENABLE_PARCEL_TRACKING = True

    #First, initialize the agent
    client = Agent(settings)

    # Now let's log it in
    api.spawn(client.login,
              options.loginuri,
              args[0],
              args[1],
              password,
              start_location=options.region,
              connect_region=True)

    # wait for the agent to connect to it's region
    while client.connected == False:
        api.sleep(0)

    while client.region.connected == False:
        api.sleep(0)

    # sample specific stuff
    # client.region.parcel_manager.request_current_parcel_properties()

    client.region.parcel_manager.request_all_parcel_properties()

    # Wait for all parcel info to be received...
    while not client.region.parcel_manager.parcel_map_full:
        if not client.running: break
        api.sleep(0)

    for parcel in client.region.parcel_manager.parcels:
        client.region.parcel_manager.request_parcel_dwell(parcel.LocalID)

    # run until killed
    while client.running:
        api.sleep(0)

    print ''
    print 'Parcel data for %s parcels' % (len(
        client.region.parcel_manager.parcels))
    for parcel in client.region.parcel_manager.parcels:
        print ''
        for attr in parcel.__dict__:
            print '  %s:            %s' % (attr, parcel.__dict__[attr])

    # inspect some data
    print ''
    print 'Parcel Overlay data:'
    print client.region.parcel_manager.parcel_overlay
Exemple #22
0
def login():
    """ login an to a login endpoint """

    parser = OptionParser(usage="usage: %prog --file filename [options]")

    parser.add_option("-f",
                      "--farm",
                      dest="farm",
                      default="aditi",
                      help="farm to create test accounts on")
    parser.add_option(
        "-l",
        "--loginuri",
        dest="loginuri",
        default="https://login.aditi.lindenlab.com/cgi-bin/login.cgi",
        help="specified the target loginuri")
    parser.add_option("-c",
                      "--count",
                      dest="count",
                      default=0,
                      help="number of agents to login")
    parser.add_option("-s",
                      "--scriptsdir",
                      dest="scriptsdir",
                      default="/local/linden/scripts",
                      help="location of the scripts dir (checkout/install)")
    parser.add_option("-d",
                      "--delay",
                      dest="delay",
                      default=0,
                      help="delay between logins (defaults to 0)")
    scriptname = "create_user.pl"

    (options, args) = parser.parse_args()

    # initialize logging
    console = logging.StreamHandler()
    console.setLevel(
        logging.DEBUG)  # seems to be a no op, set it for the logger
    formatter = logging.Formatter(
        '%(asctime)-30s%(name)-30s: %(levelname)-8s %(message)s')
    console.setFormatter(formatter)
    logging.getLogger('').addHandler(console)
    logging.getLogger('').setLevel(logging.INFO)

    # do some param validation
    if int(options.count) == 0:
        print "Must specify some number > 0 of accounts to create and login"
        sys.exit()

    if not os.path.isdir(options.scriptsdir):
        print "%s does not exist, where is your checkout or install?" % (
            options.scriptsdir)
        sys.exit()

    script = os.path.join(options.scriptsdir, scriptname)

    if not os.path.isfile(script):
        print "%s does not exist, where is your checkout or install?" % (
            script)
        sys.exit()

    delay = int(options.delay)

    # prep instance settings, disable some unnecessary things
    settings = Settings()
    settings.ENABLE_OBJECT_TRACKING = False
    settings.MULTIPLE_SIM_CONNECTIONS = False
    settings.ENABLE_REGION_EVENT_QUEUE = False
    settings.ENABLE_PARCEL_TRACKING = False
    settings.ENABLE_INVENTORY_MANAGEMENT = False

    clients = []
    agents = []

    # create agents on the grid via the standard scripts/create_user.pl script
    # Enus has a lib-style create_user.py in the works, almost done.
    # firstname = timestamp
    # lastname = (default LLQAbot, id - 5644)
    # password = firstname mod
    # email = [email protected]
    # ./create_user.pl --farm aditi --firstname create_user
    #           --lastname 5644 --password lindentest --email [email protected]

    firstname_seed = 'OITest'
    lastname_id = 5644
    lastname = 'LLQABot'

    logger.info("Creating %s accounts for use in test pass." % (options.count))

    for i in range(int(options.count)):
        timestamp = str(int(time.time()))
        timestamp = timestamp[len(timestamp) - 6:]
        firstname = "%s%s%s" % (firstname_seed, i, timestamp)
        password = firstname
        email = "%s%s" % (firstname, '@lindenlab.com')

        #logger.info("Creating %s %s with password of %s" %
        #            (firstname, lastname, password))

        #cmd = "%s --farm %s --firstname %s --lastname %s --password %s --email %s" %
        #    (script, options.farm, firstname, lastname, password, email)

        cmd = [
            script, '--farm', options.farm, '--firstname', firstname,
            '--lastname',
            str(lastname_id), '--password', password, '--email', email
        ]

        #logger.info("Running %s" % (cmd))

        p = subprocess.Popen(cmd,
                             stdout=subprocess.PIPE,
                             stderr=subprocess.PIPE)

        # test for success
        # HACKy
        result = p.stdout.read()

        if re.match("Sucessfully", result):
            logger.info("Successfully created %s %s" % (firstname, lastname))
            clients.append([firstname, lastname, password])
        else:
            logger.error("Failed to create %s %s" % (firstname, lastname))
            logger.error("Terminal failure state. Stopping.")
            sys.exit()

    # Now let's prime the accounts for login
    for params in clients:
        #First, initialize the agent
        agents.append(Agent(settings, params[0], params[1], params[2]))

    agentmanager = AgentManager()
    agentmanager.initialize(agents)

    try:
        # log them in
        for key in agentmanager.agents:
            api.sleep(delay)
            agentmanager.login(key, options.loginuri)

        while agentmanager.has_agents_running():
            api.sleep(0)
    # work around greenlet complaining about getting killed
    except AssertionError, e:
        pass
Exemple #23
0
def login():
    """ login an to a login endpoint """ 

    parser = OptionParser(usage="usage: %prog [options] firstname lastname minx maxx miny maxy")

    logger = logging.getLogger("client.example")

    parser.add_option("-l", "--loginuri", dest="loginuri", default="https://login.agni.lindenlab.com/cgi-bin/login.cgi",
                      help="specified the target loginuri")
    parser.add_option("-r", "--region", dest="region", default=None,
                      help="specifies the region (regionname/x/y/z) to connect to")
    parser.add_option("-q", "--quiet", dest="quiet", default=False, action="store_true",
                    help="log warnings and above (default is debug)")
    parser.add_option("-d", "--verbose", dest="verbose", default=False, action="store_true",
                    help="log info and above (default is debug)")
    parser.add_option("-p", "--password", dest="password", default=None,
                      help="specifies password instead of being prompted for one")

    parser.add_option("-m", "--message", dest="message", default=None,
                      help="The message to chat")

    (options, args) = parser.parse_args()

    if len(args) != 6:
        parser.error("Expected 6 arguments")

    (firstname, lastname, minx, maxx, miny, maxy) = args
    minx, maxx, miny, maxy = int(minx), int(maxx), int(miny), int(maxy)
               
    console = logging.StreamHandler()
    formatter = logging.Formatter('%(asctime)-30s%(name)-30s: %(levelname)-8s %(message)s')
    console.setFormatter(formatter)
    logging.getLogger('').addHandler(console)

        # setting the level for the handler above seems to be a no-op
        # it needs to be set for the logger, here the root logger
        # otherwise it is NOTSET(=0) which means to log nothing.
    if options.verbose:
        logging.getLogger('').setLevel(logging.INFO)
    elif options.quiet:
        logging.getLogger('').setLevel(logging.WARNING)
    else:
        logging.getLogger('').setLevel(logging.DEBUG)

    # example from a pure agent perspective

    #grab a password!
    if options.password:
        password = options.password
    else:
        password = getpass.getpass()

    # prep instance settings
    settings = Settings()

    settings.ENABLE_INVENTORY_MANAGEMENT = False
    settings.ENABLE_COMMUNICATIONS_TRACKING = False
    settings.ENABLE_OBJECT_TRACKING = False
    settings.ENABLE_UDP_LOGGING =True
    settings.ENABLE_EQ_LOGGING = True
    settings.ENABLE_CAPS_LOGGING = True
    settings.MULTIPLE_SIM_CONNECTIONS = False

    #First, initialize the agent
    client = Agent(settings)

    # Now let's log it in
    api.spawn(client.login, options.loginuri, firstname, lastname, password, start_location = options.region, connect_region = True)

    # wait for the agent to connect to it's region
    while client.connected == False:
        api.sleep(0)

    while client.region.connected == False:
        api.sleep(0)


    def got_region(region):
        print "%s (%d, %d)" % (region['name'], region['x'], region['y'])

    client.map_service.request_block(minx, maxx, miny, maxy, got_region)
        
    while client.running:
        api.sleep(0)
def login():
    """ login an to a login endpoint """

    parser = OptionParser(
        usage="usage: %prog [options] firstname lastname groupname")

    logger = logging.getLogger("client.example")

    parser.add_option(
        "-l",
        "--loginuri",
        dest="loginuri",
        default="https://login.aditi.lindenlab.com/cgi-bin/login.cgi",
        help="specified the target loginuri")
    parser.add_option(
        "-r",
        "--region",
        dest="region",
        default=None,
        help="specifies the region (regionname/x/y/z) to connect to")
    parser.add_option("-q",
                      "--quiet",
                      dest="quiet",
                      default=False,
                      action="store_true",
                      help="log warnings and above (default is debug)")
    parser.add_option("-d",
                      "--verbose",
                      dest="verbose",
                      default=False,
                      action="store_true",
                      help="log info and above (default is debug)")
    parser.add_option(
        "-p",
        "--password",
        dest="password",
        default=None,
        help="specifies password instead of being prompted for one")

    parser.add_option("-m",
                      "--message",
                      dest="message",
                      default=None,
                      help="The message to chat")

    (options, args) = parser.parse_args()

    if len(args) != 3:
        parser.error("Expected 3 arguments")

    (firstname, lastname, groupname) = args

    console = logging.StreamHandler()
    formatter = logging.Formatter(
        '%(asctime)-30s%(name)-30s: %(levelname)-8s %(message)s')
    console.setFormatter(formatter)
    logging.getLogger('').addHandler(console)

    # setting the level for the handler above seems to be a no-op
    # it needs to be set for the logger, here the root logger
    # otherwise it is NOTSET(=0) which means to log nothing.
    if options.verbose:
        logging.getLogger('').setLevel(logging.INFO)
    elif options.quiet:
        logging.getLogger('').setLevel(logging.WARNING)
    else:
        logging.getLogger('').setLevel(logging.DEBUG)

    # example from a pure agent perspective

    #grab a password!
    if options.password:
        password = options.password
    else:
        password = getpass.getpass()

    # prep instance settings
    settings = Settings()

    settings.ENABLE_INVENTORY_MANAGEMENT = False
    settings.ENABLE_COMMUNICATIONS_TRACKING = False
    settings.ENABLE_OBJECT_TRACKING = False
    settings.ENABLE_UDP_LOGGING = True
    settings.ENABLE_EQ_LOGGING = True
    settings.ENABLE_CAPS_LOGGING = True
    settings.MULTIPLE_SIM_CONNECTIONS = False

    #First, initialize the agent
    client = Agent(settings)

    # Now let's log it in
    api.spawn(client.login,
              options.loginuri,
              firstname,
              lastname,
              password,
              start_location=options.region,
              connect_region=True)

    # wait for the agent to connect to it's region
    while client.connected == False:
        api.sleep(0)

    while client.region.connected == False:
        api.sleep(0)

    while len(client.group_manager.group_store) == 0:
        api.sleep(0)

    print client.group_manager.group_store

    group = [
        group for group in client.group_manager.group_store
        if group.GroupName == groupname
    ]
    if not group:
        log.error("No such group: '%s'", groupname)
        sys.exit(-1)
    group = group[0]

    if options.message:
        group.chat(options.message)

    c = 0

    while client.running:
        api.sleep(0)
        if len(group.chat_history) > c:
            print group.chat_history[c:]
            c = len(group_chat_history)
Exemple #25
0
def login():
    """ login an to a login endpoint """

    parser = OptionParser(usage="usage: %prog [options] firstname lastname")

    logger = logging.getLogger("client.example")

    parser.add_option(
        "-l",
        "--loginuri",
        dest="loginuri",
        default="https://login.aditi.lindenlab.com/cgi-bin/login.cgi",
        help="specified the target loginuri")
    parser.add_option("-r",
                      "--region",
                      dest="region",
                      default=None,
                      help="specifies the region to connect to")
    #http://ec2-75-101-203-98.compute-1.amazonaws.com:9000
    parser.add_option("-q",
                      "--quiet",
                      dest="verbose",
                      default=True,
                      action="store_false",
                      help="enable verbose mode")
    parser.add_option(
        "-p",
        "--password",
        dest="password",
        default=None,
        help="specifies password instead of being prompted for one")

    (options, args) = parser.parse_args()

    if len(args) != 2:
        parser.error("Expected arguments: firstname lastname")

    if options.verbose:
        console = logging.StreamHandler()
        console.setLevel(
            logging.DEBUG)  # seems to be a no op, set it for the logger
        formatter = logging.Formatter(
            '%(asctime)-30s%(name)-30s: %(levelname)-8s %(message)s')
        console.setFormatter(formatter)
        logging.getLogger('').addHandler(console)

        # setting the level for the handler above seems to be a no-op
        # it needs to be set for the logger, here the root logger
        # otherwise it is NOTSET(=0) which means to log nothing.
        logging.getLogger('').setLevel(logging.DEBUG)
    else:
        print "Attention: This script will print nothing if you use -q. So it might be boring to use it like that ;-)"

    # example from a pure agent perspective

    #grab a password!
    if options.password:
        password = options.password
    else:
        password = getpass.getpass()

    # let's disable inventory handling for this example
    settings = Settings()
    settings.ENABLE_INVENTORY_MANAGEMENT = True
    settings.ENABLE_EQ_LOGGING = False
    settings.ENABLE_CAPS_LOGGING = False

    #First, initialize the agent
    client = Agent(settings=settings)

    # Now let's log it in
    api.spawn(client.login,
              options.loginuri,
              args[0],
              args[1],
              password,
              start_location=options.region,
              connect_region=True)

    # wait for the agent to connect to it's region
    while client.connected == False:
        api.sleep(0)

    while client.region.connected == False:
        api.sleep(0)

    # in this case, wait for the client.Position to become populated, as we need to rez a box
    # relative to our current position
    while client.Position.X == 0.0 and client.Position.Y == 0.0 and \
              client.Position.Z == 0.0:
        api.sleep(10)

    # for folders whose parent = root folder aka My Inventory, request their contents
    [
        client.inventory._request_folder_contents(folder.FolderID)
        for folder in client.inventory.folders
        if folder.ParentID == client.inventory.inventory_root.FolderID
    ]

    # next, let's wait 30 seconds and FetchInventory for items we know about
    now = time.time()
    start = now
    while now - start < 5 and client.running:
        api.sleep()
        now = time.time()

    #Find the Scripts folder
    matches = client.inventory.search_inventory(client.inventory.folders,
                                                name="Scripts")
    folder = matches.pop()

    #Creates a new script in the scripts folder and the callback will upload the script asset
    script = \
"""
default
{
    state_entry()
    {
        llSay(0, "Hello, PyBOT!");
    }

    touch_start(integer total_number)
    {
        llSay(0, "PyBOT says Hi.");
    }
}
"""
    client.inventory.create_new_item(
        folder, "TestLSL1", "created by PyOGP", AssetType.LSLText,
        InventoryType.LSL, WearablesIndex.WT_SHAPE, 0,
        lambda item: client.asset_manager.upload_script_via_caps(
            item.ItemID, script))

    #Finds our script in the inventory
    api.sleep(5)
    matches = client.inventory.search_inventory(client.inventory.folders,
                                                name="TestLSL1")
    script = matches.pop()

    #Registers ObjectSelected event for finding rezzed prim
    object_handler = client.events_handler.register("ObjectSelected")

    #Callback that rezzes script when rezzed prim is found.
    def rez_script(payload):
        client.region.objects.send_RezScript(client, payload.payload['object'],
                                             script.ItemID)
        object_handler.unsubscribe(
            rez_script)  #must unsubscribe or infinite loop

    object_handler.subscribe(rez_script)

    #rezzes a prim, and automatically selects it
    client.region.objects.create_default_box(GroupID=client.ActiveGroupID)

    while client.running:
        api.sleep(0)

    print ''
    print ''
    print 'At this point, we have an Agent object, Inventory dirs, and with a Region attribute'
    print 'Agent attributes:'
    for attr in client.__dict__:
        print attr, ':\t\t\t', client.__dict__[attr]
    print ''
    print ''
    print 'Objects being tracked: %s' % len(client.region.objects.object_store)
    print ''
    print ''
    states = {}
    for _object in client.region.objects.object_store:
        if str(client.agent_id) == str(_object.OwnerID):
            print "My OBJECT"
            print
            print
        if _object.State != None:
            print 'LocalID:', _object.LocalID, '\tUUID: ', _object.FullID, '\tState: ', _object.State, '\tPosition: ', _object.Position
        else:
            if states.has_key(_object.State):
                states[_object.State] += 1
            else:
                states[_object.State] = 1
    print ''
    print 'Object states I don\'t care about atm'
    for state in states:
        print '\t State: ', state, '\tFrequency: ', states[state]
    print ''
    print ''
    print 'Avatars being tracked: %s' % len(client.region.objects.avatar_store)
    print ''
    print ''
    for _avatar in client.region.objects.avatar_store:
        print 'ID:', _avatar.LocalID, '\tUUID: ', _avatar.FullID, '\tNameValue: ', _avatar.NameValue, '\tPosition: ', _avatar.Position
    print ''
    print ''
    print 'Region attributes:'
    for attr in client.region.__dict__:
        print attr, ':\t\t\t', client.region.__dict__[attr]
Exemple #26
0
    def test_create_new_item(self):

        self.inventory.agent = Agent()
        agent_id = UUID()
        agent_id.random()
        self.inventory.agent.agent_id = agent_id

        self.inventory.agent.region = DummyRegion()

        matches = self.inventory.search_inventory(self.inventory.folders,
                                                  name='My Inventory')
        self.assertEqual(len(matches), 1)
        folder = matches.pop()
        self.inventory.create_new_item(folder, "Name", "Desc",
                                       AssetType.LSLText, InventoryType.LSL,
                                       WearablesIndex.WT_SHAPE, 0)
        packet = self.inventory.agent.region.dummy_packet_holder.pop()
        self.assertEqual(packet.name, "CreateInventoryItem")

        self.assertEqual(packet['InventoryBlock'][0]['FolderID'],
                         folder.FolderID)
        self.assertEqual(packet['InventoryBlock'][0]['Name'], 'Name')
        self.assertEqual(packet['InventoryBlock'][0]['Description'], 'Desc')

        fake_uuid = UUID()
        fake_uuid.random()
        packet = Message(
            'UpdateCreateInventoryItem',
            Block('AgentData',
                  AgentID=UUID(),
                  SimApproved=True,
                  TransactionID=UUID()),
            Block('InventoryData',
                  ItemID=fake_uuid,
                  FolderID=folder.FolderID,
                  CallbackID=0,
                  CreatorID=agent_id,
                  OwnerID=agent_id,
                  GroupID=UUID(),
                  BaseMask=Permissions.All,
                  OwnerMask=Permissions.All,
                  GroupMask=Permissions.None_,
                  EveryoneMask=Permissions.None_,
                  NextOwnerMask=Permissions.None_,
                  GroupOwned=False,
                  AssetID=UUID(),
                  Type=AssetType.LSLText,
                  InvType=InventoryType.LSL,
                  Flags=0,
                  SaleType=0,
                  SalePrice=0,
                  Name="Name",
                  Description="Desc",
                  CreationDate=0,
                  CRC=0))
        self.inventory.agent.region.message_handler.handle(packet)
        matches = self.inventory.search_inventory(self.inventory.folders,
                                                  name="Name")
        self.assertEqual(len(matches), 1)
        item = matches.pop()
        self.assertEqual(item.Name, "Name")