2017-11-12 7 views
8

창에서 작동하지 않습니다 :.sendto() 메소드는이 코드를 사용하는 나는 창문에 sikuli 파이썬 스크립트를 개발

from socket import AF_INET, SOCK_DGRAM 
import sys 
import socket 
import struct, time 

host = "pool.ntp.org" 
port = 123 
buf = 1024 
address = (host,port) 
msg = '\x1b' + 47 * '\0' 

# reference time (in seconds since 1900-01-01 00:00:00) 
TIME1970 = 2208988800L # 1970-01-01 00:00:00 

# connect to server 
client = socket.socket(AF_INET, SOCK_DGRAM) 
client.sendto(msg, address) 
msg, address = client.recvfrom(buf) 

t = struct.unpack("!12I", msg)[10] 
t -= TIME1970 

current_time = time.ctime(t).replace(" "," ") 

코드는 리눅스에서 나에 파이썬 스크립트에서 잘 작동

[error] script [ Sikuli_Test_Original ] stopped with error in line 23 
[error] _socket.error ([Errno -1] Unmapped exception:  java.util.concurrent.RejectedExecutionException: event executor terminated) 
[error] --- Traceback --- error source first line: module (function) statement 359: _socket (handle_exception) _socket.error: [Errno -1] Unmapped exception: java.util.concurrent.RejectedExecutionException: event executor terminated 
995: _socket (sendto) File "C:\Users\myuser\Documents\Sikuli\sikulix.jar\Lib\_socket.py", line 971, in _datagram_connect 
[error] --- Traceback --- end -------------- 

어떤 생각을 왜 그것을 해결하는 방법 : 나는 창문에 sikulix에이 코드를 사용하는 경우 윈도우는하지만, 다음과 같은 오류와 (줄에서 =>client.sendto (MSG, 주소)) 충돌 ?

+0

나는 하나 – user3472065

+0

당신이 같은 sikuli 버전에 사용하고 sikuli가 자신의 _socket.py를 사용하려고 인상이 아닌 시스템을했다 두 시스템? –

+0

예, 최신 버전의 sikulix – user3472065

답변

0

귀하의 문제는 자이 썬과 방법 Sikuli interops 논의 (그리고 자이 썬 버그처럼 보인다)이 스레드에서 해결 분명히 논의되었다

https://bugs.launchpad.net/sikuli/+bug/1464105 내가 솔루션을 확인; 이 코드는 Windows 10에서 SikuliX IDE 내에서 작동합니다. 상단의 추가 초기화 헤더에 기본적으로 트릭 : 오류 로그에서

import sys, _socket 
from socket import AF_INET, SOCK_DGRAM 
if _socket.NIO_GROUP.isShutdown(): 
    print "RE-CREATING NIO_GROUP" 
    _socket.NIO_GROUP = _socket.NioEventLoopGroup(2, _socket.DaemonThreadFactory("PyScan-Netty-Client-%s")) 
    sys.registerCloser(_socket._shutdown_threadpool) 
import socket 
import struct, time 

host = "pool.ntp.org" 
port = 123 
buf = 1024 
address = (host,port) 
msg = '\x1b' + 47 * '\0' 

# reference time (in seconds since 1900-01-01 00:00:00) 
TIME1970 = 2208988800L # 1970-01-01 00:00:00 
print "Before socket operation" 
# connect to server 
client = socket.socket(AF_INET, SOCK_DGRAM) 
client.sendto(msg, address) 
print "After socket operation" 
msg, address = client.recvfrom(buf) 
t = struct.unpack("!12I", msg)[10] 
t -= TIME1970 

current_time = time.ctime(t).replace(" "," ") 
print current_time 
관련 문제