def install_demo(home, backend, template): """Install a demo tracker Parameters: home: tracker home directory path backend: database backend name template: full path to the tracker template directory """ from roundup import init, instance, password, backends # set up the config for this tracker config = configuration.CoreConfig() config['TRACKER_HOME'] = home config['MAIL_DOMAIN'] = 'localhost' config['DATABASE'] = 'db' config['WEB_DEBUG'] = True if backend in ('mysql', 'postgresql'): config['RDBMS_HOST'] = 'localhost' config['RDBMS_USER'] = '******' config['RDBMS_PASSWORD'] = '******' config['RDBMS_NAME'] = 'rounduptest' # see if we have further db nuking to perform module = backends.get_backend(backend) if module.db_exists(config): module.db_nuke(config) init.install(home, template) # don't have email flying around os.remove(os.path.join(home, 'detectors', 'nosyreaction.py')) try: os.remove(os.path.join(home, 'detectors', 'nosyreaction.pyc')) except os.error, error: if error.errno != errno.ENOENT: raise
def install_demo(home, backend, template): """Install a demo tracker Parameters: home: tracker home directory path backend: database backend name template: tracker template """ from roundup import init, instance, password # set up the config for this tracker template_dir = os.path.join('share', 'roundup', 'templates', template) # Load optional override ini file. Missing ini file is ignored. template_cfg = configuration.UserConfig(template_dir + "/config_ini.ini") config = configuration.CoreConfig( settings={i.name: i.get() for i in template_cfg.items()}) config['TRACKER_HOME'] = home config['MAIL_DOMAIN'] = 'localhost' config['DATABASE'] = 'db' config['WEB_DEBUG'] = True if backend in ('mysql', 'postgresql'): config['RDBMS_HOST'] = 'localhost' config['RDBMS_USER'] = '******' config['RDBMS_PASSWORD'] = '******' config['RDBMS_NAME'] = 'rounduptest' config['RDBMS_BACKEND'] = backend # see if we need to clean up existing directory if os.path.exists(home): if os.path.exists(home + '/config.ini'): # clear everything out to avoid conflicts with former # extensions and detectors print("Nuking directory left from the previous demo instance.") shutil.rmtree(home) else: print("Error: Refusing to nuke non-tracker directory:") print(" %s" % home) sys.exit(1) init.install(home, template_dir) # Remove config_ini.ini file from tracker_home (not template dir). # Ignore file not found - not all templates have # config_ini.ini files. try: os.remove(home + "/config_ini.ini") except OSError as e: # FileNotFound exception under py3 if e.errno == 2: pass else: raise # don't have email flying around nosyreaction = os.path.join(home, 'detectors', 'nosyreaction.py') if os.path.exists(nosyreaction): os.remove(nosyreaction) nosyreaction += 'c' if os.path.exists(nosyreaction): os.remove(nosyreaction) # figure basic params for server hostname = 'localhost' # pick a fairly odd, random port port = 8917 while 1: print('Trying to set up web server on port %d ...' % port, ) s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) try: s.connect((hostname, port)) except socket.error as e: if not hasattr(e, 'args') or e.args[0] != errno.ECONNREFUSED: raise print('should be ok.') break else: s.close() print('already in use.') port += 100 config['TRACKER_WEB'] = 'http://%s:%s/demo/' % (hostname, port) # write the config config['INSTANT_REGISTRATION'] = 1 config.save(os.path.join(home, config.INI_FILE)) # open the tracker and initialise tracker = instance.open(home) tracker.init(password.Password('admin')) # add the "demo" user db = tracker.open('admin') # FIXME: Move tracker-specific demo initialization into the tracker # templates. if os.path.basename(template) == 'minimal': db.user.create(username='******', password=password.Password('demo'), roles='User') else: db.user.create(username='******', password=password.Password('demo'), realname='Demo User', roles='User') db.commit() db.close()
def install_demo(home, backend, template): """Install a demo tracker Parameters: home: tracker home directory path backend: database backend name template: tracker template """ from roundup import init, instance, password, backends # set up the config for this tracker config = configuration.CoreConfig() config['TRACKER_HOME'] = home config['MAIL_DOMAIN'] = 'localhost' config['DATABASE'] = 'db' config['WEB_DEBUG'] = True if backend in ('mysql', 'postgresql'): config['RDBMS_HOST'] = 'localhost' config['RDBMS_USER'] = '******' config['RDBMS_PASSWORD'] = '******' config['RDBMS_NAME'] = 'rounduptest' # see if we have further db nuking to perform module = backends.get_backend(backend) if module.db_exists(config): module.db_nuke(config) template_dir = os.path.join('share', 'roundup', 'templates', template) init.install(home, template_dir) # don't have email flying around nosyreaction = os.path.join(home, 'detectors', 'nosyreaction.py') if os.path.exists(nosyreaction): os.remove(nosyreaction) nosyreaction += 'c' if os.path.exists(nosyreaction): os.remove(nosyreaction) init.write_select_db(home, backend) # figure basic params for server hostname = 'localhost' # pick a fairly odd, random port port = 8917 while 1: print 'Trying to set up web server on port %d ...'%port, s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) try: s.connect((hostname, port)) except socket.error, e: if not hasattr(e, 'args') or e.args[0] != errno.ECONNREFUSED: raise print 'should be ok.' break else: s.close() print 'already in use.' port += 100
def install_demo(home, backend, template): """Install a demo tracker Parameters: home: tracker home directory path backend: database backend name template: tracker template """ from roundup import init, instance, password, backends # set up the config for this tracker config = configuration.CoreConfig() config["TRACKER_HOME"] = home config["MAIL_DOMAIN"] = "localhost" config["DATABASE"] = "db" config["WEB_DEBUG"] = True if backend in ("mysql", "postgresql"): config["RDBMS_HOST"] = "localhost" config["RDBMS_USER"] = "******" config["RDBMS_PASSWORD"] = "******" config["RDBMS_NAME"] = "rounduptest" config["RDBMS_BACKEND"] = backend # see if we need to clean up existing directory if os.path.exists(home): if os.path.exists(home + "/config.ini"): # clear everything out to avoid conflicts with former # extensions and detectors print "Nuking directory left from the previous demo instance." shutil.rmtree(home) else: print "Error: Refusing to nuke non-tracker directory:" print " %s" % home sys.exit(1) template_dir = os.path.join("share", "roundup", "templates", template) init.install(home, template_dir) # don't have email flying around nosyreaction = os.path.join(home, "detectors", "nosyreaction.py") if os.path.exists(nosyreaction): os.remove(nosyreaction) nosyreaction += "c" if os.path.exists(nosyreaction): os.remove(nosyreaction) # figure basic params for server hostname = "localhost" # pick a fairly odd, random port port = 8917 while 1: print "Trying to set up web server on port %d ..." % port, s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) try: s.connect((hostname, port)) except socket.error, e: if not hasattr(e, "args") or e.args[0] != errno.ECONNREFUSED: raise print "should be ok." break else: s.close() print "already in use." port += 100
def install_demo(home, backend, template): """Install a demo tracker Parameters: home: tracker home directory path backend: database backend name template: tracker template """ from roundup import init, instance, password, backends # set up the config for this tracker config = configuration.CoreConfig() config['TRACKER_HOME'] = home config['MAIL_DOMAIN'] = 'localhost' config['DATABASE'] = 'db' config['WEB_DEBUG'] = True if backend in ('mysql', 'postgresql'): config['RDBMS_HOST'] = 'localhost' config['RDBMS_USER'] = '******' config['RDBMS_PASSWORD'] = '******' config['RDBMS_NAME'] = 'rounduptest' # see if we need to clean up existing directory if os.path.exists(home): if os.path.exists(home + '/config.ini'): # clear everything out to avoid conflicts with former # extensions and detectors print "Nuking directory left from the previous demo instance." shutil.rmtree(home) else: print "Error: Refusing to nuke non-tracker directory:" print " %s" % home sys.exit(1) template_dir = os.path.join('share', 'roundup', 'templates', template) init.install(home, template_dir) # don't have email flying around nosyreaction = os.path.join(home, 'detectors', 'nosyreaction.py') if os.path.exists(nosyreaction): os.remove(nosyreaction) nosyreaction += 'c' if os.path.exists(nosyreaction): os.remove(nosyreaction) init.write_select_db(home, backend) # figure basic params for server hostname = 'localhost' # pick a fairly odd, random port port = 8917 while 1: print 'Trying to set up web server on port %d ...'%port, s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) try: s.connect((hostname, port)) except socket.error, e: if not hasattr(e, 'args') or e.args[0] != errno.ECONNREFUSED: raise print 'should be ok.' break else: s.close() print 'already in use.' port += 100