Ejemplo n.º 1
0
def main():
    " run helloworld on parsed args"
    args = parse_command_line()
    helloworld.helloworld(name=args.name,
                          howlong=args.howlong,
                          countdown=args.countdown,
                          luckynumber=args.luckynumber,
                          surprise=args.surprise)
Ejemplo n.º 2
0
def main():
    " run helloworld on parsed args"
    args = parse_command_line()
    helloworld.helloworld(name=args.name,
                          howlong=args.howlong,
                          countdown=args.countdown,
                          cny=args.cny,
                          fortune=args.fortune)
Ejemplo n.º 3
0
def hello_world():
    global session
    result = helloworld.helloworld()
    new_entry = {'author': session[0],
                 'date': datetime.datetime.utcnow(),
                 'result': str(result)
                 }
    collection4.insert_one(new_entry)
    if session[2] == 'student':
        return render_template('show_result.html', result=result['response']['result']['greeting'], name=session[0])
    elif session[2] == 'lead':
        return render_template('lead_show_result.html', result=result['response']['result']['greeting'], name=session[0])
    elif session[2] == 'admin':
        return render_template('admin_show_result.html', result=result['response']['result']['greeting'], name=session[0])
    else:
        return render_template('show_result.html', result=result['response']['result']['greeting'], name=session[0])
Ejemplo n.º 4
0
def main():
    " run helloworld on parsed args"
    args = parse_command_line()
    helloworld.helloworld(bestmusic=args.bestmusic,
                          crabtime=args.crabtime,
                          polite=args.polite)
Ejemplo n.º 5
0
 def test_helloworld(self):
     st = 'Hello dhanu'
     ret_value = helloworld.helloworld(st)
     print 'ret_value = ', ret_value
     assert (ret_value == True)
Ejemplo n.º 6
0
import helloworld

print("Hi")
print(helloworld.helloworld())
Ejemplo n.º 7
0
import helloworld
helloworld.helloworld("Python")
import datetime
x = datetime.datetime.now()
print(x)
Ejemplo n.º 8
0
import sys

from helloworld import helloworld

helloworld(sys.stdout)
Ejemplo n.º 9
0
from helloworld import helloworld
from time import time
import math

lim = 10000000

j = 0
tinic=time()
while (j<lim):
    r = helloworld(1.0)
    j+=1
tfin=time()
print("Con C. Elapsed time %.02f s" % (tfin-tinic))

j=0
tinic=time()
while (j<lim):
    r = math.expm1(1.0)
    j+=1
tfin=time()
print("Python solo. Elapsed time %.02f s" % (tfin-tinic))
 def printMessages(self):
     i = 1
     for msg in MessageTracker.messages:
         print("Message ", str(i), ":", msg)
         helloworld.helloworld()
Ejemplo n.º 11
0
# test 1:
# from:
#
# http://www.tutorialspoint.com/python/python_further_extensions.htm
#
# python setup.py  install

from helloworld import helloworld

helloworld()
# okay!



Ejemplo n.º 12
0
#!/usr/bin/python
import sys
from helloworld import helloworld

sys.path.append('../')
sys.stdout.write('Hello from my script!\n')
rv = helloworld("JIMMY")
print rv;
Ejemplo n.º 13
0
#!/usr/bin/env python
#import ctypes
#import coupling
import helloworld
# ll = ctypes.cdll.LoadLibrary
# lib = ll('./coupling.so')
#cpp = ctypes.CDLL('./libcoupling.so')
#
# class coupling(object):
#     def __init__(self):
#         self.add = lib.add()
#
# #coupling c

#B = cpp.add_c(1,2)
# 设置sum()函数传入参数的类型
# lib.add_c.argtypes = [ctypes.c_double, ctypes.c_double]
# # 这是sum()函数返回参数的类型
# lib.add_c.restype = ctypes.c_double
#
# a = ctypes.c_double(2.0)
# b = ctypes.c_double(2.0)
a = 2
b = 2
hw = helloworld.helloworld("lanyulei", 18)
hw.printinfo()
#c = oupling.add(a,b)
#print(c)
Ejemplo n.º 14
0
def main():
    " run helloworld on parsed args"
    args = parse_command_line()
    helloworld.helloworld(name=args.name, date=args.date)
Ejemplo n.º 15
0
def test():
	sc = helloworld.helloworld()
	testing.run_expecting_output(sc, "Hello World!\n")	
Ejemplo n.º 16
0
def main():
    "run helloworld on parsed args"
    args = parse_command_line()
    helloworld.helloworld(militarytime=args.militarytime, age=args.age)
Ejemplo n.º 17
0
import helloworld

status = helloworld.helloworld()
print(status)
Ejemplo n.º 18
0
 def test_should_issue_hello_world_message(self):
    rv = helloworld("JIMMY")
    #self.assertEqual('collado'.upper(), rv)
    self.assertEqual("mena".upper(), rv)
Ejemplo n.º 19
0
	def test_should_issue_hello_world_message(self):
		out = mock()

		helloworld(out)

		verify(out).write("hello world")
Ejemplo n.º 20
0
import helloworld

__author__ =  'Jordan Kidd'

# This calls the C extension and prints out the text compiled within
print(helloworld.helloworld())
Ejemplo n.º 21
0
def main():
    " run helloworld on parsed args"
    args = parse_command_line()
    helloworld.helloworld(popcorn=args.popcorn, countdown=args.countdown)
Ejemplo n.º 22
0
 def test_should_issue_hello_world_message(self):
     """docstring for test_should_issue_hello_world_message"""
     out = mock()
     helloworld(out)
     verify(out).write("Hello world of Python\n")
import helloworld
from google.appengine.api import mail


obj = helloworld.helloworld()
mail_body = obj.parse_feed()
mail.send_mail(sender="*****@*****.**",
                to="*****@*****.**",
                subject="TVSeries Schedule",
                body=mail_body)
Ejemplo n.º 24
0
def main():
    " run helloworld on parsed args"
    args = parse_command_line()
    helloworld.helloworld(name=args.name,
                          birthMonthNum=args.birthMonthNum,
                          Nehabday=args.Nehabday)
Ejemplo n.º 25
0
def main():
    "run helloworld on parsed args"
    args = parse_command_line()
    helloworld.helloworld(name=args.name, aday=args.aday, temp=args.temp)
Ejemplo n.º 26
0
def main():

    # ############### GENERAL INITIALISATION ################

    if not os.path.exists(vHello_DATA_DIR):
        os.makedirs(vHello_DATA_DIR)

    ks_creds = os_utils.get_credentials("keystone")
    nv_creds = os_utils.get_credentials("nova")
    nt_creds = os_utils.get_credentials("neutron")

    logger.info("Prepare OpenStack plateform (create tenant and user)")
    keystone = ksclient.Client(**ks_creds)

    user_id = os_utils.get_user_id(keystone, ks_creds['username'])
    if user_id == '':
        step_failure("init", "Error : Failed to get id of " +
                     ks_creds['username'])

    tenant_id = os_utils.create_tenant(
        keystone, TENANT_NAME, TENANT_DESCRIPTION)
    if tenant_id == '':
        step_failure("init", "Error : Failed to create " +
                     TENANT_NAME + " tenant")

    roles_name = ["admin", "Admin"]
    role_id = ''
    for role_name in roles_name:
        if role_id == '':
            role_id = os_utils.get_role_id(keystone, role_name)

    if role_id == '':
        logger.error("Error : Failed to get id for %s role" % role_name)

    if not os_utils.add_role_user(keystone, user_id, role_id, tenant_id):
        logger.error("Error : Failed to add %s on tenant" %
                     ks_creds['username'])

    user_id = os_utils.create_user(
        keystone, TENANT_NAME, TENANT_NAME, None, tenant_id)
    if user_id == '':
        logger.error("Error : Failed to create %s user" % TENANT_NAME)

    logger.info("Update OpenStack creds informations")
    ks_creds.update({
        "username": TENANT_NAME,
        "password": TENANT_NAME,
        "tenant_name": TENANT_NAME,
    })

    nt_creds.update({
        "tenant_name": TENANT_NAME,
    })

    nv_creds.update({
        "project_id": TENANT_NAME,
    })

    logger.info("Upload some OS images if it doesn't exist")
    glance_endpoint = keystone.service_catalog.url_for(
        service_type='image', endpoint_type='publicURL')
    glance = glclient.Client(1, glance_endpoint, token=keystone.auth_token)

    for img in IMAGES.keys():
        image_name = IMAGES[img]['image_name']
        image_url = IMAGES[img]['image_url']

        image_id = os_utils.get_image_id(glance, image_name)

        if image_id == '':
            logger.info("""%s image doesn't exist on glance repository. Try
            downloading this image and upload on glance !""" % image_name)
            image_id = download_and_add_image_on_glance(
                glance, image_name, image_url)

        if image_id == '':
            step_failure(
                "init",
                "Error : Failed to find or upload required OS "
                "image for this deployment")

    nova = nvclient.Client("2", **nv_creds)

    logger.info("Update security group quota for this tenant")
    neutron = ntclient.Client(**nt_creds)
    if not os_utils.update_sg_quota(neutron, tenant_id, 50, 100):
        step_failure(
            "init",
            "Failed to update security group quota for tenant " + TENANT_NAME)

    logger.info("Update cinder quota for this tenant")
    from cinderclient import client as cinderclient

    creds_cinder = os_utils.get_credentials("cinder")
    cinder_client = cinderclient.Client('1', creds_cinder['username'],
                                        creds_cinder['api_key'],
                                        creds_cinder['project_id'],
                                        creds_cinder['auth_url'],
                                        service_type="volume")
    if not os_utils.update_cinder_quota(cinder_client, tenant_id, 20, 10, 150):
        step_failure(
            "init", "Failed to update cinder quota for tenant " + TENANT_NAME)

    # ############### CLOUDIFY INITIALISATION ################

    cfy = orchestrator(vHello_DATA_DIR, CFY_INPUTS, logger)

    cfy.set_credentials(username=ks_creds['username'], password=ks_creds[
                        'password'], tenant_name=ks_creds['tenant_name'],
                        auth_url=ks_creds['auth_url'])

    logger.info("Collect flavor id for cloudify manager server")
    nova = nvclient.Client("2", **nv_creds)

    flavor_name = "m1.medium"
    flavor_id = os_utils.get_flavor_id(nova, flavor_name)
    for requirement in CFY_MANAGER_REQUIERMENTS:
        if requirement == 'ram_min':
            flavor_id = os_utils.get_flavor_id_by_ram_range(
                nova, CFY_MANAGER_REQUIERMENTS['ram_min'], 8196)

    if flavor_id == '':
        logger.error(
            "Failed to find %s flavor. "
            "Try with ram range default requirement !" % flavor_name)
        flavor_id = os_utils.get_flavor_id_by_ram_range(nova, 4000, 8196)

    if flavor_id == '':
        step_failure("orchestrator",
                     "Failed to find required flavor for this deployment")

    cfy.set_flavor_id(flavor_id)

    image_name = "centos_7"
    image_id = os_utils.get_image_id(glance, image_name)
    for requirement in CFY_MANAGER_REQUIERMENTS:
        if requirement == 'os_image':
            image_id = os_utils.get_image_id(
                glance, CFY_MANAGER_REQUIERMENTS['os_image'])

    if image_id == '':
        step_failure(
            "orchestrator",
            "Error : Failed to find required OS image for cloudify manager")

    cfy.set_image_id(image_id)

    ext_net = os_utils.get_external_net(neutron)
    if not ext_net:
        step_failure("orchestrator", "Failed to get external network")

    cfy.set_external_network_name(ext_net)

    ns = functest_utils.get_resolvconf_ns()
    if ns:
        cfy.set_nameservers(ns)

    logger.info("Prepare virtualenv for cloudify-cli")
    cmd = "chmod +x " + vHello_DIR + "create_venv.sh"
    functest_utils.execute_command(cmd, logger)
    time.sleep(3)
    cmd = vHello_DIR + "create_venv.sh " + vHello_DATA_DIR
    functest_utils.execute_command(cmd, logger)

    cfy.download_manager_blueprint(
        CFY_MANAGER_BLUEPRINT['url'], CFY_MANAGER_BLUEPRINT['branch'])

    # ############### CLOUDIFY DEPLOYMENT ################
    start_time_ts = time.time()
    end_time_ts = start_time_ts
    logger.info("Cloudify deployment Start Time:'%s'" % (
        datetime.datetime.fromtimestamp(start_time_ts).strftime(
            '%Y-%m-%d %H:%M:%S')))

    error = cfy.deploy_manager()
    if error:
        step_failure("orchestrator", error)

    end_time_ts = time.time()
    duration = round(end_time_ts - start_time_ts, 1)
    logger.info("Cloudify deployment duration:'%s'" % duration)
    set_result("orchestrator", duration, "")

    # ############### helloworld INITIALISATION ################

    cw = helloworld(CW_INPUTS, cfy, logger)

    logger.info("Collect flavor id for all helloworld vm")
    nova = nvclient.Client("2", **nv_creds)

    flavor_name = "m1.small"
    flavor_id = os_utils.get_flavor_id(nova, flavor_name)
    for requirement in CW_REQUIERMENTS:
        if requirement == 'ram_min':
            flavor_id = os_utils.get_flavor_id_by_ram_range(
                nova, CW_REQUIERMENTS['ram_min'], 8196)

    if flavor_id == '':
        logger.error(
            "Failed to find %s flavor. Try with ram range "
            "default requirement !" % flavor_name)
        flavor_id = os_utils.get_flavor_id_by_ram_range(nova, 4000, 8196)

    if flavor_id == '':
        step_failure(
            "vHello", "Failed to find required flavor for this deployment")

    cw.set_flavor_id(flavor_id)

    image_name = "ubuntu_14.04"
    image_id = os_utils.get_image_id(glance, image_name)
    for requirement in CW_REQUIERMENTS:
        if requirement == 'os_image':
            image_id = os_utils.get_image_id(
                glance, CW_REQUIERMENTS['os_image'])

    if image_id == '':
        step_failure(
            "vHello",
            "Error : Failed to find required OS image for cloudify manager")

    cw.set_image_id(image_id)

    ext_net = os_utils.get_external_net(neutron)
    if not ext_net:
        step_failure("vHello", "Failed to get external network")

    cw.set_external_network_name(ext_net)

    # ############### helloworld DEPLOYMENT ################

    start_time_ts = time.time()
    end_time_ts = start_time_ts
    logger.info("vHello VNF deployment Start Time:'%s'" % (
        datetime.datetime.fromtimestamp(start_time_ts).strftime(
            '%Y-%m-%d %H:%M:%S')))

    error = cw.deploy_vnf(CW_BLUEPRINT)
    if error:
        step_failure("vHello", error)

    end_time_ts = time.time()
    duration = round(end_time_ts - start_time_ts, 1)
    logger.info("vHello VNF deployment duration:'%s'" % duration)
    set_result("vHello", duration, "")
Ejemplo n.º 27
0
import helloworld

hw = helloworld.helloworld("me", 18)
hw.printinfo()
helloworld.test_func()
Ejemplo n.º 28
0
from helloworld import helloworld

b = helloworld()
b.test()
Ejemplo n.º 29
0
from helloworld import helloworld
from time import time
import math

lim = 10000000

j = 0
tinic = time()
while (j < lim):
    r = helloworld(1.0)
    j += 1
tfin = time()
print("Con C. Elapsed time %.02f s" % (tfin - tinic))

j = 0
tinic = time()
while (j < lim):
    r = math.expm1(1.0)
    j += 1
tfin = time()
print("Python solo. Elapsed time %.02f s" % (tfin - tinic))
Ejemplo n.º 30
0
 def test_should_issue_hello_world_message(self):
     out = mock()
     helloworld(out)
     verify(out).write("Hello World of Python Builder\n")
Ejemplo n.º 31
0
print("Enter Your Name :")
ch=input()
import helloworld
helloworld.helloworld(ch)
def should_issue_hello_world_message():
    out = mock()

    helloworld(out)

    verify(out).write("Hello world of Python\n")
Ejemplo n.º 33
0
def main():
    "run helloworld on parsed args"
    args = parse_command_line()
    helloworld.helloworld(name=args.name, nextm=args.nextm, roll=args.roll)
Ejemplo n.º 34
0
    def test_should_issue_hello_world_message(self):
        out = Mock()

        helloworld(out)

        out.write.assert_called_with("Hello world of Python\n")
Ejemplo n.º 35
-4
import helloworld
print helloworld.helloworld()

Ejemplo n.º 36
-9
    def test_should_issue_hello_world_message(self):
        out = Mock()

        helloworld(out)

        out.write.assert_called_with("Hello world of Python\n")