Skip to content
Closed
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
17 changes: 12 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,20 @@ sudo: false
python:
- "2.6"
- "2.7"
install:
#- "3.4"
before_install:
- "./.travis_python_dep.sh"
install: true
#- pip install pep8 --use-mirrors
#- pip install pyflakes --use-mirrors
- pip install robotframework
- pip install selenium
- pip install decorator
- pip install docutils
# Installation is done at before_install
##- pip install robotframework==3.0b1
##- pip install selenium
##- pip install decorator
##- pip install docutils
##- pip install future
# Mockito is only used when in Python 2.7 after installing future
##- pip install mockito
#- "if [[ ${BROWSER} == 'ie' ]]; then pip install ie_only_pkg; fi"
before_script:
- "export DISPLAY=:99.0"
Expand Down
24 changes: 24 additions & 0 deletions .travis_python_dep.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash
set -ev
PYTHON_VERSION=`python -c "import sys; print(sys.version[:3])"`
if [ "${PYTHON_VERSION}" = "2.6" ]; then
pip install robotframework==2.9.2
pip install selenium
pip install decorator
pip install docutils
# pip install future
# pip install mockito
elif [ "${PYTHON_VERSION}" = "2.7" ]; then
pip install robotframework
pip install selenium
pip install decorator
pip install docutils
# pip install future
# pip install mockito
elif [ "${PYTHON_VERSION}" = "3.4" ]; then
pip install robotframework==3.0b1
pip install selenium
pip install decorator
pip install docutils
pip install future
fi
17 changes: 9 additions & 8 deletions build_dist.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python

from __future__ import print_function
import os, sys, shutil, subprocess, argparse

THIS_DIR = os.path.dirname(os.path.abspath(__file__))
Expand All @@ -9,9 +10,9 @@
sys.path.append(os.path.join(THIS_DIR, "demo"))

def main():
parser = argparse.ArgumentParser(description="Builds a Se2Lib distribution")
parser.add_argument('py_26_path', action='store', help='Python 2.6 executbale file path')
parser.add_argument('py_27_path', action='store', help='Python 2.7 executbale file path')
parser = argparse.ArgumentParser(description="Builds a Selenium2Library distribution")
parser.add_argument('py_26_path', action='store', help='Python 2.6 executable file path')
parser.add_argument('py_27_path', action='store', help='Python 2.7 executable file path')
parser.add_argument('--release', action='store_true')
parser.add_argument('--winonly', action='store_true')
args = parser.parse_args()
Expand All @@ -33,7 +34,7 @@ def clear_dist_folder():

def run_doc_gen():
import generate
print
print()
generate.main()

def run_register(args):
Expand All @@ -50,12 +51,12 @@ def run_builds(args):
_run_setup(args.py_27_path, "bdist_wininst", [ "--plat-name=win32" ], args.release)
_run_setup(args.py_27_path, "bdist_wininst", [ "--plat-name=win-amd64" ], args.release)
else:
print
print()
print("Windows binary installers cannot be built on this platform!")

def run_demo_packaging():
import package
print
print()
package.main()

def _run_setup(py_path, type, params, upload):
Expand All @@ -66,8 +67,8 @@ def _run_setup(py_path, type, params, upload):
if upload:
setup_args.append("upload")

print
print("Running: %s" % ' '.join(setup_args))
print()
print("Running: {0}".format(' '.join(setup_args)))
returncode = subprocess.call(setup_args)
if returncode != 0:
print("Error running setup.py")
Expand Down
12 changes: 7 additions & 5 deletions demo/demoapp/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import print_function

"""Simple HTTP server requiring only Python and no other preconditions.

Server is started by running this script with argument 'start' and
Expand Down Expand Up @@ -55,25 +57,25 @@ def do_QUIT(self):
def do_POST(self):
# We could also process paremeters here using something like below.
# length = self.headers['Content-Length']
# print self.rfile.read(int(length))
# print(self.rfile.read(int(length)))
self.do_GET()


def start_server(host=DEFAULT_HOST, port=DEFAULT_PORT):
print "Demo application starting on port %s" % port
print("Demo application starting on port {0}".format(port))
root = os.path.dirname(os.path.abspath(__file__))
os.chdir(root)
server = StoppableHttpServer((host, int(port)), StoppableHttpRequestHandler)
server.serve_forever()

def stop_server(host=DEFAULT_HOST, port=DEFAULT_PORT):
print "Demo application on port %s stopping" % port
print("Demo application on port {0} stopping".format(port))
conn = httplib.HTTPConnection("%s:%s" % (host, port))
conn.request("QUIT", "/")
conn.getresponse()

def print_help():
print __doc__
print(__doc__)


if __name__ == '__main__':
Expand All @@ -82,4 +84,4 @@ def print_help():
'stop': stop_server,
'help': print_help}[sys.argv[1]](*sys.argv[2:])
except (IndexError, KeyError, TypeError):
print 'Usage: %s start|stop|help [port]' % os.path.basename(sys.argv[0])
print("Usage: {0} start|stop|help [port]".format(os.path.basename(sys.argv[0])))
6 changes: 4 additions & 2 deletions demo/package.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env python

from __future__ import print_function

import os, sys
from time import localtime
from zipfile import ZipFile, ZIP_DEFLATED
Expand All @@ -26,14 +28,14 @@ def main():
for dirname in FILES:
for filename in FILES[dirname]:
path = os.path.join('.', dirname.replace('/', os.sep), filename)
print 'Adding: ', os.path.normpath(path)
print("Adding: {0}".format(os.path.normpath(path)))
zipfile.write(path, os.path.join(name, path))
zipfile.close()
target_path = os.path.join('..', 'dist', zipname)
if os.path.exists(target_path):
os.remove(target_path)
os.rename(zipname, target_path)
print 'Created: ', os.path.abspath(target_path)
print("Created: {0}".format(os.path.abspath(target_path)))
finally:
os.chdir(cwd)

Expand Down
16 changes: 9 additions & 7 deletions demo/rundemo.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#! /usr/bin/env python

from __future__ import print_function

"""Runner Script for Robot Framework SeleniumLibrary Demo

Tests are run by giving a path to the tests to be executed as an argument to
Expand Down Expand Up @@ -33,9 +35,9 @@
try:
import Selenium2Library
except ImportError, e:
print 'Importing Selenium2Library module failed (%s).' % e
print 'Please make sure you have Selenium2Library properly installed.'
print 'See INSTALL.rst for troubleshooting information.'
print("Importing Selenium2Library module failed ({0})".format(e))
print("Please make sure you have Selenium2Library properly installed.")
print("See INSTALL.rst for troubleshooting information.")
sys.exit(1)


Expand All @@ -55,12 +57,12 @@ def stop_demo_application():
call(['python', DEMOAPP, 'stop'], stdout=TemporaryFile(), stderr=STDOUT)

def print_help():
print __doc__
print(__doc__)

def print_usage():
print 'Usage: rundemo.py [options] datasource'
print ' or: rundemo.py demoapp start|stop'
print ' or: rundemo.py help'
print("Usage: rundemo.py [options] datasource")
print(" or: rundemo.py demoapp start|stop")
print(" or: rundemo.py help")


if __name__ == '__main__':
Expand Down
12 changes: 6 additions & 6 deletions doc/buildhtml.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# Author: David Goodger <goodger@python.org>
# Copyright: This module has been placed in the public domain.

from __future__ import print_function
"""
Generates .html from all the .txt files in a directory.

Expand All @@ -29,7 +30,7 @@
import docutils
from docutils import ApplicationError
from docutils import core, frontend, utils
from docutils.error_reporting import ErrorOutput, ErrorString
from docutils.utils.error_reporting import ErrorOutput, ErrorString
from docutils.parsers import rst
from docutils.readers import standalone, pep
from docutils.writers import html4css1, pep_html
Expand Down Expand Up @@ -197,13 +198,12 @@ def visit(self, directory, names):
settings = self.get_settings('', directory)
errout = ErrorOutput(encoding=settings.error_encoding)
if settings.prune and (os.path.abspath(directory) in settings.prune):
print >>errout, ('/// ...Skipping directory (pruned): %s' %
directory)
print("/// ...Skipping directory (pruned): {0}".format(directory), file=errout)
sys.stderr.flush()
names[:] = []
return
if not self.initial_settings.silent:
print >>errout, '/// Processing directory: %s' % directory
print("/// Processing directory: {0}".format(directory), file=errout)
sys.stderr.flush()
# settings.ignore grows many duplicate entries as we recurse
# if we add patterns in config files or on the command line.
Expand Down Expand Up @@ -232,7 +232,7 @@ def process_txt(self, directory, name):
settings._source = os.path.normpath(os.path.join(directory, name))
settings._destination = settings._source[:-4]+'.html'
if not self.initial_settings.silent:
print >>errout, ' ::: Processing: %s' % name
print(" ::: Processing: {0}".format(name), file=errout)
sys.stderr.flush()
try:
if not settings.dry_run:
Expand All @@ -243,7 +243,7 @@ def process_txt(self, directory, name):
writer_name=pub_struct.writer_name,
settings=settings)
except ApplicationError, error:
print >>errout, ' %s' % ErrorString(error)
print(" {0}".format(ErrorString(error)), file=errout)


if __name__ == "__main__":
Expand Down
7 changes: 5 additions & 2 deletions doc/generate.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
#!/usr/bin/env python

from __future__ import print_function
from os.path import join, dirname

try:
from robot.libdoc import libdoc
except:
def main():
print """Robot Framework 2.7 or later required for generating documentation"""
print('"""Robot Framework 2.7 or later required for generating documentation"""')
else:
def main():
libdoc(join(dirname(__file__),'..','src','Selenium2Library'), join(dirname(__file__),'Selenium2Library.html'))


if __name__ == '__main__':
main()
main()
6 changes: 4 additions & 2 deletions doc/generate_readmes.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#!/usr/bin/env python

from __future__ import print_function
import os, shutil
from buildhtml import Builder


THIS_DIR = os.path.dirname(os.path.abspath(__file__))
ROOT_DIR = os.path.join(THIS_DIR, "..")
SRC_DIR = os.path.join(ROOT_DIR, "src")
Expand All @@ -19,7 +21,7 @@ def main():
try:
import docutils
except:
print "Readme files will not be built into HTML, docutils not installed"
print("Readme files will not be built into HTML, docutils not installed")
return
for readme_relative_path in README_FILES:
(readme_dir, readme_name) = _parse_readme_path(readme_relative_path)
Expand All @@ -36,7 +38,7 @@ def main():
os.remove(target_readme_html_path)
os.rename(readme_html_path, target_readme_html_path)

print " ::: Saved: %s" % target_readme_html_name
print(" ::: Saved: {0}".format(target_readme_html_name))

def _parse_readme_path(readme_relative_path):
readme_abs_path = os.path.join(ROOT_DIR, readme_relative_path.replace('/', os.sep))
Expand Down
33 changes: 16 additions & 17 deletions src/ez_setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#!python

from __future__ import print_function

"""Bootstrap setuptools installation

If you want to use setuptools in your package's setup.py, just include this
Expand Down Expand Up @@ -70,10 +73,8 @@ def _validate_md5(egg_name, data):
if egg_name in md5_data:
digest = md5(data).hexdigest()
if digest != md5_data[egg_name]:
print >>sys.stderr, (
"md5 validation of %s failed! (Possible download problem?)"
% egg_name
)
print("md5 validation of {0} failed! (Possible download problem?)".format(egg_name),
file=sys.stderr)
sys.exit(2)
return data

Expand Down Expand Up @@ -105,12 +106,10 @@ def do_download():
pkg_resources.require("setuptools>="+version); return
except pkg_resources.VersionConflict, e:
if was_imported:
print >>sys.stderr, (
"The required version of setuptools (>=%s) is not available, and\n"
"can't be installed while this script is running. Please install\n"
" a more recent version first, using 'easy_install -U setuptools'."
"\n\n(Currently using %r)"
) % (version, e.args[0])
print("The required version of setuptools (>={0}) is not available, and\n".format(version), file=sys.stderr)
print("can't be installed while this script is running. Please install\n")
print(" a more recent version first, using 'easy_install -U setuptools'.")
print("\n\n(Currently using {0})".format(e.args[0]), file=sys.stderr)
sys.exit(2)
except pkg_resources.DistributionNotFound:
pass
Expand Down Expand Up @@ -216,10 +215,10 @@ def main(argv, version=DEFAULT_VERSION):
os.unlink(egg)
else:
if setuptools.__version__ == '0.0.1':
print >>sys.stderr, (
"You have an obsolete version of setuptools installed. Please\n"
"remove it from your system entirely before rerunning this script."
)
print("You have an obsolete version of setuptools installed. Please\n",
file=sys.stderr)
print("remove it from your system entirely before rerunning this script.",
file=sys.stderr)
sys.exit(2)

req = "setuptools>="+version
Expand All @@ -238,8 +237,8 @@ def main(argv, version=DEFAULT_VERSION):
from setuptools.command.easy_install import main
main(argv)
else:
print "Setuptools version",version,"or greater has been installed."
print '(Run "ez_setup.py -U setuptools" to reinstall or upgrade.)'
print("Setuptools version {0} or greater has been installed.".format(version))
print("Run 'ez_setup.py -U setuptools' to reinstall or upgrade.")

def update_md5(filenames):
"""Update our built-in md5 registry"""
Expand All @@ -262,7 +261,7 @@ def update_md5(filenames):

match = re.search("\nmd5_data = {\n([^}]+)}", src)
if not match:
print >>sys.stderr, "Internal error!"
print("Internal error!", file=sys.stderr)
sys.exit(2)

src = src[:match.start(1)] + repl + src[match.end(1):]
Expand Down
Loading