def data(self, index, role):
     target = self.targets[index.row()]
     if index.isValid() and (0 <= index.row() < len(
             self.targets)) and target:
         column = index.column()
         if role == Qt.DecorationRole:
             if column == 1:
                 picturePath = os.path.join(GeneralUtilities.getTempDir(),
                                            target['targetPicture'])
                 if picturePath and os.path.exists(picturePath):
                     pixmap = QPixmap(picturePath)
                     return QIcon(
                         pixmap.scaled(30, 30, Qt.IgnoreAspectRatio,
                                       Qt.FastTransformation))
                 else:
                     pixmap = QPixmap(':/creepy/user')
                     pixmap.scaled(20, 20, Qt.IgnoreAspectRatio)
                     return QIcon(pixmap)
         if role == Qt.DisplayRole:
             if column == 0:
                 return QVariant(target['pluginName'])
             elif column == 1:
                 return QVariant()
             elif column == 2:
                 return QVariant(target['targetUsername'])
             elif column == 3:
                 return QVariant(target['targetFullname'])
             elif column == 4:
                 return QVariant(target['targetUserid'])
     else:
         return QVariant()
Example #2
0
    def searchForTargets(self, search_term):
        logger.debug('Attempting to search for targets. Search term was : ' +
                     search_term)
        possibleTargets = []
        try:
            if self.api is None:
                self.api = self.getAuthenticatedAPI()
            results = self.api.user_search(q=search_term)

            for i in results:
                target = {'pluginName': 'Instagram Plugin'}
                target['targetUserid'] = i.id
                target['targetUsername'] = i.username
                target['targetPicture'] = 'profile_pic_%s' % i.id
                target['targetFullname'] = i.full_name
                # save the pic in the temp folder to show it later
                filename = 'profile_pic_%s' % i.id
                temp_file = os.path.join(GeneralUtilities.getTempDir(),
                                         filename)
                if not os.path.exists(temp_file):
                    urllib.urlretrieve(i.profile_picture, temp_file)
                possibleTargets.append(target)
            logger.debug(
                str(len(possibleTargets)) +
                ' possible targets were found matching the search query')
        except Exception as err:
            logger.error('Error searching for targets with instagram plugin.')
            logger.error(err)
        return possibleTargets
Example #3
0
 def searchForTargets(self, search_term):
     possibleTargets = []
     logger.debug('Searching for Targets from Twitter Plugin. Search term is : ' + search_term)
     try:
         if self.api is None:
             self.api = self.getAuthenticatedAPI()
         search_results = self.api.search_users(q=search_term)
         if search_results:
             logger.debug('Twitter returned  ' + str(len(search_results)) + ' results')
             for i in search_results:
                 if self.options_boolean['exclude_geo_disabled'] == 'True' and not i.geo_enabled:
                     continue
                 target = {'pluginName': 'Twitter Plugin'}
                 target['targetUserid'] = i.id_str
                 target['targetUsername'] = i.screen_name
                 target['targetPicture'] = 'profile_pic_%s' % i.id_str
                 target['targetFullname'] = i.name
                 # save the pic in the temp folder to show it later
                 filename = 'profile_pic_%s' % i.id_str
                 temp_file = os.path.join(GeneralUtilities.getTempDir(), filename)
                 # Retieve and save the profile phot only if it does not exist
                 if not os.path.exists(temp_file):
                     urllib.urlretrieve(i.profile_image_url, temp_file)
                 possibleTargets.append(target)
     except tweepy.TweepError, e:
         logger.error('Error authenticating with Twitter API.')
         logger.error(e)
         if e.response.status_code == 429:
             remaining, limit, reset = self.getRateLimitStatus('search_users')
             return False, 'Error authenticating with Twitter: {0}. Your limits will be renewed at : {1}'.format(
                 e.message, reset.strftime('%Y-%m-%d %H:%M:%S %z'))
         return False, 'Error authenticating with Twitter: {0}'.format(e.message)
 def data(self, index, role):
     target = self.targets[index.row()]
     if index.isValid() and (0 <= index.row() < len(self.targets)) and target: 
         column = index.column()
         if role == Qt.DecorationRole:
             if column == 1:
                 picturePath = os.path.join(GeneralUtilities.getTempDir(),
                                            target['targetPicture'])
                 if picturePath and os.path.exists(picturePath):
                     pixmap = QPixmap(picturePath)
                     return QIcon(pixmap.scaled(30, 30, Qt.IgnoreAspectRatio, Qt.FastTransformation))
                 else:
                     pixmap = QPixmap(':/creepy/user')
                     pixmap.scaled(20, 20, Qt.IgnoreAspectRatio)
                     return QIcon(pixmap)
         if role == Qt.DisplayRole:
             if column == 0:
                 return QVariant(target['pluginName'])
             elif column == 1:
                 return QVariant()
             elif column == 2:
                 return QVariant(target['targetUsername'])
             elif column == 3:
                 return QVariant(target['targetFullname'])
             elif column == 4:
                 return QVariant(target['targetUserid'])
     else: 
         return QVariant()
Example #5
0
 def searchForTargets(self, search_term):
     possibleTargets = []
     logger.debug(
         'Searching for Targets from Twitter Plugin. Search term is : ' +
         search_term)
     try:
         if self.api is None:
             self.api = self.getAuthenticatedAPI()
         search_results = self.api.search_users(q=search_term)
         if search_results:
             logger.debug('Twitter returned  ' + str(len(search_results)) +
                          ' results')
             for i in search_results:
                 if self.options_boolean[
                         'exclude_geo_disabled'] == 'True' and not i.geo_enabled:
                     continue
                 target = {'pluginName': 'Twitter Plugin'}
                 target['targetUserid'] = i.id_str
                 target['targetUsername'] = i.screen_name
                 target['targetPicture'] = 'profile_pic_%s' % i.id_str
                 target['targetFullname'] = i.name
                 # save the pic in the temp folder to show it later
                 filename = 'profile_pic_%s' % i.id_str
                 temp_file = os.path.join(GeneralUtilities.getTempDir(),
                                          filename)
                 # Retieve and save the profile phot only if it does not exist
                 if not os.path.exists(temp_file):
                     urllib.urlretrieve(i.profile_image_url, temp_file)
                 possibleTargets.append(target)
     except tweepy.TweepError as e:
         logger.error('Error authenticating with Twitter API.')
         logger.error(e)
         if e.response.status_code == 429:
             remaining, limit, reset = self.getRateLimitStatus(
                 'search_users')
             return False, 'Error authenticating with Twitter: {0}. Your limits will be renewed at : {1}'.format(
                 e.message, reset.strftime('%Y-%m-%d %H:%M:%S %z'))
         return False, 'Error authenticating with Twitter: {0}'.format(
             e.message)
     except Exception as err:
         logger.error(err)
         logger.error('Error searching for targets in Twitter plugin.')
     return possibleTargets
Example #6
0
    def searchForTargets(self, search_term):
        logger.debug("Attempting to search for targets. Search term was : " + search_term)
        possibleTargets = []
        try:
            if self.api is None:
                self.api = self.getAuthenticatedAPI()
            results = self.api.user_search(q=search_term)

            for i in results:
                target = {'pluginName': 'Instagram Plugin'}
                target['targetUserid'] = i.id
                target['targetUsername'] = i.username
                target['targetPicture'] = 'profile_pic_%s' % i.id
                target['targetFullname'] = i.full_name
                # save the pic in the temp folder to show it later
                filename = 'profile_pic_%s' % i.id
                temp_file = os.path.join(GeneralUtilities.getTempDir(), filename)
                if not os.path.exists(temp_file):
                    urllib.urlretrieve(i.profile_picture, temp_file)
                possibleTargets.append(target)
            logger.debug(str(len(possibleTargets)) + " possible targets were found matching the search query")
        except Exception, err:
            logger.error("Error searching for targets with instagram plugin.")
            logger.error(err)