mirror of
				https://github.com/KevinMidboe/delugeClient.git
				synced 2025-10-29 12:00:13 +00:00 
			
		
		
		
	Compare commits
	
		
			6 Commits
		
	
	
		
			ci/build-a
			...
			snyk-fix-7
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|  | 405d59e06d | ||
| adf8f3f1ef | |||
| 8f2327c065 | |||
| 9bfa3c4c59 | |||
| 078d422498 | |||
| a6fb543b3f | 
							
								
								
									
										82
									
								
								.drone.yml
									
									
									
									
									
								
							
							
						
						
									
										82
									
								
								.drone.yml
									
									
									
									
									
								
							| @@ -1,14 +1,90 @@ | ||||
| --- | ||||
| kind: pipeline | ||||
| type: docker | ||||
| name: delugeClient | ||||
| name: Build and test amd64 | ||||
|  | ||||
| platform: | ||||
|   os: linux | ||||
|   arch: amd64 | ||||
|  | ||||
| steps: | ||||
|   - name: Build package | ||||
|   - name: Build source | ||||
|     image: python:3.10 | ||||
|     commands: | ||||
|       - make build | ||||
|     - make build | ||||
|  | ||||
|   - name: Install | ||||
|     image: python:3.10 | ||||
|     commands: | ||||
|     - make dist | ||||
|     - pip3 install -r requirements.txt | ||||
|     - pip3 install dist/*.whl | ||||
| #     - pipenv install pytest | ||||
|  | ||||
| #   - name: Run tests | ||||
| #     image: python:3.10 | ||||
| #     commands: | ||||
| #       pipenv run pytest | ||||
|  | ||||
| --- | ||||
| kind: pipeline | ||||
| type: docker | ||||
| name: Publish package to PyPi | ||||
|  | ||||
| platform: | ||||
|   os: linux | ||||
|   arch: amd64 | ||||
|  | ||||
| steps: | ||||
|   - name: Newer version to publish? | ||||
|     image: python:3.10 | ||||
|     commands: | ||||
|       - pip3 install delugeClient-kevin -q -q | ||||
|       - bash publish_version?.sh | ||||
|  | ||||
|   - name: PyPi verify | ||||
|     image: python:3.10 | ||||
|     commands: | ||||
|       - make dist | ||||
|       - pip3 install twine | ||||
|       - twine check dist/* | ||||
|  | ||||
|   - name: PyPi test publish | ||||
|     image: python:3.10 | ||||
|     environment: | ||||
|       TWINE_USERNAME: | ||||
|         from_secret: TWINE_USERNAME | ||||
|       TWINE_PASSWORD: | ||||
|         from_secret: TWINE_TEST_PASSWORD | ||||
|     commands: | ||||
|       - make dist | ||||
|       - pip3 install twine | ||||
|       - twine upload --repository-url https://test.pypi.org/legacy/ dist/* | ||||
|  | ||||
|   - name: PyPi publish | ||||
|     image: python:3.10 | ||||
|     environment: | ||||
|       TWINE_USERNAME: | ||||
|         from_secret: TWINE_USERNAME | ||||
|       TWINE_PASSWORD: | ||||
|         from_secret: TWINE_PASSWORD | ||||
|     commands: | ||||
|       - make dist | ||||
|       - pip3 install twine | ||||
|       - twine upload dist/* | ||||
|  | ||||
| depends_on: | ||||
|   - Build and test amd64 | ||||
|  | ||||
| trigger: | ||||
|   branch: | ||||
|     - master | ||||
|   event: | ||||
|     exclude: | ||||
|       - pull_request | ||||
|  | ||||
| --- | ||||
| kind: signature | ||||
| hmac: 60604a21f35e11d078d5d381bbea8e25b903175c018ba9e6f4a4379285e89883 | ||||
|  | ||||
| ... | ||||
|   | ||||
							
								
								
									
										7
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										7
									
								
								Makefile
									
									
									
									
									
								
							| @@ -7,9 +7,14 @@ install: | ||||
| build: | ||||
| 	python3 setup.py build | ||||
|  | ||||
| dist: | ||||
| tarball: | ||||
| 	python3 setup.py sdist | ||||
|  | ||||
| wheel: | ||||
| 	python3 setup.py bdist_wheel | ||||
|  | ||||
| dist: tarball wheel | ||||
|  | ||||
| upload: clean dist | ||||
| 	twine upload dist/* | ||||
|  | ||||
|   | ||||
							
								
								
									
										111
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										111
									
								
								README.md
									
									
									
									
									
								
							| @@ -4,23 +4,20 @@ | ||||
|  | ||||
| <h4 align="center"> A easy to use Deluge CLI that can connect to Deluge RPC (even over ssh) written entirely in python.</h4> | ||||
|  | ||||
| | Tested version | PyPi package | Drone CI | | ||||
| | Tested version | PyPi package | License | | ||||
| |:--------|:------|:------| | ||||
| | [](https://www.python.org/downloads/release/python-3100/) | [](https://pypi.org/project/delugeClient_kevin/) | [](https://drone.schleppe.cloud/KevinMidboe/delugeClient) | ||||
| | [](https://www.python.org/downloads/release/python-3100/) | [](https://pypi.org/project/delugeClient_kevin/) |[](LICENSE) | ||||
|  | ||||
|  | ||||
| | Known vulnerabilities | License | | ||||
| | Drone CI | Known vulnerabilities | | ||||
| |:--------|:------| | ||||
| | [](https://snyk.io/test/github/kevinmidboe/delugeClient?targetFile=requirements.txt) |[](LICENSE) | ||||
|  | ||||
| | [](https://drone.schleppe.cloud/KevinMidboe/delugeClient) | [](https://snyk.io/test/github/kevinmidboe/delugeClient?targetFile=requirements.txt) | ||||
|  | ||||
| <p align="center"> | ||||
|   <a href="#abstract">Abstract</a> • | ||||
|   <a href="#setup_virtualenv">Setup virtualenv</a> • | ||||
|   <a href="#configure">Configure</a> • | ||||
|   <a href="#installation">Install dependencies</a> • | ||||
|   <a href="#install">Install</a> • | ||||
|   <a href="#usage">Usage</a> • | ||||
|   <a href="#running">Running</a> • | ||||
|   <a href="#setup_virtualenv">Setup Virtual Environment</a> • | ||||
|   <a href="#configure">Configure</a> • | ||||
|   <a href="#contributing">Contributing</a> | ||||
| </p> | ||||
|  | ||||
| @@ -28,6 +25,51 @@ | ||||
| ## <a name="abstract"></a> Abstract | ||||
| Create a deluge python client for interfacing with deluge for common tasks like listing, adding, removing and setting download directory for torrents.  | ||||
|  | ||||
| ## <a name="install"></a> Install | ||||
| Install from source: | ||||
| ```bash | ||||
| python3 setup.py install | ||||
| ``` | ||||
|  | ||||
| Install from pip: | ||||
| ```bash | ||||
| pip3 install delugeClient-kevin | ||||
| ``` | ||||
|  | ||||
| ## <a name="usage"></a> Usage | ||||
| View delugeClient cli options with `delugeclient --help`: | ||||
|  | ||||
| ``` | ||||
|  Usage: python -m delugeclient [OPTIONS] COMMAND [ARGS]... | ||||
|  | ||||
| ╭─ Options ───────────────────────────────────────────────────────────────╮ | ||||
| │ --debug                       Set log level to debug                    │ | ||||
| │ --info                        Set log level to info                     │ | ||||
| │ --warning                     Set log level to warning                  │ | ||||
| │ --error                       Set log level to error                    │ | ||||
| │ --install-completion          Install completion for the current shell. │ | ||||
| │ --show-completion             Show completion for the current shell     │ | ||||
| │ --help                        Show this message and exit.               │ | ||||
| ╰─────────────────────────────────────────────────────────────────────────╯ | ||||
| ╭─ Commands ──────────────────────────────────────────────────────────────╮ | ||||
| │ add                Add magnet torrent                                   │ | ||||
| │ disk               Get free disk space                                  │ | ||||
| │ get                Get torrent by id or hash                            │ | ||||
| │ ls                 List all torrents                                    │ | ||||
| │ remove             Remove torrent by id or hash                         │ | ||||
| │ rm                 Remove torrent by name                               │ | ||||
| │ search             Search for string segment in torrent name            │ | ||||
| │ toggle             Toggle torrent download state                        │ | ||||
| │ version            Print package version                                │ | ||||
| ╰─────────────────────────────────────────────────────────────────────────╯ | ||||
| ``` | ||||
|  | ||||
| ### Running from source | ||||
| Run from source for fun or during development using module flag: | ||||
|  | ||||
| ``` | ||||
| python3 -m delugeClient --help | ||||
| ``` | ||||
|  | ||||
| ## <a name="setup_virtualenv"></a> Setup Virtual Environment | ||||
| Virtual environment allows us to create a local environment for the requirements needed. Because pip does not download packages already downloaded to your system, we can use virtualenv to save our packages in the project folder. | ||||
| @@ -41,7 +83,7 @@ To install virtualenv, simply run: | ||||
| ``` | ||||
|  | ||||
|  | ||||
| ### Usage | ||||
| ### Virtualenv setup | ||||
| After you have downloaded this project go to it in your terminal by going to the folder you downloaded and typing the following: | ||||
|  | ||||
|  | ||||
| @@ -58,8 +100,6 @@ The to setup a virtual environment enter this: | ||||
|  > If you get an error now it might be because you don't have python3.10, please make sure you have python version 3.10 if else you can download it from [here](https://www.python.org/downloads/) | ||||
|  | ||||
|  | ||||
| First we navigate to the folder we downloaded. | ||||
|  | ||||
| Then we use the ```virtualenv``` command to create a ```env``` subdirectory in our project. This is where pip will download everything to and where we can add other specific python versions. Then we need to *activate* our virtual environment by doing: | ||||
|  | ||||
| ``` | ||||
| @@ -96,51 +136,6 @@ Then you need to change the HOST and PORT to reflect the address for your deluge | ||||
|  $ cat /home/USER/.config/deluge/auth | ||||
| ``` | ||||
|  | ||||
|  | ||||
| ## <a name="install"></a> Install Required Dependencies | ||||
| Now that we have our virutalenv set up and activated we want to install all the necessary packages listed in `requirements.txt`. To install it's dependencies do the following: | ||||
|  | ||||
| ``` | ||||
|  $ pip install -r requirements.txt | ||||
| ``` | ||||
|  | ||||
| Now we have our neccessary packages installed! | ||||
|  | ||||
|  | ||||
| ## <a name="usage"></a> Usage | ||||
|  | ||||
| ``` | ||||
| Custom delugeRPC client | ||||
| Usage: | ||||
|    deluge_cli add MAGNET [DIR] [--debug | --warning | --error] | ||||
|    deluge_cli get TORRENT | ||||
|    deluge_cli ls [--downloading | --seeding | --paused] | ||||
|    deluge_cli toggle TORRENT | ||||
|    deluge_cli rm TORRENT [--debug | --warning | --error] | ||||
|    deluge_cli (-h | --help) | ||||
|    deluge_cli --version | ||||
|  | ||||
| Arguments: | ||||
|    MAGNET        Magnet link to add | ||||
|    DIR           Directory to save to | ||||
|    TORRENT       A selected torrent | ||||
|  | ||||
| Options: | ||||
|    -h --help     Show this screen | ||||
|    --version     Show version | ||||
|    --debug       Print all debug log | ||||
|    --warning     Print only logged warnings | ||||
|    --error       Print error messages (Error/Warning) | ||||
| ``` | ||||
|  | ||||
| ### <a name="running"></a> Running | ||||
| To interface with deluged : | ||||
|  | ||||
| ``` | ||||
|  $ ./deluge_cli.py ls | ||||
| ``` | ||||
|  | ||||
|  | ||||
| ## <a name="contributing"></a> Contributing | ||||
| - Fork it! | ||||
| - Create your feature branch: git checkout -b my-new-feature | ||||
|   | ||||
| @@ -2,12 +2,14 @@ | ||||
| # -*- encoding: utf-8 -*- | ||||
|  | ||||
| from sys import path | ||||
| from os.path import dirname, join | ||||
| from os.path import dirname, join, abspath | ||||
|  | ||||
| path.append(dirname(__file__)) | ||||
| SCRIPT_DIR = dirname(abspath(__file__)) | ||||
| path.append(dirname(SCRIPT_DIR)) | ||||
|  | ||||
| import logging | ||||
| from utils import BASE_DIR | ||||
| from delugeClient.utils import BASE_DIR | ||||
| from delugeClient.deluge import Deluge | ||||
|  | ||||
| def addHandler(handler): | ||||
|   handler.setFormatter(formatter) | ||||
|   | ||||
| @@ -1,5 +1,4 @@ | ||||
| #!/usr/bin/env python3.10 | ||||
|  | ||||
| import os | ||||
| import sys | ||||
| import signal | ||||
| @@ -8,10 +7,10 @@ import logging | ||||
| import typer | ||||
| from pprint import pprint | ||||
|  | ||||
| from deluge import Deluge | ||||
| from utils import ColorizeFilter, BASE_DIR, validHash, convertFilesize | ||||
| from __version__ import __version__ | ||||
| from __init__ import addHandler | ||||
| from delugeClient.deluge import Deluge | ||||
| from delugeClient.utils import ColorizeFilter, BASE_DIR, validHash, convertFilesize | ||||
| from delugeClient.__version__ import __version__ | ||||
| from delugeClient.__init__ import addHandler | ||||
|  | ||||
| ch = logging.StreamHandler() | ||||
| ch.addFilter(ColorizeFilter()) | ||||
|   | ||||
| @@ -1 +1,4 @@ | ||||
| __version__ = '0.3.1' | ||||
| __version__ = '0.3.5' | ||||
|  | ||||
| if __name__ == '__main__': | ||||
|   print(__version__) | ||||
|   | ||||
| @@ -9,9 +9,9 @@ import logging.config | ||||
|  | ||||
| from deluge_client import DelugeRPCClient, FailedToReconnectException | ||||
| from sshtunnel import SSHTunnelForwarder, BaseSSHTunnelForwarderError | ||||
| from utils import getConfig, BASE_DIR | ||||
|  | ||||
| from torrent import Torrent | ||||
| from delugeClient.utils import getConfig, BASE_DIR | ||||
| from delugeClient.torrent import Torrent | ||||
|  | ||||
| logger = logging.getLogger('deluge_cli') | ||||
|  | ||||
|   | ||||
| @@ -2,7 +2,7 @@ import json | ||||
| import logging | ||||
| from distutils.util import strtobool | ||||
|  | ||||
| from utils import convert | ||||
| from delugeClient.utils import convert | ||||
|  | ||||
| logger = logging.getLogger('deluge_cli') | ||||
|  | ||||
| @@ -44,5 +44,5 @@ class Torrent(object): | ||||
|     return json.dumps(torrentDict) | ||||
|  | ||||
|   def __str__(self): | ||||
|     return "{} {} Progress: {}% ETA: {} State: {} Paused: {}".format( | ||||
|       self.key, self.name[:59].ljust(60), self.progress.rjust(5), self.eta.rjust(11), self.state.ljust(12), self.paused) | ||||
|     return "{} Progress: {}% ETA: {} State: {} Paused: {}".format( | ||||
|       self.name[:59].ljust(60), self.progress.rjust(5), self.eta.rjust(11), self.state.ljust(12), self.paused) | ||||
|   | ||||
							
								
								
									
										19
									
								
								publish_version?.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								publish_version?.sh
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,19 @@ | ||||
| #!/usr/bin/bash | ||||
|  | ||||
| PYPI_VERSION=$(pip3 show delugeClient-kevin | awk '$1 ~ /Version:/ { print $2 }') | ||||
| SOURCE_VERSION=$(python3 delugeClient/__version__.py) | ||||
|  | ||||
| printf "Source version:\t\t %s\n" $SOURCE_VERSION | ||||
| printf "Remote PyPi version:\t %s\n" $PYPI_VERSION | ||||
|  | ||||
| function version { | ||||
|   echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'; | ||||
| } | ||||
|  | ||||
| if [ $(version $SOURCE_VERSION) -gt $(version $PYPI_VERSION) ]; then | ||||
|   echo "Soure is newer than remote, publishing!" | ||||
|   exit 0 | ||||
| else | ||||
|   echo "Source is same or oldre than remote, nothing to do." | ||||
|   exit 1 | ||||
| fi | ||||
| @@ -1,5 +1,5 @@ | ||||
| colored==1.4.4 | ||||
| deluge-client==1.9.0 | ||||
| requests==2.28.1 | ||||
| requests==2.31.0 | ||||
| sshtunnel==0.4.0 | ||||
| typer==0.7.0 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user