def get_display(my): web = WebContainer.get_web() context_url = web.get_context_url().to_string() js_url = "%s/javascript" % context_url spt_js_url = "%s/spt_js" % context_url # adding new core "spt" javascript library folder version = Environment.get_release_version() # add some third party libraries third_party = js_includes.third_party security = Environment.get_security() for include in js_includes.third_party: Container.append_seq("Page:js", "%s/%s" % (spt_js_url,include)) all_js_path = js_includes.get_compact_js_filepath() if os.path.exists( all_js_path ): Container.append_seq("Page:js", "%s/%s" % (context_url, js_includes.get_compact_js_context_path_suffix())) else: for include in js_includes.legacy_core: Container.append_seq("Page:js", "%s/%s" % (js_url,include)) for include in js_includes.spt_js: Container.append_seq("Page:js", "%s/%s" % (spt_js_url,include)) for include in js_includes.legacy_app: Container.append_seq("Page:js", "%s/%s" % (js_url,include)) # custom js files to include includes = Config.get_value("install", "include_js") includes = includes.split(",") for include in includes: include = include.strip() if include: print "include: ", include Container.append_seq("Page:js", include) widget = Widget() js_files = Container.get("Page:js") for js_file in js_files: widget.add('<script src="%s?ver=%s" ></script>\n' % (js_file,version) ) return widget
def get_display(my): web = WebContainer.get_web() context_url = web.get_context_url().to_string() js_url = "%s/javascript" % context_url spt_js_url = "%s/spt_js" % context_url # adding new core "spt" javascript library folder version = Environment.get_release_version() # add some third party libraries third_party = js_includes.third_party security = Environment.get_security() # FIXME: this logic should not be located here. # no reason to have the edit_area_full.js if not security.check_access("builtin", "view_script_editor", "allow") and security.check_access("builtin", "view_site_admin", "allow"): if "edit_area/edit_area_full.js" in third_party: third_party.remove("edit_area/edit_area_full.js") for include in js_includes.third_party: Container.append_seq("Page:js", "%s/%s" % (spt_js_url,include)) all_js_path = js_includes.get_compact_js_filepath() if os.path.exists( all_js_path ): Container.append_seq("Page:js", "%s/%s" % (context_url, js_includes.get_compact_js_context_path_suffix())) else: for include in js_includes.legacy_core: Container.append_seq("Page:js", "%s/%s" % (js_url,include)) for include in js_includes.spt_js: Container.append_seq("Page:js", "%s/%s" % (spt_js_url,include)) for include in js_includes.legacy_app: Container.append_seq("Page:js", "%s/%s" % (js_url,include)) #Container.append_seq("Page:js", "http://webplayer.unity3d.com/download_webplayer-3.x/3.0/uo/UnityObject.js") #Container.append_seq("Page:js", "/context/spt_js/UnityObject.js") #widget = DivWdg() #widget.set_id("javascript") #my.set_as_panel(widget) widget = Widget() js_files = Container.get("Page:js") for js_file in js_files: widget.add('<script src="%s?ver=%s" ></script>\n' % (js_file,version) ) return widget
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)
def get_css_wdg(self): widget = Widget() web = WebContainer.get_web() context_url = web.get_context_url().to_string() skin = web.get_skin() version = Environment.get_release_version() # Bootstrap use_bootstrap = True if use_bootstrap: Container.append_seq( "Page:css", "%s/spt_js/bootstrap/css/bootstrap.min.css?ver=%s" % (context_url, version)) # add the color wheel css Container.append_seq( "Page:css", "%s/spt_js/mooRainbow/Assets/mooRainbow.css" % context_url) Container.append_seq( "Page:css", "%s/spt_js/mooDialog/css/MooDialog.css" % context_url) Container.append_seq( "Page:css", "%s/spt_js/mooScrollable/Scrollable.css" % context_url) # first load context css Container.append_seq("Page:css", "%s/style/layout.css" % context_url) # TEST Container.append_seq("Page:css", "%s/spt_js/video/video-js.css" % context_url) # get all of the registered css file css_files = Container.get_seq("Page:css") for css_file in css_files: widget.add( '<link rel="stylesheet" href="%s" type="text/css" />\n' % css_file) # custom js files to include includes = Config.get_value("install", "include_css") includes = includes.split(",") for include in includes: include = include.strip() if include: print("include: ", include) widget.add( '<link rel="stylesheet" href="%s" type="text/css" />\n' % include) return widget
def get_display(my): web = WebContainer.get_web() context_url = web.get_context_url().to_string() js_url = "%s/javascript" % context_url spt_js_url = "%s/spt_js" % context_url # adding new core "spt" javascript library folder version = Environment.get_release_version() # add some third party libraries third_party = js_includes.third_party security = Environment.get_security() for include in js_includes.third_party: Container.append_seq("Page:js", "%s/%s" % (spt_js_url, include)) all_js_path = js_includes.get_compact_js_filepath() if os.path.exists(all_js_path): Container.append_seq( "Page:js", "%s/%s" % (context_url, js_includes.get_compact_js_context_path_suffix())) else: for include in js_includes.legacy_core: Container.append_seq("Page:js", "%s/%s" % (js_url, include)) for include in js_includes.spt_js: Container.append_seq("Page:js", "%s/%s" % (spt_js_url, include)) for include in js_includes.legacy_app: Container.append_seq("Page:js", "%s/%s" % (js_url, include)) # custom js files to include includes = Config.get_value("install", "include_js") includes = includes.split(",") for include in includes: include = include.strip() if include: print "include: ", include Container.append_seq("Page:js", include) widget = Widget() js_files = Container.get("Page:js") for js_file in js_files: widget.add('<script src="%s?ver=%s" ></script>\n' % (js_file, version)) return widget
def get_display(my): web = WebContainer.get_web() context_url = web.get_context_url().to_string() js_url = "%s/javascript" % context_url spt_js_url = "%s/spt_js" % context_url # adding new core "spt" javascript library folder version = Environment.get_release_version() # add some third party libraries third_party = js_includes.third_party security = Environment.get_security() # FIXME: this logic should not be located here. # no reason to have the edit_area_full.js #if not security.check_access("builtin", "view_script_editor", "allow") and security.check_access("builtin", "view_site_admin", "allow"): # if "edit_area/edit_area_full.js" in third_party: # third_party.remove("edit_area/edit_area_full.js") for include in js_includes.third_party: Container.append_seq("Page:js", "%s/%s" % (spt_js_url,include)) all_js_path = js_includes.get_compact_js_filepath() if os.path.exists( all_js_path ): Container.append_seq("Page:js", "%s/%s" % (context_url, js_includes.get_compact_js_context_path_suffix())) else: for include in js_includes.legacy_core: Container.append_seq("Page:js", "%s/%s" % (js_url,include)) for include in js_includes.spt_js: Container.append_seq("Page:js", "%s/%s" % (spt_js_url,include)) for include in js_includes.legacy_app: Container.append_seq("Page:js", "%s/%s" % (js_url,include)) #Container.append_seq("Page:js", "http://webplayer.unity3d.com/download_webplayer-3.x/3.0/uo/UnityObject.js") #Container.append_seq("Page:js", "/context/spt_js/UnityObject.js") widget = Widget() js_files = Container.get("Page:js") for js_file in js_files: widget.add('<script src="%s?ver=%s" ></script>\n' % (js_file,version) ) return widget
def upgrade(my): project_code = my.kwargs.get('project_code') # run the upgrade script (this has to be done in a separate # process due to possible sql errors in a transaction install_dir = Environment.get_install_dir() python = Config.get_value("services", "python") if not python: python = "python" impl = Project.get_database_impl() from pyasm.search.upgrade import Upgrade version = Environment.get_release_version() version.replace('.', '_') upgrade = Upgrade(version, is_forced=True, project_code=project_code, quiet=True) upgrade.execute()
def get_css_wdg(self): widget = Widget() web = WebContainer.get_web() context_url = web.get_context_url().to_string() skin = web.get_skin() version = Environment.get_release_version() # Bootstrap use_bootstrap = True if use_bootstrap: Container.append_seq("Page:css", "%s/spt_js/bootstrap/css/bootstrap.min.css?ver=%s" % (context_url, version)) # add the color wheel css Container.append_seq("Page:css", "%s/spt_js/mooRainbow/Assets/mooRainbow.css" % context_url) Container.append_seq("Page:css", "%s/spt_js/mooDialog/css/MooDialog.css" % context_url) Container.append_seq("Page:css", "%s/spt_js/mooScrollable/Scrollable.css" % context_url) # first load context css Container.append_seq("Page:css", "%s/style/layout.css" % context_url) # TEST Container.append_seq("Page:css", "%s/spt_js/video/video-js.css" % context_url) # get all of the registered css file css_files = Container.get_seq("Page:css") for css_file in css_files: widget.add('<link rel="stylesheet" href="%s" type="text/css" />\n' % css_file ) # custom js files to include includes = Config.get_value("install", "include_css") includes = includes.split(",") for include in includes: include = include.strip() if include: print("include: ", include) widget.add('<link rel="stylesheet" href="%s" type="text/css" />\n' % include ) return widget
def upgrade(my): project_code = my.kwargs.get('project_code') # run the upgrade script (this has to be done in a separate # process due to possible sql errors in a transaction install_dir = Environment.get_install_dir() python = Config.get_value("services", "python") if not python: python = "python" impl = Project.get_database_impl() from pyasm.search.upgrade import Upgrade version = Environment.get_release_version() version.replace('.', '_') upgrade = Upgrade(version, is_forced=True, project_code=project_code, quiet=True) upgrade.execute()
def get_display(my): top_div = DivWdg() top_div.add_styles("text-align: center") top_div.add_style("margin-top: 10px") top_div.add_style("opacity: 0.5") top_div.add_style("font-size: 10px") tactic_span = SpanWdg() tactic_span.add("TACTIC®") rel_span = SpanWdg() rel_span.add(" Release %s" % Environment.get_release_version()) top_div.add(tactic_span) top_div.add(rel_span) top_div.add( " © 2005-2015, Southpaw Technology Inc. All Rights Reserved. " ) show_license_info = my.kwargs.get("show_license_info") if show_license_info: security = Environment.get_security() if security: license = Environment.get_security().get_license() company = license.get_data("company") if company.startswith('ALL'): lic_type = '' tmps = company.split('-') if tmps: lic_type = tmps[-1] lic_type = lic_type.strip() license_text = "Open Source License - %s" % lic_type else: license_text = "Licensed to %s" % company else: license_text = "No License" top_div.add(license_text) top_div.add("<br/>" * 2) return top_div
def get_display(my): top_div = DivWdg() top_div.add_styles("text-align: center") top_div.add_style("margin-top: 10px") top_div.add_style("opacity: 0.5") top_div.add_style("font-size: 10px") tactic_span = SpanWdg() tactic_span.add( "TACTIC®" ) rel_span = SpanWdg() rel_span.add( " Release %s" % Environment.get_release_version() ) top_div.add( tactic_span ) top_div.add( rel_span ) top_div.add( " © 2005-2015, Southpaw Technology Inc. All Rights Reserved. " ) show_license_info = my.kwargs.get("show_license_info") if show_license_info: security = Environment.get_security() if security: license = Environment.get_security().get_license() company = license.get_data("company") if company.startswith('ALL'): lic_type = '' tmps = company.split('-') if tmps: lic_type = tmps[-1] lic_type = lic_type.strip() license_text = "Open Source License - %s" %lic_type else: license_text = "Licensed to %s" % company else: license_text = "No License" top_div.add( license_text ) top_div.add("<br/>"*2) return top_div
def preprocess(my): my.version = Environment.get_release_version()
class CherryPyStartup(object): def __init__(my, port=''): # It is possible on startup that the database is not running. from pyasm.common import Environment from pyasm.search import DbContainer, DatabaseException, Sql plugin_dir = Environment.get_plugin_dir() sys.path.insert(0, plugin_dir) try: sql = DbContainer.get("sthpw") if sql.get_database_type() != "MongoDb": # before batch, clean up the ticket with a NULL code if os.getenv('TACTIC_MODE') != 'production': sql.do_update('DELETE from "ticket" where "code" is NULL;') else: start_port = Config.get_value("services", "start_port") if start_port: start_port = int(start_port) else: start_port = 8081 if port and int(port) == start_port: sql.do_update( 'DELETE from "ticket" where "code" is NULL;') except DatabaseException, e: # TODO: need to work on this print "ERROR: could not connect to [sthpw] database" #os.environ["TACTIC_CONFIG_PATH"] = Config.get_default_config_path() #Sql.set_default_vendor("Sqlite") Config.set_tmp_config() Config.reload_config() # try connecting again try: sql = DbContainer.get("sthpw") except: print "Could not connect to the database." raise # is it CherryPyStartup's responsibility to start batch? from pyasm.security import Batch Batch() my.site_dir = os.getenv("TACTIC_SITE_DIR") my.install_dir = os.getenv("TACTIC_INSTALL_DIR") # set up a simple environment. May need a more complex one later my.env = Environment() my.setup_env() my.config = my.setup_sites() my.init_only = False cherrypy.startup = my # this initializes the web. # - sets up virtual implied tiggers from web_init import WebInit WebInit().execute() # Windows should handle fine #start up the caching system if it's not windows cache_mode = Config.get_value("install", "cache_mode") if not cache_mode: cache_mode = 'complete' if os.name == 'nt': cache_mode = 'basic' from cache_startup import CacheStartup cmd = CacheStartup(mode=cache_mode) cmd.execute() cmd.init_scheduler() # DEPRECATED (but keeping it around" """ # start up the queue system ... if Config.get_value("sync", "enabled") == "true": # start up the sync system ... print "Starting Transaction Sync ..." from tactic.command import TransactionQueueManager TransactionQueueManager.start() # start up the sync system ... print "Starting Watch Folder Service ..." from tactic.command import WatchServerFolderTask WatchServerFolderTask.start() """ # start up scheduled triggers #from tactic.command import ScheduledTriggerMonitor #ScheduledTriggerMonitor.start() #from pyasm.web import Translation #Translation.install() # close all the threads in this startup thread from pyasm.search import DbContainer DbContainer.close_thread_sql() version = Environment.get_release_version() print print "Starting TACTIC v%s ..." % version print
elif answer == 'n': sys.exit(0) else: print "Only y or n is accepted. Exiting..." sys.exit(0) version = current_version elif len(args) == 1: version = args[0] else: print "Either 1 or no argument can be accepted." if not version: version = tacticversion if version != Environment.get_release_version(): answer = raw_input("[%s] does not match currently running TACTIC version [%s]. If it is a lower version number, it will probably not work. -f must be used to continue. For regular upgrade, you have not symlinked to the new TACTIC version. Continue (y/n): " \ %(version, Environment.get_release_version())) if answer == "y": if not is_forced: print "-f option must be used in this situation. " sys.exit(0) pass elif answer == 'n': sys.exit(0) else: print "Only y or n is accepted. Exiting..." sys.exit(0)
def preprocess(self): self.version = Environment.get_release_version()
def get_display(self): top = self.top top.add_style("padding: 10px") top.add_color("background", "background") top.add_style("width: 400px") inner = DivWdg() top.add(inner) inner.add("The following projects have databases that are out of date with this version of TACTIC") server_version = Environment.get_release_version() server_div = DivWdg() inner.add(server_div) server_div.add("Installed TACTIC Version: ") server_div.add(server_version) server_div.add_style("padding: 20px") server_div.add_style("font-weight: bold") search = Search("sthpw/project") projects = search.get_sobjects() projects_div = DivWdg() inner.add(projects_div) table = Table() projects_div.add(table) table.add_style("margin: 20px") table.set_max_width() for project in projects: project_code = project.get_code() if project_code == 'admin': continue table.add_row() project_version = project.get_value("last_version_update") if project_version < server_version: td = table.add_cell() td.add(project_code) td = table.add_cell() if not project_version: td.add("-") else: td.add(project_version) button = ActionButtonWdg(title="Update") inner.add(button) button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var server = TacticServerStub.get(); var cmd = 'tactic.ui.app.update_wdg.UpdateCbk'; server.execute_cmd(cmd); ''' } ) return top
def get_display(my): web = WebContainer.get_web() tactic_header = Table() tactic_header.add_row() tactic_header.add_color("color", "color2") # tactic logo and release info skin = web.get_skin() src = '/context/skins/' + skin + '/images/tactic_logo.png' img = HtmlElement.img(src) img.add_class('hand') img.add_attr('title', 'Go to home page') img.add_behavior({'type': 'click_up', 'cbjs_action': "window.location='/tactic/'"}) rel_div = DivWdg() rel_div.add(" "*3) rel_div.add("Release: %s" %Environment.get_release_version() ) rel_div.add_style("font-size: 9px") # Need this to override the above color in add_looks rel_div.add_color("color", "color2") tactic_wdg = Table() tactic_wdg.add_style("width: 180px") tactic_wdg.add_row() td = tactic_wdg.add_cell( img ) td.set_style("width:100px") tactic_wdg.add_row() td = tactic_wdg.add_cell( rel_div ) td.set_style("text-align: left") td = tactic_header.add_cell( tactic_wdg ) # add the project thumb and title project = Project.get() if my.show_project: thumb_div = DivWdg() td = tactic_header.add_cell( thumb_div ) thumb_div.add_style("height: 28px") thumb_div.add_style("overflow: hidden") thumb_div.add_border(modifier=-10) thumb_div.add_style("-moz-border-radius: 3px") thumb = ThumbWdg() thumb_div.add(thumb) thumb.set_sobject(project) thumb.set_icon_size("45") td.set_style("vertical-align: top; padding-right:14px;padding-left: 3px") td = tactic_header.add_cell( project.get_value("title") ) #td.add_looks( "fnt_title_1" ) td.add_style("font-size: 20px") td.add_style("white-space: nowrap") td.add_style("padding-left: 14px") # project selection td = tactic_header.add_cell() project_div = DivWdg() project_div.add_style("margin-top: -5px") project_div.add(ProjectSelectWdg() ) td.add( project_div ) td.set_style("padding-left: 14px") # Global Actions Gear Menu (contains links to Documentation) ... action_bar_btn_dd = PageHeaderGearMenuWdg() action_div = DivWdg(action_bar_btn_dd) action_div.add_style("margin-top: -5px") td = tactic_header.add_cell( action_div ) if PrefSetting.get_value_by_key('subscription_bar') == 'true': from message_wdg import SubscriptionBarWdg sub = SubscriptionBarWdg(mode='popup') tactic_header.add_cell(sub) # user login # user user = Environment.get_login() full_name = user.get_full_name() user_div = SpanWdg( HtmlElement.b( "%s " % full_name) , css='hand') user_div.set_style("padding-right:10px") # signout login = Environment.get_security().get_login() search_key = SearchKey.get_by_sobject(login) span = SpanWdg() span.add( user_div ) user_div.add_attr('spt_nudge_menu_vert', '20') td = tactic_header.add_cell(span) td.set_style("width:100%; text-align:right; white-space: nowrap") from tactic.ui.widget import SingleButtonWdg button = SingleButtonWdg(title='My Account', icon=IconWdg.USER, show_arrow=True) button_div = DivWdg(button) button_div.add_style("margin-top: -5px") button.add_attr('spt_nudge_menu_horiz', '-80') button.add_attr('spt_nudge_menu_vert', '10') td = tactic_header.add_cell(button_div) menus = my.get_smart_menu() # TODO: this part seems redundant to attach to both SmartMenu.add_smart_menu_set(user_div, [menus]) SmartMenu.assign_as_local_activator(user_div, None, True) SmartMenu.add_smart_menu_set(button, [menus]) SmartMenu.assign_as_local_activator(button, None, True) td.set_style("width:100%;") button = SingleButtonWdg(title='Help', icon=IconWdg.HELP_BUTTON, show_arrow=False) #button.add_behavior( { #'type': 'click_up', #'cbjs_action': ''' #window.open("/doc/") #''' #} ) button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' spt.named_events.fire_event("show_help") ''' } ) from tactic.ui.container import DialogWdg help_dialog = DialogWdg(z_index=900, show_pointer=False) td.add(help_dialog) help_dialog.add_title("Help") help_dialog.add_class("spt_help") # container for help help_div = DivWdg() help_dialog.add(help_div) from help_wdg import HelpWdg help_wdg = HelpWdg() help_div.add(help_wdg) button_div = DivWdg(button) button_div.add_style("margin-top: -5px") td = tactic_header.add_cell(button_div) td.set_style("width:100%; text-align:right; white-space: nowrap") # Layout the Main Header Table main_div = DivWdg() # TEST: NEW LAYOUT if Config.get_value("install", "layout") == "fixed": main_div.add_style("position: fixed") main_div.add_style("z-index: 100") main_div.add_style("width: 100%") license = Environment.get_security().get_license() if not license.is_licensed(): from tactic.ui.app import LicenseManagerWdg license_manager = LicenseManagerWdg(use_popup=True) main_div.add(license_manager) # create the header table tactic_header_div = DivWdg() tactic_header_div.add(tactic_header) tactic_header_div.add_gradient("background", "background2", 10, -10) main_div.add(tactic_header_div) main_div.add( my.get_js_popup() ) """ main_div.add( HelpPopupWdg() ) # FIXME: is this even used at all? action_bar_popup = PopupWdg( id="ActionBarWdg_popup", allow_page_activity=True, width="636px" ) action_bar_popup.add_title( "TACTIC™ Action Bar" ) action_bar_popup.add( ActionBarWdg() ) main_div.add( action_bar_popup ) """ # FIXME(?): does this CommonPopup need to be at z_start=300? By default popups will be at z_start=200 popup = PopupWdg( id="CommonPopup", allow_page_activity=True, width="600px", z_start=300 ) popup.add('Tools', 'title') main_div.add( popup ) return main_div
def add_top_behaviors(self): self.body.add_relay_behavior( { 'type': 'click', 'bvr_match_class': 'tactic_popup', 'cbjs_action': ''' var view = bvr.src_el.getAttribute("view"); if (!view) { spt.alert("No view found"); } var target = bvr.src_el.getAttribute("target"); var title = bvr.src_el.getAttribute("title"); var class_name = 'tactic.ui.panel.CustomLayoutWdg'; var kwargs = { view: view, } var attributes = bvr.src_el.attributes; for (var i = 0; i < attributes.length; i++) { var name = attributes[i].name; if (name == "class") { continue; } var value = attributes[i].value; kwargs[name] = value; } spt.panel.load_popup(title, class_name, kwargs); ''' } ) self.body.add_relay_behavior( { 'type': 'click', 'bvr_match_class': 'tactic_load', 'cbjs_action': ''' var view = bvr.src_el.getAttribute("view"); if (!view) { spt.alert("No view found"); } var target_class = bvr.src_el.getAttribute("target"); if (! target_class ) { target_class = "spt_content"; } if (target_class.indexOf(".") != "-1") { var parts = target_class.split("."); var top = bvr.src_el.getParent("."+parts[0]); var target = top.getElement("."+parts[1]); } else { var target = $(document.body).getElement("."+target_class); } var class_name = 'tactic.ui.panel.CustomLayoutWdg'; var kwargs = { view: view, } var attributes = bvr.src_el.attributes; for (var i = 0; i < attributes.length; i++) { var name = attributes[i].name; if (name == "class") { continue; } var value = attributes[i].value; kwargs[name] = value; } spt.panel.load(target, class_name, kwargs); var scroll = bvr.src_el.getAttribute("scroll"); if (scroll == "top") { window.scrollTo(0,0); } ''' } ) self.body.add_relay_behavior( { 'type': 'click', 'bvr_match_class': 'tactic_link', 'cbjs_action': ''' var href = bvr.src_el.getAttribute("href"); if (!href) { spt.alert("No href defined for this link"); return; } var target = bvr.src_el.getAttribute("target"); if (!target) { target = "_self"; } window.open(href, target); ''' } ) self.body.add_relay_behavior( { 'type': 'click', 'bvr_match_class': 'tactic_refresh', 'cbjs_action': ''' var target_class = bvr.src_el.getAttribute("target"); if (target_class.indexOf(".") != "-1") { var parts = target_class.split("."); var top = bvr.src_el.getParent("."+parts[0]); var target = top.getElement("."+parts[1]); } else { var target = $(document.body).getElement("."+target_class); } spt.panel.refresh(target); ''' } ) self.body.add_relay_behavior( { 'type': 'click', 'bvr_match_class': 'tactic_new_tab', 'cbjs_action': ''' var view = bvr.src_el.getAttribute("view") var search_key = bvr.src_el.getAttribute("search_key") var expression = bvr.src_el.getAttribute("expression") var name = bvr.src_el.getAttribute("name"); var title = bvr.src_el.getAttribute("title"); if (!name) { name = title; } if (!title) { title = name; } if (!title && !name) { title = name = "Untitled"; } if (expression) { var server = TacticServerStub.get(); var sss = server.eval(expression, {search_keys: search_key, single: true}) search_key = sss.__search_key__; } spt.tab.set_main_body_tab() if (view) { var cls = "tactic.ui.panel.CustomLayoutWdg"; var kwargs = { view: view } } else if (search_key) { var cls = "tactic.ui.tools.SObjectDetailWdg"; var kwargs = { search_key: search_key } } var attributes = bvr.src_el.attributes; for (var i = 0; i < attributes.length; i++) { var attr_name = attributes[i].name; if (attr_name == "class") { continue; } var value = attributes[i].value; kwargs[attr_name] = value; } try { spt.tab.add_new(name, title, cls, kwargs); } catch(e) { spt.alert(e); } ''' } ) self.body.add_relay_behavior( { 'type': 'click', 'bvr_match_class': 'tactic_submit', 'cbjs_action': ''' var command = bvr.src_el.getAttribute("command"); var kwargs = { } var server = TacticServerStub.get(); try { server.execute_cmd(command, kwargs); } catch(e) { spt.alert(e); } ''' } ) self.body.add_relay_behavior( { 'type': 'mouseenter', 'bvr_match_class': 'tactic_hover', 'cbjs_action': ''' var bgcolor = bvr.src_el.getStyle("background"); bvr.src_el.setAttribute("spt_bgcolor", bgcolor); bvr.src_el.setStyle("background", "#EEE"); ''' } ) self.body.add_relay_behavior( { 'type': 'mouseleave', 'bvr_match_class': 'tactic_hover', 'cbjs_action': ''' var bgcolor = bvr.src_el.getAttribute("spt_bgcolor"); if (!bgcolor) bgcolor = ""; //var bgcolor = "" bvr.src_el.setStyle("background", bgcolor); ''' } ) self.body.set_unique_id() self.body.add_smart_style( "tactic_load", "cursor", "pointer" ) # check version of the database project = Project.get() version = project.get_value("last_version_update") release = Environment.get_release_version() #if version < release: # FIXME: can't do this ... TACTIC cannot be running when the database # is upgrading. if False: try: from pyasm.security import Site site = Site.get_site() install_dir = Environment.get_install_dir() cmd = '''python "%s/src/bin/upgrade_db.py" -f -s "%s" --quiet --yes &''' % (install_dir, site) print("cmd: ", cmd) os.system(cmd) pass except Exception as e: print("WARNING: ", e)
def preprocess(self): self.version = Environment.get_release_version()
def get_display(my): top = my.top top.add_style("padding: 10px") top.add_color("background", "background") top.add_style("width: 400px") inner = DivWdg() top.add(inner) inner.add("The following projects have databases that are out of date with this version of TACTIC") server_version = Environment.get_release_version() server_div = DivWdg() inner.add(server_div) server_div.add("Installed TACTIC Version: ") server_div.add(server_version) server_div.add_style("padding: 20px") server_div.add_style("font-weight: bold") search = Search("sthpw/project") projects = search.get_sobjects() projects_div = DivWdg() inner.add(projects_div) table = Table() projects_div.add(table) table.add_style("margin: 20px") table.set_max_width() for project in projects: project_code = project.get_code() if project_code == 'admin': continue table.add_row() project_version = project.get_value("last_version_update") if project_version < server_version: td = table.add_cell() td.add(project_code) td = table.add_cell() if not project_version: td.add("-") else: td.add(project_version) button = ActionButtonWdg(title="Update") inner.add(button) button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var server = TacticServerStub.get(); var cmd = 'tactic.ui.app.update_wdg.UpdateCbk'; server.execute_cmd(cmd); ''' } ) return top
def __init__(self, port=''): # It is possible on startup that the database is not running. from pyasm.common import Environment from pyasm.search import DbContainer, DatabaseException, Sql plugin_dir = Environment.get_plugin_dir() sys.path.insert(0, plugin_dir) try: sql = DbContainer.get("sthpw") if sql.get_database_type() != "MongoDb": # before batch, clean up the ticket with a NULL code if os.getenv('TACTIC_MODE') != 'production': sql.do_update('DELETE from "ticket" where "code" is NULL') else: start_port = Config.get_value("services", "start_port") if start_port: start_port = int(start_port) else: start_port = 8081 if port and int(port) == start_port: sql.do_update('DELETE from "ticket" where "code" is NULL') except DatabaseException as e: # TODO: need to work on this print("ERROR: could not connect to [sthpw] database") #os.environ["TACTIC_CONFIG_PATH"] = Config.get_default_config_path() #Sql.set_default_vendor("Sqlite") Config.set_tmp_config() Config.reload_config() # try connecting again try: sql = DbContainer.get("sthpw") except: print "Could not connect to the database." raise # is it CherryPyStartup's responsibility to start batch? from pyasm.security import Batch Batch() self.site_dir = os.getenv("TACTIC_SITE_DIR") self.install_dir = os.getenv("TACTIC_INSTALL_DIR") # set up a simple environment. May need a more complex one later self.env = Environment() self.setup_env() self.config = self.setup_sites() self.init_only = False cherrypy.startup = self # this initializes the web. # - sets up virtual implied tiggers from web_init import WebInit WebInit().execute() # Windows should handle fine #start up the caching system if it's not windows cache_mode = Config.get_value("install", "cache_mode") if not cache_mode: cache_mode = 'complete' if os.name == 'nt': cache_mode = 'basic' from cache_startup import CacheStartup cmd = CacheStartup(mode=cache_mode) cmd.execute() cmd.init_scheduler() # DEPRECATED (but keeping it around" """ # start up the queue system ... if Config.get_value("sync", "enabled") == "true": # start up the sync system ... print("Starting Transaction Sync ...") from tactic.command import TransactionQueueManager TransactionQueueManager.start() # start up the sync system ... print("Starting Watch Folder Service ...") from tactic.command import WatchServerFolderTask WatchServerFolderTask.start() """ # start up scheduled triggers #from tactic.command import ScheduledTriggerMonitor #ScheduledTriggerMonitor.start() #from pyasm.web import Translation #Translation.install() # close all the threads in this startup thread from pyasm.search import DbContainer DbContainer.close_thread_sql() version = Environment.get_release_version() print("") print("Starting TACTIC v%s ..." % version) print("")
def preprocess(my): my.version = Environment.get_release_version()
pass elif answer == 'n': sys.exit(0) else: print "Only y or n is accepted. Exiting..." sys.exit(0) version = current_version elif len(args) == 1: version = args[0] else: print "Either 1 or no argument can be accepted." if not version: version = tacticversion if version != Environment.get_release_version(): answer = raw_input("[%s] does not match currently running TACTIC version [%s]. If it is a lower version number, it will probably not work. -f must be used to continue. For regular upgrade, you have not symlinked to the new TACTIC version. Continue (y/n): " \ %(version, Environment.get_release_version())) if answer == "y": if not is_forced: print "-f option must be used in this situation. " sys.exit(0) pass elif answer == 'n': sys.exit(0) else: print "Only y or n is accepted. Exiting..." sys.exit(0) # check if some projects are already in newer version
def get_compact_js_context_path_suffix(): context_path_suffix = "spt_js/_compact_spt_all_r%s.js" % Environment.get_release_version().replace(".","_") return context_path_suffix
def get_compact_js_context_path_suffix(): context_path_suffix = "spt_js/_compact_spt_all_r%s.js" % Environment.get_release_version( ).replace(".", "_") return context_path_suffix
def add_top_behaviors(self): self.body.add_relay_behavior({ 'type': 'click', 'bvr_match_class': 'tactic_popup', 'cbjs_action': ''' var view = bvr.src_el.getAttribute("view"); if (!view) { spt.alert("No view found"); } var target = bvr.src_el.getAttribute("target"); var title = bvr.src_el.getAttribute("title"); var class_name = 'tactic.ui.panel.CustomLayoutWdg'; var kwargs = { view: view, } var attributes = bvr.src_el.attributes; for (var i = 0; i < attributes.length; i++) { var name = attributes[i].name; if (name == "class") { continue; } var value = attributes[i].value; kwargs[name] = value; } spt.panel.load_popup(title, class_name, kwargs); ''' }) self.body.add_relay_behavior({ 'type': 'click', 'bvr_match_class': 'tactic_load', 'cbjs_action': ''' var view = bvr.src_el.getAttribute("view"); if (!view) { spt.alert("No view found"); } var target_class = bvr.src_el.getAttribute("target"); if (! target_class ) { target_class = "spt_content"; } if (target_class.indexOf(".") != "-1") { var parts = target_class.split("."); var top = bvr.src_el.getParent("."+parts[0]); var target = top.getElement("."+parts[1]); } else { var target = $(document.body).getElement("."+target_class); } var class_name = 'tactic.ui.panel.CustomLayoutWdg'; var kwargs = { view: view, } var attributes = bvr.src_el.attributes; for (var i = 0; i < attributes.length; i++) { var name = attributes[i].name; if (name == "class") { continue; } var value = attributes[i].value; kwargs[name] = value; } spt.panel.load(target, class_name, kwargs); var scroll = bvr.src_el.getAttribute("scroll"); if (scroll == "top") { window.scrollTo(0,0); } ''' }) self.body.add_relay_behavior({ 'type': 'click', 'bvr_match_class': 'tactic_link', 'cbjs_action': ''' var href = bvr.src_el.getAttribute("href"); if (!href) { spt.alert("No href defined for this link"); return; } var target = bvr.src_el.getAttribute("target"); if (!target) { target = "_self"; } window.open(href, target); ''' }) self.body.add_relay_behavior({ 'type': 'click', 'bvr_match_class': 'tactic_refresh', 'cbjs_action': ''' var target_class = bvr.src_el.getAttribute("target"); if (target_class.indexOf(".") != "-1") { var parts = target_class.split("."); var top = bvr.src_el.getParent("."+parts[0]); var target = top.getElement("."+parts[1]); } else { var target = $(document.body).getElement("."+target_class); } spt.panel.refresh(target); ''' }) self.body.add_relay_behavior({ 'type': 'click', 'bvr_match_class': 'tactic_new_tab', 'cbjs_action': ''' var view = bvr.src_el.getAttribute("view") var search_key = bvr.src_el.getAttribute("search_key") var expression = bvr.src_el.getAttribute("expression") var name = bvr.src_el.getAttribute("name"); var title = bvr.src_el.getAttribute("title"); if (!name) { name = title; } if (!title) { title = name; } if (!title && !name) { title = name = "Untitled"; } if (expression) { var server = TacticServerStub.get(); var sss = server.eval(expression, {search_keys: search_key, single: true}) search_key = sss.__search_key__; } spt.tab.set_main_body_tab() if (view) { var cls = "tactic.ui.panel.CustomLayoutWdg"; var kwargs = { view: view } } else if (search_key) { var cls = "tactic.ui.tools.SObjectDetailWdg"; var kwargs = { search_key: search_key } } var attributes = bvr.src_el.attributes; for (var i = 0; i < attributes.length; i++) { var attr_name = attributes[i].name; if (attr_name == "class") { continue; } var value = attributes[i].value; kwargs[attr_name] = value; } try { spt.tab.add_new(name, title, cls, kwargs); } catch(e) { spt.alert(e); } ''' }) self.body.add_relay_behavior({ 'type': 'click', 'bvr_match_class': 'tactic_submit', 'cbjs_action': ''' var command = bvr.src_el.getAttribute("command"); var kwargs = { } var server = TacticServerStub.get(); try { server.execute_cmd(command, kwargs); } catch(e) { spt.alert(e); } ''' }) self.body.add_relay_behavior({ 'type': 'mouseenter', 'bvr_match_class': 'tactic_hover', 'cbjs_action': ''' var bgcolor = bvr.src_el.getStyle("background"); bvr.src_el.setAttribute("spt_bgcolor", bgcolor); bvr.src_el.setStyle("background", "#EEE"); ''' }) self.body.add_relay_behavior({ 'type': 'mouseleave', 'bvr_match_class': 'tactic_hover', 'cbjs_action': ''' var bgcolor = bvr.src_el.getAttribute("spt_bgcolor"); if (!bgcolor) bgcolor = ""; //var bgcolor = "" bvr.src_el.setStyle("background", bgcolor); ''' }) self.body.set_unique_id() self.body.add_smart_style("tactic_load", "cursor", "pointer") # check version of the database project = Project.get() version = project.get_value("last_version_update") release = Environment.get_release_version() #if version < release: # FIXME: can't do this ... TACTIC cannot be running when the database # is upgrading. if False: try: from pyasm.security import Site site = Site.get_site() install_dir = Environment.get_install_dir() cmd = '''python "%s/src/bin/upgrade_db.py" -f -s "%s" --quiet --yes &''' % ( install_dir, site) print("cmd: ", cmd) os.system(cmd) pass except Exception as e: print("WARNING: ", e)