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()
VALUES ('shot_attr_change', 'Attribute Changes For Shots', 'email', 'prod/shot', 'update|prod/shot'); ''') print "Upgrading the database schema in quiet mode..." print from pyasm.search.upgrade import Upgrade from pyasm.security import Batch Batch() version = my.get_version() version.replace('.', '_') upgrade = Upgrade(version, is_forced=True, project_code=None, quiet=True) upgrade.execute() #print os.system('python \"%s/src/bin/upgrade_db.py\" -f -q -y'%install_dir) print print print "*** Installation of TACTIC completed at [%s] ***" %my.tactic_base_dir print print #if my.backup_msg: # print my.backup_msg if os.name != 'nt': print "Next, please install the Apache Web Server and then copy the Apache config extension [%s] to the Apache web server config area. e.g. /etc/httpd/conf.d/"%my.apache_conf_path else:
VALUES ('asset_attr_change', 'Attribute Changes For Assets', 'email', 'prod/asset', 'update|prod/asset'); INSERT INTO notification (code, description, "type", search_type, event) VALUES ('shot_attr_change', 'Attribute Changes For Shots', 'email', 'prod/shot', 'update|prod/shot'); ''') print "Upgrading the database schema in quiet mode..." print from pyasm.search.upgrade import Upgrade from pyasm.security import Batch Batch() version = self.get_version() version.replace('.', '_') upgrade = Upgrade(version, is_forced=True, project_code=None, quiet=True) upgrade.execute() #print os.system('python \"%s/src/bin/upgrade_db.py\" -f -q -y'%install_dir) print print print "*** Installation of TACTIC completed at [%s] ***" % self.tactic_base_dir print print #if self.backup_msg: # print self.backup_msg if os.name != 'nt': print "Next, please install the Apache Web Server and then copy the Apache config extension [%s] to the Apache web server config area. e.g. /etc/httpd/conf.d/" % self.apache_conf_path
pass elif answer == 'n': sys.exit(0) else: print "Only y or n is accepted. Exiting..." sys.exit(0) p = re.compile(r'\d+.\d+.\d+(.\w+)?$') if not p.match(version): print print "Version pattern is invalid. Examples for version are 2.0.0 or 2.0.0.rc02. If you are just upgrading to the current version, just run: " print print "python upgrade_db.py" sys.exit(0) version.replace('.', '_') upgrade = Upgrade(version, is_forced, project_code=project_code, quiet=quiet, is_confirmed=is_confirmed) upgrade.execute() if not quiet: print "Upgrade to version [%s] finished." % version tmp_dir = Environment.get_tmp_dir() output_file = '%s/upgrade_output.txt' % tmp_dir if not quiet: print "Upgrade output file saved in [%s]" % output_file
def execute(self, install_db=True, install_defaults=False, database_type='PostgresSQL', port_num='5432'): self.tactic_base_dir = None self.tactic_data_base_dir = None self.tactic_install_dir = None self.tmp_dir = None self.tactic_site_dir = None self.tactic_apache_user = '******' self.apache_conf_path = None self.database_type = database_type self.port_num = port_num self.backup_msg = None self.non_default_install = False project_code = "sthpw" project_type = "sthpw" self.print_header() # verification try: if install_db: self.check_db_program() self.check_db_exists(project_code) # install the necessary files to python directory self.install_to_python(install_defaults) except InstallException as e: print("Error: %s" %e.__str__()) print() print("Exiting...") print() sys.exit(2) self.update_tactic_configs() # check modules try: import tacticenv except ImportError: print('Error: Failed to "import tacticenv"') return self.check_modules(install_db) # create the asset_dir from pyasm.common import Environment asset_dir = Environment.get_asset_dir() if not os.path.exists(asset_dir): os.makedirs(asset_dir) # check that the main directories exists install_dir = os.getenv("TACTIC_INSTALL_DIR") data_dir = os.getenv("TACTIC_DATA_DIR") if not os.path.exists(install_dir): print("Environment variable TACTIC_INSTALL_DIR '%s' does not exist" % install_dir) return if not os.path.exists(data_dir): print("Environment variable TACTIC_DATA_DIR '%s' does not exist" % data_dir) return # create the dist folder dist_dir = Environment.get_dist_dir() if not os.path.exists(dist_dir): os.makedirs(dist_dir) self.create_temp_directory() self.change_directory_ownership() self.install_win32_service() if install_db == False: print("TACTIC setup successful. Next, the TACTIC database needs to be configured.") return # dynamically load modules now that we know where they are from pyasm.search import DatabaseImpl, DbContainer # create the sthpw database database = DatabaseImpl.get() # check if database exists print("Creating database '%s' ..." % project_code) print() db_exists = False from pyasm.search import DatabaseException try: if database.database_exists(project_code): print("... already exists. Please remove first") raise InstallException("Database '%s' already exists" % project_code) db_exists = True except DatabaseException as e: pass if not db_exists: # create the database database.create_database(project_code) # import the default schema database.import_schema(project_code, project_type) # import the default data database.import_default_data(project_code, project_type) # add the default user (admin) self.run_sql(''' --add in admin group INSERT INTO login_group (login_group, description) VALUES ('admin', 'Site Administration'); --add in admin user, default password 'tactic' INSERT INTO "login" ("login", "password", "upn", first_name, last_name) VALUES ('admin', '39195b0707436a7ecb92565bf3411ab1', 'admin', 'Admin', ''); --add the admin user to the admin group INSERT INTO login_in_group ("login", login_group) VALUES ('admin', 'admin'); ''') # add in the necessary triggers for email notification self.run_sql(''' --register notification INSERT INTO notification (code, description, "type", search_type, event) VALUES ('asset_attr_change', 'Attribute Changes For Assets', 'email', 'prod/asset', 'update|prod/asset'); INSERT INTO notification (code, description, "type", search_type, event) VALUES ('shot_attr_change', 'Attribute Changes For Shots', 'email', 'prod/shot', 'update|prod/shot'); ''') print("Upgrading the database schema in quiet mode...") print() from pyasm.search.upgrade import Upgrade from pyasm.security import Batch Batch() version = self.get_version() version.replace('.', '_') upgrade = Upgrade(version, is_forced=True, project_code=None, quiet=True) upgrade.execute() #print(os.system('python \"%s/src/bin/upgrade_db.py\" -f -q -y'%install_dir)) print() print() print("*** Installation of TACTIC completed at [%s] ***" %self.tactic_base_dir) print() print() #if self.backup_msg: # print(self.backup_msg) if os.name != 'nt': print("Next, please install the Apache Web Server and then copy the Apache config extension [%s] to the Apache web server config area. e.g. /etc/httpd/conf.d/"%self.apache_conf_path) else: print("Next, please install the Apache Web Server and then copy the Apache config extension [%s] to the Apache web server config area. e.g. C:/Program Files/Apache Software Foundation/Apache2.2/conf/"%self.apache_conf_path) print() print("Depending on the OS, you may need to add the following line to the main config file [httpd.conf] shipped with Apache as well:") print() if os.name == 'nt': print("Include conf/tactic_win32.conf") else: print("Include conf.d/*.conf") print()