diff --git a/config.ini b/config.ini index ac7b526..71599d9 100644 --- a/config.ini +++ b/config.ini @@ -1,10 +1,11 @@ [Deluge] -HOST = YOUR_DELUGE_HOST +HOST = YOUR_DELUGE_HOST_IP PORT = YOUR_DELUGE_PORT USER = YOUR_DELUGE_USER PASSWORD = YOUR_DELUGE_PASSWORD [ssh] -HOST = YOUR_DELUGE_SERVER_IP +HOST = YOUR_SSH_HOST_IP USER = YOUR_SSH_USER -PKEY = YOUR_SSH_PRIVATE_KEY_DIRECTORY \ No newline at end of file +PKEY = YOUR_SSH_PRIVATE_KEY_DIR +PASSWORD = YOUR_SSH_PASSWORD diff --git a/deluge_cli.py b/deluge_cli.py index b4144fa..3ce9fc3 100755 --- a/deluge_cli.py +++ b/deluge_cli.py @@ -96,6 +96,7 @@ class Deluge(object): self.ssh_host = config['ssh']['HOST'] self.ssh_user = config['ssh']['USER'] + self.ssh_password = config['ssh']['PASSWORD'] self.ssh_pkey = config['ssh']['PKEY'] self._connect() @@ -110,8 +111,12 @@ class Deluge(object): def _connect(self): logger.info('Checking if script on same server as deluge RPC') if (socket.gethostbyname(socket.gethostname()) != self.host): - self.tunnel = SSHTunnelForwarder(self.ssh_host, ssh_username=self.ssh_user, ssh_pkey=self.ssh_pkey, - local_bind_address=('localhost', self.port), remote_bind_address=('localhost', self.port)) + if (self.ssh_password): + self.tunnel = SSHTunnelForwarder(self.ssh_host, ssh_username=self.ssh_user, ssh_password=self.ssh_password, + local_bind_address=('localhost', self.port), remote_bind_address=('localhost', self.port)) + else: + self.tunnel = SSHTunnelForwarder(self.ssh_host, ssh_username=self.ssh_user, ssh_pkey=self.ssh_pkey, + local_bind_address=('localhost', self.port), remote_bind_address=('localhost', self.port)) self.tunnel.start() self.client = DelugeRPCClient(self.host, self.port, self.user, self.password) diff --git a/test.py b/test.py new file mode 100644 index 0000000..95774ee --- /dev/null +++ b/test.py @@ -0,0 +1,7 @@ +import deluge_cli + +resp = deluge_cli.main('ls') +for el in list(resp): + print(el) + +# print(resp)