os.gentenv function is not working on windows
#1
hello

Have a little problem with this code ....
Code:
# Check if the user allready accepted the EULA

       if (os_linux):
           eula_path = os.getenv("HOME") + '/EULA_blue-pill-accepted'
           eula = os.path.exists(eula_path)
           print 'eula was accepted for linux'

       if (os_windows):
           eula_path = str(os.getenv("USERPROFILE")) + '\\EULA_blue-pill-accepted'
           print eula_path
           eula = os.path.exists(eula_path)
           print 'eula was accepted for windows'

Under linux it is working
Under windows the functions should return the path to the user
but allways returns 'NONE'

Where is the point I miss ?

Regards
Hans
Reply
#2
Check to see that you have an environment variable "USERPROFILE" ?
The normal XBMC log IS NOT a debug log, to enable debug logging you must toggle it on under XBMC Settings - System or in advancedsettings.xml. Use XBMC Debug Log Addon to retrieve it.
Reply
#3
CrashX Wrote:Check to see that you have an environment variable "USERPROFILE" ?

If I do in a commandshell SET the variable USERPROFILE is listet, therefore the
command should return the path to the home directory of the user.

I did insert the print statement to see the value.

It allways returns NONE

regards
hans
Reply
#4
Confirmed, this only happens in XBMC. Please file a report on Trac if you must... but I'm curious why you care about messing with the user's environment instead of staying inside of the XBMC file structure?

Unless you're doing something I'm not seeing, you should be checking special://userdata/script_data (or plugin_data).

PS - the 'HOME' variable is also legal in Windows, well... XP at least, so you can maybe drop the different OS functions.
Always read the XBMC online-manual, FAQ and search and search the forum before posting.
For troubleshooting and bug reporting please read how to submit a proper bug report.

If you're interested in writing addons for xbmc, read docs and how-to for plugins and scripts ||| http://code.google.com/p/xbmc-addons/
Reply
#5
hi,
I have a alternative solution for windows, not very good. but is work

Code:
import os

file_txt = os.path.join( os.getcwd(), "userprofile.txt" )

command = 'echo %userprofile%>"'+ file_txt + '"'

os.system( command )

if os.path.exsist( file_txt ):
    print str( file( file_txt ).read() ).strip( "\n" )
else:
    print "unknown"
frost
For my bad English, sorry. I am French Canadian.
Admin @ Passion-XBMC.org
Reply
#6
FrostBox Wrote:hi,
I have a alternative solution for windows, not very good. but is work

Code:
import os

file_txt = os.path.join( os.getcwd(), "userprofile.txt" )

command = 'echo %userprofile%>"'+ file_txt + '"'

os.system( command )

if os.path.exsist( file_txt ):
    print str( file( file_txt ).read() ).strip( "\n" )
else:
    print "unknown"
frost

Merci beaucoup mon vieux ;-=)

Je l'essaier demain soir ....

PS : Escuse my poor french and english ;-) LOL
Jean
Reply
#7
rwparris2 Wrote:PS - the 'HOME' variable is also legal in Windows, well... XP at least, so you can maybe drop the different OS functions.

Not true on XP Pro SP3 - Just checked on a fresh install and there is HOMEDRIVE and HOMEPATH but HOME is not valid.
Reply
#8
Zeron Wrote:Not true on XP Pro SP3 - Just checked on a fresh install and there is HOMEDRIVE and HOMEPATH but HOME is not valid.
Yeah that's what I tested as well. It works IN python; windows itself doesn't know what HOME means but python understands.
Always read the XBMC online-manual, FAQ and search and search the forum before posting.
For troubleshooting and bug reporting please read how to submit a proper bug report.

If you're interested in writing addons for xbmc, read docs and how-to for plugins and scripts ||| http://code.google.com/p/xbmc-addons/
Reply
#9
OK I created a ticket inside trac

[XBMC] #7044: os.getenv not working as expected with python / win32


If I know the function is not working with windows I place the file inside the script-directory.

Regards
Hans
Reply

Logout Mark Read Team Forum Stats Members Help
os.gentenv function is not working on windows0