DeprecationWarning: os.getcwd() currently lies to you

  Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
moreginger Offline
Junior Member
Posts: 38
Joined: Oct 2011
Reputation: 3
Post: #1
A bug [1] was reported against the Ted plugin for Eden, saying that it fails to run. Part of the log was provided to me:

[INDENT]15:21:17 T:5872 NOTICE: [PLUGIN] 'TED Talks: version 2.3.0b1' initialized!
15:21:18 T:5872 ERROR: C:\Program Files\XBMC\system\python\Lib\multiprocessing\process.py:25: DeprecationWarning: os.getcwd() currently lies to you so please use addon.getAddonInfo('path') to find the script's root directory and DO NOT make relative path accesses based on the results of 'os.getcwd.'
ORIGINAL_DIR = os.path.abspath(os.getcwd())
15:21:18 T:5960 DEBUG: ------ Window Init (DialogBusy.xml) ------
15:21:18 T:5872 ERROR: C:\Program Files\XBMC\system\python\Lib\tempfile.py:162: DeprecationWarning: os.getcwd() currently lies to you so please use addon.getAddonInfo('path') to find the script's root directory and DO NOT make relative path accesses based on the results of 'os.getcwd.'
dirlist.append(_os.getcwd())
15:21:19 T:4112 INFO: Loading skin file: DialogProgress.xml[/INDENT]

I'd really appreciate some help here as I am new to xbmc and also don't have access to a Windows machine.
1) Is this error actually fatal or not? It says "DeprecationWarning" but is logged as an ERROR - I thought they were fatal, but OTOH we appear to have two from a single run.
2) I don't see it on Linux (built from Eden beta 3 source). Shouldn't this DeprecationWarning log on all platforms to allow these issues to be caught during development?
3) What am I supposed to do about it? Both the lines of logging come from python libs (is xbmc fetching these from the ether on demand?) - do the libs need to be tweaked by someone?
4) Shouldn't there be a trace?

Many thanks for reading this.

[1] https://github.com/moreginger/xbmc-plugi...s/issues/5
find quote
Eldorado Offline
Fan
Posts: 524
Joined: May 2009
Reputation: 14
Post: #2
Do exactly as it says to grab the addon path

Instead of using:
Code:
os.getcwd

Use:
Code:
addon.getAddonInfo('path')

This msg displays on all platforms I've seen
find quote
giftie Offline
Skilled Python Coder
Posts: 2,364
Joined: Mar 2010
Reputation: 54
Location: Calgary, Alberta
Post: #3
Eldorado Wrote:Do exactly as it says to grab the addon path

Instead of using:
Code:
os.getcwd

Use:
Code:
addon.getAddonInfo('path')

This msg displays on all platforms I've seen

This is not happening in the addon but the Python modules that the addon is importing(multiprocessing and tempfile)

Probably need some tweaking to the warning to not be affected by the Python modules(probably should post a Ticket on Trac)


Moreginger - these are just warnings(for the time being) they should still function properly.

[Image: e4f63e45ba34fe4695b3bb08eb2499d8e4ee484e...4c076g.jpg]
For troubleshooting and bug reporting please make sure you read this first you can also use XBMC Log Uploader Script.
Cinema Experience
Cinema Experience Wiki
cdART Manager
fanart.tv


find quote
moreginger Offline
Junior Member
Posts: 38
Joined: Oct 2011
Reputation: 3
Post: #4
giftie Wrote:This is not happening in the addon but the Python modules that the addon is importing(multiprocessing and tempfile)

Probably need some tweaking to the warning to not be affected by the Python modules(probably should post a Ticket on Trac)


Moreginger - these are just warnings(for the time being) they should still function properly.
Ah thanks. So perhaps there was a further problem downstream in the log. I've requested more information.

I'll file a bug about the warning in xbmc trac.
find quote
moreginger Offline
Junior Member
Posts: 38
Joined: Oct 2011
Reputation: 3
Post: #5
moreginger Wrote:I'll file a bug about the warning in xbmc trac.
http://trac.xbmc.org/ticket/12679
find quote
spiff Offline
Retired Developer
Posts: 12,386
Joined: Nov 2003
Post: #6
LOL. we put the warning there for a reason. hint; the reason is NOT having a trac ticket opened on our ass.
find quote
Martijn Offline
Team Kodi
Posts: 11,439
Joined: Jul 2011
Reputation: 165
Location: Dawn of time
Post: #7
spiff Wrote:LOL. we put the warning there for a reason. hint; the reason is NOT having a trac ticket opened on our ass.

It now says ERROR and not WARNING so i think that's why the ticket was made (can't acces trac @work because of stupid content control)

Always read the XBMC online-manual, FAQ and search the forums before posting.
Do NOT e-mail Team-XBMC members asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting, make sure you read this first

For your mediacenter artwork go to
[Image: fanarttv.png]
find quote
moreginger Offline
Junior Member
Posts: 38
Joined: Oct 2011
Reputation: 3
Post: #8
spiff Wrote:LOL. we put the warning there for a reason. hint; the reason is NOT having a trac ticket opened on our ass.
Apologies, I opened the trac issue primarily because I don't understand how I am supposed to fix this deprecation warning in Lib/multithreading/process.py and Lib/tempfile.py.

On the trac issue you point out that the plugin needs to switch to xbmc.python 2.0 for Eden. I didn't know this, but from reading [1] I get the impression that this will simply force the deprecation error to be rigorously enforced.

Perhaps setting xbmc.python 2.0 will cause different (fixed) versions of the libraries to be used as well, but that would surprise me?

[1] http://wiki.xbmc.org/index.php?title=Eden_API_changes
find quote
spiff Offline
Retired Developer
Posts: 12,386
Joined: Nov 2003
Post: #9
if you set python 2.0, we will not override os.getcwd at all. the whole point of the warning is to inform peeps who port dharma code.
find quote
moreginger Offline
Junior Member
Posts: 38
Joined: Oct 2011
Reputation: 3
Post: #10
spiff Wrote:if you set python 2.0, we will not override os.getcwd at all. the whole point of the warning is to inform peeps who port dharma code.
From this I infer that it is currently overridden to "do the thing that you should have done in the first place"?

But from http://wiki.xbmc.org/index.php?title=Eden_API_changes
Quote:Certain deprecated functions like os.getcwd() will produce a warning in backwards-compatibility mode, whereas they will fail outright otherwise. Add-ons with this enabled will not be accepted into the Eden repo, they should instead be updated.

If this is true, then how is setting python 2.0 not going to cause the addon to fail outright when it tries to use the library modules? Well I can try it tonight I suppose Smile

Thanks for your help.
find quote
spiff Offline
Retired Developer
Posts: 12,386
Joined: Nov 2003
Post: #11
because we check if the addon imports xbmc.python at version 1.0, if it does we *override* the os.getcwd method in the python os module, with pseudo code:

print warning()
call original_os.getcwd()

this will override it globally on the interpreter level, so it applies to submodules as well.
find quote