Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syntax Error with run_saved_query.py #295

Open
atlas-g0d opened this issue Jun 27, 2018 · 4 comments
Open

Syntax Error with run_saved_query.py #295

atlas-g0d opened this issue Jun 27, 2018 · 4 comments
Assignees
Labels

Comments

@atlas-g0d
Copy link

I get the following syntax error on line 39 of run_saved_query.py:

except errors.DfpReportError, e:
                            ^
SyntaxError: invalid syntax

Here's the snipet from code (starting on line 36) that I can't figure out how to format:

try:
  # Run the report and wait for it to finish.
  report_job_id = report_downloader.WaitForReport(report_job)
except errors.DfpReportError, e:
  print 'Failed to generate report. Error was: %s' % e
# Change to your preferred export format.
export_format = 'CSV_DUMP'

Is this a python version issue?

Thanks for the help!

@grivescorbett
Copy link
Contributor

Hi,

Thanks for writing in! This looks like it need to be updated. The syntax should be except errors.DfpReportError as e:

@atlas-g0d
Copy link
Author

Yeah, I tried that, too, but then got an indent error.

File "dfp_api_savedquery.py", line 40
    except errors.DfpReportError as e:
    ^
IndentationError: unexpected unindent

The indent seems right to me (with my 1-2 yrs python experience) so still trying to figure it out.

Thanks, @grivescorbett !

@grivescorbett
Copy link
Contributor

Weird, feel free to post to the DFP API Forum and we can give you a hand with the implementation over there.

@atlas-g0d
Copy link
Author

I got the code to work by doing the following:

  1. At line 57, change except errors.DfpReportError, e: to except errors.DfpReportErrorase:
  2. Make sure at line 57 - except errors.DfpReportError as e: stays under Try on line 54. Atom editor auto-adjusted the indention incorrectly so I had to move it back.
  3. All Print 'string' needs to be changed to Print('string')
  4. At line 39, change .WithBindVariable('id', long(saved_query_id)) to .WithBindVariable('id', int(saved_query_id))

Whala- everything ran after that. I know it has to do with the Python version (2 vs 3) but I am not familiar with how to work around the version changes. I'm sure there's some lib for that. I guess I'll figure that out eventually. Hope this helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants