py3 changes

py3_forced
idziubenko 3 years ago
parent 437a8af872
commit eeaad7c2b5

6
.gitignore vendored

@ -0,0 +1,6 @@
revert_changes_to_vmachine
push_to_vmachine*
.vscode
*.pyc
*.pyo
*.bak

@ -14,6 +14,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from __future__ import absolute_import
import os import os
import stat import stat
import re import re
@ -39,7 +40,7 @@ from calculate.lib.utils.common import cmpVersion
from calculate.desktop._cl_keys import getKey, clearKey from calculate.desktop._cl_keys import getKey, clearKey
from calculate.lib.convertenv import convertEnv from calculate.lib.convertenv import convertEnv
from calculate.lib.encrypt import encrypt from calculate.lib.encrypt import encrypt
from client_cache import userCache from .client_cache import userCache
from shutil import copy2 from shutil import copy2
from socket import gethostbyname from socket import gethostbyname
import tarfile import tarfile
@ -48,6 +49,7 @@ from calculate.client.rsync import ProfileSyncer, ProfileSyncerError
from calculate.lib.utils.common import get_fastlogin_domain_path from calculate.lib.utils.common import get_fastlogin_domain_path
from calculate.lib.cl_lang import setLocalTranslate, getLazyLocalTranslate from calculate.lib.cl_lang import setLocalTranslate, getLazyLocalTranslate
from functools import reduce
_ = lambda x: x _ = lambda x: x
setLocalTranslate('cl_client3', sys.modules[__name__]) setLocalTranslate('cl_client3', sys.modules[__name__])
@ -203,7 +205,7 @@ class commandServer(color_print):
except ldap.INVALID_CREDENTIALS: except ldap.INVALID_CREDENTIALS:
errMessage = _("Wrong password") errMessage = _("Wrong password")
return False, errMessage return False, errMessage
except ldap.LDAPError, e: except ldap.LDAPError as e:
errMessage = e[0]['desc'] errMessage = e[0]['desc']
return False, errMessage return False, errMessage
return True, errMessage return True, errMessage
@ -218,10 +220,10 @@ class commandServer(color_print):
стандартного ввода (stdin) стандартного ввода (stdin)
pwDialog - структура для вывода приглашения в режиме диалога pwDialog - структура для вывода приглашения в режиме диалога
""" """
if optStdIn and options.has_key(optStdIn): if optStdIn and optStdIn in options:
pwdA = sys.stdin.readline().rstrip() pwdA = sys.stdin.readline().rstrip()
pwdB = sys.stdin.readline().rstrip() pwdB = sys.stdin.readline().rstrip()
elif optDialog and options.has_key(optDialog): elif optDialog and optDialog in options:
if not pwDialog: if not pwDialog:
pwDialog = [_("New password"), pwDialog = [_("New password"),
_("Retype the new password")] _("Retype the new password")]
@ -429,7 +431,7 @@ class Client(commandServer, encrypt, Desktop):
try: try:
if iniParser(configFileName).setVar( if iniParser(configFileName).setVar(
'rsync', {'files': rsync.getFilesNum()}): 'rsync', {'files': rsync.getFilesNum()}):
os.chmod(configFileName, 0600) os.chmod(configFileName, 0o600)
os.chown(configFileName, uid, gid) os.chown(configFileName, uid, gid)
except Exception: except Exception:
pass pass
@ -437,7 +439,7 @@ class Client(commandServer, encrypt, Desktop):
try: try:
if iniParser(configFileName).setVar( if iniParser(configFileName).setVar(
'rsync', {'exitcode': rsync.getExitCode()}): 'rsync', {'exitcode': rsync.getExitCode()}):
os.chmod(configFileName, 0600) os.chmod(configFileName, 0o600)
os.chown(configFileName, uid, gid) os.chown(configFileName, uid, gid)
except Exception: except Exception:
pass pass
@ -452,8 +454,8 @@ class Client(commandServer, encrypt, Desktop):
# get directory permissions # get directory permissions
mode = getModeFile(changeDir, mode="mode") mode = getModeFile(changeDir, mode="mode")
# if permission wrong( not 0700) then change it # if permission wrong( not 0700) then change it
if mode != 0700: if mode != 0o700:
os.chmod(changeDir, 0700) os.chmod(changeDir, 0o700)
return True return True
def clearHomeDir(self, homeDir): def clearHomeDir(self, homeDir):
@ -671,7 +673,7 @@ class Client(commandServer, encrypt, Desktop):
self.createUserDirectory(pathConfig, uid, gid) self.createUserDirectory(pathConfig, uid, gid)
try: try:
if iniParser(configFileName).setVar(nameSection, varsDict): if iniParser(configFileName).setVar(nameSection, varsDict):
os.chmod(configFileName, 0600) os.chmod(configFileName, 0o600)
os.chown(configFileName, uid, gid) os.chown(configFileName, uid, gid)
except Exception: except Exception:
return False return False
@ -688,7 +690,7 @@ class Client(commandServer, encrypt, Desktop):
self.createUserDirectory(pdir, uid, gid) self.createUserDirectory(pdir, uid, gid)
os.mkdir(userdir) os.mkdir(userdir)
os.chown(userdir, uid, gid) os.chown(userdir, uid, gid)
os.chmod(userdir, 0700) os.chmod(userdir, 0o700)
except OSError: except OSError:
raise ClientError(_("Failed to create the directory") + ". " + raise ClientError(_("Failed to create the directory") + ". " +
_("Permission denied: '%s'") % userdir) _("Permission denied: '%s'") % userdir)
@ -1433,7 +1435,7 @@ class Client(commandServer, encrypt, Desktop):
try: try:
if iniParser(configFileName).setVar( if iniParser(configFileName).setVar(
'rsync', {'exitcode': rsync.getExitCode()}): 'rsync', {'exitcode': rsync.getExitCode()}):
os.chmod(configFileName, 0600) os.chmod(configFileName, 0o600)
os.chown(configFileName, uid, gid) os.chown(configFileName, uid, gid)
except Exception: except Exception:
pass pass
@ -1445,8 +1447,8 @@ class Client(commandServer, encrypt, Desktop):
# get directory permissions # get directory permissions
mode = getModeFile(changeDir, mode="mode") mode = getModeFile(changeDir, mode="mode")
# if permission wrong( not 0700) then change it # if permission wrong( not 0700) then change it
if mode != 0700: if mode != 0o700:
os.chmod(changeDir, 0700) os.chmod(changeDir, 0o700)
self.endTask() self.endTask()
return True return True

@ -21,6 +21,7 @@ from calculate.lib.utils.files import getModeFile
from calculate.lib.cl_ldap import ldapUser from calculate.lib.cl_ldap import ldapUser
from calculate.lib.cl_lang import setLocalTranslate from calculate.lib.cl_lang import setLocalTranslate
from functools import reduce
_ = lambda x: x _ = lambda x: x
setLocalTranslate('cl_client3', sys.modules[__name__]) setLocalTranslate('cl_client3', sys.modules[__name__])
@ -289,7 +290,7 @@ class _shareCache(_shareData):
self.printERROR(_("Failed to create file %s") % self.fileName) self.printERROR(_("Failed to create file %s") % self.fileName)
return False return False
if self.getFileAccess(perm="WRITE"): if self.getFileAccess(perm="WRITE"):
modeFile = 0600 modeFile = 0o600
if getModeFile(self.fileName, mode="mode") != modeFile: if getModeFile(self.fileName, mode="mode") != modeFile:
os.chmod(self.fileName, modeFile) os.chmod(self.fileName, modeFile)
buff = "\n".join(map(lambda x: ":".join(x), self.data)) + "\n" buff = "\n".join(map(lambda x: ":".join(x), self.data)) + "\n"

@ -14,7 +14,9 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import action from __future__ import absolute_import
import client
from . import action
from . import client
section = "client" section = "client"

@ -244,7 +244,7 @@ class VariableUrUserPw(Variable, LdapHelper):
ldapInit.bind_s(userDN, password) ldapInit.bind_s(userDN, password)
except ldap.INVALID_CREDENTIALS: except ldap.INVALID_CREDENTIALS:
raise VariableError(_("Wrong password")) raise VariableError(_("Wrong password"))
except ldap.LDAPError, e: except ldap.LDAPError as e:
errMessage = e[0]['desc'] errMessage = e[0]['desc']
raise VariableError(errMessage) raise VariableError(errMessage)
return True return True
@ -409,7 +409,7 @@ class VariableClLdapData(ldapUser, ReadonlyVariable):
current server current server
""" """
searchPrevHost = self.searchPrevHost(userName, osLinuxShort) searchPrevHost = self.searchPrevHost(userName, osLinuxShort)
if searchPrevHost and searchPrevHost[0][0][1].has_key('host'): if searchPrevHost and 'host' in searchPrevHost[0][0][1]:
prevHost = searchPrevHost[0][0][1]['host'][0] prevHost = searchPrevHost[0][0][1]['host'][0]
else: else:
prevHost = None prevHost = None

@ -13,16 +13,17 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from __future__ import absolute_import
import sys import sys
from calculate.lib.datavars import VariableError, DataVarsError from calculate.lib.datavars import VariableError, DataVarsError
from calculate.core.server.func import WsdlBase from calculate.core.server.func import WsdlBase
from calculate.desktop.desktop import DesktopError from calculate.desktop.desktop import DesktopError
from client import ClientError from .client import ClientError
from calculate.lib.utils.samba import SambaError from calculate.lib.utils.samba import SambaError
from utils.cl_client import ClClientAction from .utils.cl_client import ClClientAction
from utils.cl_passwd import ClPasswdAction from .utils.cl_passwd import ClPasswdAction
from utils.cl_client_sync import (ClClientSyncLoginAction, from .utils.cl_client_sync import (ClClientSyncLoginAction,
ClClientSyncLogoutAction) ClClientSyncLogoutAction)
import calculate.desktop.desktop as desktop import calculate.desktop.desktop as desktop
import calculate.client.client as client import calculate.client.client as client

@ -1,4 +1,4 @@
#!/usr/bin/env python2 #!/usr/bin/env python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# setup.py --- Setup script for calculate-desktop # setup.py --- Setup script for calculate-desktop

Loading…
Cancel
Save