Параметры поддержки раздачи и приёма соединений пиров

master v1.1.1
Роман Бородин 2022-04-30 20:19:28 +03:00
parent 3a3c9743a6
commit 3d44da9baa
8 changed files with 13 additions and 4078 deletions

View File

@ -61,6 +61,8 @@ func (o *Engine) StartTorrent(idx int64) error {
o.torrCfg = torrent.NewDefaultClientConfig() o.torrCfg = torrent.NewDefaultClientConfig()
o.torrCfg.ListenPort = o.settings.ListenPort o.torrCfg.ListenPort = o.settings.ListenPort
o.torrCfg.DataDir = o.settings.DownloadPath o.torrCfg.DataDir = o.settings.DownloadPath
o.torrCfg.Seed = o.settings.Seed
o.torrCfg.AcceptPeerConnections = o.settings.AcceptPeerConnections
o.torrCfg.DefaultStorage = storage.NewFileWithCompletion(o.settings.DownloadPath, storage.NewMapPieceCompletion()) o.torrCfg.DefaultStorage = storage.NewFileWithCompletion(o.settings.DownloadPath, storage.NewMapPieceCompletion())
if o.settings.Proxy != "" { if o.settings.Proxy != "" {

View File

@ -1,33 +0,0 @@
# Makefile for python interface for package gorrent.
# File is generated by gopy. Do not edit.
# gopy gen --output=py/gorrent gorrent
GOCMD=go
GOBUILD=$(GOCMD) build -mod=mod
GOIMPORTS=goimports
PYTHON=env python3
LIBEXT=.so
# get the CC and flags used to build python:
GCC = $(shell $(GOCMD) env CC)
CFLAGS = $(shell python3-config --includes)
LDFLAGS = -L/usr/lib64 $(BOOST_ROOT)/stage/lib/libboost_python*.a -lpthread -ldl -lutil -lm -lm
all: build
build:
# build target builds the generated files -- this is what gopy build does..
# this will otherwise be built during go build and may be out of date
- rm -f gorrent.c
# goimports is needed to ensure that the imports list is valid
$(GOIMPORTS) -w gorrent.go
# generate gorrent_go$(LIBEXT) from gorrent.go -- the cgo wrappers to go functions
$(GOBUILD) -buildmode=c-archive -o gorrent_go.a gorrent.go
# use pybindgen to build the gorrent.c file which are the CPython wrappers to cgo wrappers..
# note: pip install pybindgen to get pybindgen if this fails
$(PYTHON) build.py
# build the _gorrent$(LIBEXT) library that contains the cgo and CPython wrappers
# generated gorrent.py python wrapper imports this c-code package
$(GCC) gorrent.c gorrent_go.a -o _gorrent$(LIBEXT) $(CFLAGS) $(LDFLAGS) -fPIC --shared -w

View File

View File

@ -1,216 +0,0 @@
# python build stubs for package gorrent
# File is generated by gopy. Do not edit.
# gopy gen --output=py/gorrent gorrent
from pybindgen import retval, param, Function, Module
import sys
class CheckedFunction(Function):
def __init__(self, *a, **kw):
super(CheckedFunction, self).__init__(*a, **kw)
self._failure_expression = kw.get('failure_expression', '')
self._failure_cleanup = kw.get('failure_cleanup', '')
def set_failure_expression(self, expr):
self._failure_expression = expr
def set_failure_cleanup(self, expr):
self._failure_cleanup = expr
def generate_call(self):
super(CheckedFunction, self).generate_call()
check = "PyErr_Occurred()"
if self._failure_expression:
check = "{} && {}".format(self._failure_expression, check)
failure_cleanup = self._failure_cleanup or None
self.before_call.write_error_check(check, failure_cleanup)
def add_checked_function(mod, name, retval, params, failure_expression='', *a, **kw):
fn = CheckedFunction(name, retval, params, *a, **kw)
fn.set_failure_expression(failure_expression)
mod._add_function_obj(fn)
return fn
def add_checked_string_function(mod, name, retval, params, failure_expression='', *a, **kw):
fn = CheckedFunction(name, retval, params, *a, **kw)
fn.set_failure_cleanup('if (retval != NULL) free(retval);')
fn.after_call.add_cleanup_code('free(retval);')
fn.set_failure_expression(failure_expression)
mod._add_function_obj(fn)
return fn
mod = Module('_gorrent')
mod.add_include('"gorrent_go.h"')
mod.add_function('GoPyInit', None, [])
mod.add_function('DecRef', None, [param('int64_t', 'handle')])
mod.add_function('IncRef', None, [param('int64_t', 'handle')])
mod.add_function('NumHandles', retval('int'), [])
mod.add_function('Slice_bool_CTor', retval('int64_t'), [])
mod.add_function('Slice_bool_len', retval('int'), [param('int64_t', 'handle')])
mod.add_function('Slice_bool_elem', retval('bool'), [param('int64_t', 'handle'), param('int', 'idx')])
mod.add_function('Slice_bool_subslice', retval('int64_t'), [param('int64_t', 'handle'), param('int', 'st'), param('int', 'ed')])
mod.add_function('Slice_bool_set', None, [param('int64_t', 'handle'), param('int', 'idx'), param('bool', 'value')])
mod.add_function('Slice_bool_append', None, [param('int64_t', 'handle'), param('bool', 'value')])
mod.add_function('Slice_byte_CTor', retval('int64_t'), [])
mod.add_function('Slice_byte_len', retval('int'), [param('int64_t', 'handle')])
mod.add_function('Slice_byte_elem', retval('uint8_t'), [param('int64_t', 'handle'), param('int', 'idx')])
mod.add_function('Slice_byte_subslice', retval('int64_t'), [param('int64_t', 'handle'), param('int', 'st'), param('int', 'ed')])
mod.add_function('Slice_byte_set', None, [param('int64_t', 'handle'), param('int', 'idx'), param('uint8_t', 'value')])
mod.add_function('Slice_byte_append', None, [param('int64_t', 'handle'), param('uint8_t', 'value')])
mod.add_function('Slice_float32_CTor', retval('int64_t'), [])
mod.add_function('Slice_float32_len', retval('int'), [param('int64_t', 'handle')])
mod.add_function('Slice_float32_elem', retval('float'), [param('int64_t', 'handle'), param('int', 'idx')])
mod.add_function('Slice_float32_subslice', retval('int64_t'), [param('int64_t', 'handle'), param('int', 'st'), param('int', 'ed')])
mod.add_function('Slice_float32_set', None, [param('int64_t', 'handle'), param('int', 'idx'), param('float', 'value')])
mod.add_function('Slice_float32_append', None, [param('int64_t', 'handle'), param('float', 'value')])
mod.add_function('Slice_float64_CTor', retval('int64_t'), [])
mod.add_function('Slice_float64_len', retval('int'), [param('int64_t', 'handle')])
mod.add_function('Slice_float64_elem', retval('double'), [param('int64_t', 'handle'), param('int', 'idx')])
mod.add_function('Slice_float64_subslice', retval('int64_t'), [param('int64_t', 'handle'), param('int', 'st'), param('int', 'ed')])
mod.add_function('Slice_float64_set', None, [param('int64_t', 'handle'), param('int', 'idx'), param('double', 'value')])
mod.add_function('Slice_float64_append', None, [param('int64_t', 'handle'), param('double', 'value')])
mod.add_function('Slice_int_CTor', retval('int64_t'), [])
mod.add_function('Slice_int_len', retval('int'), [param('int64_t', 'handle')])
mod.add_function('Slice_int_elem', retval('int64_t'), [param('int64_t', 'handle'), param('int', 'idx')])
mod.add_function('Slice_int_subslice', retval('int64_t'), [param('int64_t', 'handle'), param('int', 'st'), param('int', 'ed')])
mod.add_function('Slice_int_set', None, [param('int64_t', 'handle'), param('int', 'idx'), param('int64_t', 'value')])
mod.add_function('Slice_int_append', None, [param('int64_t', 'handle'), param('int64_t', 'value')])
mod.add_function('Slice_int16_CTor', retval('int64_t'), [])
mod.add_function('Slice_int16_len', retval('int'), [param('int64_t', 'handle')])
mod.add_function('Slice_int16_elem', retval('int16_t'), [param('int64_t', 'handle'), param('int', 'idx')])
mod.add_function('Slice_int16_subslice', retval('int64_t'), [param('int64_t', 'handle'), param('int', 'st'), param('int', 'ed')])
mod.add_function('Slice_int16_set', None, [param('int64_t', 'handle'), param('int', 'idx'), param('int16_t', 'value')])
mod.add_function('Slice_int16_append', None, [param('int64_t', 'handle'), param('int16_t', 'value')])
mod.add_function('Slice_int32_CTor', retval('int64_t'), [])
mod.add_function('Slice_int32_len', retval('int'), [param('int64_t', 'handle')])
mod.add_function('Slice_int32_elem', retval('int32_t'), [param('int64_t', 'handle'), param('int', 'idx')])
mod.add_function('Slice_int32_subslice', retval('int64_t'), [param('int64_t', 'handle'), param('int', 'st'), param('int', 'ed')])
mod.add_function('Slice_int32_set', None, [param('int64_t', 'handle'), param('int', 'idx'), param('int32_t', 'value')])
mod.add_function('Slice_int32_append', None, [param('int64_t', 'handle'), param('int32_t', 'value')])
mod.add_function('Slice_int64_CTor', retval('int64_t'), [])
mod.add_function('Slice_int64_len', retval('int'), [param('int64_t', 'handle')])
mod.add_function('Slice_int64_elem', retval('int64_t'), [param('int64_t', 'handle'), param('int', 'idx')])
mod.add_function('Slice_int64_subslice', retval('int64_t'), [param('int64_t', 'handle'), param('int', 'st'), param('int', 'ed')])
mod.add_function('Slice_int64_set', None, [param('int64_t', 'handle'), param('int', 'idx'), param('int64_t', 'value')])
mod.add_function('Slice_int64_append', None, [param('int64_t', 'handle'), param('int64_t', 'value')])
mod.add_function('Slice_int8_CTor', retval('int64_t'), [])
mod.add_function('Slice_int8_len', retval('int'), [param('int64_t', 'handle')])
mod.add_function('Slice_int8_elem', retval('int8_t'), [param('int64_t', 'handle'), param('int', 'idx')])
mod.add_function('Slice_int8_subslice', retval('int64_t'), [param('int64_t', 'handle'), param('int', 'st'), param('int', 'ed')])
mod.add_function('Slice_int8_set', None, [param('int64_t', 'handle'), param('int', 'idx'), param('int8_t', 'value')])
mod.add_function('Slice_int8_append', None, [param('int64_t', 'handle'), param('int8_t', 'value')])
mod.add_function('Slice_rune_CTor', retval('int64_t'), [])
mod.add_function('Slice_rune_len', retval('int'), [param('int64_t', 'handle')])
mod.add_function('Slice_rune_elem', retval('int32_t'), [param('int64_t', 'handle'), param('int', 'idx')])
mod.add_function('Slice_rune_subslice', retval('int64_t'), [param('int64_t', 'handle'), param('int', 'st'), param('int', 'ed')])
mod.add_function('Slice_rune_set', None, [param('int64_t', 'handle'), param('int', 'idx'), param('int32_t', 'value')])
mod.add_function('Slice_rune_append', None, [param('int64_t', 'handle'), param('int32_t', 'value')])
mod.add_function('Slice_string_CTor', retval('int64_t'), [])
mod.add_function('Slice_string_len', retval('int'), [param('int64_t', 'handle')])
mod.add_function('Slice_string_elem', retval('char*'), [param('int64_t', 'handle'), param('int', 'idx')])
mod.add_function('Slice_string_subslice', retval('int64_t'), [param('int64_t', 'handle'), param('int', 'st'), param('int', 'ed')])
mod.add_function('Slice_string_set', None, [param('int64_t', 'handle'), param('int', 'idx'), param('char*', 'value')])
mod.add_function('Slice_string_append', None, [param('int64_t', 'handle'), param('char*', 'value')])
mod.add_function('Slice_uint_CTor', retval('int64_t'), [])
mod.add_function('Slice_uint_len', retval('int'), [param('int64_t', 'handle')])
mod.add_function('Slice_uint_elem', retval('uint64_t'), [param('int64_t', 'handle'), param('int', 'idx')])
mod.add_function('Slice_uint_subslice', retval('int64_t'), [param('int64_t', 'handle'), param('int', 'st'), param('int', 'ed')])
mod.add_function('Slice_uint_set', None, [param('int64_t', 'handle'), param('int', 'idx'), param('uint64_t', 'value')])
mod.add_function('Slice_uint_append', None, [param('int64_t', 'handle'), param('uint64_t', 'value')])
mod.add_function('Slice_uint16_CTor', retval('int64_t'), [])
mod.add_function('Slice_uint16_len', retval('int'), [param('int64_t', 'handle')])
mod.add_function('Slice_uint16_elem', retval('uint16_t'), [param('int64_t', 'handle'), param('int', 'idx')])
mod.add_function('Slice_uint16_subslice', retval('int64_t'), [param('int64_t', 'handle'), param('int', 'st'), param('int', 'ed')])
mod.add_function('Slice_uint16_set', None, [param('int64_t', 'handle'), param('int', 'idx'), param('uint16_t', 'value')])
mod.add_function('Slice_uint16_append', None, [param('int64_t', 'handle'), param('uint16_t', 'value')])
mod.add_function('Slice_uint32_CTor', retval('int64_t'), [])
mod.add_function('Slice_uint32_len', retval('int'), [param('int64_t', 'handle')])
mod.add_function('Slice_uint32_elem', retval('uint32_t'), [param('int64_t', 'handle'), param('int', 'idx')])
mod.add_function('Slice_uint32_subslice', retval('int64_t'), [param('int64_t', 'handle'), param('int', 'st'), param('int', 'ed')])
mod.add_function('Slice_uint32_set', None, [param('int64_t', 'handle'), param('int', 'idx'), param('uint32_t', 'value')])
mod.add_function('Slice_uint32_append', None, [param('int64_t', 'handle'), param('uint32_t', 'value')])
mod.add_function('Slice_uint64_CTor', retval('int64_t'), [])
mod.add_function('Slice_uint64_len', retval('int'), [param('int64_t', 'handle')])
mod.add_function('Slice_uint64_elem', retval('uint64_t'), [param('int64_t', 'handle'), param('int', 'idx')])
mod.add_function('Slice_uint64_subslice', retval('int64_t'), [param('int64_t', 'handle'), param('int', 'st'), param('int', 'ed')])
mod.add_function('Slice_uint64_set', None, [param('int64_t', 'handle'), param('int', 'idx'), param('uint64_t', 'value')])
mod.add_function('Slice_uint64_append', None, [param('int64_t', 'handle'), param('uint64_t', 'value')])
mod.add_function('Slice_uint8_CTor', retval('int64_t'), [])
mod.add_function('Slice_uint8_len', retval('int'), [param('int64_t', 'handle')])
mod.add_function('Slice_uint8_elem', retval('uint8_t'), [param('int64_t', 'handle'), param('int', 'idx')])
mod.add_function('Slice_uint8_subslice', retval('int64_t'), [param('int64_t', 'handle'), param('int', 'st'), param('int', 'ed')])
mod.add_function('Slice_uint8_set', None, [param('int64_t', 'handle'), param('int', 'idx'), param('uint8_t', 'value')])
mod.add_function('Slice_uint8_append', None, [param('int64_t', 'handle'), param('uint8_t', 'value')])
mod.add_function('Slice_Ptr_gorrent_FileInfo_CTor', retval('int64_t'), [])
mod.add_function('Slice_Ptr_gorrent_FileInfo_len', retval('int'), [param('int64_t', 'handle')])
mod.add_function('Slice_Ptr_gorrent_FileInfo_elem', retval('int64_t'), [param('int64_t', 'handle'), param('int', 'idx')])
mod.add_function('Slice_Ptr_gorrent_FileInfo_subslice', retval('int64_t'), [param('int64_t', 'handle'), param('int', 'st'), param('int', 'ed')])
mod.add_function('Slice_Ptr_gorrent_FileInfo_set', None, [param('int64_t', 'handle'), param('int', 'idx'), param('int64_t', 'value')])
mod.add_function('Slice_Ptr_gorrent_FileInfo_append', None, [param('int64_t', 'handle'), param('int64_t', 'value')])
mod.add_function('gorrent_Settings_CTor', retval('int64_t'), [])
mod.add_function('gorrent_Settings_DownloadPath_Get', retval('char*'), [param('int64_t', 'handle')])
mod.add_function('gorrent_Settings_DownloadPath_Set', None, [param('int64_t', 'handle'), param('char*', 'val')])
mod.add_function('gorrent_Settings_HttpBindHost_Get', retval('char*'), [param('int64_t', 'handle')])
mod.add_function('gorrent_Settings_HttpBindHost_Set', None, [param('int64_t', 'handle'), param('char*', 'val')])
mod.add_function('gorrent_Settings_HttpBindPort_Get', retval('int64_t'), [param('int64_t', 'handle')])
mod.add_function('gorrent_Settings_HttpBindPort_Set', None, [param('int64_t', 'handle'), param('int64_t', 'val')])
mod.add_function('gorrent_Settings_ListenPort_Get', retval('int64_t'), [param('int64_t', 'handle')])
mod.add_function('gorrent_Settings_ListenPort_Set', None, [param('int64_t', 'handle'), param('int64_t', 'val')])
mod.add_function('gorrent_Settings_MaxConnections_Get', retval('int64_t'), [param('int64_t', 'handle')])
mod.add_function('gorrent_Settings_MaxConnections_Set', None, [param('int64_t', 'handle'), param('int64_t', 'val')])
mod.add_function('gorrent_Settings_TorrentPath_Get', retval('char*'), [param('int64_t', 'handle')])
mod.add_function('gorrent_Settings_TorrentPath_Set', None, [param('int64_t', 'handle'), param('char*', 'val')])
mod.add_function('gorrent_Settings_Proxy_Get', retval('char*'), [param('int64_t', 'handle')])
mod.add_function('gorrent_Settings_Proxy_Set', None, [param('int64_t', 'handle'), param('char*', 'val')])
mod.add_function('gorrent_Settings_KeepFiles_Get', retval('bool'), [param('int64_t', 'handle')])
mod.add_function('gorrent_Settings_KeepFiles_Set', None, [param('int64_t', 'handle'), param('bool', 'val')])
mod.add_function('gorrent_Settings_Debug_Get', retval('bool'), [param('int64_t', 'handle')])
mod.add_function('gorrent_Settings_Debug_Set', None, [param('int64_t', 'handle'), param('bool', 'val')])
mod.add_function('gorrent_TorrentStatus_CTor', retval('int64_t'), [])
mod.add_function('gorrent_TorrentStatus_DownloadRate_Get', retval('int64_t'), [param('int64_t', 'handle')])
mod.add_function('gorrent_TorrentStatus_DownloadRate_Set', None, [param('int64_t', 'handle'), param('int64_t', 'val')])
mod.add_function('gorrent_TorrentStatus_UploadRate_Get', retval('int64_t'), [param('int64_t', 'handle')])
mod.add_function('gorrent_TorrentStatus_UploadRate_Set', None, [param('int64_t', 'handle'), param('int64_t', 'val')])
mod.add_function('gorrent_TorrentStatus_Seeds_Get', retval('int64_t'), [param('int64_t', 'handle')])
mod.add_function('gorrent_TorrentStatus_Seeds_Set', None, [param('int64_t', 'handle'), param('int64_t', 'val')])
mod.add_function('gorrent_Engine_CTor', retval('int64_t'), [])
add_checked_function(mod, 'gorrent_Engine_IsAlive', retval('bool'), [param('int64_t', '_handle')])
add_checked_function(mod, 'gorrent_Engine_StartTorrent', retval('char*'), [param('int64_t', '_handle'), param('int64_t', 'idx')])
add_checked_function(mod, 'gorrent_Engine_Status', retval('int64_t'), [param('int64_t', '_handle')])
add_checked_function(mod, 'gorrent_Engine_FileStatus', retval('int64_t'), [param('int64_t', '_handle'), param('int64_t', 'i')])
add_checked_function(mod, 'gorrent_Engine_Stop', None, [param('int64_t', '_handle'), param('bool', 'goRun')])
add_checked_string_function(mod, 'gorrent_Engine_GetMsg', retval('char*'), [param('int64_t', '_handle')])
add_checked_function(mod, 'gorrent_Engine_Clean', None, [param('int64_t', '_handle'), param('bool', 'goRun')])
mod.add_function('gorrent_FileInfo_CTor', retval('int64_t'), [])
mod.add_function('gorrent_FileInfo_Length_Get', retval('int64_t'), [param('int64_t', 'handle')])
mod.add_function('gorrent_FileInfo_Length_Set', None, [param('int64_t', 'handle'), param('int64_t', 'val')])
mod.add_function('gorrent_FileInfo_Path_Get', retval('int64_t'), [param('int64_t', 'handle')])
mod.add_function('gorrent_FileInfo_Path_Set', None, [param('int64_t', 'handle'), param('int64_t', 'val')])
mod.add_function('gorrent_FileInfo_PathUTF8_Get', retval('int64_t'), [param('int64_t', 'handle')])
mod.add_function('gorrent_FileInfo_PathUTF8_Set', None, [param('int64_t', 'handle'), param('int64_t', 'val')])
mod.add_function('gorrent_FileStatus_CTor', retval('int64_t'), [])
mod.add_function('gorrent_FileStatus_Name_Get', retval('char*'), [param('int64_t', 'handle')])
mod.add_function('gorrent_FileStatus_Name_Set', None, [param('int64_t', 'handle'), param('char*', 'val')])
mod.add_function('gorrent_FileStatus_Url_Get', retval('char*'), [param('int64_t', 'handle')])
mod.add_function('gorrent_FileStatus_Url_Set', None, [param('int64_t', 'handle'), param('char*', 'val')])
mod.add_function('gorrent_FileStatus_Progress_Get', retval('int64_t'), [param('int64_t', 'handle')])
mod.add_function('gorrent_FileStatus_Progress_Set', None, [param('int64_t', 'handle'), param('int64_t', 'val')])
mod.add_function('gorrent_FileStatus_Length_Get', retval('int64_t'), [param('int64_t', 'handle')])
mod.add_function('gorrent_FileStatus_Length_Set', None, [param('int64_t', 'handle'), param('int64_t', 'val')])
mod.add_function('gorrent_Info_CTor', retval('int64_t'), [])
mod.add_function('gorrent_Info_Name_Get', retval('char*'), [param('int64_t', 'handle')])
mod.add_function('gorrent_Info_Name_Set', None, [param('int64_t', 'handle'), param('char*', 'val')])
mod.add_function('gorrent_Info_Length_Get', retval('int64_t'), [param('int64_t', 'handle')])
mod.add_function('gorrent_Info_Length_Set', None, [param('int64_t', 'handle'), param('int64_t', 'val')])
mod.add_function('gorrent_Info_Source_Get', retval('char*'), [param('int64_t', 'handle')])
mod.add_function('gorrent_Info_Source_Set', None, [param('int64_t', 'handle'), param('char*', 'val')])
mod.add_function('gorrent_Info_Files_Get', retval('int64_t'), [param('int64_t', 'handle')])
mod.add_function('gorrent_Info_Files_Set', None, [param('int64_t', 'handle'), param('int64_t', 'val')])
add_checked_function(mod, 'gorrent_Info_LoadFile', retval('char*'), [param('int64_t', '_handle'), param('char*', 'path')])
add_checked_function(mod, 'gorrent_NewSettings', retval('int64_t'), [])
add_checked_function(mod, 'gorrent_NewEngine', retval('int64_t'), [param('int64_t', 'settings')])
add_checked_function(mod, 'gorrent_GetMetaFromFile', retval('int64_t'), [param('char*', 'path')])
add_checked_string_function(mod, 'gorrent_Version', retval('char*'), [])
mod.generate(open('gorrent.c', 'w'))

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,723 +0,0 @@
# python wrapper for package gorrent within overall package gorrent
# This is what you import to use the package.
# File is generated by gopy. Do not edit.
# gopy gen --output=py/gorrent gorrent
# the following is required to enable dlopen to open the _go.so file
import os,sys,inspect,collections
try:
import collections.abc as _collections_abc
except ImportError:
_collections_abc = collections
cwd = os.getcwd()
currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
os.chdir(currentdir)
from . import _gorrent
from . import go
os.chdir(cwd)
# to use this code in your end-user python file, import it as follows:
# from gorrent import gorrent
# and then refer to everything using gorrent. prefix
# packages imported by this package listed below:
# ---- Types ---
# Python type for slice []*gorrent.FileInfo
class Slice_Ptr_gorrent_FileInfo(go.GoClass):
""""""
def __init__(self, *args, **kwargs):
"""
handle=A Go-side object is always initialized with an explicit handle=arg
otherwise parameter is a python list that we copy from
"""
self.index = 0
if len(kwargs) == 1 and 'handle' in kwargs:
self.handle = kwargs['handle']
_gorrent.IncRef(self.handle)
elif len(args) == 1 and isinstance(args[0], go.GoClass):
self.handle = args[0].handle
_gorrent.IncRef(self.handle)
else:
self.handle = _gorrent.Slice_Ptr_gorrent_FileInfo_CTor()
_gorrent.IncRef(self.handle)
if len(args) > 0:
if not isinstance(args[0], _collections_abc.Iterable):
raise TypeError('Slice_Ptr_gorrent_FileInfo.__init__ takes a sequence as argument')
for elt in args[0]:
self.append(elt)
def __del__(self):
_gorrent.DecRef(self.handle)
def __str__(self):
s = 'gorrent.Slice_Ptr_gorrent_FileInfo len: ' + str(len(self)) + ' handle: ' + str(self.handle) + ' ['
if len(self) < 120:
s += ', '.join(map(str, self)) + ']'
return s
def __repr__(self):
return 'gorrent.Slice_Ptr_gorrent_FileInfo([' + ', '.join(map(str, self)) + '])'
def __len__(self):
return _gorrent.Slice_Ptr_gorrent_FileInfo_len(self.handle)
def __getitem__(self, key):
if isinstance(key, slice):
if key.step == None or key.step == 1:
st = key.start
ed = key.stop
if st == None:
st = 0
if ed == None:
ed = _gorrent.Slice_Ptr_gorrent_FileInfo_len(self.handle)
return Slice_Ptr_gorrent_FileInfo(handle=_gorrent.Slice_Ptr_gorrent_FileInfo_subslice(self.handle, st, ed))
return [self[ii] for ii in range(*key.indices(len(self)))]
elif isinstance(key, int):
if key < 0:
key += len(self)
if key < 0 or key >= len(self):
raise IndexError('slice index out of range')
return FileInfo(handle=_gorrent.Slice_Ptr_gorrent_FileInfo_elem(self.handle, key))
else:
raise TypeError('slice index invalid type')
def __setitem__(self, idx, value):
if idx < 0:
idx += len(self)
if idx < len(self):
_gorrent.Slice_Ptr_gorrent_FileInfo_set(self.handle, idx, value.handle)
return
raise IndexError('slice index out of range')
def __iadd__(self, value):
if not isinstance(value, _collections_abc.Iterable):
raise TypeError('Slice_Ptr_gorrent_FileInfo.__iadd__ takes a sequence as argument')
for elt in value:
self.append(elt)
return self
def __iter__(self):
self.index = 0
return self
def __next__(self):
if self.index < len(self):
rv = _gorrent.Slice_Ptr_gorrent_FileInfo_elem(self.handle, self.index)
self.index = self.index + 1
return rv
raise StopIteration
def append(self, value):
_gorrent.Slice_Ptr_gorrent_FileInfo_append(self.handle, value.handle)
def copy(self, src):
""" copy emulates the go copy function, copying elements into this list from source list, up to min of size of each list """
mx = min(len(self), len(src))
for i in range(mx):
self[i] = src[i]
#---- Enums from Go (collections of consts with same type) ---
#---- Constants from Go: Python can only ask that you please don't change these! ---
# ---- Global Variables: can only use functions to access ---
# ---- Interfaces ---
# ---- Structs ---
# Python type for struct gorrent.Settings
class Settings(go.GoClass):
""""""
def __init__(self, *args, **kwargs):
"""
handle=A Go-side object is always initialized with an explicit handle=arg
otherwise parameters can be unnamed in order of field names or named fields
in which case a new Go object is constructed first
"""
if len(kwargs) == 1 and 'handle' in kwargs:
self.handle = kwargs['handle']
_gorrent.IncRef(self.handle)
elif len(args) == 1 and isinstance(args[0], go.GoClass):
self.handle = args[0].handle
_gorrent.IncRef(self.handle)
else:
self.handle = _gorrent.gorrent_Settings_CTor()
_gorrent.IncRef(self.handle)
if 0 < len(args):
self.DownloadPath = args[0]
if "DownloadPath" in kwargs:
self.DownloadPath = kwargs["DownloadPath"]
if 1 < len(args):
self.HttpBindHost = args[1]
if "HttpBindHost" in kwargs:
self.HttpBindHost = kwargs["HttpBindHost"]
if 2 < len(args):
self.HttpBindPort = args[2]
if "HttpBindPort" in kwargs:
self.HttpBindPort = kwargs["HttpBindPort"]
if 3 < len(args):
self.ListenPort = args[3]
if "ListenPort" in kwargs:
self.ListenPort = kwargs["ListenPort"]
if 4 < len(args):
self.MaxConnections = args[4]
if "MaxConnections" in kwargs:
self.MaxConnections = kwargs["MaxConnections"]
if 5 < len(args):
self.TorrentPath = args[5]
if "TorrentPath" in kwargs:
self.TorrentPath = kwargs["TorrentPath"]
if 6 < len(args):
self.Proxy = args[6]
if "Proxy" in kwargs:
self.Proxy = kwargs["Proxy"]
if 7 < len(args):
self.KeepFiles = args[7]
if "KeepFiles" in kwargs:
self.KeepFiles = kwargs["KeepFiles"]
if 8 < len(args):
self.Debug = args[8]
if "Debug" in kwargs:
self.Debug = kwargs["Debug"]
def __del__(self):
_gorrent.DecRef(self.handle)
def __str__(self):
pr = [(p, getattr(self, p)) for p in dir(self) if not p.startswith('__')]
sv = 'gorrent.Settings{'
first = True
for v in pr:
if callable(v[1]):
continue
if first:
first = False
else:
sv += ', '
sv += v[0] + '=' + str(v[1])
return sv + '}'
def __repr__(self):
pr = [(p, getattr(self, p)) for p in dir(self) if not p.startswith('__')]
sv = 'gorrent.Settings ( '
for v in pr:
if not callable(v[1]):
sv += v[0] + '=' + str(v[1]) + ', '
return sv + ')'
@property
def DownloadPath(self):
return _gorrent.gorrent_Settings_DownloadPath_Get(self.handle)
@DownloadPath.setter
def DownloadPath(self, value):
if isinstance(value, go.GoClass):
_gorrent.gorrent_Settings_DownloadPath_Set(self.handle, value.handle)
else:
_gorrent.gorrent_Settings_DownloadPath_Set(self.handle, value)
@property
def HttpBindHost(self):
return _gorrent.gorrent_Settings_HttpBindHost_Get(self.handle)
@HttpBindHost.setter
def HttpBindHost(self, value):
if isinstance(value, go.GoClass):
_gorrent.gorrent_Settings_HttpBindHost_Set(self.handle, value.handle)
else:
_gorrent.gorrent_Settings_HttpBindHost_Set(self.handle, value)
@property
def HttpBindPort(self):
return _gorrent.gorrent_Settings_HttpBindPort_Get(self.handle)
@HttpBindPort.setter
def HttpBindPort(self, value):
if isinstance(value, go.GoClass):
_gorrent.gorrent_Settings_HttpBindPort_Set(self.handle, value.handle)
else:
_gorrent.gorrent_Settings_HttpBindPort_Set(self.handle, value)
@property
def ListenPort(self):
return _gorrent.gorrent_Settings_ListenPort_Get(self.handle)
@ListenPort.setter
def ListenPort(self, value):
if isinstance(value, go.GoClass):
_gorrent.gorrent_Settings_ListenPort_Set(self.handle, value.handle)
else:
_gorrent.gorrent_Settings_ListenPort_Set(self.handle, value)
@property
def MaxConnections(self):
return _gorrent.gorrent_Settings_MaxConnections_Get(self.handle)
@MaxConnections.setter
def MaxConnections(self, value):
if isinstance(value, go.GoClass):
_gorrent.gorrent_Settings_MaxConnections_Set(self.handle, value.handle)
else:
_gorrent.gorrent_Settings_MaxConnections_Set(self.handle, value)
@property
def TorrentPath(self):
return _gorrent.gorrent_Settings_TorrentPath_Get(self.handle)
@TorrentPath.setter
def TorrentPath(self, value):
if isinstance(value, go.GoClass):
_gorrent.gorrent_Settings_TorrentPath_Set(self.handle, value.handle)
else:
_gorrent.gorrent_Settings_TorrentPath_Set(self.handle, value)
@property
def Proxy(self):
return _gorrent.gorrent_Settings_Proxy_Get(self.handle)
@Proxy.setter
def Proxy(self, value):
if isinstance(value, go.GoClass):
_gorrent.gorrent_Settings_Proxy_Set(self.handle, value.handle)
else:
_gorrent.gorrent_Settings_Proxy_Set(self.handle, value)
@property
def KeepFiles(self):
return _gorrent.gorrent_Settings_KeepFiles_Get(self.handle)
@KeepFiles.setter
def KeepFiles(self, value):
if isinstance(value, go.GoClass):
_gorrent.gorrent_Settings_KeepFiles_Set(self.handle, value.handle)
else:
_gorrent.gorrent_Settings_KeepFiles_Set(self.handle, value)
@property
def Debug(self):
return _gorrent.gorrent_Settings_Debug_Get(self.handle)
@Debug.setter
def Debug(self, value):
if isinstance(value, go.GoClass):
_gorrent.gorrent_Settings_Debug_Set(self.handle, value.handle)
else:
_gorrent.gorrent_Settings_Debug_Set(self.handle, value)
# Python type for struct gorrent.TorrentStatus
class TorrentStatus(go.GoClass):
""""""
def __init__(self, *args, **kwargs):
"""
handle=A Go-side object is always initialized with an explicit handle=arg
otherwise parameters can be unnamed in order of field names or named fields
in which case a new Go object is constructed first
"""
if len(kwargs) == 1 and 'handle' in kwargs:
self.handle = kwargs['handle']
_gorrent.IncRef(self.handle)
elif len(args) == 1 and isinstance(args[0], go.GoClass):
self.handle = args[0].handle
_gorrent.IncRef(self.handle)
else:
self.handle = _gorrent.gorrent_TorrentStatus_CTor()
_gorrent.IncRef(self.handle)
if 0 < len(args):
self.DownloadRate = args[0]
if "DownloadRate" in kwargs:
self.DownloadRate = kwargs["DownloadRate"]
if 1 < len(args):
self.UploadRate = args[1]
if "UploadRate" in kwargs:
self.UploadRate = kwargs["UploadRate"]
if 2 < len(args):
self.Seeds = args[2]
if "Seeds" in kwargs:
self.Seeds = kwargs["Seeds"]
def __del__(self):
_gorrent.DecRef(self.handle)
def __str__(self):
pr = [(p, getattr(self, p)) for p in dir(self) if not p.startswith('__')]
sv = 'gorrent.TorrentStatus{'
first = True
for v in pr:
if callable(v[1]):
continue
if first:
first = False
else:
sv += ', '
sv += v[0] + '=' + str(v[1])
return sv + '}'
def __repr__(self):
pr = [(p, getattr(self, p)) for p in dir(self) if not p.startswith('__')]
sv = 'gorrent.TorrentStatus ( '
for v in pr:
if not callable(v[1]):
sv += v[0] + '=' + str(v[1]) + ', '
return sv + ')'
@property
def DownloadRate(self):
return _gorrent.gorrent_TorrentStatus_DownloadRate_Get(self.handle)
@DownloadRate.setter
def DownloadRate(self, value):
if isinstance(value, go.GoClass):
_gorrent.gorrent_TorrentStatus_DownloadRate_Set(self.handle, value.handle)
else:
_gorrent.gorrent_TorrentStatus_DownloadRate_Set(self.handle, value)
@property
def UploadRate(self):
return _gorrent.gorrent_TorrentStatus_UploadRate_Get(self.handle)
@UploadRate.setter
def UploadRate(self, value):
if isinstance(value, go.GoClass):
_gorrent.gorrent_TorrentStatus_UploadRate_Set(self.handle, value.handle)
else:
_gorrent.gorrent_TorrentStatus_UploadRate_Set(self.handle, value)
@property
def Seeds(self):
return _gorrent.gorrent_TorrentStatus_Seeds_Get(self.handle)
@Seeds.setter
def Seeds(self, value):
if isinstance(value, go.GoClass):
_gorrent.gorrent_TorrentStatus_Seeds_Set(self.handle, value.handle)
else:
_gorrent.gorrent_TorrentStatus_Seeds_Set(self.handle, value)
# Python type for struct gorrent.Engine
class Engine(go.GoClass):
""""""
def __init__(self, *args, **kwargs):
"""
handle=A Go-side object is always initialized with an explicit handle=arg
otherwise parameters can be unnamed in order of field names or named fields
in which case a new Go object is constructed first
"""
if len(kwargs) == 1 and 'handle' in kwargs:
self.handle = kwargs['handle']
_gorrent.IncRef(self.handle)
elif len(args) == 1 and isinstance(args[0], go.GoClass):
self.handle = args[0].handle
_gorrent.IncRef(self.handle)
else:
self.handle = _gorrent.gorrent_Engine_CTor()
_gorrent.IncRef(self.handle)
def __del__(self):
_gorrent.DecRef(self.handle)
def __str__(self):
pr = [(p, getattr(self, p)) for p in dir(self) if not p.startswith('__')]
sv = 'gorrent.Engine{'
first = True
for v in pr:
if callable(v[1]):
continue
if first:
first = False
else:
sv += ', '
sv += v[0] + '=' + str(v[1])
return sv + '}'
def __repr__(self):
pr = [(p, getattr(self, p)) for p in dir(self) if not p.startswith('__')]
sv = 'gorrent.Engine ( '
for v in pr:
if not callable(v[1]):
sv += v[0] + '=' + str(v[1]) + ', '
return sv + ')'
def IsAlive(self):
"""IsAlive() bool"""
return _gorrent.gorrent_Engine_IsAlive(self.handle)
def StartTorrent(self, idx):
"""StartTorrent(long idx) str"""
return _gorrent.gorrent_Engine_StartTorrent(self.handle, idx)
def Status(self):
"""Status() object"""
return TorrentStatus(handle=_gorrent.gorrent_Engine_Status(self.handle))
def FileStatus(self, i):
"""FileStatus(int i) object, str"""
return FileStatus(handle=_gorrent.gorrent_Engine_FileStatus(self.handle, i))
def Stop(self, goRun=False):
"""Stop() """
_gorrent.gorrent_Engine_Stop(self.handle, goRun)
def GetMsg(self):
"""GetMsg() str"""
return _gorrent.gorrent_Engine_GetMsg(self.handle)
def Clean(self, goRun=False):
"""Clean() """
_gorrent.gorrent_Engine_Clean(self.handle, goRun)
# Python type for struct gorrent.FileInfo
class FileInfo(go.GoClass):
""""""
def __init__(self, *args, **kwargs):
"""
handle=A Go-side object is always initialized with an explicit handle=arg
otherwise parameters can be unnamed in order of field names or named fields
in which case a new Go object is constructed first
"""
if len(kwargs) == 1 and 'handle' in kwargs:
self.handle = kwargs['handle']
_gorrent.IncRef(self.handle)
elif len(args) == 1 and isinstance(args[0], go.GoClass):
self.handle = args[0].handle
_gorrent.IncRef(self.handle)
else:
self.handle = _gorrent.gorrent_FileInfo_CTor()
_gorrent.IncRef(self.handle)
if 0 < len(args):
self.Length = args[0]
if "Length" in kwargs:
self.Length = kwargs["Length"]
if 1 < len(args):
self.Path = args[1]
if "Path" in kwargs:
self.Path = kwargs["Path"]
if 2 < len(args):
self.PathUTF8 = args[2]
if "PathUTF8" in kwargs:
self.PathUTF8 = kwargs["PathUTF8"]
def __del__(self):
_gorrent.DecRef(self.handle)
def __str__(self):
pr = [(p, getattr(self, p)) for p in dir(self) if not p.startswith('__')]
sv = 'gorrent.FileInfo{'
first = True
for v in pr:
if callable(v[1]):
continue
if first:
first = False
else:
sv += ', '
sv += v[0] + '=' + str(v[1])
return sv + '}'
def __repr__(self):
pr = [(p, getattr(self, p)) for p in dir(self) if not p.startswith('__')]
sv = 'gorrent.FileInfo ( '
for v in pr:
if not callable(v[1]):
sv += v[0] + '=' + str(v[1]) + ', '
return sv + ')'
@property
def Length(self):
return _gorrent.gorrent_FileInfo_Length_Get(self.handle)
@Length.setter
def Length(self, value):
if isinstance(value, go.GoClass):
_gorrent.gorrent_FileInfo_Length_Set(self.handle, value.handle)
else:
_gorrent.gorrent_FileInfo_Length_Set(self.handle, value)
@property
def Path(self):
return go.Slice_string(handle=_gorrent.gorrent_FileInfo_Path_Get(self.handle))
@Path.setter
def Path(self, value):
if isinstance(value, go.GoClass):
_gorrent.gorrent_FileInfo_Path_Set(self.handle, value.handle)
else:
raise TypeError("supplied argument type {t} is not a go.GoClass".format(t=type(value)))
@property
def PathUTF8(self):
return go.Slice_string(handle=_gorrent.gorrent_FileInfo_PathUTF8_Get(self.handle))
@PathUTF8.setter
def PathUTF8(self, value):
if isinstance(value, go.GoClass):
_gorrent.gorrent_FileInfo_PathUTF8_Set(self.handle, value.handle)
else:
raise TypeError("supplied argument type {t} is not a go.GoClass".format(t=type(value)))
# Python type for struct gorrent.FileStatus
class FileStatus(go.GoClass):
""""""
def __init__(self, *args, **kwargs):
"""
handle=A Go-side object is always initialized with an explicit handle=arg
otherwise parameters can be unnamed in order of field names or named fields
in which case a new Go object is constructed first
"""
if len(kwargs) == 1 and 'handle' in kwargs:
self.handle = kwargs['handle']
_gorrent.IncRef(self.handle)
elif len(args) == 1 and isinstance(args[0], go.GoClass):
self.handle = args[0].handle
_gorrent.IncRef(self.handle)
else:
self.handle = _gorrent.gorrent_FileStatus_CTor()
_gorrent.IncRef(self.handle)
if 0 < len(args):
self.Name = args[0]
if "Name" in kwargs:
self.Name = kwargs["Name"]
if 1 < len(args):
self.Url = args[1]
if "Url" in kwargs:
self.Url = kwargs["Url"]
if 2 < len(args):
self.Progress = args[2]
if "Progress" in kwargs:
self.Progress = kwargs["Progress"]
if 3 < len(args):
self.Length = args[3]
if "Length" in kwargs:
self.Length = kwargs["Length"]
def __del__(self):
_gorrent.DecRef(self.handle)
def __str__(self):
pr = [(p, getattr(self, p)) for p in dir(self) if not p.startswith('__')]
sv = 'gorrent.FileStatus{'
first = True
for v in pr:
if callable(v[1]):
continue
if first:
first = False
else:
sv += ', '
sv += v[0] + '=' + str(v[1])
return sv + '}'
def __repr__(self):
pr = [(p, getattr(self, p)) for p in dir(self) if not p.startswith('__')]
sv = 'gorrent.FileStatus ( '
for v in pr:
if not callable(v[1]):
sv += v[0] + '=' + str(v[1]) + ', '
return sv + ')'
@property
def Name(self):
return _gorrent.gorrent_FileStatus_Name_Get(self.handle)
@Name.setter
def Name(self, value):
if isinstance(value, go.GoClass):
_gorrent.gorrent_FileStatus_Name_Set(self.handle, value.handle)
else:
_gorrent.gorrent_FileStatus_Name_Set(self.handle, value)
@property
def Url(self):
return _gorrent.gorrent_FileStatus_Url_Get(self.handle)
@Url.setter
def Url(self, value):
if isinstance(value, go.GoClass):
_gorrent.gorrent_FileStatus_Url_Set(self.handle, value.handle)
else:
_gorrent.gorrent_FileStatus_Url_Set(self.handle, value)
@property
def Progress(self):
return _gorrent.gorrent_FileStatus_Progress_Get(self.handle)
@Progress.setter
def Progress(self, value):
if isinstance(value, go.GoClass):
_gorrent.gorrent_FileStatus_Progress_Set(self.handle, value.handle)
else:
_gorrent.gorrent_FileStatus_Progress_Set(self.handle, value)
@property
def Length(self):
return _gorrent.gorrent_FileStatus_Length_Get(self.handle)
@Length.setter
def Length(self, value):
if isinstance(value, go.GoClass):
_gorrent.gorrent_FileStatus_Length_Set(self.handle, value.handle)
else:
_gorrent.gorrent_FileStatus_Length_Set(self.handle, value)
# Python type for struct gorrent.Info
class Info(go.GoClass):
""""""
def __init__(self, *args, **kwargs):
"""
handle=A Go-side object is always initialized with an explicit handle=arg
otherwise parameters can be unnamed in order of field names or named fields
in which case a new Go object is constructed first
"""
if len(kwargs) == 1 and 'handle' in kwargs:
self.handle = kwargs['handle']
_gorrent.IncRef(self.handle)
elif len(args) == 1 and isinstance(args[0], go.GoClass):
self.handle = args[0].handle
_gorrent.IncRef(self.handle)
else:
self.handle = _gorrent.gorrent_Info_CTor()
_gorrent.IncRef(self.handle)
if 0 < len(args):
self.Name = args[0]
if "Name" in kwargs:
self.Name = kwargs["Name"]
if 1 < len(args):
self.Length = args[1]
if "Length" in kwargs:
self.Length = kwargs["Length"]
if 2 < len(args):
self.Source = args[2]
if "Source" in kwargs:
self.Source = kwargs["Source"]
if 3 < len(args):
self.Files = args[3]
if "Files" in kwargs:
self.Files = kwargs["Files"]
def __del__(self):
_gorrent.DecRef(self.handle)
def __str__(self):
pr = [(p, getattr(self, p)) for p in dir(self) if not p.startswith('__')]
sv = 'gorrent.Info{'
first = True
for v in pr:
if callable(v[1]):
continue
if first:
first = False
else:
sv += ', '
sv += v[0] + '=' + str(v[1])
return sv + '}'
def __repr__(self):
pr = [(p, getattr(self, p)) for p in dir(self) if not p.startswith('__')]
sv = 'gorrent.Info ( '
for v in pr:
if not callable(v[1]):
sv += v[0] + '=' + str(v[1]) + ', '
return sv + ')'
@property
def Name(self):
return _gorrent.gorrent_Info_Name_Get(self.handle)
@Name.setter
def Name(self, value):
if isinstance(value, go.GoClass):
_gorrent.gorrent_Info_Name_Set(self.handle, value.handle)
else:
_gorrent.gorrent_Info_Name_Set(self.handle, value)
@property
def Length(self):
return _gorrent.gorrent_Info_Length_Get(self.handle)
@Length.setter
def Length(self, value):
if isinstance(value, go.GoClass):
_gorrent.gorrent_Info_Length_Set(self.handle, value.handle)
else:
_gorrent.gorrent_Info_Length_Set(self.handle, value)
@property
def Source(self):
return _gorrent.gorrent_Info_Source_Get(self.handle)
@Source.setter
def Source(self, value):
if isinstance(value, go.GoClass):
_gorrent.gorrent_Info_Source_Set(self.handle, value.handle)
else:
_gorrent.gorrent_Info_Source_Set(self.handle, value)
@property
def Files(self):
return Slice_Ptr_gorrent_FileInfo(handle=_gorrent.gorrent_Info_Files_Get(self.handle))
@Files.setter
def Files(self, value):
if isinstance(value, go.GoClass):
_gorrent.gorrent_Info_Files_Set(self.handle, value.handle)
else:
raise TypeError("supplied argument type {t} is not a go.GoClass".format(t=type(value)))
def LoadFile(self, path):
"""LoadFile(str path) str"""
return _gorrent.gorrent_Info_LoadFile(self.handle, path)
# ---- Slices ---
# ---- Maps ---
# ---- Constructors ---
def NewSettings():
"""NewSettings() object"""
return Settings(handle=_gorrent.gorrent_NewSettings())
def NewEngine(settings):
"""NewEngine(object settings) object"""
return Engine(handle=_gorrent.gorrent_NewEngine(settings.handle))
def GetMetaFromFile(path):
"""GetMetaFromFile(str path) object, str"""
return Info(handle=_gorrent.gorrent_GetMetaFromFile(path))
# ---- Functions ---
def Version():
"""Version() str"""
return _gorrent.gorrent_Version()

View File

@ -9,6 +9,8 @@ type Settings struct {
TorrentPath string TorrentPath string
Proxy string Proxy string
KeepFiles bool KeepFiles bool
Seed bool
AcceptPeerConnections bool
Debug bool Debug bool
} }