Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# 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
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details
# http://www.gnu.org/licenses/gpl-3.0.txt
from ...logging import make_logger
log = make_logger(__name__)
import blinker
from collections import namedtuple
from ..poll import RequestPoller
from ..utils import (convert, const)
TorrentCount = namedtuple('TorrentCount', ('active', 'downloading', 'isolated',
'stopped', 'total', 'uploading'))
class StatusAPI():
"""Transmission daemon status information"""
# Pass poller methods through to our pollers
# 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
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details
# http://www.gnu.org/licenses/gpl-3.0.txt
from ...logging import make_logger
log = make_logger(__name__)
from ..base import file as base
from . import _mixin as mixin
from .. import CmdError
from ... import objects
from ._table import (print_table, TERMSIZE)
import os
class ListFilesCmd(base.ListFilesCmdbase,
mixin.make_request, mixin.select_torrents, mixin.select_files,
mixin.only_supported_columns):
provides = {'cli'}
async def make_file_list(self, tfilter, ffilter, columns):
# 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
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details
# http://www.gnu.org/licenses/gpl-3.0.txt
from ..logging import make_logger
log = make_logger(__name__)
DEFAULT_DELIMS = (' ',)
DEFAULT_ESCAPES = ('\\',)
DEFAULT_QUOTES = ('"', "'")
class Char(str):
"""Single character with parser-provided attributes"""
def __new__(cls, char, *, string='', delim='', escape='', quote='',
is_special=False, is_escaped=False, is_quoted=False):
obj = super().__new__(cls, char)
obj._string = string
obj._delim = delim
obj._escape = escape
obj._quote = quote
"""Value types for Torrent classes"""
# The TYPES dictionary at the end of this file maps Torrent key names to
# types. Every Torrent key must have a type, even if it's just a no-op
# (`lambda obj: obj`).
#
# A type is any callable that converts a single value to the appropriate class
# instance.
#
# Types are used to convert values from the server (e.g. large integers) and
# from the user (e.g. number strings like '3.5G'). Not all types must accept
# user-given values (e.g. 'files').
from ..logging import make_logger
log = make_logger(__name__)
from collections import abc
from .utils import pretty_float
import os
from itertools import chain
import re
class Number(float):
"""float with a nice string representation; also parses strings like '123K' or '123Mi'"""
_PREFIXES_BINARY = (('Ti', 1024**4), ('Gi', 1024**3), ('Mi', 1024**2), ('Ki', 1024))
_PREFIXES_METRIC = (('T', 1000**4), ('G', 1000**3), ('M', 1000**2), ('k', 1000))
_ALL_PREFIXES = tuple((prefix.lower(), size)
for prefix,size in chain.from_iterable(zip(_PREFIXES_BINARY,
_PREFIXES_METRIC)))
# 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
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details
# http://www.gnu.org/licenses/gpl-3.0.txt
from ...logging import make_logger
log = make_logger(__name__)
from ..base import torrent as base
from . import _mixin as mixin
from ... import objects
from ._common import make_tab_title_widget
from ...completion import candidates
from ...utils.cliparser import Arg
import functools
import os
class AddTorrentsCmd(base.AddTorrentsCmdbase,
mixin.polling_frenzy, mixin.make_request):
provides = {'tui'}
@staticmethod
# 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
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details
# http://www.gnu.org/licenses/gpl-3.0.txt
from ..logging import make_logger
log = make_logger(__name__)
import logging
import urwid
import time
import asyncio
from .scroll import (Scrollable, ScrollBar)
class UILogRecordHandler(logging.Handler):
"""Feed LogRecords to a LogWidget"""
def __init__(self, logwidget):
super().__init__()
self._logwidget = logwidget
# 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
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details
# http://www.gnu.org/licenses/gpl-3.0.txt
"""Commands that work exclusively in the TUI"""
from ...logging import make_logger
log = make_logger(__name__)
from .. import (InitCommand, CmdError)
from ...completion import candidates
from . import _mixin as mixin
from ._common import make_tab_title_widget
from ... import objects
from .. import utils
import shlex
from functools import partial
import os
# Import tui.main module only on demand
def _get_keymap_contexts():
from ...tui.tuiobjects import keymap
# 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
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details
# http://www.gnu.org/licenses/gpl-3.0.txt
from ...logging import make_logger
log = make_logger(__name__)
from string import hexdigits as HEXDIGITS
from collections import abc
import os
import base64
from ..utils import (Response, URL)
from ..base import TorrentAPIBase
from .torrent import (TorrentFields, Torrent)
from .. import ClientError
from ..filters import (TorrentFilter, FileFilter)
from ..utils import (Bool, Bandwidth, BoolOrBandwidth)
from ..ttypes import Path
class _TorrentCache():
# 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
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details
# http://www.gnu.org/licenses/gpl-3.0.txt
from ..logging import make_logger
log = make_logger(__name__)
import os
from .defaults import DEFAULT_RCFILE
def _tildify(p):
homedir = os.path.expanduser('~')
if p.startswith(homedir):
return '~' + p[len(homedir):]
return p
def _unescape_linebreaks(lines):
unescaped = []
append_next = False
# 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
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details
# http://www.gnu.org/licenses/gpl-3.0.txt
from ...logging import make_logger
log = make_logger(__name__)
from .. import (InitCommand, CmdError)
from . import _mixin as mixin
from ... import objects
from ._common import (make_X_FILTER_spec, make_COLUMNS_doc, make_SCRIPTING_doc)
import asyncio
class ListFilesCmdbase(mixin.get_file_columns, metaclass=InitCommand):
name = 'filelist'
aliases = ('fls', 'lsf')
provides = set()
category = 'file'
description = 'List files of torrent(s)'
usage = ('filelist []',