Пример #1
0
import os

from lib import db

# Importing the files that define the request handlers is what registers the
# handlers with bottle.
from handlers import auth
from handlers import index
from handlers import samplequiz

CONFIG_FILE = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                           'app.conf')

DEFAULT_DB_FILE = '/tmp/database.sqlite'

if __name__ == '__main__':
    if os.path.exists(CONFIG_FILE):
        config = configparser.ConfigParser()
        config.read_dict({
            'db': {
                'filepath': DEFAULT_DB_FILE,
            },
        })
        config.read([CONFIG_FILE])
        filepath = config.get('db', 'filepath')
    else:
        filepath = DEFAULT_DB_FILE

    db.init(filepath)
    run(host='0.0.0.0', port=80, server='paste')
Пример #2
0

from lib.handlers import Create, Login
safety_box = tornado.web.Application([
  ("/login", Login),
  ("/create", Create),
  # ("/auth", Auth),
  ("/", IndexHandler)
])

if __name__ == '__main__':
  parser = argparse.ArgumentParser()

  parser.add_argument(
    '-p', 
    '--port', 
    metavar='port', 
    type=int,
    default=7999,
    help='listen on the specified port'
  )

  args = parser.parse_args()

  from lib import db
  db.init()

  safety_box.listen(args.port)
  print('Listening on port {port}'.format(port=args.port))
  iol = tornado.ioloop.IOLoop.instance()
  iol.start()
Пример #3
0
    app.init_logger('update_db')

    # parse command line
    parser = argparse.ArgumentParser(description='Update photo database')
    args = parser.parse_args()

    mimetypes.init()

    # add mime type for raw images
    mimetypes.add_type('image/raw', '.CR2')

    # directories
    source_dir = app.config.get('directories', 'photos')
    database_file = app.config.get('database', 'file')

    database = db.init(database_file)

    # 1. check for deleted files
    print 'Check for deleted files'

    cursor = db.fetch('SELECT id, path FROM photos')
    for row in cursor.fetchall():
        if not os.path.exists(os.path.join(source_dir, row[1])):
            db.get_conn().execute('DELETE FROM photos WHERE id = ?', row[0])
            sys.stdout.write('X')
        else:
            sys.stdout.write('.')
        sys.stdout.flush()

    print
Пример #4
0
        self.render("public/index.html")


from lib.handlers import Create, Login

safety_box = tornado.web.Application([
    ("/login", Login),
    ("/create", Create),
    # ("/auth", Auth),
    ("/", IndexHandler)
])

if __name__ == '__main__':
    parser = argparse.ArgumentParser()

    parser.add_argument('-p',
                        '--port',
                        metavar='port',
                        type=int,
                        default=7999,
                        help='listen on the specified port')

    args = parser.parse_args()

    from lib import db
    db.init()

    safety_box.listen(args.port)
    print('Listening on port {port}'.format(port=args.port))
    iol = tornado.ioloop.IOLoop.instance()
    iol.start()
Пример #5
0
VERSION = '0.5'

args = arguments.get_args()  # this function returns the args object

if not args.silent:
    banner.header(VERSION)

if args.domain == None:
    logger.red('Please supply a domain')
    quit()
else:
    domain = args.domain
    if args.name != None:
        db.db_name = args.name
    db.init()  # create the database file

interval = args.interval
counter = interval

if not args.query:
    if not args.single:
        try:
            while True:
                sleep(1)
                counter -= 1
                logger.timer('Querying in %s seconds(s)' %
                             logger.BLUE(counter))
                if counter <= 0:
                    runner.go()
                    counter = interval