Skip to content
Merged
31 changes: 31 additions & 0 deletions .appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
environment:

matrix:

# For Python versions available on Appveyor, see
# http://www.appveyor.com/docs/installed-software#python

- PYTHON: "C:\\Python27"
- PYTHON: "C:\\Python33"
- PYTHON: "C:\\Python34"
- PYTHON: "C:\\Python35"
- PYTHON: "C:\\Python36"
- PYTHON: "C:\\Python27-x64"
- PYTHON: "C:\\Python33-x64"
- PYTHON: "C:\\Python34-x64"
- PYTHON: "C:\\Python35-x64"
- PYTHON: "C:\\Python36-x64"

install:
# We need our usual libraries
- "%PYTHON%\\python.exe -m pip install -r requirements.txt"
# We need to install the python-can library itself
- "%PYTHON%\\python.exe -m pip install ."

build: off

test_script:
# Note that you must use the environment variable %PYTHON% to refer to
# the interpreter you're using - Appveyor does not do anything special
# to put the Python version you want to use on PATH.
- "%PYTHON%\\python.exe setup.py test"
14 changes: 9 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
python-can
==========

|release| |docs| |build|
|release| |docs| |build_travis| |build_appveyor|

.. |release| image:: https://img.shields.io/pypi/v/python-can.svg
:target: https://pypi.python.org/pypi/python-can/
:alt: Latest Version
:alt: Latest Version on PyPi

.. |docs| image:: https://readthedocs.org/projects/python-can/badge/?version=stable
:target: https://python-can.readthedocs.io/en/stable/
:alt: Documentation Status
:alt: Documentation build Status

.. |build| image:: https://travis-ci.org/hardbyte/python-can.svg?branch=develop
.. |build_travis| image:: https://travis-ci.org/hardbyte/python-can.svg?branch=develop
:target: https://travis-ci.org/hardbyte/python-can/branches
:alt: CI Server for develop branch
:alt: Travis CI Server for develop branch

.. |build_appveyor| image:: https://ci.appveyor.com/api/projects/status/github/hardbyte/python-can?branch=develop&svg=true
:target: https://ci.appveyor.com/project/hardbyte/python-can/history
:alt: AppVeyor CI Server for develop branch


The **C**\ ontroller **A**\ rea **N**\ etwork is a bus standard designed
Expand Down
13 changes: 7 additions & 6 deletions can/io/sqlite.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import logging
import sqlite3

from deprecated import deprecated

from can.listener import BufferedReader
from can.message import Message

Expand All @@ -22,7 +24,8 @@
buffer = memoryview


class SqliteReader:
@deprecated(reason="Use the name SqliteReader instead. (Replaced in v2.1)")
class SqlReader:
"""
Reads recorded CAN messages from a simple SQL database.

Expand All @@ -49,7 +52,7 @@ def _create_frame_from_db_tuple(frame_data):
def __iter__(self):
log.debug("Iterating through messages from sql db")
for frame_data in self.cursor.execute(self._SELECT_ALL_COMMAND):
yield SqliteReader._create_frame_from_db_tuple(frame_data)
yield self._create_frame_from_db_tuple(frame_data)

def __len__(self):
# this might not run in constant time
Expand All @@ -65,10 +68,8 @@ def close(self):
"""Closes the connection to the database."""
self.conn.close()


# Backward compatibility
# TODO remove in later releases?
SqlReader = SqliteReader
# SqliteReader is the newer name
SqliteReader = SqlReader


class SqliteWriter(BufferedReader):
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
pyserial
pyserial >= 3.0
Deprecated >= 1.1.0
34 changes: 27 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,44 @@
logging.basicConfig(level=logging.WARNING)

setup(

# Description
name="python-can",
url="https://github.com/hardbyte/python-can",
description="Controller Area Network interface module for Python",
long_description=long_description,

# Code
version=version,
packages=find_packages(),

# Author
author="Brian Thorne",
author_email="brian@thorne.link",
description="Controller Area Network interface module for Python",
long_description=long_description,

# License
license="LGPL v3",

# Package data
package_data={
"": ["CONTRIBUTORS.txt", "LICENSE.txt"],
"doc": ["*.*"]
},
# Tests can be run using `python setup.py test`
test_suite="nose.collector",
tests_require=['mock', 'nose', 'pyserial'],

# Installation
install_requires=[
'Deprecated >= 1.1.0',
],
extras_require={
'serial': ['pyserial'],
'serial': ['pyserial >= 3.0'],
'neovi': ['python-ics'],
}
},

# Testing
test_suite="nose.collector",
tests_require=[
'mock',
'nose',
'pyserial >= 3.0'
],
)
2 changes: 2 additions & 0 deletions test/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env python
# coding: utf-8
11 changes: 4 additions & 7 deletions test/back2back_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,19 @@

"""
This module tests two virtual busses attached to each other.

Some tests are skipped when run on Travis CI because they are not
reproducible, see #243 (https://github.com/hardbyte/python-can/issues/243).
"""

import os
from __future__ import absolute_import

import unittest
import time

import can

IS_TRAVIS = os.environ.get('TRAVIS', 'default') == 'true'
from .config import *

BITRATE = 500000
TIMEOUT = 0.1
TEST_CAN_FD = True

INTERFACE_1 = 'virtual'
CHANNEL_1 = 'vcan0'
Expand Down Expand Up @@ -79,7 +76,7 @@ def _send_and_receive(self, msg):
def test_no_message(self):
self.assertIsNone(self.bus1.recv(0.1))

@unittest.skipIf(IS_TRAVIS, "skip on Travis CI")
@unittest.skipIf(IS_CI, "the timing sensitive behaviour cannot be reproduced reliably on a CI server")
def test_timestamp(self):
self.bus2.send(can.Message())
recv_msg1 = self.bus1.recv(TIMEOUT)
Expand Down
24 changes: 24 additions & 0 deletions test/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env python
# coding: utf-8

"""
This module contains some configuration for the tests.

Some tests are skipped when run on a CI server because they are not
reproducible, see #243 (https://github.com/hardbyte/python-can/issues/243).
"""

from os import environ as environment

# see here for the environment variables that are set on the CI servers:
# - https://docs.travis-ci.com/user/environment-variables/
# - https://www.appveyor.com/docs/environment-variables/

IS_TRAVIS = environment.get('TRAVIS', '').lower() == 'true'
IS_APPVEYOR = environment.get('APPVEYOR', '').lower() == 'true'

IS_CI = IS_TRAVIS or IS_APPVEYOR or \
environment.get('CI', '').lower() == 'true' or \
environment.get('CONTINUOUS_INTEGRATION', '').lower() == 'true'

TEST_CAN_FD = True
4 changes: 3 additions & 1 deletion test/listener_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"""
"""

from __future__ import absolute_import

from time import sleep
import unittest
import random
Expand All @@ -14,7 +16,7 @@

import can

from data.example_data import generate_message
from .data.example_data import generate_message

channel = 'vcan0'
can.rc['interface'] = 'virtual'
Expand Down
7 changes: 4 additions & 3 deletions test/logformats_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"""

from __future__ import print_function
from __future__ import absolute_import

import unittest
import tempfile
Expand All @@ -28,9 +29,9 @@

import can

from data.example_data import TEST_MESSAGES_BASE, TEST_MESSAGES_REMOTE_FRAMES, \
TEST_MESSAGES_ERROR_FRAMES, TEST_COMMENTS, \
generate_message
from .data.example_data import TEST_MESSAGES_BASE, TEST_MESSAGES_REMOTE_FRAMES, \
TEST_MESSAGES_ERROR_FRAMES, TEST_COMMENTS, \
generate_message


def _test_writer_and_reader(test_case, writer_constructor, reader_constructor, sleep_time=None,
Expand Down
10 changes: 4 additions & 6 deletions test/simplecyclic_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,20 @@

"""
This module tests cyclic send tasks.

Some tests are skipped when run on Travis CI because they are not
reproducible, see #243 (https://github.com/hardbyte/python-can/issues/243).
"""

import os
from __future__ import absolute_import

from time import sleep
import unittest

import can

IS_TRAVIS = os.environ.get('TRAVIS', 'default') == 'true'
from .config import *

class SimpleCyclicSendTaskTest(unittest.TestCase):

@unittest.skipIf(IS_TRAVIS, "skip on Travis CI")
@unittest.skipIf(IS_CI, "the timing sensitive behaviour cannot be reproduced reliably on a CI server")
def test_cycle_time(self):
msg = can.Message(extended_id=False, arbitration_id=0x100, data=[0,1,2,3,4,5,6,7])
bus1 = can.interface.Bus(bustype='virtual')
Expand Down