인터넷에서 많은 Linux ISO 토런트를 다운로드합니다. 다운로드를 완료 한 토렌트에 대한 세부 정보를 iPhone에 알려주는 작은 파이썬 스크립트를 만들었습니다. 급류의 이름, 레이블 및 크기를 보냅니다.qBittorrent를 사용하여 스크립트를 실행할 때 Python에서 IO 오류 13을 극복하는 방법
Pushbullet.py이라는 파이썬 라이브러리를 사용하여 내 전화로 알림을 보냅니다.
import os , sys, string, time, random
from datetime import datetime
from os import linesep
from pushbullet import Pushbullet
#Random Sys.Argv replacements
names = ['ubuntu-16.04.1-desktop-amd64.iso', 'Kali-Linux', 'Linux-Mind', 'dog', 'Arch-Linux']
labels = ['Movie', 'TV Show', 'Music', 'Program' ,'Game', 'eBook']
sizes = ['5000000000', '2000000000', '777758998000']
name_rand = (random.choice(names))
label_rand = (random.choice(labels))
sizes_rand = (random.choice(sizes))
#System arguements passed from qBittorrent to this script. This usually should be sys.argv[1-3] but changed for this case.
torrent_name = name_rand
torrent_category = label_rand
torrent_size = sizes_rand
qbittorrent_byte = Decimal(torrent_size)
mebibyte_divisor = Decimal(1048576)
mebibyte_value = qbittorrent_byte/mebibyte_divisor
mebibyte_string = str(round(mebibyte_value,2))
#Pushbullet Config
pb = Pushbullet("API-KEY")
iPhone = pb.devices[0]
t = time.localtime()
date_run = time.asctime(t)
#Pushbullet message templates
pb_title = torrent_category + " Download Completed"
pb_message = "Torrent: " + torrent_name + "\n" + "Size: " + mebibyte_string + " MB" + "\n" + "Label: " + torrent_category + "\n" + "Run on: " + date_run
pb_debug = date_run + "\n" + "Torrent: " + torrent_name + "\n" + "Size: " + mebibyte_string + " MB" + "\n" + "Label: " + torrent_category
def Send_Push():
push = iPhone.push_note(pb_title, pb_message)
print "PUSH sent successfully"
def write_file():
file = open("debug.txt", "a")
pb_message_debug = date_run + "\n" + "Torrent: " + torrent_name + "\n" + "Size: " + mebibyte_string + " MB" + "\n" + "Label: " + torrent_category
file.write(pb_message_debug + "\n")
file.close()
Send_Push()
write_file()
이 스크립트는 내 전화로 테스트 메시지를 보내는 데 사용할 수 있습니다. 이 파일을 바탕 화면에 저장하고 CMD를 사용하여 실행하면 내 전화로 메시지를 보내고 예정된대로 debug.txt 파일을 작성합니다.
그러나 다운로드가 완료 될 때마다 qBittorrent가 스크립트를 실행하도록 구성하면 메시지가 내 전화기로 전송되지만 debug.txt 파일에는 추가되지 않습니다.
CMD를 사용하여 스크립트를 실행하려고 할 때마다 완전히 작동합니다. 내 휴대 전화로 메시지를 보내고 debug.txt에 추가
그것은 qBittorrent은 .. 내가 거부 IO 오류 13 권한을 받고있는 이유
도움말 사람 밖으로 나의 이론이다? 모든 변경 사항을 엽니 다.