I just created an python script that solve me a problem i need but i want to convert this script to exe file to run it in any windows machine without need of install python on it I have search of how could i convert the py to exe and run it and i have found that i could use script called py2exe the problem here that i want to convert my file to exe and run it as a windows service continuously on the my PC.
Here is the my script:
import socket, sys, serial
HOST = '' # Symbolic name, meaning all available interfaces
PORT = 8888 # Arbitrary non-privileged port
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
print 'Socket created'
#Bind socket to local host and port
try:
s.bind((HOST, PORT))
except socket.error as msg:
print 'Bind failed. Error Code : ' + str(msg[0]) + ' Message ' + msg[1]
sys.exit()
print 'Socket bind complete'
#Start listening on socket
s.listen(10)
print 'Socket now listening'
# try:
#now keep talking with the client
while 1:
#wait to accept a connection - blocking call
conn, addr = s.accept()
# print('Connected with {}:{}'.format(addr[0], addr[1]))
str = conn.recv(100)
n_str = str[8:]
last_c = n_str.find('%')
last_str = n_str[:last_c]
final_str = last_str.replace('+',' ')[:-3]
print(final_str)
try:
pole = serial.Serial('COM4')
pole.write(' \r\n')
pole.write(final_str+'\r\n')
pole.close()
except:
print(Exception.message)
s.close()
Could i have some help here