Рефакторинг: работа с файлами

legacy27 3.6.2.1
parent b1f426c145
commit e7f1b95d45

@ -30,7 +30,7 @@ from calculate.lib.cl_ini_parser import iniParser
from calculate.lib.cl_print import color_print
from calculate.lib.utils.ip import Pinger, IPError
from calculate.lib.utils.files import (getModeFile, removeDir,
pathJoin, tarLinks,
pathJoin, tarLinks, readFile,
listDirectory, process, find, STDOUT,
checkUtils)
from calculate.lib.utils.samba import Samba, SambaError
@ -890,7 +890,7 @@ class Client(commandServer, encrypt, Desktop):
"""
# read file list from config
try:
filesProfileTxt = open(pathListFile).read()
filesProfileTxt = readFile(pathListFile)
except IOError:
return False
listFilesProfile = filter(lambda x: x.strip(),
@ -928,8 +928,8 @@ class Client(commandServer, encrypt, Desktop):
try:
if os.path.exists(cmdLineFile) and \
os.path.exists(environFile):
return (open(cmdLineFile, 'r').read().strip(),
open(environFile, 'r').read().strip())
return (readFile(cmdLineFile).strip(),
readFile(environFile).strip())
except (OSError, IOError):
pass
return "", ""

@ -284,7 +284,7 @@ class _shareCache(_shareData):
return False
if not os.path.exists(self.fileName):
try:
open(self.fileName, "w")
open(self.fileName, "w").close()
except IOError:
self.printERROR(_("Failed to create file %s") % self.fileName)
return False

Loading…
Cancel
Save