Exemple #1
0
    def __init__(self, router, r_id, samples, keyword="CommandArguments"):
        """
        Initializes the attributes of the translator
        
        Args:
            router: A reference to the router object using this receiver.
            r_id: The id of this receiver (usually "translator").
            samples: The number of samples being monitored.
            keyword: The name of the dictionary of command:[args] pairs for
                this translator to use.
        """
        super(TranslatorReceiver, self).__init__(router, r_id)

        self.cmd_args = utils.read_config_dict(keyword)
        self.num_samples = samples

        self.help_strings = utils.read_config_dict("HelpStrings")

        self.test_whitelist = utils.read_config_dict("TestWhiteList").values()
 def __init__(self, router, r_id, samples, keyword = "CommandArguments"):
     """
     Initializes the attributes of the translator
     
     Args:
         router: A reference to the router object using this receiver.
         r_id: The id of this receiver (usually "translator").
         samples: The number of samples being monitored.
         keyword: The name of the dictionary of command:[args] pairs for
             this translator to use.
     """
     super(TranslatorReceiver, self).__init__(router, r_id)
     
     self.cmd_args = utils.read_config_dict(keyword)
     self.num_samples = samples
     
     self.help_strings = utils.read_config_dict("HelpStrings")
     
     self.test_whitelist = utils.read_config_dict("TestWhiteList").values()
 def __init__(self, hasCamera = True):
     """
     Read the initialization dictionary for this class and initialize
     the board connection, camera connection, sample positions, and light
     states.
     """
     
     config_dict = utils.read_config_dict("CameraCommunicator")
     self._lights = None
     self._camera_positions = None
     
     #Initialization of board comm
     try:
         port = config_dict['arduino_port']
     except KeyError:
         port = default_dict['arduino_port']
     
     self._board_comm = self._connect(port)
     
     #Initialization of the Camera
     if hasCamera:
         self.cam = Camera(config_dict['camera_number'])
     
     #Initialization of the Lights
     try:
         self._lights = Lights(self._board_comm, 
                               config_dict['light_states'])
     except KeyError:
         self._lights = Lights(self._board_comm)
     
     #Initialization of the CameraPosition
     try:
         max_x = config_dict['max_x']
     except KeyError:
         max_x = default_dict['max_x']
     
     try:
         max_y = config_dict['max_y']
     except KeyError:
         max_y = default_dict['max_y']
         
     try:
         max_z = config_dict['max_z']
     except KeyError:
         max_z = default_dict['max_z']
         
     self._camera_positions = CameraPosition(self._board_comm, max_x, max_y, 
                                           max_z)
     
     #Set the sample positions
     self.sample_positions = []
     
     self._set_sample_pos(config_dict)
Exemple #4
0
    def __init__(self, hasCamera=True):
        """
        Read the initialization dictionary for this class and initialize
        the board connection, camera connection, sample positions, and light
        states.
        """

        config_dict = utils.read_config_dict("CameraCommunicator")
        self._lights = None
        self._camera_positions = None

        #Initialization of board comm
        try:
            port = config_dict['arduino_port']
        except KeyError:
            port = default_dict['arduino_port']

        self._board_comm = self._connect(port)

        #Initialization of the Camera
        if hasCamera:
            self.cam = Camera(config_dict['camera_number'])

        #Initialization of the Lights
        try:
            self._lights = Lights(self._board_comm,
                                  config_dict['light_states'])
        except KeyError:
            self._lights = Lights(self._board_comm)

        #Initialization of the CameraPosition
        try:
            max_x = config_dict['max_x']
        except KeyError:
            max_x = default_dict['max_x']

        try:
            max_y = config_dict['max_y']
        except KeyError:
            max_y = default_dict['max_y']

        try:
            max_z = config_dict['max_z']
        except KeyError:
            max_z = default_dict['max_z']

        self._camera_positions = CameraPosition(self._board_comm, max_x, max_y,
                                                max_z)

        #Set the sample positions
        self.sample_positions = []

        self._set_sample_pos(config_dict)
 def __init__(self):
     """
     Initializes the link between this app and Flickr API using stored 
     configuration values. Due to the way the Flickr API authorizes, the 
     first time a set of credentials are used on a given system, this must 
     be initialized within a context that allows a browser window to open and
     username and password to be entered.
     """
     
     config_dict = utils.read_config_dict("FlickrCommunicator")
     
     self.flickr = FlickrAPI(config_dict['api_key'], 
                             config_dict['api_secret'])
     
     self.app_name = config_dict['app_name']
     
     (token, frob) = self.flickr.get_token_part_one(perms='write')
     if not token: 
         raw_input("Press ENTER after you authorized this program")
         
     self.flickr.get_token_part_two((token, frob))
 def __init__(self, delay_time = [60, 5], last_id = None, 
              id_file_name = "default_id_file.txt", 
              twitter_auth_name = "Auth@cbrya_labtest"):
     """ 
     The initialization currently currently defaults to the @cbrya_labtest twitter
     oAuth credentials. It also initializes the various queues, times, and
     id-related variables.
     
     Args:
         delay_time: A list of the delay times needed. The first two are used.
         last_id: The tweet ID of the last processed tweet.
         id_file_name: The name of the file that stores the persistent ID 
             of the last tweet processed. 
         twitter_auth_name: The header name of the configuration entry that
             contains the authorization.
     """
     
     #Get the auth dictionary
     try:
         auth_dict = utils.read_config_dict(twitter_auth_name)
     
     #In case of failure, defaults to @cbrya_labtest
     except utils.BadConfigFileError:
         auth_dict = utils.read_config_dict("TwitterCommunicator")
     
     # The API object that will do the interaction with Twitter
     self.api = twitter.Api(auth_dict['con_key'], #@UndefinedVariable
                           auth_dict['con_sec_key'], 
                           auth_dict['acc_tkn'],  
                           auth_dict['acc_tkn_sec'])
     
     #This twitter accounts screen name. Stored to stay within twitter rate
     #limits.
     self.screen_name = self.api.VerifyCredentials().GetScreenName()
     
     #A queue to hold the unprocessed tweets             
     self.tweet_queue = deque()
     
     #A queue to hold the unsent twitter posts
     self.post_queue = deque()
     
     #Integer time delays to prevent getting rate limited
     self.get_delay_time = delay_time[0] #defaults to 60s (15 requests/15 min)
     self.post_delay_time = delay_time[1] #defaults to 5s (180 requests/15 min)
     
     #A time (in seconds) that will measure the time since the previous get
     #request from twitter
     self.get_request_time = time.time()
     
     #A time (in seconds) that will measure the time since the previous post
     #request from twitter
     self.post_request_time = time.time()
     
     #The filename of the file that holds the last twitter status processed
     self.id_file_name = id_file_name
     
     #The id of the last twitter status processed
     if(last_id == None):
         self.last_id = self._retrieve_last_id()
     else:
         self.last_id = last_id
Exemple #7
0
    def __init__(self,
                 delay_time=[60, 5],
                 last_id=None,
                 id_file_name="default_id_file.txt",
                 twitter_auth_name="Auth@cbrya_labtest"):
        """ 
        The initialization currently currently defaults to the @cbrya_labtest twitter
        oAuth credentials. It also initializes the various queues, times, and
        id-related variables.
        
        Args:
            delay_time: A list of the delay times needed. The first two are used.
            last_id: The tweet ID of the last processed tweet.
            id_file_name: The name of the file that stores the persistent ID 
                of the last tweet processed. 
            twitter_auth_name: The header name of the configuration entry that
                contains the authorization.
        """

        #Get the auth dictionary
        try:
            auth_dict = utils.read_config_dict(twitter_auth_name)

        #In case of failure, defaults to @cbrya_labtest
        except utils.BadConfigFileError:
            auth_dict = utils.read_config_dict("TwitterCommunicator")

        # The API object that will do the interaction with Twitter
        self.api = twitter.Api(
            auth_dict['con_key'],  #@UndefinedVariable
            auth_dict['con_sec_key'],
            auth_dict['acc_tkn'],
            auth_dict['acc_tkn_sec'])

        #This twitter accounts screen name. Stored to stay within twitter rate
        #limits.
        self.screen_name = self.api.VerifyCredentials().GetScreenName()

        #A queue to hold the unprocessed tweets
        self.tweet_queue = deque()

        #A queue to hold the unsent twitter posts
        self.post_queue = deque()

        #Integer time delays to prevent getting rate limited
        self.get_delay_time = delay_time[
            0]  #defaults to 60s (15 requests/15 min)
        self.post_delay_time = delay_time[
            1]  #defaults to 5s (180 requests/15 min)

        #A time (in seconds) that will measure the time since the previous get
        #request from twitter
        self.get_request_time = time.time()

        #A time (in seconds) that will measure the time since the previous post
        #request from twitter
        self.post_request_time = time.time()

        #The filename of the file that holds the last twitter status processed
        self.id_file_name = id_file_name

        #The id of the last twitter status processed
        if (last_id == None):
            self.last_id = self._retrieve_last_id()
        else:
            self.last_id = last_id