コード例 #1
0
def collect_ga(verbose = True):
    '''Collecting the latest Google Analytics data.'''
    print "%s Collecting Google Analytics data." % item('prompt_bullet')
    try:
        records = ga_collect.get_last_weeks_data()
        # print json.dumps(records)
        StoreRecords(data = records, table = "funnel")
        print "%s Google Analytics collection ran successfully." % item('prompt_success')
        return True

    except Exception as e:
        if verbose:
            print e
            return False

    print "%s Google Analytics failed to run." % item('prompt_error')
コード例 #2
0
def CheckOpenShift():
  '''Checking if the application is on an OpenShift environment.'''
  
  try:
    if os.environ['OPENSHIFT_REPO_DIR']:
      print "%s Application on OpenShift." % I.item('prompt_bullet')
      l = {
        "ip": os.environ['OPENSHIFT_PYTHON_IP'],
        "port": int(os.environ['OPENSHIFT_PYTHON_PORT'])
      }

  except Exception as e:
    print "%s Application not on OpenShift." % I.item('prompt_bullet')
    l = {
      "ip": '0.0.0.0',
      "port": 7000
    } 

  return l
コード例 #3
0
def WelcomeMessage(port):
  '''Welcome.'''
  print "%s server started on port %s." % (I.item('prompt_bullet'), port)
コード例 #4
0
# This should be called, not defined here.
def collect_ga(verbose = True):
    '''Collecting the latest Google Analytics data.'''
    print "%s Collecting Google Analytics data." % item('prompt_bullet')
    try:
        records = ga_collect.get_last_weeks_data()
        # print json.dumps(records)
        StoreRecords(data = records, table = "funnel")
        print "%s Google Analytics collection ran successfully." % item('prompt_success')
        return True

    except Exception as e:
        if verbose:
            print e
            return False

    print "%s Google Analytics failed to run." % item('prompt_error')


def main():
    '''Wrapper.'''
    collect_ga()
    CKANUsers.CollectDaily()
    CKANOrgs.CollectDaily()


if __name__ == "__main__":
  print "%s Running daily jobs." % item('prompt_bullet')
  main()