<s> """<STR_LIT>""" <EOL> import tempfile <EOL> from googleads import dfp <EOL> from googleads import errors <EOL> ORDER_ID = '<STR_LIT>' <EOL> def main ( client , order_id ) : <EOL> line_item_service = client . GetService ( '<STR_LIT>' , version = '<STR_LIT>' ) <EOL> report_downloader = client . GetDataDownloader ( version = '<STR_LIT>' ) <EOL> values = [ { <EOL> '<STR_LIT:key>' : '<STR_LIT>' , <EOL> '<STR_LIT:value>' : { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:value>' : order_id <EOL> } <EOL> } ] <EOL> query = '<STR_LIT>' <EOL> statement = dfp . FilterStatement ( query , values ) <EOL> custom_field_ids = set ( ) <EOL> while True : <EOL> response = line_item_service . getLineItemsByStatement ( <EOL> statement . ToStatement ( ) ) <EOL> if '<STR_LIT>' in response : <EOL> for line_item in response [ '<STR_LIT>' ] : <EOL> if '<STR_LIT>' in line_item : <EOL> for custom_field_value in line_item [ '<STR_LIT>' ] : <EOL> custom_field_ids . add ( custom_field_value [ '<STR_LIT>' ] ) <EOL> statement . offset += dfp . SUGGESTED_PAGE_LIMIT <EOL> else : <EOL> break <EOL> filter_statement = { '<STR_LIT>' : query , '<STR_LIT>' : values } <EOL> report_job = { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> '<STR_LIT>' : filter_statement , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : list ( custom_field_ids ) <EOL> } <EOL> } <EOL> try : <EOL> report_job_id = report_downloader . WaitForReport ( report_job ) <EOL> except errors . DfpReportError , e : <EOL> print '<STR_LIT>' % e <EOL> export_format = '<STR_LIT>' <EOL> report_file = tempfile . NamedTemporaryFile ( suffix = '<STR_LIT>' , delete = False ) <EOL> report_downloader . DownloadReportToFile ( <EOL> report_job_id , export_format , report_file ) <EOL> report_file . close ( ) <EOL> print '<STR_LIT>' % ( <EOL> report_job_id , report_file . name ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> dfp_client = dfp . DfpClient . LoadFromStorage ( ) <EOL> main ( dfp_client , ORDER_ID ) </s>
