Ejemplo n.º 1
0
def stop_wireless():
    ''' Try official ways to stop wireless such as nmcli and rfkill.

        These often leave the service enabled, or the service is re-enabled
        on boot.

        To do: check rmcomm piconets
    '''

    if not sh.which('nm'):
        sh.aptitude('install', 'nmcli')
    assert sh.which('nm')

    if not sh.which('service'):
        service_path = '/usr/local/sbin/service'
        with open(service_path, 'w') as service_file:
            service_file.write(service_script_text)
        os.chmod(service_path, 0o755)
    assert sh.which('service')

    try:
        sh.nmcli('nm', 'wifi', 'off')
        sh.nmcli('nm', 'wwan', 'off')
    except:
        pass

    # rfkill block all
    try:
        #if not sh.which ('rfkill'):
        #    sh.aptitude('install', 'rfkill')
        #assert sh.which ('rfkill')
        sh.rfkill('block', 'all')
    except:
        # some variants of linux don't have /dev/rfkill,
        # so there's no program rfkill
        pass

    # /etc/init.d/bluetooth stop
    try:
        sh.service(Bluetooth, 'stop')
    except:
        try:
            sh.service(Bluetooth+'-unused', 'stop')
        except:
            pass
Ejemplo n.º 2
0
def install():
    from sh import aptitude, ErrorReturnCode
    print("\nChecking installed packages...\n")

    # check if we have samba and netatalk already installed
    has_samba = package_installed("samba-common")
    has_netatalk = package_installed("netatalk")
    has_avahi = package_installed("avahi-daemon")

    # check highest version available in package manager
    response = aptitude("versions", "netatalk")
    print(str(response))
    response = re.search("Package netatalk:\ni\\s*(\\S*)", str(response))
    print(response.groups())

    print(has_samba, has_netatalk, has_avahi)
    null = input()
Ejemplo n.º 3
0
 def safe_upgrade(self):
     sh.aptitude('-y', 'safe-upgrade', _err=sys.stderr, _out=sys.stdout)
Ejemplo n.º 4
0
 def ensure_installed(self, packages):
     sh.aptitude('-y', 'install', *packages, _err=sys.stderr, _out=sys.stdout)
Ejemplo n.º 5
0
 def update(self):
     print(" * Updating dpkg repositories ...")
     sh.aptitude('-y', 'update', _err=sys.stderr, _out=sys.stdout)