Skip to content

Commit

Permalink
Change to os.path.dirname instead to support Python 2.7
Browse files Browse the repository at this point in the history
  • Loading branch information
isaksamsten committed Aug 13, 2020
1 parent c89595d commit c2736cc
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
4 changes: 2 additions & 2 deletions autoremovetorrents/client/deluge.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import time
from pathlib import Path
import os
from deluge_client import DelugeRPCClient
from deluge_client.client import DelugeClientException
from ..torrent import Torrent
Expand Down Expand Up @@ -131,7 +131,7 @@ def torrent_properties(self, torrent_hash):
# Set the last active time of those never active torrents to timestamp 0
torrent_obj.last_activity = torrent['time_since_transfer'] if torrent['time_since_transfer'] > 0 else 0
torrent_obj.progress = torrent['progress'] / 100 # Accept Range: 0-1
torrent_obj.root_path = Path(torrent['files'][0]['path']).parts[0]
torrent_obj.root_path = os.path.dirname(torrent['files'][0]['path'])

return torrent_obj

Expand Down
3 changes: 1 addition & 2 deletions autoremovetorrents/client/qbittorrent.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#-*- coding:utf-8 -*-
import requests
import time
from pathlib import Path
from ..torrent import Torrent
from ..torrentstatus import TorrentStatus
from ..exception.loginfailure import LoginFailure
Expand Down Expand Up @@ -204,7 +203,7 @@ def torrent_properties(self, torrent_hash):
if 'last_activity' in torrent:
torrent_obj.last_activity = torrent['last_activity']
torrent_obj.progress = torrent['progress']
torrent_obj.root_path = Path(files[0]['name']).parts[0]
torrent_obj.root_path = os.path.dirname(files[0]['name'])

return torrent_obj

Expand Down
4 changes: 2 additions & 2 deletions autoremovetorrents/client/transmission.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#-*- coding:utf-8 -*-
import requests
from pathlib import Path
import os
from ..torrent import Torrent
from ..torrentstatus import TorrentStatus
from ..exception.connectionfailure import ConnectionFailure
Expand Down Expand Up @@ -130,7 +130,7 @@ def torrent_properties(self, torrent_hash):
torrent_obj.average_upload_speed = torrent['uploadedEver'] / torrent['secondsSeeding'] if torrent['secondsSeeding'] != 0 else 0
torrent_obj.average_download_speed = torrent['downloadedEver'] / torrent['secondsDownloading'] if torrent['secondsDownloading'] != 0 else 0
torrent_obj.progress = torrent['percentDone']
torrent_obj.root_path = Path(torrent['files'][0]['name']).parts[0]
torrent_obj.root_path = os.path.dirname(torrent['files'][0]['name'])
return torrent_obj

# Judge Torrent Status
Expand Down

0 comments on commit c2736cc

Please sign in to comment.