/usr/share/jockey/handlers/sl_modem.py is in jockey-common 0.9.7-0ubuntu7.16.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | # -*- coding: utf-8 -*-
# (c) 2008 Canonical Ltd.
# Author: Martin Pitt <martin.pitt@ubuntu.com>
# License: GPL v2 or later
import re, os.path, logging, subprocess
from jockey.handlers import Handler
# dummy stub for xgettext
def _(x): return x
class SlModem(Handler):
def __init__(self, backend):
Handler.__init__(self, backend, name=_('Software modem'),
rationale=_(
'This driver enables the usage of many software modems, as '
'commonly found in laptops.\n\n'
'If this driver is not enabled, you will not be able to use '
'your modem.'))
self.package = 'sl-modem-daemon'
self.modem_re = re.compile('^\s*\d+\s*\[Modem\s*\]')
self.modem_as_subdevice_re = re.compile('^card [0-9].*[mM]odem')
def available(self):
'''Check /proc/asound/cards and aplay -l for a "Modem" card.'''
if Handler.available(self) == False:
return False
try:
for l in open('/proc/asound/cards'):
if self.modem_re.match(l):
return True
except IOError as e:
logging.error('could not open /proc/asound/cards: %s' % str(e))
try:
aplay = subprocess.Popen(['aplay', '-l'], env={},
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(aplay_out, aplay_err) = aplay.communicate()
except OSError as e:
logging.error('could not open aplay -l: %s' % str(e))
return False
if aplay.returncode != 0:
logging.error('aplay -l failed with %i: %s' % (aplay.returncode,
aplay_err))
return False
for row in aplay_out.splitlines():
if self.modem_as_subdevice_re.match(row):
return True
return False
def used(self):
return self.enabled() and os.path.exists('/dev/modem')
|