Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/creactivistore/_templates/lib/triplestore/_runner.py
diff options
context:
space:
mode:
Diffstat (limited to 'creactivistore/_templates/lib/triplestore/_runner.py')
-rw-r--r--creactivistore/_templates/lib/triplestore/_runner.py51
1 files changed, 51 insertions, 0 deletions
diff --git a/creactivistore/_templates/lib/triplestore/_runner.py b/creactivistore/_templates/lib/triplestore/_runner.py
new file mode 100644
index 0000000..27bc330
--- /dev/null
+++ b/creactivistore/_templates/lib/triplestore/_runner.py
@@ -0,0 +1,51 @@
+# python import
+import logging, os, shlex, subprocess, shutil, tarfile
+
+# server tools import
+from server.tools import storage
+
+# get application logger
+logger = logging.getLogger('helostore')
+
+
+class Runner(object):
+
+ class __Singleton:
+
+ def __init__(self):
+ self.proc = None
+
+ def run(self):
+ # prepare paths
+ _store_path = storage.get_path(path='store', bundle=False)
+ # 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)
+ # ..
+ 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