Skip to content

Commit

Permalink
Merge branch 'release/0.2.0'
Browse files Browse the repository at this point in the history
Conflicts:
	setup.py
  • Loading branch information
smn committed Nov 9, 2015
2 parents cb32ab5 + 68cd08c commit 857060b
Show file tree
Hide file tree
Showing 12 changed files with 69 additions and 43 deletions.
2 changes: 2 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[run]
omit = ve/*
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@ nosetests.xml
_trial_temp
*.log
*.pid
wheelhouse/
26 changes: 22 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,29 @@
sudo: false
language: python
python:
- 2.6
- 2.7
- 3.5
matrix:
allow_failures:
- python: 3.5
install:
- pip install coveralls --use-mirrors
- pip install -r requirements.pip --use-mirrors
- pip install https://github.com/thijstriemstra/python-messaging/archive/master.zip
- pip install coveralls
- pip install wheel
- pip install -r requirements-dev.txt
- pip install -e .
- flake8
script:
- coverage run --source=txgsm `which trial` txgsm
- py.test --cov=txgsm --cov-report=term
after_success:
- coveralls
- coveralls
deploy:
provider: pypi
distributions: sdist bdist_wheel
user: smn
password:
secure: "lALu68z75ANy0tD2SNVh3+IEz/RAbQyKiYtjXkxPKIg/j6wb8BL65CG3dhf9yzfTRR01BvqD4aqCfq6saeaqAyv6r5yEcmLFjMRE3uf9SlRXSnFXxJ+LRedrNJVZsFn3QBrbAZh6S+SMrOcoynrZQ6qHQMFDSxR0jn4b2SWGQyQ="
on:
tags: true
all_branches: true
2 changes: 2 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Simon de Haan, http://github.com/smn
Thijs Triemstra, http://github.com/thijstriemstra
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.2.0
5 changes: 5 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
flake8==2.4.1
coverage==4.0
pytest==2.8.2
pytest-xdist==1.13.1
pytest-cov==2.2.0
File renamed without changes.
6 changes: 6 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[pytest]
addopts = --doctest-modules --verbose --ignore=ve/ txgsm/

[flake8]
ignore = F403
exclude = ve,docs
33 changes: 4 additions & 29 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,41 +1,17 @@
from setuptools import setup

import re


def listify(filename):
return filter(None, open(filename, 'r').read().split('\n'))

install_requires = listify("requirements.txt")

_SIMPLE_VERSION_RE = re.compile("(?P<name>.*)-(?P<version>[0-9.]+|dev)$")


def parse_requirements(filename):
install_requires = []
dependency_links = []
for requirement in listify(filename):
if requirement.startswith("#"):
continue
if requirement.startswith("-e"):
continue
if requirement.startswith("https:") or requirement.startswith("http:"):
(_, _, name) = requirement.partition('#egg=')
ver_match = _SIMPLE_VERSION_RE.match(name)
if ver_match:
# egg names with versions need to be converted to
# an == requirement.
name = "%(name)s==%(version)s" % ver_match.groupdict()
install_requires.append(name)
dependency_links.append(requirement)
else:
install_requires.append(requirement)
return install_requires, dependency_links

install_requires, dependency_links = parse_requirements("requirements.pip")
with open('VERSION', 'r') as fp:
version = fp.read().strip()

setup(
name="txgsm",
version="0.1.4",
version=version,
url='http://github.com/smn/txgsm',
license='BSD',
description="Utilities for talking to a GSM modem over USB via AT "
Expand All @@ -52,7 +28,6 @@ def parse_requirements(filename):
},
include_package_data=True,
install_requires=install_requires,
dependency_links=dependency_links,
classifiers=[
'Development Status :: 3 - Alpha',
'Intended Audience :: Developers',
Expand Down
2 changes: 0 additions & 2 deletions txgsm/protocol.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
# -*- test-case-name: txgsm.tests.test_protocol -*-
# -*- coding: utf-8 -*-
from twisted.internet.serialport import SerialPort
from twisted.internet import reactor
from twisted.protocols.basic import LineReceiver
from twisted.internet.defer import Deferred
from twisted.application.service import Service
from twisted.python import log

from .utils import quote
Expand Down
18 changes: 13 additions & 5 deletions txgsm/service.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# -*- test-case-name: txgsm.tests.test_service -*-
import sys
from pprint import pprint
from zope.interface import implements
from zope.interface import implementer

from twisted.python import usage
from twisted.plugin import IPlugin
Expand Down Expand Up @@ -58,6 +57,8 @@ class Options(usage.Options):

optParameters = [
["device", "d", None, "The device to connect to."],
["baudrate", "b", 9600, "Baud rate such as 9600 or 115200."],
["timeout", "t", None, "Set a read timeout value."],
]


Expand Down Expand Up @@ -85,16 +86,23 @@ def stopService(self):
self.port.loseConnection()


@implementer(IServiceMaker, IPlugin)
class TxGSMServiceMaker(object):
implements(IServiceMaker, IPlugin)
tapname = "txgsm"
tapname = 'txgsm'
description = ("Utilities for talking to a GSM modem over USB via AT "
"commands.")
options = Options

def makeService(self, options):
device = options['device']
service = TxGSMService(device)
conn_options = {
'baudrate': int(options['baudrate']),
'timeout': None
}
if options['timeout'] is not None:
conn_options['timeout'] = int(options['timeout'])

service = TxGSMService(device, **conn_options)
service.onProtocol.addCallback(self.set_verbosity, options)

dispatch = {
Expand Down
16 changes: 13 additions & 3 deletions txgsm/tests/test_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ def assert_configure_modem(self):
yield self.assertExchange(['AT+CMEE=1'], ['OK'])
yield self.assertExchange(['AT+CSMS=1'], ['OK'])

def make_service(self, command, options):
args = ['--device', '/dev/foo', command]
args.extend(options)
def make_service(self, command, cmdOptions=[], connOptions=[]):
args = ['--device', '/dev/foo']
args.extend(connOptions)
args.extend([command] + cmdOptions)
service_options = Options()
service_options.parseOptions(args)
service_maker = TxGSMServiceMaker()
Expand Down Expand Up @@ -116,6 +117,15 @@ def test_ussd_session(self):
'Dial *111# for Airtime Advance. T&Cs apply.",255')
])

def test_service_options(self):
baudrate = 115200
timeout = 1000
service = self.make_service('probe-modem', connOptions=[
'--baudrate', baudrate, '--timeout', timeout])

self.assertEqual(service.conn_options['baudrate'], baudrate)
self.assertEqual(service.conn_options['timeout'], timeout)

@inlineCallbacks
def test_probe_modem(self):
service = self.make_service('probe-modem', [])
Expand Down

0 comments on commit 857060b

Please sign in to comment.