<s> import json <EOL> import pytest <EOL> import subprocess <EOL> import sys <EOL> from os . path import join , dirname <EOL> from . utils import info , fail <EOL> def pytest_addoption ( parser ) : <EOL> parser . addoption ( <EOL> "<STR_LIT>" , type = str , default = "<STR_LIT>" , help = "<STR_LIT>" <EOL> ) <EOL> def get_phantomjs_screenshot ( url , screenshot_path , wait , width = <NUM_LIT:1000> , height = <NUM_LIT:1000> ) : <EOL> """<STR_LIT>""" <EOL> phantomjs = pytest . config . getoption ( '<STR_LIT>' ) <EOL> cmd = [ phantomjs , join ( dirname ( __file__ ) , "<STR_LIT>" ) , url , screenshot_path , str ( wait ) , str ( width ) , str ( height ) ] <EOL> info ( "<STR_LIT>" % "<STR_LIT:U+0020>" . join ( cmd ) ) <EOL> try : <EOL> proc = subprocess . Popen ( cmd , stdout = subprocess . PIPE , stderr = subprocess . PIPE ) <EOL> proc . wait ( ) <EOL> except OSError : <EOL> fail ( "<STR_LIT>" % "<STR_LIT:U+0020>" . join ( cmd ) ) <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> return json . loads ( proc . stdout . read ( ) . decode ( "<STR_LIT:utf-8>" ) ) </s>
