우분투 12.04 상자에 토런트가 uTorrent와 함께 다운로드 될 때 알림을 보내도록 작은 파이썬 스크립트를 만들었습니다. pgrep -l torrent를 실행하면 scipt가로드되고이를 죽일 수 없습니다. utorrent는 토렌트 이름을 전달하는 스크립트를 호출합니다. 스크립트는 잘 작동하고 터미널에서 실행할 때 종료되지만 utorrent가 호출 할 때 닫히지 않습니다. 스크립트의 맨 아래에 sys.exit()를 추가하려고 시도했지만 프로세스를 중지하지 않고 알림을 보내지 못하게했습니다.파이썬 uTorrent 알림 스크립트가 종료되지 않습니다
나는 scipt를 닫기 위해 할 수 있습니까? 또한 이러한 프로세스를 어떻게 죽일 수 있을지에 대한 아이디어가 있습니까? 나는 pkill과 htop을 죽이려고했다.
감사합니다.
#!/usr/bin/python
import sys
import os
import socket
def network_notify(message):
host = ['192.168.0.4', '192.168.0.6'] #server IP
port = 50000
size = 1024
title = 'Torrent Downloaded'
for i in host:
try:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((i,port))
except:
None
else:
s.send('\"' + title + '\" \"' +message+'"')
data = s.recv(size)
s.close()
if len(sys.argv) > 1:
name = ' '.join(sys.argv[1:])
network_notify(name)
을 heres pgrep을
[email protected]Netb$ pgrep -l torrent
27516 torrentNotify.p
27518 torrentNotify.p
27520 torrentNotify.p
27521 torrentNotify.p
27522 torrentNotify.p
27529 torrentNotify.p
27531 torrentNotify.p
27540 torrentNotify.p
27541 torrentNotify.p
27545 torrentNotify.p
27546 torrentNotify.p
27550 torrentNotify.p
27551 torrentNotify.p
27552 torrentNotify.p
27553 torrentNotify.p
27555 torrentNotify.p
27558 torrentNotify.p
27567 torrentNotify.p
27570 torrentNotify.p
27571 torrentNotify.p
27573 torrentNotify.p
27574 torrentNotify.p
28959 torrentNotify.p
28965 torrentNotify.p
28970 torrentNotify.p
무엇이'wchan'입니까? –
wchan 모두 출구입니다. – James
catch-all 'except :'절이 유용한 정보를 숨길 수 있습니다. 또한,'socket' 메소드 호출 중 하나가 걸려있을 수 있습니다. 어떤 디버깅을 위해 어떤 로깅을 추가하는 것이 유용 할 수 있습니다. – martineau