Sep-14-2020, 09:53 PM
Hi there,
I can't figure out why my mktorrent subprocess command is failing. Any help in understanding why would be much appreciated.
Here's my code:
I can't figure out why my mktorrent subprocess command is failing. Any help in understanding why would be much appreciated.
Here's my code:
import os import subprocess target_file = "C:\\Users\\REMOVED\\python_apps\\my_progs\\test_folder\\test.test-test.mp4" temp_dest = "C:\\Users\\REMOVED\\python_apps\\my_progs" final_dest = os.path.join(temp_dest, "test_folder") print(final_dest) basename = os.path.basename(target_file) torrent_name = basename + ".torrent" print(torrent_name) filesize = float(os.path.getsize(target_file)) #print(filesize) filesize_gb = round(filesize / (1024 * 1024 * 1024), 3) #print(filesize_gb) if filesize_gb >= 16: piece_size = 24 elif filesize_gb >= 8 and filesize_gb < 16: piece_size = 23 elif filesize_gb >= 4 and filesize_gb < 8: piece_size = 22 elif filesize_gb >= 2 and filesize_gb < 4: piece_size = 21 elif filesize_gb >= 1 and filesize_gb < 2: piece_size = 20 elif filesize_gb >= 0.5 and filesize_gb < 1: piece_size = 19 elif filesize_gb >= 0.35 and filesize_gb < 0.5: piece_size = 18 elif filesize_gb >= 0.15 and filesize_gb < 0.35: piece_size = 17 elif filesize_gb >= 0.05 and filesize_gb < 0.15: piece_size = 16 elif filesize_gb <= 0.05: piece_size = 15 #print(piece_size) os.chdir(final_dest) subprocess.run('mktorrent', '-vp', '-s', 'HUH', '-l', piece_size, '-a', 'https://sometracker.org/announce.php', target_file, '-o', torrent_name, final_dest)I'm receiving this error:
Error:Traceback (most recent call last):
File "C:\Users\REMOVED\python_apps\my_progs\create_torrent\create_torrent.py", line 39, in <module>
subprocess.run('mktorrent', '-vp', '-s', 'HUH', '-l', piece_size, '-a', 'https://sometracker.org/announce.php', target_file, '-o', torrent_name, final_dest)
File "C:\Users\REMOVED\AppData\Local\Programs\Python\Python38-32\lib\subprocess.py", line 489, in run
with Popen(*popenargs, **kwargs) as process:
File "C:\Users\REMOVED\AppData\Local\Programs\Python\Python38-32\lib\subprocess.py", line 753, in __init__
raise TypeError("bufsize must be an integer")
TypeError: bufsize must be an integer
Here is the expected command and I tested in cmd with success.mktorrent -vp -s HUH -l 16 -a http://sometracker.org/announce.php test.test-test.mp4 -o test.test-test.mp4.torrent C:\Users\REMOVED\python_apps\my_progs\test_folder