Esempio n. 1
0
 def raise_exception(self):
     if exc_type == 'GAE':
         raise GoogleAdsError('Test GAM Error')
     if exc_type == 'RNA':
         raise ResourceNotActive('Test')
     if exc_type == 'RNF':
         raise ResourceNotFound('Test')
     if exc_type == 'KI':
         raise KeyboardInterrupt()
Esempio n. 2
0
  def GetCampaigns(self, client_customer_id):
    """Returns a client account's Campaigns that haven't been removed.

    Args:
      client_customer_id: str Client Customer Id used to retrieve Campaigns.

    Returns:
      list List of Campaign data objects.
    """
    self.client.SetClientCustomerId(client_customer_id)
    # A somewhat hackish workaround for "The read operation timed out" error,
    # which could be triggered on AppEngine's end if the request is too large
    # and is taking too long.
    max_tries = 3
    today = time.strftime('%Y%m%d', time.localtime())
    for i in xrange(1, max_tries + 1):
      try:
        selector = {
            'fields': ['Id', 'Name', 'Status', 'BudgetId', 'Amount'],
            'predicates': [
                {
                    'field': 'Status',
                    'operator': 'NOT_EQUALS',
                    'values': ['REMOVED']
                }
            ],
            'dateRange': {
                'min': today,
                'max': today
            }
        }
        campaigns = self.client.GetService('CampaignService').get(selector)
        if int(campaigns['totalNumEntries']) > 0:
          return campaigns['entries']
        else:
          return None
      except Exception, e:
        if i == max_tries:
          raise GoogleAdsError(e)
        continue
Esempio n. 3
0
 def raise_exception(self):
     raise GoogleAdsError('Test GAM Error')
Esempio n. 4
0
 def raise_exception(self):
     raise GoogleAdsError('Test Network')