# Path: scrapebot/configuration.py
# class Configuration:
#     def __init__(self, ini_file='config.ini'):
#         self.config = configparser.ConfigParser()
#         self.config.read(ini_file)
#         self.__dict = {}
# 
#     def get_db_engine_string(self):
#         """
#         Generates the mysql connection string, ready for SQLAlchemy
#         :return:
#         """
#         return self.config.get('Database', 'dialect', fallback='mysql+pymysql') + \
#             '://' + self.get('Database', 'user', fallback='root') + \
#             ':' + self.get('Database', 'password', fallback='password') + \
#             '@' + self.get('Database', 'host', fallback='localhost') + \
#             '/' + self.get('Database', 'database', fallback='scrapebot')
# 
#     def add_section(self, section):
#         if section not in self.config:
#             self.config[section] = {}
# 
#     def add_value(self, section, name, value):
#         self.add_section(section)
#         self.config[section][name] = str(value)
# 
#     def write(self):
#         try:
#             with open('config.ini', 'w') as configfile:
#                 self.config.write(configfile)
#                 return True
#         except:
#             return False
# 
#     def get(self, section, key, fallback=None):
#         if section not in self.__dict:
#             self.__dict[section] = {}
#         key = key.lower()
#         if key not in self.__dict[section]:
#             self.__dict[section][key] = self.config.get(section, key, fallback=fallback)
#         return self.__dict[section][key]
# 
# Path: scrapebot/database.py
# class User(UserMixin, base):
# class UserInstancePrivilege(base):
# class UserRecipePrivilege(base):
# class Instance(base):
# class RecipeOrder(base):
# class Recipe(base):
# class RecipeStep(base):
# class RecipeStepItem(base):
# class RunStatusEnum(enum.Enum):
# class Run(base):
# class LogTypeEnum(enum.Enum):
# class Log(base):
# class Data(base):
#     def __repr__(self):
#     def create_password(self):
#     def check_password(self, password):
#     def get_id(self):
#     def jsonify(self):
#     def __repr__(self):
#     def jsonify(self):
#     def __repr__(self):
#     def jsonify(self):
#     def __repr__(self):
#     def get_active_recipes(self):
#     def is_visible_to_user(self, user):
#     def is_editable_by_user(self, user):
#     def runs_recipe(self, recipe, only_consider_active=True):
#     def get_latest_run(self, recipe=None, only_include_successful_runs=False):
#     def get_latest_runs(self, n=10, recipe=None, only_include_successful_runs=False):
#     def jsonify(self, include_latest_run=False, recipe=None):
#     def __repr__(self):
#     def jsonify(self):
#     def __repr__(self):
#     def get_active_steps(self):
#     def get_average_runtime(self):
#     def is_visible_to_user(self, user):
#     def is_editable_by_user(self, user):
#     def runs_on_instance(self, instance):
#     def get_latest_run(self, instance=None, only_include_successful_runs=False):
#     def get_latest_runs(self, n=10, instance=None, only_include_successful_runs=False):
#     def jsonify(self, include_latest_run=False, instance=None):
#     def __repr__(self):
#     def find_random_item(self):
#     def run(self, config, run, prior_step=None):
#     def jsonify(self):
#     def __repr__(self):
#     def jsonify(self):
#     def __repr__(self):
#     def get_recipe_order(self):
#     def process(self, config, step, prior_step=None):
#     def end_session(self):
#     def jsonify(self, include_log=False, include_data=False):
#     def __repr__(self):
#     def jsonify(self):
#     def __repr__(self):
#     def jsonify(self):


import platform
import os
import getpass
import sys
import traceback
from crontab import CronTab
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker, scoped_session
from scrapebot.configuration import Configuration
from scrapebot.database import base, User, Instance
    try:
        engine = get_engine(config)
        base.metadata.create_all(engine)
        db = get_db(engine)
    except:
        print('- uh, there is a problem with connecting to your database ...')
        exit(3)
    print('- read tables: ' + ', '.join(base.metadata.tables.keys()))
    users = db.query(User).order_by(User.created).all()
    user = None
    if len(users) == 0:
        print('- the database currently does not contain any users, so we will create a default one')
        username = read_forcefully('- what name should this user listen to', 'root')
        email = read_forcefully('- and what is this user\'s email address')
        user = create_user(db, username, email)
    else:
        print('- one or many users available')
        user = db.query(User).filter(User.name == 'root').first()
        if user is None:
            user = users[0]

    while read_bool_forcefully('Do you want to create another user'):
        username = read_forcefully('- what name should this user listen to')
        email = read_forcefully('- and what is this user\'s email address')
        create_user(db, username, email)

    print('Checking this instance')
    this_instance = db.query(Instance).filter(Instance.name == instance_name)
    print('- it is called ' + instance_name)
    if this_instance.count() == 0:

# Path: scrapebot/configuration.py
# class Configuration:
#     def __init__(self, ini_file='config.ini'):
#         self.config = configparser.ConfigParser()
#         self.config.read(ini_file)
#         self.__dict = {}
# 
#     def get_db_engine_string(self):
#         """
#         Generates the mysql connection string, ready for SQLAlchemy
#         :return:
#         """
#         return self.config.get('Database', 'dialect', fallback='mysql+pymysql') + \
#             '://' + self.get('Database', 'user', fallback='root') + \
#             ':' + self.get('Database', 'password', fallback='password') + \
#             '@' + self.get('Database', 'host', fallback='localhost') + \
#             '/' + self.get('Database', 'database', fallback='scrapebot')
# 
#     def add_section(self, section):
#         if section not in self.config:
#             self.config[section] = {}
# 
#     def add_value(self, section, name, value):
#         self.add_section(section)
#         self.config[section][name] = str(value)
# 
#     def write(self):
#         try:
#             with open('config.ini', 'w') as configfile:
#                 self.config.write(configfile)
#                 return True
#         except:
#             return False
# 
#     def get(self, section, key, fallback=None):
#         if section not in self.__dict:
#             self.__dict[section] = {}
#         key = key.lower()
#         if key not in self.__dict[section]:
#             self.__dict[section][key] = self.config.get(section, key, fallback=fallback)
#         return self.__dict[section][key]
# 
# Path: scrapebot/database.py
# class User(UserMixin, base):
# class UserInstancePrivilege(base):
# class UserRecipePrivilege(base):
# class Instance(base):
# class RecipeOrder(base):
# class Recipe(base):
# class RecipeStep(base):
# class RecipeStepItem(base):
# class RunStatusEnum(enum.Enum):
# class Run(base):
# class LogTypeEnum(enum.Enum):
# class Log(base):
# class Data(base):
#     def __repr__(self):
#     def create_password(self):
#     def check_password(self, password):
#     def get_id(self):
#     def jsonify(self):
#     def __repr__(self):
#     def jsonify(self):
#     def __repr__(self):
#     def jsonify(self):
#     def __repr__(self):
#     def get_active_recipes(self):
#     def is_visible_to_user(self, user):
#     def is_editable_by_user(self, user):
#     def runs_recipe(self, recipe, only_consider_active=True):
#     def get_latest_run(self, recipe=None, only_include_successful_runs=False):
#     def get_latest_runs(self, n=10, recipe=None, only_include_successful_runs=False):
#     def jsonify(self, include_latest_run=False, recipe=None):
#     def __repr__(self):
#     def jsonify(self):
#     def __repr__(self):
#     def get_active_steps(self):
#     def get_average_runtime(self):
#     def is_visible_to_user(self, user):
#     def is_editable_by_user(self, user):
#     def runs_on_instance(self, instance):
#     def get_latest_run(self, instance=None, only_include_successful_runs=False):
#     def get_latest_runs(self, n=10, instance=None, only_include_successful_runs=False):
#     def jsonify(self, include_latest_run=False, instance=None):
#     def __repr__(self):
#     def find_random_item(self):
#     def run(self, config, run, prior_step=None):
#     def jsonify(self):
#     def __repr__(self):
#     def jsonify(self):
#     def __repr__(self):
#     def get_recipe_order(self):
#     def process(self, config, step, prior_step=None):
#     def end_session(self):
#     def jsonify(self, include_log=False, include_data=False):
#     def __repr__(self):
#     def jsonify(self):
#     def __repr__(self):
#     def jsonify(self):


# Path: setup.py
import platform
import os
import getpass
import sys
import traceback
from crontab import CronTab
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker, scoped_session
from scrapebot.configuration import Configuration
from scrapebot.database import base, User, Instance

    try:
        engine = get_engine(config)
        base.metadata.create_all(engine)
        db = get_db(engine)
    except:
        print('- uh, there is a problem with connecting to your database ...')
        exit(3)
    print('- read tables: ' + ', '.join(base.metadata.tables.keys()))
    users = db.query(User).order_by(User.created).all()
    user = None
    if len(users) == 0:
        print('- the database currently does not contain any users, so we will create a default one')
        username = read_forcefully('- what name should this user listen to', 'root')
        email = read_forcefully('- and what is this user\'s email address')
        user = create_user(db, username, email)
    else:
        print('- one or many users available')
        user = db.query(User).filter(User.name == 'root').first()
        if user is None:
            user = users[0]

    while read_bool_forcefully('Do you want to create another user'):
        username = read_forcefully('- what name should this user listen to')
        email = read_forcefully('- and what is this user\'s email address')
        create_user(db, username, email)

    print('Checking this instance')
    this_instance = db.query(Instance).filter(Instance.name == instance_name)
    print('- it is called ' + instance_name)
    if this_instance.count() == 0:

        db.add(Instance(name=instance_name, owner_uid=user.uid))