def testMakeDirAndExists(self): temp_dir_path = os.path.join(os.path.dirname(__file__), "data", "temp-dir") FileManager.make_dir(temp_dir_path) self.assertTrue(os.path.exists(temp_dir_path)) self.assertTrue(os.path.isdir(temp_dir_path)) self.assertTrue(FileManager.exists(temp_dir_path)) os.removedirs(temp_dir_path) self.assertFalse(os.path.exists(temp_dir_path)) self.assertFalse(FileManager.exists(temp_dir_path))
def testMakeDirAndExists(self): temp_dir_path = os.path.join(os.path.dirname(__file__), "data", "temp-dir") FileManager.make_dir(temp_dir_path) self.assertTrue(os.path.exists(temp_dir_path)) self.assertTrue(os.path.isdir(temp_dir_path)) self.assertTrue(FileManager.exists(temp_dir_path)) os.removedirs(temp_dir_path) self.assertFalse(os.path.exists(temp_dir_path)) self.assertFalse(FileManager.exists(temp_dir_path))
def testRmAndExists(self): temp_file_path = os.path.join(os.path.dirname(__file__), "data", "temp-file") f = open(temp_file_path, 'w') f.write("foo") f.close() self.assertTrue(os.path.exists(temp_file_path)) self.assertTrue(os.path.isfile(temp_file_path)) self.assertTrue(FileManager.exists(temp_file_path)) FileManager.rm(temp_file_path) self.assertFalse(os.path.exists(temp_file_path)) self.assertFalse(FileManager.exists(temp_file_path))
def testRmAndExists(self): temp_file_path = os.path.join(os.path.dirname(__file__), "data", "temp-file") f = open(temp_file_path, 'w') f.write("foo") f.close() self.assertTrue(os.path.exists(temp_file_path)) self.assertTrue(os.path.isfile(temp_file_path)) self.assertTrue(FileManager.exists(temp_file_path)) FileManager.rm(temp_file_path) self.assertFalse(os.path.exists(temp_file_path)) self.assertFalse(FileManager.exists(temp_file_path))
def lookup(): '''lookup and return the current operating system we are running as''' # TODO other operating system checks if FileManager.exists('/etc/fedora-release'): return 'fedora' elif FileManager.exists('/etc/redhat-release'): return 'rhel' elif FileManager.exists('/etc/centos-release'): return 'centos' elif FileManager.exists("/proc/version"): c = FileManager.read_file("/proc/version") if len(re.findall('Ubuntu', c)) > 0: return 'ubuntu' elif len(re.findall('Debian', c)) > 0: return 'debian' elif FileManager.exists('C:\\'): return 'windows' return None
def lookup(): '''lookup and return the current operating system we are running as''' # TODO other operating system checks if FileManager.exists('/etc/fedora-release'): return 'fedora' elif FileManager.exists('/etc/redhat-release'): return 'rhel' elif FileManager.exists('/etc/centos-release'): return 'centos' elif FileManager.exists("/proc/version"): c = FileManager.read_file("/proc/version") if len(re.findall('Ubuntu', c)) > 0: return 'ubuntu' elif len(re.findall('Debian', c)) > 0: return 'debian' elif FileManager.exists('C:\\'): return 'windows' return None