Skip to content

Commit

Permalink
support python 3
Browse files Browse the repository at this point in the history
  • Loading branch information
slxiao committed Nov 21, 2019
1 parent 5830f52 commit 0cf6241
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 27 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ sudo: false

python:
- "2.7"
- "3.6"
- "3.7"

addons:
apt:
Expand All @@ -14,7 +16,7 @@ install:
- pip install coveralls

script:
tox -e test
pytest -vv -s --cov=conport --cov-report term --cov-report html

after_success:
coveralls
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<a href="https://travis-ci.org/slxiao/conport">
<img alt="Build Status" src="http://img.shields.io/travis/slxiao/conport/master.svg?style=flat-square" />
</a>
<a href="https://www.python.org/download/releases/2.7.14/">
<img alt="Python Version" src="https://img.shields.io/badge/python-2.7-blue.svg" />
<a href="https://pypi.org/project/conport/">
<img alt="Python Version" src="https://img.shields.io/pypi/pyversions/conport.svg" />
</a>
<a href="https://coveralls.io/github/slxiao/conport?branch=master">
<img alt="Coverage" src="https://coveralls.io/repos/github/slxiao/conport/badge.svg?branch=master" />
Expand Down
2 changes: 1 addition & 1 deletion conport/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.1.6"
__version__ = "1.1.8"
12 changes: 7 additions & 5 deletions conport/build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import jenkins
import url

from datetime import datetime, timedelta
import time
Expand All @@ -19,10 +18,13 @@ def build_in_boundary(past_hours, timestamp):


def get_jenkins_home(job_url):
myurl = url.parse(job_url)
if myurl.port:
return myurl.scheme + "://" + myurl.host + ":" + str(myurl.port)
return myurl.scheme + "://" + myurl.host
import sys
if sys.version_info[0] == 2:
from urlparse import urlparse
else:
from urllib.parse import urlparse
myurl = urlparse(job_url)
return myurl.scheme + "://" + myurl.netloc


def get_job_name(job_url):
Expand Down
2 changes: 1 addition & 1 deletion conport/conport.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import sys
if sys.version_info.major < 3:
reload(sys)
sys.setdefaultencoding('utf8')
sys.setdefaultencoding('utf8')

def conport(args=None):
parser = get_parser()
Expand Down
2 changes: 1 addition & 1 deletion conport/mail.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
from email.MIMEImage import MIMEImage
from email.mime.image import MIMEImage

from .summary import get_build_summary
from .figure import get_binary_figure
Expand Down
2 changes: 1 addition & 1 deletion conport/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def get_template_path(report_lan):


def get_html_output(report_lan, job_url, report_title, past_hours, build_summary, case_summary, pure_html):
jinja2_template_string = open(get_template_path(report_lan), 'rb').read()
jinja2_template_string = open(get_template_path(report_lan), 'r').read()
template = Template(jinja2_template_string)

build_metrics = {}
Expand Down
10 changes: 5 additions & 5 deletions conport/summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

def get_atom_reports(test_reports):
atom_reports = []
for number, report in test_reports.iteritems():
for number, report in test_reports.items():
suites = report['report']['suites']
for suite in suites:
suite_name = suite['name']
Expand All @@ -30,7 +30,7 @@ def get_merged_reports(atom_reports):


def get_ordered_reports(merged_reports):
for full_name, merged in merged_reports.iteritems():
for full_name, merged in merged_reports.items():
merged['suite'] = full_name.split('.')[0]
merged['case'] = full_name.split('.')[1]
merged['pass'] = len([i for i in merged['atoms'] if i[1] == 'PASSED'])
Expand Down Expand Up @@ -58,7 +58,7 @@ def get_ordered_reports(merged_reports):

def get_build_summary(test_reports):
build_summary = []
for number, report in test_reports.iteritems():
for number, report in test_reports.items():
build = {"number": number, "pass": 0,
"fail": 0, "duration": round(report["duration"]/1000, 1)}
suites = report['report']['suites']
Expand All @@ -74,8 +74,8 @@ def get_build_summary(test_reports):


def get_case_summary(test_reports):
case_summary = get_ordered_reports(
get_merged_reports(get_atom_reports(test_reports))).values()
case_summary = list(get_ordered_reports(
get_merged_reports(get_atom_reports(test_reports))).values())
for i in range(len(case_summary)):
case_summary[i]["rank"] = i + 1
return case_summary
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ configparser
jinja2>=2.7
matplotlib
python-jenkins
url
attrdict
8 changes: 5 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import setuptools
from setuptools import setup

version = '1.1.6'
version = '1.1.8'

setup(
include_package_data=True,
Expand All @@ -16,8 +16,7 @@
install_requires=[
"jinja2>=2.7",
"matplotlib",
"python-jenkins",
"url"
"python-jenkins"
],
long_description=io.open('README.md', encoding='utf8').read(),
long_description_content_type='text/markdown',
Expand All @@ -27,6 +26,7 @@
]
},
url='https://github.com/slxiao/contport',
python_requires='>=2.6, !=3.0.*, !=3.1.*, !=3.2.*, <4',
license='MIT',
author='slxiao',
author_email='shliangxiao@gmail.com',
Expand All @@ -40,6 +40,8 @@
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Topic :: Software Development :: Libraries :: Python Modules',
],
data_files=[('', ['conport/cfg.ini', 'conport/template.html'])]
Expand Down
9 changes: 3 additions & 6 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
[tox]
envlist = test
#indexserver =
# default = https://pypi.org/
envlist = py{27,36,37}

[testenv]
basepython =
python2.7
usedevelop = True
deps =
pytest
pytest-cov
pytest-mock
-rrequirements.txt

commands =
test: {envpython} -m pytest -v -s --cov=conport --cov-report term --cov-report html
pytest -vv -s --cov=conport --cov-report term --cov-report html

0 comments on commit 0cf6241

Please # to comment.