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
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
pip install selenium
pip install decorator
pip install docutils
pip install future
fi
23 changes: 14 additions & 9 deletions build_dist.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#!/usr/bin/env python

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

THIS_DIR = os.path.dirname(os.path.abspath(__file__))
DIST_DIR = os.path.join(THIS_DIR, "dist")
Expand All @@ -9,9 +14,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 +38,7 @@ def clear_dist_folder():

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

def run_register(args):
Expand All @@ -50,12 +55,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 +71,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])))
9 changes: 6 additions & 3 deletions demo/package.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#!/usr/bin/env python

import os, sys
from __future__ import print_function

import os
import sys
from time import localtime
from zipfile import ZipFile, ZIP_DEFLATED

Expand All @@ -26,14 +29,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
18 changes: 10 additions & 8 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 @@ -32,10 +34,10 @@

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.'
except ImportError as e:
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
14 changes: 7 additions & 7 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 @@ -242,8 +242,8 @@ def process_txt(self, directory, name):
parser_name='restructuredtext',
writer_name=pub_struct.writer_name,
settings=settings)
except ApplicationError, error:
print >>errout, ' %s' % ErrorString(error)
except ApplicationError as 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()
9 changes: 6 additions & 3 deletions doc/generate_readmes.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#!/usr/bin/env python

import os, shutil
from __future__ import print_function
import os
import 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 +22,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 +39,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
2 changes: 1 addition & 1 deletion src/Selenium2Library/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os
from keywords import *
from Selenium2Library.keywords import *
from version import VERSION
from utils import LibraryListener

Expand Down
2 changes: 1 addition & 1 deletion src/Selenium2Library/keywords/_runonfailure.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def _run_on_failure(self):
self._running_on_failure_routine = True
try:
BUILTIN.run_keyword(self._run_on_failure_keyword)
except Exception, err:
except Exception as err:
self._run_on_failure_error(err)
finally:
self._running_on_failure_routine = False
Expand Down
3 changes: 2 additions & 1 deletion src/Selenium2Library/keywords/_screenshot.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import robot
import os, errno
import os
import errno

from Selenium2Library import utils
from keywordgroup import KeywordGroup
Expand Down
2 changes: 1 addition & 1 deletion src/Selenium2Library/keywords/_tableelement.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def table_cell_should_contain(self, table_locator, row, column, expected, loglev
% (table_locator, row, column, expected))
try:
content = self.get_table_cell(table_locator, row, column, loglevel='NONE')
except AssertionError, err:
except AssertionError as err:
self._info(err)
self.log_source(loglevel)
raise AssertionError(message)
Expand Down
2 changes: 1 addition & 1 deletion src/Selenium2Library/keywords/keywordgroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def _run_on_failure_decorator(method, *args, **kwargs):
self._already_in_keyword = True # Set a flag on the instance so that as we call keywords inside this call and this gets run again, we know we're at least one level in.
try:
return method(*args, **kwargs)
except Exception, err:
except Exception as err:
if hasattr(self, '_run_on_failure') and not self._has_run_on_failure:
# If we're in an inner keyword, track the fact that we've already run on failure once
self._has_run_on_failure = True
Expand Down
Loading