Ejemplo n.º 1
0
def build():
    """Initialise and migrate database to latest version."""
    print(cyan("\nUpdating database..."))
    with settings(hide("warnings"), warn_only=True):
        if not os.path.exists(config_file_path):
            do("alembic -c %s init db/postgresql" % config_file_path)
        upgrade_db()
Ejemplo n.º 2
0
def build():
    """ Build or update the virtualenv """
    with settings(hide('stdout')):
        print(cyan('\nUpdating venv, installing packages...'))
        # remove non-virtualenv Fabric, because it causes problems
        # TODO: the logic of this will need to be re-thought
        do('sudo pip uninstall Fabric -qy', capture=True)
        do('[ -e venv ] || virtualenv venv --no-site-packages')
        # annoyingly, pip prints errors to stdout (instead of stderr), so we
        # have to check the return code and output only if there's an error.
        with settings(warn_only=True):
            # upgrade pip so we can take advantage of fancy new features
            pupgrade = do('venv/bin/pip install pip --upgrade')
            if pupgrade.failed:
                print(red(pupgrade))
                abort("pip upgrade unsuccessful %i" % pupgrade.return_code)
            # http://www.pip-installer.org/en/latest/cookbook.html#fast-local-installs
            do('mkdir -p pyarchives', capture=True)
            do('venv/bin/pip install -v --download pyarchives -r requirements.txt --upgrade')
            # if webassets==dev exists, rename it
            # if os.path.exists("pyarchives/master"):
                # os.rename("pyarchives/master", "pyarchives/webassets-dev.tar.gz")
            pip = do(
                'venv/bin/pip install --no-index --find-links=file://vagrant/pyarchives -r requirements.txt --upgrade',
                capture=True)
        if pip.failed:
            print(red(pip))
            abort("pip exited with return code %i" % pip.return_code)
Ejemplo n.º 3
0
def build():
    """Initialise and migrate database to latest version."""
    print(cyan('\nUpdating database...'))
    with settings(hide('warnings'), warn_only=True):
        if not os.path.exists(config_file_path):
            do('alembic -c %s init db/postgresql' % config_file_path)
            do('mkdir db/postgresql/versions')
        upgrade_db()
Ejemplo n.º 4
0
def alert():

    global messages
    while True:
        curr_len = len(messages)
        cnt = 0
        if config.debug:
            logging.debug('alerting metrics...(%s messages)' % curr_len)
        while cnt < curr_len:
            do(*messages.popleft())
            cnt += 1
        time.sleep(10)
def build():
    """Build or update the virtualenv."""
    with settings(hide('stdout')):
        print(cyan('\nUpdating venv, installing packages...'))
        do('[ -e venv ] || virtualenv venv --no-site-packages')
        # annoyingly, pip prints errors to stdout (instead of stderr), so we
        # have to check the return code and output only if there's an error.
        with settings(warn_only=True):
            pip = do('venv/bin/pip install -r requirements.txt', capture=True)
        if pip.failed:
            print(red(pip))
            abort("pip exited with return code %i" % pip.return_code)
Ejemplo n.º 6
0
def build():
    """Build or update the virtualenv."""
    with settings(hide('stdout')):
        print(cyan('\nUpdating venv, installing packages...'))
        do('[ -e venv ] || virtualenv venv --no-site-packages')
        # annoyingly, pip prints errors to stdout (instead of stderr), so we
        # have to check the return code and output only if there's an error.
        with settings(warn_only=True):
            pip = do('venv/bin/pip install -r requirements.txt', capture=True)
        if pip.failed:
            print(red(pip))
            abort("pip exited with return code %i" % pip.return_code)
Ejemplo n.º 7
0
def build():
    """
    Build or update the virtualenv.
    """
    with settings(hide('stdout')):
        
        print(cyan('\nFABRIC: Updating venv, installing packages ...'))
        
        do('[ -e venv ] || virtualenv venv --no-site-packages') 


        with settings(warn_only=True):
            pip = do('venv/bin/pip install -r requirements.txt', capture=True)

        if pip.failed:
            print(red(pip))
            abort("pip exited with return code %i" % pip.return_code)
Ejemplo n.º 8
0
def build():
    """ Build or update the virtualenv """
    with settings(hide("stdout")):
        print(cyan("\nUpdating venv, installing packages..."))
        # remove non-virtualenv Fabric, because it causes problems
        # TODO: the logic of this will need to be re-thought
        do("sudo pip uninstall Fabric -qy", capture=True)
        do("[ -e venv ] || virtualenv venv --no-site-packages")
        # annoyingly, pip prints errors to stdout (instead of stderr), so we
        # have to check the return code and output only if there's an error.
        with settings(warn_only=True):
            # upgrade pip so we can take advantage of fancy new features
            pupgrade = do("venv/bin/pip install pip --upgrade")
            if pupgrade.failed:
                print(red(pupgrade))
                abort("pip upgrade unsuccessful %i" % pupgrade.return_code)
            # http://www.pip-installer.org/en/latest/cookbook.html#fast-local-installs
            do("mkdir -p pyarchives", capture=True)
            do("venv/bin/pip install -v -r requirements.txt --upgrade")
Ejemplo n.º 9
0
def main():
    start, climb, switch = get_screen_information()
    model = ActionClassifier()
    model.cuda()
    model.train()

    optimizer = torch.optim.AdamW(model.parameters())
    criterion = torch.nn.CrossEntropyLoss()
    while True:
        x = torch.tensor(do(switch))
        prediction = model(x)
        loss = criterion
        optimizer.zero_grad()
        loss.backward()
        optimizer.step()
Ejemplo n.º 10
0
    def fetch_accepted_problems(self):
        response = self.session.get("https://leetcode.com/api/problems/all/")
        all_problems = json.loads(response.content.decode('utf-8'))
        # filter AC problems
        counter = 0
        for item in all_problems['stat_status_pairs']:
            if item['status'] == 'ac':
                id, slug = destructure(item['stat'], "question_id", "question__title_slug")
                # only update problem if not exists
                if Problem.get_or_none(Problem.id == id) is None:
                    counter += 1
                    # fetch problem
                    do(self.fetch_problem, args=[slug, True])
                    # fetch solution
                    do(self.fetch_solution, args=[slug])

                # always try to update submission
                do(self.fetch_submission, args=[slug])
        print(f"🤖 Updated {counter} problems")
def run():
    """Start app in debug mode (for development)."""
    do('export FLASK_CONFIG=$PWD/app/config/dev.cfg && venv/bin/python app/run.py')
Ejemplo n.º 12
0
def run():
    """Start app in debug mode (for development)."""
    do('export FLASK_CONFIG=$PWD/app/config/dev.cfg && chmod 755 app/run.sh && cd ./app && ./run.sh')
Ejemplo n.º 13
0
def check():
    """Syntax check on Puppet config."""
    print(cyan('\nChecking puppet syntax...'))
    do('find puppet -type f -name \'*.pp\' |xargs puppet parser validate')
Ejemplo n.º 14
0
def apply():
    """Apply Puppet manifest."""
    print(cyan('\nApplying puppet manifest...'))
    do('sudo puppet apply --modulepath=puppet/modules/ puppet/manifests/standalone.pp' % env)
def check():
    """Syntax check on Puppet config."""
    print(cyan("\nChecking puppet syntax..."))
    do("find puppet -type f -name '*.pp' |xargs puppet parser validate")
Ejemplo n.º 16
0
def check():
    """ Syntax check on Puppet config."""

    print( cyan( '\nChecking puppet syntax...') )
    do('find puppet -type f -name \'*.pp\' | xargs puppet parser validate ')
Ejemplo n.º 17
0
def build():
    """Initialise and migrate database to latest version."""
    print(cyan('\nUpdating database...'))
    with settings(hide('warnings'), warn_only=True):
        do('venv/bin/alembic -c %s init db/postgresql' % config_file_path)
Ejemplo n.º 18
0
def run():
    """Start app in debug mode (for development)."""
    do('export FLASK_CONFIG=$PWD/app/config/dev.cfg && venv/bin/python app/run.py'
       )
def build():
    """Initialise and migrate database to latest version."""
    print(cyan('\nUpdating database...'))
    with settings(hide('warnings'), warn_only=True):
        do('venv/bin/alembic -c %s init db/postgresql' % config_file_path)
def apply():
    """Apply Puppet manifest."""
    print(cyan("\nApplying puppet manifest..."))
    do("sudo puppet apply --modulepath=puppet/modules/ puppet/manifests/standalone.pp" % env)
Ejemplo n.º 21
0
def apply():
    """ Apply Puppet manifest. """
    print(cyan('\nAppying puppet manifeset ...') )
    do('sudo puppet apply --modulepath=puppet/modules puppet/manifests/default.pp' %env)