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))
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!'
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!'
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))
def webcam_toggle(): if webcam(): returncode('sudo /sbin/modprobe uvcvideo') else: returncode('sudo /sbin/modprobe -rv uvcvideo')
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()
#!/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()