pyTivo Discussion Forum Forum Index pyTivo Discussion Forum
Answers and the development of pyTivo a TiVo transcoding server
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Preventing Windows 7 sleep during transfers
Goto page 1, 2  Next
 
Post new topic   Reply to topic    pyTivo Discussion Forum Forum Index -> Support
 View previous topic :: View next topic  
Author Message
stevehogan



Joined: 18 Mar 2012
Posts: 7

PostPosted: Sun Mar 18, 2012 1:41 am    Post subject: Preventing Windows 7 sleep during transfers Reply with quote

If this has been asked and answered 1) I apologize and 2) would appreciate someone pointing me at the answer. I cannot find it.

Is there a way to prevent Windows 7 from going to sleep during a transfer? Being a good green guy (Irish) I have my PS set to go to sleep after 20 minutes of inactivity. Of course, Windows does not recognize a pyTivo transfer as "activity" and the machine goes to sleep. I can wake up the machine remotely (using an app on my Android phone) so I can get the shares to show up (after waiting a few minuted for the beacon to do its job). However, when I start a transfer, it stops in 20 minutes when the PC goes to sleep.

I have found some thoughts on coding to prevent systems from going to sleep (this problem is apparently not unique to pyTivo) but am not smart enough to know how to implement them

Any ideas?
Back to top
View user's profile Send private message
philhu



Joined: 04 Jan 2008
Posts: 474

PostPosted: Mon Mar 19, 2012 12:56 pm    Post subject: Reply with quote

Try this program:

http://www.vistax64.com/general-discussion/222308-vista-goes-sleep-while-burning-dvd.html#post1022013

It will make your computer stay awak, run an app, when done, it goes back to 'standard' mode

I'm not quite sure how you would incorporate it into the system, maybe connect the batch commands doing the transfer through this
Back to top
View user's profile Send private message
stevehogan



Joined: 18 Mar 2012
Posts: 7

PostPosted: Mon Mar 19, 2012 1:56 pm    Post subject: Reply with quote

Thanks. This is definitely a step in the right direction. However, it apparently doesn't work in Windows 7 according to a later post in the same thread http://www.vistax64.com/general-discussion/222308-vista-goes-sleep-while-burning-dvd-2.html#post1229022

I have not verified that it does not work yet, but I have seen other discussions claiming that calls to SetThreadExecutionState don't seem to work as described in Windows 7. Will try this later today.

Given my severely rusty programming skills, I will probably do more damage than I am worth trying this Confused

EDIT: Here is a thread describing the problem with Windows 7. http://answers.microsoft.com/en-us/windows/forum/windows_7-performance/windows-7-sleeps-more-than-the-7-dwarfs/c48d35f1-2604-4404-9b60-bf3c69f42d59

Here is another one with MAYBE a hint of a kinda cure http://answers.microsoft.com/en-us/windows/forum/windows_7-performance/windows-7-enters-standby-while-cscript-is-running/51b8e4ae-28d8-40cc-99b9-d106235da25c

More details ... If the system goes to sleep when there are no transfers, I understand that the Shares will disappear from my Tivo. I use an Android app on my phone to send a Wake Up on LAN command to the PC and a few moments later, the shares are there, which is acceptable. Then, if I start a transfer, 20 minutes later, the server goes to sleep and the transfer crashes.

Any help would be much appreciated.
Back to top
View user's profile Send private message
philhu



Joined: 04 Jan 2008
Posts: 474

PostPosted: Tue Mar 20, 2012 1:23 pm    Post subject: Reply with quote

Try this one:

http://www.windows7download.com/win7-no-sleep/qzwrddkd.html
Back to top
View user's profile Send private message
stevehogan



Joined: 18 Mar 2012
Posts: 7

PostPosted: Wed Mar 21, 2012 12:56 am    Post subject: Reply with quote

Thanks for the suggestion. I already have this app. It works fine for those situations where I am at the PC when I initiate the task. However, what I really need is something that will trigger when I start a transfer remotely i.e. a pull from the tivo end. I am going to try to figure out how this thing works and perhaps build a version that I can call from pytivo. Any additional suggestions from anyone will be appreciated.

EDIT: FWIW, here is another approach to solving the problem. This moves the mouse 1 pixel back and forth every 30 seconds or so and uses that to keep things awake.

http://www.symantec.com/connect/downloads/readynosleepexe-prevents-screensaver-and-pc-locking
Back to top
View user's profile Send private message
philhu



Joined: 04 Jan 2008
Posts: 474

PostPosted: Thu Mar 22, 2012 1:01 pm    Post subject: Reply with quote

cant you modify pytivo so it calls this app to keep awake at the start of the transfer?
Back to top
View user's profile Send private message
stevehogan



Joined: 18 Mar 2012
Posts: 7

PostPosted: Thu Mar 22, 2012 2:19 pm    Post subject: Reply with quote

Actually I can't modify python at all Smile The last time I wrote any meaningful code of any kind (except for some truly lame HTML) was 1991 Sad

I did find this document from Microsoft that seems to describe the methods to use with Windows 7.

http://www.google.com/url?sa=t&source=web&cd=4&ved=0CB0QFjAD&url=http%3A%2F%2Fdownload.microsoft.com%2Fdownload%2F7%2FE%2F7%2F7E7662CF-CBEA-470B-A97E-CE7CE0D98DC2%2FAvailabilityRequests.docx&ei=PLIQTP-nCoaHnQe7v63LBw&usg=AFQjCNHXIYVHqPI8wULojjB4i0cDmB5LBg

I am going to flog through this thing to see if I can figure out what needs to happen and also flog through pytivo to see if I can figure out where the transfer requests are processed. Any guidance would be appreciated.
Back to top
View user's profile Send private message
lucasnz



Joined: 13 Sep 2010
Posts: 251

PostPosted: Thu Mar 22, 2012 7:37 pm    Post subject: Reply with quote

I'd be interested in including this functionality in my fork of pytivo. The difficulty is, while pytivo knows when the transfer starts, it doesn't really know when they are complete. Perhaps delaying sleep by 5 minutes each time data is transferred would work? Alternatively there is a clean up function that clears off failed transfers.

This article describes how to call win32 functions in python:
http://docs.python.org/library/ctypes.html

If you figure can figure out the correct commands to delay sleep for 5 mins then (or to stop sleep), then I can assist in integrating it into pytivo.

Luke
Back to top
View user's profile Send private message
stevehogan



Joined: 18 Mar 2012
Posts: 7

PostPosted: Thu Mar 22, 2012 11:23 pm    Post subject: Reply with quote

Cool! This sounds like a good project to keep me out of the bars this weekend Smile I will take a run at it.
Back to top
View user's profile Send private message
Iluvatar



Joined: 29 Feb 2008
Posts: 335

PostPosted: Fri Mar 23, 2012 12:45 am    Post subject: Reply with quote

lucasnz wrote:
I'd be interested in including this functionality in my fork of pytivo. The difficulty is, while pytivo knows when the transfer starts, it doesn't really know when they are complete. Perhaps delaying sleep by 5 minutes each time data is transferred would work? Alternatively there is a clean up function that clears off failed transfers.

This article describes how to call win32 functions in python:
http://docs.python.org/library/ctypes.html

If you figure can figure out the correct commands to delay sleep for 5 mins then (or to stop sleep), then I can assist in integrating it into pytivo.

Luke


Not sure on *nix yet but the consensus on Win is with 'SetThreadExecutionState'

Example from SABnzbd:
Code:

def keep_awake():
    """ If we still have work to do, keep Windows system awake
"""
    global KERNEL32
    if KERNEL32 and not sabnzbd.downloader.Downloader.do.paused:
        if (not PostProcessor.do.empty()) or not NzbQueue.do.is_empty():
            # set ES_SYSTEM_REQUIRED
            KERNEL32.SetThreadExecutionState(ctypes.c_int(0x00000001))

_________________
My pyTivo fork - Read link for changes
FFmpeg for OS X
Back to top
View user's profile Send private message
stevehogan



Joined: 18 Mar 2012
Posts: 7

PostPosted: Fri Mar 23, 2012 1:12 am    Post subject: Reply with quote

Specifically on Win prior to Win 7, SetThreadExecutionState( ES_CONTINUOUS | ES_SYSTEM_REQUIRED )

However, I have stumbled across enough stuff now saying this does not work as advertised i.e. does not work in Win7 in the same way it worked in Vista and XP (don't know why as yet but trying to figure it out) and, worse yet, other programs running concurrently (for whatever reason) can turn this thing off (for example, scheduled virus scan). FWIW, Microsoft for Win7 is pushing Power Availability Requests per this Microsoft white paper http://www.microsoft.com/whdc/system/pnppwr/powermgmt/AvailabilityRequests.mspx

Still don't know exactly what this all means. I suppose worst case it means one version for Win7 and another for prior WIN (ugh).

I guess I opened a small can of ugly little worms here Smile
Thanks for flogging this issue. I really appreciate it.
Back to top
View user's profile Send private message
lucasnz



Joined: 13 Sep 2010
Posts: 251

PostPosted: Fri Mar 23, 2012 2:30 am    Post subject: Reply with quote

I don't see any reason to support pre win7 for this feature...
Back to top
View user's profile Send private message
wmcbrine



Joined: 04 Jan 2008
Posts: 2009
Location: Maryland

PostPosted: Fri Mar 23, 2012 3:38 am    Post subject: Reply with quote

You're using pyTivo intermittently -- why not stop it and start it when you need it, instead of treating it as a full-time service, but having to manually wake the server each time? That would eliminate the delay you're seeing, since pyTivo is recognized immediately when it first starts up. And you could wrap pyTivo as a whole in your sleep-defeater, if necessary.

The idea that it's OK for shares to disappear while pyTivo is running (but not for transfers to be interrupted), and that we should design for that, is not one that I can embrace.

_________________
My pyTivo fork . My page
Back to top
View user's profile Send private message Visit poster's website
stevehogan



Joined: 18 Mar 2012
Posts: 7

PostPosted: Fri Mar 23, 2012 4:43 am    Post subject: Reply with quote

No, It is not that I am actually using it intermittently; I just want to save a few kw of electricity and not have to haul my fat butt up the stairs and start pytivo just to transfer a movie. The way I would like to use this is to start it up remotely (using wake up on LAN from my Android phone) then transfer a file from the library. Perhaps this does not meet your vision of how this should work and for that I truly apologize. I do truly do appreciate the work you have done creating this and I do apologize if I have in some manner offended you or anyone else. Not everyone in this world does everything the same way. FWIW, (per lucansz) I see no reason to support pre WIN7 either inasmuch as those versions of Windows are dying a well-deserved death. Thanks to everyone who has contributed to this effort thus far. If a solution becomes available, I would appreciate seeing it. If I am able to flog through this and develop one myself, I will be delighted to share it with everyone who is interested. The next step in this process will be for me to figure out how to cause a Wake up on Lan based upon a packet being received from a specific IP (my Tivo, which has a fixed IP) so that perhaps I can force the Tivo to cause the PC to wake up (perhaps this is impossible).

Just so you know, my incentive for this was having an unattended PC (my previous pytivo source running 24 hours a day) have a failure that blew a physical hole in the motherboard and costing me about two weeks of recovery work. I have thus promised myself to do whatever I can to minimize the stress on my system going forward. Hence this request. Respectfully submitted.
Back to top
View user's profile Send private message
wmcbrine



Joined: 04 Jan 2008
Posts: 2009
Location: Maryland

PostPosted: Fri Mar 23, 2012 5:58 am    Post subject: Reply with quote

I don't know why you'd think I was offended. All I'm saying is, no. Smile For me, anyway.

There's no reason that starting pyTivo should require a physical trip, BTW. Even Windows has an optional telnet service, or of course you can do the remote framebuffer thing.

_________________
My pyTivo fork . My page
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    pyTivo Discussion Forum Forum Index -> Support All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum
Site is in NO WAY affiliated with TiVo Inc

Powered by phpBB © 2001, 2005 phpBB Group
phpBB SEO

Get pytivo at SourceForge.net. Fast, secure and Free Open Source software downloads
[ Time: 1.2358s ][ Queries: 12 (0.0154s) ][ GZIP on - Debug on ]