Пример #1
0
    def run_plugin(self):
        api_key_file = open(plugin.get_plugin_file_location(PLUGIN_NAME,'li_api_key'));
        try:
            self.API_KEY = api_key_file.readline();
        finally:
            api_key_file.close();
        secret_key_file = open(plugin.get_plugin_file_location(PLUGIN_NAME,'li_secret_key'));
        try:
            self.SECRET_KEY = secret_key_file.readline();
        finally:
            secret_key_file.close();

        self.li = linkedin.LinkedIn(self.API_KEY, self.SECRET_KEY);
        self.access_token = self.retrieve_access_token()
Пример #2
0
 def configure(self, data=None):
     if data is None:
         data = {}
         plugin.ensure_plugin_config_store_exist(PLUGIN_NAME)
         token = self.li.getRequestToken(None);
         data['token'] = token
         url = self.li.getAuthorizeUrl(token);
         data[plugin.PLUGIN_CONF_INFO] = "visit the provided url to authorize Zourite to access your LinkedIn account." \
                                         " LinkedIn will give you a verifierNote the verifier number that Zourite will ask you for." 
         data[plugin.PLUGIN_CONF_WEBBROWSER] = url
         data['verifier'] = None
         data[plugin.PLUGIN_CONF_STEP] = "VERIFIER"
         return data
     
     elif data[plugin.PLUGIN_CONF_STEP] == 'VERIFIER':
         verifier = int(data["verifier"])
         token = data['token']
         access_token = self.li.getAccessToken(token, verifier);
         try:
             access_token_file = open(plugin.get_plugin_file_location(PLUGIN_NAME,'li_access_token'),'wb');
             pickle.dump(access_token,access_token_file)
             access_token_file.close()
         except IOError:
             logging.warning("the access token could not be saved")
         return {}
     else :
         raise plugin.ConfigurationRequiredExeption() # may raise a specific 
Пример #3
0
    def retrieve_access_token(self):
        # essaye de charger l'acces token
        try:
            access_token_file = open(plugin.get_plugin_file_location(PLUGIN_NAME,'li_access_token'),'rb');
            access_token = pickle.load(access_token_file)
        except IOError:
            # pas d'acess token on en génère un autre
            raise plugin.ConfigurationRequiredExeption()            

        return access_token;
Пример #4
0
 def _retrieve_gmail_credential(self):
     # essaye de charger l'acces token
     try:
         gmail_file = open(plugin.get_plugin_file_location(PLUGIN_NAME,'gmail_credential'),'rb');
         gmail_credential = pickle.load(gmail_file)
         gmail_file.close()
     except IOError:
         # pas d'acess token on en génère un autre
         raise plugin.ConfigurationRequiredExeption()            
 
     return gmail_credential;
Пример #5
0
    def _configure_gmail_account(self, user, password):
 
        gc = GmailCredential()
        gc.email = user
        gc.password = password
        try:
            gmail_file = open(plugin.get_plugin_file_location(PLUGIN_NAME,'gmail_credential'),'wb');
            pickle.dump(gc,gmail_file)
            gmail_file.close()
        except IOError:
            logging.warning("the access token could not be saved")
        
        return gc
Пример #6
0
 def _configure_gmail_account(self):
     '''
     launch the configuration wizard
     '''
     #TODO this is only a consol wizardn need to be more generic... 
     gc = GmailCredential()
     gc.email = raw_input("Please gmail account: ")
     gc.password = raw_input("Please gmail password: "******"the access token could not be saved")
     
     return gc
Пример #7
0
 def generate_new_access_token(self):
     # lance le processus d'authentification aupres de linkedIn
     # pour avoir un acess token
     token = self.li.getRequestToken(None);
     url = self.li.getAuthorizeUrl(token);
     # ouvre un navigateur pour que l'utilisateur autorise l'acc_s à son compte
     webbrowser.open_new_tab(url);
     # saisi du code de verification
     verifier = int(raw_input("Please enter the verifier number: "))
     access_token = self.li.getAccessToken(token, verifier);
     try:
         access_token_file = open(plugin.get_plugin_file_location(PLUGIN_NAME,'li_access_token'),'wb');
         pickle.dump(access_token,access_token_file)
         access_token_file.close()
     except IOError:
         logging.warning("the access token could not be saved")
     
     return access_token;
Пример #8
0
    def __init__(self, entry, hosted_image_binary):
        plugin.ShortProfile.__init__(self)
        Person.__init__(self, entry)
        
        if hosted_image_binary is None :
            self.picture = plugin.ImageProxyNone()
        else:
            filename = self.id
            file = plugin.get_plugin_file_location(PLUGIN_NAME, filename )
            image_file = open(file, 'wb')
            image_file.write(hosted_image_binary)
            image_file.close()
            self.picture = plugin.ImageProxyFile(PLUGIN_NAME, filename)

        # TODO should choose the work labeled one
        if len(entry.email) > 0 :
             self.email =  entry.email[0].address
        
        if len(entry.phone_number) > 0:
            self.phone = entry.phone_number[0].text