Exemplo n.º 1
0
def write_default_config(new_config_path):
    # TODO: support enumerating osmosdr devices and configuring specifically for them
    # TODO: support more than one audio device (moot currently because gnuradio doesn't have a enumeration operation)
    from shinysdr.devices import find_audio_rx_names
    audio_rx_names = find_audio_rx_names()
    if audio_rx_names:
        has_audio = True
        audio_rx_name = audio_rx_names[0]
    else:
        has_audio = False
        audio_rx_name = ''

    config_text = '''\
# -*- coding: utf-8 -*-

# This is a ShinySDR configuration file. For more information about what can
# be put here, read the manual section on it, available from the running
# ShinySDR server at: http://localhost:8100/manual/configuration

from shinysdr.devices import AudioDevice
from shinysdr.plugins.osmosdr import OsmoSDRDevice
from shinysdr.plugins.simulate import SimulatedDevice

# OsmoSDR generic driver; handles USRP, RTL-SDR, FunCube Dongle, HackRF, etc.
# To select a specific device, replace '' with 'rtl=0' etc.
config.devices.add(u'osmo', OsmoSDRDevice(''))

# For hardware which uses a sound-card as its ADC or appears as an
# audio device.
%(audio_comment)sconfig.devices.add(u'audio', AudioDevice(rx_device='%(audio_rx_name)s'))

# Locally generated RF signals for test purposes.
config.devices.add(u'sim', SimulatedDevice())

config.serve_web(
    # These are in Twisted endpoint description syntax:
    # <http://twistedmatrix.com/documents/current/api/twisted.internet.endpoints.html#serverFromString>
    # Note: ws_endpoint must currently be 1 greater than http_endpoint; if one
    # is SSL then both must be. These restrictions will be relaxed later.
    http_endpoint='tcp:8100',
    ws_endpoint='tcp:8101',

    # A secret placed in the URL as simple access control. Does not
    # provide any real security unless using HTTPS. The default value
    # in this file has been automatically generated from 128 random bits.
    # Set to None to not use any secret.
    root_cap='%(root_cap)s',
    
    # Page title / station name
    title='ShinySDR')
''' % {
        'root_cap': generate_cap(),
        'audio_comment': '' if has_audio else '# ',
        'audio_rx_name': audio_rx_name,
    }

    os.mkdir(new_config_path)
    with open(os.path.join(new_config_path, 'config.py'), 'w') as f:
        f.write(config_text.encode('utf-8'))
    os.mkdir(os.path.join(new_config_path, 'dbs-read-only'))
Exemplo n.º 2
0
def write_default_config(new_config_path):
    # TODO: support enumerating osmosdr devices and configuring specifically for them
    # TODO: support more than one audio device (moot currently because gnuradio doesn't have a enumeration operation)
    from shinysdr.devices import find_audio_rx_names
    audio_rx_names = find_audio_rx_names()
    if audio_rx_names:
        has_audio = True
        audio_rx_name = audio_rx_names[0]
    else:
        has_audio = False
        audio_rx_name = ''
    
    config_text = '''\
# -*- coding: utf-8 -*-

# This is a ShinySDR configuration file. For more information about what can
# be put here, read the manual section on it, available from the running
# ShinySDR server at: http://localhost:8100/manual/configuration

from shinysdr.devices import AudioDevice
from shinysdr.plugins.osmosdr import OsmoSDRDevice
from shinysdr.plugins.simulate import SimulatedDevice

# OsmoSDR generic driver; handles USRP, RTL-SDR, FunCube Dongle, HackRF, etc.
# To select a specific device, replace '' with 'rtl=0' etc.
config.devices.add(u'osmo', OsmoSDRDevice(''))

# For hardware which uses a sound-card as its ADC or appears as an
# audio device.
%(audio_comment)sconfig.devices.add(u'audio', AudioDevice(rx_device='%(audio_rx_name)s'))

# Locally generated RF signals for test purposes.
config.devices.add(u'sim', SimulatedDevice())

config.serve_web(
    # These are in Twisted endpoint description syntax:
    # <http://twistedmatrix.com/documents/current/api/twisted.internet.endpoints.html#serverFromString>
    # Note: ws_endpoint must currently be 1 greater than http_endpoint; if one
    # is SSL then both must be. These restrictions will be relaxed later.
    http_endpoint='tcp:8100',
    ws_endpoint='tcp:8101',

    # A secret placed in the URL as simple access control. Does not
    # provide any real security unless using HTTPS. The default value
    # in this file has been automatically generated from 128 random bits.
    # Set to None to not use any secret.
    root_cap='%(root_cap)s',
    
    # Page title / station name
    title='ShinySDR')
''' % {
        'root_cap': generate_cap(),
        'audio_comment': '' if has_audio else '# ',
        'audio_rx_name': audio_rx_name,
    }
    
    os.mkdir(new_config_path)
    with open(os.path.join(new_config_path, 'config.py'), 'w') as f:
        f.write(config_text.encode('utf-8'))
    os.mkdir(os.path.join(new_config_path, 'dbs-read-only'))
Exemplo n.º 3
0
 def test_none(self):
     self.assertEqual([],
         find_audio_rx_names(_module=_AudioModuleStub({})))
Exemplo n.º 4
0
 def test_normal(self):
     # TODO: This test will have to change once we actually support enumerating audio devices
     self.assertEqual([''],
         find_audio_rx_names(_module=_AudioModuleStub({'': 2})))
Exemplo n.º 5
0
 def test_none(self):
     self.assertEqual([], find_audio_rx_names(_module=_AudioModuleStub({})))
Exemplo n.º 6
0
 def test_normal(self):
     # TODO: This test will have to change once we actually support enumerating audio devices
     self.assertEqual(
         [''], find_audio_rx_names(_module=_AudioModuleStub({'': 2})))