Added install and uninstall program

master3.3
Самоукин Алексей 14 years ago
parent 9f9f281326
commit 554f7996f7

@ -38,11 +38,6 @@ DESCRIPTION = _("Changes settings for connecting to domain")
# Опции командной строки
CMD_OPTIONS = [{'shortOption':"r",
'help':_("remove the settings for connecting to a domain")},
{'longOption':"install",
'help':_("add use of scripts this package for window manager")},
{'longOption':"uninstall",
'help':_("remove use of scripts this package for window \
manager and, if necessary, removes from domain")},
{'longOption':"mount",
'help':_("mount [remote] resource for domain")}]
@ -124,14 +119,6 @@ class client_cmd(share_cmd):
"""Вывод из домена"""
return self.logicObj.delDomain()
def install(self):
"""Инсталяция"""
return self.logicObj.installClient()
def uninstall(self):
"""Удаление"""
return self.logicObj.uninstallClient()
def mountRemote(self):
"""Монтирование remote и домашней директории если компьютер в домене

@ -0,0 +1,58 @@
#-*- 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, TitledHelpFormatter
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,
formatter=TitledHelpFormatter(),
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()

@ -0,0 +1,58 @@
#-*- 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, TitledHelpFormatter
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,
formatter=TitledHelpFormatter(),
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()

@ -52,14 +52,6 @@ if __name__ == "__main__":
# Вывод из домена
if not obj.delDomain():
sys.exit(1)
elif opts.install:
# Инсталяция
if not obj.install():
sys.exit(1)
elif opts.uninstall:
# Удаление
if not obj.uninstall():
sys.exit(1)
elif opts.mount:
# Монтирование remote
if not obj.mountRemote():

@ -0,0 +1,52 @@
#!/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.vars:
# Наложение шаблонов на систему при инсталяции
if not obj.installProg():
sys.exit(1)
# Запись переменных
if not obj.writeVars(opts):
sys.exit(1)
sys.exit(0)

@ -0,0 +1,54 @@
#!/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.vars:
# Наложение шаблонов на систему при деинсталяции
if not obj.uninstallProg():
sys.exit(1)
# Запись переменных
if not obj.writeVars(opts):
sys.exit(1)
sys.exit(0)

@ -21,6 +21,9 @@ 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"
__app__ = "calculate-client"
@ -99,6 +102,33 @@ 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__,
@ -112,10 +142,14 @@ setup(
packages = ['calculate-client.pym'],
data_files = data_files,
scripts=["./scripts/cl-sync-2.2",
"./scripts/cl-client-2.2"],
"./scripts/cl-client-2.2",
"./scripts/install",
"./scripts/uninstall"],
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},
cmdclass={'install_data': cl_install_data,
'build_scripts':cl_build_scripts,
'install_scripts':cl_install_scripts},
)

Loading…
Cancel
Save