Fixes Issue 297 "Unresolved reference" in AdSense Management API samples
diff --git a/samples/adsense/generate_report.py b/samples/adsense/generate_report.py
index b6619d8..4ccc128 100644
--- a/samples/adsense/generate_report.py
+++ b/samples/adsense/generate_report.py
@@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-"""This example retrieves a report for the specified ad client.
+"""Retrieves a saved report or a report for the specified ad client.
To get ad clients, run get_all_ad_clients.py.
@@ -31,9 +31,11 @@
# Declare command-line flags.
argparser = argparse.ArgumentParser(add_help=False)
-argparser.add_argument('ad_client_id',
+argparser.add_argument(
+ '--ad_client_id',
help='The ID of the ad client for which to generate a report')
-argparser.add_argument('report_id',
+argparser.add_argument(
+ '--report_id',
help='The ID of the saved report to generate')
@@ -51,7 +53,7 @@
# Retrieve report.
if saved_report_id:
result = service.reports().saved().generate(
- savedReportId=saved_report_id).execute()
+ savedReportId=saved_report_id).execute()
elif ad_client_id:
result = service.reports().generate(
startDate='2011-01-01', endDate='2011-08-31',
@@ -62,8 +64,7 @@
dimension=['DATE'],
sort=['+DATE']).execute()
else:
- print ('Specify ad client id or saved report id!\nUsage: %s ARGS\\n%s'
- % (sys.argv[0], gflags.FLAGS))
+ argparser.print_help()
sys.exit(1)
# Display headers.
for header in result['headers']:
diff --git a/samples/adsense/get_all_custom_channels_for_ad_unit.py b/samples/adsense/get_all_custom_channels_for_ad_unit.py
index 5064c01..18d1632 100644
--- a/samples/adsense/get_all_custom_channels_for_ad_unit.py
+++ b/samples/adsense/get_all_custom_channels_for_ad_unit.py
@@ -30,16 +30,16 @@
from apiclient import sample_tools
from oauth2client import client
-import sys
-import gflags
-
# Declare command-line flags.
argparser = argparse.ArgumentParser(add_help=False)
-argparser.add_argument('account_id',
+argparser.add_argument(
+ 'account_id',
help='The ID of the account with the specified ad unit')
-argparser.add_argument('ad_client_id',
+argparser.add_argument(
+ 'ad_client_id',
help='The ID of the ad client with the specified ad unit')
-argparser.add_argument('ad_unit_id',
+argparser.add_argument(
+ 'ad_unit_id',
help='The ID of the ad unit for which to get custom channels')
MAX_PAGE_SIZE = 50