Commits

Anonymous committed e6561e3 Draft

better debug info

Comments (0)

Files changed (1)

     logger.debug('test')
     key, secret = args
 
-    client = FilmasterOAuthClient(key, secret, opts.access_token)
-    if not opts.access_token:
-        if opts.fb_access_token and not opts.callback_url:
-            request_token = client.fetch_request_token()
-            access_token = client.facebook_login(opts.fb_access_token)
-        else:
-            request_token = client.fetch_request_token()
-            authorize_url = client.get_authorize_url(request_token, callback_url=opts.callback_url)
-            print 'open in browser:', authorize_url
-            verifier = raw_input('oauth_verifier:')
-            access_token = client.fetch_access_token(request_token, verifier)
+    try:
+        client = FilmasterOAuthClient(key, secret, opts.access_token)
+        if not opts.access_token:
+            if opts.fb_access_token and not opts.callback_url:
+                request_token = client.fetch_request_token()
+                access_token = client.facebook_login(opts.fb_access_token)
+            else:
+                request_token = client.fetch_request_token()
+                authorize_url = client.get_authorize_url(request_token, callback_url=opts.callback_url)
+                print 'open in browser:', authorize_url
+                verifier = raw_input('oauth_verifier:')
+                access_token = client.fetch_access_token(request_token, verifier)
+        logger.info("access_token: %s", client.access_token)
 
-    logger.info("access_token: %s", client.access_token)
-
-    pprint(client.put('/1.1/profile/', {'latitude': '52.3', 'longitude': '21'}))
-
+        client.put('/1.1/profile/', {'latitude': '52.3', 'longitude': '21'})
+        pprint(client.get('/1.1/profile/'))
+    except urllib2.HTTPError, e:
+        print e.read()
+        raise
+    """
     today = datetime.date.today()
     showtimes = client.get('/1.1/profile/showtimes/%s/?limit=50&include=film' % today)
     for s in showtimes['objects']:
         print s['film']['guess_rating']
 
     pprint(client.get('/1.1/profile/meta/film/jestes-bogiem/?include=channels&date=%s' % today))
+    """