diff options
author | Suren A. Chilingaryan <csa@suren.me> | 2016-03-02 23:36:19 +0100 |
---|---|---|
committer | Suren A. Chilingaryan <csa@suren.me> | 2016-03-02 23:36:19 +0100 |
commit | f7636162ba124c0d6b5accaa72c842033f3e2309 (patch) | |
tree | 9ae5ceddde46e7c511bba899b869f54c6fef6283 /pywrap/pcilib.py | |
parent | 7e39a6c8ae5c3f95b3b2895c4ce8d858c7ad3b79 (diff) | |
parent | 02d0026e2df2ba5c68c0c1a67aec4437c9e8e8f3 (diff) | |
download | pcitool-f7636162ba124c0d6b5accaa72c842033f3e2309.tar.gz pcitool-f7636162ba124c0d6b5accaa72c842033f3e2309.tar.bz2 pcitool-f7636162ba124c0d6b5accaa72c842033f3e2309.tar.xz pcitool-f7636162ba124c0d6b5accaa72c842033f3e2309.zip |
Further improvements of Python scripting and web-interface API for register manipulations by Vasiliy Chernov
Diffstat (limited to 'pywrap/pcilib.py')
-rw-r--r-- | pywrap/pcilib.py | 38 |
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) |