MCPcopy Create free account
hub / github.com/aaPanel/BaoTa / ReadFile

Method ReadFile

class/projectModel/safecloudModel.py:2254–2277  ·  view source on GitHub ↗

@time: 2025-02-19 @name 读取文件内容 @param filepath 文件路径 @return 文件内容

(self, filepath, mode='r')

Source from the content-addressed store, hash-verified

2252 return False
2253
2254 def ReadFile(self, filepath, mode='r'):
2255 '''
2256 @time: 2025-02-19
2257 @name 读取文件内容
2258 @param filepath 文件路径
2259 @return 文件内容
2260 '''
2261 import os
2262 if not os.path.exists(filepath): return False
2263 try:
2264 fp = open(filepath, mode)
2265 f_body = fp.read()
2266 fp.close()
2267 except Exception as ex:
2268 if sys.version_info[0] != 2:
2269 try:
2270 fp = open(filepath, mode, encoding="utf-8")
2271 f_body = fp.read()
2272 fp.close()
2273 except Exception as ex2:
2274 return False
2275 else:
2276 return False
2277 return f_body
2278
2279 def test_file(self, get):
2280 '''

Callers 15

test_fileMethod · 0.95
get_configMethod · 0.45
listMethod · 0.45
get_system_userMethod · 0.45
get_system_userMethod · 0.45
replace_jdk_versionMethod · 0.45
get_serverMethod · 0.45
get_jdk_pathMethod · 0.45
set_hostsMethod · 0.45
get_local_jdk_versionMethod · 0.45
get_project_dumpMethod · 0.45

Calls 4

openFunction · 0.85
existsMethod · 0.45
readMethod · 0.45
closeMethod · 0.45

Tested by 1

test_fileMethod · 0.76