diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..35ea017 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +revert_changes_to_vmachine +push_to_vmachine* +.vscode +*.pyc +*.pyo +*.bak \ No newline at end of file diff --git a/pym/client/client.py b/pym/client/client.py index 9578aed..e86a9f1 100644 --- a/pym/client/client.py +++ b/pym/client/client.py @@ -14,6 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +from __future__ import absolute_import import os import stat import re @@ -39,7 +40,7 @@ from calculate.lib.utils.common import cmpVersion from calculate.desktop._cl_keys import getKey, clearKey from calculate.lib.convertenv import convertEnv from calculate.lib.encrypt import encrypt -from client_cache import userCache +from .client_cache import userCache from shutil import copy2 from socket import gethostbyname 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.cl_lang import setLocalTranslate, getLazyLocalTranslate +from functools import reduce _ = lambda x: x setLocalTranslate('cl_client3', sys.modules[__name__]) @@ -203,7 +205,7 @@ class commandServer(color_print): except ldap.INVALID_CREDENTIALS: errMessage = _("Wrong password") return False, errMessage - except ldap.LDAPError, e: + except ldap.LDAPError as e: errMessage = e[0]['desc'] return False, errMessage return True, errMessage @@ -218,10 +220,10 @@ class commandServer(color_print): стандартного ввода (stdin) pwDialog - структура для вывода приглашения в режиме диалога """ - if optStdIn and options.has_key(optStdIn): + if optStdIn and optStdIn in options: pwdA = 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: pwDialog = [_("New password"), _("Retype the new password")] @@ -429,7 +431,7 @@ class Client(commandServer, encrypt, Desktop): try: if iniParser(configFileName).setVar( 'rsync', {'files': rsync.getFilesNum()}): - os.chmod(configFileName, 0600) + os.chmod(configFileName, 0o600) os.chown(configFileName, uid, gid) except Exception: pass @@ -437,7 +439,7 @@ class Client(commandServer, encrypt, Desktop): try: if iniParser(configFileName).setVar( 'rsync', {'exitcode': rsync.getExitCode()}): - os.chmod(configFileName, 0600) + os.chmod(configFileName, 0o600) os.chown(configFileName, uid, gid) except Exception: pass @@ -452,8 +454,8 @@ class Client(commandServer, encrypt, Desktop): # get directory permissions mode = getModeFile(changeDir, mode="mode") # if permission wrong( not 0700) then change it - if mode != 0700: - os.chmod(changeDir, 0700) + if mode != 0o700: + os.chmod(changeDir, 0o700) return True def clearHomeDir(self, homeDir): @@ -671,7 +673,7 @@ class Client(commandServer, encrypt, Desktop): self.createUserDirectory(pathConfig, uid, gid) try: if iniParser(configFileName).setVar(nameSection, varsDict): - os.chmod(configFileName, 0600) + os.chmod(configFileName, 0o600) os.chown(configFileName, uid, gid) except Exception: return False @@ -688,7 +690,7 @@ class Client(commandServer, encrypt, Desktop): self.createUserDirectory(pdir, uid, gid) os.mkdir(userdir) os.chown(userdir, uid, gid) - os.chmod(userdir, 0700) + os.chmod(userdir, 0o700) except OSError: raise ClientError(_("Failed to create the directory") + ". " + _("Permission denied: '%s'") % userdir) @@ -1433,7 +1435,7 @@ class Client(commandServer, encrypt, Desktop): try: if iniParser(configFileName).setVar( 'rsync', {'exitcode': rsync.getExitCode()}): - os.chmod(configFileName, 0600) + os.chmod(configFileName, 0o600) os.chown(configFileName, uid, gid) except Exception: pass @@ -1445,8 +1447,8 @@ class Client(commandServer, encrypt, Desktop): # get directory permissions mode = getModeFile(changeDir, mode="mode") # if permission wrong( not 0700) then change it - if mode != 0700: - os.chmod(changeDir, 0700) + if mode != 0o700: + os.chmod(changeDir, 0o700) self.endTask() return True diff --git a/pym/client/client_cache.py b/pym/client/client_cache.py index 2612630..8b14c08 100644 --- a/pym/client/client_cache.py +++ b/pym/client/client_cache.py @@ -21,6 +21,7 @@ from calculate.lib.utils.files import getModeFile from calculate.lib.cl_ldap import ldapUser from calculate.lib.cl_lang import setLocalTranslate +from functools import reduce _ = lambda x: x setLocalTranslate('cl_client3', sys.modules[__name__]) @@ -289,7 +290,7 @@ class _shareCache(_shareData): self.printERROR(_("Failed to create file %s") % self.fileName) return False if self.getFileAccess(perm="WRITE"): - modeFile = 0600 + modeFile = 0o600 if getModeFile(self.fileName, mode="mode") != modeFile: os.chmod(self.fileName, modeFile) buff = "\n".join(map(lambda x: ":".join(x), self.data)) + "\n" diff --git a/pym/client/variables/__init__.py b/pym/client/variables/__init__.py index aa85411..127db29 100644 --- a/pym/client/variables/__init__.py +++ b/pym/client/variables/__init__.py @@ -14,7 +14,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -import action -import client +from __future__ import absolute_import + +from . import action +from . import client section = "client" diff --git a/pym/client/variables/client.py b/pym/client/variables/client.py index 27bc905..2e027c8 100644 --- a/pym/client/variables/client.py +++ b/pym/client/variables/client.py @@ -244,7 +244,7 @@ class VariableUrUserPw(Variable, LdapHelper): ldapInit.bind_s(userDN, password) except ldap.INVALID_CREDENTIALS: raise VariableError(_("Wrong password")) - except ldap.LDAPError, e: + except ldap.LDAPError as e: errMessage = e[0]['desc'] raise VariableError(errMessage) return True @@ -409,7 +409,7 @@ class VariableClLdapData(ldapUser, ReadonlyVariable): current server """ 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] else: prevHost = None diff --git a/pym/client/wsdl_client.py b/pym/client/wsdl_client.py index 0bf99e6..2fcf5b0 100644 --- a/pym/client/wsdl_client.py +++ b/pym/client/wsdl_client.py @@ -13,16 +13,17 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +from __future__ import absolute_import import sys from calculate.lib.datavars import VariableError, DataVarsError from calculate.core.server.func import WsdlBase from calculate.desktop.desktop import DesktopError -from client import ClientError +from .client import ClientError from calculate.lib.utils.samba import SambaError -from utils.cl_client import ClClientAction -from utils.cl_passwd import ClPasswdAction -from utils.cl_client_sync import (ClClientSyncLoginAction, +from .utils.cl_client import ClClientAction +from .utils.cl_passwd import ClPasswdAction +from .utils.cl_client_sync import (ClClientSyncLoginAction, ClClientSyncLogoutAction) import calculate.desktop.desktop as desktop import calculate.client.client as client diff --git a/setup.py b/setup.py index 80c6fa3..3579183 100755 --- a/setup.py +++ b/setup.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python # -*- coding: utf-8 -*- # setup.py --- Setup script for calculate-desktop