[Plugin] Autoshutdown - Shutdown PC once torrents complete

Suggest, post, or discuss plugins for Deluge
monkey_maniac
New User
New User
Posts: 4
Joined: Mon Jul 22, 2013 12:14 pm
OS or Distro: Ubuntu Server

Re: [Plugin] Autoshutdown - Shutdown PC once torrents comple

Postby monkey_maniac » Mon Jul 22, 2013 12:18 pm

Cas wrote:I had been working on adding windows code to the plugin but never got around to testing it. The eggs are below for anyone wishing to help test it for me. If you have any issue enable debug logging and look for AutoShutdown messages.

Edit: I was testing on Linux and found several major issues so fixed them and have attached the new version. It is still untested on Windows so some feedback would be helpful.


Can you publish the source?

Cheers

Cas
Top Bloke
Top Bloke
Posts: 3463
Joined: Mon Dec 07, 2009 6:04 am
OS or Distro: Ubuntu 16.04
Location: Scotland

Re: [Plugin] Autoshutdown - Shutdown PC once torrents comple

Postby Cas » Wed Jul 24, 2013 8:46 am

monkey_maniac wrote:Can you publish the source?

https://github.com/cas--/autoshutdown

monkey_maniac
New User
New User
Posts: 4
Joined: Mon Jul 22, 2013 12:14 pm
OS or Distro: Ubuntu Server

Re: [Plugin] Autoshutdown - Shutdown PC once torrents comple

Postby monkey_maniac » Sun Jul 28, 2013 10:44 pm

Cool thanks scotty :)

monkey_maniac
New User
New User
Posts: 4
Joined: Mon Jul 22, 2013 12:14 pm
OS or Distro: Ubuntu Server

Re: [Plugin] Autoshutdown - Shutdown PC once torrents comple

Postby monkey_maniac » Tue Jul 30, 2013 5:54 pm

I have given 1.1 a go on Ubuntu Server 13.04 and you need to install the python-dbus package otherwise you'll get the following error:

Code: Select all

[ERROR   ] 18:09:53 pluginmanagerbase:146 Unable to instantiate plugin!
[ERROR   ] 18:09:53 pluginmanagerbase:147 No module named dbus
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/deluge/pluginmanagerbase.py", line 144, in enable_plugin
    instance = cls(plugin_name.replace("-", "_"))
  File "build/bdist.linux-x86_64/egg/autoshutdown/__init__.py", line 44, in __init__
    from core import Core as _plugin_cls
  File "build/bdist.linux-x86_64/egg/autoshutdown/core.py", line 58, in <module>
ImportError: No module named dbus


The next problem is dbus related, but I have next to no knowledge on it. It seems somewhat related to the fact that I'm running it headless.

Code: Select all

[ERROR   ] 18:15:33 init:51 org.freedesktop.DBus.Error.NotSupported: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/deluge/plugins/init.py", line 48, in enable
    self.plugin.enable()
  File "build/bdist.linux-x86_64/egg/autoshutdown/core.py", line 91, in enable
    bus = dbus.Bus(dbus.Bus.TYPE_SESSION)
  File "/usr/lib/python2.7/dist-packages/dbus/_dbus.py", line 100, in __new__
    bus = BusConnection.__new__(subclass, bus_type, mainloop=mainloop)
  File "/usr/lib/python2.7/dist-packages/dbus/bus.py", line 122, in __new__
    bus = cls._new_for_bus(address_or_type, mainloop=mainloop)
DBusException: org.freedesktop.DBus.Error.NotSupported: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11


It looks like it should be using 'org.freedesktop.UPower' and it's probably worth logging out original underlying exception to rule out for sanity sake.

I have tried installing dbus-x11, and running the following:

Code: Select all

monkey@media-server:~/.config$ dbus-launch --sh-syntax
DBUS_SESSION_BUS_ADDRESS='unix:abstract=/tmp/dbus-QYf8bEnb6J,guid=d4f011ea42e72139a631088e51f7fb66';
export DBUS_SESSION_BUS_ADDRESS;
DBUS_SESSION_BUS_PID=2372;
monkey@media-server:~/.config$ dbus-monitor
Failed to open connection to session bus: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
monkey@media-server:~/.config$ export DISPLAY=:0
monkey@media-server:~/.config$ dbus-monitor
Failed to open connection to session bus: //bin/dbus-launch terminated abnormally with the following error: Autolaunch error: X11 initialization failed.

monkey_maniac
New User
New User
Posts: 4
Joined: Mon Jul 22, 2013 12:14 pm
OS or Distro: Ubuntu Server

Re: [Plugin] Autoshutdown - Shutdown PC once torrents comple

Postby monkey_maniac » Wed Jul 31, 2013 12:33 pm

Made a bit of progress - you can connect to the system dbus instance:

Code: Select all

dbus-send --system --print-reply --dest=org.freedesktop.ConsoleKit /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Stop


Although you will need to set up permissions for the relevant user:

Code: Select all

[Actions for my user]
Identity=unix-user:monkey
Action=org.freedesktop.upower.*;org.freedesktop.consolekit.system.*;org.freedesk​top.udisks.*
ResultAny=yes
ResultInactive=no
ResultActive=yes


I will see if I can do this in python...

niawag
New User
New User
Posts: 2
Joined: Fri Sep 20, 2013 3:58 pm
OS or Distro: Windows 7

Re: [Plugin] Autoshutdown - Shutdown PC once torrents comple

Postby niawag » Fri Sep 20, 2013 4:01 pm

Hi and thanks for your plugin, I've tried the version made for windows but I'm facing a bug :

Code: Select all

ImportError: No module named ntsecuritycon
Unable to instantiate plugin!
No module named ntsecuritycon
Traceback (most recent call last):
  File "deluge\pluginmanagerbase.py", line 144, in enable_plugin
  File "c:\users\xxx\appdata\roaming\deluge\plugins\autoshutdown-1.1-py2.6.egg\autoshutdown\__init__.py", line 44, in __init__
    from core import Core as _plugin_cls
  File "c:\users\xxx\appdata\roaming\deluge\plugins\autoshutdown-1.1-py2.6.egg\autoshutdown\core.py", line 53, in <module>
ImportError: No module named ntsecuritycon


Do you know if this can be solved easily?
I don't have much time now to try debugging it but I could give a hand later.

Cas
Top Bloke
Top Bloke
Posts: 3463
Joined: Mon Dec 07, 2009 6:04 am
OS or Distro: Ubuntu 16.04
Location: Scotland

Re: [Plugin] Autoshutdown - Shutdown PC once torrents comple

Postby Cas » Fri Sep 20, 2013 5:51 pm

Ah likely because I was testing in dev mode that has all the win32 python modules. The Deluge has a reduced set of only those required.

Replace:

Code: Select all

from ntsecuritycon import TOKEN_ADJUST_PRIVILEGES, TOKEN_QUERY, SE_SHUTDOWN_NAME, SE_PRIVILEGE_ENABLED

with:

Code: Select all

TOKEN_QUERY = 8
TOKEN_ADJUST_PRIVILEGES = 32
SE_SHUTDOWN_NAME = "SeShutdownPrivilege"
SE_PRIVILEGE_ENABLED = 2


Make sure the indentation is correct (4 spaces)

niawag
New User
New User
Posts: 2
Joined: Fri Sep 20, 2013 3:58 pm
OS or Distro: Windows 7

Re: [Plugin] Autoshutdown - Shutdown PC once torrents comple

Postby niawag » Mon Sep 23, 2013 9:07 am

Hi and thanks for your answer, I replaced the code and it's working, I can add the plugin. I'll test if it work as intended as soon as possible.

EDIT : just tested and it worked just great with hibernation, thanks a lot!

vondawe
New User
New User
Posts: 1
Joined: Thu Mar 20, 2014 11:48 am
OS or Distro: Windows

Re: [Plugin] Autoshutdown - Shutdown PC once torrents comple

Postby vondawe » Thu Mar 20, 2014 12:55 pm

Hi!
I just tested the plugin on Windows. Replaced the code in core.py and the plugin started working. When a torrent finishes i can choose to hibernate the computer, so far so good.
But the problem is that the plugin does not seem to recoqnize when there are several torrents in queue. I have limited my deluge client to only download 1 torrent at a time and the rest are queued and paused.
Is it possible to make the plugin recognize the paused-queued torrents and not hibernate/shutdown until all torrents have been downloaded?

ooEagleOneoo
New User
New User
Posts: 2
Joined: Tue Nov 25, 2014 8:39 am
OS or Distro: Windows 7 64

New User needs help please

Postby ooEagleOneoo » Wed Nov 26, 2014 5:22 am

Hi all, I have just changed from Utorrent to Deluge, what l have found is, say l have a torrent with only 3 seeders, in Utorrent it will not connect to those 3 seeders, but when I fire up Deluge those 3 seeders come straight in and l start downloading.
My one problem is I would like deluge to shut-down my PC when all my torrents have finished downloading, In Pref then Plugins, I have turned on Autoshutdown with the green light or dot on shut-down. but it does not shut-down my PC.
I am not a coder and have no idea, can anyone help me please. using 1.3.6 as others are banned in certain torrent sites except 1.3.6. using Windows 7 64.


Return to “Plugins”

Who is online

Users browsing this forum: Bing [Bot] and 7 guests