Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .test-infra/jenkins/dependency_check/bigquery_client_utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import print_function
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
Expand Down Expand Up @@ -101,7 +102,7 @@ def insert_dep_to_table(self, dep, version, release_date, is_currently_used=Fals
try:
query_job = self.bigquery_client.query(query)
if not query_job.done():
print query_job.result()
print(query_job.result())
except:
raise

Expand All @@ -123,7 +124,7 @@ def delete_dep_from_table(self, dep, version):
try:
query_job = self.bigquery_client.query(query)
if not query_job.done():
print query_job.result()
print(query_job.result())
except:
raise

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def extract_results(file_path):
see_oudated_deps = True
raw_report.close()
return outdated_deps
except Exception, e:
except Exception as e:
raise


Expand Down Expand Up @@ -266,7 +266,7 @@ def generate_report(file_path, sdk_type, project_id, dataset_id, table_id):
for dep in high_priority_deps:
report.write("%s" % dep)
report.write("</table>\n")
except Exception, e:
except Exception as e:
report.write('<p> {0} </p>'.format(str(e)))

report.close()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
# This script performs testing of scenarios from verify_performance_test_results.py
#

from __future__ import print_function
import unittest, mock
from mock import patch
from datetime import datetime
Expand All @@ -39,7 +40,7 @@ class DependencyCheckReportGeneratorTest(unittest.TestCase):
"""Tests for `dependency_check_report_generator.py`."""

def setUp(self):
print "Test name:", self._testMethodName
print("Test name:", self._testMethodName)


@patch('google.cloud.bigquery.Client')
Expand Down
2 changes: 1 addition & 1 deletion sdks/python/apache_beam/runners/worker/sdk_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def _request_process_bundle_progress(self, request):
def task():
instruction_reference = getattr(
request, request.WhichOneof('request')).instruction_reference
if self._instruction_id_vs_worker.has_key(instruction_reference):
if instruction_reference in self._instruction_id_vs_worker:
self._execute(
lambda: self._instruction_id_vs_worker[
instruction_reference
Expand Down
4 changes: 2 additions & 2 deletions sdks/python/apache_beam/runners/worker/sdk_worker_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,10 @@ def _get_worker_count(pipeline_options):
an int containing the worker_threads to use. Default is 1
"""
pipeline_options = pipeline_options.get(
'options') if pipeline_options.has_key('options') else {}
'options') if 'options' in pipeline_options else {}
experiments = pipeline_options.get(
'experiments'
) if pipeline_options and pipeline_options.has_key('experiments') else []
) if pipeline_options and 'experiments' in pipeline_options else []

experiments = experiments if experiments else []

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ class WorkerIdInterceptor(grpc.StreamStreamClientInterceptor):
# and throw exception in worker_id_interceptor.py after we have rolled out
# the corresponding container changes.
# Unique worker Id for this worker.
_worker_id = os.environ['WORKER_ID'] if os.environ.has_key(
'WORKER_ID') else str(uuid.uuid4())
_worker_id = os.environ.get('WORKER_ID', str(uuid.uuid4()))

def __init__(self):
pass
Expand Down
2 changes: 1 addition & 1 deletion sdks/python/apache_beam/tools/map_fn_microbenchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def run_benchmark(num_maps=100, num_runs=10, num_elements_step=1000):
print("%6d element%s %g sec" % (
num_elements, " " if num_elements == 1 else "s", timings[num_elements]))

print
print()
# pylint: disable=unused-variable
gradient, intercept, r_value, p_value, std_err = stats.linregress(
*list(zip(*list(timings.items()))))
Expand Down
12 changes: 9 additions & 3 deletions website/.jenkins/append_index_html_to_internal_links.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,18 @@
'sudo apt-get install python-beautifulsoup4'.

"""
from __future__ import print_function
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The website source code is currently being migrated from https://github.com/apache/beam-site, but is not yet ready. Website changes in apache/beam will be overwritten on next merge. Please contribute changes at apache/beam-site according to the website contribution guide. You can track migration progress via [BEAM-4493].

Do you know if this change was also made in the apache/beam-site repository? If not, it will need to be migrated.


import fnmatch
import os
import re
from bs4 import BeautifulSoup

try:
unicode # pylint: disable=unicode-builtin
except NameError:
unicode = str

# Original link match. Matches any string which starts with '/' and doesn't
# have a file extension.
linkMatch = r'^\/(.*\.(?!([^\/]+)$))?[^.]*$'
Expand All @@ -56,10 +62,10 @@
if 'javadoc' not in root:
matches.append(os.path.join(root, filename))

print 'Matches: ' + str(len(matches))
print('Matches: ' + str(len(matches)))
# Iterates over each matched file looking for link matches.
for match in matches:
print 'Fixing links in: ' + match
print('Fixing links in: ' + match)
mf = open(match)
soup = BeautifulSoup(mf)
# Iterates over every <a>
Expand All @@ -86,7 +92,7 @@
html = unicode(soup).encode('utf-8')
# Write back to the file.
with open(match, "wb") as f:
print 'Replacing ' + hr + ' with: ' + a['href']
print('Replacing ' + hr + ' with: ' + a['href'])
f.write(html)
except KeyError as e:
# Some <a> tags don't have an href.
Expand Down