def create_db():
    """Creates the development database"""
    from bespin import config, database, db_versions
    from migrate.versioning.shell import main

    config.set_profile('dev')

    base_url = config.c.dburl

    config_file = options.server.config_file
    if config_file.exists():
        info("Loading config: %s", config_file)
        code = compile(config_file.bytes(), config_file, "exec")
        exec code in {}

    if config.c.dburl == base_url and path("devdata.db").exists():
        raise BuildFailure("Development database already exists")

    config.activate_profile()
    dry("Create database tables",
        database.Base.metadata.create_all,
        bind=config.c.dbengine)

    repository = str(path(db_versions.__file__).dirname())
    dburl = config.c.dburl
    result = sh("python bespin/db_versions/manage.py version", capture=True)
    dry("Turn on migrate versioning", main,
        ["version_control", "--version",
         result.rstrip(), dburl, repository])
예제 #2
0
def start_server(args=None):
    if args is None:
        args = sys.argv[1:]

    if args:
        mode = args.pop(0)
    else:
        mode = "dev"

    print("Bespin mobwrite worker (mode=" + mode + ")")
    config.set_profile(mode)

    if args:
        config.load_pyconfig(args.pop(0))

    if mode == "dev":
        config.load_pyconfig("devconfig.py")

    config.activate_profile()

    app = WSGIMobWrite()
    app = db_middleware(app)

    serve(app,
          config.c.mobwrite_server_address,
          config.c.mobwrite_server_port,
          use_threadpool=True)
예제 #3
0
def create_db():
    """Creates the development database"""
    from bespin import config, database, db_versions
    from migrate.versioning.shell import main
    
    config.set_profile('dev')
    
    base_url = config.c.dburl
    
    config_file = options.server.config_file
    if config_file.exists():
        info("Loading config: %s", config_file)
        code = compile(config_file.bytes(), config_file, "exec")
        exec code in {}

    if config.c.dburl == base_url and path("devdata.db").exists():
        raise BuildFailure("Development database already exists")
    
    config.activate_profile()
    dry("Create database tables", database.Base.metadata.create_all, bind=config.c.dbengine)
    
    repository = str(path(db_versions.__file__).dirname())
    dburl = config.c.dburl
    result = sh("python bespin/db_versions/manage.py version", capture=True)
    dry("Turn on migrate versioning", main, ["version_control", "--version", result.rstrip(), dburl, repository])
예제 #4
0
def editbespin(options):
    """Use Bespin to edit Bespin. This will change the given
    user's file location to the directory above Bespin, allowing
    you to edit Bespin (and any other projects you have
    in that directory)."""
    
    if not 'editbespin' in options or not options.editbespin.user:
        raise BuildFailure("You must specify a user with -u for this task.")
        
    user = options.editbespin.user
    
    from bespin import config
    from bespin import database, filesystem
    from sqlalchemy.orm.exc import NoResultFound
    
    config.set_profile("dev")
    config.activate_profile()
    session = config.c.session_factory()
    try:
        user = session.query(database.User).filter_by(username=user).one()
    except NoResultFound:
        raise BuildFailure("I couldn't find %s in the database. Sorry!" % (user))
    
    location = path.getcwd().parent.abspath()
    user.file_location = location
    user.recompute_files()
    session.commit()
    bespinsettings_loc = location / "BespinSettings"
    if not bespinsettings_loc.exists():
        project = filesystem.get_project(user, user, "BespinSettings", create=True)
        project.install_template('usertemplate')
    info("User %s set up to access directory %s" % (user, location))
예제 #5
0
파일: pavement.py 프로젝트: spot/bespin
def start():
    """Starts the BespinServer on localhost port 8080 for development.
    
    You can change the port and allow remote connections by setting
    server.port or server.address on the command line.
    
    paver server.address=your.ip.address server.port=8000 start
    
    will allow remote connections (assuming you don't have a firewall
    blocking the connection) and start the server on port 8000.
    """
    # automatically install Dojo if it's not there already
    if not (options.dojo.destination / "dojo").exists():
        dojo()
    
    from bespin import config, controllers
    from paste.httpserver import serve
    
    options.order('server')
    
    config.set_profile('dev')
    
    if options.server.try_build:
        config.c.static_dir = (options.build_dir / "frontend").abspath()
    
    if options.server.dburl:
        config.c.dburl = options.server.dburl
    
    if options.server.async:
        config.c.async_jobs = True
        config.c.queue_path = path.getcwd() / "queue.db"
    
    config.activate_profile()
    port = int(options.port)
    serve(controllers.make_app(), options.address, port, use_threadpool=True)
예제 #6
0
파일: test_queues.py 프로젝트: spot/bespin
def setup_module(module):
    if queue_db.exists():
        print "Deleting old queue DB"
        queue_db.unlink()
    config.set_profile("test")
    config.c.async_jobs = True
    config.c.queue_path = queue_db
    config.activate_profile()
예제 #7
0
파일: pavement.py 프로젝트: iNeft/bespin
def try_upgrade():
    """Run SQLAlchemy-migrate test on your database."""
    from bespin import config, model, db_versions
    from migrate.versioning.shell import main
    config.set_profile('dev')
    config.activate_profile()
    repository = str(path(db_versions.__file__).dirname())
    dburl = config.c.dburl
    dry("Test the database upgrade", main, ["test", repository, dburl])
예제 #8
0
def upgrade():
    """Upgrade your database."""
    from bespin import config, model, db_versions
    from migrate.versioning.shell import main
    config.set_profile('dev')
    config.activate_profile()
    repository = str(path(db_versions.__file__).dirname())
    dburl = config.c.dburl
    dry("Run the database upgrade", main, ["upgrade", dburl, repository])
예제 #9
0
def try_upgrade():
    """Run SQLAlchemy-migrate test on your database."""
    from bespin import config, model, db_versions
    from migrate.versioning.shell import main
    config.set_profile('dev')
    config.activate_profile()
    repository = str(path(db_versions.__file__).dirname())
    dburl = config.c.dburl
    dry("Test the database upgrade", main, ["test", repository, dburl])
예제 #10
0
파일: pavement.py 프로젝트: iNeft/bespin
def upgrade():
    """Upgrade your database."""
    from bespin import config, model, db_versions
    from migrate.versioning.shell import main
    config.set_profile('dev')
    config.activate_profile()
    repository = str(path(db_versions.__file__).dirname())
    dburl = config.c.dburl
    dry("Run the database upgrade", main, ["upgrade", dburl, repository])
def setup_module():
    global app, app_murdoc
    config.set_profile('test')
    app = controllers.make_app()
    app = BespinTestApp(app)
    app_murdoc = controllers.make_app()
    app_murdoc = BespinTestApp(app_murdoc)
    
    _install_test_plugin_path()
    config.activate_profile()
예제 #12
0
def setup_module(module):
    global app, session
    config.set_profile('test')
    config.activate_profile()
    Base.metadata.drop_all(bind=config.c.dbengine)
    Base.metadata.create_all(bind=config.c.dbengine)
    session = config.c.session_factory()
    User.create_user("BillBixby", "", "*****@*****.**")
    app = controllers.make_app()
    app = BespinTestApp(app)
    app.post("/register/login/BillBixby", dict(password=""))
예제 #13
0
def setup_module(module):
    global user_manager, app, session
    config.set_profile('test')
    config.activate_profile()
    model.Base.metadata.drop_all(bind=config.c.dbengine)
    model.Base.metadata.create_all(bind=config.c.dbengine)
    session = config.c.sessionmaker(bind=config.c.dbengine)
    user_manager = model.UserManager(session)
    user_manager.create_user("BillBixby", "", "*****@*****.**")
    app = controllers.make_app()
    app = TestApp(app)
    app.post("/register/login/BillBixby", dict(password=""))
예제 #14
0
파일: pavement.py 프로젝트: iNeft/bespin
def seeddb():
    from bespin import config, filesystem
    from bespin.database import User, Connection
    config.set_profile("dev")
    config.activate_profile()

    def get_user(name):
        user = User.find_user(name)
        if user == None:
            user = User.create_user(name, name, name + "@foo.com")
            session.commit()
            info("Created user called '" + name + "'")
        try:
            filesystem.get_project(user, user, "BespinSettings")
        except:
            settings = filesystem.get_project(user,
                                              user,
                                              "BespinSettings",
                                              create=True)
            settings.install_template('usertemplate')
            info("Created BespinSettings project for '" + name + "'")
        return user

    # Seriously there is something wrong with my ego today ;-)
    bgalbraith = get_user("bgalbraith")
    kdangoor = get_user("kdangoor")
    dalmaer = get_user("d")
    mattb = get_user("mattb")
    zuck = get_user("zuck")
    tom = get_user("tom")
    ev = get_user("ev")
    j = get_user("j")

    bgalbraith.follow(j)
    kdangoor.follow(j)
    dalmaer.follow(j)
    mattb.follow(j)
    zuck.follow(j)
    tom.follow(j)
    ev.follow(j)

    jproject = filesystem.get_project(j, j, "SampleProject", create=True)

    j.add_sharing(jproject, bgalbraith, edit=True)
    j.add_sharing(jproject, kdangoor, edit=True)
    j.add_sharing(jproject, dalmaer, edit=True)
    j.add_sharing(jproject, mattb, edit=False)
    j.add_sharing(jproject, zuck, edit=False)
    j.add_sharing(jproject, tom, edit=False)
    j.add_sharing(jproject, ev, edit=False)
예제 #15
0
파일: test_users.py 프로젝트: iNeft/bespin
def test_password_change_bad_code():
    config.set_profile("test")
    config.activate_profile()
    _clear_db()

    app = controllers.make_app()
    app = BespinTestApp(app)
    resp = app.post('/register/new/BillBixby',
                    dict(email="*****@*****.**", password="******"))
    app.reset()

    resp = app.post('/register/password/BillBixby',
                    dict(code="42", newPassword="******"),
                    status=400)
예제 #16
0
def create_db():
    """Creates the development database"""
    from bespin import config, database, db_versions
    from migrate.versioning.shell import main
    
    if path("devdata.db").exists():
        raise BuildFailure("Development database already exists")
    config.set_profile('dev')
    config.activate_profile()
    dry("Create database tables", database.Base.metadata.create_all, bind=config.c.dbengine)
    
    repository = str(path(db_versions.__file__).dirname())
    dburl = config.c.dburl
    dry("Turn on migrate versioning", main, ["version_control", dburl, repository])
예제 #17
0
파일: test_users.py 프로젝트: Jangts/bespin
def test_password_change_bad_code():
    config.set_profile("test")
    config.activate_profile()
    _clear_db()
    
    app = controllers.make_app()
    app = BespinTestApp(app)
    resp = app.post('/register/new/BillBixby', dict(email="*****@*****.**",
                                                    password="******"))
    app.reset()
    
    resp = app.post('/register/password/BillBixby', dict( 
                                            code="42",
                                            newPassword="******"),
                    status=400)
    
예제 #18
0
def seeddb():
    from bespin import config, filesystem
    from bespin.database import User, Connection
    config.set_profile("dev")
    config.activate_profile()

    def get_user(name):
        user = User.find_user(name)
        if user == None:
            user = User.create_user(name, name, name + "@foo.com")
            session.commit()
            info("Created user called '" + name + "'")
        try:
            filesystem.get_project(user, user, "BespinSettings")
        except:
            settings = filesystem.get_project(user, user, "BespinSettings", create=True)
            settings.install_template('usertemplate')
            info("Created BespinSettings project for '" + name + "'")
        return user

    # Seriously there is something wrong with my ego today ;-)
    bgalbraith = get_user("bgalbraith")
    kdangoor = get_user("kdangoor")
    dalmaer = get_user("d")
    mattb = get_user("mattb")
    zuck = get_user("zuck")
    tom = get_user("tom")
    ev = get_user("ev")
    j = get_user("j")

    bgalbraith.follow(j)
    kdangoor.follow(j)
    dalmaer.follow(j)
    mattb.follow(j)
    zuck.follow(j)
    tom.follow(j)
    ev.follow(j)

    jproject = filesystem.get_project(j, j, "SampleProject", create=True)

    j.add_sharing(jproject, bgalbraith, edit=True)
    j.add_sharing(jproject, kdangoor, edit=True)
    j.add_sharing(jproject, dalmaer, edit=True)
    j.add_sharing(jproject, mattb, edit=False)
    j.add_sharing(jproject, zuck, edit=False)
    j.add_sharing(jproject, tom, edit=False)
    j.add_sharing(jproject, ev, edit=False)
예제 #19
0
파일: test_users.py 프로젝트: iNeft/bespin
def test_lost_username(send_text_email):
    config.set_profile("test")
    config.activate_profile()
    _clear_db()

    app = controllers.make_app()
    app = BespinTestApp(app)
    resp = app.post('/register/new/BillBixby',
                    dict(email="*****@*****.**", password="******"))

    resp = app.post('/register/lost/', dict(email='*****@*****.**'))
    assert send_text_email.called
    args = send_text_email.call_args[0]
    assert args[0] == '*****@*****.**'
    assert args[1].startswith("Your username for ")
    assert "Your username is:" in args[2]
    assert "BillBixby" in args[2]
예제 #20
0
파일: pavement.py 프로젝트: iNeft/bespin
def create_db():
    """Creates the development database"""
    from bespin import config, database, db_versions
    from migrate.versioning.shell import main

    if path("devdata.db").exists():
        raise BuildFailure("Development database already exists")
    config.set_profile('dev')
    config.activate_profile()
    dry("Create database tables",
        database.Base.metadata.create_all,
        bind=config.c.dbengine)

    repository = str(path(db_versions.__file__).dirname())
    dburl = config.c.dburl
    dry("Turn on migrate versioning", main,
        ["version_control", dburl, repository])
예제 #21
0
파일: test_users.py 프로젝트: Jangts/bespin
def test_lost_username(send_text_email):
    config.set_profile("test")
    config.activate_profile()
    _clear_db()
    
    app = controllers.make_app()
    app = BespinTestApp(app)
    resp = app.post('/register/new/BillBixby', dict(email="*****@*****.**",
                                                    password="******"))
    
    resp = app.post('/register/lost/', dict(email='*****@*****.**'))
    assert send_text_email.called
    args = send_text_email.call_args[0]
    assert args[0] == '*****@*****.**'
    assert args[1].startswith("Your username for ")
    assert "Your username is:" in args[2]
    assert "BillBixby" in args[2]
예제 #22
0
def main():
  # Start up a thread that does timeouts and cleanup
  thread.start_new_thread(cleanup_thread, ())

  from bespin import config, controllers
  from bespin.mobwrite.mobwrite_daemon import MobwriteWorker
  config.set_profile('dev')    
  config.activate_profile()

  logging.info("Listening on port %d..." % LOCAL_PORT)
  s = SocketServer.ThreadingTCPServer(("", LOCAL_PORT), AutoPersisterEchoRequestHandler)
  try:
    s.serve_forever()
  except KeyboardInterrupt:
    logging.info("Shutting down.")
    logging.shutdown()
    s.socket.close()
예제 #23
0
파일: test_users.py 프로젝트: iNeft/bespin
def test_password_change_with_confirmation_code():
    config.set_profile("test")
    config.activate_profile()
    _clear_db()

    app = controllers.make_app()
    app = BespinTestApp(app)
    resp = app.post('/register/new/BillBixby',
                    dict(email="*****@*****.**", password="******"))
    app.reset()

    user = User.find_user("BillBixby")
    verify_code = controllers._get_password_verify_code(user)
    resp = app.post('/register/password/BillBixby',
                    dict(code=verify_code, newPassword="******"))

    user = User.find_user('BillBixby', 'hatetraffic')
    assert user
예제 #24
0
파일: test_users.py 프로젝트: Jangts/bespin
def test_users_can_be_locked_out():
    config.set_profile("test")
    config.c.login_failure_tracking = "memory"
    config.c.login_attempts = "1"
    config.c.lockout_period = "1"
    config.activate_profile()
    app = controllers.make_app()
    app = BespinTestApp(app)
    _clear_db()
    
    resp = app.post('/register/new/BillBixby', dict(email="*****@*****.**",
                                                    password="******"))
    resp = app.post("/register/login/BillBixby",
        dict(password="******"), status=401)
    
    # fail with good password now, because we're locked out
    resp = app.post("/register/login/BillBixby",
        dict(password="******"), status=401)
예제 #25
0
파일: test_users.py 프로젝트: Jangts/bespin
def test_lost_password_request(send_text_email):
    config.set_profile("test")
    config.activate_profile()
    _clear_db()
    
    app = controllers.make_app()
    app = BespinTestApp(app)
    resp = app.post('/register/new/BillBixby', dict(email="*****@*****.**",
                                                    password="******"))
    
    app.reset()
    resp = app.post('/register/lost/', dict(username='******'))
    assert send_text_email.called
    args = send_text_email.call_args[0]
    assert args[0] == '*****@*****.**'
    assert args[1].startswith("Requested password change for ")
    user = User.find_user("BillBixby")
    verify_code = controllers._get_password_verify_code(user)
    assert verify_code in args[2]
예제 #26
0
파일: test_users.py 프로젝트: Jangts/bespin
def test_password_change_with_confirmation_code():
    config.set_profile("test")
    config.activate_profile()
    _clear_db()
    
    app = controllers.make_app()
    app = BespinTestApp(app)
    resp = app.post('/register/new/BillBixby', dict(email="*****@*****.**",
                                                    password="******"))
    app.reset()
    
    user = User.find_user("BillBixby")
    verify_code = controllers._get_password_verify_code(user)
    resp = app.post('/register/password/BillBixby', dict( 
                                            code=verify_code,
                                            newPassword="******"))
    
    user = User.find_user('BillBixby', 'hatetraffic')
    assert user
예제 #27
0
파일: test_users.py 프로젝트: iNeft/bespin
def test_lost_password_request(send_text_email):
    config.set_profile("test")
    config.activate_profile()
    _clear_db()

    app = controllers.make_app()
    app = BespinTestApp(app)
    resp = app.post('/register/new/BillBixby',
                    dict(email="*****@*****.**", password="******"))

    app.reset()
    resp = app.post('/register/lost/', dict(username='******'))
    assert send_text_email.called
    args = send_text_email.call_args[0]
    assert args[0] == '*****@*****.**'
    assert args[1].startswith("Requested password change for ")
    user = User.find_user("BillBixby")
    verify_code = controllers._get_password_verify_code(user)
    assert verify_code in args[2]
예제 #28
0
def installkey(options):
    """Install an SSH key into your Bespin keychain. This will
    prompt you for your Bespin keychain password. You must
    give a Bespin username with -u. You must also specify
    a passwordless SSH private key file with -f."""
    
    if not 'installkey' in options or not options.installkey.user:
        raise BuildFailure("You must specify a user with -u for this task.")
    
    if not options.installkey.file:
        raise BuildFailure("You must specify a private key with with -f")
    
    private_key = path(options.installkey.file)
    public_key = private_key + ".pub"
    
    if not private_key.exists() or not public_key.exists():
        raise BuildFailure("Either your private key file or public key file does not exist")
        
    
        
    user = options.installkey.user
    
    import getpass
    
    password = getpass.getpass("Enter your keychain password: "******"dev")
    config.activate_profile()
    session = config.c.session_factory()
    try:
        user = session.query(database.User).filter_by(username=user).one()
    except NoResultFound:
        raise BuildFailure("I couldn't find %s in the database. Sorry!" % (user))
    
    keychain = vcs.KeyChain(user, password)
    public_key = public_key.bytes()
    private_key = private_key.bytes()
    keychain.set_ssh_key(private_key, public_key)
예제 #29
0
파일: pavement.py 프로젝트: iNeft/bespin
def installkey(options):
    """Install an SSH key into your Bespin keychain. This will
    prompt you for your Bespin keychain password. You must
    give a Bespin username with -u. You must also specify
    a passwordless SSH private key file with -f."""

    if not 'installkey' in options or not options.installkey.user:
        raise BuildFailure("You must specify a user with -u for this task.")

    if not options.installkey.file:
        raise BuildFailure("You must specify a private key with with -f")

    private_key = path(options.installkey.file)
    public_key = private_key + ".pub"

    if not private_key.exists() or not public_key.exists():
        raise BuildFailure(
            "Either your private key file or public key file does not exist")

    user = options.installkey.user

    import getpass

    password = getpass.getpass("Enter your keychain password: "******"dev")
    config.activate_profile()
    session = config.c.session_factory()
    try:
        user = session.query(database.User).filter_by(username=user).one()
    except NoResultFound:
        raise BuildFailure("I couldn't find %s in the database. Sorry!" %
                           (user))

    keychain = vcs.KeyChain(user, password)
    public_key = public_key.bytes()
    private_key = private_key.bytes()
    keychain.set_ssh_key(private_key, public_key)
예제 #30
0
def process_mobwrite(args=None):
  if args is None:
    args = sys.argv[1:]

  if args:
    mode = args.pop(0)
  else:
    mode = "dev"

  print("Bespin mobwrite worker (mode=" + mode + ")")  
  config.set_profile(mode)

  if args:
    config.load_pyconfig(args.pop(0))

  config.activate_profile()

  mobwrite_core.logging.basicConfig()
  main()
  mobwrite_core.logging.shutdown()
예제 #31
0
def process_mobwrite(args=None):
    if args is None:
        args = sys.argv[1:]

    if args:
        mode = args.pop(0)
    else:
        mode = "dev"

    print("Bespin mobwrite worker (mode=" + mode + ")")
    config.set_profile(mode)

    if args:
        config.load_pyconfig(args.pop(0))

    config.activate_profile()

    mobwrite_core.logging.basicConfig()
    main()
    mobwrite_core.logging.shutdown()
예제 #32
0
파일: test_users.py 프로젝트: iNeft/bespin
def test_users_can_be_locked_out():
    config.set_profile("test")
    config.c.login_failure_tracking = "memory"
    config.c.login_attempts = "1"
    config.c.lockout_period = "1"
    config.activate_profile()
    app = controllers.make_app()
    app = BespinTestApp(app)
    _clear_db()

    resp = app.post('/register/new/BillBixby',
                    dict(email="*****@*****.**", password="******"))
    resp = app.post("/register/login/BillBixby",
                    dict(password="******"),
                    status=401)

    # fail with good password now, because we're locked out
    resp = app.post("/register/login/BillBixby",
                    dict(password="******"),
                    status=401)
예제 #33
0
파일: pavement.py 프로젝트: iNeft/bespin
def start():
    """Starts the BespinServer on localhost port 8080 for development.
    
    You can change the port and allow remote connections by setting
    server.port or server.address on the command line.
    
    paver server.address=your.ip.address server.port=8000 start
    
    will allow remote connections (assuming you don't have a firewall
    blocking the connection) and start the server on port 8000.
    """
    # automatically install Dojo if it's not there already
    if not (options.dojo.destination / "dojo").exists():
        dojo()

    from bespin import config, controllers
    from paste.httpserver import serve

    options.order('server')

    config.set_profile('dev')

    if options.server.try_build:
        config.c.static_dir = (options.build_dir / "frontend").abspath()

    if options.server.dburl:
        config.c.dburl = options.server.dburl

    if options.server. async:
        config.c.async_jobs = True

    config_file = options.server.config_file
    if config_file.exists():
        info("Loading config: %s", config_file)
        code = compile(config_file.bytes(), config_file, "exec")
        exec code in {}

    config.activate_profile()
    port = int(options.port)
    serve(controllers.make_app(), options.address, port, use_threadpool=True)
def start():
    """Starts the BespinServer on localhost port 8080 for development.
    
    You can change the port and allow remote connections by setting
    server.port or server.address on the command line.
    
    paver server.address=your.ip.address server.port=8000 start
    
    will allow remote connections (assuming you don't have a firewall
    blocking the connection) and start the server on port 8000.
    """
    from bespin import config, controllers
    from paste.httpserver import serve

    options.order('server')

    config.set_profile('dev')

    if options.staticdir:
        config.c.static_dir = path(options.clientdir) / options.staticdir

    if options.server.dburl:
        config.c.dburl = options.server.dburl

    if options.server. async:
        config.c.async_jobs = True

    config.c.server_base_url = options.server_base_url

    config_file = options.server.config_file
    if config_file.exists():
        info("Loading config: %s", config_file)
        code = compile(config_file.bytes(), config_file, "exec")
        exec code in {}

    config.activate_profile()
    port = int(options.port)
    serve(controllers.make_app(), options.address, port, use_threadpool=True)
예제 #35
0
def start():
    """Starts the BespinServer on localhost port 8080 for development.
    
    You can change the port and allow remote connections by setting
    server.port or server.address on the command line.
    
    paver server.address=your.ip.address server.port=8000 start
    
    will allow remote connections (assuming you don't have a firewall
    blocking the connection) and start the server on port 8000.
    """
    from bespin import config, controllers
    from paste.httpserver import serve
    
    options.order('server')
    
    config.set_profile('dev')
    
    if options.staticdir:
        config.c.static_dir = path(options.clientdir) / options.staticdir
    
    if options.server.dburl:
        config.c.dburl = options.server.dburl
    
    if options.server.async:
        config.c.async_jobs = True
    
    config.c.server_base_url = options.server_base_url
    
    config_file = options.server.config_file
    if config_file.exists():
        info("Loading config: %s", config_file)
        code = compile(config_file.bytes(), config_file, "exec")
        exec code in {}
    
    config.activate_profile()
    port = int(options.port)
    serve(controllers.make_app(), options.address, port, use_threadpool=True)
def process_queue(args=None):
    log.info("Bespin queue worker")
    if args is None:
        args = sys.argv[1:]

    if args:
        config.set_profile(args.pop(0))
    else:
        config.set_profile("dev")
        config.c.async_jobs = True

    if args:
        config.load_pyconfig(args.pop(0))

    config.activate_profile()

    bq = config.c.queue
    log.debug("Queue: %s", bq)
    for qi in bq.read_queue("vcs"):
        log.info("Processing job %s", qi.id)
        log.debug("Message: %s", qi.message)
        qi.run()
        qi.done()
예제 #37
0
파일: queue.py 프로젝트: Jangts/bespin
def process_queue(args=None):
    log.info("Bespin queue worker")
    if args is None:
        args = sys.argv[1:]

    if args:
        config.set_profile(args.pop(0))
    else:
        config.set_profile("dev")
        config.c.async_jobs=True

    if args:
        config.load_config(args.pop(0))

    config.activate_profile()

    bq = config.c.queue
    log.debug("Queue: %s", bq)
    for qi in bq.read_queue("vcs"):
        log.info("Processing job %s", qi.id)
        log.debug("Message: %s", qi.message)
        qi.run()
        qi.done()
예제 #38
0
파일: pavement.py 프로젝트: iNeft/bespin
def editbespin(options):
    """Use Bespin to edit Bespin. This will change the given
    user's file location to the directory above Bespin, allowing
    you to edit Bespin (and any other projects you have
    in that directory)."""

    if not 'editbespin' in options or not options.editbespin.user:
        raise BuildFailure("You must specify a user with -u for this task.")

    user = options.editbespin.user

    from bespin import config
    from bespin import database, filesystem
    from sqlalchemy.orm.exc import NoResultFound

    config.set_profile("dev")
    config.activate_profile()
    session = config.c.session_factory()
    try:
        user = session.query(database.User).filter_by(username=user).one()
    except NoResultFound:
        raise BuildFailure("I couldn't find %s in the database. Sorry!" %
                           (user))

    location = path.getcwd().parent.abspath()
    user.file_location = location
    user.recompute_files()
    session.commit()
    bespinsettings_loc = location / "BespinSettings"
    if not bespinsettings_loc.exists():
        project = filesystem.get_project(user,
                                         user,
                                         "BespinSettings",
                                         create=True)
        project.install_template('usertemplate')
    info("User %s set up to access directory %s" % (user, location))
예제 #39
0
def start_server(args=None):
    if args is None:
        args = sys.argv[1:]

    if args:
        mode = args.pop(0)
    else:
        mode = "dev"

    print("Bespin mobwrite worker (mode=" + mode + ")")  
    config.set_profile(mode)

    if args:
        config.load_pyconfig(args.pop(0))

    if mode == "dev":
        config.load_pyconfig("devconfig.py")

    config.activate_profile()

    app = WSGIMobWrite()
    app = db_middleware(app)

    serve(app, config.c.mobwrite_server_address, config.c.mobwrite_server_port, use_threadpool=True)
예제 #40
0
def setup_module(module):
    global app
    config.set_profile("test")
    app = controllers.make_app()
    app = BespinTestApp(app)
예제 #41
0
def setup_module(module):
    global app
    config.set_profile('test')
    app = controllers.make_app()
    app = BespinTestApp(app)
    logging.basicConfig(level=logging.DEBUG)
예제 #42
0
파일: test_users.py 프로젝트: iNeft/bespin
def setup_module(module):
    config.set_profile("test")
    config.activate_profile()
예제 #43
0
파일: test_vcs.py 프로젝트: spot/bespin
def setup_module(module):
    global app
    config.set_profile('test')
    app = controllers.make_app()
    app = TestApp(app)
# 

from path import path

from simplejson import loads

from bespin import config, plugins, controllers
from bespin.database import User, Base, EventLog, _get_session, GalleryPlugin
from bespin.filesystem import get_project

from __init__ import BespinTestApp

app = None

plugindir = (path(__file__).dirname() / "plugindir").abspath()
config.set_profile("test")
_original_plugin_path = config.c.plugin_path

def _install_test_plugin_path(name="testplugins"):
    config.c.plugin_path = [dict(name=name, path=plugindir, 
                            chop=len(plugindir))]

def setup_module():
    global app, app_murdoc
    config.set_profile('test')
    app = controllers.make_app()
    app = BespinTestApp(app)
    app_murdoc = controllers.make_app()
    app_murdoc = BespinTestApp(app_murdoc)
    
    _install_test_plugin_path()
def setup_module(module):
    global app
    config.set_profile('test')
    app = controllers.make_app()
    app = BespinTestApp(app)
    logging.basicConfig(level=logging.DEBUG)
예제 #46
0
def setup_module(module):
    global app
    config.set_profile('test')
    app = controllers.make_app()
    app = BespinTestApp(app)
예제 #47
0
파일: test_config.py 프로젝트: joncv/bespin
def setup_module(module):
    config.set_profile("test")
    config.activate_profile()