<reponame>cognitect-labs/clj9p<filename>interop/validate_server.py
# Copyright 2019 Cognitect. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS-IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

#!/usr/bin/env python

import sys
import os
import socket
from py9p import py9p

class CmdClient(py9p.Client):
    pass

def getSock(host, port):
    sock = socket.socket(socket.AF_INET)
    sock.connect((host, port),)

def main():
    args = sys.argv[1:]
    srv_host = args[0]
    srv_port = int(args[1])
    sock = getSock(srv_host, srv_port)
    print "Created 9P socket connection...", sock
    user = os.environ.get('USER')
    authsrv = None
    authmode = 'none'
    privkey = None
    passwd = <PASSWORD>
    creds = py9p.Credentials(user, authmode, passwd, privkey)
    print "Version, Auth, and Attach..."
    client = CmdClient(sock, creds, authsrv)
    print "done."
    return 0

if __name__ == "__main__":
    try:
        main()
    except KeyboardInterrupt:
        print("interrupted.")
    except EOFError:
        print("done.")
    except Exception as m:
        print("unhandled exception: " + str(m.args))
        raise


# Copyright 2019 Cognitect. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS-IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

#!/usr/bin/env python

import sys
import os
import socket
from py9p import py9p

class CmdClient(py9p.Client):
    pass

def getSock(host, port):
    sock = socket.socket(socket.AF_INET)
    sock.connect((host, port),)

def main():
    args = sys.argv[1:]
    srv_host = args[0]
    srv_port = int(args[1])
    sock = getSock(srv_host, srv_port)
    print "Created 9P socket connection...", sock
    user = os.environ.get('USER')
    authsrv = None
    authmode = 'none'
    privkey = None
    passwd = <PASSWORD>
    creds = py9p.Credentials(user, authmode, passwd, privkey)
    print "Version, Auth, and Attach..."
    client = CmdClient(sock, creds, authsrv)
    print "done."
    return 0

if __name__ == "__main__":
    try:
        main()
    except KeyboardInterrupt:
        print("interrupted.")
    except EOFError:
        print("done.")
    except Exception as m:
        print("unhandled exception: " + str(m.args))
        raise
# Copyright 2019 Cognitect. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # #      http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS-IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #!/usr/bin/env python