Пример #1
0
 def test_error(self,d):
     path = d.write('test.py','\n'.join((
             "import sys",
             "sys.stdout.write('stdout\\n')",
             "sys.stderr.write('stderr\\n')",
             "sys.exit(1)",
             )),path=True)
     compare(1,returncode(sys.executable+' '+path))
Пример #2
0
def check(config_folder, junk):
    with open(os.path.join(config_folder, 'os_packages'), 'wb') as out:
        for possible in (
                'dpkg -l',
                'yum list',
                'up2date --showall',
        ):
            if execute.returncode('which ' + possible.split()[0]) != 0:
                continue
            out.write(execute.simple(possible))
            return ''
    return 'Could not find package manager!'
Пример #3
0
def check(config_folder,junk):
    with open(os.path.join(config_folder, 'os_packages'), 'wb') as out:
        for possible in (
            'dpkg -l',
            'yum list',
            'up2date --showall',
            ):
            if execute.returncode('which '+possible.split()[0])!=0:
                continue
            out.write(execute.simple(possible))
            return ''
    return 'Could not find package manager!'
Пример #4
0
    def test_working_directory(self,d):
        dir = d.makedir('a_dir',path=True)
        
        # tempdirs on Mac OS X give a different path
        # after you've os.chdir's into them!
        cur = os.getcwd()
        try:
            os.chdir(dir)
            expected = os.getcwd()
        finally:
            os.chdir(cur)
            
        path = d.write('test.py','\n'.join((
                "import os,sys",
                "dir = os.getcwd()",
                "if dir==%r:"% expected,
                "  sys.exit(3)",
                "else:",
                "  sys.exit(2)",
                )),path=True)

        compare(3,returncode(sys.executable+' '+path,cwd=dir))
Пример #5
0
def webcam_toggle():
    if webcam():
        returncode('sudo /sbin/modprobe uvcvideo')
    else:
        returncode('sudo /sbin/modprobe -rv uvcvideo')
Пример #6
0
A/V control for System76 laptop using Unity
'''

import os

from execute import returncode

# check for the existence of /dev/video0 which is used currently for webcam
webcam = lambda: os.path.exists('/dev/video0') == False


def webcam_toggle():
    if webcam():
        returncode('sudo /sbin/modprobe uvcvideo')
    else:
        returncode('sudo /sbin/modprobe -rv uvcvideo')


# use the amixer application to glean the status of the microphone
microphone = lambda: returncode("amixer get Capture | grep Capt | grep off"
                                ) == 0
microphone_toggle = lambda: returncode("amixer set Capture toggle")


def main():
    print "Mic muted ? {0}, Webcam off ? {1}".format(microphone(), webcam())


if __name__ == '__main__':
    main()
Пример #7
0
def webcam_toggle():
    if webcam():
        returncode('sudo /sbin/modprobe uvcvideo')
    else:
        returncode('sudo /sbin/modprobe -rv uvcvideo')
Пример #8
0
#!/usr/bin/env python
'''
A/V control for System76 laptop using Unity
'''

import os

from execute import returncode

# check for the existence of /dev/video0 which is used currently for webcam
webcam = lambda: os.path.exists('/dev/video0') == False
def webcam_toggle():
    if webcam():
        returncode('sudo /sbin/modprobe uvcvideo')
    else:
        returncode('sudo /sbin/modprobe -rv uvcvideo')

# use the amixer application to glean the status of the microphone
microphone = lambda: returncode("amixer get Capture | grep Capt | grep off") == 0
microphone_toggle = lambda: returncode("amixer set Capture toggle")

def main():
    print "Mic muted ? {0}, Webcam off ? {1}".format(microphone(), webcam())

if __name__ == '__main__':
    main()