setup.py: fix entry_point to use amodem/__main__.py

This commit is contained in:
Roman Zeyde
2015-04-10 21:17:03 +03:00
parent 3a33338425
commit 66148650ed
2 changed files with 20 additions and 14 deletions

View File

@@ -94,8 +94,8 @@ def get_volume_cmd(args):
return c[args.command]
class _DummyInterface(object):
''' Audio interface mock, to skip shared library loading. '''
class _DummyContextManager(object):
def __enter__(self):
pass
@@ -103,19 +103,14 @@ class _DummyInterface(object):
pass
def _main():
fmt = ('Audio OFDM MODEM: {0:.1f} kb/s ({1:d}-QAM x {2:d} carriers) '
'Fs={3:.1f} kHz')
description = fmt.format(config.modem_bps / 1e3, len(config.symbols),
config.Nfreq, config.Fs / 1e3)
interface = audio.Interface(config=config)
def wrap(cls, stream, enable):
return cls(stream) if enable else stream
def create_parser(description, interface):
p = argparse.ArgumentParser(description=description)
subparsers = p.add_subparsers()
def wrap(cls, stream, enable):
return cls(stream) if enable else stream
# Modulator
sender = subparsers.add_parser(
'send', help='modulate binary data into audio signal.')
@@ -182,6 +177,17 @@ def _main():
if argcomplete:
argcomplete.autocomplete(p)
return p
def _main():
fmt = ('Audio OFDM MODEM: {0:.1f} kb/s ({1:d}-QAM x {2:d} carriers) '
'Fs={3:.1f} kHz')
description = fmt.format(config.modem_bps / 1e3, len(config.symbols),
config.Nfreq, config.Fs / 1e3)
interface = audio.Interface(config=config)
p = create_parser(description, interface)
args = p.parse_args()
if args.verbose == 0:
level, fmt = 'INFO', '%(message)s'
@@ -200,11 +206,11 @@ def _main():
args.pylab = None
if getattr(args, 'plot', False):
import pylab
import pylab # pylint: disable=import-error
args.pylab = pylab
if args.audio_library == '-':
interface = _DummyInterface()
interface = _DummyContextManager()
else:
interface.load(args.audio_library)

View File

@@ -42,5 +42,5 @@ setup(
'Topic :: System :: Networking',
'Topic :: Communications',
],
scripts=['amodem-cli'],
entry_points={'console_scripts': ['amodem = amodem.__main__:_main']},
)