Skip to content

Commit 65a0806

Browse files
committed
Fixes Issue 297 "Unresolved reference" in AdSense Management API samples
1 parent 49d2439 commit 65a0806

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

samples/adsense/generate_report.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17-
"""This example retrieves a report for the specified ad client.
17+
"""Retrieves a saved report or a report for the specified ad client.
1818
1919
To get ad clients, run get_all_ad_clients.py.
2020
@@ -31,9 +31,11 @@
3131

3232
# Declare command-line flags.
3333
argparser = argparse.ArgumentParser(add_help=False)
34-
argparser.add_argument('ad_client_id',
34+
argparser.add_argument(
35+
'--ad_client_id',
3536
help='The ID of the ad client for which to generate a report')
36-
argparser.add_argument('report_id',
37+
argparser.add_argument(
38+
'--report_id',
3739
help='The ID of the saved report to generate')
3840

3941

@@ -51,7 +53,7 @@ def main(argv):
5153
# Retrieve report.
5254
if saved_report_id:
5355
result = service.reports().saved().generate(
54-
savedReportId=saved_report_id).execute()
56+
savedReportId=saved_report_id).execute()
5557
elif ad_client_id:
5658
result = service.reports().generate(
5759
startDate='2011-01-01', endDate='2011-08-31',
@@ -62,8 +64,7 @@ def main(argv):
6264
dimension=['DATE'],
6365
sort=['+DATE']).execute()
6466
else:
65-
print ('Specify ad client id or saved report id!\nUsage: %s ARGS\\n%s'
66-
% (sys.argv[0], gflags.FLAGS))
67+
argparser.print_help()
6768
sys.exit(1)
6869
# Display headers.
6970
for header in result['headers']:

samples/adsense/get_all_custom_channels_for_ad_unit.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,16 @@
3030
from apiclient import sample_tools
3131
from oauth2client import client
3232

33-
import sys
34-
import gflags
35-
3633
# Declare command-line flags.
3734
argparser = argparse.ArgumentParser(add_help=False)
38-
argparser.add_argument('account_id',
35+
argparser.add_argument(
36+
'account_id',
3937
help='The ID of the account with the specified ad unit')
40-
argparser.add_argument('ad_client_id',
38+
argparser.add_argument(
39+
'ad_client_id',
4140
help='The ID of the ad client with the specified ad unit')
42-
argparser.add_argument('ad_unit_id',
41+
argparser.add_argument(
42+
'ad_unit_id',
4343
help='The ID of the ad unit for which to get custom channels')
4444

4545
MAX_PAGE_SIZE = 50

0 commit comments

Comments
 (0)