mirror of
				https://github.com/KevinMidboe/delugeClient.git
				synced 2025-10-29 12:00:13 +00:00 
			
		
		
		
	Compare commits
	
		
			3 Commits
		
	
	
		
			socket
			...
			py2-compat
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| a2c9180752 | |||
| 6ca9e91bd7 | |||
| 5e39ecb8bc | 
| @@ -9,7 +9,7 @@ Usage: | ||||
|    deluge_cli ls [--downloading | --seeding | --paused] | ||||
|    deluge_cli toggle TORRENT | ||||
|    deluge_cli progress | ||||
|    deluge_cli rm NAME [--debug | --warning | --error] | ||||
|    deluge_cli rm NAME [--destroy | --debug | --warning | --error] | ||||
|    deluge_cli (-h | --help) | ||||
|    deluge_cli --version | ||||
|  | ||||
| @@ -24,6 +24,7 @@ Options: | ||||
|    --debug       Print all debug log | ||||
|    --warning     Print only logged warnings | ||||
|    --error       Print error messages (Error/Warning) | ||||
|    --destroy     When removing choose to remove file on disk | ||||
| """ | ||||
|  | ||||
| import argparse | ||||
| @@ -42,7 +43,7 @@ from pprint import pprint | ||||
| from deluge_client import DelugeRPCClient | ||||
| from sshtunnel import SSHTunnelForwarder | ||||
| from docopt import docopt | ||||
| from .utils import ColorizeFilter, convert | ||||
| from utils import ColorizeFilter, convert | ||||
|  | ||||
| BASE_DIR = os.path.dirname(os.path.abspath(__file__)) | ||||
|  | ||||
| @@ -150,7 +151,7 @@ class Deluge(object): | ||||
|        | ||||
|       print('Response:', response) | ||||
|  | ||||
|    def remove(self, name): | ||||
|    def remove(self, name, destroyFiles=False): | ||||
|       matches = list(filter(lambda t: t.name == name, self.get_all())) | ||||
|       logger.info('Matches for {}: {}'.format(name, matches)) | ||||
|        | ||||
| @@ -158,7 +159,7 @@ class Deluge(object): | ||||
|          raise ValueError('Multiple files found matching key. Unable to remove.') | ||||
|       elif (len(matches) == 1): | ||||
|          torrent = matches[0] | ||||
|          response = self.client.call('core.remove_torrent', torrent.key, False) | ||||
|          response = self.client.call('core.remove_torrent', torrent.key, destroyFiles) | ||||
|          logger.info('Response: {}'.format(str(response))) | ||||
|  | ||||
|          if (response == False): | ||||
| @@ -298,8 +299,9 @@ def main(): | ||||
|       deluge.togglePaused(_id) | ||||
|  | ||||
|    elif arguments['rm']: | ||||
|       logger.info('Remove by name: {}'.format(name)) | ||||
|       deluge.remove(name) | ||||
|       destroy = arguments['--destroy'] | ||||
|       logger.info('Remove by name: {}. Destroy files: {}'.format(name, destroy)) | ||||
|       deluge.remove(name, destroy) | ||||
|  | ||||
| if __name__ == '__main__': | ||||
|    main() | ||||
|   | ||||
| @@ -6,7 +6,6 @@ cryptography==2.3 | ||||
| deluge-client==1.6.0 | ||||
| docopt==0.6.2 | ||||
| idna==2.7 | ||||
| paramiko==2.4.1 | ||||
| pyasn1==0.4.4 | ||||
| pycparser==2.18 | ||||
| PyNaCl==1.2.1 | ||||
|   | ||||
							
								
								
									
										2
									
								
								utils.py
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								utils.py
									
									
									
									
									
								
							| @@ -35,7 +35,7 @@ class ColorizeFilter(logging.Filter): | ||||
|       return True | ||||
|  | ||||
| def convert(data): | ||||
|     if isinstance(data, bytes):  return data.decode('ascii') | ||||
|     if isinstance(data, bytes):  return data.decode('utf-8') | ||||
|     if isinstance(data, dict):   return dict(map(convert, data.items())) | ||||
|     if isinstance(data, tuple):  return map(convert, data) | ||||
|     json_data = json.dumps(data) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user