Change projects/topology file location
authorDonghoon Shin <dhs.shine@gmail.com>
Fri, 9 Sep 2016 14:26:24 +0000 (14:26 +0000)
committerDonghoon Shin <dhs.shine@gmail.com>
Fri, 9 Sep 2016 14:43:53 +0000 (14:43 +0000)
12 files changed:
debian/postinst
litmus/__init__.py
litmus/cmds/cmd_adhoc.py
litmus/cmds/cmd_cp.py
litmus/cmds/cmd_imp.py
litmus/cmds/cmd_mk.py
litmus/core/manager.py
litmus/device/device.py
setup.py
tools/litmus
tools/projects [deleted file]
tools/topology [deleted file]

index 769f92f3c823b5b3306a60d48b5cf33019a9d3f9..65629a524ef2f287a8290d55cfd5caa9464102e4 100644 (file)
@@ -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#
 
index 7abbcb8dc05c9c0cd8a5c4d8c2d55304c5817fb7..d2c807443680a94f16ec9b6becae93945251c1ae 100644 (file)
 # 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')
index e8a228c3c52542c78f6c4cf9c7926ed377d96af2..a1de8e6ad315529fdb16208e26181ea14144c7ce 100755 (executable)
@@ -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
index d6a7c0ae356c5d1ed96e24a54369c6a68d9b570d..9ad676c587c1dceb5c2d6efafa6114d5fc0e5541 100755 (executable)
@@ -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:
index 2730daa0b095d3b359607ee972554d4991760ab1..91de1b87d2ef428b6f9b64d93cc24501c5113ccd 100755 (executable)
@@ -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:
index 5b0856d01c76d28b57552e5384f654d5d0f094cf..beda78801f53a65a7323ce56d9b3ce3c320fe6f9 100755 (executable)
@@ -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:
index 1dd14d3486133d30351ad7e4245dbda283c27587..8c71909c1322f89cd18fba5031c8b09a4a3dd5f6 100644 (file)
@@ -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:
index 2e10a77d7af978d2151474e6a970dab29b560e79..9d9123af8d4b13d8cbbbecca00979de34a0648e2 100644 (file)
@@ -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()))
index 981c6d9909dcc4aa0d58ab78161eaa8435272c0a..2c226122f6991d137cdbaf65da9fb334040235c3 100644 (file)
--- 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',
index 5af569ed98bb39dfce066e1a50d354ffedefe177..709faf5123ec5b48a44710c8b70e7fd01b91a50a 100644 (file)
 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 (file)
index e69de29..0000000
diff --git a/tools/topology b/tools/topology
deleted file mode 100644 (file)
index e69de29..0000000