我從互聯網上下載了很多linux ISO種子。我已經制作了自己的小python腳本,它會向我的iPhone發送通知,告知我已完成下載的torrent的詳細信息。給我發送洪流的名稱,標籤和大小。如何在使用qBittorrent運行腳本時克服Python中的IO錯誤13
我使用了一個名爲Pushbullet.py的python庫來將通知發送到我的手機。
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權限..
幫助一個人了呢?打開以進行任何更改..