def main(): prs = argparse.ArgumentParser('create montage db and load initial data') add_arg = prs.add_argument add_arg('--db_url') add_arg('--debug', action="store_true", default=False) add_arg('--verbose', action="store_true", default=False) args = prs.parse_args() db_url = args.db_url if not db_url: # print '== loading db_url from config' try: config = load_env_config() except Exception: print '!! no db_url specified and could not load config file' raise else: db_url = config.get('db_url') try: create_schema(db_url=db_url, echo=args.verbose) except Exception: if not args.debug: raise pdb.post_mortem() else: print '++ schema created' return
def main(): prs = argparse.ArgumentParser('create montage db and load initial data') add_arg = prs.add_argument add_arg('--db_url') add_arg('--verbose', action="store_true", default=False) args = prs.parse_args() db_url = args.db_url if not db_url: # print '== loading db_url from config' try: config = load_env_config() except Exception: print '!! no db_url specified and could not load config file' raise else: db_url = config.get('db_url') check_schema(db_url=db_url, base_type=Base, echo=args.verbose, autoexit=True) return
def main(): config = utils.load_env_config() prs = argparse.ArgumentParser('test the montage server endpoints') add_arg = prs.add_argument add_arg('--remote', type=str, help='run tests on a remote montage installation') add_arg('--remote_prod', action='store_true', help='run tests on https://tools.wmflabs.org/montage') add_arg('--remote_dev', action='store_true', help='run tests on https://tools.wmflabs.org/montage-dev') args = prs.parse_args() if args.remote: base_url = args.remote elif args.remote_prod: base_url = 'https://tools.wmflabs.org/montage' elif args.remote_dev: base_url = 'https://tools.wmflabs.org/montage-dev' else: base_url = 'http://localhost:5000' parsed_url = urlparse.urlparse(base_url) domain = parsed_url.netloc.partition(':')[0] if domain.startswith('localhost'): domain = 'localhost.local' ck_val = config['dev_local_cookie_value'] else: ck_val = config['dev_remote_cookie_value'] ck = cookielib.Cookie(version=0, name='clastic_cookie', value=ck_val, port=None, port_specified=False, domain=domain, domain_specified=True, domain_initial_dot=False, path=parsed_url.path, path_specified=True, secure=False, expires=None, discard=False, comment=None, comment_url=None, rest={}, rfc2109=False) cookies.set_cookie(ck) print('running tests on %s' % base_url) full_run(base_url, remote=args.remote)
def montage_app(tmpdir): config = utils.load_env_config(env_name='devtest') config['db_url'] = config['db_url'].replace('///', '///' + str(tmpdir) + '/') db_url = config['db_url'] _create_schema(db_url=db_url) index_path = STATIC_PATH + '/index.html' if not os.path.exists(index_path): mkdir_p(STATIC_PATH) with open(index_path, 'w') as f: f.write('<html><body>just for tests</body></html>') app = create_app('devtest', config=config) return app
def main(): prs = argparse.ArgumentParser('drop montage db') add_arg = prs.add_argument add_arg('--db_url') add_arg('--debug', action="store_true", default=False) add_arg('--force', action="store_true", default=False) add_arg('--verbose', action="store_true", default=False) args = prs.parse_args() db_url = args.db_url if not db_url: # print '== loading db_url from config' try: config = load_env_config() except Exception: print '!! no db_url specified and could not load config file' raise else: db_url = config.get('db_url') if not args.force: confirmed = raw_input('?? this will drop all tables from %r.' ' type yes to confirm: ' % db_url) if not confirmed == 'yes': print '-- you typed %r, aborting' % confirmed sys.exit(0) print '.. dropping all tables in %r in:' % db_url time.sleep(1.2) for x in range(3, 0, -1): print '.. ', x time.sleep(0.85) try: drop_schema(db_url=db_url, echo=args.verbose) except Exception: if not args.debug: raise pdb.post_mortem() else: print '++ schema dropped' return
import random import datetime from pprint import pprint from montage.rdb import (make_rdb_session, JurorDAO, OrganizerDAO, MaintainerDAO, CoordinatorDAO, lookup_user) from montage.utils import PermissionDenied, get_threshold_map, load_env_config random.seed('badidea') GIST_URL = 'https://gist.githubusercontent.com/slaporte/7433943491098d770a8e9c41252e5424/raw/ca394147a841ea5f238502ffd07cbba54b9b1a6a/wlm2015_fr_500.csv' config = load_env_config() def cross_complete(rdb_session, rnd): juror1, juror2 = rnd.jurors[0], rnd.jurors[1] juror1_dao = JurorDAO(rdb_session, juror1) task = juror1_dao.get_tasks_from_round(rnd, num=1)[0] juror2_dao = JurorDAO(rdb_session, juror2) juror2_dao.apply_rating(task, 0.2) return def rate_round_tasks(rdb_session, rnd, limit_per=None): for juror in rnd.jurors: print '.. voting for %s' % juror.username juror_dao = JurorDAO(rdb_session, juror)