rebrand to flood

This commit is contained in:
Alon Zakai 2006-12-08 14:28:03 +00:00
parent 406135df66
commit be94dcda7a
10 changed files with 89 additions and 89 deletions

View File

@ -1,5 +1,5 @@
=================================
Installation of pytorrent
Installation of Flood
=================================
Compile: python setup.py build
@ -11,7 +11,7 @@ Dependencies to compile (written as Ubuntu packages): python, libboost-filesyste
May also depend on (not sure): python-dev, and -dev packages for all boost libs
Makefile.libtorrent-only.* are the makefiles from libtorrent, copied as it. They don't refer to pytorrent, and probably won't work in the current directory structure. However, they may help people know what dependencies etc. are needed
Makefile.libtorrent-only.* are the makefiles from libtorrent, copied as it. They don't refer to Flood, and probably won't work in the current directory structure. However, they may help people know what dependencies etc. are needed
If you find mistakes here, please notify me on the project page, www.deluge-torrent.org. Thank you.

View File

@ -18,5 +18,6 @@
*
* NOTE:The libtorrent code is copyrighted by Arvid Norberg; see the notice in
* the libtorrent files. However, to ensure no misunderstanding: the entire project
* as a whole is licenced, as mentioned above, under the GPL.
* as a whole is licenced, as mentioned above, under the GPL. Only laziness has
* prevented every single notice there from being changed from BSD to GPL.
*/

View File

@ -1,17 +1,17 @@
=================
pytorrent
Flood
=================
You may compile the code with the script 'makeit'. The
script 'installit' will install the pytorrent_core package
script 'installit' will install the flood_core package
to the central package store, so that it can be imported inside
pytorrent.py (which is required).
flood.py (which is required).
Currently the scripts do NOT copy pytorrent.py to the central
package store, as Deluge imports pytorrent.py by "import
library.pytorrent"
Currently the scripts do NOT copy flood.py to the central
package store, as Deluge imports flood.py by "import
library.flood"
You can check whether pytorrent works by running
You can check whether flood works by running
python test.py

View File

@ -1,9 +1,9 @@
Package: pytorrent
Package: flood
Version: 0.2.99-1-i386
Section: base
Priority: optional
Architecture: all
Depends: python, libboost-filesystem1.33.1, libboost-date-time1.33.1, libboost-program-options1.33.1, libboost-regex1.33.1, libboost-thread1.33.1, libc6-dev, zlib1g-dev
Maintainer: A. Zakai ('Kripken') <kripkensteiner@gmail.com>
Description: A Python wrapper for the (Sourceforge, not Rakshasa!) libtorrent C++ library.
Description: A Python module for bittorrent, based on Rasterbar's libtorrent.
URL: http://www.deluge-torrent.org

View File

@ -111,7 +111,7 @@ torrents_t *M_torrents = NULL;
// Exception types & macro
//------------------------
static PyObject *PyTorrentError = NULL;
static PyObject *FloodError = NULL;
static PyObject *InvalidEncodingError = NULL;
static PyObject *FilesystemError = NULL;
static PyObject *DuplicateTorrentError = NULL;
@ -148,7 +148,7 @@ long get_torrent_index(torrent_handle &handle)
return i;
}
RAISE_INT(PyTorrentError, "Handle not found.");
RAISE_INT(FloodError, "Handle not found.");
}
long get_index_from_unique_ID(long unique_ID)
@ -159,7 +159,7 @@ long get_index_from_unique_ID(long unique_ID)
if ((*M_torrents)[i].unique_ID == unique_ID)
return i;
RAISE_INT(PyTorrentError, "No such unique_ID.");
RAISE_INT(FloodError, "No such unique_ID.");
}
long internal_add_torrent(std::string const& torrent_name,
@ -269,7 +269,7 @@ long count_DHT_peers(entry &state)
static PyObject *torrent_pre_init(PyObject *self, PyObject *args)
{
if (!PyArg_ParseTuple(args, "OOOOO", &PyTorrentError,
if (!PyArg_ParseTuple(args, "OOOOO", &FloodError,
&InvalidEncodingError,
&FilesystemError,
&DuplicateTorrentError,
@ -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("flood_core; using libtorrent %s. Compiled with NDEBUG value: %d\r\n",
LIBTORRENT_VERSION,
NDEBUG);
@ -382,7 +382,7 @@ static PyObject *torrent_save_fastresume(PyObject *self, PyObject *args)
Py_INCREF(Py_None); return Py_None;
} else
RAISE_PTR(PyTorrentError, "Invalid handle or no metadata for fastresume.");
RAISE_PTR(FloodError, "Invalid handle or no metadata for fastresume.");
}
static PyObject *torrent_set_max_half_open(PyObject *self, PyObject *args)
@ -1118,7 +1118,7 @@ static PyObject *torrent_create_torrent(PyObject *self, PyObject *args)
{
// std::cerr << e.what() << "\n";
// return Py_BuildValue("l", 0);
RAISE_PTR(PyTorrentError, e.what());
RAISE_PTR(FloodError, e.what());
}
}
@ -1168,7 +1168,7 @@ static PyObject *torrent_apply_IP_filter(PyObject *self, PyObject *args)
// Python Module data
//====================
static PyMethodDef pytorrent_core_methods[] = {
static PyMethodDef flood_core_methods[] = {
{"pre_init", torrent_pre_init, METH_VARARGS, "."},
{"init", torrent_init, METH_VARARGS, "."},
{"quit", torrent_quit, METH_VARARGS, "."},
@ -1205,7 +1205,7 @@ static PyMethodDef pytorrent_core_methods[] = {
PyMODINIT_FUNC
initpytorrent_core(void)
initflood_core(void)
{
Py_InitModule("pytorrent_core", pytorrent_core_methods);
Py_InitModule("flood_core", flood_core_methods);
};

View File

@ -1,6 +1,5 @@
#
# Copyright (C) 2006 Alon Zakai ('Kripken') <kripkensteiner@gmail.com>
# Copyright (C) 2006 Zach Tibbitts <zach@collegegeek.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -17,14 +16,14 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# Deluge Library, a.k.a. pytorrent, previously known as python-libtorrent:
# Deluge Library, a.k.a. Flood, previously known as python-libtorrent:
#
# pytorrent is a Python library for torrenting, that includes
# pytorrent.py, which is Python code, and pytorrent_core, which is also a Python
# Flood is a Python library for torrenting, that includes
# Flood, which is Python code, and Flood_core, which is also a Python
# module, but written in C++, and includes the libtorrent torrent library. Only
# pytorrent should be visible, and only it should be imported, in the client.
# pytorrent_core contains mainly libtorrent-interfacing code, and a few other things
# that make most sense to write at that level. pytorrent.py contains all other
# Flood should be visible, and only it should be imported, in the client.
# Flood_core contains mainly libtorrent-interfacing code, and a few other things
# that make most sense to write at that level. Flood contains all other
# torrent-system management: queueing, configuration management, persistent
# list of torrents, etc.
#
@ -34,10 +33,10 @@
# 1. torrent_info - persistent data, like name, upload speed cap, etc.
# 2. core_torrent_state - transient state data from the core. This may take
# time to calculate, so we do if efficiently
# 3. supp_torrent_state - supplementary torrent data, from pytorrent
# 3. supp_torrent_state - supplementary torrent data, from Flood
import pytorrent_core
import flood_core
import os, shutil
import pickle
import time
@ -66,35 +65,35 @@ DEFAULT_PREFS = {
}
PREF_FUNCTIONS = {
"max_uploads" : pytorrent_core.set_max_uploads,
"listen_on" : pytorrent_core.set_listen_on,
"max_connections" : pytorrent_core.set_max_connections,
"max_uploads" : flood_core.set_max_uploads,
"listen_on" : flood_core.set_listen_on,
"max_connections" : flood_core.set_max_connections,
"use_DHT" : None, # not a normal pref in that is is applied only on start
"max_active_torrents" : None, # no need for a function, applied constantly
"auto_seed_ratio" : None, # no need for a function, applied constantly
"max_download_rate" : pytorrent_core.set_download_rate_limit,
"max_upload_rate" : pytorrent_core.set_upload_rate_limit
"max_download_rate" : flood_core.set_download_rate_limit,
"max_upload_rate" : flood_core.set_upload_rate_limit
}
# Exceptions
class PyTorrentError(Exception):
class FloodError(Exception):
def __init__(self, value):
self.value = value
def __str__(self):
return repr(self.value)
class InvalidEncodingError(PyTorrentError):
class InvalidEncodingError(FloodError):
pass
class FilesystemError(PyTorrentError):
class FilesystemError(FloodError):
pass
class DuplicateTorrentError(PyTorrentError):
class DuplicateTorrentError(FloodError):
pass
class InvalidTorrentError(PyTorrentError):
class InvalidTorrentError(FloodError):
pass
@ -154,22 +153,22 @@ class manager:
os.mkdir(self.base_dir + "/" + TORRENTS_SUBDIR)
# Pre-initialize the core's data structures
pytorrent_core.pre_init(PyTorrentError,
InvalidEncodingError,
FilesystemError,
DuplicateTorrentError,
InvalidTorrentError)
flood_core.pre_init(FloodError,
InvalidEncodingError,
FilesystemError,
DuplicateTorrentError,
InvalidTorrentError)
# Start up the core
assert(len(version) == 4)
pytorrent_core.init(client_ID,
int(version[0]),
int(version[1]),
int(version[2]),
int(version[3]),
user_agent)
flood_core.init(client_ID,
int(version[0]),
int(version[1]),
int(version[2]),
int(version[3]),
user_agent)
self.constants = pytorrent_core.constants()
self.constants = flood_core.constants()
# Unique IDs are NOT in the state, since they are temporary for each session
self.unique_IDs = {} # unique_ID -> a torrent_info object, i.e. persistent data
@ -199,9 +198,9 @@ class manager:
# Apply DHT, if needed. Note that this is before any torrents are added
if self.get_pref('use_DHT'):
if not blank_slate:
pytorrent_core.start_DHT(self.base_dir + "/" + DHT_FILENAME)
flood_core.start_DHT(self.base_dir + "/" + DHT_FILENAME)
else:
pytorrent_core.start_DHT("")
flood_core.start_DHT("")
# Unpickle the state, or create a new one
if not blank_slate:
@ -243,11 +242,11 @@ class manager:
# Stop DHT, if needed
if self.get_pref('use_DHT'):
print "Stopping DHT..."
pytorrent_core.stop_DHT(self.base_dir + "/" + DHT_FILENAME)
flood_core.stop_DHT(self.base_dir + "/" + DHT_FILENAME)
# Shutdown torrent core
print "Quitting the core..."
pytorrent_core.quit()
flood_core.quit()
def pre_quitting(self):
# Save the uploaded data from this session to the existing upload memory
@ -268,12 +267,12 @@ class manager:
self.prefs[key] = DEFAULT_PREFS[key]
return self.prefs[key]
else:
raise PyTorrentError("Asked for a pref that doesn't exist: " + key)
raise FloodError("Asked for a pref that doesn't exist: " + key)
def set_pref(self, key, value):
# Make sure this is a valid key
if key not in DEFAULT_PREFS.keys():
raise PyTorrentError("Asked to change a pref that isn't valid: " + key)
raise FloodError("Asked to change a pref that isn't valid: " + key)
self.prefs[key] = value
@ -290,7 +289,7 @@ class manager:
def remove_torrent(self, unique_ID, data_also):
# Save some data before we remove the torrent, needed later in this func
temp = self.unique_IDs[unique_ID]
temp_fileinfo = pytorrent_core.get_fileinfo(unique_ID)
temp_fileinfo = flood_core.get_fileinfo(unique_ID)
self.remove_torrent_ns(unique_ID)
self.sync()
@ -317,18 +316,18 @@ class manager:
# A separate function, because people may want to call it from time to time
def save_fastresume_data(self):
for unique_ID in self.unique_IDs:
pytorrent_core.save_fastresume(unique_ID, self.unique_IDs[unique_ID].filename)
flood_core.save_fastresume(unique_ID, self.unique_IDs[unique_ID].filename)
# State retrieval functions
def get_state(self):
ret = pytorrent_core.get_session_info()
ret = flood_core.get_session_info()
# Get additional data from our level
ret['is_listening'] = pytorrent_core.is_listening()
ret['port'] = pytorrent_core.listening_port()
ret['is_listening'] = flood_core.is_listening()
ret['port'] = flood_core.listening_port()
if self.get_pref('use_DHT'):
ret['DHT_nodes'] = pytorrent_core.get_DHT_info()
ret['DHT_nodes'] = flood_core.get_DHT_info()
return ret
@ -336,7 +335,7 @@ class manager:
def get_torrent_state(self, unique_ID, full=False):
ret = self.get_core_torrent_state(unique_ID, True).copy()
# Add the pytorrent-level things to the pytorrent_core data
# Add the flood-level things to the flood_core data
if self.get_supp_torrent_state(unique_ID) is not None:
ret.update(self.get_supp_torrent_state(unique_ID))
@ -402,10 +401,10 @@ class manager:
if (index < self.state.max_active_torrents or self.state_max_active_torrents == -1) \
and self.get_core_torrent_state(unique_ID, efficient)['is_paused'] \
and not self.is_user_paused(unique_ID):
pytorrent_core.resume(unique_ID)
flood_core.resume(unique_ID)
elif not self.get_core_torrent_state(unique_ID, efficient)['is_paused'] and \
(index >= self.state.max_active_torrents or self.is_user_paused(unique_ID)):
pytorrent_core.pause(unique_ID)
flood_core.pause(unique_ID)
# Event handling
@ -414,7 +413,7 @@ class manager:
# wants to do something - show messages, for example
ret = []
event = pytorrent_core.pop_event()
event = flood_core.pop_event()
while event is not None:
# print "EVENT: ", event
@ -447,7 +446,7 @@ class manager:
"tracker_messages",
new)
event = pytorrent_core.pop_event()
event = flood_core.pop_event()
return ret
@ -458,7 +457,7 @@ class manager:
self.unique_IDs[unique_ID].file_filter = file_filter[:]
pytorrent_core.set_filter_out(file_filter)
flood_core.set_filter_out(file_filter)
def get_file_filter(self, unique_ID):
try:
@ -484,7 +483,7 @@ class manager:
return self.unique_IDs[unique_ID].user_paused
def get_num_torrents(self):
return pytorrent_core.get_num_torrents()
return flood_core.get_num_torrents()
def get_unique_IDs(self):
return self.unique_IDs.keys()
@ -497,7 +496,7 @@ 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_core_torrent_states.keys():
self.saved_core_torrent_states[unique_ID] = cached_data(pytorrent_core.get_torrent_state,
self.saved_core_torrent_states[unique_ID] = cached_data(flood_core.get_torrent_state,
unique_ID)
return self.saved_core_torrent_states[unique_ID].get(efficiently)
@ -519,7 +518,7 @@ class manager:
def get_core_torrent_peer_info(self, unique_ID, efficiently=True):
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,
self.saved_torrent_peer_infos[unique_ID] = cached_data(flood_core.get_peer_info,
unique_ID)
return self.saved_torrent_peer_infos[unique_ID].get(efficiently)
@ -531,7 +530,7 @@ class manager:
(temp, filename_short) = os.path.split(filename)
if filename_short in os.listdir(self.base_dir + "/" + TORRENTS_SUBDIR):
raise PyTorrentError("Duplicate Torrent, it appears: " + filename_short)
raise FloodError("Duplicate Torrent, it appears: " + filename_short)
full_new_name = self.base_dir + "/" + TORRENTS_SUBDIR + "/" + filename_short
@ -557,7 +556,7 @@ class manager:
for torrent in self.state.torrents:
if torrent not in torrents_with_unique_ID:
# print "Adding torrent to core:", torrent.filename, torrent.save_dir, torrent.compact
unique_ID = pytorrent_core.add_torrent(torrent.filename,
unique_ID = flood_core.add_torrent(torrent.filename,
torrent.save_dir,
torrent.compact)
# print "Got unique ID:", unique_ID
@ -568,7 +567,7 @@ class manager:
to_delete = []
for torrent in self.state.torrents:
if torrent.delete_me:
pytorrent_core.remove_torrent(torrent.unique_ID, torrent.filename)
flood_core.remove_torrent(torrent.unique_ID, torrent.filename)
to_delete.append(torrent.unique_ID)
for unique_ID in to_delete:
@ -583,7 +582,7 @@ class manager:
assert(len(self.unique_IDs) == len(self.state.torrents))
assert(len(self.unique_IDs) == len(self.state.queue))
assert(len(self.unique_IDs) == pytorrent_core.get_num_torrents())
assert(len(self.unique_IDs) == flood_core.get_num_torrents())
return ret

View File

@ -30,9 +30,9 @@ import platform
pythonVersion = platform.python_version()[0:3]
print "========================================="
print "Creating pytorrent_core for Python " + pythonVersion
print "========================================="
print "====================================="
print "Creating flood_core for Python " + pythonVersion
print "====================================="
import os

View File

@ -24,7 +24,7 @@ pythonVersion = platform.python_version()[0:3]
from distutils.core import setup, Extension
module1 = Extension('pytorrent_core',
module1 = Extension('flood_core',
include_dirs = ['./include', './include/libtorrent',
'/usr/include/python' + pythonVersion],
libraries = ['boost_filesystem', 'boost_date_time',
@ -44,7 +44,7 @@ module1 = Extension('pytorrent_core',
'cpp/peer_connection.cpp',
'cpp/piece_picker.cpp',
'cpp/policy.cpp',
'cpp/pytorrent_core.cpp',
'cpp/flood_core.cpp',
'cpp/session.cpp',
'cpp/session_impl.cpp',
'cpp/sha1.cpp',
@ -66,9 +66,9 @@ module1 = Extension('pytorrent_core',
'cpp/kademlia/rpc_manager.cpp',
'cpp/kademlia/traversal_algorithm.cpp'])
setup(name = 'pytorrent_core',
setup(name = 'flood_core',
version = '0.5.0',
description = 'A module for the bittorrent protocol. Built using (Sourgeforge, not Rakshasha) libtorrent.',
description = "A module for the bittorrent protocol. Built using Rasterbar's libtorrent.",
author="Alon Zakai ('Kripken'), Zach Tibbitts",
author_email="kripkensteiner@gmail.com",
url="http://www.deluge-torrent.org",

View File

@ -9,11 +9,11 @@
#*/
import pytorrent
import flood
from time import sleep
import os
manager = pytorrent.manager("PT", "0500", "pytorrent - testing only",
manager = flood.manager("FL", "0500", "flood - testing only",
os.path.expanduser("~") + "/Temp")# blank_slate=True)
#manager.set_pref('max_upload_rate', 6*1024)

View File

@ -22,7 +22,7 @@ import time
import BaseHTTPServer
import sys, os
import pytorrent
import flood
# Constants
@ -38,7 +38,7 @@ class WebUICore:
self.running = False
def start(self):
self.manager = pytorrent.manager("DE", "0511", "Deluge WebUI",
self.manager = flood.manager("DE", "0511", "Deluge WebUI",
os.path.expanduser("~") + "/Temp")#, blank_slate=True)
self.running = True