summaryrefslogtreecommitdiffstats
path: root/pywrap/pcilib.py
diff options
context:
space:
mode:
Diffstat (limited to 'pywrap/pcilib.py')
-rw-r--r--pywrap/pcilib.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/pywrap/pcilib.py b/pywrap/pcilib.py
new file mode 100644
index 0000000..f4976bf
--- /dev/null
+++ b/pywrap/pcilib.py
@@ -0,0 +1,38 @@
+from pcipywrap import *
+import os
+import sys
+
+class pcilib(pcipywrap):
+ def __init__(s, *args):
+ pcipywrap.__init__(s, *args)
+
+ #load scripts
+ scripts_dir = os.environ.get('PCILIB_SCRIPTS_DIR')
+ if scripts_dir:
+ scripts_dir_abs = os.path.abspath(scripts_dir)
+ if not scripts_dir_abs in sys.path:
+ sys.path.append(scripts_dir_abs)
+
+ s.__scipts = dict()
+ for script in os.listdir(scripts_dir_abs):
+ if script.endswith('.py'):
+ script_module = os.path.splitext(script)[0]
+ __import__(script_module)
+ s.__scipts[script_module] = sys.modules[script_module]
+
+
+ def get_scripts_list(s):
+ scripts = []
+ for script in s.__scipts:
+ curr_script = dict()
+ curr_script['name'] = script
+ if 'description' in dir(s.__scipts[script]):
+ curr_script['description'] = s.__scipts[script].description
+ scripts.append(curr_script)
+ return scripts
+
+
+ def run_script(s, name, input_value):
+ if not name in s.__scipts:
+ raise Exception('Script ' + name +' has not loaded')
+ return s.__scipts[name].run(s, input_value)