2013-03-27, 18:05
I am trying to write a simple addon to show the contents of the log file in a textbox control on screen.
I looked into the XBMC log uploader addon to see how does it get the path and how it reads the xbmc.log file.
I managed to create the right skin but I cannot read the log file contents, I think because the file is opened by XBMC and in use all the time.
Just to check this theory I changed from xbmc.log to xbmc.old.log and the file shows OK.
The code from XBMC uploader that opens and reads the file is just:
And I use the exact same code to read the file in my addon:
How comes I get no content but the uploader addon does succeed in sending the log data?
The log file is readable, I know this because in Windows (Win7) you can open the log file while XBMC is running and you get to see all log messages, you can even refresh it after some event and you get the extra lines too.
I looked into the XBMC log uploader addon to see how does it get the path and how it reads the xbmc.log file.
I managed to create the right skin but I cannot read the log file contents, I think because the file is opened by XBMC and in use all the time.
Just to check this theory I changed from xbmc.log to xbmc.old.log and the file shows OK.
The code from XBMC uploader that opens and reads the file is just:
Code:
def upload_file(self, filepath):
url = 'http://xbmclogs.com/'
self.__log('reading log...')
file_content = open(filepath, 'r').read()
self.__log('starting upload "%s"...' % filepath)
post_dict = {'paste_data': file_content,
'api_submit': True,
'mode': 'xml'}
if filepath.endswith('.log'):
post_dict['paste_lang'] = 'xbmc'
elif filepath.endswith('.xml'):
post_dict['paste_lang'] = 'advancedsettings'
post_data = urllib.urlencode(post_dict)
req = urllib2.Request(url, post_data)
. . .
And I use the exact same code to read the file in my addon:
Code:
file_content = open(filepath, 'r').read()
How comes I get no content but the uploader addon does succeed in sending the log data?
The log file is readable, I know this because in Windows (Win7) you can open the log file while XBMC is running and you get to see all log messages, you can even refresh it after some event and you get the extra lines too.