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 01-17-2010, 08:34 AM
tmiranda's Avatar
tmiranda tmiranda is offline
SageTVaholic
 
Join Date: Jul 2005
Location: Central Florida, USA
Posts: 5,851
Impossible "If"

Stumped again. I've got code in a UI Widget chain that looks like this:

Code:
DebugLog("1")
   If IsFilePath(str)
   > true
      DebugLog("2")
         Display Picture
      DebugLog("3")
         Display Text
   > else
      DebugLog("4")
         Display Something Else
When I look in the logfile I see the "1", but never the "2", "3" or "4". No errors in the log either. How can this happen? I've stared at the code for 2 days....

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
  #2  
Old 01-17-2010, 11:35 AM
MeInMaui's Avatar
MeInMaui MeInMaui is offline
SageTVaholic
 
Join Date: Feb 2005
Location: Maui. HI
Posts: 4,203
Have you evaluated IsFilePath(str) separately to make sure it is giving you what you expect? If it is somehow giving you a null value that could screw things up. I often add a temporary UI chain ending with a text widget to test a call to make sure the output is what I expect.

Aloha,
Mike
__________________
"Everything doesn't exist. I'm thirsty." ...later... "No, it's real!!! I'm full."
- Nikolaus (4yrs old)
Reply With Quote
  #3  
Old 01-17-2010, 11:46 AM
PLUCKYHD PLUCKYHD is offline
SageTVaholic
 
Join Date: Dec 2007
Posts: 6,257
Yeah it has to be returning something other than true or false.


If you might have a null sometimes and that is okay with you, you could change the false to else, but if it is not returning a boolean than you will always get te else result
Reply With Quote
  #4  
Old 01-17-2010, 11:58 AM
GKusnick's Avatar
GKusnick GKusnick is offline
SageTVaholic
 
Join Date: Dec 2005
Posts: 5,083
A null result should be caught be the else branch. The only way neither branch would execute is if the If expression throws an exception that aborts the whole chain.

I strongly recommend doing your Studio development with the console window enabled so you can see exceptions as they happen instead of having to search through logs later. Enable the console window in the registry as follows:

Code:
[HKEY_LOCAL_MACHINE\SOFTWARE\Frey Technologies\Common]
"consolewin"=dword:00000001
Also make sure you have error reporting turned on in Studio (Tools > Notify On Errors).
Attached Files
File Type: zip Consolewin.zip (326 Bytes, 191 views)
__________________
-- Greg
Reply With Quote
  #5  
Old 01-17-2010, 12:58 PM
razrsharpe razrsharpe is offline
Sage Icon
 
Join Date: Sep 2008
Location: Boston, MA
Posts: 2,111
Just yesterday i was having a problem with IsFilePath. It was always returning false (even for paths that exist). I ending up writing my own method. Here is the method that i am using:

Code:
    public static boolean IsFilePath(String path){
        File fp = new File(path);
        return fp.exists();
    }
__________________
Server 2003 r2 32bit, SageTV9 (finally!)
2x Dual HDHR (OTA), 1x HD-PVR (Comcast), 1x HDHR-3CC via SageDCT (Comcast)
2x HD300, 1x SageClient (Win10 Test/Development)
Check out TVExplorer
Reply With Quote
  #6  
Old 01-17-2010, 01:17 PM
GKusnick's Avatar
GKusnick GKusnick is offline
SageTVaholic
 
Join Date: Dec 2005
Posts: 5,083
Quote:
Originally Posted by razrsharpe View Post
I ending up writing my own method.
But note that your method does not distinguish between files and directories, which the Sage API method does. Maybe you meant to use IsDirectoryPath() instead? In any case, it seems confusing to name your method the same as the Sage one, even though it does something different.
__________________
-- Greg
Reply With Quote
  #7  
Old 01-17-2010, 01:58 PM
razrsharpe razrsharpe is offline
Sage Icon
 
Join Date: Sep 2008
Location: Boston, MA
Posts: 2,111
Quote:
Originally Posted by GKusnick View Post
But note that your method does not distinguish between files and directories, which the Sage API method does. Maybe you meant to use IsDirectoryPath() instead? In any case, it seems confusing to name your method the same as the Sage one, even though it does something different.
mmm... didnt realize that my method didn't distinguish between directories... i guess i should fix that... thanks. I named it IsFilePath because i thought i was testing for a file path (not both files and directories).

I meant to use IsFilePath() and it wasn't working for me for some reason. I passed it a valid path (to an existing file) and it was always returning false for me... I am sure I am doing something wrong I just couldn't figure it out. time to go digging i suppose...
__________________
Server 2003 r2 32bit, SageTV9 (finally!)
2x Dual HDHR (OTA), 1x HD-PVR (Comcast), 1x HDHR-3CC via SageDCT (Comcast)
2x HD300, 1x SageClient (Win10 Test/Development)
Check out TVExplorer
Reply With Quote
  #8  
Old 01-17-2010, 02:02 PM
PLUCKYHD PLUCKYHD is offline
SageTVaholic
 
Join Date: Dec 2007
Posts: 6,257
Quote:
Originally Posted by razrsharpe View Post
mmm... didnt realize that my method didn't distinguish between directories... i guess i should fix that... thanks. I named it IsFilePath because i thought i was testing for a file path (not both files and directories).

I meant to use IsFilePath() and it wasn't working for me for some reason. I passed it a valid path (to an existing file) and it was always returning false for me... I am sure I am doing something wrong I just couldn't figure it out. time to go digging i suppose...
Yeah I call .isFile() or IsDirectory() depending on what I am looking for.
Reply With Quote
  #9  
Old 01-17-2010, 02:23 PM
Fuzzy's Avatar
Fuzzy Fuzzy is offline
SageTVaholic
 
Join Date: Sep 2005
Location: Jurupa Valley, CA
Posts: 9,957
It definitely sounds like there may be a problem in the IsFilePath(str) API code. As mentioned, it really should ALWAYS result in either a true or a false. I mean, no matter WHAT you pass to it, it should check if it exists and is a file. If neither is true, it should return a false. I can't see how it should EVER fire an exception. Any error accessing the given path should be caught and return a false.

I wonder if the 'str' you are passing it a null? maybe then it's failing out.
__________________
Buy Fuzzy a beer! (Fuzzy likes beer)

unRAID Server: i7-6700, 32GB RAM, Dual 128GB SSD cache and 13TB pool, with SageTVv9, openDCT, Logitech Media Server and Plex Media Server each in Dockers.
Sources: HRHR Prime with Charter CableCard. HDHR-US for OTA.
Primary Client: HD-300 through XBoxOne in Living Room, Samsung HLT-6189S
Other Clients: Mi Box in Master Bedroom, HD-200 in kids room
Reply With Quote
  #10  
Old 01-17-2010, 02:32 PM
tmiranda's Avatar
tmiranda tmiranda is offline
SageTVaholic
 
Join Date: Jul 2005
Location: Central Florida, USA
Posts: 5,851
Thanks all. I replaced "If IsFilePath()" with "If true" and the same thing happens. Nothing is printed from either of the two branches (true, else). My system is possessed. Could the xml somehow be corrupted?

Thanks Greg for the console window trick, I did not know about that and it is very useful.
__________________

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
  #11  
Old 01-17-2010, 02:54 PM
PLUCKYHD PLUCKYHD is offline
SageTVaholic
 
Join Date: Dec 2007
Posts: 6,257
Quote:
Originally Posted by tmiranda View Post
Thanks all. I replaced "If IsFilePath()" with "If true" and the same thing happens. Nothing is printed from either of the two branches (true, else). My system is possessed. Could the xml somehow be corrupted?

Thanks Greg for the console window trick, I did not know about that and it is very useful.
Can we see a screenshot of the studio code that helps sometimes

Also download babgvant registry settings it will let you enable the debug console and adjust java settings without having to work in the properties file
Reply With Quote
  #12  
Old 01-17-2010, 03:09 PM
tmiranda's Avatar
tmiranda tmiranda is offline
SageTVaholic
 
Join Date: Jul 2005
Location: Central Florida, USA
Posts: 5,851
Screenshot attached. I put a "false" branch to cover all of my bases and I replaced DebugLog with THROWANERROR to see if the code ever gets executed. It doesn't - no errors are thrown. I see the DebugLog message just before the If and then nothing at all. The code just seem to skip all of the branches.
__________________

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
  #13  
Old 01-17-2010, 03:10 PM
tmiranda's Avatar
tmiranda tmiranda is offline
SageTVaholic
 
Join Date: Jul 2005
Location: Central Florida, USA
Posts: 5,851
Here is the screenshot.....
Attached Images
File Type: jpg studio.jpg (107.0 KB, 169 views)
__________________

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
  #14  
Old 01-17-2010, 04:10 PM
GKusnick's Avatar
GKusnick GKusnick is offline
SageTVaholic
 
Join Date: Dec 2005
Posts: 5,083
Quote:
Originally Posted by Fuzzy View Post
It definitely sounds like there may be a problem in the IsFilePath(str) API code. As mentioned, it really should ALWAYS result in either a true or a false. I mean, no matter WHAT you pass to it, it should check if it exists and is a file. If neither is true, it should return a false. I can't see how it should EVER fire an exception. Any error accessing the given path should be caught and return a false.
I disagree. If you pass in null instead of a valid string, you should expect a NullPointerException. If a file system error occurs such that the method can't tell whether the file exists or not, then neither true nor false would be a correct result, and it should throw an exception.
__________________
-- Greg
Reply With Quote
  #15  
Old 01-17-2010, 05:07 PM
razrsharpe razrsharpe is offline
Sage Icon
 
Join Date: Sep 2008
Location: Boston, MA
Posts: 2,111
what is THROWANERROR? if you are calling a custom method that you wrote you need to use the full method name (ie PackageName_ClassName_MethodName)? The debug log should be throughing a bunch of exceptions though if cant find THROWANERROR.

Don't forget Greg's other trick to Notify on Errors (Tools -> Notify on Errors). That will also help you catch lots of user error (unitialized variables, Untitled code, syntax errors, etc).

I find reading the console window to be hard sometimes (not big enough, cant make it wider, etc). So what i do is open sagetvclient_0.txt (the client log, same thing as the console window) in Notepadd++. Notepad++ will tell me if the file has changed and reload it. It's very handy.
__________________
Server 2003 r2 32bit, SageTV9 (finally!)
2x Dual HDHR (OTA), 1x HD-PVR (Comcast), 1x HDHR-3CC via SageDCT (Comcast)
2x HD300, 1x SageClient (Win10 Test/Development)
Check out TVExplorer
Reply With Quote
  #16  
Old 01-17-2010, 05:18 PM
GKusnick's Avatar
GKusnick GKusnick is offline
SageTVaholic
 
Join Date: Dec 2005
Posts: 5,083
Quote:
Originally Posted by razrsharpe View Post
I find reading the console window to be hard sometimes (not big enough, cant make it wider, etc).
Actually you can resize the console window (or any command prompt), change fonts and colors, and so forth by right-clicking the title bar and choosing Properties. I like to set the buffer height to 1000 for scrolling back through exception chains. When done, choose "Modify shortcut" to make the changes permanent.
__________________
-- Greg
Reply With Quote
  #17  
Old 01-17-2010, 05:22 PM
razrsharpe razrsharpe is offline
Sage Icon
 
Join Date: Sep 2008
Location: Boston, MA
Posts: 2,111
Quote:
Originally Posted by GKusnick View Post
Actually you can resize the console window (or any command prompt), change fonts and colors, and so forth by right-clicking the title bar and choosing Properties. I like to set the buffer height to 1000 for scrolling back through exception chains. When done, choose "Modify shortcut" to make the changes permanent.
well ill be damned thanks for the tip that's awesome
__________________
Server 2003 r2 32bit, SageTV9 (finally!)
2x Dual HDHR (OTA), 1x HD-PVR (Comcast), 1x HDHR-3CC via SageDCT (Comcast)
2x HD300, 1x SageClient (Win10 Test/Development)
Check out TVExplorer
Reply With Quote
  #18  
Old 01-17-2010, 06:20 PM
tmiranda's Avatar
tmiranda tmiranda is offline
SageTVaholic
 
Join Date: Jul 2005
Location: Central Florida, USA
Posts: 5,851
Quote:
Originally Posted by razrsharpe View Post
what is THROWANERROR? if you are calling a custom method that you wrote you need to use the full method name (ie PackageName_ClassName_MethodName)? The debug log should be throughing a bunch of exceptions though if cant find THROWANERROR.

Don't forget Greg's other trick to Notify on Errors (Tools -> Notify on Errors). That will also help you catch lots of user error (unitialized variables, Untitled code, syntax errors, etc).

I find reading the console window to be hard sometimes (not big enough, cant make it wider, etc). So what i do is open sagetvclient_0.txt (the client log, same thing as the console window) in Notepadd++. Notepad++ will tell me if the file has changed and reload it. It's very handy.
THROWANERROR is junk that I put in there to cause an error on purpose. The problem is that the error never occurs. No matter what conditional I put in the "If" NONE of the branches (true, false, else) are ever called. (Hence the title of the thread.)

Notify on error is on. No errors in the logfile. Nothing. No matter what I put in the true, false, else branches the code is not executed.

I tried putting gibberish in the branch to see if an error pops up, and it does. (So if I change ">true" to ">kjshdfkjhg" I get an error.) I also tried changing the conditional to gibberish "If ldkslkfdgkljdf" and that causes an error as expected. So it seems the conditional is being evaluated but it never matches true, false, or else. How can that be?

Greg - Cool trick on resizing the console window.
razr - Notepad++ sounds good too!
__________________

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
  #19  
Old 01-17-2010, 06:53 PM
GKusnick's Avatar
GKusnick GKusnick is offline
SageTVaholic
 
Join Date: Dec 2005
Posts: 5,083
Are you sure the If itself is being reached? It looks like there's another If above it, just off screen. Have you instrumented that one to see which of its branches is being taken?

The rules for Ifs in blue UI code are a bit unintuitive. The entire tree, included all branches, gets evaluated at menu load time to instantiate the UI components. There are then additional passes for layout and rendering, during which only active branches get evaluated. So you'll sometimes see debug output triggering at unexpected times that might lead you to think a branch is active when it really isn't.

You might also experiment with Studio's breakpoint and trace features. I don't use them much myself, but in a pinch they can help shed light on what's really going on.
__________________
-- Greg
Reply With Quote
  #20  
Old 01-17-2010, 07:35 PM
tmiranda's Avatar
tmiranda tmiranda is offline
SageTVaholic
 
Join Date: Jul 2005
Location: Central Florida, USA
Posts: 5,851
Greg,

I'm sure (as I can be) that it is being reached because I can see the output from the DebugLog() statement (see below) just before the If in the logfile.

Code:
DebugLog("PFFD:: 4.2 BannerImage = " + BannerImage)
I've tried using Studio's breakpoint, trace and step features but never had much luck using them.

I'm really stuck at the moment. I am updating my "Phoenix Fanart for Default" STV to use the new Genre methods in the latest phoenix API. I though maybe the new phoenix jar file was causing problems so I went back to the previous version and that made no difference at all.

Time to clear the mind with a beer and some football.

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
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
"Not Manual Recording" filtering doesn't work in SageTV's "Upcoming Movies" menu vince100 SageTV Customizations 3 11-23-2009 03:56 PM
"Sort By Title" most shows end up under "T" as in "The" grauchy SageMC Custom Interface 1 09-25-2009 06:44 AM
"Set defaults" for Series forgets "Keep"/"Auto-delete" setting maxpower SageMC Custom Interface 9 05-14-2008 09:44 PM
Stutter/Jitter using A180/Vbox and OTA? Check signal "Strength" not "quality" svemuri Hardware Support 0 12-13-2005 10:51 AM
Installing/Uninstalling "Got All Media" caused Sage to report "No capture device" VorpalBlade Hardware Support 3 10-15-2005 01:30 AM


All times are GMT -6. The time now is 12:58 PM.


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