コード例 #1
0
ファイル: ssh_connect.py プロジェクト: mohitsud/superloop
def ssh_connect(args):

    auditcreeper = False
    commands = initialize.configuration
    argument_node = args.hostname

    ### NODE_OBJECT IS A LIST OF ALL THE NODES IN THE DATABASE WITH ALL ATTRIBUTES
    node_object = process_nodes()

    ### MATCH_NODE IS A LIST OF NODES THAT MATCHES THE ARGUEMENTS PASSED IN BY USER
    match_node = search_node(argument_node, node_object)

    if (len(match_node) == 0):
        print("[+] [NO MATCHING NODES AGAINST DATABASE]")
        print("")

    else:
        node_element(match_node, node_object)
        id = 1
        ssh_id = 0

        print("ID\tname\t\t\taddress\t\tplatform")

        for index in initialize.element:

            print("{}\t{}\t{}\t{}".format(id, node_object[index]['hostname'],
                                          node_object[index]['ip'],
                                          node_object[index]['platform']))
            id = id + 1

        port = get_port(node_object, initialize.element, ssh_id)

        if (len(initialize.element) == 1):
            subprocess.call("ssh admin@{} -p {}".format(
                node_object[initialize.element[ssh_id]]['ip'], port),
                            shell=True)

        else:
            ssh_id = int(raw_input("Enter ID to SSH to: "))

            ### NODE_ID WILL MAP TO THE CORRECT NODE_OBJECT HOST TO CONNECT TO.
            ssh_id = ssh_id - 1

            port = get_port(node_object, initialize.element, ssh_id)
            subprocess.call("ssh admin@{} -p {}".format(
                node_object[initialize.element[ssh_id]]['ip'], port),
                            shell=True)
コード例 #2
0
ファイル: serve.py プロジェクト: hailes1/CafRate
            print >> sys.stderr, stderr
        self._set_headers('text/html')
        self.wfile.write(outgoing_data)
        exe_mtime = new_mtime

    def log_message(self, format, *args):
        sys.stderr.write(".")
        
def run(server_class=HTTPServer, handler_class=S, port=25100):
    server_address = ('', port)
    httpd = server_class(server_address, handler_class)
    hostname = socket.gethostname()
    print 'Starting httpd at', (hostname + ':' + str(port)), 'with', exe_name, '...'
    httpd.serve_forever()

if __name__ == "__main__":
    from sys import argv

    if len(argv) == 3:
        exe_name = argv[1]
        run(port=int(argv[2]))
    elif len(argv) == 2:
    	port = get_port()
        exe_name = argv[1]
        run(port=port)
    elif len(argv) == 1:
    	port = get_port()
        run(port=port)
    else:
        print "Usage: ./serve.py [exe_name] [port]"
コード例 #3
0
gcloud = -1

if socket.gethostname().startswith('STO'):  # personal machine
    get_port = lambda: int(os.environ.get("PORT")) if os.environ.get(
        "PORT") is not None else 25199
else:
    try:  # see if running on link machines
        # sys.path.insert(0, '/usr/local/cs/cs251')
        # sys.path.append('/home/users/olaf/pub/cs251')
        sys.path.append('/usr/local/cs/cs251/port')
        from port import get_port
        #get_port = lambda : os.environ.get("PORT") if os.environ.get("PORT") is not None else 35200
    except ModuleNotFoundError:  # otherwise assume Google Cloud or personal machine
        get_port = lambda: int(os.environ.get("PORT")) if os.environ.get(
            "PORT") is not None else 8080
        print(get_port())
        gcloud = 1

exe_name = "a.out"
exe_mtime = -1
message_id = {}
yaml_files_name = "app.files"
mem_file_name = "app.mem"
yaml_mtime = -1
separator = '\n---\n'


def has_top_key(key, yaml):
    return yaml.startswith(key) or -1 != yaml.find('\n' + key)