Пример #1
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
    try:
        api.spawn(client.login, options.loginuri, args[0], args[1], password, start_location = options.region, connect_region = True)
    except LoginError, error:
        sys.exit()
Пример #2
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()
Пример #3
0
    def __init__(self, settings=None):
        """ initialize the AppEventsHandler """

        # allow the settings to be passed in
        # otherwise, grab the defaults
        if settings != None:
            self.settings = settings
        else:
            from pyogp.lib.client.settings import Settings
            self.settings = Settings()

        self.handlers = {}
Пример #4
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
Пример #5
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))
Пример #6
0
    def setUp(self):

        self.settings = Settings()
        self.settings.ENABLE_DEFERRED_PACKET_PARSING = False

        self.deserializer = UDPMessageDeserializer(settings=self.settings)

        self.region = Region()
        self.region.SimName = 'TestMe'

        self.object_store = ObjectManager(region=self.region,
                                          settings=self.settings,
                                          message_handler=MessageHandler())
        self.object_store.enable_callbacks()
        self.data = []
Пример #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
Пример #8
0
    def __init__(self, settings = None):
        """ initialize the agent manager """

        # allow the settings to be passed in
        # otherwise, grab the defaults
        if settings != None:
            self.settings = settings
        else:
            from pyogp.lib.client.settings import Settings
            self.settings = Settings()

        # store the agents in a dictionary keyed by a uuid
        # this could be agent_id, if we know it ahead of time
        # or, create a new one
        self.agents = {}

        # signal handler to capture erm signals
        self.signal_handler = signal.signal(signal.SIGINT, self.sigint_handler)

        if self.settings.LOG_VERBOSE: 
            logger.debug('Initializing agent manager for %s agents' % (len(self.agents)))
Пример #9
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]
Пример #10
0
    def __init__(self, settings = None, firstname = '', lastname = '', password = '', agent_id = None, events_handler = None, handle_signals=True):
        """ initialize this agent """

        # allow the settings to be passed in
        # otherwise, grab the defaults
        if settings != None:
            self.settings = settings
        else:
            from pyogp.lib.client.settings import Settings
            self.settings = Settings()

        # allow the eventhandler to be passed in
        # so that applications running multiple avatars
        # may use the same eventhandler

        # otherwise, let's just use our own
        if events_handler != None:
            self.events_handler = events_handler
        else:
            self.events_handler = AppEventsHandler()

        # signal handler to capture erm signals
        if handle_signals:
            self.signal_handler = signal.signal(signal.SIGINT, self.sigint_handler)

        # storage containers for agent attributes
        # we overwrite with what the grid tells us, rather than what
        # is passed in and stored in Login()
        self.firstname = firstname
        self.lastname = lastname
        self.password = password
        self.agent_id = None
        self.session_id = None
        self.local_id = None
        self.secure_session_id = None
        self.name = self.Name()
        self.active_group_powers = None
        self.active_group_name = None
        self.active_group_title = None
        self.active_group_id = None
        self.health = None
        self._login_params = None
        self.circuit_code = None

        # other storage containers
        self.inventory_host = None
        self.agent_access = None
        self.udp_blacklist = None
        self.home = None
        self.inventory = None
        self.start_location = None
        self.group_manager = GroupManager(self, self.settings)
        self.asset_manager = AssetManager(self, self.settings)
        self.map_service = MapService(self, self.settings)

        # additional attributes
        self.login_response = None
        self.connected = False
        self.grid_type = None
        self.running = True
        self.helpers = Helpers()

        # data we store as it comes in from the grid
        self.Position = Vector3()     # this will get updated later, but seed it with 000
        self.LookAt = Vector3()
        self.ActiveGroupID = UUID()

        # populated via ObjectUpdates
        self.FootCollisionPlane = Quaternion() 
        self.Velocity = Vector3()
        self.Acceleration = Vector3()
        self.Rotation = Vector3()
        self.AngularVelocity = Vector3()

        # movement
        self.state = AgentState.Null # typing, editing
        self.control_flags = 0
        self.agent_update_flags = AgentUpdateFlags.Null


        # should we include these here?
        self.agentdomain = None     # the agent domain the agent is connected to if an OGP context
        self.child_regions = []     # all neighboring regions
        self._pending_child_regions = []    # neighbor regions an agent may connect to
        self.region = None          # the host simulation for the agent

        # init AppearanceManager()
        self.appearance = AppearanceManager(self, self.settings)

        # Cache of agent_id->(first_name, last_name); per agent to prevent info leaks
        self.agent_id_map = {}

        if self.settings.LOG_VERBOSE: 
            logger.debug('Initializing agent: %s' % (self))
Пример #11
0
    def __init__(self, region, agent, RequestResult = None, SequenceID = None, SnapSelection = None, SelfCount = None, OtherCount = None, PublicCount = None, LocalID = None, OwnerID = None, IsGroupOwned = None, AuctionID = None, ClaimDate = None, ClaimPrice = None, RentPrice = None, AABBMin = None, AABBMax = None, Bitmap = None, Area = None, Status = None, SimWideMaxPrims = None, SimWideTotalPrims = None, MaxPrims = None, TotalPrims = None, OwnerPrims = None, GroupPrims = None, OtherPrims = None, SelectedPrims = None, ParcelPrimBonus = None, OtherCleanTime = None, ParcelFlags = None, SalePrice = None, Name = None, Desc = None, MusicURL = None, MediaURL = None, MediaID = None, MediaAutoScale = None, GroupID = None, PassPrice = None, PassHours = None, Category = None, AuthBuyerID = None, SnapshotID = None, UserLocation = None, UserLookAt = None, LandingType = None, RegionPushOverride = None, RegionDenyAnonymous = None, RegionDenyIdentified = None, RegionDenyTransacted = None, RegionDenyAgeUnverified = None, ParcelID = None, ActualArea = None, BillableArea = None, Flags = None, GlobalX = None, GlobalY = None, GlobalZ = None, SimName = None, Dwell = None, settings = None):
        """ initialize a representation of a parcel. the data is currently being populated directly from the ParcelProperties message """

        # allow the settings to be passed in
        # otherwise, grab the defaults
        if settings != None:
            self.settings = settings
        else:
            from pyogp.lib.client.settings import Settings
            self.settings = Settings()

        self.region = region
        self.agent = agent

        # mapping values from the ParcelProperties message
        # not all properties will ultimately live here, but for now
        # mapping all of them will do

        # from ParcelInfoReply
        self.ParcelID = ParcelID
        self.OwnerID = OwnerID
        self.ActualArea = ActualArea
        self.BillableArea = BillableArea
        self.Flags = Flags
        self.GlobalX = GlobalX
        self.GlobalY = GlobalY
        self.GlobalZ = GlobalZ
        self.SimName = SimName
        self.Dwell = Dwell
        self.AuctionID = AuctionID

        # from ParcelProperties
        self.RequestResult = RequestResult 
        self.SequenceID = SequenceID 
        self.SnapSelection = SnapSelection 
        self.SelfCount = SelfCount 
        self.OtherCount = OtherCount 
        self.PublicCount = PublicCount 
        self.LocalID = LocalID 
        self.OwnerID = OwnerID 
        self.IsGroupOwned = IsGroupOwned 
        self.AuctionID = AuctionID 
        self.ClaimDate = ClaimDate 
        self.ClaimPrice = ClaimPrice 
        self.RentPrice = RentPrice 
        self.AABBMin = AABBMin 
        self.AABBMax = AABBMax 
        self.Bitmap = Bitmap 
        self.Area = Area 
        self.Status = Status 
        self.SimWideMaxPrims = SimWideMaxPrims 
        self.SimWideTotalPrims = SimWideTotalPrims 
        self.MaxPrims = MaxPrims 
        self.TotalPrims = TotalPrims 
        self.OwnerPrims = OwnerPrims 
        self.GroupPrims = GroupPrims 
        self.OtherPrims = OtherPrims 
        self.SelectedPrims = SelectedPrims 
        self.ParcelPrimBonus = ParcelPrimBonus 
        self.OtherCleanTime = OtherCleanTime 
        self.ParcelFlags = ParcelFlags 
        self.SalePrice = SalePrice 
        self.Name = Name 
        self.Desc = Desc 
        self.MusicURL = MusicURL 
        self.MediaURL = MediaURL 
        self.MediaID = MediaID 
        self.MediaAutoScale = MediaAutoScale 
        self.GroupID = GroupID 
        self.PassPrice = PassPrice 
        self.PassHours = PassHours 
        self.Category = Category 
        self.AuthBuyerID = AuthBuyerID 
        self.SnapshotID = SnapshotID 
        self.UserLocation = UserLocation 
        self.UserLookAt = UserLookAt 
        self.LandingType = LandingType 
        self.RegionPushOverride = RegionPushOverride 
        self.RegionDenyAnonymous = RegionDenyAnonymous 
        self.RegionDenyIdentified = RegionDenyIdentified 
        self.RegionDenyTransacted = RegionDenyTransacted 
        self.RegionDenyAgeUnverified = RegionDenyAgeUnverified 
Пример #12
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

    #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]
Пример #13
0
    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
    settings.ACCEPT_INVENTORY_OFFERS = True

    agents = []

    # Now let's prime the accounts for login
    for params in clients:
        #First, initialize the agent
Пример #14
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")

    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]
Пример #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("-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)
Пример #17
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]
Пример #18
0
Licensed under the Apache License, Version 2.0.
You may obtain a copy of the License at:
    http://www.apache.org/licenses/LICENSE-2.0
or in 
    http://svn.secondlife.com/svn/linden/projects/2008/pyogp/lib/base/LICENSE.txt

$/LicenseInfo$
"""

# std lib
import logging

#pyogp
from pyogp.lib.client.settings import Settings

settings = Settings()
debug = settings.ENABLE_LOGGING_IN_TESTS

#setup logging

if debug: 

    console = logging.StreamHandler()
    console.setLevel(logging.DEBUG) # seems to be a no op, set it for the logger
    formatter = logging.Formatter('%(asctime)-30s%(name)-15s: %(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.
Пример #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(
        "-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
Пример #20
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
Пример #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 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]
Пример #22
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]
Пример #23
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("-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]
Пример #24
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)
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]