예제 #1
0
def deploy(mode, onlyUp=False):
    ADD_DEPLOY_CONFIG = ' -f docker-compose.yml.deploy -f docker-compose.yml.%s ' % mode

    def call_docker_compose_deploy(command):
        return os.system(env.docker_compose(ADD_DEPLOY_CONFIG + command))

    def call_docker_compose_deploy_new(command):
        return os.system('NEW=_new ' +
                         env.docker_compose(ADD_DEPLOY_CONFIG + command))

    if not onlyUp:
        if 0 != call_docker_compose_deploy_new(env.run(["cd %(output_path)s_new && %(prepare)s"\
                %{'prepare': (run.COMMAND_DEPENDENCES + ' && ' + run.COMMAND_PREPARE), 'output_path': VOLUME_PATH}])):
            return False
        call_docker_compose_deploy_new(env.down())
        if 0 != call_docker_compose_deploy_new(env.run(["cd .. &&\
                rm -rf %(output_path)s && mv %(output_path)s_new %(output_path)s"\
                %{'output_path': VOLUME_PATH}])):
            return False
        if 0 != call_docker_compose_deploy(env.run(["cd .. &&\
                rm -rf %(output_path)s_new"\
                %{'output_path': VOLUME_PATH}])):
            return False
        if 0 != call_docker_compose_deploy(env.run([run.COMMAND_DB_MIGRATE])):
            return False
    return 0 == call_docker_compose_deploy(env.up())
예제 #2
0
def sync(args=[]):
    if 0 != os.system(
            env.docker_compose_env(
                env.run(
                    ['%s && %s' %
                     (COMMAND_DEPENDENCES, COMMAND_DB_MIGRATE)]))):
        config_info()
예제 #3
0
def rails_new(args=[]):
    if 0 == os.system(
            env.docker_compose_env(
                env.run([
                    'gem install rails && rails new . -d postgresql --webpack=vue'
                ]))):
        print(env.line_seperator('=', 80))
        print("\n            INSTALL FINISH\n")
        config_info()
        show_hint()
예제 #4
0
bought_drugs = 0
no_interaction = 0
refused_sell = 0
skipped_line = 0

print(str(datetime.datetime.now()))

#got both
if True:
    for i in range(500):
        saved_Q_table = dict()
        #train the model
        for i in range(500):  #1000
            [x, x, saved_Q_table] = env.run(Q_table=saved_Q_table,
                                            tree=pharm_tree,
                                            render=False,
                                            learn=True,
                                            playable=False)
        #run the trained model
        [result, skipped_line_result, x] = env.run(Q_table=saved_Q_table,
                                                   tree=pharm_tree,
                                                   render=False,
                                                   learn=False,
                                                   playable=False)
        if result == 0:
            no_interaction = no_interaction + 1
        elif result == 1:
            stole_drugs = stole_drugs + 1
        elif result == 2:
            bought_drugs = bought_drugs + 1
        elif result == 3:
예제 #5
0
def migrate(args=[]):
    os.system(env.docker_compose_env(env.run(['%s' % (COMMAND_DB_MIGRATE)])))
예제 #6
0
def prepare(args=[]):
    os.system(
        env.docker_compose_env(
            env.run(['%s && %s' % (COMMAND_DEPENDENCES, COMMAND_PREPARE)],
                    run_args='--no-deps')))
예제 #7
0
def rails_reset(args=[]):
    os.system(
        env.docker_compose_env(
            env.run(['%s && %s' % (COMMAND_DROP, COMMAND_DB_SEED)])))
예제 #8
0
def rails_drop(args=[]):
    os.system(env.docker_compose_env(env.run([COMMAND_DROP])))
예제 #9
0
def rails_c(args=[]):
    os.system(env.docker_compose_env(env.run(['rails c'])))