v28 broke my scripts

25 views
Skip to first unread message

Rinaldo Merlo

unread,
Feb 8, 2018, 7:02:02 PM2/8/18
to stb-tester
Hi,

Since upgrading to v28, most of my scripts started failing with an error like this:

Saved screenshot to 'screenshot.png'.
Traceback (most recent call last):
  File "/usr/lib/stbt/_stbt/stbt_run.py", line 118, in sane_unicode_and_exception_handling
    yield
  File "/usr/lib/stbt/stbt-run", line 53, in main
    test_function.call()
  File "/usr/lib/stbt/_stbt/stbt_run.py", line 99, in fn
    execfile(filename, test_globals)
  File "/home/rmerlo/STBT/SCRIPTS/PH7YTPLAY_YouTube_Initiate_Playback.py", line 20, in <module>
    raise Exception("Error: You forgot to specify the shelf number")


It's at the point in each script where I import a config module/file for the rack/shelf/STB under test, like so:

try:
   s = sys.argv[1]
   exec('from %s import *'%s)
except: 
    raise Exception("Error: You forgot to specify the shelf number")

I was able to resolve it by changing that section in all the scripts to a simpler:

shelffile = sys.argv[1]
exec('from %s import *' %shelffile)

although I suspect the fix was not the actual rewrite of the code but maybe the removal of some invalid unicode character(s) that I can't see. 

I thought you'd want to know anyway, but do you have any idea why it broke? Is it my fault? As far as I can see, that bit of my scripts is nothing to do with the stb-tester api's, and is just generic python.

FYI, the shelf modules that I import are just a bunch of python variable declarations specific to the rack/shelf/STB under test. 

David Röthlisberger

unread,
Feb 9, 2018, 7:02:39 AM2/9/18
to Rinaldo Merlo, stb-tester
On Fri, 9 Feb 2018, at 12:02 AM, Rinaldo Merlo wrote:
try:
   s = sys.argv[1]
   exec('from %s import *'%s)
except: 
    raise Exception("Error: You forgot to specify the shelf number")

My guess is that you forgot to specify a command-line argument so sys.argv[1] raised KeyError. But since you are catching any exception, you didn't see the KeyError.

Conclusion: The different behaviour is because you invoked "stbt run" differently. Nothing to do with the stb-tester version, nor with the change to your python script.


Kind regards,

David Röthlisberger
Stb-tester.com Ltd.

--
Stb-tester.com Ltd is a company registered in England and Wales.
Registered number: 08800454. Registered office: 33b Aliwal Road,
Battersea, London, SW11 1RB.


Reply all
Reply to author
Forward
0 new messages