Exemple #1
0
"""
Creates a new company.

Usage:
    create_company.py <name>

Options:
    <name>  The name of the company.

"""
from docopt import docopt

from env import path_setup
path_setup()

from jobber.script import run
from jobber.core.models import Company


def main(name, session):
    company = Company(name=name)
    session.add(company)


if __name__ == '__main__':
    arguments = docopt(__doc__)
    name = arguments['<name>']
    run(main, name)
Exemple #2
0
"""
from docopt import docopt

from env import path_setup
path_setup()

from jobber.script import run, die, green
from jobber.core.models import Job
from jobber.functions import social_broadcast


def main(jobid, service, session):
    job = session.query(Job).get(jobid)
    if not job:
        die("Job ({}) was not found.".format(jobid))
    try:
        sb = social_broadcast(job, service)
        session.add(sb)
        session.commit()
        print green("Great, broadcasting was successful.")
    except Exception as exc:
        die(exc)


if __name__ == '__main__':
    arguments = docopt(__doc__)
    jobid = arguments['<jobid>']
    service = arguments['<service>']
    run(main, jobid, service)
Exemple #3
0
from env import path_setup
path_setup()

from jobber.script import run, die
from jobber.core.models import Job
from jobber.core.search import IndexManager, Index
from jobber.conf import settings


def main(query, session):
    name = settings.SEARCH_INDEX_NAME
    directory = settings.SEARCH_INDEX_DIRECTORY

    if not IndexManager.exists(name, directory):
        die('Search index does not exist!')

    if isinstance(query, str):
        query = unicode(query, 'utf-8')

    index = Index()
    for result in index.search(query):
        job = session.query(Job).get(result['id'])
        print job


if __name__ == '__main__':
    arguments = docopt(__doc__)
    query = arguments['<query>']
    run(main, query)
Exemple #4
0
    if not job:
        die("Job ({}) does not exist.".format(job_id))

    print isinstance(job.title, unicode)

    print "You're reviewing the following listing:"
    print make_summary(job).encode('utf-8')

    action = 'publish' if not job.published else 'unpublish'
    if prompt("Do you want to {} this listing?".format(blue(action)), yesno=True):
        job.published = not job.published
        session.commit()

        print green('Job {}ed!'.format(action))

        if action == 'unpublish':
            return

        if prompt(blue('Do you want to send a confirmation email?'), yesno=True):
            send_confirmation_email(job)
            print green('Confirmation email sent!')
    else:
        die('Bye.')


if __name__ == '__main__':
    arguments = docopt(__doc__)
    job_id = int(arguments['<job_id>'])
    run(main, job_id)
Exemple #5
0
"""
from docopt import docopt

from env import path_setup

path_setup()

from jobber.script import run, die, green
from jobber.core.models import Job
from jobber.functions import social_broadcast


def main(jobid, service, session):
    job = session.query(Job).get(jobid)
    if not job:
        die("Job ({}) was not found.".format(jobid))
    try:
        sb = social_broadcast(job, service)
        session.add(sb)
        session.commit()
        print green("Great, broadcasting was successful.")
    except Exception as exc:
        die(exc)


if __name__ == '__main__':
    arguments = docopt(__doc__)
    jobid = arguments['<jobid>']
    service = arguments['<service>']
    run(main, jobid, service)
Exemple #6
0
    },
    'contact_email': {
        'name': 'contact_email',
        'prompt': "Okay, what's the email?"
    }
}

def main(session, app):
    kwargs = dict()
    next = 'title'

    while next:
        field = field_schema[next]
        message = field['prompt']
        handler = field.get('handler')
        value = prompt(message)
        if handler:
            value = handler(value, session)
        kwargs[next] = value
        next = field.get('next')
        if hasattr(next, '__call__'):
            next = next(value)

    job = Job(**kwargs)
    session.add(job)


if __name__ == '__main__':
    docopt(__doc__)
    run(main)
Exemple #7
0
def main(should_create, index_all, session):
    name = settings.SEARCH_INDEX_NAME
    directory = settings.SEARCH_INDEX_DIRECTORY

    if should_create:
        print blue("You've asked to (re)create index '{}'.".format(name))
        IndexManager.create(Schema, name, directory)

    if not IndexManager.exists(name, directory):
        die('Search index does not exist!')

    index = Index()

    start = time.time()

    kwargs = {} if index_all else {'published': True}
    jobs = session.query(Job).filter_by(**kwargs).all()

    index.add_document_bulk([job.to_document() for job in jobs])
    duration = time.time() - start

    print green("{0} documents added okay in {1:.2f} ms.".format(len(jobs), duration))


if __name__ == '__main__':
    arguments = docopt(__doc__)
    should_create = arguments['--create']
    index_all = arguments['--all']
    run(main, should_create, index_all)
Exemple #8
0
def main(should_create, index_all, session):
    name = settings.SEARCH_INDEX_NAME
    directory = settings.SEARCH_INDEX_DIRECTORY

    if should_create:
        print blue("You've asked to (re)create index '{}'.".format(name))
        IndexManager.create(Schema, name, directory)

    if not IndexManager.exists(name, directory):
        die('Search index does not exist!')

    index = Index()

    start = time.time()

    kwargs = {} if index_all else {'published': True}
    jobs = session.query(Job).filter_by(**kwargs).all()

    index.add_document_bulk([job.to_document() for job in jobs])
    duration = time.time() - start

    print green("{0} documents added okay in {1:.2f} ms.".format(
        len(jobs), duration))


if __name__ == '__main__':
    arguments = docopt(__doc__)
    should_create = arguments['--create']
    index_all = arguments['--all']
    run(main, should_create, index_all)
Exemple #9
0
        die("Job ({}) does not exist.".format(job_id))

    print isinstance(job.title, unicode)

    print "You're reviewing the following listing:"
    print make_summary(job).encode('utf-8')

    action = 'publish' if not job.published else 'unpublish'
    if prompt("Do you want to {} this listing?".format(blue(action)),
              yesno=True):
        job.published = not job.published
        session.commit()

        print green('Job {}ed!'.format(action))

        if action == 'unpublish':
            return

        if prompt(blue('Do you want to send a confirmation email?'),
                  yesno=True):
            send_confirmation_email(job)
            print green('Confirmation email sent!')
    else:
        die('Bye.')


if __name__ == '__main__':
    arguments = docopt(__doc__)
    job_id = int(arguments['<job_id>'])
    run(main, job_id)
Exemple #10
0
"""
Creates a new location.

Usage:
    create_location.py <city> <country>

Options:
    <city>  The city.
    <country_code>  Alpha-3 country code.

"""
from docopt import docopt

from env import path_setup
path_setup()

from jobber.script import run
from jobber.core.models import Location


def main(city, country_code, session):
    location = Location(city=city, country_code=country_code)
    session.add(location)


if __name__ == '__main__':
    arguments = docopt(__doc__)
    city = arguments['<city>']
    country = arguments['<country>']
    run(main, city, country)