A left over collection of utility classes that are mostly not needed now.

This file can properly be removed/not included once the logging facility is
migrated to autotest properly.  The other class isn't used any more since I
modified the 'upload_task_files' in the harness_beaker.py file.

Signed-off-by: Don Zickus <dzic...@redhat.com>
---
 client/at_utils.py |   74 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 74 insertions(+), 0 deletions(-)
 create mode 100644 client/at_utils.py

diff --git a/client/at_utils.py b/client/at_utils.py
new file mode 100644
index 0000000..ba040c2
--- /dev/null
+++ b/client/at_utils.py
@@ -0,0 +1,74 @@
+# at_utils.py
+#
+# Copyright (C) 2011 Jan Stancek <jstan...@redhat.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+"""
+at_utils - utils shared by at_launcher and autotest's harness_beaker
+"""
+__author__ = """Copyright Jan Stancek 2011"""
+
+import os
+import sys
+import traceback
+import ConfigParser
+import logging
+log = logging
+
+def logException(exc):
+    log.critical('type(exc), exc:')
+    log.critical(type(exc))
+    log.critical(exc)
+
+    exc_type, exc_value, exc_traceback = sys.exc_info()
+    stack = traceback.format_exception(exc_type, exc_value, exc_traceback)
+
+    log.critical('stack:')
+    for line in stack:
+        log.critical(line)
+
+def getAllFilesFromDir(rootdir, dir_parts, dirfilter):
+    """
+        builds an array of pairs (dirname, filename) recursively
+        dirname is concatenated name of all sub-directories under rootdir
+
+        rootdir - directory where it starts (string)
+        dir_parts - array of all sub-directories (array)
+        dirfilter list of top level subdirs to dirfilter out (array)
+    """
+
+    if len(dir_parts) == 0:
+        subdirs = ''
+    else:
+        #subdirs = reduce(lambda all, part: os.path.join(all, part), dir_parts)
+        subdirs = reduce(os.path.join, dir_parts)
+    fulldir = os.path.join(rootdir, subdirs)
+
+    ret = []
+    if os.path.isdir(fulldir):
+        entries = os.listdir(fulldir)
+        for entry in entries:
+            if os.path.isfile(os.path.join(fulldir, entry)):
+                ret.append((subdirs, entry))
+            elif os.path.isdir(os.path.join(fulldir, entry)):
+                if (len(dir_parts) == 0) and (entry in dirfilter):
+                    pass
+                else:
+                    ret.extend(getAllFilesFromDir(rootdir, dir_parts + 
[entry], dirfilter))
+    return ret
+
+if __name__ == '__main__':
+    pass
+
-- 
1.7.1

_______________________________________________
Beaker-devel mailing list
Beaker-devel@lists.fedorahosted.org
https://lists.fedorahosted.org/mailman/listinfo/beaker-devel

Reply via email to