Пример #1
0
            utils.add_file_handler_to_logger(app.logger, constants.FLASK_LOG_FILE_PATH)
            app.secret_key = file(constants.SECRET_KEY_FILE_PATH, 'r').read()
            app.run(host='0.0.0.0', port=constants.PORT, threaded=True)

            background_crawl.stop()

        elif cmd == 'setup':
            raw_input('press any key to continue...')

            os.makedirs(constants.BOOK_IMGS_PATH)
            os.makedirs(constants.BOOK_THUMBNAILS_PATH)
            os.makedirs(constants.CRAWLER_SRC_PATH)
            os.makedirs(constants.LOG_PATH)
            db.create_all()

            file(constants.SECRET_KEY_FILE_PATH, 'w').write(utils.gen_random_string())

        elif cmd == 'cleanup':
            raw_input('press any key to continue...')

            db.drop_all()
            shutil.rmtree(constants.DATA_PATH)
            shutil.rmtree(constants.LOG_PATH)

        elif cmd == 'backup':
            shutil.make_archive(datetime.datetime.now().strftime("backup_%Y%m%d_%H%M%S"), 'zip', '.', constants.WEBSITE_DATA_PATH)

        elif cmd == 'add_account':
            account = Account(sys.argv[2], sys.argv[3], getpass.getpass())
            db.session.add(account)
            db.session.commit()
Пример #2
0
            app.secret_key = file(constants.SECRET_KEY_FILE_PATH, 'r').read()
            app.run(host='0.0.0.0', port=constants.PORT, threaded=True)

            background_crawl.stop()

        elif cmd == 'setup':
            raw_input('press any key to continue...')

            os.makedirs(constants.BOOK_IMGS_PATH)
            os.makedirs(constants.BOOK_THUMBNAILS_PATH)
            os.makedirs(constants.CRAWLER_SRC_PATH)
            os.makedirs(constants.LOG_PATH)
            db.create_all()

            file(constants.SECRET_KEY_FILE_PATH,
                 'w').write(utils.gen_random_string())

        elif cmd == 'cleanup':
            raw_input('press any key to continue...')

            db.drop_all()
            shutil.rmtree(constants.DATA_PATH)
            shutil.rmtree(constants.LOG_PATH)

        elif cmd == 'backup':
            shutil.make_archive(
                datetime.datetime.now().strftime("backup_%Y%m%d_%H%M%S"),
                'zip', '.', constants.WEBSITE_DATA_PATH)

        elif cmd == 'add_account':
            account = Account(sys.argv[2], sys.argv[3], getpass.getpass())
Пример #3
0
 def set_password(self, password):
     self.salt = utils.gen_random_string()
     self.password_hash = hashlib.sha1(self.salt + ',' + password).hexdigest()