def run(code, kwargs): code = jsondumps(code) kwargs = jsondumps(kwargs) install_dir = tacticenv.get_install_dir() cmd = '%s/src/tactic/command/js_cmd.py' % install_dir python_exec = Config.get_value("services", "python") cmd_list = [python_exec, cmd, code, kwargs] import subprocess program = subprocess.Popen(cmd_list, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE) ret_val, error = program.communicate() lines = [] start = False for line in ret_val.split("\n") : if line.startswith("~"*20): start = True continue if not start: continue lines.append(line) value = jsonloads("\n".join(lines)) return value
def run(code, kwargs): code = jsondumps(code) kwargs = jsondumps(kwargs) install_dir = tacticenv.get_install_dir() cmd = '%s/src/tactic/command/js_cmd.py' % install_dir python_exec = Config.get_value("services", "python") cmd_list = [python_exec, cmd, code, kwargs] import subprocess program = subprocess.Popen(cmd_list, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE) ret_val, error = program.communicate() lines = [] start = False for line in ret_val.split("\n"): if line.startswith("~" * 20): start = True continue if not start: continue lines.append(line) value = jsonloads("\n".join(lines)) return value
def upgrade(my): # Note this should only be called when the database is local ... # for now, just sqlite database vendor = Config.get_value("database", "vendor") if vendor != 'Sqlite': return version = Environment.get_release_version() print "Upgrade database to version [%s] ..." % version import sys #path = __file__ #dirname = os.path.dirname(path) #path = "%s/upgrade.py" % dirname dir = os.getcwd() file_path = sys.modules[__name__].__file__ full_path = os.path.join(dir, file_path) dirname = os.path.dirname(full_path) # take another directory off dirname = os.path.dirname(dirname) if os.name == 'posix': executable = "%s/python/bin/python" % dirname else: executable = "%s/python/python.exe" % dirname #print 'exec: ', executable install_dir = tacticenv.get_install_dir() path = "%s/src/bin/upgrade_db.py" % install_dir import subprocess subprocess.call([executable, path , "-f", "-y"]) print "... done upgrade"
def main(): install_dir = tacticenv.get_install_dir() version = Environment.get_release_version() api_version = Environment.get_release_api_version() client_api_dir = '%s/src/client' % install_dir context_client_dir = '%s/src/context/client' % install_dir print "install: ", install_dir print "version: ", version # copy scm directory in api scm_dir = "%s/src/tactic/scm" % install_dir client_dir = "%s/src/client" % install_dir to_scm_dir = "%s/src/client/tactic_client_lib/scm" % install_dir if os.path.exists(to_scm_dir): shutil.rmtree(to_scm_dir) shutil.copytree(scm_dir, to_scm_dir) # create the client api zip package into context/client dir path = "%s/src/context/client/tactic-api-%s.zip" % (install_dir, api_version) if os.path.exists(path): os.system('''rm "%s"''' % path) os.system('''cd "%s"; zip -r "%s" "tactic_client_lib"''' % (client_api_dir, path) ) # copy the client api into the standalone minimal python from_dir = '%s/src/client/tactic_client_lib' % install_dir python = '%s/src/client/python-3.6.6-win32-minimal' % install_dir to_dir = '%s/Lib/site-packages/tactic_client_lib' % python if os.path.exists(to_dir): shutil.rmtree(to_dir) shutil.copytree(from_dir, to_dir) # copy and rename to the api version to_name = "tactic-api-python-%s" % api_version to_dir = os.path.dirname(python) + "/" + to_name; if os.path.exists(to_dir): shutil.rmtree(to_dir) shutil.copytree(python, to_dir) # zip this up to_dir = os.path.dirname(python) zip_path = "%s/%s.zip" % (to_dir, to_name) if os.path.exists(zip_path): os.unlink(zip_path) os.system('''cd "%s"; zip -r "%s.zip" "%s"''' % (to_dir, to_name, to_name) ) shutil.rmtree("%s/%s" % (to_dir, to_name) ) # final_path = "%s/%s.zip" % (context_client_dir, to_name) if os.path.exists(final_path): os.unlink(final_path) print(zip_path, final_path) shutil.move(zip_path, final_path)
def main(): install_dir = tacticenv.get_install_dir() version = Environment.get_release_version() api_version = Environment.get_release_api_version() client_api_dir = '%s/src/client' % install_dir context_client_dir = '%s/src/context/client' % install_dir print "install: ", install_dir print "version: ", version # copy scm directory in api scm_dir = "%s/src/tactic/scm" % install_dir client_dir = "%s/src/client" % install_dir to_scm_dir = "%s/src/client/tactic_client_lib/scm" % install_dir if os.path.exists(to_scm_dir): shutil.rmtree(to_scm_dir) shutil.copytree(scm_dir, to_scm_dir) # create the client api zip package into context/client dir path = "%s/src/context/client/tactic-api-%s.zip" % (install_dir, api_version) if os.path.exists(path): os.system('''rm "%s"''' % path) os.system('''cd "%s"; zip -r "%s" "tactic_client_lib"''' % (client_api_dir, path)) # copy the client api into the standalone minimal python from_dir = '%s/src/client/tactic_client_lib' % install_dir python = '%s/src/client/python-3.6.6-win32-minimal' % install_dir to_dir = '%s/Lib/site-packages/tactic_client_lib' % python if os.path.exists(to_dir): shutil.rmtree(to_dir) shutil.copytree(from_dir, to_dir) # copy and rename to the api version to_name = "tactic-api-python-%s" % api_version to_dir = os.path.dirname(python) + "/" + to_name if os.path.exists(to_dir): shutil.rmtree(to_dir) shutil.copytree(python, to_dir) # zip this up to_dir = os.path.dirname(python) zip_path = "%s/%s.zip" % (to_dir, to_name) if os.path.exists(zip_path): os.unlink(zip_path) os.system('''cd "%s"; zip -r "%s.zip" "%s"''' % (to_dir, to_name, to_name)) shutil.rmtree("%s/%s" % (to_dir, to_name)) # final_path = "%s/%s.zip" % (context_client_dir, to_name) if os.path.exists(final_path): os.unlink(final_path) print(zip_path, final_path) shutil.move(zip_path, final_path)
# # PROPRIETARY INFORMATION. This software is proprietary to # Southpaw Technology, and is not to be reproduced, transmitted, # or disclosed in any way without written permission. # # # scripts that starts up a number of Tactic and monitors them __all__ = ['TacticThread', 'TacticTimedThread', 'WatchFolderThread', 'ASyncThread', 'TacticMonitor', 'CustomPythonProcessThread'] import os, sys, threading, time, urllib, random, subprocess, re import tacticenv tactic_install_dir = tacticenv.get_install_dir() tactic_site_dir = tacticenv.get_site_dir() app_server = "cherrypy" #try: # import setproctitle # setproctitle.setproctitle("TACTICmaster") #except: # pass from pyasm.common import Environment, Common, Date, Config, jsonloads, jsondumps from pyasm.search import Search, DbContainer, SearchType python = Config.get_value("services", "python") if not python:
# # # import os, sys # set up environment os.environ['TACTIC_APP_SERVER'] = "cherrypy" os.environ['TACTIC_MODE'] = "development" os.environ['TACTIC_CLEANUP'] = "true" import tacticenv from pyasm.common import Environment, Config tactic_install_dir = tacticenv.get_install_dir() tactic_site_dir = tacticenv.get_site_dir() sys.path.insert(0, "%s/src" % tactic_install_dir) sys.path.insert(0, "%s/tactic_sites" % tactic_install_dir) sys.path.insert(0, tactic_site_dir) sys.path.insert(0, "%s/3rd_party/CherryPy" % tactic_install_dir) def startup(port, server=""): from tactic.startup import FirstRunInit cmd = FirstRunInit() cmd.execute()