From: Donghoon Shin Date: Fri, 9 Sep 2016 14:26:24 +0000 (+0000) Subject: Change projects/topology file location X-Git-Tag: 0.3.3~22^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=25e04b432bec948b300f5477c0b735591842ceab;p=tools%2Flitmus.git Change projects/topology file location --- diff --git a/debian/postinst b/debian/postinst index 769f92f..65629a5 100644 --- a/debian/postinst +++ b/debian/postinst @@ -35,10 +35,6 @@ esac # generated by other debhelper scripts. [ -x /sbin/udevadm ] && /sbin/udevadm control --reload-rules -chmod 666 /etc/litmus/topology -chmod 666 /etc/litmus/projects -groupadd -f litmus -usermod -aG litmus ${SUDO_USER} #DEBHELPER# diff --git a/litmus/__init__.py b/litmus/__init__.py index 7abbcb8..d2c8074 100644 --- a/litmus/__init__.py +++ b/litmus/__init__.py @@ -12,10 +12,13 @@ # 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 os __version__ = '0.2.1' -_duts_ = '/etc/litmus/topology' -_projects_ = '/etc/litmus/projects' +_homedir_ = os.path.expanduser('~') +_confdir_ = os.path.join(_homedir_, '.litmus') +_duts_ = os.path.join(_confdir_, 'topology') +_projects_ = os.path.join(_confdir_, 'projects') _tmpdir_ = '/tmp' _path_for_locks_ = '/var/lock/litmus/' _dev_types_ = ('u3', 'xu3', 'empty') diff --git a/litmus/cmds/cmd_adhoc.py b/litmus/cmds/cmd_adhoc.py index e8a228c..a1de8e6 100755 --- a/litmus/cmds/cmd_adhoc.py +++ b/litmus/cmds/cmd_adhoc.py @@ -23,7 +23,6 @@ def main(args): project_path = os.path.abspath(args.project_path) sys.path.append(project_path) - call(['chgrp', '-R', 'litmus', project_path]) call(['chmod', '-R', '775', project_path]) import userscript diff --git a/litmus/cmds/cmd_cp.py b/litmus/cmds/cmd_cp.py index d6a7c0a..9ad676c 100755 --- a/litmus/cmds/cmd_cp.py +++ b/litmus/cmds/cmd_cp.py @@ -43,7 +43,6 @@ def main(args): description = args.description os.mkdir(path) copy(orig['path'], path) - call(['chgrp', '-R', 'litmus', path]) call(['chmod', '-R', '775', path]) with open(_projects_, 'a') as f: diff --git a/litmus/cmds/cmd_imp.py b/litmus/cmds/cmd_imp.py index 2730daa..91de1b8 100755 --- a/litmus/cmds/cmd_imp.py +++ b/litmus/cmds/cmd_imp.py @@ -58,7 +58,6 @@ def main(args): raise Exception('There\'s no litmus project scripts at {0}' .format(prj_path)) - call(['chgrp', '-R', 'litmus', prj_path]) call(['chmod', '-R', '775', prj_path]) with open(_projects_, 'a') as f: diff --git a/litmus/cmds/cmd_mk.py b/litmus/cmds/cmd_mk.py index 5b0856d..beda788 100755 --- a/litmus/cmds/cmd_mk.py +++ b/litmus/cmds/cmd_mk.py @@ -51,7 +51,6 @@ def main(args): src = os.path.join(os.path.join(litmus.__path__[0], 'templates'), dev_type) copy(src, path) - call(['chgrp', '-R', 'litmus', path]) call(['chmod', '-R', '775', path]) with open(_projects_, 'a') as f: diff --git a/litmus/core/manager.py b/litmus/core/manager.py index 1dd14d3..8c71909 100644 --- a/litmus/core/manager.py +++ b/litmus/core/manager.py @@ -108,10 +108,9 @@ Lightweight test manager for tizen automated testing gotten_tlock = dev['tlock'].acquire(blocking=False) gotten_ilock = dev['ilock'].acquire(blocking=False) try: - shutil.chown(dev['ilock'].path, group='litmus') os.chmod(dev['ilock'].path, 0o664) except PermissionError: - logging.debug('Can\'t change owner and permission') + logging.debug('Can\'t change lock file permission') # if acquire tlock and ilock, assign a device. if gotten_tlock and gotten_ilock: diff --git a/litmus/device/device.py b/litmus/device/device.py index 2e10a77..9d9123a 100644 --- a/litmus/device/device.py +++ b/litmus/device/device.py @@ -16,7 +16,6 @@ import os import time import serial -import shutil import logging import fasteners from threading import Thread, Lock @@ -529,10 +528,10 @@ class device(object): self._global_ilock.acquire() # set gid of ilock file try: - shutil.chown(self._global_ilock.path, group='litmus') os.chmod(self._global_ilock.path, 0o664) except PermissionError: - pass + logging.debug('Can\'t change lock file permission') + if self._global_tlock.locked() and self._global_ilock.acquired: logging.debug('global lock acquired for {}' .format(self.get_id())) diff --git a/setup.py b/setup.py index 981c6d9..2c22612 100644 --- a/setup.py +++ b/setup.py @@ -18,7 +18,6 @@ import os from setuptools import setup, find_packages PROJECT_NAME = 'litmus' -ETC_PATH = os.path.join('/etc', PROJECT_NAME) version = re.search("__version__.*'(.+)'", open(os.path.join(PROJECT_NAME, '__init__.py')) @@ -33,7 +32,6 @@ setup(name=PROJECT_NAME, url="http://www.tizen.org", package_dir={PROJECT_NAME: 'litmus'}, packages=find_packages(exclude=['litmus.templates']), - data_files=[(ETC_PATH, ['tools/projects', 'tools/topology'])], include_package_data=True, license="Apache", platforms='any', diff --git a/tools/litmus b/tools/litmus index 5af569e..709faf5 100644 --- a/tools/litmus +++ b/tools/litmus @@ -16,12 +16,11 @@ import os import sys import signal -import shutil import functools import logging import traceback from argparse import ArgumentParser, RawTextHelpFormatter -from litmus import __version__, _path_for_locks_ +from litmus import __version__, _path_for_locks_, _duts_, _projects_, _confdir_ from litmus.core.util import init_logger @@ -151,11 +150,34 @@ def init_lockdir(): """docstring for init_lockdir""" if not os.path.exists(_path_for_locks_): os.mkdir(_path_for_locks_) - try: - shutil.chown(_path_for_locks_, group='litmus') - os.chmod(_path_for_locks_, 0o775) - except PermissionError: - pass + try: + os.chmod(_path_for_locks_, 0o775) + except PermissionError: + logging.debug('Can\'t change lock directory permission') + + +def init_confdir(): + """docstring for init_confdir""" + if not os.path.exists(_confdir_): + os.mkdir(_confdir_) + try: + os.chmod(_confdir_, 0o775) + except PermissionError: + logging.debug('Can\'t change config directory permission') + + if not os.path.exists(_duts_): + open(_duts_, 'a').close() + try: + os.chmod(_duts_, 0o664) + except PermissionError: + logging.debug('Can\'t change topology file permission') + + if not os.path.exists(_projects_): + open(_projects_, 'a').close() + try: + os.chmod(_duts_, 0o664) + except PermissionError: + logging.debug('Can\'t change projects file permission') def main(argv=None): @@ -185,6 +207,7 @@ if __name__ == '__main__': try: init_logger() init_lockdir() + init_confdir() signal.signal(signal.SIGTERM, sigterm_handler) sys.exit(main(sys.argv)) except KeyboardInterrupt: diff --git a/tools/projects b/tools/projects deleted file mode 100644 index e69de29..0000000 diff --git a/tools/topology b/tools/topology deleted file mode 100644 index e69de29..0000000