-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
35 lines (29 loc) · 920 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import yaml
import cgi
import wsgiref.handlers
from google.appengine.ext import (
webapp, db
)
from gdata.analytics.client import (
AnalyticsClient, ProfileQuery
)
from google.appengine.api import urlfetch
urlfetch.set_default_fetch_deadline(60)
class GoogleAccount(db.Model):
email = db.StringProperty(required=True)
password = db.StringProperty(required=True)
class AnalyticsTest(webapp.RequestHandler):
def get(self):
account = GoogleAccount.all().fetch(1)[0]
client = AnalyticsClient()
client.ClientLogin(account.email, account.password, 'gpc-test')
profile_query = ProfileQuery()
feed = client.GetMgmtFeed(profile_query)
self.response.out.write(yaml.dump(feed))
application = webapp.WSGIApplication([
('/', AnalyticsTest)
], debug=True)
def main():
wsgiref.handlers.CGIHandler().run(application)
if __name__ =='__main__':
main()