Exemple #1
0
def search_fingerprint(url='', key='', org='', account='', fingerprint='', **kwargs):
    org_list = orgs.get_orgs(url=url, org=org, account=account, key=key)
    for o in org_list:
        account_list = accounts.get_accounts(url=url, org=o['name'], key=key)
        for acc in account_list:
            agent_list = agents.get_agents(url=url, org=org, account=acc['name'], key=key)
            for ag in agent_list:
                if ag['id'] == fingerprint:
                    click.echo('Organization: %s Account: %s Agent: %s' % (o['name'], acc['name'], ag['name']))
Exemple #2
0
def search_fingerprint(url='', key='', org='', account='', fingerprint='', **kwargs):
    org_list = orgs.get_orgs(url=url, org=org, account=account, key=key)
    for o in org_list:
        account_list = accounts.get_accounts(url=url, org=o['name'], key=key)
        for acc in account_list:
            agent_list = agents.get_agents(url=url, org=org, account=acc['name'], key=key)
            for ag in agent_list:
                if ag['id'] == fingerprint:
                    click.echo('Organization: ' + o['name'] + ' Account: ' + acc['name'] + ' Agent: ' + ag['name'])
Exemple #3
0
def search_agent(url='', key='', org='', account='', agent='', **kwargs):
    org_list = orgs.get_orgs(url=url, org=org, account=account, key=key)
    for o in org_list:
        account_list = accounts.get_accounts(url=url, org=o['name'], key=key)
        for acc in account_list:
            agent_list = agents.get_agents(url=url, org=org, account=acc['name'], key=key)
            for ag in agent_list:
                if ag['name'] == agent:
                    click.echo('Organization: %s Account: %s Agent: %s' % (o['name'], acc['name'], ag['name']))
Exemple #4
0
def statistics():
    if not accounts.is_admin():
        flash("Ei oikeuksia ylläpitosivulle.", "warning")
        return redirect("/")
    auth_list = authors.get_authors()
    m_list = librarymaterial.get_material_by_name()
    type_list = materialtypes.get_types()
    acc_list = accounts.get_accounts()
    loan_history = loans.get_loan_history()
    return render_template("statistics.html", auth_list=auth_list, m_list=m_list, type_list=type_list, acc_list=acc_list, loan_history=loan_history)
Exemple #5
0
def load_all_projects(wf):
    log.debug('start updating the cache')
    wf = Workflow3()

    all_accounts = None
    try:
        all_accounts = Accounts(get_accounts(wf))
    except PasswordNotFound:  # API key has not yet been set
        notify("WARNING", "No API key saved")

        log.error('No API key saved')

    log.debug('loading accounts...')

    if not all_accounts:
        # just paste gitlab url to the variables page and token to the keychain and start using the workflow
        url = get_wf_variable(wf, "gitlab_url")
        token = get_wf_variable(wf, "gitlab_token")
        all_accounts = Account({
            "simple_account": {
                "url": url,
                "token": token,
                "project_membership": "true",
                "project_visibility": "internal",
            }
        })

    log.info('Removing cache: {}'.format(DATA_FILE))
    # if os.path.exists(DATA_FILE):
    #     return
    try:
        os.remove(DATA_FILE)
    except:
        pass

    result = []
    for acc_name, acc_settings in all_accounts.dict.items():
        log.info('base api url is: {url}; api token is: {token_name}'.format(
            url=acc_settings.url, token_name=acc_settings.token))
        result.extend(get_all_pages(wf, account=acc_settings))

    with open(DATA_FILE, 'w+') as fp:
        json.dump(result, fp)

    notify(
        "Cache was updated",
        "Was loaded {projects} projects from all gitlab instances".format(
            projects=len(result)))
Exemple #6
0
def search_metadata(url='', key='', org='', account='', metadata='', **kwargs):
    agent_names = []
    org_list = orgs.get_orgs(url=url, org=org, account=account, key=key)
    for o in org_list:
        account_list = accounts.get_accounts(url=url, org=o['name'], key=key)
        for acc in account_list:
            agent_list = agents.get_agents(url=url, org=org, account=acc['name'], key=key)
            for summary in agent_list:
                agent_names.append(summary['name'])
            for agent in agent_names:
                try:
                    search_hash = flatten(agents.get_agent(url=url, org=org, account=acc['name'], key=key, agent_name=agent))
                    if metadata in search_hash.keys() or metadata in search_hash.values():
                        click.echo('Organization: ' + o['name'] + ' Account: ' + acc['name'] + ' Agent: ' + agent)
                except:
                    continue
Exemple #7
0
def search_metadata(url='', key='', org='', account='', metadata='', **kwargs):
    agent_names = []
    org_list = orgs.get_orgs(url=url, org=org, account=account, key=key)
    for o in org_list:
        account_list = accounts.get_accounts(url=url, org=o['name'], key=key)
        for acc in account_list:
            agent_list = agents.get_agents(url=url, org=org, account=acc['name'], key=key)
            for summary in agent_list:
                agent_names.append(summary['name'])
            for agent in agent_names:
                try:
                    search_hash = flatten(agents.get_agent(url=url, org=org, account=acc['name'],
                                                           key=key, agent_name=agent))
                    if metadata in search_hash.keys() or metadata in search_hash.values():
                        click.echo('Organization: %s Account: %s Agent: %s' % (o['name'], acc['name'], agent))
                except:
                    continue
Exemple #8
0
def restore_org(url='', key='', org='', backupdir='', **kwargs):
    for a in accounts.get_accounts():
        restore_account(url, key, org, a['name'], backupdir)
Exemple #9
0
def backup_org(url='', org='', key='', backupdir='', **kwargs):
    for a in accounts.get_accounts(url=url, org=org, key=key):
        backup_account(url=url, key=key, org=org, account=a['name'], backupdir=backupdir)
Exemple #10
0
 def get(self):
     amount = int(request.args.get("amount", 1))
     acc = accounts.get_accounts(amount)
     return acc
Exemple #11
0
def restore_org(url='', key='', org='', backup_dir='', **kwargs):
    for a in accounts.get_accounts():
        restore_account(url, key, org, a['name'], backup_dir)
Exemple #12
0
def backup_org(url='', org='', key='', backup_dir='', **kwargs):
    click.echo(click.style('Backing up accounts in %s...' % org, 'white', bold=True))
    for a in accounts.get_accounts(url=url, org=org, key=key):
        click.echo(click.style(' * Backing up account: ', 'white', bold=True) + click.style(a['name'], 'green'))
        backup_account(url=url, key=key, org=org, account=a['name'], backup_dir=backup_dir)
def main():
    """The main controller
    """
    NotEmpty, Users = accounts.check_users_in_db()
    if (NotEmpty):
        numberofusers = len(Users)
        if (numberofusers > 1):
            speech_ui.playsound('./data/multiple-users.mp3')
            text = get_name()
            try:
                ID = accounts.get_id(text)
                username = text
                acc = accounts.get_accounts(ID)
            except (UnboundLocalError, TypeError):
                speech_ui.playsound('./data/no-user.mp3')
                cleanexit.quit()
            if (len(acc) > 1):
                try:
                    email_acc = get_email()
                    emailacc, password, host = accounts.get_logins(email_acc)
                except (TypeError, UnboundLocalError):
                    speech_ui.playsound('./data/no-email.mp3')
                    cleanexit.quit()
            else:
                if not acc:
                    speech_ui.speak(
                        "%s! You do not have an account Please add one" %
                        username)
                    newemail = get_email()
                    newhost = get_host(newemail)
                    newpassword = get_password()
                    accounts.add_account(newhost, ID, newemail, newpassword)
                    cleanexit.quit()
                else:
                    for i in acc:
                        emailacc, password, host = i
        else:
            for i in Users:
                ID, username, gender = i
            acc = accounts.get_accounts(ID)
            if (len(acc) > 1):
                try:
                    speech_ui.playsound('./data/many-emails.mp3')
                    email_acc = get_email()
                    emailacc, password, host = accounts.get_logins(email_acc)
                except (TypeError, UnboundLocalError):
                    speech_ui.playsound('./data/no-email.mp3')
                    cleanexit.quit()
            else:
                if not acc:
                    speech_ui.speak(
                        "%s! You do not have an account Please add one" %
                        username)
                    newemail = get_email()
                    newhost = get_host(newemail)
                    newpassword = get_password()
                    accounts.add_account(newhost, ID, newemail, newpassword)
                    cleanexit.quit()
                else:
                    for i in acc:
                        emailacc, password, host = i
        host = get_host(emailacc)
        imapname, imapport, smtpname, smtpport = accounts.get_host(host)
        text = """
        Welcome %s!. What would you wish to do?
        1. Check inbox.
        2. Compose email.
        3. Add an account.
        4. Delete an account.
        5. Add a new user.
        6. Delete a user.""" % username
        speech_ui.speak(text)
        text = speech_ui.take_voice()
        homophonesOne = ['one', '1', 'warn']
        homophonesTwo = ['two', '2', 'too']
        homophonesFour = ['for', '4']
        if (text in homophonesOne):
            recieve_mails.get_email(imapname, imapport, emailacc, password)
        elif (text in homophonesTwo):
            reciever = get_dest_email()
            send_mails.main(smtpname, smtpport, emailacc, password, reciever)
        elif (text == '3'):
            newemail = get_email()
            newhost = get_host(newemail)
            newpassword = get_password()
            accounts.add_account(newhost, ID, newemail, newpassword)
            cleanexit.quit()
        elif (text in homophonesFour):
            text = get_email()
            accounts.delete_account(text)
            cleanexit.quit()
        elif (text == '5'):
            name = get_name()
            gender = get_gender()
            accounts.insert_user(name, gender)
            cleanexit.quit()
        elif (text == '6'):
            name = get_name()
            accounts.delete_user(name)
            cleanexit.quit()
    else:
        initial_setup()