Here is a small piece of code that summarizes the method on all operating systems
import sys , subprocess def open_magnet(magnet): """Open magnet according to os.""" if sys.platform.startswith('linux'): subprocess.Popen(['xdg-open', magnet], stdout=subprocess.PIPE, stderr=subprocess.PIPE) elif sys.platform.startswith('win32'): os.startfile(magnet) elif sys.platform.startswith('cygwin'): os.startfile(magnet) elif sys.platform.startswith('darwin'): subprocess.Popen(['open', magnet], stdout=subprocess.PIPE, stderr=subprocess.PIPE) else: subprocess.Popen(['xdg-open', magnet], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
source share