Пример #1
0
def synth_update(indiv=False):
    '''Get latest batch of DOIs from NeuroSynth, convert DOIs
    to PMIDs, and add missing articles to NeuroTrends.

    '''

    # Get DOIs from NeuroSynth
    synth_dois = synth_load.extract_neurosynth_dois()

    # Get IDs from NeuroTrends
    trend_ids = session.query(Article.doi, Article.pmid).all()
    trend_dois = [id[0] for id in trend_ids if id[0] is not None]
    trend_pmids = [id[1] for id in trend_ids]

    # Get set difference
    dois_to_add = list(set(synth_dois) - set(trend_dois))

    print 'Adding %s articles...' % (len(dois_to_add))

    # Initialize PMIDs to add
    if not indiv:
        pmids_to_add = []

    # Loop over DOIs
    for doi in dois_to_add:

        # Initialize PMID to missing
        pmid = ''

        # Attempt to get PMID from CrossRef API
        xref_info = pmid_doi.pmid_doi({'doi': doi})
        if 'pmid' in xref_info:
            pmid = xref_info['pmid']
            print 'Found PMID using CrossRef'
        else:
            # Attempt to get PMID from PubMed API
            pubmed_info = pubsearch.artsearch(doi, retmax=2)
            if len(pubmed_info) == 1:
                pmid = pubmed_info[0]['pmid']
                print 'Found PMID using PubMed'

        # Quit if PMID missing
        if not pmid:
            continue

        # Quit if PMID in NeuroTrends
        if pmid in trend_pmids:
            continue

        # Update database OR add to list
        if indiv:
            main.update([str(pmid)])
        else:
            pmids_to_add.append(str(pmid))

    # Add PMIDs to NeuroTrends
    if not indiv:
        main.update(pmids_to_add)
Пример #2
0
def synth_update(indiv=False):
    """Get latest batch of DOIs from NeuroSynth, convert DOIs
    to PMIDs, and add missing articles to NeuroTrends.

    """

    # Get DOIs from NeuroSynth
    synth_dois = synth_load.extract_neurosynth_dois()

    # Get IDs from NeuroTrends
    trend_ids = session.query(Article.doi, Article.pmid).all()
    trend_dois = [id[0] for id in trend_ids if id[0] is not None]
    trend_pmids = [id[1] for id in trend_ids]

    # Get set difference
    dois_to_add = list(set(synth_dois) - set(trend_dois))

    print "Adding %s articles..." % (len(dois_to_add))

    # Initialize PMIDs to add
    if not indiv:
        pmids_to_add = []

    # Loop over DOIs
    for doi in dois_to_add:

        # Initialize PMID to missing
        pmid = ""

        # Attempt to get PMID from CrossRef API
        xref_info = pmid_doi.pmid_doi({"doi": doi})
        if "pmid" in xref_info:
            pmid = xref_info["pmid"]
            print "Found PMID using CrossRef"
        else:
            # Attempt to get PMID from PubMed API
            pubmed_info = pubsearch.artsearch(doi, retmax=2)
            if len(pubmed_info) == 1:
                pmid = pubmed_info[0]["pmid"]
                print "Found PMID using PubMed"

        # Quit if PMID missing
        if not pmid:
            continue

        # Quit if PMID in NeuroTrends
        if pmid in trend_pmids:
            continue

        # Update database OR add to list
        if indiv:
            main.update([str(pmid)])
        else:
            pmids_to_add.append(str(pmid))

    # Add PMIDs to NeuroTrends
    if not indiv:
        main.update(pmids_to_add)
Пример #3
0
def test_initial():
    config = {
        'ginger': {},
        'cucumber': {},
    }

    main.update(config, 'flask', 3)
    main.update(config, 'django', 3)

    assert sum(config['ginger'].values()) == sum(config['cucumber'].values())
    assert sum(sum(x.values()) for x in config.values()) == 3 + 3
Пример #4
0
def download_from_disk():
    if os.path.exists('logs.txt'):
        os.remove('logs.txt')
    if os.path.exists('users_db.txt'):
        os.remove('users_db.txt')
    if os.path.exists('Raspisanie.xlsx'):
        os.remove('Raspisanie.xlsx')

    y.download('/bot/logs.txt', 'logs.txt')
    y.download('/bot/users_db.txt', 'users_db.txt')
    y.download('/bot/Raspisanie.xlsx', 'Raspisanie.xlsx')
    update()
Пример #5
0
def test_custom():
    config = {
        'AEO#%$&#': {
            'jango': 2,
            'Flask': 3,
        },
        '%$#$': {
            'flask': 1,
        },
    }
    main.update(config, 'flask', 5)
    main.update(config, 'DjaNgo', 3)
    assert sum(config['%$#$'].values()) == sum(config['AEO#%$&#'].values())
    assert config['AEO#%$&#'].get('flask') != config['AEO#%$&#'].get('Flask')
Пример #6
0
def test_predictable_config():
    permutations = []
    services = [('flask', 7), ('django', 13), ('pylons', 17)]

    for permutation in itertools.permutations(services):
        config = {
            'ginger': {},
            'cucumber': {},
        }
        for svc, num in permutation:
            main.update(config, svc, num)
        assert sum(sum(x.values()) for x in config.values()) == 7 + 13 + 17
        permutations.append(config)

    assert all(p == permutations[0] for p in permutations[1:])
Пример #7
0
def test_update_param(name, amount, expected):
    config = {
        'huston': {
            'django': 5,
            'flask': 3,
        },
        'miami': {
            'flask': 11,
        },
        'orlando': {
            'flask': 11,
        },
    }

    main.update(config, name, amount)
    print(config)
    assert {k: sum(v.values()) for k, v in config.items()} == expected
Пример #8
0
def updateScene(_=None):
    """
    updateScene()

    Fonction de mise à jour appelée périodiquement par GLUT.
    Wrapper se contentant d'appeler main.update()
    """

    glutTimerFunc(DELAY, updateScene, 0)

    # Calcul du temps écoulé
    global _last_frame
    now = time.time()
    delta = now - _last_frame
    _last_frame = now

    main.update(delta)
    glutPostRedisplay()  # Demande le réaffichage
Пример #9
0
def download():
    site = requests.get("https://www.mirea.ru/schedule/")
    soup = bs4.BeautifulSoup(site.text, "html.parser")
    rasp = soup.find_all('div', class_='uk-width-1-2 uk-width-auto@s')
    for line in rasp:
        if str(line).find('КБиСП') != -1 and str(line).find('2 курс') != -1 and str(line).find('магистр') == -1 and \
                str(line).find('экз') == -1 and str(line).find('зач') == -1:
            pos_href = str(line).find('http')
            pos_target = str(line).find('target')
            link = str(line)[pos_href:pos_target - 2]
            #r = requests.head(link, allow_redirects=True, auth=('user', 'pass'))
            #site1 = 'http://webservices.mirea.ru/upload/iblock/862/КБиСП 2 курс 1 сем.xlsx'
            filename = wget.download(link)
            if os.path.exists('./Raspisanie.xlsx'):
                os.remove('Raspisanie.xlsx')
            if os.path.exists('./Rasp.txt'):
                os.remove('./Rasp.txt')
            os.rename(filename, 'Raspisanie.xlsx')
            # f = open('aaaa.txt', 'w', encoding='utf8', errors='ignore')
            update()
Пример #10
0
def test_equality():
    config = {
        'ginger': {
            'django': 2,
            'flask': 3,
        },
        'cucumber': {
            'flask': 1,
        },
    }

    main.update(config, 'pylons', 0)
    assert config == {
        'ginger': {
            'django': 2,
            'flask': 3,
        },
        'cucumber': {
            'flask': 1,
        },
    }
Пример #11
0
def test_update():
    config = {
        'ginger': {
            'django': 2,
            'flask': 3,
        },
        'cucumber': {
            'flask': 1,
        },
    }

    main.update(config, 'pylons', 7)
    assert config == {
        'ginger': {
            'django': 2,
            'flask': 3,
            'pylons': 1,
        },
        'cucumber': {
            'flask': 1,
            'pylons': 6,
        },
    }
Пример #12
0
def test_update():
    config = {
        'ginger': {
            'django': 2,
            'flask': 3,
        },
        'cucumber': {
            'flask': 1,
        },
    }

    main.update(config, 'pylons', 7)
    # Пришлось немного изменить тест, ведь при таких
    #  исходных данных оба результата одинаково
    #  удовлетворяют условию
    res = [{
        'ginger': {
            'django': 2,
            'flask': 3,
            'pylons': 1,
        },
        'cucumber': {
            'flask': 1,
            'pylons': 6,
        },
    }, {
        'ginger': {
            'django': 2,
            'flask': 3,
            'pylons': 2,
        },
        'cucumber': {
            'flask': 1,
            'pylons': 5,
        },
    }]
    assert config in res
Пример #13
0
def test_update_2():
    config = {
        'ginger': {
            'django': 5,
            'flask': 3,
        },
        'cucumber': {
            'flask': 4,
        },
        'nginx': {
            'ruby': 2,
        },
        'gunicorn': {
            'tornado': 2,
        },
    }

    main.update(config, 'pylons', 2)

    assert config == {
        'ginger': {
            'django': 5,
            'flask': 3,
        },
        'cucumber': {
            'flask': 4,
        },
        'nginx': {
            'ruby': 2,
            'pylons': 1
        },
        'gunicorn': {
            'tornado': 2,
            'pylons': 1
        },
    }
Пример #14
0
    def updatebt():
        userval = int(userv.get())
        passval = int(passv.get())
        generatorval = int(generatorv.get())
        site = str(sitee.get()).lower()

        if userval == 1 and passval == 0:
            user = str(usere.get())
            passw = None
            main.update(site, user, passw)
            messagebox.showinfo("Success", "Username updated")
            winu.destroy()

        elif userval == 0 and passval == 1:
            user = None
            passw = 0
            if generatorval == 1:
                passw = main.pwgenerator()
            elif generatorval == 2:
                passw = passe.get()
            main.update(site, user, passw)
            if generatorval == 1:
                messagebox.showinfo("Success", "Password updated\nYour new password is: "+passw)
            elif generatorval == 2:
                messagebox.showinfo("Success", "Password updated")
            winu.destroy()

        elif userval == 1 and passval == 1:
            user = str(usere.get())
            passw = 0
            if generatorval == 1:
                passw = main.pwgenerator()
            elif generatorval == 2:
                passw = passe.get()
            main.update(site, user, passw)
            if generatorval == 1:
                messagebox.showinfo("Success", "Password updated\nYour new password is: " + passw)
            elif generatorval == 2:
                messagebox.showinfo("Success", "Password updated")
            winu.destroy()

        elif userval == 0 and passval == 0:
            messagebox.showinfo("Error", "Please check a box")
Пример #15
0
def update_locacao(id_locacao, filmes_id, usuarios_id):
    update("locacoes", "id", id_locacao, ["filmes_id", "usuarios_id"], [filmes_id, usuarios_id])
Пример #16
0
def update_filme(id_filme,titulo, ano, classificacao, preco, diretores_id, generos_id):
    update("filmes", "id", id_filme, ["titulo", "ano", "classificacao", "preco", "diretores_id", "generos_id"], [titulo, ano, classificacao, preco, diretores_id, generos_id])
Пример #17
0
def update_diretor(id_diretor, nome_completo):
    update("diretores", "id", id_diretor, ["nome_completo"], [nome_completo])
Пример #18
0
def update_genero(id_genero, nome):
    update("generos", "id", id_genero, ["nome"], [nome])
Пример #19
0
def update_usuario(id_usuario, nome_completo, CPF):
    update("usuarios", "id", id_usuario, ["nome_completo", "CPF"], [nome_completo, CPF])
def delete_locacao(id):
    delete("locacoes", "id", id)


# tabela pagamentos


def insert_pagamentos(id, status, cod_pagamento, valor, data, locação_id):
    return insert("pagamento"["id", "status", "cod pagamento", "valor", "data", "locação_id "])


def update_pagamento(id, status, locação_id" cod_pagamento, valor, data, locação_id):


update("pagamento", "id", "status", " cod_pagamento", "valor", "data"[id, status, cod_pagamento, valor, data])


def delete_pagamento(id, status, cod_pagamento, valor, data, locação_id):
    delete("pagamento", [id, " status", "locação_id", "cod_pagamento", "valor", " data", "locação_id"], id, status,
           locação_id, cod_pagamento, valor, data, locação_id)


def select_pagamento(valor, data):
    return_select_like("pagamento", "valor", "data", [valor, data])



# tabela Usuario

def insert_usuario(id, nome_completo, cpf):
Пример #21
0
def alter_movie(id_movie, titulo): #rodando
    update("filmes", "id", id_movie, [titulo,])
Пример #22
0
def test_reconfiguration():
    data = {'ginger': {'flask': 6}, 'cucumber': {'django': 1}}

    actual = main.update(data, 'aiohttp', 1)
    print(actual)
Пример #23
0
 def funcUpdateBtn(self):
     boole = main.update()
     if (boole):
         tkinter.messagebox.showinfo(message='Updated successfully!')
Пример #24
0
 def update_display(self, swap1=None, swap2=None):
     import main
     main.update(self, swap1, swap2)
Пример #25
0
def alter_payment(id, tipo, status, codigo_pagamento, valor, data, locacoes_id):
    update("pagamentos", "id", id, ["tipo", "status", "codigo_pagamento", "valor", "data", "locacoes_id"],
           [tipo, status, codigo_pagamento, valor, data, locacoes_id,])
Пример #26
0
def deploy():
    main.update()
    nginx.restart_app()
Пример #27
0
def alter_user(id_user, nome_completo): #rodando
    update("usuarios", "id", id_user, ["nome_completo"], [nome_completo,])
Пример #28
0
 def run(self):
     if self.name == 1:
         main.update()
     if self.name == 2:
         sudoku.solve()
Пример #29
0
def update_estado(id, sigla, nome):
    update("estados", "id", id, ["sigla", "nome"], [sigla, nome])
Пример #30
0
def alter_director(id_diretor, nome_completo):
    update("diretores", "id", id_diretor, ["nome_completo"], [nome_completo,])
Пример #31
0
def alter_genre(id_genre, nome): #rodando
    update("generos", "id", id_genre, ["nome"], [nome,])
Пример #32
0
def alter_rent(id, data_inicio, data_fim, filmes_id, id_usuario):
    update("locacoes", "id", id, ["id", "data_inicio", "data_fim", "filmes_id", "id_usuario"],
           [id, data_inicio, data_fim, filmes_id, id_usuario,])
Пример #33
0
async def start(ws):
    """Lance le bot sur l'adresse Web Socket donnée."""
    global last_sequence  # global est nécessaire pour modifier la variable
    with aiohttp.ClientSession() as session:
        async with session.ws_connect(f"{ws}?v=5&encoding=json") as ws:
            async for msg in ws:
                if msg.tp == aiohttp.WSMsgType.TEXT:
                    data = json.loads(msg.data)
                elif msg.tp == aiohttp.WSMsgType.BINARY:
                    data = json.loads(zlib.decompress(msg.data))
                else:
                    print("?", msg.tp)

                # https://discordapp.com/developers/docs/topics/gateway#gateway-op-codes
                if data['op'] == 10:  # Hello
                    asyncio.ensure_future(heartbeat(ws, data['d']['heartbeat_interval']))
                    await identify(ws)
                elif data['op'] == 11:  # Heartbeat ACK
                    print("< Heartbeat ACK")
                elif data['op'] == 0:  # Dispatch
                    last_sequence = data['s']
                    if data['t'] == "MESSAGE_CREATE":

                        print(data['d'])

                        if data['d']['content'] == '?help':
                            helpMsg = helpTask()
                            await send_message(data['d']['author']['id'],helpMsg)

                        if '?new' in data['d']['content']:
                            arguments = shlex.split(data['d']['content'])

                            if len(arguments) != 4:
                                await send_message(data['d']['author']['id'],'Veuillez entrez un titre, une description et une date')
                            else:
                                newMsg = new(data['d']['author']['id'], arguments[1], arguments[2], arguments[3])
                                await send_message(data['d']['author']['id'],newMsg)
                                task = rappel(data['d']['author']['id'], arguments[1],arguments[3])
                                await task
                                listeRappel.append(task)

                        if '?update' in data['d']['content']:
                            arguments = shlex.split(data['d']['content'])

                            if len(arguments) != 4:
                                await send_message(data['d']['author']['id'],f"Veuillez entrez l'id de votre tâche, le champ que vous souhaitez changer et la nouvelle valeur.")
                                await send_message(data['d']['author']['id'],f"Exemple : update 0 name NewName")
                            else:
                                updateMsg = update(data['d']['author']['id'], arguments[1], arguments[2], arguments[3])
                                await send_message(data['d']['author']['id'],updateMsg)

                        if '?delete' in data['d']['content']:
                            arguments = shlex.split(data['d']['content'])
                            deleteMsg = delete(data['d']['author']['id'], arguments[1])
                            await send_message(data['d']['author']['id'],deleteMsg)
                            #listeRappel[int(arguments[1])].cancel()

                        if '?list' in data['d']['content']:
                            tacheList=listTask(data['d']['author']['id'])
                            await send_message(data['d']['author']['id'],tacheList)

                        if '?detail' in data['d']['content']:
                            arguments = shlex.split(data['d']['content'])
                            details = detail(data['d']['author']['id'], arguments[1])
                            await send_message(data['d']['author']['id'],details)

                        if data['d']['content'] == '?quit':
                            store()
                            await send_message(data['d']['author']['id'],'Bye Bye !')
                            break

                    else:
                        print('Todo?', data['t'])
                else:
                    print("Unknown?", data)