summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBill Peck <bpeck@redhat.com>2009-11-09 19:28:07 +0000
committerBill Peck <bpeck@redhat.com>2009-11-09 19:28:07 +0000
commita9bf694f8421e612fc6b64ac6723658c5be1968d (patch)
treee5defbd5d37404e8a9919ec876392513185ea7d0
parent61e5d3b3bce205dc64dd54c85e983d8da9291f07 (diff)
more missing python piecesrh-tests-distribution-inventory-1_1-28
-rw-r--r--Tasks/distribution/inventory/Makefile3
-rwxr-xr-xTasks/distribution/inventory/utilist.py38
2 files changed, 40 insertions, 1 deletions
diff --git a/Tasks/distribution/inventory/Makefile b/Tasks/distribution/inventory/Makefile
index 4f69f81..67b9039 100644
--- a/Tasks/distribution/inventory/Makefile
+++ b/Tasks/distribution/inventory/Makefile
@@ -44,7 +44,8 @@ BUILT_FILES=
# data files, .c files, scripts anything needed to either compile the test and/or run it.
FILES=$(METADATA) runtest.sh Makefile PURPOSE push-inventory.py \
- smolt.py software.py i18n.py disks.py pushInventory.py
+ smolt.py software.py i18n.py disks.py pushInventory.py procfs.py \
+ utilist.py
run: $(FILES) build
./runtest.sh
diff --git a/Tasks/distribution/inventory/utilist.py b/Tasks/distribution/inventory/utilist.py
new file mode 100755
index 0000000..23fa171
--- /dev/null
+++ b/Tasks/distribution/inventory/utilist.py
@@ -0,0 +1,38 @@
+#! /usr/bin/python
+# -*- python -*-
+# -*- coding: utf-8 -*-
+
+def hexbitmask(l, nr_entries):
+ hexbitmask = []
+ bit = 0
+ mask = 0
+ for entry in range(nr_entries):
+ if entry in l:
+ mask |= (1 << bit)
+ bit += 1
+ if bit == 32:
+ bit = 0
+ hexbitmask.insert(0, mask)
+ mask = 0
+
+ if bit < 32 and mask != 0:
+ hexbitmask.insert(0, mask)
+
+ return hexbitmask
+
+def bitmasklist(line, nr_entries):
+ fields = line.strip().split(",")
+ bitmasklist = []
+ entry = 0
+ for i in range(len(fields) - 1, -1, -1):
+ mask = int(fields[i], 16)
+ while mask != 0:
+ if mask & 1:
+ bitmasklist.append(entry)
+ mask >>= 1
+ entry += 1
+ if entry == nr_entries:
+ break
+ if entry == nr_entries:
+ break
+ return bitmasklist