added more py3 related changes
This commit is contained in:
parent
584bc7da9f
commit
940b125820
14 changed files with 59 additions and 25 deletions
6
.gitignore
vendored
Normal file
6
.gitignore
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
revert_changes_to_vmachine
|
||||
push_to_vmachine*
|
||||
.vscode
|
||||
*.pyc
|
||||
*.pyo
|
||||
*.bak
|
21
bin/cl-core_py3
Normal file
21
bin/cl-core_py3
Normal file
|
@ -0,0 +1,21 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2012-2016 Mir Calculate. http://www.calculate-linux.org
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# 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.
|
||||
|
||||
import calculate.core.core_main as core_main
|
||||
|
||||
if __name__ == '__main__':
|
||||
core_main.core_main()
|
|
@ -22,8 +22,8 @@ import logging
|
|||
from calculate.console.application.client_class import Client_suds
|
||||
import os
|
||||
import sys
|
||||
# import urllib2
|
||||
import urllib.request as urllib2
|
||||
from urllib.error import URLError
|
||||
from calculate.core.datavars import DataVarsCore
|
||||
from calculate.core.client.function import clear
|
||||
from calculate.consolegui.application.client_class import (
|
||||
|
@ -81,7 +81,7 @@ def get_certifactions_for_host(host, use_dbus=False):
|
|||
client.wsdl.services[0].setlocation(url)
|
||||
server_host_name = client.service.get_server_host_name()
|
||||
del client
|
||||
except (urllib2.URLError, TransportError) as e:
|
||||
except (URLError, TransportError) as e:
|
||||
log.debug(_('Failed to connect', ) + _(': ') + str(e))
|
||||
return []
|
||||
except KeyboardInterrupt:
|
||||
|
|
|
@ -16,13 +16,13 @@
|
|||
|
||||
from __future__ import print_function
|
||||
from __future__ import absolute_import
|
||||
import urllib2 as u2
|
||||
import urllib.request as u2
|
||||
import os
|
||||
import sys
|
||||
import calculate.contrib
|
||||
from suds.transport.http import HttpTransport
|
||||
import httplib #http.client in python3
|
||||
from httplib import HTTPConnection
|
||||
import httplib.client #http.client in python3
|
||||
from httplib.client import HTTPConnection
|
||||
import socket
|
||||
import ssl
|
||||
import hashlib
|
||||
|
|
|
@ -17,8 +17,7 @@
|
|||
# from server.cl_server import main
|
||||
# print(main)
|
||||
|
||||
from __future__ import print_function
|
||||
from __future__ import absolute_import
|
||||
from importlib import reload
|
||||
def core_main():
|
||||
import sys
|
||||
|
||||
|
|
|
@ -261,7 +261,7 @@ class TaskState(object):
|
|||
i_value, i_comment = 0, 1
|
||||
answerByChar = map(lambda x: x[i_value][firstletter], answers)
|
||||
|
||||
if filter(lambda x: answerByChar.count(x) > 1, answerByChar):
|
||||
if list(filter(lambda x: answerByChar.count(x) > 1, answerByChar)):
|
||||
use_getch = False
|
||||
sa = slice(0, None)
|
||||
else:
|
||||
|
@ -287,8 +287,8 @@ class TaskState(object):
|
|||
printer("\n")
|
||||
raise KeyboardInterrupt
|
||||
ask = ask.lower()
|
||||
like_answers = filter(lambda x: x[i_value].startswith(ask),
|
||||
answers)
|
||||
like_answers = list(filter(lambda x: x[i_value].startswith(ask),
|
||||
answers))
|
||||
if not like_answers:
|
||||
self.state.printERROR(_('The answer is uncertain'))
|
||||
continue
|
||||
|
|
|
@ -21,7 +21,7 @@ from calculate.lib.utils.text import _u8
|
|||
import re
|
||||
from os import path
|
||||
from calculate.lib.cl_lang import getLazyLocalTranslate, setLocalTranslate
|
||||
from collections import MutableMapping
|
||||
from collections.abc import MutableMapping
|
||||
|
||||
_ = lambda x: x
|
||||
setLocalTranslate('cl_core3', sys.modules[__name__])
|
||||
|
|
|
@ -29,7 +29,6 @@ from calculate.lib.utils import ip as ip
|
|||
from calculate.core.datavars import DataVarsCore
|
||||
from calculate.lib.utils.files import readFile
|
||||
from calculate.lib.utils.text import _u8
|
||||
# import urllib2 as u2
|
||||
import urllib.request as u2
|
||||
|
||||
if hasattr(u2, "ssl"):
|
||||
|
@ -176,7 +175,7 @@ def check_server_certificate(cert, key, cert_path, args, port, auto=False):
|
|||
import calculate.contrib
|
||||
from suds.client import Client
|
||||
from .client_class import HTTPSClientsCertTransport
|
||||
from urllib2 import URLError
|
||||
from urllib.error import URLError
|
||||
|
||||
try:
|
||||
client = Client(url, transport=HTTPSClientsCertTransport(
|
||||
|
|
|
@ -46,7 +46,9 @@ _('No module named %s')
|
|||
@clearDataVars
|
||||
def main(*args, **keywords):
|
||||
_args = list(unpack_single_opts(sys.argv[1:]))
|
||||
if os.path.basename(sys.argv[0]) != 'cl-core':
|
||||
#TODO change back
|
||||
# if os.path.basename(sys.argv[0]) != 'cl-core':
|
||||
if False:
|
||||
parser = cert_cmd.parse(full=False)
|
||||
args, unknown_args = parser.parse_known_args(_args)
|
||||
args.method = '_temp_'
|
||||
|
@ -139,7 +141,7 @@ def main(*args, **keywords):
|
|||
except IOError:
|
||||
pass
|
||||
|
||||
from urllib2 import URLError
|
||||
from urllib.error import URLError
|
||||
|
||||
from traceback import print_exc
|
||||
|
||||
|
@ -208,7 +210,7 @@ def main(*args, **keywords):
|
|||
serv_certbase, certbase, data_path)
|
||||
return 0
|
||||
except BaseException as e:
|
||||
from urllib2 import URLError
|
||||
from urllib.error import URLError
|
||||
|
||||
if isinstance(e, URLError) and log_filename:
|
||||
if file_logger:
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
# limitations under the License.
|
||||
|
||||
from __future__ import print_function
|
||||
import urllib2 as u2
|
||||
import urllib.request as u2
|
||||
import os
|
||||
import sys
|
||||
import calculate.contrib
|
||||
|
|
|
@ -76,8 +76,8 @@ class CommonMethods(MethodsInterface):
|
|||
i_orig, i_data = 0, 1
|
||||
i_mime, i_cfgname = 0, 1
|
||||
cfg_files = getCfgFiles(prefix=prefix).items()
|
||||
info = filter(lambda x: (filesApply is None or
|
||||
x[i_data][0][i_cfgname] in filesApply),
|
||||
info = list(filter(lambda x: (filesApply is None or
|
||||
x[i_data][0][i_cfgname] in filesApply)),
|
||||
cfg_files)
|
||||
max_info = len(info)
|
||||
for ind, data in enumerate(info):
|
||||
|
|
|
@ -186,7 +186,10 @@ def local_method(metaObject, args, unknown_args):
|
|||
"""
|
||||
import os
|
||||
|
||||
sym_link = os.path.basename(sys.argv[0])
|
||||
# sym_link = os.path.basename(sys.argv[0])
|
||||
|
||||
#DEBUG - TODO remove this and uncomment thing above
|
||||
sym_link = "cl-core"
|
||||
if sym_link != 'cl-core':
|
||||
if sym_link in LoadedMethods.conMethods.keys():
|
||||
args.method = LoadedMethods.conMethods[sym_link][0]
|
||||
|
@ -220,6 +223,7 @@ def local_method(metaObject, args, unknown_args):
|
|||
try:
|
||||
view = getattr(metaObject, method_view_name)(metaObject, 0, view_obj)
|
||||
except AttributeError:
|
||||
print("DE")
|
||||
colorPrint.printERROR(_('Method not found: ') + method_view_name)
|
||||
return 1
|
||||
try:
|
||||
|
@ -266,6 +270,9 @@ def call_method(metaObject, args, unknown_args, colorPrint):
|
|||
"""
|
||||
Function for call method through metaObject and args
|
||||
"""
|
||||
print("METHODCALL")
|
||||
print(metaObject)
|
||||
print(dir(metaObject))
|
||||
method_name = args.method
|
||||
stdin_passwd = args.stdin_passwd
|
||||
method_view_name = method_name + '_view'
|
||||
|
|
|
@ -200,7 +200,7 @@ def get_method_argparser(view, args, cl_core=False):
|
|||
prog=progr, add_help=False, formatter_class=RawAndDefaultsHelpFormatter)
|
||||
parser.fixBoolVariables = fix_bool_variables
|
||||
|
||||
for Group in ifilter(lambda x: x.fields, get_list(view.groups)):
|
||||
for Group in filter(lambda x: x.fields, get_list(view.groups)):
|
||||
group = parser.add_argument_group(Group.name)
|
||||
for field in get_list(Group.fields):
|
||||
if field.element == 'error':
|
||||
|
@ -622,7 +622,7 @@ def collect_table(field, val_list, client, wait_thread=None,
|
|||
if hasattr(field.opt, "syntax") and field.opt.syntax:
|
||||
reArgs = re.compile(field.opt.syntax)
|
||||
# check for correct sentense
|
||||
for wrong in ifilterfalse(reArgs.search, val_list):
|
||||
for wrong in filterfalse(reArgs.search, val_list):
|
||||
# raise Error on wrong
|
||||
raise ValueError(_("Wrong %s value syntax") %
|
||||
(field.opt.shortopt or field.opt.longopt)
|
||||
|
@ -642,7 +642,7 @@ def collect_table(field, val_list, client, wait_thread=None,
|
|||
choiceValue = field.tablevalue.values.ChoiceValue
|
||||
choiceValue = filter(lambda x: x.typefield != 'readonly', choiceValue)
|
||||
lenChoiceValue = len(choiceValue)
|
||||
for wrong in ifilter(lambda x: len(x) > lenChoiceValue,
|
||||
for wrong in filter(lambda x: len(x) > lenChoiceValue,
|
||||
val_table):
|
||||
if type(wrong) in (list, tuple):
|
||||
wrong = ":".join(wrong)
|
||||
|
|
|
@ -34,10 +34,10 @@ class Variables(MethodsInterface):
|
|||
Write variable to env files, or delete from env files
|
||||
"""
|
||||
dv = self.clVars
|
||||
data = filter(lambda x: x[LOCATION] or
|
||||
data = list(filter(lambda x: x[LOCATION] or
|
||||
not x[LOCATION] and
|
||||
dv.isFromIni(x[VARIABLE]),
|
||||
vardata)
|
||||
vardata))
|
||||
if data:
|
||||
head = [_("Variable"), _("Mode"), _("Location"), _("Value")]
|
||||
self.printTable(_("List of variables"), head, data)
|
||||
|
|
Loading…
Add table
Reference in a new issue