py3 changes

py3_forced
idziubenko 3 years ago
parent 32ed0a3b0f
commit 89b8539539

6
.gitignore vendored

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

@ -42,7 +42,7 @@ def get_git_fetchhead(gitpath):
def get_git_head_commit(gitpath): def get_git_head_commit(gitpath):
headpath = os.path.join(gitpath, "HEAD") headpath = os.path.join(gitpath, "HEAD")
head = read_file(headpath) head = read_file(headpath)
m = re.search("^ref: (refs/heads/.*)$", head, re.M) m = re.search(r"^ref: (refs/heads/.*)$", head, re.M)
if m: if m:
commitfile = os.path.join(gitpath, m.group(1)) commitfile = os.path.join(gitpath, m.group(1))
return read_file(commitfile) return read_file(commitfile)
@ -73,11 +73,11 @@ def get_xorg_log_resolution():
with open(xlog, 'r') as f: with open(xlog, 'r') as f:
logdata = f.read() logdata = f.read()
for re_pat in ( for re_pat in (
"Output [\S]+ using initial mode (\d+)x(\d+)", r"Output [\S]+ using initial mode (\d+)x(\d+)",
"Virtual screen size determined to be" r"Virtual screen size determined to be"
" ([0-9]+)\s*x\s*([0-9]+)", r" ([0-9]+)\s*x\s*([0-9]+)",
'Setting mode "(\d+)x(\d+)[0-9@]"', r'Setting mode "(\d+)x(\d+)[0-9@]"',
"Virtual size is (\d+)x(\d+)"): r"Virtual size is (\d+)x(\d+)"):
reXorgLogParser = re.compile(re_pat, re.S) reXorgLogParser = re.compile(re_pat, re.S)
resXorgLogParser = reXorgLogParser.search(logdata) resXorgLogParser = reXorgLogParser.search(logdata)
if resXorgLogParser: if resXorgLogParser:

@ -39,8 +39,9 @@ class ImageViewer(QtGui.QMainWindow):
@staticmethod @staticmethod
def select_color(): def select_color():
try: try:
if filter(re.compile(r"(cld|cldx|cldg|cmc|cls)-themes-12").search, #TODO change for any in list compr?
os.listdir('/var/db/pkg/media-gfx')): if list(filter(re.compile(r"(cld|cldx|cldg|cmc|cls)-themes-12").search,
os.listdir('/var/db/pkg/media-gfx'))):
return "#73a363" return "#73a363"
except OSError: except OSError:
pass pass

@ -164,7 +164,7 @@ class Desktop(MethodsInterface):
tf.close() tf.close()
return True return True
def createUserDir(self, userName, uid, gid, userDir, mode=0700): def createUserDir(self, userName, uid, gid, userDir, mode=0o700):
""" """
Create user directory with need uid and gid Create user directory with need uid and gid
""" """
@ -201,10 +201,10 @@ class Desktop(MethodsInterface):
mountProfileDir = path.join(dirStart, ".%s" % dirEnd) mountProfileDir = path.join(dirStart, ".%s" % dirEnd)
mountRemoteProfileDir = path.join(dirStart, ".%s.remote" % dirEnd) mountRemoteProfileDir = path.join(dirStart, ".%s.remote" % dirEnd)
with open("/proc/mounts") as f: with open("/proc/mounts") as f:
return filter(lambda x: x.startswith(homeDir) or return list(filter(lambda x: x.startswith(homeDir) or
x.startswith(mountProfileDir) or x.startswith(mountProfileDir) or
x.startswith(mountRemoteProfileDir), x.startswith(mountRemoteProfileDir),
map(lambda x: x.split(" ")[1], f)) map(lambda x: x.split(" ")[1], f)))
def umountSleepPath(self, rpath): def umountSleepPath(self, rpath):
""" """
@ -335,17 +335,17 @@ class Desktop(MethodsInterface):
if uid: if uid:
uid = int(uid) uid = int(uid)
for i in range(0, postWaitTime): for i in range(0, postWaitTime):
if not filter(lambda x: "ksmserver" in x, if not list(filter(lambda x: "ksmserver" in x,
getRunCommands(uid=uid)): getRunCommands(uid=uid))):
break break
time.sleep(1) time.sleep(1)
time.sleep(1) time.sleep(1)
if filter(lambda x: "xdm/xdm\x00--logout" in x, if list(filter(lambda x: "xdm/xdm\x00--logout" in x,
getRunCommands()): getRunCommands())):
for i in range(0, waitTime): for i in range(0, waitTime):
if not filter(lambda x: "xdm/xdm\x00--logout" in x, if not list(filter(lambda x: "xdm/xdm\x00--logout" in x,
getRunCommands()): getRunCommands())):
return True return True
time.sleep(1) time.sleep(1)
else: else:

@ -14,7 +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.
import action from . import action
import desktop from . import desktop
section = "desktop" section = "desktop"

@ -59,9 +59,9 @@ class DomainInfoHelper(VariableInterface):
""" """
def getUserDataInFile(self, login, filePasswd): def getUserDataInFile(self, login, filePasswd):
return filter(lambda x: x[0] == login, return list(filter(lambda x: x[0] == login,
map(lambda x: x.strip().split(':'), map(lambda x: x.strip().split(':'),
readLinesFile(filePasswd))) readLinesFile(filePasswd))))
def isDomainUser(self, userName): def isDomainUser(self, userName):
if userName: if userName:
@ -93,9 +93,9 @@ class VariableUrDomainSet(ReadonlyVariable, DomainInfoHelper):
type = "bool" type = "bool"
def getUserDataInFile(self, login, file_passwd): def getUserDataInFile(self, login, file_passwd):
return filter(lambda x: x[0] == login, return list(filter(lambda x: x[0] == login,
map(lambda x: x.strip().split(':'), map(lambda x: x.strip().split(':'),
readLinesFile(file_passwd))) readLinesFile(file_passwd))))
def get(self): def get(self):
return "on" if self.isDomainUser(self.Get('ur_login')) else "off" return "on" if self.isDomainUser(self.Get('ur_login')) else "off"
@ -156,10 +156,10 @@ class VariableClDesktopGstData(ReadonlyVariable):
if res == gst.STATE_CHANGE_SUCCESS: if res == gst.STATE_CHANGE_SUCCESS:
outdata['device_name'] = alsamixer.get_property("device-name") outdata['device_name'] = alsamixer.get_property("device-name")
outdata['long_name'] = alsamixer.get_factory().get_longname() outdata['long_name'] = alsamixer.get_factory().get_longname()
outdata['internal_name'] = filter(str.isalnum, outdata['internal_name'] = list(filter(str.isalnum,
"%s (%s)" % ( "%s (%s)" % (
outdata['device_name'], outdata['device_name'],
outdata['long_name'])) outdata['long_name'])))
outdata['channels'] = [] outdata['channels'] = []
for t in alsamixer.list_tracks(): for t in alsamixer.list_tracks():
if t.flags & gst.interfaces.MIXER_TRACK_OUTPUT: if t.flags & gst.interfaces.MIXER_TRACK_OUTPUT:
@ -265,17 +265,17 @@ class VariableClDesktopOnlineData(ReadonlyTableVariable, DomainInfoHelper):
(x[2].startswith("(:") or (x[2].startswith("(:") or
x[1].startswith(":")), x[1].startswith(":")),
map(lambda x: listProcessing( map(lambda x: listProcessing(
filter(lambda y: y, x.split())), list(filter(lambda y: y, x.split()))),
resWho)))), resWho)))),
key=lambda x: x[0]), key=lambda x: x[0]),
lambda x: x[0]) lambda x: x[0])
xData = map(lambda x: (x[0][0], x[0][1], xData = list(map(lambda x: (x[0][0], x[0][1],
self.get_user_uid(x[0][0]), self.get_user_uid(x[0][0]),
"on" if self.isDomainUser( "on" if self.isDomainUser(
x[0][0]) else "off", x[0][0]) else "off",
len(x)), len(x)),
map(lambda x: list(x[1]), map(lambda x: list(x[1]),
xData)) xData)))
return xData return xData
setValue = Variable.setValue setValue = Variable.setValue
@ -461,11 +461,10 @@ class VariableClDesktopHashFace(Variable):
login = self.Get('ur_login') login = self.Get('ur_login')
icon_list = self.Get('cl_desktop_face_list') icon_list = self.Get('cl_desktop_face_list')
if icon_list: if icon_list:
# return path.join(self.Get('cl_desktop_face_path'),
# icon_list[sum(map(lambda x: ord(x), hashlib.md5(login).digest())) % len(icon_list)])
return path.join(self.Get('cl_desktop_face_path'), return path.join(self.Get('cl_desktop_face_path'),
icon_list[sum(map(lambda x: ord(x), icon_list[sum([x for x in hashlib.md5(login.encode("UTF-8")).digest()]) % len(icon_list)])
hashlib.md5(
login).digest())) % len(
icon_list)])
else: else:
return "" return ""

@ -17,9 +17,9 @@ 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 desktop import DesktopError from .desktop import DesktopError
from utils.cl_desktop import ClDesktopLogoutAction, ClDesktopAction from .utils.cl_desktop import ClDesktopLogoutAction, ClDesktopAction
import desktop from . import desktop
from calculate.lib.cl_lang import setLocalTranslate, getLazyLocalTranslate from calculate.lib.cl_lang import setLocalTranslate, getLazyLocalTranslate

@ -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