Пример #1
0
def ami_for_project(pname):
    "returns possible AMIs suitable for given project"
    conn = core.connect_aws_with_pname(pname, 'ec2')
    kwargs = {
        # you're better off just going here:
        # https://cloud-images.ubuntu.com/locator/ec2/
        # http://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeImages.html#query-DescribeImages-filters
        'filters': {
            #'root-device-type': 'ebs',
            #'virtualization_type': 'hvm',
            'architecture': 'x86_64',
            #'name': 'ubuntu/images/*',
            'name': 'ubuntu/images/*/*14.04*201605*',
            'state': 'available',
            'root-device-name': '/dev/sda1',
        },
        'owners': ['099720109477']  # Canonical
    }
    results = conn.get_all_images(**kwargs)

    print results

    print len(results), "results"

    return utils.table(
        results, ['id', 'root_device_type', 'virtualization_type', 'name'])
Пример #2
0
def ami_for_project(pname):
    "returns possible AMIs suitable for given project"
    conn = core.connect_aws_with_pname(pname, 'ec2')
    kwargs = {
        # you're better off just going here:
        # https://cloud-images.ubuntu.com/locator/ec2/
        # http://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeImages.html#query-DescribeImages-filters
        'filters': {
            #'root-device-type': 'ebs',
            #'virtualization_type': 'hvm',
            'architecture': 'x86_64',
            #'name': 'ubuntu/images/*',
            'name': 'ubuntu/images/*/*14.04*201605*',
            'state': 'available',
            'root-device-name': '/dev/sda1',
        },
        'owners': ['099720109477'] # Canonical
    }
    results = conn.get_all_images(**kwargs)

    print results
    
    print len(results),"results"

    return utils.table(results, ['id', 'root_device_type', 'virtualization_type', 'name'])
Пример #3
0
def rand_neutral_etienne (inds, theta, immig):
    '''
    generates random distribution according to J, theta and I

    :argument inds: number of individuals in community (J)
    :argument theta: corresponding to the model
    :argument immig: immigration rate (I)

    :returns: distribution of abundance (list)
    
    '''
    theta = float (theta)
    immig = float (immig)
    mcnum   = [0] * int (inds)
    locnum  = [0] * int (inds)
    mcnum[0] = 1
    new = nxt = -1
    for ind in xrange (inds):
        if random () > immig / (ind + immig):
            locnum [ind] = locnum [int (random () * ind)]
        else:
            new += 1
            if random () <= theta / (theta + new):
                nxt += 1
                mcnum[new] = nxt + 1
            else:
                mcnum[new] = mcnum[int (random () * (new))]
            locnum[ind] = mcnum[new]
    return table (locnum, new + 1)
Пример #4
0
    def test_table(self):
        class AnObject():
            def __init__(self, project, instance_id):
                self.project = project
                self.instance_id = instance_id

        rows = [AnObject('lax', 'ci'), AnObject('bot', 'end2end')]
        keys = ['project', 'instance_id']
        self.assertEqual("lax, ci\nbot, end2end", utils.table(rows, keys))
Пример #5
0
    def test_table(self):
        class AnObject():
            def __init__(self, project, cluster):
                self.project = project
                self.cluster = cluster

        rows = [AnObject('lax', 'ci'), AnObject('bot', 'end2end')]
        keys = ['project', 'cluster']
        self.assertEqual("lax, ci\nbot, end2end", utils.table(rows, keys))
Пример #6
0
def november21(query):
    """
    Обработка нажатия на кнопку "21 ноября"
    :param query: Запрос на вывод расписания на 21 ноября
    """
    print('Пользователь', query.from_user.id,
          'открыл расписание на 21 ноября"')
    bot.answer_callback_query(query.id)
    bot.delete_message(query.message.chat.id, query.message.message_id + 1)
    bot.edit_message_text(utils.table(query.data),
                          query.message.chat.id,
                          query.message.message_id,
                          parse_mode='Markdown')
    bot.send_message(query.message.chat.id,
                     config.menu_return,
                     reply_markup=back_keyboard)
Пример #7
0
def rand_neutral_ewens (inds, theta):
    '''
    generates random distribution according to J and theta
    
    :argument inds: number of individuals in community (J)
    :argument theta: corresponding to the model

    :returns: distribution of abundance (list)
    
    '''
    theta = float (theta)
    out = [0] * int (inds)
    out [0] = spp = 1
    for ind in xrange (inds):
        if random () < theta/(theta + ind):
            spp += 1
            out[ind] = spp
        else:
            out[ind] = out [int (random () * ind)]
    return table (out, spp)
Пример #8
0
    if isinstance(options.transactions,
                  (unicode, str)) and not options.transactions.isdigit():
        print("--transactions must be an integer.")
        raise SystemExit

    options.transactions = int(options.transactions)

    returned_data = {}

    if options.scenario:
        if options.scenario in scenarios.map:
            print options
            returned_data = scenarios.map[options.scenario](options)
            if not isinstance(returned_data, dict):
                returned_data = {}
        else:
            print("Error: Unknown scenario.")
            raise SystemExit

    if "routers" in returned_data:
        table_data = [{"Routing Table": r,
            "Consensus Events": str(r.tbucket.consensus_events) +\
            "               "} \
            for r in returned_data["routers"]]
        utils.table(table_data)

    returned_data.update({"utils": utils})

    if options.repl:
        utils.invoke_ptpython(returned_data)
Пример #9
0
cased_users_col_names = ['ID', 'PARENTID', 'Email', 'First_Name', 'last_name']
cased_users2_col_names = ['UserID', 'UserName']
cased_func_names = [
    'Custom_Fun', '_custom_fun', 'Custom_Func1', 'custom_func2',
    'set_returning_func'
]
cased_tbls = ['Users', 'Orders']
cased_views = ['User_Emails', 'Functions']
casing = (['SELECT', 'PUBLIC'] + cased_func_names + cased_tbls + cased_views +
          cased_users_col_names + cased_users2_col_names)
# Lists for use in assertions
cased_funcs = [
    function(f)
    for f in ('Custom_Fun', '_custom_fun', 'Custom_Func1', 'custom_func2')
] + [function('set_returning_func')]
cased_tbls = [table(t) for t in (cased_tbls + ['"Users"', '"select"'])]
cased_rels = [view(t) for t in cased_views] + cased_funcs + cased_tbls
cased_users_cols = [column(c) for c in cased_users_col_names]
aliased_rels = [
    table(t) for t in ('users u', '"Users" U', 'orders o', '"select" s')
] + [view('user_emails ue'), view('functions f')] + [
    function(f) for f in ('_custom_fun() cf', 'custom_fun() cf',
                          'custom_func1() cf', 'custom_func2() cf')
] + [
    function('set_returning_func(x := , y := ) srf',
             display='set_returning_func(x, y) srf')
]
cased_aliased_rels = [
    table(t) for t in ('Users U', '"Users" U', 'Orders O', '"select" s')
] + [view('User_Emails UE'), view('Functions F')] + [
    function(f) for f in ('_custom_fun() cf', 'Custom_Fun() CF',
import os

import utils

# load arguments
arguments = docopt(__doc__)
print()
print('PROVIDED ARGUMENTS')
print(arguments)
print()

configuration = json.load(open(arguments['--config_path']))
verbose = int(arguments['--verbose'])

frame_label2lexeme_objs, \
frame_label2lemma_objs, \
merging_stats = utils.load_sonar_annotations(configuration,
                                             verbose=verbose)


df = utils.table(frame_label2lexeme_objs,
                 frame_label2lemma_objs)


utils.remove_and_create_folder(configuration['statistics_folder'])

stats_path = os.path.join(configuration['statistics_folder'],
                          'frequency.xlsx')
df.to_excel(stats_path, index=False)

Пример #11
0
cased_users_col_names = ['ID', 'PARENTID', 'Email', 'First_Name', 'last_name']
cased_users2_col_names = ['UserID', 'UserName']
cased_func_names = [
    'Custom_Fun', '_custom_fun', 'Custom_Func1', 'custom_func2', 'set_returning_func'
]
cased_tbls = ['Users', 'Orders']
cased_views = ['User_Emails', 'Functions']
casing = (
        ['SELECT', 'PUBLIC'] + cased_func_names + cased_tbls + cased_views
        + cased_users_col_names + cased_users2_col_names
)
# Lists for use in assertions
cased_funcs = [
                  function(f) for f in ('Custom_Fun', '_custom_fun', 'Custom_Func1', 'custom_func2')
              ] + [function('set_returning_func')]
cased_tbls = [table(t) for t in (cased_tbls + ['"Users"', '"select"'])]
cased_rels = [view(t) for t in cased_views] + cased_funcs + cased_tbls
cased_users_cols = [column(c) for c in cased_users_col_names]
aliased_rels = [
                   table(t) for t in ('users u', '"Users" U', 'orders o', '"select" s')
               ] + [view('user_emails ue'), view('functions f')] + [
                   function(f) for f in (
        '_custom_fun() cf', 'custom_fun() cf', 'custom_func1() cf',
        'custom_func2() cf'
    )
               ] + [function(
    'set_returning_func(x := , y := ) srf',
    display='set_returning_func(x, y) srf'
)]
cased_aliased_rels = [
                         table(t) for t in ('Users U', '"Users" U', 'Orders O', '"select" s')