def single_thread():
    terms = []
    for i in range(args.quantity):
        name = '%s-%s' % (args.name,i)
        print "Starting Terminal %s" % name
        container_key, container_ip, subdomain = start_snap(name, snapshot_id, args.size, script)
        terms.append({'container_key':container_key, 'container_ip':container_ip, 'subdomain':subdomain, 'name':name})
    time.sleep(1) # Prevent race-condition issues

    # Installing stuff by ssh method
    if args.method == 'ssh':
        for i in range(len(terms)):
            terminal.add_authorized_key_to_terminal(terms[i]['container_key'],publicKey)
            time.sleep(1)
            if args.script is not None:
                print "Sending Script"
                send_script(terms[i]['container_ip'], 'root', key_name ,args.script)
                print "Running Script"
                run_on_terminal(terms[i]['container_ip'], 'root', key_name ,'/bin/bash /root/%s' % os.path.basename(args.script))
    elif args.method == 'startup_key':
        for i in range(len(terms)):
            terminal.add_authorized_key_to_terminal(terms[i]['container_key'],publicKey)
            time.sleep(1)

    if args.ports is not None:
        host_subdomain=socket.gethostname()
        ports=args.ports.split(',')
        terms.append(terminal.get_terminal(None,host_subdomain)['terminal'])
        for t in range(len(terms)):
            container_key=terms[t]['container_key']
            links=[]
            for s in range(len(terms)):
                for port in range(len(ports)):
                    link={'port':(ports[port]),'source':terms[s]['subdomain']}
                    links.append(link)
            terminal.add_terminal_links(container_key,links)
    return terms
dataset/ETHPy150Open terminalcloud/terminal-tools/script-terminals.py/single_thread/original