SageTV Community  

Go Back   SageTV Community > SageTV Development and Customizations > SageTV Studio
Forum Rules FAQs Community Downloads Today's Posts Search

Notices

SageTV Studio Discussion related to the SageTV Studio application produced by SageTV. Questions, issues, problems, suggestions, etc. relating to the Studio software application should be posted here.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 08-11-2010, 12:38 PM
evilpenguin's Avatar
evilpenguin evilpenguin is offline
SageTVaholic
 
Join Date: Aug 2003
Location: Seattle, WA
Posts: 3,696
Creating nightly task from STVi

I'm looking to write some studio code that will run an executable nightly (i.e. every night at 2am, run this process), can someone point me in the right direction?
__________________
Clients: 1xHD200 Connected to 50" TH-50PZ750U Plasma
Server : Shuttle SFF SSH55J2 w/ Win7 Home, SageTV v7, Core i3 540, 2GB RAM, 30GB SSD for OS, 1.5TB+2x1TB WDGP for Recordings, BluRay, 2xHDHR, 1xFirewire
SageTV : PlayOn, SJQ, MediaShrink, Comskip, Jetty, Web Client, BMT


Having a problem? Don't forget to include a log! (Instructions for: PlayOn For SageTV v1.5, MediaShrink)
Reply With Quote
  #2  
Old 08-11-2010, 12:53 PM
tmiranda's Avatar
tmiranda tmiranda is offline
SageTVaholic
 
Join Date: Jul 2005
Location: Central Florida, USA
Posts: 5,851
Without knowing the details it sounds like you could do this from Java in a "standard" plugin using TimerTask(). Does it have to be in Studio? Remember that if the UI goes away (extender turned off, client or placeshifter disconnected) there is no UI so you can't guarantee the process will execute.

Tom
__________________

Sage Server: 8th gen Intel based system w/32GB RAM running Ubuntu Linux, HDHomeRun Prime with cable card for recording. Runs headless. Accessed via RD when necessary. Four HD-300 Extenders.
Reply With Quote
  #3  
Old 08-11-2010, 12:56 PM
GKusnick's Avatar
GKusnick GKusnick is offline
SageTVaholic
 
Join Date: Dec 2005
Posts: 5,083
It's doable, using Fork(), Wait(), and ExecuteProcess(). But are you sure you really want to do it from an STVI? That would have the effect of kicking off a separate instance of the executable for each connected client. Typically you'd want to launch just one instance, regardless of how many clients are connected. For that, your best bet is a Standard plugin written in Java and using a java.util.Timer to kick off your executable at predefined times or intervals.
__________________
-- Greg
Reply With Quote
  #4  
Old 08-11-2010, 01:19 PM
evilpenguin's Avatar
evilpenguin evilpenguin is offline
SageTVaholic
 
Join Date: Aug 2003
Location: Seattle, WA
Posts: 3,696
Yeah, that's really the proper way of doing it, I was just hoping to get away without writing any *shudder* Java. Oh well, can someone point me towards Standard Plug-in 101, I can't seem to find any official info?

Edit: Found the .doc hidden in this thread, prolly should be added to one of the Studio Stickies.
__________________
Clients: 1xHD200 Connected to 50" TH-50PZ750U Plasma
Server : Shuttle SFF SSH55J2 w/ Win7 Home, SageTV v7, Core i3 540, 2GB RAM, 30GB SSD for OS, 1.5TB+2x1TB WDGP for Recordings, BluRay, 2xHDHR, 1xFirewire
SageTV : PlayOn, SJQ, MediaShrink, Comskip, Jetty, Web Client, BMT


Having a problem? Don't forget to include a log! (Instructions for: PlayOn For SageTV v1.5, MediaShrink)

Last edited by evilpenguin; 08-11-2010 at 01:21 PM.
Reply With Quote
  #5  
Old 08-11-2010, 01:55 PM
tmiranda's Avatar
tmiranda tmiranda is offline
SageTVaholic
 
Join Date: Jul 2005
Location: Central Florida, USA
Posts: 5,851
EP,

If you like I can email you the Java framework/stub code that I use for standard plugins. PM your email address if interested.

Tom
__________________

Sage Server: 8th gen Intel based system w/32GB RAM running Ubuntu Linux, HDHomeRun Prime with cable card for recording. Runs headless. Accessed via RD when necessary. Four HD-300 Extenders.
Reply With Quote
  #6  
Old 08-11-2010, 02:00 PM
GKusnick's Avatar
GKusnick GKusnick is offline
SageTVaholic
 
Join Date: Dec 2005
Posts: 5,083
Also note that my Tools Library includes an abstract class that makes writing a Standard plugin pretty painless. Just extend that class and fill in the bits specific to your plugin. I think Stuckless has something similar in his Sagex library.

Mine also allows you to define your config options (if any) in XML form, so there's even less Java code to write.

I can post a simple skeleton plugin if you like.
__________________
-- Greg
Reply With Quote
  #7  
Old 08-11-2010, 02:02 PM
evilpenguin's Avatar
evilpenguin evilpenguin is offline
SageTVaholic
 
Join Date: Aug 2003
Location: Seattle, WA
Posts: 3,696
I found these two threads which seem to be pretty helpful for a complete newb...

Standard Plugin - Sanity check please -I imagine this is pretty close to the stub code you're talking about. Is the framework you're talking about something special that gets imported into the IDE for quick development? If so please do send it my way, i'll PM you the address.

Pre-v7 Instructions for setting up Eclipse - I'd love it if someone could expand on these instructions for working with the v7 Standard plug-in interface.
__________________
Clients: 1xHD200 Connected to 50" TH-50PZ750U Plasma
Server : Shuttle SFF SSH55J2 w/ Win7 Home, SageTV v7, Core i3 540, 2GB RAM, 30GB SSD for OS, 1.5TB+2x1TB WDGP for Recordings, BluRay, 2xHDHR, 1xFirewire
SageTV : PlayOn, SJQ, MediaShrink, Comskip, Jetty, Web Client, BMT


Having a problem? Don't forget to include a log! (Instructions for: PlayOn For SageTV v1.5, MediaShrink)
Reply With Quote
  #8  
Old 08-11-2010, 02:05 PM
evilpenguin's Avatar
evilpenguin evilpenguin is offline
SageTVaholic
 
Join Date: Aug 2003
Location: Seattle, WA
Posts: 3,696
Quote:
Originally Posted by GKusnick View Post
Also note that my Tools Library includes an abstract class that makes writing a Standard plugin pretty painless. Just extend that class and fill in the bits specific to your plugin. I think Stuckless has something similar in his Sagex library.

Mine also allows you to define your config options (if any) in XML form, so there's even less Java code to write.

I can post a simple skeleton plugin if you like.
Please do post an example, i'm a little lost on how to get started.
__________________
Clients: 1xHD200 Connected to 50" TH-50PZ750U Plasma
Server : Shuttle SFF SSH55J2 w/ Win7 Home, SageTV v7, Core i3 540, 2GB RAM, 30GB SSD for OS, 1.5TB+2x1TB WDGP for Recordings, BluRay, 2xHDHR, 1xFirewire
SageTV : PlayOn, SJQ, MediaShrink, Comskip, Jetty, Web Client, BMT


Having a problem? Don't forget to include a log! (Instructions for: PlayOn For SageTV v1.5, MediaShrink)
Reply With Quote
  #9  
Old 08-11-2010, 02:13 PM
GKusnick's Avatar
GKusnick GKusnick is offline
SageTVaholic
 
Join Date: Dec 2005
Posts: 5,083
Here you go:

Code:
public class MyPlugin extends XmlConfig.Plugin
    {

    public MyPlugin(sage.SageTVPluginRegistry reg, boolean fReset)
        {
    //  Load XML config info from JAR file resource.
    //  (You can also use an external XML file if that's simpler for you.)
        super(XmlConfig.FromResource(MyPlugin.class, "MyPlugin.config.xml"));
        
        if (fReset)
            resetConfig();

        }

    public void start()
        {
        StartTimerTask();
        }

    public void stop()
        {
        StopTimerTask();
        }

    public void setConfigValue(String szSetting, String szValue)
        {
    //  Do any required validation of the setting value.

        super.setConfigValue(szSetting, szValue);

    //  Restart the task with the new settings.
        StopTimerTask();
        StartTimerTask();
        }

    private java.util.Timer timer = null;
    private java.util.TimerTask task = null;

    private void StartTimerTask()
        {
    //  Get task start time and period from .properties file.
    
        task = new java.util.TimerTask()
            {
            public void run()
                {
            //  Do your thing.
                }
            };
        
        if (timer == null)
            timer = new java.util.Timer("MyTimer", true);
        timer.scheduleAtFixedRate(task, tStart, dtPeriod);

        }

    private void StopTimerTask()
        {
        if (task != null)
            {
            task.cancel();
            task = null;
            }
        }

    }
Disclaimer: this is stripped down from an actual working plugin and has not been tested in this exact form, but it should cover the essentials.

Edit: The explanation of the XML config format is in the XmlConfig Javadocs included with my library.
__________________
-- Greg
Reply With Quote
  #10  
Old 08-11-2010, 02:28 PM
Slugger Slugger is offline
SageTVaholic
 
Join Date: Mar 2007
Location: Kingston, ON
Posts: 4,008
EP, can I ask what you're up to? I'm sort of starting the design work for SJQv4 and one of the items at the top of the list is to bring a good old fashioned crontab to SageTV, which would allow you to schedule SageTV specific tasks to run on a regular schedule, with a few additions (such as conditional execution of the scheduled tasks based on the state of the server, etc.). My idea has become rather large and extravagant, so not sure if it will actually happen (as my ideas expand, my excitement level/desire to write it lowers), but if you're heading down the same road then maybe you'll save me a bunch of work.
__________________
Twitter: @ddb_db
Server: Intel i5-4570 Quad Core, 16GB RAM, 1 x 128GB OS SSD (Win7 Pro x64 SP1), 1 x 2TB media drive
Capture: 2 x Colossus
STB Controller: 1 x USB-UIRT
Software:Java 1.7.0_71; SageTV 7.1.9
Clients: 1 x HD300, 2 x HD200, 1 x SageClient, 1 x PlaceShifter
Plugins: Too many to list now...
Reply With Quote
  #11  
Old 08-11-2010, 04:42 PM
PLUCKYHD PLUCKYHD is offline
SageTVaholic
 
Join Date: Dec 2007
Posts: 6,257
Quote:
Originally Posted by evilpenguin View Post
Please do post an example, i'm a little lost on how to get started.
I would also offer up to do the "java" for you if you don't want to read up.I can easily make you a standard plugin with the code you need.

cheers,

pluckyhd
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problems creating an stvi to modify DynMenu (default) wado1971 SageTV Studio 2 02-21-2009 04:23 PM
Creating STVi imports Opus4 SageTV Studio 2 01-24-2008 01:14 PM
Creating Simple STVi Slugger SageTV Studio 3 04-08-2007 06:59 PM
creating STVi matrix35 SageTV Studio 6 02-25-2007 06:48 PM
Nightly shutdown for power saving simonen Hardware Support 15 11-04-2006 04:38 AM


All times are GMT -6. The time now is 02:29 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2023, vBulletin Solutions Inc.
Copyright 2003-2005 SageTV, LLC. All rights reserved.