예제 #1
0
파일: cli.py 프로젝트: webmasteraxe/Feeder
def sync(args):
    ensure_config(args.config)

    from feeder import read_config

    # Read config and configure database path
    read_config(args.config)

    # Only import after config reading
    ensure_db_exists()
    from feeder import sync
    print("Caching feeds...")
    sync.cache_all_feeds()
    print("Caching complete")
예제 #2
0
파일: cli.py 프로젝트: webmasteraxe/Feeder
def add_user(args):
    config = args.config
    username = args.username
    password = args.password
    remove = args.remove

    ensure_config(config)
    from feeder import read_config

    read_config(config)
    ensure_db_exists()

    from hashlib import sha1
    from werkzeug.security import generate_password_hash
    from feeder.database import db
    from feeder.models import get_user
    from feeder.constants import __ANDROID_SALT__

    if remove:
        user = get_user(username, allow_creation=False)
        if user:
            db.session.delete(user)
            db.session.commit()
            print("Removed user", username)
        else:
            print("No such user. Nothing to do.")
    else:
        if not password:
            from getpass import getpass
            password = getpass()

        # Generate a password hash
        # Make sure to use a byte string
        try:
            bpassword = password.encode('utf-8')
        except AttributeError:
            # Already bytestring
            bpassword = password

        # Then add the salt used by the android client
        androidpassword = sha1(__ANDROID_SALT__ + bpassword)\
            .hexdigest().lower()

        # And finally salt it for real
        user = get_user(username, allow_creation=True)
        user.passwordhash = generate_password_hash(androidpassword)

        db.session.add(user)
        db.session.commit()
        print("Updated user", username)
예제 #3
0
파일: cli.py 프로젝트: webmasteraxe/Feeder
def server(args):
    ensure_config(args.config)
    from feeder import read_config

    # Put config/arguments here
    kw = {}

    for k, v in read_config(args.config).items():
        if k in 'debug,host,port'.split(','):
            # Lowercase as kwargs in run
            kw[k] = v

    if args.debug:
        kw['debug'] = True

    if args.host:
        kw['host'] = args.host

    if args.port:
        kw['port'] = args.port

    ensure_db_exists()
    # This configures rest api to run. Do it AFTER config loading
    #import feeder.rest
    from feeder.rest import app
    app.run(**kw)
예제 #4
0
'''
Synchronizes all known RSS feeds. This should probably be
run as a cronscript:

Run:
    crontab -e

Then enter a line like this (syncs every 10 minutes):

    */10 * * * * /path/to/python /path/to/feeder/flaskapp/runsync.py [-c configfile]
'''
from feeder import read_config
import sys

if __name__ == '__main__':
    args = sys.argv[1:]
    if '-c' in args:
        i = args.index('-c')
        configfile = args[i + 1]
    else:
        configfile = 'config.yaml'

    # Read config and configure database path
    read_config(configfile)

    # ONly import after config reading
    from feeder import sync
    print("Caching feeds...")
    sync.cache_all_feeds()
    print("Caching complete")
예제 #5
0
파일: createdb.py 프로젝트: ccciit/Feeder
# -*- coding: utf-8 -*-
'''
Usage
    python createdb.py -c /path/to/config.yaml

Creates the database whose location is specified by the config file.
See config-sample.yaml for details.
'''
import sys
from feeder import read_config


if __name__ == '__main__':
    if len(sys.argv) != 3 or sys.argv[1] != '-c':
        exit(__doc__)

    configfile = sys.argv[2]
    read_config(configfile)

    import feeder.rest
    from feeder.database import db
    db.create_all()

    exit("Database created successfully")
예제 #6
0
        print("Database was created successfully")


if __name__ == '__main__':
    args = sys.argv[1:]

    # Put config/arguments here
    kw = {}

    if '-c' in args:
        i = args.index('-c')
        configfile = args[i + 1]
    else:
        configfile = 'config.yaml'

    for k, v in read_config(configfile).items():
        if k in 'debug,host,port'.split(','):
            # Lowercase as kwargs in run
            kw[k] = v

    # If arguments are specified, they override config values
    if '--help' in args:
        exit(__doc__)
    if '-d' in args:
        kw['debug'] = True
    if '-h' in args:
        i = args.index('-h')
        kw['host'] = args[i + 1]
    if '-p' in args:
        i = args.index('-p')
        kw['port'] = int(args[i + 1])