все целые должны быть явно 64-битные

master
Роман Бородин 2022-03-24 00:38:29 +03:00
parent a3b36b9794
commit a5da028344
6 changed files with 324 additions and 321 deletions

View File

@ -18,19 +18,19 @@ import (
const boltDbDir = `piece_complete_db`
type TorrentStatus struct {
DownloadRate int
UploadRate int
Seeds int
DownloadRate int64
UploadRate int64
Seeds int64
}
type FileStatus struct {
Name string
Url string
Progress int
Length int
Progress int64
Length int64
}
type Engine struct {
fileIdx int
fileIdx int64
settings *Settings
torrCfg *torrent.ClientConfig
client *torrent.Client
@ -42,26 +42,18 @@ type Engine struct {
shutdown context.CancelFunc
msgs chan string
status struct {
lastBytesReadData int
lastBytesWrittenData int
downRate int
upRate int
seeds int
lastBytesReadData int64
lastBytesWrittenData int64
downRate int64
upRate int64
seeds int64
}
}
func NewEngine(settings *Settings) *Engine {
e := &Engine{
settings: settings,
msgs: make(chan string, 50),
}
e.ctx, e.shutdown = context.WithCancel(context.Background())
return e
}
func (o *Engine) IsAlive() bool {
return o.alive
}
func (o *Engine) StartTorrent(idx int) error {
func (o *Engine) StartTorrent(idx int64) error {
o.fileIdx = idx
var err error
o.torrCfg = torrent.NewDefaultClientConfig()
@ -144,16 +136,16 @@ func (o *Engine) updateStats() {
if o.status.lastBytesReadData == 0 {
o.status.downRate = 0
} else {
o.status.downRate = (int(stats.BytesReadData.Int64()) - o.status.lastBytesReadData) / 1024
o.status.downRate = (stats.BytesReadData.Int64() - o.status.lastBytesReadData) / 1024
}
o.status.lastBytesReadData = int(stats.BytesReadData.Int64())
o.status.lastBytesReadData = stats.BytesReadData.Int64()
if o.status.lastBytesWrittenData == 0 {
o.status.upRate = 0
} else {
o.status.upRate = (int(stats.BytesWrittenData.Int64()) - o.status.lastBytesWrittenData) / 1024
o.status.upRate = (stats.BytesWrittenData.Int64() - o.status.lastBytesWrittenData) / 1024
}
o.status.lastBytesWrittenData = int(stats.BytesWrittenData.Int64())
o.status.seeds = stats.ConnectedSeeders
o.status.lastBytesWrittenData = stats.BytesWrittenData.Int64()
o.status.seeds = int64(stats.ConnectedSeeders)
}
func (o *Engine) Status() TorrentStatus {
@ -177,11 +169,11 @@ func (o *Engine) FileStatus(i int) (FileStatus, error) {
pathParts[idx] = url.QueryEscape(pathParts[idx])
}
fs.Url = fmt.Sprintf(`http://%s:%d/files/%s`, o.settings.HttpBindHost, o.settings.HttpBindPort, strings.Join(pathParts, `/`))
fs.Progress = int(float64(file.BytesCompleted()) / float64(file.Length()) * 100.0)
fs.Progress = int64(float64(file.BytesCompleted()) / float64(file.Length()) * 100.0)
if fs.Progress < 0 {
fs.Progress *= -1
}
fs.Length = int(file.Length())
fs.Length = file.Length()
if fs.Length < 0 {
fs.Length *= -1
}

8
go.mod
View File

@ -3,20 +3,19 @@ module gorrent
go 1.17
require (
github.com/RoaringBitmap/roaring v0.9.4
github.com/anacrolix/dht/v2 v2.15.2-0.20220123034220-0538803801cb
github.com/anacrolix/log v0.10.1-0.20220123034749-3920702c17f8
github.com/anacrolix/torrent v1.41.0
github.com/go-python/gopy v0.4.0
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac
)
require (
github.com/RoaringBitmap/roaring v0.9.4 // indirect
github.com/anacrolix/chansync v0.3.0 // indirect
github.com/anacrolix/confluence v1.9.0 // indirect
github.com/anacrolix/dht/v2 v2.15.2-0.20220123034220-0538803801cb // indirect
github.com/anacrolix/envpprof v1.1.1 // indirect
github.com/anacrolix/go-libutp v1.2.0 // indirect
github.com/anacrolix/log v0.10.1-0.20220123034749-3920702c17f8 // indirect
github.com/anacrolix/missinggo v1.3.0 // indirect
github.com/anacrolix/missinggo/perf v1.0.0 // indirect
github.com/anacrolix/missinggo/v2 v2.5.2 // indirect
@ -62,6 +61,7 @@ require (
golang.org/x/crypto v0.0.0-20220131195533-30dcbda58838 // indirect
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
modernc.org/libc v1.11.82 // indirect
modernc.org/mathutil v1.4.1 // indirect

View File

@ -1,5 +1,7 @@
package gorrent
import "context"
var version = `1.0.0`
func GetMetaFromFile(path string) (*Info, error) {
@ -13,3 +15,12 @@ func GetMetaFromFile(path string) (*Info, error) {
func Version() string {
return version
}
func NewEngine(settings *Settings) *Engine {
e := &Engine{
settings: settings,
msgs: make(chan string, 50),
}
e.ctx, e.shutdown = context.WithCancel(context.Background())
return e
}

View File

@ -147,22 +147,6 @@ mod.add_function('Slice_Ptr_gorrent_FileInfo_elem', retval('int64_t'), [param('i
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_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')])
@ -207,6 +191,22 @@ add_checked_function(mod, 'gorrent_Engine_FileStatus', retval('int64_t'), [param
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')])
add_checked_function(mod, 'gorrent_GetMetaFromFile', retval('int64_t'), [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')])

View File

@ -1246,102 +1246,6 @@ func handleFromPtr_gorrent_TorrentStatus(p interface{}) CGoHandle {
// ---- Structs ---
// --- wrapping struct: gorrent.FileInfo ---
//export gorrent_FileInfo_CTor
func gorrent_FileInfo_CTor() CGoHandle {
return CGoHandle(handleFromPtr_gorrent_FileInfo(&gorrent.FileInfo{}))
}
//export gorrent_FileInfo_Length_Get
func gorrent_FileInfo_Length_Get(handle CGoHandle) C.longlong {
op := ptrFromHandle_gorrent_FileInfo(handle)
return C.longlong(op.Length)
}
//export gorrent_FileInfo_Length_Set
func gorrent_FileInfo_Length_Set(handle CGoHandle, val C.longlong) {
op := ptrFromHandle_gorrent_FileInfo(handle)
op.Length = int64(val)
}
//export gorrent_FileInfo_Path_Get
func gorrent_FileInfo_Path_Get(handle CGoHandle) CGoHandle {
op := ptrFromHandle_gorrent_FileInfo(handle)
return handleFromPtr_Slice_string(&op.Path)
}
//export gorrent_FileInfo_Path_Set
func gorrent_FileInfo_Path_Set(handle CGoHandle, val CGoHandle) {
op := ptrFromHandle_gorrent_FileInfo(handle)
op.Path = deptrFromHandle_Slice_string(val)
}
//export gorrent_FileInfo_PathUTF8_Get
func gorrent_FileInfo_PathUTF8_Get(handle CGoHandle) CGoHandle {
op := ptrFromHandle_gorrent_FileInfo(handle)
return handleFromPtr_Slice_string(&op.PathUTF8)
}
//export gorrent_FileInfo_PathUTF8_Set
func gorrent_FileInfo_PathUTF8_Set(handle CGoHandle, val CGoHandle) {
op := ptrFromHandle_gorrent_FileInfo(handle)
op.PathUTF8 = deptrFromHandle_Slice_string(val)
}
// --- wrapping struct: gorrent.FileStatus ---
//export gorrent_FileStatus_CTor
func gorrent_FileStatus_CTor() CGoHandle {
return CGoHandle(handleFromPtr_gorrent_FileStatus(&gorrent.FileStatus{}))
}
//export gorrent_FileStatus_Name_Get
func gorrent_FileStatus_Name_Get(handle CGoHandle) *C.char {
op := ptrFromHandle_gorrent_FileStatus(handle)
return C.CString(op.Name)
}
//export gorrent_FileStatus_Name_Set
func gorrent_FileStatus_Name_Set(handle CGoHandle, val *C.char) {
op := ptrFromHandle_gorrent_FileStatus(handle)
op.Name = C.GoString(val)
}
//export gorrent_FileStatus_Url_Get
func gorrent_FileStatus_Url_Get(handle CGoHandle) *C.char {
op := ptrFromHandle_gorrent_FileStatus(handle)
return C.CString(op.Url)
}
//export gorrent_FileStatus_Url_Set
func gorrent_FileStatus_Url_Set(handle CGoHandle, val *C.char) {
op := ptrFromHandle_gorrent_FileStatus(handle)
op.Url = C.GoString(val)
}
//export gorrent_FileStatus_Progress_Get
func gorrent_FileStatus_Progress_Get(handle CGoHandle) C.longlong {
op := ptrFromHandle_gorrent_FileStatus(handle)
return C.longlong(op.Progress)
}
//export gorrent_FileStatus_Progress_Set
func gorrent_FileStatus_Progress_Set(handle CGoHandle, val C.longlong) {
op := ptrFromHandle_gorrent_FileStatus(handle)
op.Progress = int(val)
}
//export gorrent_FileStatus_Length_Get
func gorrent_FileStatus_Length_Get(handle CGoHandle) C.longlong {
op := ptrFromHandle_gorrent_FileStatus(handle)
return C.longlong(op.Length)
}
//export gorrent_FileStatus_Length_Set
func gorrent_FileStatus_Length_Set(handle CGoHandle, val C.longlong) {
op := ptrFromHandle_gorrent_FileStatus(handle)
op.Length = int(val)
}
// --- wrapping struct: gorrent.Info ---
//export gorrent_Info_CTor
func gorrent_Info_CTor() CGoHandle {
@ -1540,7 +1444,7 @@ func gorrent_TorrentStatus_DownloadRate_Get(handle CGoHandle) C.longlong {
//export gorrent_TorrentStatus_DownloadRate_Set
func gorrent_TorrentStatus_DownloadRate_Set(handle CGoHandle, val C.longlong) {
op := ptrFromHandle_gorrent_TorrentStatus(handle)
op.DownloadRate = int(val)
op.DownloadRate = int64(val)
}
//export gorrent_TorrentStatus_UploadRate_Get
@ -1552,7 +1456,7 @@ func gorrent_TorrentStatus_UploadRate_Get(handle CGoHandle) C.longlong {
//export gorrent_TorrentStatus_UploadRate_Set
func gorrent_TorrentStatus_UploadRate_Set(handle CGoHandle, val C.longlong) {
op := ptrFromHandle_gorrent_TorrentStatus(handle)
op.UploadRate = int(val)
op.UploadRate = int64(val)
}
//export gorrent_TorrentStatus_Seeds_Get
@ -1564,7 +1468,7 @@ func gorrent_TorrentStatus_Seeds_Get(handle CGoHandle) C.longlong {
//export gorrent_TorrentStatus_Seeds_Set
func gorrent_TorrentStatus_Seeds_Set(handle CGoHandle, val C.longlong) {
op := ptrFromHandle_gorrent_TorrentStatus(handle)
op.Seeds = int(val)
op.Seeds = int64(val)
}
@ -1590,7 +1494,7 @@ func gorrent_Engine_StartTorrent(_handle CGoHandle, idx C.longlong) *C.char {
if __err != nil {
return C.CString("")
}
__err = gopyh.Embed(vifc, reflect.TypeOf(gorrent.Engine{})).(*gorrent.Engine).StartTorrent(int(idx))
__err = gopyh.Embed(vifc, reflect.TypeOf(gorrent.Engine{})).(*gorrent.Engine).StartTorrent(int64(idx))
if __err != nil {
estr := C.CString(__err.Error())
@ -1664,6 +1568,102 @@ func gorrent_Engine_Clean(_handle CGoHandle, goRun C.char) {
}
}
// --- wrapping struct: gorrent.FileInfo ---
//export gorrent_FileInfo_CTor
func gorrent_FileInfo_CTor() CGoHandle {
return CGoHandle(handleFromPtr_gorrent_FileInfo(&gorrent.FileInfo{}))
}
//export gorrent_FileInfo_Length_Get
func gorrent_FileInfo_Length_Get(handle CGoHandle) C.longlong {
op := ptrFromHandle_gorrent_FileInfo(handle)
return C.longlong(op.Length)
}
//export gorrent_FileInfo_Length_Set
func gorrent_FileInfo_Length_Set(handle CGoHandle, val C.longlong) {
op := ptrFromHandle_gorrent_FileInfo(handle)
op.Length = int64(val)
}
//export gorrent_FileInfo_Path_Get
func gorrent_FileInfo_Path_Get(handle CGoHandle) CGoHandle {
op := ptrFromHandle_gorrent_FileInfo(handle)
return handleFromPtr_Slice_string(&op.Path)
}
//export gorrent_FileInfo_Path_Set
func gorrent_FileInfo_Path_Set(handle CGoHandle, val CGoHandle) {
op := ptrFromHandle_gorrent_FileInfo(handle)
op.Path = deptrFromHandle_Slice_string(val)
}
//export gorrent_FileInfo_PathUTF8_Get
func gorrent_FileInfo_PathUTF8_Get(handle CGoHandle) CGoHandle {
op := ptrFromHandle_gorrent_FileInfo(handle)
return handleFromPtr_Slice_string(&op.PathUTF8)
}
//export gorrent_FileInfo_PathUTF8_Set
func gorrent_FileInfo_PathUTF8_Set(handle CGoHandle, val CGoHandle) {
op := ptrFromHandle_gorrent_FileInfo(handle)
op.PathUTF8 = deptrFromHandle_Slice_string(val)
}
// --- wrapping struct: gorrent.FileStatus ---
//export gorrent_FileStatus_CTor
func gorrent_FileStatus_CTor() CGoHandle {
return CGoHandle(handleFromPtr_gorrent_FileStatus(&gorrent.FileStatus{}))
}
//export gorrent_FileStatus_Name_Get
func gorrent_FileStatus_Name_Get(handle CGoHandle) *C.char {
op := ptrFromHandle_gorrent_FileStatus(handle)
return C.CString(op.Name)
}
//export gorrent_FileStatus_Name_Set
func gorrent_FileStatus_Name_Set(handle CGoHandle, val *C.char) {
op := ptrFromHandle_gorrent_FileStatus(handle)
op.Name = C.GoString(val)
}
//export gorrent_FileStatus_Url_Get
func gorrent_FileStatus_Url_Get(handle CGoHandle) *C.char {
op := ptrFromHandle_gorrent_FileStatus(handle)
return C.CString(op.Url)
}
//export gorrent_FileStatus_Url_Set
func gorrent_FileStatus_Url_Set(handle CGoHandle, val *C.char) {
op := ptrFromHandle_gorrent_FileStatus(handle)
op.Url = C.GoString(val)
}
//export gorrent_FileStatus_Progress_Get
func gorrent_FileStatus_Progress_Get(handle CGoHandle) C.longlong {
op := ptrFromHandle_gorrent_FileStatus(handle)
return C.longlong(op.Progress)
}
//export gorrent_FileStatus_Progress_Set
func gorrent_FileStatus_Progress_Set(handle CGoHandle, val C.longlong) {
op := ptrFromHandle_gorrent_FileStatus(handle)
op.Progress = int64(val)
}
//export gorrent_FileStatus_Length_Get
func gorrent_FileStatus_Length_Get(handle CGoHandle) C.longlong {
op := ptrFromHandle_gorrent_FileStatus(handle)
return C.longlong(op.Length)
}
//export gorrent_FileStatus_Length_Set
func gorrent_FileStatus_Length_Set(handle CGoHandle, val C.longlong) {
op := ptrFromHandle_gorrent_FileStatus(handle)
op.Length = int64(val)
}
// ---- Slices ---

View File

@ -127,179 +127,6 @@ class Slice_Ptr_gorrent_FileInfo(go.GoClass):
# ---- Structs ---
# 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):
""""""
@ -678,7 +505,7 @@ class Engine(go.GoClass):
"""IsAlive() bool"""
return _gorrent.gorrent_Engine_IsAlive(self.handle)
def StartTorrent(self, idx):
"""StartTorrent(int idx) str"""
"""StartTorrent(long idx) str"""
return _gorrent.gorrent_Engine_StartTorrent(self.handle, idx)
def Status(self):
"""Status() object"""
@ -696,6 +523,179 @@ class Engine(go.GoClass):
"""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)
# ---- Slices ---