mirror of
https://git.deluge-torrent.org/deluge
synced 2025-04-20 11:35:49 +00:00
new .cpp directory
This commit is contained in:
parent
460dfd76a5
commit
406135df66
38 changed files with 53 additions and 46 deletions
|
@ -281,7 +281,7 @@ static PyObject *torrent_pre_init(PyObject *self, PyObject *args)
|
|||
|
||||
static PyObject *torrent_init(PyObject *self, PyObject *args)
|
||||
{
|
||||
printf("pytorrent_core, using libtorrent %s. Compiled with NDEBUG value: %d\r\n",
|
||||
printf("pytorrent_core; using libtorrent %s. Compiled with NDEBUG value: %d\r\n",
|
||||
LIBTORRENT_VERSION,
|
||||
NDEBUG);
|
||||
|
||||
|
@ -336,12 +336,17 @@ static PyObject *torrent_init(PyObject *self, PyObject *args)
|
|||
|
||||
static PyObject *torrent_quit(PyObject *self, PyObject *args)
|
||||
{
|
||||
printf("core: shutting down session...\r\n");
|
||||
delete M_ses; // SLOWPOKE because of waiting for the trackers before shutting down
|
||||
printf("core: removing settings...\r\n");
|
||||
delete M_settings;
|
||||
printf("core: removing torrents...\r\n");
|
||||
delete M_torrents;
|
||||
|
||||
Py_DECREF(M_constants);
|
||||
|
||||
printf("core shut down.\r\n");
|
||||
|
||||
Py_INCREF(Py_None); return Py_None;
|
||||
};
|
||||
|
||||
|
@ -813,22 +818,22 @@ static PyObject *torrent_get_peer_info(PyObject *self, PyObject *args)
|
|||
M_torrents->at(index).handle.get_peer_info(peers);
|
||||
|
||||
PyObject *peer_info;
|
||||
|
||||
PyObject *ret = PyTuple_New(peers.size());
|
||||
PyObject *curr_piece, *py_pieces;
|
||||
|
||||
for (unsigned long i = 0; i < peers.size(); i++)
|
||||
{
|
||||
std::vector<bool> &pieces = peers[i].pieces;
|
||||
unsigned long pieces_had = 0;
|
||||
|
||||
PyObject *py_pieces = PyTuple_New(pieces.size());
|
||||
py_pieces = PyTuple_New(pieces.size());
|
||||
|
||||
for (unsigned long piece = 0; piece < pieces.size(); piece++)
|
||||
{
|
||||
if (pieces[piece])
|
||||
pieces_had++;
|
||||
|
||||
curr_piece = Py_BuildValue("i", pieces[piece]);
|
||||
curr_piece = Py_BuildValue("i", long(pieces[piece]));
|
||||
PyTuple_SetItem(py_pieces, piece, curr_piece);
|
||||
}
|
||||
|
|
@ -110,7 +110,7 @@ class cached_data:
|
|||
def get(self, efficiently=True):
|
||||
if self.timestamp == -1 or time.time() > self.timestamp + CACHED_DATA_EXPIRATION or \
|
||||
not efficiently:
|
||||
self.data = self.get_method(key)
|
||||
self.data = self.get_method(self.key)
|
||||
self.timestamp = time.time()
|
||||
|
||||
return self.data
|
||||
|
@ -127,8 +127,6 @@ class torrent_info:
|
|||
self.user_paused = False # start out unpaused
|
||||
self.uploaded_memory = 0
|
||||
|
||||
self.file_filter = []
|
||||
|
||||
self.delete_me = False # set this to true, to delete it on next sync
|
||||
|
||||
|
||||
|
@ -472,7 +470,7 @@ class manager:
|
|||
def apply_all_file_filters(self):
|
||||
for unique_ID in self.unique_IDs.keys():
|
||||
try:
|
||||
self.set_file_filter(self.unique_IDs[unique_ID].file_filter)
|
||||
self.set_file_filter(unique_ID, self.unique_IDs[unique_ID].file_filter)
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
|
@ -498,11 +496,11 @@ class manager:
|
|||
|
||||
# Efficient: use a saved state, if it hasn't expired yet
|
||||
def get_core_torrent_state(self, unique_ID, efficiently=True):
|
||||
if unique_ID not in self.saved_torrent_states.keys()
|
||||
self.saved_torrent_states[unique_ID] = cached_data(pytorrent_core.get_torrent_state,
|
||||
if unique_ID not in self.saved_core_torrent_states.keys():
|
||||
self.saved_core_torrent_states[unique_ID] = cached_data(pytorrent_core.get_torrent_state,
|
||||
unique_ID)
|
||||
|
||||
return self.saved_torrent_states[unique_ID].get(efficiently)
|
||||
return self.saved_core_torrent_states[unique_ID].get(efficiently)
|
||||
|
||||
def get_supp_torrent_state(self, unique_ID):
|
||||
try:
|
||||
|
@ -520,7 +518,7 @@ class manager:
|
|||
self.supp_torrent_states[unique_ID][key] = val
|
||||
|
||||
def get_core_torrent_peer_info(self, unique_ID, efficiently=True):
|
||||
if unique_ID not in self.saved_torrent_peer_infos.keys()
|
||||
if unique_ID not in self.saved_torrent_peer_infos.keys():
|
||||
self.saved_torrent_peer_infos[unique_ID] = cached_data(pytorrent_core.get_peer_info,
|
||||
unique_ID)
|
||||
|
||||
|
@ -614,5 +612,7 @@ class manager:
|
|||
return ret
|
||||
|
||||
def calc_availability(self, unique_ID):
|
||||
pass
|
||||
|
||||
def calc_swarm_speed(self, unique_ID):
|
||||
pass
|
||||
|
|
|
@ -54,6 +54,8 @@ for line in data:
|
|||
p.close()
|
||||
|
||||
print ""
|
||||
# else:
|
||||
# print "NOT DOING: ", line
|
||||
|
||||
# Now redo it, for real. Nothing should occur, except for installation, if requested
|
||||
print "Finalizing..."
|
||||
|
|
|
@ -32,39 +32,39 @@ module1 = Extension('pytorrent_core',
|
|||
'boost_serialization', 'boost_thread', 'z', 'pthread'],
|
||||
extra_compile_args = ["-Wno-missing-braces"],
|
||||
# extra_link_args = [""],
|
||||
sources = ['alert.cpp',
|
||||
'allocate_resources.cpp',
|
||||
'bt_peer_connection.cpp',
|
||||
'entry.cpp',
|
||||
'escape_string.cpp',
|
||||
'file.cpp',
|
||||
'http_tracker_connection.cpp',
|
||||
'identify_client.cpp',
|
||||
'ip_filter.cpp',
|
||||
'peer_connection.cpp',
|
||||
'piece_picker.cpp',
|
||||
'policy.cpp',
|
||||
'pytorrent_core.cpp',
|
||||
'session.cpp',
|
||||
'session_impl.cpp',
|
||||
'sha1.cpp',
|
||||
'stat.cpp',
|
||||
'storage.cpp',
|
||||
'torrent.cpp',
|
||||
'torrent_handle.cpp',
|
||||
'torrent_info.cpp',
|
||||
'tracker_manager.cpp',
|
||||
'udp_tracker_connection.cpp',
|
||||
'web_peer_connection.cpp',
|
||||
'./kademlia/closest_nodes.cpp',
|
||||
'./kademlia/dht_tracker.cpp',
|
||||
'./kademlia/find_data.cpp',
|
||||
'./kademlia/node.cpp',
|
||||
'./kademlia/node_id.cpp',
|
||||
'./kademlia/refresh.cpp',
|
||||
'./kademlia/routing_table.cpp',
|
||||
'./kademlia/rpc_manager.cpp',
|
||||
'./kademlia/traversal_algorithm.cpp'])
|
||||
sources = ['cpp/alert.cpp',
|
||||
'cpp/allocate_resources.cpp',
|
||||
'cpp/bt_peer_connection.cpp',
|
||||
'cpp/entry.cpp',
|
||||
'cpp/escape_string.cpp',
|
||||
'cpp/file.cpp',
|
||||
'cpp/http_tracker_connection.cpp',
|
||||
'cpp/identify_client.cpp',
|
||||
'cpp/ip_filter.cpp',
|
||||
'cpp/peer_connection.cpp',
|
||||
'cpp/piece_picker.cpp',
|
||||
'cpp/policy.cpp',
|
||||
'cpp/pytorrent_core.cpp',
|
||||
'cpp/session.cpp',
|
||||
'cpp/session_impl.cpp',
|
||||
'cpp/sha1.cpp',
|
||||
'cpp/stat.cpp',
|
||||
'cpp/storage.cpp',
|
||||
'cpp/torrent.cpp',
|
||||
'cpp/torrent_handle.cpp',
|
||||
'cpp/torrent_info.cpp',
|
||||
'cpp/tracker_manager.cpp',
|
||||
'cpp/udp_tracker_connection.cpp',
|
||||
'cpp/web_peer_connection.cpp',
|
||||
'cpp/kademlia/closest_nodes.cpp',
|
||||
'cpp/kademlia/dht_tracker.cpp',
|
||||
'cpp/kademlia/find_data.cpp',
|
||||
'cpp/kademlia/node.cpp',
|
||||
'cpp/kademlia/node_id.cpp',
|
||||
'cpp/kademlia/refresh.cpp',
|
||||
'cpp/kademlia/routing_table.cpp',
|
||||
'cpp/kademlia/rpc_manager.cpp',
|
||||
'cpp/kademlia/traversal_algorithm.cpp'])
|
||||
|
||||
setup(name = 'pytorrent_core',
|
||||
version = '0.5.0',
|
||||
|
|
|
@ -14,7 +14,7 @@ from time import sleep
|
|||
import os
|
||||
|
||||
manager = pytorrent.manager("PT", "0500", "pytorrent - testing only",
|
||||
os.path.expanduser("~") + "/Temp")#, blank_slate=True)
|
||||
os.path.expanduser("~") + "/Temp")# blank_slate=True)
|
||||
|
||||
#manager.set_pref('max_upload_rate', 6*1024)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue