diff options
author | florent <florent@toopy.org> | 2012-02-06 21:51:28 (GMT) |
---|---|---|
committer | florent <florent@toopy.org> | 2012-02-06 21:51:28 (GMT) |
commit | b7d174099e53522ccdf20d0c6cd33e96784b099e (patch) | |
tree | 650860b2dbe7a171ceac41fdbe89ce38fb246875 /olpcfr/semanticxo/_runner.py |
Diffstat (limited to 'olpcfr/semanticxo/_runner.py')
-rw-r--r-- | olpcfr/semanticxo/_runner.py | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/olpcfr/semanticxo/_runner.py b/olpcfr/semanticxo/_runner.py new file mode 100644 index 0000000..cdbe650 --- /dev/null +++ b/olpcfr/semanticxo/_runner.py @@ -0,0 +1,45 @@ +# python import +import os, shlex, subprocess, tarfile + +# olpcfr tools import +from olpcfr.tools import logger, storage + + +class Runner(object): + + class __Singleton: + + def __init__(self): + self.proc = None + + def run(self): + # prepare paths + _store_path = storage.get_path(path='store') + # change dir for unzipping + os.chdir(_store_path) + if os.path.exists('redstore'): + pass + else: + _trip_zip = storage.get_path(path='data/triplestore.tar.bz2') + # extract files in tmp dir + _tar = tarfile.open(_trip_zip) + _tar.extractall() + _tar.close() + # get args + args = shlex.split('sh %s/wrapper.sh' % _store_path) + self.proc = subprocess.Popen(args) + # stay in the dir + os.chdir(storage.BUNDLE) + + def stop(self): + pass + + # singleton instance + instance = None + + def __new__(c): + if Runner.instance is None: + Runner.instance = Runner.__Singleton() + else: + pass + return Runner.instance |