Advertisement
Guest User

Untitled

a guest
Dec 11th, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.20 KB | None | 0 0
  1.             def send_photoshop(msg):
  2.                 conn = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  3.                 conn.settimeout(10)
  4.                 try:
  5.                     call = 0
  6.                     RETRY_COUNT = 10
  7.                     while call < RETRY_COUNT:
  8.                         try:
  9.                             hostname = socket.gethostname()
  10.                             HOST = socket.gethostbyname(hostname)
  11.                             logging.info("HOST OLD " + str(HOST))
  12.                             PORT = 8123
  13.                             conn_result = conn.connect_ex((HOST, PORT))
  14.  
  15.                             logging.info(""
  16.                                 "conn.connect_ex: " + str(conn_result) + "; HOST = " + str(HOST) + "; PORT = " str(PORT) + " " + str(traceback.format_exc()))
  17.                             conn.send(msg)
  18.                             break
  19.                         except BrokenPipeError:
  20.                             logging.info(
  21.                                 "BrokenPipeError  try conn.send(msg) FALL whith call = " + str(call) + " " + str(traceback.format_exc()))
  22.                             call+=1
  23.                             #TODO need to import time !!!!
  24.                             time.sleep(5) # wait 5 sec
  25.  
  26.                         if platform == "win32":
  27.                             result = conn.recv(4096)
  28.                             logging.info(
  29.                                 "conn.recv(4096) WINDOWS " + " " + str(traceback.format_exc()))
  30.                         else:
  31.  
  32.                             result = None  # conn.recv(4096)
  33.                             logging.info(
  34.                                 "MAC result = None " + " " + str(traceback.format_exc()))
  35.                             # result = conn.recv(4096)
  36.                             logging.info(
  37.                                 "conn.recv(4096) line " + " " + str(traceback.format_exc()))
  38.                 finally:
  39.                     conn.close()
  40.                     logging.info(
  41.                             "conn  close " + str(traceback.format_exc()))
  42.                 if DEBUG:
  43.                    print(result)
  44.                 Error(None, 0, 15)
  45.                 return result
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement