From eafaf6db3f4e8329e583f0ae0e891c763c5735f3 Mon Sep 17 00:00:00 2001 From: Mike Hiretsky Date: Wed, 26 Oct 2011 09:49:55 +0400 Subject: [PATCH] Update import paths. --- {pym => install}/__init__.py | 0 {pym => install}/cl_apply_template.py | 39 +++----- {pym => install}/cl_apply_template_cmd.py | 13 +-- {pym => install}/cl_distr.py | 25 +++-- {pym => install}/cl_fill_install.py | 106 +++++----------------- {pym => install}/cl_install.py | 62 ++++++------- {pym => install}/cl_install_cmd.py | 13 +-- {pym => install}/cl_kernel_utils.py | 8 +- {pym => install}/cl_migrate_users.py | 11 +-- {pym => install}/cl_share_cmd.py | 11 ++- {pym => install}/cl_vars_install.py | 3 +- install/cl_wsdl_install.py | 89 ++++++++++++++++++ setup.cfg | 4 +- setup.py | 7 +- 14 files changed, 204 insertions(+), 187 deletions(-) rename {pym => install}/__init__.py (100%) rename {pym => install}/cl_apply_template.py (87%) rename {pym => install}/cl_apply_template_cmd.py (95%) rename {pym => install}/cl_distr.py (98%) rename {pym => install}/cl_fill_install.py (94%) rename {pym => install}/cl_install.py (98%) rename {pym => install}/cl_install_cmd.py (98%) rename {pym => install}/cl_kernel_utils.py (98%) rename {pym => install}/cl_migrate_users.py (98%) rename {pym => install}/cl_share_cmd.py (93%) rename {pym => install}/cl_vars_install.py (98%) create mode 100644 install/cl_wsdl_install.py diff --git a/pym/__init__.py b/install/__init__.py similarity index 100% rename from pym/__init__.py rename to install/__init__.py diff --git a/pym/cl_apply_template.py b/install/cl_apply_template.py similarity index 87% rename from pym/cl_apply_template.py rename to install/cl_apply_template.py index 2c56772..2bf4a3a 100644 --- a/pym/cl_apply_template.py +++ b/install/cl_apply_template.py @@ -21,43 +21,30 @@ from cl_install import InstallError __version__ = cl_install.__version__ __app__ = cl_install.__app__ -from cl_datavars import DataVars -from cl_template import template, templateClt -from cl_print import color_print -import cl_overriding +from calculate.lib.cl_datavars import DataVars +from calculate.lib.cl_template import template, templateClt +from calculate.lib.cl_print import color_print +from calculate.lib import cl_overriding -import cl_lang -tr = cl_lang.lang() -tr.setLocalDomain('cl_install') -tr.setLanguage(sys.modules[__name__]) -#sys.path.insert(0, "/usr/lib/calculate-2.2/calculate-lib/pym") - -#packagePath = "/usr/lib/calculate-2.2" -#for path in os.listdir(packagePath): - #realPath = os.path.join(packagePath,path) - #if os.path.isdir(realPath): - #pymPath = os.path.join(realPath,"pym") - #if len(filter(lambda x:x.startswith("cl_vars_") and\ - #x.endswith(".py") or x.startswith("cl_fill_") and\ - #x.endswith(".py"), os.listdir(pymPath)))==2: - #sys.path.insert(0, os.path.abspath(pymPath)) +from calculate.lib.cl_lang import setLocalTranslate +setLocalTranslate('cl_install',sys.modules[__name__]) cl_overriding.exit = cl_install.defaultExit cl_overriding.printERROR = cl_install.defaultPrintERROR class DataVarsObject(DataVars): - """Класс переменных для десктопа""" + """Share class for variables""" def __init__(self, section): DataVars.__init__(self) self.section=section def importDataObject(self, **args): - '''Заполнить конфигурацию переменных, для десктопа''' - # Имя секции в calculate.env - #envSection = "calculate-desktop" - # заполнить переменные окружения алгоритмом по умолнанию - self.importData(self.section, ('cl_vars_%s' %self.section, - 'cl_fill_%s' %self.section)) + """Filling variables for section""" + self.importData(self.section, + ('calculate.{package}.cl_vars_{package}'.format( + package=self.section), + 'calculate.{package}.cl_fill_{package}'.format( + package=self.section))) self.flIniFile() class updateConfFiles(color_print): diff --git a/pym/cl_apply_template_cmd.py b/install/cl_apply_template_cmd.py similarity index 95% rename from pym/cl_apply_template_cmd.py rename to install/cl_apply_template_cmd.py index cc6aa60..f2ba2ca 100644 --- a/pym/cl_apply_template_cmd.py +++ b/install/cl_apply_template_cmd.py @@ -15,14 +15,15 @@ # limitations under the License. import os, sys, re +from os import path from cl_apply_template import updateConfFiles, __app__, __version__ -from cl_opt import opt -from cl_share_cmd import share_cmd -from cl_lang import lang -from cl_utils import listDirectory,pathJoin -from os import path -lang().setLanguage(sys.modules[__name__]) +from calculate.lib.cl_opt import opt +from calculate.install.cl_share_cmd import share_cmd +from calculate.lib.utils.files import listDirectory,pathJoin + +from calculate.lib.cl_lang import setLocalTranslate +setLocalTranslate('cl_install',sys.modules[__name__]) USAGE = _("%prog [options] path_to_clt_file") diff --git a/pym/cl_distr.py b/install/cl_distr.py similarity index 98% rename from pym/cl_distr.py rename to install/cl_distr.py index 6b3da28..d0cd37a 100644 --- a/pym/cl_distr.py +++ b/install/cl_distr.py @@ -18,28 +18,27 @@ from os import path from random import choice import string import os -import types from time import sleep import re import sys import operator -from cl_utils import runOsCommand,isMount,removeDir,typeFile,pathJoin, \ - process,getRunCommands,getTupleVersion,cmpVersion, \ - detectDeviceForPartition, getProgPath,listDirectory, \ - checkUtils,STDOUT,getUdevDeviceInfo, countPartitions -from cl_vars_share import varsShare from shutil import copyfile,copytree -from cl_template import _terms from subprocess import Popen,PIPE,STDOUT -from cl_fill import fillVars -from cl_vars_share import varsShare + +from calculate.lib.utils.files import (runOsCommand,isMount,removeDir, + typeFile,pathJoin,process,getRunCommands, + getProgPath,listDirectory,checkUtils) +from calculate.lib.utils.common import getTupleVersion,cmpVersion +from calculate.lib.utils.device import (detectDeviceForPartition, + getUdevDeviceInfo, countPartitions) +from calculate.lib.cl_vars_share import varsShare +from calculate.lib.cl_template import _terms +from calculate.lib.cl_fill import fillVars import threading -from cl_lang import lang -tr = lang() -tr.setLocalDomain('cl_install') -tr.setLanguage(sys.modules[__name__]) +from calculate.lib.cl_lang import setLocalTranslate +setLocalTranslate('cl_install',sys.modules[__name__]) class SignalInterrupt: __interruptProcessObjs = [] diff --git a/pym/cl_fill_install.py b/install/cl_fill_install.py similarity index 94% rename from pym/cl_fill_install.py rename to install/cl_fill_install.py index 0e2c057..2038fc1 100644 --- a/pym/cl_fill_install.py +++ b/install/cl_fill_install.py @@ -18,32 +18,30 @@ import os import sys import re from crypt import crypt -import cl_overriding -from cl_datavars import glob_attr +from calculate.lib.cl_vars_share import varsShare from os import path from os import readlink,access,R_OK -from cl_utils import isMount,typeFile,getTupleVersion,pathJoin,isFstabMount,\ - listDirectory, getAvailableVideo, getUUIDDict, \ - getUdevDeviceInfo, getPartitionDevice, getPartitionSize, \ - isPkgInstalled, process, checkUtils, readLinesFile, \ - FStab, lspci, getInstalledVideo,getDeviceType, \ - getPartitionType, getOsProberHash, getProgPath, \ - getRaidPartitions, getLvmPartitions, getLvmGroups, \ - getPasswdUsers -from cl_distr import DistributiveRepository,PartitionDistributive -from cl_fill import clLocale +from calculate.lib.utils.files import (listDirectory, pathJoin,process, + checkUtils, readLinesFile, FStab, getProgPath) +from calculate.lib.utils.common import (getTupleVersion, getAvailableVideo, + getInstalledVideo, getPasswdUsers) +from calculate.lib.utils.portage import isPkgInstalled +from calculate.lib.utils.device import (getUUIDDict, getUdevDeviceInfo, + getPartitionDevice, getPartitionSize, lspci, + getDeviceType, getPartitionType, getOsProberHash, + getRaidPartitions, getLvmPartitions) +from calculate.lib.utils import ip +from calculate.lib.cl_fill import clLocale +from calculate.lib.cl_template import _terms +from calculate.install.cl_distr import (DistributiveRepository, + PartitionDistributive) +from calculate.install.cl_install import convertDictOpt from operator import itemgetter -from cl_template import _terms -from subprocess import PIPE, Popen -from cl_install import convertDictOpt -from utils import ip -from cl_lang import lang -tr = lang() -tr.setLocalDomain('cl_install') -tr.setLanguage(sys.modules[__name__]) +from calculate.lib.cl_lang import setLocalTranslate +setLocalTranslate('cl_install',sys.modules[__name__]) -class fillVars(object, glob_attr): +class fillVars(object, varsShare): nonTransferedDirs = ["/","/bin", "/dev", "/etc", "/lib", "/lib32", "/lib64", "/opt", "/proc", "/sbin", @@ -645,68 +643,12 @@ class fillVars(object, glob_attr): %(x[0],x[1]), bindData)) return "\n".join(filter(lambda x: x, [rootLine,otherLines,bindLines])) - - - #def get_os_net_config_info(self): - #"""Content of /etc/conf.d/net file""" - - #def getNetGateways(): - #"""Get the network gateways""" - #execStr = 'route -n' - #res = self._runos(execStr,env={"LANG":"C"}) - #if res is False: - #cl_overriding.printERROR("Failed to execute '%s'"%execStr) - #cl_overriding.exit(1) - #flagData = False - ## retData = {'eth0':'10.0.0.1' ...} - #retData = {} - #for line in res: - #if flagData: - #routeData = map(lambda y: y.strip(), - #filter(lambda x: x, line.split(" "))) - #if len(routeData) == 8: - #if routeData[3] == "UG" and routeData[7]!="lo": - #retData[routeData[7]] = routeData[1] - #if line.startswith('Destination'): - #flagData = True - #return retData - - #strIpAllow = self.Get('os_net_ip') - #strNetAllow = self.Get('os_net_allow') - #strInterfInfo = self.Get('os_net_interfaces_info') - #systemName = self.Get('os_linux_shortname') - #ret = "" - #retList = [] - #gatewaysData = getNetGateways() - #if strIpAllow and strNetAllow: - #listDevInfo = map(lambda x: x.split(" "),strInterfInfo.split(",")) - #listDevInfo = map(lambda x: (x[0], x[1][1:-1]),listDevInfo) - #listDevInfo = filter(lambda x: x[1]!="Off" ,listDevInfo) - #listIpNet = map(lambda x: (x[0],"%s/%s"%(x[1],x[2])), - #zip(listDevInfo,strIpAllow.split(","), - #map(lambda x: x.partition("/")[2], - #strNetAllow.split(",")))) - #flagNotPlug = not systemName in ("CLS") - #for info, ipNet in listIpNet: - #dev, data = info - #if data=="DHCP": - #retList.append('config_%s=( "dhcp" )'%dev) - #if flagNotPlug: - #retList.append('modules_%s=( "!plug" )'%dev) - #else: - #retList.append('config_%s=( %s )'%(dev,ipNet)) - #if gatewaysData and dev in gatewaysData: - #retList.append('routes_%s=( "default gw %s" )'\ - #%(dev,gatewaysData[dev])) - #if flagNotPlug: - #retList.append('modules_%s=( "!plug" )'%dev) - #return "\n".join(retList) - def _comment(self,s,mp,dev): - if s.startswith("UUID"): - return "# %s was on %s during installation\n%s" % (mp,dev,s) - else: - return s + """Generate comment for /etc/fstab each line""" + if s.startswith("UUID"): + return "# %s was on %s during installation\n%s" % (mp,dev,s) + else: + return s def get_os_install_fstab_swap_conf(self): """Information about swap for fstab""" diff --git a/pym/cl_install.py b/install/cl_install.py similarity index 98% rename from pym/cl_install.py rename to install/cl_install.py index 0af020c..7f25d21 100644 --- a/pym/cl_install.py +++ b/install/cl_install.py @@ -22,21 +22,25 @@ import re import sys import traceback from os import path -from cl_utils import runOsCommand,appendProgramToEnvFile, \ - removeProgramToEnvFile,pathJoin, \ - scanDirectory,process,getTupleVersion, \ - detectDeviceForPartition,listDirectory, \ - cmpVersion,STDOUT,getUdevDeviceInfo, \ - getLvmPartitions,getInstalledVideo, \ - getSupportArch, refreshLVM, refreshUdev -from cl_vars_share import varsShare +from StringIO import StringIO +from time import sleep +from subprocess import PIPE,STDOUT +from shutil import copy2 +from calculate.lib.utils.files import (runOsCommand,pathJoin,scanDirectory, + process,listDirectory,STDOUT) +from calculate.lib.utils.common import (appendProgramToEnvFile, + removeProgramToEnvFile, getTupleVersion, + cmpVersion,getUserPassword, + getSupportArch, getInstalledVideo ) +from calculate.lib.utils.device import (detectDeviceForPartition, + getUdevDeviceInfo, getLvmPartitions, refreshLVM, + refreshUdev) +from calculate.lib.cl_vars_share import varsShare +from calculate.lib import cl_overriding +from calculate.lib.utils import ip from cl_kernel_utils import KernelConfig,InitRamFs -import cl_overriding -from StringIO import StringIO -from utils import ip - install_errors = "" def installExit(*args,**kwars): raise InstallError(globals()["install_errors"]) @@ -55,26 +59,21 @@ def pop_install_errors(): defaultExit = cl_overriding.exit defaultPrintERROR = cl_overriding.printERROR -from cl_lang import lang -from cl_fill import clLocale -from cl_template import template -from cl_datavars import DataVars -from cl_print import color_print -from cl_distr import PartitionDistributive,DistributiveRepository,\ - DistributiveError, ScratchPartitionDistributive, \ - MultiPartitions, Spinner, FlashDistributive, SignalInterrupt,\ - Distributive -from cl_string import tableReport -from time import sleep -from subprocess import PIPE,STDOUT -from server.utils import dialogYesNo +from calculate.lib.cl_fill import clLocale +from calculate.lib.cl_template import template +from calculate.lib.cl_datavars import DataVars +from calculate.lib.cl_print import color_print +from cl_distr import (PartitionDistributive,DistributiveRepository, + DistributiveError, ScratchPartitionDistributive, + MultiPartitions, Spinner, FlashDistributive, SignalInterrupt, + Distributive) +from calculate.lib.utils.text import tableReport +from calculate.lib.server.utils import dialogYesNo from cl_migrate_users import migrate, currentUsers -from cl_utils import getUserPassword -from encrypt import encrypt -from shutil import copy2 +from calculate.lib.encrypt import encrypt -from cl_lang import lang -lang().setLanguage(sys.modules[__name__]) +from calculate.lib.cl_lang import setLocalTranslate +setLocalTranslate('cl_install',sys.modules[__name__]) class InstallError(Exception): """Installation Error""" @@ -92,7 +91,8 @@ class DataVarsInstall(DataVars): # Имя секции в calculate.env envSection = "install" # заполнить переменные окружения алгоритмом по умолнанию - self.importData(envSection, ('cl_vars_install','cl_fill_install')) + self.importData(envSection, ('calculate.install.cl_vars_install', + 'calculate.install.cl_fill_install')) class convertDictOpt: diff --git a/pym/cl_install_cmd.py b/install/cl_install_cmd.py similarity index 98% rename from pym/cl_install_cmd.py rename to install/cl_install_cmd.py index 7706961..d06bbbc 100644 --- a/pym/cl_install_cmd.py +++ b/install/cl_install_cmd.py @@ -19,14 +19,15 @@ import sys from cl_install import cl_install, InstallError, __app__, __version__,\ get_install_errors -from cl_vars_share import varsShare -from cl_opt import opt +from calculate.lib.cl_vars_share import varsShare +from calculate.lib.cl_opt import opt from cl_share_cmd import share_cmd -from utils import ip as iputils -from cl_utils import isPkgInstalled +from calculate.lib.utils import ip as iputils +from calculate.lib.utils.portage import isPkgInstalled + +from calculate.lib.cl_lang import setLocalTranslate +setLocalTranslate('cl_install',sys.modules[__name__]) -from cl_lang import lang -lang().setLanguage(sys.modules[__name__]) OSSYSTEM_LIST=sorted(varsShare.dictNameSystem.keys()) NM_LIST=sorted(varsShare.dictNetworkManagers.keys()) diff --git a/pym/cl_kernel_utils.py b/install/cl_kernel_utils.py similarity index 98% rename from pym/cl_kernel_utils.py rename to install/cl_kernel_utils.py index 2cae14b..cba6f34 100644 --- a/pym/cl_kernel_utils.py +++ b/install/cl_kernel_utils.py @@ -14,14 +14,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -from cl_utils import typeFile, process, listDirectory -import gzip import re import os from os import path from os import access,R_OK -from subprocess import PIPE -from shutil import rmtree,copy2 +from shutil import copy2 +import gzip + +from calculate.lib.utils.files import typeFile, process, listDirectory class KernelConfig: """Object for work with kernel config diff --git a/pym/cl_migrate_users.py b/install/cl_migrate_users.py similarity index 98% rename from pym/cl_migrate_users.py rename to install/cl_migrate_users.py index 1c060ec..54160ef 100644 --- a/pym/cl_migrate_users.py +++ b/install/cl_migrate_users.py @@ -15,14 +15,13 @@ # limitations under the License. import os, sys, re, time -from cl_utils import pathJoin -from cl_print import color_print -from encrypt import encrypt +from calculate.lib.encrypt import encrypt from os import path -from cl_utils import pathJoin +from calculate.lib.utils.files import pathJoin +from calculate.lib.cl_print import color_print -from cl_lang import lang -lang().setLanguage(sys.modules[__name__]) +from calculate.lib.cl_lang import setLocalTranslate +setLocalTranslate('cl_install',sys.modules[__name__]) class _shareData: diff --git a/pym/cl_share_cmd.py b/install/cl_share_cmd.py similarity index 93% rename from pym/cl_share_cmd.py rename to install/cl_share_cmd.py index 568d451..adb18fb 100644 --- a/pym/cl_share_cmd.py +++ b/install/cl_share_cmd.py @@ -17,14 +17,15 @@ import sys import os -from cl_print import color_print -from cl_utils import _error +from calculate.lib.cl_print import color_print +from calculate.lib.utils.common import _error import cl_install # Перевод сообщений для программы -from cl_lang import lang -lang().setLanguage(sys.modules[__name__]) -import cl_overriding +from calculate.lib.cl_lang import setLocalTranslate +setLocalTranslate('cl_install',sys.modules[__name__]) + +from calculate.lib import cl_overriding class share_cmd(color_print, _error): """Класс общих методов обработки опций командной строки""" diff --git a/pym/cl_vars_install.py b/install/cl_vars_install.py similarity index 98% rename from pym/cl_vars_install.py rename to install/cl_vars_install.py index 8d7f59d..eb3739b 100644 --- a/pym/cl_vars_install.py +++ b/install/cl_vars_install.py @@ -1,6 +1,6 @@ #-*- coding: utf-8 -*- -# Copyright 2010 Calculate Ltd. http://www.calculate-linux.org +# Copyright 2010-2012 Calculate Ltd. 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. @@ -13,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -#Допустимые ключи значений # mode - read only or writeable variable # value - default variable value # select - list of posible values for variable diff --git a/install/cl_wsdl_install.py b/install/cl_wsdl_install.py new file mode 100644 index 0000000..31f7e3d --- /dev/null +++ b/install/cl_wsdl_install.py @@ -0,0 +1,89 @@ +#-*- coding: utf-8 -*- + +# Copyright 2010-2012 Calculate Ltd. 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 soaplib, sys, time + +import lxml.etree +from soaplib.serializers.primitive import String, Integer, Any +from soaplib.serializers.clazz import Array + +from soaplib.serializers.clazz import ClassSerializer +from soaplib.service import rpc + +class NewType (ClassSerializer): + helper = Integer + value = Any + +class UserInfo(ClassSerializer): + name = String + surname = String + +class GroupInfo(ClassSerializer): + name = String + gid = Integer + +class UserInfoValue (ClassSerializer): + table = UserInfo + +class GroupInfoValue (ClassSerializer): + table = GroupInfo + +# Класс с выполняемым кодом +class Wsdl: + + def install (self, name, times) : + try: + results = [] + self.writeFile() + for i in range( 0, times ) : + results.append('Hello!!!, %s %d'%(name, i)) + # Помещение данных в словарь процессов + self.setData (results) + + # Учёт процесса выполнения + while self.getPercent() < 100: + time.sleep(2) + # Увеличение процента выполнения процесса + self.addPercent (20) + return True + # Обработка сигнала прерывания работы процесса + except KeyboardInterrupt: + # Необходимо передать Fasle для сохранения данных о процессе + return False + + import sys, os + #sys.path.insert(0,os.path.abspath('~/Home/mydir/source/my/soap/temp')) + from baseClass import Basic, check_permissions + + @rpc( NewType, UserInfoValue, _returns = Array( String ) ) + def func (self, a, b): + return [] + + @rpc( String, Integer, Array(String), Integer, Integer, String,\ + #_inVariableNames = {'_stri':'stri', "a" : "a"},\ + _returns = NewType, _outVariableName='return') #Array( String ) ) + # проверка прав на вызов функции + @check_permissions() + # кэширование параметров + @Basic.cache + # команда для консоли + @Basic.console('cl-say-hello') + @Basic.gui('Misc') + #def say_hello_view + def say_hello ( self, cert, sid, name, times, a = 5, _stri = "stri_"): + install = type("CommonInstall",(self.Common, Wsdl, object), {}) + return self.startprocess(sid, target=install,method="install", + args_proc = (name[0], times)) diff --git a/setup.cfg b/setup.cfg index 1b8519f..ef3306a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -3,6 +3,6 @@ install_dir=/usr/share [install] install-scripts=/usr/bin -install-purelib=/usr/lib/calculate-2.2 -install-platlib=/usr/lib/calculate-2.2 +#install-purelib=/usr/lib/calculate-2.2 +#install-platlib=/usr/lib/calculate-2.2 #install-data=/usr/lib/calculate-2.2/calculate-install diff --git a/setup.py b/setup.py index fb4b6b0..2c7d5ae 100755 --- a/setup.py +++ b/setup.py @@ -173,11 +173,10 @@ setup( author_email = "support@calculate.ru", url = "http://calculate-linux.org", license = "http://www.apache.org/licenses/LICENSE-2.0", - package_dir = {'calculate-install': "."}, - packages = ['calculate-install.pym'], + package_dir = {'calculate.install': "install"}, + packages = ['calculate.install'], data_files = data_files, - scripts=["./scripts/cl-install", - "./scripts/cl-template"], + scripts=[], cmdclass={'install_data': cl_install_data, 'build':build,'build_man':build_man, 'install':install,'install_man':install_man},