![]() |
|
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. |
![]() |
|
Thread Tools | Search this Thread | Display Modes |
#1
|
||||
|
||||
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) |
#2
|
||||
|
||||
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. |
#3
|
||||
|
||||
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 |
#4
|
||||
|
||||
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. |
#5
|
||||
|
||||
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. |
#6
|
||||
|
||||
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 |
#7
|
||||
|
||||
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) |
#8
|
||||
|
||||
Quote:
__________________
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) |
#9
|
||||
|
||||
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; } } } Edit: The explanation of the XML config format is in the XmlConfig Javadocs included with my library.
__________________
-- Greg |
#10
|
|||
|
|||
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... |
#11
|
|||
|
|||
Quote:
cheers, pluckyhd |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|
![]() |
||||
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 |