def setUpModule(): """Create database and tables.""" global compmgr, userscomp, liccomp, attcomp, syscomp, projcomp, wikicomp, \ tckcomp, revcomp, xicomp, cachemgr testdir = os.path.basename(os.path.dirname(__file__)) testfile = os.path.basename(__file__) seed = config['seed'] and int(config['seed']) or genseed() log_mheader(log, testdir, testfile, seed) random.seed(seed) info = " Creating models (module-level) ... " log.info(info) print info # Setup SQLAlchemy database engine engine = engine_from_config(config, 'sqlalchemy.') # init_model( engine ) create_models(engine, config, sysentries_cfg=meta.sysentries_cfg, permissions=permissions) compmgr = config['compmgr'] userscomp = config['userscomp'] liccomp = LicenseComponent(compmgr) syscomp = SystemComponent(compmgr) attcomp = AttachComponent(compmgr) projcomp = ProjectComponent(compmgr) wikicomp = WikiComponent(compmgr) tckcomp = TicketComponent(compmgr) revcomp = ReviewComponent(compmgr) xicomp = XInterfaceComponent(compmgr) # Populate DataBase with sample entries print " Populating permissions ..." pop_permissions(seed=seed) print " Populating users ( no_of_users=%s, no_of_relations=%s ) ..." % \ ( no_of_users, no_of_relations ) pop_user(no_of_users, no_of_relations, seed=seed) print " Populating licenses ( no_of_tags=%s, no_of_attachs=%s ) ..." % \ ( no_of_tags, no_of_attachs ) pop_licenses(no_of_tags, no_of_attachs, seed=seed) print " Populating projects ( no_of_projects=%s ) ..." % no_of_projects pop_projects(no_of_projects, no_of_tags, no_of_attachs, seed=seed) print " Populating tickets ( no_of_tickets=%s ) ..." % no_of_tickets pop_tickets(no_of_tickets, no_of_tags, no_of_attachs, seed=seed) print " Populating vcs ( no_of_vcs=%s ) ..." % no_of_vcs pop_vcs(no_of_vcs=no_of_vcs, seed=seed) print " Populating wikis ( no_of_wikis=%s ) ..." % no_of_wikis pop_wikipages(no_of_tags, no_of_attachs, seed=seed) print " Populating reviews ( no_of_reviews=%s ) ..." % no_of_reviews pop_reviews(no_of_reviews, no_of_tags, no_of_attachs, seed=seed) print ( " no_of_users=%s, no_of_relations=%s, no_of_tags=%s, " + \ "no_of_attach=%s, no_of_projects=%s, no_of_reviews=%s" ) % \ ( no_of_users, no_of_relations, no_of_tags, no_of_attachs, no_of_projects, no_of_reviews ) # Setup cache manager isdir(cachedir) or os.makedirs(cachedir) cachemgr = cachemod.cachemanager(cachedir) config['cachemgr'] = cachemgr
def setUpModule(): """Create database and tables.""" global compmgr, userscomp, syscomp, wikicomp, seed, ref_swikis, cachemgr testdir = os.path.basename(os.path.dirname(__file__)) testfile = os.path.basename(__file__) seed = config['seed'] and int(config['seed']) or genseed() log_mheader(log, testdir, testfile, seed) random.seed(seed) info = " Creating models (module-level) ... " log.info(info) print info # Setup SQLAlchemy database engine engine = engine_from_config(config, 'sqlalchemy.') # init_model( engine ) create_models(engine, config, sysentries_cfg=meta.sysentries_cfg, permissions=permissions) compmgr = config['compmgr'] userscomp = config['userscomp'] syscomp = SystemComponent(compmgr) wikicomp = WikiComponent(compmgr) # Populate DataBase with sample entries print " Populating permissions ..." pop_permissions(seed=seed) print " Populating users ( no_of_users=%s, no_of_relations=%s ) ..." % \ ( no_of_users, no_of_relations ) pop_user(no_of_users, no_of_relations, seed=seed) ref_swikis = surf_dir(pjoin(sampledata_dir, 'wikipages'))
def setUpModule() : """Create database and tables.""" global compmgr, userscomp, tagcomp, attachcomp, projcomp, wikicomp, wikidata, \ votcomp, zwparser, seed, cachemgr testdir = os.path.basename( os.path.dirname( __file__ )) testfile = os.path.basename( __file__ ) seed = config['seed'] and int(config['seed']) or genseed() log_mheader( log, testdir, testfile, seed ) random.seed( seed ) info = " Creating models (module-level) ... " log.info( info ) print info # Setup SQLAlchemy database engine engine = engine_from_config( config, 'sqlalchemy.' ) # init_model( engine ) create_models( engine, config, sysentries_cfg=meta.sysentries_cfg, permissions=permissions ) compmgr = config['compmgr'] userscomp = config['userscomp'] tagcomp = TagComponent( compmgr ) attachcomp = AttachComponent( compmgr ) projcomp = ProjectComponent( compmgr ) wikicomp = WikiComponent( compmgr ) votcomp = VoteComponent( compmgr ) # Populate DataBase with sample entries print " Populating permissions ..." pop_permissions( seed=seed ) print " Populating users ( no_of_users=%s, no_of_relations=%s ) ..." % \ ( no_of_users, no_of_relations ) pop_user( no_of_users, no_of_relations, seed=seed ) print " Populating licenses ( no_of_tags=%s, no_of_attachs=%s ) ..." % \ ( no_of_tags, no_of_attachs ) pop_licenses( no_of_tags, no_of_attachs, seed=seed ) print " Populating projects ( no_of_projects=%s ) ..." % no_of_projects pop_projects( no_of_projects, no_of_tags, no_of_attachs, seed=seed ) print " Populating tickets ( no_of_tickets=%s ) ..." % no_of_tickets pop_tickets( no_of_tickets, no_of_tags, no_of_attachs, seed=seed ) print " Populating vcs ( no_of_vcs=%s ) ..." % no_of_vcs pop_vcs( no_of_vcs=no_of_vcs, seed=seed ) print " Populating reviews ( no_of_reviews=%s ) ..." % no_of_reviews pop_reviews( no_of_reviews, no_of_tags, no_of_attachs, seed=seed ) # Collect the expected database objects. wikidata = gen_wiki( no_of_tags, no_of_attachs, seed=seed ) print ( " no_of_users=%s, no_of_relations=%s, no_of_tags=%s, " + \ "no_of_attach=%s, no_of_projects=%s, no_of_wikis=%s" ) % \ ( no_of_users, no_of_relations, no_of_tags, no_of_attachs, no_of_projects, no_of_wikis ) zwparser = ZWParser( lex_optimize=True, yacc_debug=True, yacc_optimize=False ) # Setup cache manager isdir( cachedir ) or os.makedirs( cachedir ) cachemgr = cachemod.cachemanager( cachedir ) config['cachemgr'] = cachemgr
def setUpModule() : """Create database and tables.""" global taglist, fnamelist, lines, compmgr, userscomp, filenames, \ attachcomp, liccomp, projcomp, tckcomp, revcomp, wikicomp, \ tagcomp, seed, cachemgr testdir = os.path.basename( os.path.dirname( __file__ )) testfile = os.path.basename( __file__ ) seed = config['seed'] and int(config['seed']) or genseed() log_mheader( log, testdir, testfile, seed ) random.seed( seed ) info = " Creating models (module-level) ... " log.info( info ) print info # Setup SQLAlchemy database engine engine = engine_from_config( config, 'sqlalchemy.' ) # init_model( engine ) create_models( engine, config, sysentries_cfg=meta.sysentries_cfg, permissions=permissions ) # prepare data for testing taglist = [ unicode(h.randomname( randint(0,LEN_TAGNAME), alphanum)) for i in range(randint(0,500)) ] fnamelist = [ h.randomname( randint(1,128) ) + choice( extnames ) for i in range(1000) ] lines = [ ''.join([ choice( alphanum ) for i in range(80) ]) for i in range(50) ] compmgr = config['compmgr'] userscomp = config['userscomp'] attachcomp= AttachComponent( compmgr ) tagcomp = TagComponent( config['compmgr'] ) liccomp = LicenseComponent( compmgr ) projcomp = ProjectComponent( compmgr ) tckcomp = TicketComponent( compmgr ) revcomp = ReviewComponent( compmgr ) wikicomp = WikiComponent( compmgr ) print " Creating `%s` directory for generating attachments ..." % tmp_dir not os.path.isdir( tmp_dir ) and os.makedirs( tmp_dir ) filenames = gen_localfiles( tmp_dir, [ fnamelist.pop( fnamelist.index(choice(fnamelist)) ) for i in range( no_of_attach ) ] ) # Populate DataBase with sample entries print " Populating permissions ..." pop_permissions( seed=seed ) print " Populating users ( no_of_users=%s, no_of_relations=%s ) ..." % \ ( no_of_users, no_of_relations ) pop_user( no_of_users, no_of_relations, seed=seed ) print " no_of_users=%s, no_of_relations=%s, no_of_attach=%s" % \ (no_of_users, no_of_relations, no_of_attach) # Setup cache manager isdir( cachedir ) or os.makedirs( cachedir ) cachemgr = cachemod.cachemanager( cachedir ) config['cachemgr'] = cachemgr
def command( self ) : """Handle the sub-command""" from zeta.comp.system import SystemComponent from zeta.comp.ticket import TicketComponent from zeta.comp.wiki import WikiComponent if len(self.args) == 1 and self.args[0] == 'upgradedb' : syscomp = SystemComponent( compmgr ) tckcomp = TicketComponent( compmgr ) wikicomp= WikiComponent( compmgr ) count = syscomp.upgradewiki() print "Upgraded %s static wiki pages ... ok" % count count = tckcomp.upgradewiki() print "Upgraded %s ticket comments ... ok" % count cnt_wcnt, cnt_wcmt = wikicomp.upgradewiki() print "Upgraded %s wiki contents and %s wiki comments ... ok" % \ ( cnt_wcnt, cnt_wcmt ) else : print "Please provide a valid command. Use -h to know the usage ..."
def setUpModule() : """Create database and tables.""" global compmgr, userscomp, attachcomp, tagcomp, liccomp, projcomp, \ wikicomp, votcomp, taglist, seed, cachemgr testdir = os.path.basename( os.path.dirname( __file__ )) testfile = os.path.basename( __file__ ) seed = config['seed'] and int(config['seed']) or genseed() log_mheader( log, testdir, testfile, seed ) random.seed( seed ) info = " Creating models (module-level) ... " log.info( info ) print info # Setup SQLAlchemy database engine engine = engine_from_config( config, 'sqlalchemy.' ) # init_model( engine ) create_models( engine, config, sysentries_cfg=meta.sysentries_cfg, permissions=permissions ) compmgr = config['compmgr'] userscomp = config['userscomp'] attachcomp = AttachComponent( compmgr ) tagcomp = TagComponent( compmgr ) liccomp = LicenseComponent( compmgr ) projcomp = ProjectComponent( compmgr ) wikicomp = WikiComponent( compmgr ) votcomp = VoteComponent( compmgr ) taglist = [ unicode(h.randomname( randint(0,LEN_TAGNAME), tagchars)) for i in range(randint(1,no_of_tags)) ] # Populate DataBase with sample entries print " Populating permissions ..." pop_permissions( seed=seed ) print " Populating users ( no_of_users=%s, no_of_relations=%s ) ..." % \ ( no_of_users, no_of_relations ) pop_user( no_of_users, no_of_relations, seed=seed ) print " Populating licenses ( no_of_tags=%s, no_of_attachs=%s ) ..." % \ ( no_of_tags, no_of_attachs ) pop_licenses( no_of_tags, no_of_attachs, seed=seed ) print " Populating projects ( no_of_projects=%s ) ..." % no_of_projects pop_projects( no_of_projects, no_of_tags, no_of_attachs, seed=seed ) print " Populating wikis ( no_of_wikis=%s ) ..." % no_of_wikis pop_wikipages( no_of_tags, no_of_attachs, seed=seed ) print ( " no_of_users=%s, no_of_relations=%s, no_of_tags=%s, " + \ "no_of_attach=%s, no_of_projects=%s, no_of_wikis=%s" ) % \ ( no_of_users, no_of_relations, no_of_tags, no_of_attachs, no_of_projects, no_of_wikis ) # Setup cache manager isdir( cachedir ) or os.makedirs( cachedir ) cachemgr = cachemod.cachemanager( cachedir ) config['cachemgr'] = cachemgr
def loadcomponents(config, global_conf, app_conf): from zeta.auth.users import UserComponent from zeta.comp.system import SystemComponent from zeta.comp.attach import AttachComponent from zeta.comp.license import LicenseComponent from zeta.comp.project import ProjectComponent from zeta.comp.review import ReviewComponent from zeta.comp.tag import TagComponent from zeta.comp.ticket import TicketComponent from zeta.comp.timeline import TimelineComponent from zeta.comp.vcs import VcsComponent from zeta.comp.vote import VoteComponent from zeta.comp.wiki import WikiComponent from zeta.comp.xinterface import XInterfaceComponent from zeta.comp.xsearch import XSearchComponent from zeta.comp.zmail import ZMailComponent from zeta.comp.forms import VForm global userscomp, syscomp, attcomp, attachcomp, liccomp, projcomp, prjcomp,\ revcomp, revwcomp, tagcomp, tckcomp, tlcomp, vcscomp, votecomp, \ votcomp, wikicomp, xintcomp, xicomp, srchcomp, zmailcomp, mailcomp, \ vfcomp userscomp = config['userscomp'] = UserComponent(compmgr) syscomp = SystemComponent(compmgr) attcomp = attachcomp = AttachComponent(compmgr) liccomp = LicenseComponent(compmgr) projcomp = prjcomp = ProjectComponent(compmgr) revcomp = revwcomp = ReviewComponent(compmgr) tagcomp = TagComponent(compmgr) tckcomp = TicketComponent(compmgr) tlcomp = TimelineComponent(compmgr) vcscomp = VcsComponent(compmgr) votecomp = votcomp = VoteComponent(compmgr) wikicomp = WikiComponent(compmgr) xintcomp = xicomp = XInterfaceComponent(compmgr) srchcomp = XSearchComponent(compmgr) zmailcomp = mailcomp = ZMailComponent(compmgr, config=config) vfcomp = VForm(compmgr) return None