Skip to content

Commit

Permalink
Make run.py python 2 compatible only. Fixes web-platform-tests#120
Browse files Browse the repository at this point in the history
This aligns with all the other python code that W3C and browser vendors
use in their infrastructure.
  • Loading branch information
AutomatedTester committed Sep 22, 2017
1 parent 18c9d00 commit da85b9e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ matrix:
- "node"

- language: python
python: 3.4
python: 2.7
install: "pip install -r requirements.txt"
script:
- pep8 .
Expand Down
17 changes: 9 additions & 8 deletions run/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# limitations under the License.

import argparse
import configparser
import ConfigParser as configparser
import gzip
import json
import platform as host_platform
Expand Down Expand Up @@ -60,7 +60,6 @@


def main(platform_id, platform, args, config):
assert sys.version_info.major == 3, 'This script requires Python 3.'

print('PLATFORM_ID:', platform_id)
print('PLATFORM INFO:', platform)
Expand Down Expand Up @@ -133,7 +132,7 @@ def main(platform_id, platform, args, config):
config['gs_results_bucket'], SUMMARY_PATH
)

if config.getboolean('install_wptrunner'):
if config.get('install_wptrunner'):
print('==================================================')
print('Installing wptrunner')
command = ['pip', 'install', '--user', '-e', 'tools/wptrunner']
Expand Down Expand Up @@ -185,7 +184,6 @@ def main(platform_id, platform, args, config):

if args.path:
command.append(args.path)

return_code = subprocess.call(command, cwd=config['wpt_path'])

print('==================================================')
Expand Down Expand Up @@ -343,7 +341,7 @@ def write_gzip_json(filepath, payload):

with gzip.open(filepath, 'wb') as f:
payload_str = json.dumps(payload)
f.write(bytes(payload_str, 'UTF-8'))
f.write(payload_str, 'UTF-8')


def verify_gsutil_installed(config):
Expand All @@ -369,8 +367,11 @@ def get_config():
config.set('default',
key,
os.path.expandvars(config.get('default', key)))

return config['default']
conf = {}
for item in config.items('default'):
k, v = item
conf[k] = v
return conf


def patch_wpt(config, platform):
Expand All @@ -394,7 +395,7 @@ def patch_wpt(config, platform):
p = subprocess.Popen(
['git', 'apply', '-'], cwd=config['wpt_path'], stdin=subprocess.PIPE
)
p.communicate(input=bytes(patch, 'utf-8'))
p.communicate(input=patch)


def parse_args():
Expand Down
2 changes: 1 addition & 1 deletion run/run_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import unittest

from run.run import (
from run import (
report_to_summary,
version_string_to_major_minor
)
Expand Down

0 comments on commit da85b9e

Please sign in to comment.