add client interface
This commit is contained in:
parent
1ed6209465
commit
c6e80956e5
@ -1,21 +1,50 @@
|
|||||||
import socket
|
import socket
|
||||||
|
import getopt
|
||||||
|
import sys
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
def connect(host, port = 5000):
|
||||||
|
|
||||||
def client_program():
|
# instantiate
|
||||||
host = "192.168.188.61"
|
|
||||||
port = 5000
|
|
||||||
|
|
||||||
client_socket = socket.socket() # instantiate
|
|
||||||
client_socket.connect((host, port)) # connect to the server
|
client_socket.connect((host, port)) # connect to the server
|
||||||
|
|
||||||
message = input(" -> ") # take input
|
def disconnect():
|
||||||
|
|
||||||
while message.lower().strip() != 'bye':
|
|
||||||
client_socket.send(message.encode()) # send message
|
|
||||||
message = input(" -> ") # again take input
|
|
||||||
|
|
||||||
client_socket.close() # close the connection
|
client_socket.close() # close the connection
|
||||||
|
|
||||||
|
def send(data):
|
||||||
|
client_socket.send(data.encode()) # send message
|
||||||
|
|
||||||
if __name__ == '__main__':
|
def helpmenu():
|
||||||
client_program()
|
print("Options:")
|
||||||
|
print("-h show help")
|
||||||
|
print("-s <color> set static color in hex")
|
||||||
|
print("-v visualizer()")
|
||||||
|
|
||||||
|
def visualizer():
|
||||||
|
with subprocess.Popen(["cava", "-p", "./config"], stdout=subprocess.PIPE) as cava:
|
||||||
|
print(cava.stdout.readlines())
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def main(argv):
|
||||||
|
try:
|
||||||
|
opts, args = getopt.getopt(argv, "s:vh")
|
||||||
|
except getopt.GetoptError:
|
||||||
|
print(sys.argv[0], "invalid option")
|
||||||
|
print("Try", sys.argv[0], "-h for help")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
for opt, arg in opts:
|
||||||
|
if opt == "-h":
|
||||||
|
helpmenu()
|
||||||
|
sys.exit()
|
||||||
|
elif opt == "-s":
|
||||||
|
send(arg)
|
||||||
|
elif opt == "-v":
|
||||||
|
visualizer()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
client_socket = socket.socket()
|
||||||
|
connect("192.168.188.61")
|
||||||
|
main(sys.argv[1:])
|
||||||
Loading…
Reference in New Issue
Block a user