Added options --install and --uninstall for cl-client

master3.3
Самоукин Алексей 14 years ago
parent a79597b440
commit 192c1bb893

@ -39,7 +39,11 @@ DESCRIPTION = _("Changes settings for connecting to domain")
CMD_OPTIONS = [{'shortOption':"r",
'help':_("remove the settings for connecting to a domain")},
{'longOption':"mount",
'help':_("mount [remote] resource for domain")}]
'help':_("mount [remote] resource for domain")},
{'longOption':"install",
'help':_("configure the system to install this package")},
{'longOption':"uninstall",
'help':_("configure the system to uninstall this package")}]
class client_cmd(share_cmd):
def __init__(self):
@ -58,7 +62,7 @@ class client_cmd(share_cmd):
# Создаем переменные
self.logicObj.createClVars()
# Названия несовместимых опций
self.optionsNamesIncompatible = ["r", "mount"]
self.optionsNamesIncompatible = ["r", "mount", "install", "uninstall"]
# Названия опций несовмесимых с именем домена
self.optionsNamesNotDomain = self.optionsNamesIncompatible
@ -124,3 +128,11 @@ class client_cmd(share_cmd):
а так-же ввод в домен если найдено имя хоста и пароль для подключения
"""
return self.logicObj.mountRemote()
def install(self):
"""Инсталяция программы"""
return self.logicObj.installClient()
def uninstall(self):
"""Удаление программы"""
return self.logicObj.uninstallClient()

@ -1,61 +0,0 @@
#-*- coding: utf-8 -*-
# Copyright 2010 Mir 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.
from cl_client import client, __app__, __version__
from cl_opt import opt
import sys
from cl_share_cmd import share_cmd
# Перевод сообщений для программы
from cl_lang import lang
lang().setLanguage(sys.modules[__name__])
# Использование программы
USAGE = _("%prog [options]")
# Описание программы (что делает программа)
DESCRIPTION = _("Configure the system to calculate-client package")
class install_cmd(share_cmd):
def __init__(self):
# Объект опций командной строки
self.optobj = opt(\
package=__app__,
version=__version__,
usage=USAGE,
description=DESCRIPTION,
option_list=opt.variable_control+opt.color_control,
check_values=self.checkOpts)
# Создаем объект логики
self.logicObj = client()
# Создаем переменные
self.logicObj.createClVars()
def checkOpts(self, optObj, args):
"""Проверка опций командной строки"""
if args:
errMsg = _("invalid argument") + ":" + " %s" %" ".join(args)
self.optobj.error(errMsg)
return False
return optObj, args
def installProg(self):
"""Наложение шаблонов на систему при инсталяции"""
return self.logicObj.installClient()
def updateEnvFiles(self):
"""Апдейт env файлов до новой версии"""
return self.logicObj.updateEnvFiles()

@ -1,57 +0,0 @@
#-*- coding: utf-8 -*-
# Copyright 2010 Mir 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.
from cl_client import client, __app__, __version__
from cl_opt import opt
import sys
from cl_share_cmd import share_cmd
# Перевод сообщений для программы
from cl_lang import lang
lang().setLanguage(sys.modules[__name__])
# Использование программы
USAGE = _("%prog [options]")
# Описание программы (что делает программа)
DESCRIPTION = _("Configure the system to calculate-client package")
class uninstall_cmd(share_cmd):
def __init__(self):
# Объект опций командной строки
self.optobj = opt(\
package=__app__,
version=__version__,
usage=USAGE,
description=DESCRIPTION,
option_list=opt.variable_control+opt.color_control,
check_values=self.checkOpts)
# Создаем объект логики
self.logicObj = client()
# Создаем переменные
self.logicObj.createClVars()
def checkOpts(self, optObj, args):
"""Проверка опций командной строки"""
if args:
errMsg = _("invalid argument") + ":" + " %s" %" ".join(args)
self.optobj.error(errMsg)
return False
return optObj, args
def uninstallProg(self):
"""Наложение шаблонов на систему при деинсталяции"""
return self.logicObj.uninstallClient()

@ -56,6 +56,14 @@ if __name__ == "__main__":
# Монтирование remote
if not obj.mountRemote():
sys.exit(1)
elif opts.install:
# Наложение шаблонов на систему при инсталяции
if not obj.install():
sys.exit(1)
elif opts.uninstall:
# Наложение шаблонов на систему при деинсталяции
if not obj.uninstall():
sys.exit(1)
# Запись переменных
if not obj.writeVars(opts):
sys.exit(1)

@ -1,56 +0,0 @@
#!/usr/bin/python
#-*- coding: utf-8 -*-
# Copyright 2010 Mir 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 sys
import os
sys.path.insert(0,os.path.abspath('/usr/lib/calculate-2.2/calculate-lib/pym'))
sys.path.insert(0,\
os.path.abspath('/usr/lib/calculate-2.2/calculate-client/pym'))
from cl_install_cmd import install_cmd
from cl_lang import lang
tr = lang()
tr.setGlobalDomain('cl_client')
tr.setLanguage(sys.modules[__name__])
if __name__ == "__main__":
obj = install_cmd()
ret = obj.optobj.parse_args()
if ret is False:
sys.exit(1)
opts, args = ret
# Установка цвета при печати сообщений
obj.setPrintNoColor(opts)
# Установка переменных
if not obj.setVars(opts):
sys.exit(1)
# Печать переменных
obj.printVars(opts)
# Если нет печати переменных выполняем логику программы
if not opts.v:
# Апдейт env файлов
if obj.updateEnvFiles():
# Перечитывание переменные шаблонов из env файлов
obj.logicObj.clVars.flIniFile()
# Наложение шаблонов на систему при инсталяции
if not obj.installProg():
sys.exit(1)
# Запись переменных
if not obj.writeVars(opts):
sys.exit(1)
sys.exit(0)

@ -1,54 +0,0 @@
#!/usr/bin/python
#-*- coding: utf-8 -*-
# Copyright 2010 Mir 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 sys
import os
sys.path.insert(0,os.path.abspath('/usr/lib/calculate-2.2/calculate-lib/pym'))
sys.path.insert(0,\
os.path.abspath('/usr/lib/calculate-2.2/calculate-client/pym'))
from cl_uninstall_cmd import uninstall_cmd
from cl_lang import lang
tr = lang()
tr.setGlobalDomain('cl_client')
tr.setLanguage(sys.modules[__name__])
if __name__ == "__main__":
obj = uninstall_cmd()
ret = obj.optobj.parse_args()
if ret is False:
sys.exit(1)
opts, args = ret
# Установка цвета при печати сообщений
obj.setPrintNoColor(opts)
# Установка переменных
if not obj.setVars(opts):
sys.exit(1)
# Печать переменных
obj.printVars(opts)
# Если нет печати переменных выполняем логику программы
if not opts.v:
# Наложение шаблонов на систему при деинсталяции
if not obj.uninstallProg():
sys.exit(1)
# Запись переменных
if not obj.writeVars(opts):
sys.exit(1)
sys.exit(0)

@ -21,9 +21,6 @@ import os
import stat
from distutils.core import setup, Extension
from distutils.command.install_data import install_data
from distutils.command.build_scripts import build_scripts
from distutils.command.install_scripts import install_scripts
__version__ = "2.2.0.0"
__app__ = "calculate-client"
@ -36,8 +33,6 @@ var_data_files = []
#data_dirs_template = ['templates']
data_dirs_share = ['i18n']
share_calculate_dir = "/usr/share/calculate"
#template_calculate_dir = os.path.join(share_calculate_dir, "templates")
#template_replace_dirname = "client"
def __scanDir(scanDir, prefix, replace_dirname, dirData, flagDir=False):
"""Scan directory"""
@ -110,39 +105,11 @@ class cl_install_data(install_data):
if flagFound:
os.chmod(path, mode)
class cl_build_scripts(build_scripts):
"""Class for build scripts"""
def run (self):
scripts = ['./scripts/install', './scripts/uninstall']
backup_build_dir = self.build_dir
backup_scripts = filter(lambda x: not x in scripts, self.scripts)
self.scripts = scripts
self.build_dir = self.build_dir + "-bin"
build_scripts.run(self)
self.scripts = backup_scripts
self.build_dir = backup_build_dir
build_scripts.run(self)
class cl_install_scripts(install_scripts):
"""Class for install scripts"""
def run (self):
backup_install_dir = self.install_dir
backup_build_dir = self.build_dir
cl_cmd_obj = self.distribution.get_command_obj("install")
self.build_dir = self.build_dir + "-bin"
self.install_dir = os.path.join(cl_cmd_obj.install_platlib, __app__,
"bin")
install_scripts.run(self)
self.build_dir = backup_build_dir
self.install_dir = backup_install_dir
install_scripts.run(self)
setup(
name = __app__,
version = __version__,
description = "Mounting resources and synchronize the user profile",
author = "Mir Calculate Ltd.",
author = "Calculate Ltd.",
author_email = "support@calculate.ru",
url = "http://calculate-linux.org",
license = "http://www.apache.org/licenses/LICENSE-2.0",
@ -151,14 +118,10 @@ setup(
data_files = data_files,
scripts=["./scripts/cl-sync",
"./scripts/cl-client",
"./scripts/cl-passwd",
"./scripts/install",
"./scripts/uninstall"],
"./scripts/cl-passwd"],
ext_modules = [Extension('calculate-client.pym._cl_keys',
library_dirs = ['/usr/lib'],
libraries = ['keyutils'],
sources = ['./lib/cl_keys.i', './lib/cl_keys.c'])],
cmdclass={'install_data': cl_install_data,
'build_scripts':cl_build_scripts,
'install_scripts':cl_install_scripts},
cmdclass={'install_data': cl_install_data},
)

Loading…
Cancel
Save