Your 1st Add-On: Hello World!

  Thread Rating:
  • 5 Vote(s) - 4.2 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
Karnagious Offline
Posting Freak
Posts: 1,070
Joined: Nov 2012
Reputation: 48
Post: #31
XBMC Stubs allows auto-completion and documentation lookup in some IDEs. I think there is a walk-through about how to set it up in PyCharm.

https://github.com/romanvm/xbmcstubs
find quote
pieman Offline
Junior Member
Posts: 43
Joined: Jan 2014
Reputation: 0
Location: Cyprus
Post: #32
(2014-12-20 14:26)LandRover Wrote:  [quote pieman]
Thanks for adding the ATV2 path details and obviously they will be different for different set ups. Hopefully users can locate their xbmc.log and modify the tail command accordingly.

The modules that are prefixed with xbmc like xbmcgui and xbmc itself are not available in standalone Python.They will only run via XBMC. It maybe that the techies have worked out how to use them in an IDE but I certainly haven't found a way. It would be nice to use the IDE's we are familiar with but unless someone advises otherwise it is not possible. Even if you added the modules to Python I don't think they would work as they were developed to work within XBMC.

I'll just have to get used to using the logs, as a beginner I find the IDE easier to find Python formatting issues Sad . Hopefully I figure it out as obviously everyone else has managed to do. Smile

Time to keep moving forward.
[/quote]

Once you get used to using tail it is not really that much different to a regular IDE.

(2014-12-20 14:28)Karnagious Wrote:  XBMC Stubs allows auto-completion and documentation lookup in some IDEs. I think there is a walk-through about how to set it up in PyCharm.

https://github.com/romanvm/xbmcstubs

Looks like this is what we have been looking for LandRover. Thanks again Karnagious.

Easy Home Automation to Control your RF device within Kodi XBMC
Want to watch TV everywhere you go? Pop by the Want To Watch TV site.
[Image: Easy_Home_Automation.PNG]
(This post was last modified: 2014-12-20 14:36 by pieman.)
find quote
pieman Offline
Junior Member
Posts: 43
Joined: Jan 2014
Reputation: 0
Location: Cyprus
Post: #33
Not sure what I have done with the format of quotes in my last few posts but hopefully readers can make some sense of it.

xbmcstubs and PyXBMCt were written by the same person so he (?) obviously knows the ropes when it comes to Python and XBMC.

Easy Home Automation to Control your RF device within Kodi XBMC
Want to watch TV everywhere you go? Pop by the Want To Watch TV site.
[Image: Easy_Home_Automation.PNG]
(This post was last modified: 2014-12-20 14:47 by pieman.)
find quote
TerrorKeed Offline
Senior Member
Posts: 186
Joined: Jan 2013
Reputation: 0
Location: Lancashire, UK
Post: #34
Yeah, ROMAN_V_M is a beast Smile

Yeah, Me, Myself, and I, The Three Musketeers
[Image: TerrorKeed.gif]
find quote
Roman_V_M Online
Team-Kodi Member
Posts: 1,141
Joined: Jun 2011
Reputation: 56
Location: Kyiv, Ukraine
Post: #35
(2014-12-20 14:40)pieman Wrote:  Not sure what I have done with the format of quotes in my last few posts but hopefully readers can make some sense of it.

xbmcstubs and PyXBMCt were written by the same person so he (?) obviously knows the ropes when it comes to Python and XBMC.

To be honest, I've forked xbmcstubs from another Github repo that got stale some time ago and try to keep it up to date with XBMC/Kodi Python development. And xbmcstubs just help you write code in your favorite IDE, it doesn't let you actually run the code.
As for IDE, I prefer PyCharm Community Edition. There I have created a virtual environment with xmbcstubs and some other popular XBMC Python modules, which helps me with my amateur (I'm not an IT guy actually Smile) experiments.

Raspberry PI 2 + LibreELEC 8 (Kodi 17)
Samsung Galaxy Tab A 10.1 + Kodi 17 for Android
find quote
pieman Offline
Junior Member
Posts: 43
Joined: Jan 2014
Reputation: 0
Location: Cyprus
Post: #36
(2014-12-20 20:39)Roman_V_M Wrote:  
(2014-12-20 14:40)pieman Wrote:  Not sure what I have done with the format of quotes in my last few posts but hopefully readers can make some sense of it.

xbmcstubs and PyXBMCt were written by the same person so he (?) obviously knows the ropes when it comes to Python and XBMC.

To be honest, I've forked xbmcstubs from another Github repo that got stale some time ago and try to keep it up to date with XBMC/Kodi Python development. And xbmcstubs just help you write code in your favorite IDE, it doesn't let you actually run the code.
As for IDE, I prefer PyCharm Community Edition. There I have created a virtual environment with xmbcstubs and some other popular XBMC Python modules, which helps me with my amateur (I'm not an IT guy actually Smile) experiments.
Just downloading PyCharm Community Edition now. So xbmcstubs will not allow us to run the xbmc code in a regular IDE? I think you are saying the virtual environment of PyCharm will allow us to run the code though. Thanks for the mod to the format of the PyXBMCt demo zip file and the dependencies are now met in Gotham.

Easy Home Automation to Control your RF device within Kodi XBMC
Want to watch TV everywhere you go? Pop by the Want To Watch TV site.
[Image: Easy_Home_Automation.PNG]
find quote
nickr Offline
Team-Kodi Member
Posts: 18,692
Joined: May 2009
Reputation: 387
Location: Christchurch NZ
Post: #37
No. PyCharm will not allow you to run xbmc code in a gui/ide.

If I have helped you or increased your knowledge, click the 'thank user' button to give thanks :) (People with less than 20 posts won't see the "Thank you" button.)
find quote
pieman Offline
Junior Member
Posts: 43
Joined: Jan 2014
Reputation: 0
Location: Cyprus
Post: #38
(2014-12-20 21:16)nickr Wrote:  No. PyCharm will not allow you to run xbmc code in a gui/ide.

So we need to stick with 'tail' then, right?

Easy Home Automation to Control your RF device within Kodi XBMC
Want to watch TV everywhere you go? Pop by the Want To Watch TV site.
[Image: Easy_Home_Automation.PNG]
find quote
nickr Offline
Team-Kodi Member
Posts: 18,692
Joined: May 2009
Reputation: 387
Location: Christchurch NZ
Post: #39
If you want a log of the code running, yes.

If I have helped you or increased your knowledge, click the 'thank user' button to give thanks :) (People with less than 20 posts won't see the "Thank you" button.)
find quote
pieman Offline
Junior Member
Posts: 43
Joined: Jan 2014
Reputation: 0
Location: Cyprus
Smile  RE: Your First Add-On: Hello World!
Post: #40
(2014-12-20 21:19)nickr Wrote:  If you want a log of the code running, yes.

Specifically I want the log of the code NOT running i.e. all my bugs Smile
I don't like the word log in this context as it suggests a passed record of events whereas tail gives a live view of the code in operation.

Easy Home Automation to Control your RF device within Kodi XBMC
Want to watch TV everywhere you go? Pop by the Want To Watch TV site.
[Image: Easy_Home_Automation.PNG]
find quote
nickr Offline
Team-Kodi Member
Posts: 18,692
Joined: May 2009
Reputation: 387
Location: Christchurch NZ
Post: #41
(2014-12-20 21:24)pieman Wrote:  
(2014-12-20 21:19)nickr Wrote:  If you want a log of the code running, yes.

Specifically I want the log of the code NOT running i.e. all my bugs Smile
I don't like the word log in this context as it suggests a passed record of events whereas tail gives a live view of the code in operation.
Not sure what your point is.

If I have helped you or increased your knowledge, click the 'thank user' button to give thanks :) (People with less than 20 posts won't see the "Thank you" button.)
find quote
LandRover Offline
Junior Member
Posts: 10
Joined: Dec 2014
Reputation: 0
Location: Canada
Post: #42
(2014-12-20 21:27)nickr Wrote:  
(2014-12-20 21:24)pieman Wrote:  
(2014-12-20 21:19)nickr Wrote:  If you want a log of the code running, yes.

Specifically I want the log of the code NOT running i.e. all my bugs Smile
I don't like the word log in this context as it suggests a passed record of events whereas tail gives a live view of the code in operation.
Not sure what your point is.

I think that what pieman and I are looking for a is process or tool (or explanation) of how to review Python syntax errors, EOL errors, indent errors, parsing errors etc. before we attempt to run the code through Kodi/XMBC. How does a developer try to correct these errors for XMBC specific scripts given we can't seem to do this in IDE?

Pieman sorry if I got that wrong.

_______________________
XBMC Coding Novice Learner
(This post was last modified: 2014-12-20 22:49 by LandRover.)
find quote
pieman Offline
Junior Member
Posts: 43
Joined: Jan 2014
Reputation: 0
Location: Cyprus
Post: #43
(2014-12-20 22:48)LandRover Wrote:  
(2014-12-20 21:27)nickr Wrote:  
(2014-12-20 21:24)pieman Wrote:  Specifically I want the log of the code NOT running i.e. all my bugs Smile
I don't like the word log in this context as it suggests a passed record of events whereas tail gives a live view of the code in operation.
Not sure what your point is.

I think that what pieman and I are looking for a is process or tool (or explanation) of how to review Python syntax errors, EOL errors, indent errors, parsing errors etc. before we attempt to run the code through Kodi/XMBC. How does a developer try to correct these errors for XMBC specific scripts given we can't seem to do this in IDE?

Pieman sorry if I got that wrong.

You are spot on but I am happy that tail gives me a pretty good idea of where my code is at fault.

Easy Home Automation to Control your RF device within Kodi XBMC
Want to watch TV everywhere you go? Pop by the Want To Watch TV site.
[Image: Easy_Home_Automation.PNG]
find quote
nickr Offline
Team-Kodi Member
Posts: 18,692
Joined: May 2009
Reputation: 387
Location: Christchurch NZ
Post: #44
A good python ide or even an editor like notepad++ will show syntax etc errors and may also do auto-completion. It won't show logic/algorithm errors.

If I have helped you or increased your knowledge, click the 'thank user' button to give thanks :) (People with less than 20 posts won't see the "Thank you" button.)
find quote
Roman_V_M Online
Team-Kodi Member
Posts: 1,141
Joined: Jun 2011
Reputation: 56
Location: Kyiv, Ukraine
Post: #45
(2014-12-20 22:48)LandRover Wrote:  I think that what pieman and I are looking for a is process or tool (or explanation) of how to review Python syntax errors, EOL errors, indent errors, parsing errors etc. before we attempt to run the code through Kodi/XMBC. How does a developer try to correct these errors for XMBC specific scripts given we can't seem to do this in IDE?

Pieman sorry if I got that wrong.

Yes, debugging addons using Kodi logs is difficult. I remember seeing in Wiki an article about remote debugging XBMC scripts in Eclipse + PyDev. I don't use Eclipse so I haven't read the article.

However, a good IDE can help you avoid many obvious errors. E.g. PyCharm have quite advanced code inspection that can pinpoint potential problems in your code.
Also best practices of programming recommend you to divide your code into structural parts and to separate presentation logic from business-logic. In terms of Kodi addons business logic is responsible for requesting data from web-servers, processing those data, etc. And business logic should (I'd say must) be put into separate modules that don't use Kodi-specific calls (if possible). This way your business logic can be wrapped in unit tests or other testing code and tested separately, outside Kodi. This way, the only thing that needs to be tested inside Kodi is presentation logic (e.g. presenting your music collection with art, descriptions etc.), and this greatly reduces debugging/testing efforts.
To put it simple: if parts of your addon can work outside Kodi, put them in separate modules and test/debug the usual way using IDE and Python for your OS.

Raspberry PI 2 + LibreELEC 8 (Kodi 17)
Samsung Galaxy Tab A 10.1 + Kodi 17 for Android
find quote
Post Reply