Add sample_generator.py and update samples to via generator.
Reviewed in: http://codereview.appspot.com/4449062/
diff --git a/samples/buzz/buzz.py b/samples/buzz/buzz.py
index 3d657b9..18f70b8 100644
--- a/samples/buzz/buzz.py
+++ b/samples/buzz/buzz.py
@@ -15,22 +15,22 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-"""Simple command-line example for Buzz.
+"""Simple command-line sample for Buzz.
-Command-line application that retrieves the users latest content and then adds
-a new entry.
+Command-line application that retrieves the users latest content and
+then adds a new entry.
Usage:
- $ python buzz.py.py
+ $ python buzz.py
You can also get help on all the command-line flags the program understands
by running:
- $ python buzz.py.py --help
+ $ python buzz.py --help
To get detailed log output run:
- $ python buzz.py.py --logging_level=DEBUG
+ $ python buzz.py --logging_level=DEBUG
"""
__author__ = 'jcgregorio@google.com (Joe Gregorio)'
@@ -53,8 +53,10 @@
# the information it needs to authenticate. Note that it is called
# the Web Server Flow, but it can also handle the flow for native
# applications <http://code.google.com/apis/accounts/docs/OAuth2.html#IA>
-# The client_id client_secret are copied from the Identity tab on
-# the Google APIs Console <http://code.google.com/apis/console>
+# The client_id client_secret are copied from the API Access tab on
+# the Google APIs Console <http://code.google.com/apis/console>. When
+# creating credentials for this application be sure to choose an Application
+# type of "Installed application".
FLOW = OAuth2WebServerFlow(
client_id='433807057907.apps.googleusercontent.com',
client_secret='jigtZpMApkRxncxikFpR+SFg',
@@ -85,7 +87,7 @@
# Credentials will get written back to a file.
storage = Storage('buzz.dat')
credentials = storage.get()
- if credentials is None or credentials.invalid == True:
+ if credentials is None or credentials.invalid:
credentials = run(FLOW, storage)
# Create an httplib2.Http object to handle our HTTP requests and authorize it
@@ -93,11 +95,8 @@
http = httplib2.Http()
http = credentials.authorize(http)
- # Build a service object for interacting with the API. Visit
- # the Google APIs Console <http://code.google.com/apis/console>
- # to get a developerKey for your own application.
- service = build("buzz", "v1", http=http,
- developerKey="AIzaSyDRRpR3GS1F1_jKNNM9HCNd2wJQyPG3oN0")
+ service = build("buzz", "v1", http=http)
+
activities = service.activities()
# Retrieve the first two activities
@@ -135,5 +134,7 @@
print 'Added a comment to the new activity'
pprint.pprint(comment)
+
+
if __name__ == '__main__':
main(sys.argv)