summaryrefslogtreecommitdiff
path: root/demo2/utils.py
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@baserock.org>2014-02-21 04:46:49 +0000
committer <>2014-08-04 21:38:17 +0000
commitf3765db04b903b3671733e07cf1541a51966dd14 (patch)
treedefcc3c47d9b8bd78b97dcc04ee779a758d37b1c /demo2/utils.py
downloadposix-ipc-tarball-master.tar.gz
Imported from /home/lorry/working-area/delta_python-packages_posix-ipc-tarball/posix_ipc-0.9.8.tar.gz.HEADposix_ipc-0.9.8master
Diffstat (limited to 'demo2/utils.py')
-rw-r--r--demo2/utils.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/demo2/utils.py b/demo2/utils.py
new file mode 100644
index 0000000..31e2b05
--- /dev/null
+++ b/demo2/utils.py
@@ -0,0 +1,42 @@
+import time
+import sys
+
+def say(s):
+ who = sys.argv[0]
+ if who.endswith(".py"):
+ who = who[:-3]
+
+ s = "%s@%1.6f: %s" % (who, time.time(), s)
+ print (s)
+
+
+def read_params():
+ params = { }
+
+ f = open("params.txt")
+
+ for line in f:
+ line = line.strip()
+ if len(line):
+ if line.startswith('#'):
+ pass # comment in input, ignore
+ else:
+ name, value = line.split('=')
+ name = name.upper().strip()
+
+ if name == "PERMISSIONS":
+ value = int(value, 8)
+ elif "NAME" in name:
+ # This is a string; leave it alone.
+ pass
+ else:
+ value = int(value)
+
+ #print "name = %s, value = %d" % (name, value)
+
+ params[name] = value
+
+ f.close()
+
+ return params
+