The branch, frodo has been updated
       via  900fc3093ce9cfc8768ece632a2d20c1d372ccaa (commit)
      from  a7b321407f95204e50231ead7442c252a494d815 (commit)

- Log -----------------------------------------------------------------
http://xbmc.git.sourceforge.net/git/gitweb.cgi?p=xbmc/scripts;a=commit;h=900fc3093ce9cfc8768ece632a2d20c1d372ccaa

commit 900fc3093ce9cfc8768ece632a2d20c1d372ccaa
Author: Martijn Kaijser <[email protected]>
Date:   Thu Jan 9 08:11:58 2014 +0100

    [script.speedfaninfo] 0.5.5

diff --git a/script.speedfaninfo/CHANGELOG.txt 
b/script.speedfaninfo/CHANGELOG.txt
index dd8c740..3bad952 100644
--- a/script.speedfaninfo/CHANGELOG.txt
+++ b/script.speedfaninfo/CHANGELOG.txt
@@ -1,5 +1,12 @@
+v.0.5.5
+- added ability to monitor multiple logs
+- script now sets focus on window so you can scroll through it without mouse 
control
+- added additional metadata to addon
+- updated module import to follow best practice
+- cleaned up code and moved some stuff into external modules
+
 v 0.5.4
-- changed display logic so percents will show even in the number of percent 
entries doesn't match number of speed entries
+- changed display logic so percents will show even if the number of percent 
entries doesn't match number of speed entries
 - added Galician language files
 - changed over to Frodo .po language files
 - added check to threading loop for XBMC quitting
diff --git a/script.speedfaninfo/README.txt b/script.speedfaninfo/README.txt
index 04f5af1..157351d 100644
--- a/script.speedfaninfo/README.txt
+++ b/script.speedfaninfo/README.txt
@@ -1,44 +1,5 @@
-ABOUT
 This XBMC plugin parses and displays information from the SpeedFan log. While 
this plugin works on any platform, SpeedFan only works on Windows, so it is 
optimally built for people using XBMC on Windows.
 
-GETTING SPEEDFAN
-SpeedFan is available at: <http://www.almico.com/speedfan.php>
+For more information and usage directions, please see:
 
-COMPATIBILITY
-This plugin has been tested with SpeedFan 4.44. It should work with any 
version of SpeedFan that outputs the log file in the same format as 4.44. It 
has been tested on XBMC Eden (11.0) betas 2 and 3 on Windows and Macintosh. It 
has not been tested on Dharma (10.1) and likely will not work on Dharma.
-
-SPECIAL LOG CONFIGURATION CONSIDERATIONS
-This readme is not meant to be a tutorial on how to setup SpeedFan or enable 
logging.  The SpeedFan web site is available to help you with that.  To get 
SpeedFanInfo to properly parse the log file, you do need to label the various 
SpeedFan items in a specific way.
-
-SpeedFanInfo knows about four kinds of log items: temperatures, fan speeds, 
voltages, and fan speed percentages.
-
-Temperatures
-This is the first tab in the SpeedFan configuration window (labeled 
Temperatures).  Any item you are logging needs it's label to end with .temp 
(not case sensitive) for SpeedFanInfo to parse it.  (i.e. CPU.temp)
-
-Fan Speeds
-This is the second tab in the SpeedFan configuration window (labeled Fans).  
Any item you are logging needs it's label to end with .speed (not case 
sensitive) for SpeedFanInfo to parse it.  (i.e. CPU Fan.speed)
-
-Voltages
-This is the third tab in the SpeedFan configuration window (labeled Voltages). 
 Any item you are logging needs it's label to end with .voltage (not case 
sensitive) for SpeedFanInfo to parse it.  (i.e. +12V.voltage)
-
-Fan Speed Percentages
-This is the fourth tab in the SpeedFan configuration window (labeled Speeds).  
Any item you are logging needs it's label to end with .percent (not case 
sensitive) for SpeedFanInfo to parse it.  (i.e. CPU Fan.percent)  A special 
note about fan speed percentages.  They will only show on the SpeedFanInfo 
screen if you are logging the same number of fan speeds as you are fan 
percentages.  SpeedFan logs these in a predictable order, so as long as you 
don't log four of your five fan speeds and then a different four of your five 
fan speed percentages, you should be fine.
-
-SETUP
-After you install this plugin, go to the plugin settings.  There are four 
options to set.
-
-SpeedFan Log Folder
-The folder in which the SpeedFan log file resides.  Be default SpeedFan stores 
this file in C:\Program Files\SpeedFan\
-
-Log Temperature Scale
-This should be set to match the temperature scale to which you have SpeedFan 
set.  This setting just tells the plugin what to put after the integer value 
for the temperature.  This plugin will not convert from Celcius to Farenheit 
(or vice versa).
-
-Window Update Interval (in seconds)
-The number of seconds between updates to the screen.  Please note that 
SpeedFan will sometimes get it's logging a little out of sync, so sometimes the 
fan speed and fan speed percentages don't actually match.  This only happens 
when your fan speeds are fluctuating pretty rapidly, so if you wait through a 
couple of screen refreshes, the numbers usually start matching again.
-
-Enable Verbose Logging
-This drops a metric crapload of stuff into the XBMC log file.  It's really 
only useful for debugging, so I wouldn't enable it unless you're asked to do so 
by the developer to assist with troubleshooting.
-
-GETTING HELP
-Please see the thread in the XBMC forums for assistance.
-<http://forum.xbmc.org/showthread.php?p=1014479>
\ No newline at end of file
+<http://wiki.xbmc.org/index.php?title=Add-on:SpeedFan_Information_Display>
\ No newline at end of file
diff --git a/script.speedfaninfo/addon.xml b/script.speedfaninfo/addon.xml
index d37fa92..efb3c52 100644
--- a/script.speedfaninfo/addon.xml
+++ b/script.speedfaninfo/addon.xml
@@ -1,7 +1,8 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<addon id="script.speedfaninfo" name="SpeedFan Information Display" 
version="0.5.4" provider-name="pkscuot">
+<addon id="script.speedfaninfo" name="SpeedFan Information Display" 
version="0.5.5" provider-name="pkscuot">
        <requires>
                <import addon="xbmc.python" version="2.1.0"/>
+               <import addon="xbmc.addon" version="12.0.0"/>
        </requires>
        <extension point="xbmc.python.script" library="default.py">
                <provides>executable</provides>
@@ -10,7 +11,10 @@
                
<website>http://wiki.xbmc.org/index.php?title=Add-on:SpeedFan_Information_Display</website>
                <forum>http://forum.xbmc.org/showthread.php?p=1014479</forum>
                <source>https://github.com/pkscout/script.speedfaninfo</source>
-               <email>kyle dot johnson at alumni dot duke dot edu</email>
+               <license>GNU GENERAL PUBLIC LICENSE. Version 2, June 
1991</license>
+               <email>[email protected]</email>
+               <disclaimer></disclaimer>
+               <language></language>
                <summary lang="be">Display information from your SpeedFan 
log.</summary>
                <summary lang="da">Vis oplysninger fra din 
SpeedFan-log.</summary>
                <summary lang="de">Zeige Informationen aus deinem SpeedFan 
Log.</summary>
diff --git a/script.speedfaninfo/default.py b/script.speedfaninfo/default.py
index b6a7b4e..132e68b 100755
--- a/script.speedfaninfo/default.py
+++ b/script.speedfaninfo/default.py
@@ -1,20 +1,17 @@
 import os, sys, time, datetime
-import xbmcaddon, xbmc, xbmcgui
+import xbmcaddon, xbmc, xbmcgui, xbmcvfs
 from threading import Thread
-#this is a wrapper for the xbmc.log that adds logic for verbose or standard 
logging
-import xlogger
+from resources.common.xlogger import Logger
+from resources.common.fix_utf8 import smartUTF8
 
 ### get addon info and set globals
 __addon__        = xbmcaddon.Addon()
-__addonid__      = __addon__.getAddonInfo('id')
-__addonname__    = __addon__.getAddonInfo('name')
-__author__       = __addon__.getAddonInfo('author')
-__version__      = __addon__.getAddonInfo('version')
-__addonpath__    = __addon__.getAddonInfo('path')
-__addondir__     = xbmc.translatePath( __addon__.getAddonInfo('profile') )
-__addonicon__    = xbmc.translatePath('%s/icon.png' % __addonpath__ 
).decode("utf-8")
-__icon__         = __addon__.getAddonInfo('icon')
-__localize__     = __addon__.getLocalizedString
+__addonname__    = __addon__.getAddonInfo('id')
+__addonversion__ = __addon__.getAddonInfo('version')
+__addonpath__    = __addon__.getAddonInfo('path').decode('utf-8')
+__addonicon__    = xbmc.translatePath('%s/icon.png' % __addonpath__ )
+__language__     = __addon__.getLocalizedString
+
 
 #global used to tell the worker thread the status of the window
 __windowopen__   = True
@@ -24,107 +21,208 @@ ACTION_PREVIOUS_MENU = 10
 ACTION_BACK = 92
 
 #create a global logger object and set the preamble
-lw = xlogger.inst
-lw.setPreamble ('[speedfaninfo]')
+lw = Logger( '[speedfaninfo]' )
+
+
+def updateWindow( name, w ):
+    #this is the worker thread that updates the window information every w 
seconds
+    #this strange looping exists because I didn't want to sleep the thread for 
very long
+    #as time.sleep() keeps user input from being acted upon
+    delay = __addon__.getSetting( 'update_delay' )
+    while __windowopen__ and (not xbmc.abortRequested):
+        #start counting up to the delay set in the preference and sleep for 
one second
+        for i in range( int( delay ) ):
+            #as long as the window is open, keep sleeping
+            if __windowopen__:
+                time.sleep(1)
+            #otherwise drop out of the loop so we can exit the thread
+            else:
+               break
+        #as long as the window is open grab new data and refresh the window
+        if __windowopen__:
+            lw.log( 'window is still open, updating the window with new 
data',xbmc.LOGDEBUG );
+            w._populate_from_all_logs()
+
 
-#this is the class for creating and populating the window 
-class SpeedFanInfoWindow(xbmcgui.WindowXMLDialog): 
+class Main( xbmcgui.WindowXMLDialog ): 
     
-    def __init__(self, *args, **kwargs):
-        # and define it as self
-        lw.log('running __init__ from SpeedFanInfoWindow class', xbmc.LOGDEBUG)
+    def __init__( self, *args, **kwargs ): pass
+
         
-    def onInit(self):
-        #tell the object to go read the log file, parse it, and put it into 
listitems for the XML
-        lw.log('running inInit from SpeedFanInfoWindow class', xbmc.LOGDEBUG)
-        self.populateFromLog()
+    def onInit( self ):
+        self._get_settings()
+        self._populate_from_all_logs()
+
 
-    def onAction(self, action):
+    def onAction( self, action ):
         #captures user input and acts as needed
-        lw.log('running onAction from SpeedFanInfoWindow class', xbmc.LOGDEBUG)
-        if(action == ACTION_PREVIOUS_MENU or action == ACTION_BACK):
+        lw.log( 'running onAction from SpeedFanInfoWindow class', 
xbmc.LOGDEBUG )
+        if action == ACTION_PREVIOUS_MENU or action == ACTION_BACK:
             #if the user hits back or exit, close the window
-            lw.log('user initiated previous menu or back', xbmc.LOGDEBUG)
+            lw.log( 'user initiated previous menu or back', xbmc.LOGDEBUG )
             global __windowopen__
             #set this to false so the worker thread knows the window is being 
closed
             __windowopen__ = False
-            lw.log('set windowopen to false', xbmc.LOGDEBUG)
+            lw.log( 'set windowopen to false', xbmc.LOGDEBUG )
             #tell the window to close
-            lw.log('tell the window to close', xbmc.LOGDEBUG)
+            lw.log( 'tell the window to close', xbmc.LOGDEBUG )
             self.close()
-            
-    def populateFromLog(self):        
+
+
+    def _get_log_files( self ):
+        #SpeedFan rolls the log every day, so we have to look for the log file 
based on the date
+        log_file_date = 
datetime.date(2011,1,29).today().isoformat().replace('-','')
+        log_files = []
+        for info_set in self.LOGINFO:
+            if info_set['use_log'] == 'true':
+                log_file = os.path.join( info_set['loc'], 'SFLog' + 
log_file_date + '.csv' )
+                log_files.append( (info_set['title'], log_file) )
+        return log_files
+
+
+    def _get_settings( self ):
+        self.LISTCONTROL = self.getControl( 120 )
+        self.SHOWCOMPACT = __addon__.getSetting('show_compact')
+        self.LOGINFO = []        
+        for i in range( 3 ):
+            log_info = {}
+            if i == 0:
+                log_num = ''
+                log_info['use_log'] = 'true'
+            else:
+                log_num = str( i + 1 )
+                log_info['use_log'] = __addon__.getSetting( 'use_log' + 
log_num )
+            log_info['loc'] = __addon__.getSetting( 'log_location' + log_num )
+            log_info['title'] = __addon__.getSetting( 'log_title' + log_num )
+            self.LOGINFO.append( log_info )
+
+
+    def _parse_log( self ):
+        #parse the log for information, see readme for how to setup SpeedFan 
output so that the script
+        lw.log( 'started parsing log',xbmc.LOGDEBUG );
+        if __addon__.getSetting( 'temp_scale' ) == 'Celcius':
+            temp_scale = 'C'
+        else:
+            temp_scale = 'F'
+        lw.log( 'read the log file',xbmc.LOGDEBUG )
+        first, last = self._read_log_file()
+        temps = []
+        speeds = []
+        voltages = []
+        percents = []
+        if first == '' or last == '':
+            return temps, speeds, voltages, percents
+        #pair up the heading with the value
+        lw.log( 'pair up the heading with the value',xbmc.LOGDEBUG );
+        for s_item, s_value in map( None, first.split( '\t' ), last.split( 
'\t' ) ):
+            item_type = s_item.split( '.' )[-1].rstrip().lower()
+            item_text = os.path.splitext( s_item )[0].rstrip()
+            #round the number, drop the decimal and then covert to a string
+            #skip the rounding for the voltage reading
+            if item_type == 'voltage':
+                s_value = s_value.rstrip()
+            else:
+                try:
+                    s_value = str( int( round( float( s_value.rstrip() ) ) ) )
+                except ValueError:
+                    s_value = str( int( round( float( 
s_value.rstrip().replace(',', '.') ) ) ) )
+            if item_type == "temp":
+                lw.log( 'put the information in the temperature 
array',xbmc.LOGDEBUG )
+                temps.append( [item_text + ':', s_value + temp_scale] )
+            elif item_type == "speed":
+                lw.log( 'put the information in the speed array',xbmc.LOGDEBUG 
)
+                speeds.append( [item_text + ':', s_value + 'rpm'] )
+            elif item_type == "voltage":
+                lw.log( 'put the information in the voltage 
array',xbmc.LOGDEBUG )
+                voltages.append( [item_text + ':', s_value + 'v'] )
+            elif item_type == "percent":
+                lw.log( 'put the information in the percent 
array',xbmc.LOGDEBUG );
+                percents.append( [item_text, s_value + '%'] )
+        lw.log( temps, speeds, voltages, percents, xbmc.LOGDEBUG )
+        lw.log( 'ended parsing log, displaying results', xbmc.LOGDEBUG )
+        return temps, speeds, voltages, percents
+
+
+    def _populate_from_all_logs( self ):
+        lw.log( 'reset the window to prep it for data', xbmc.LOGDEBUG )
+        self.LISTCONTROL.reset()
+        displayed_log = False
+        for title, logfile in self._get_log_files():
+            self.LOGFILE = logfile
+            if title:
+                item = xbmcgui.ListItem( label=title )
+                item.setProperty( 'istitle','true' )
+                self.LISTCONTROL.addItem( item )
+            if xbmcvfs.exists( logfile ):
+                displayed_log = True
+                self._populate_from_log()
+        if displayed_log:
+            self.setFocus( self.LISTCONTROL )
+        else:
+            command = 'XBMC.Notification(%s, %s, %s, %s)' % 
(smartUTF8(__language__(30103)), smartUTF8(__language__(30104)), 6000, 
smartUTF8(__addonicon__))
+            xbmc.executebuiltin( command )
+
+                     
+    def _populate_from_log( self ):        
         #get all this stuff into list info items for the window
-        lw.log('attempting to add info of ' +  
xbmcgui.Window(xbmcgui.getCurrentWindowId()).getProperty("panel.compact") , 
xbmc.LOGDEBUG)
-        lw.log('running populateFromLog from SpeedFanInfoWindow class', 
xbmc.LOGDEBUG)
-        #create new log parser and logger obejects
-        lw.log('create new LogParser object', xbmc.LOGDEBUG)
-        lp = LogParser()
-        #get the information from the SpeedFan Log
-        lw.log('ask the LogParser to get temps, speeds, voltages, and 
percents', xbmc.LOGDEBUG)
-        temps, speeds, voltages, percents = lp.parseLog()
-        lw.log('starting to convert output for window', xbmc.LOGDEBUG)
+        temps, speeds, voltages, percents = self._parse_log()
+        lw.log( 'starting to convert output for window', xbmc.LOGDEBUG )
         #add a fancy degree symbol to the temperatures
-        lw.log('add fancy degree symbol to temperatures', xbmc.LOGDEBUG)
         for i in range(len(temps)):
               temps[i][1] = temps[i][1][:-1] + u'\N{DEGREE SIGN}' + 
temps[i][1][-1:]
-      #now parse all the data and get it into ListIems for display on the page
-        lw.log('reset the window to prep it for data', xbmc.LOGDEBUG)
-        self.getControl(120).reset()
+        #now parse all the data and get it into ListIems for display on the 
page
         #this allows for a line space *after* the first one so the page looks 
pretty
         firstline_shown = False
-        #put in all the temperature information
-        lw.log('put in all the temperature information', xbmc.LOGDEBUG)
-        if(len(temps) > 0):
-            self.populateList(__localize__(30100), temps, firstline_shown)
+        lw.log( 'put in all the temperature information', xbmc.LOGDEBUG )
+        if temps:
+            self._populate_list( __language__(30100), temps, firstline_shown )
             firstline_shown = True
-        #put in all the speed information (including percentage)
-        lw.log('put in all the speed information (including percentages)', 
xbmc.LOGDEBUG)
-        if(len(speeds) > 0):
-            lw.log('adding the percentages to the end of the speeds', 
xbmc.LOGDEBUG)
+        lw.log( 'put in all the speed information (including percentages)', 
xbmc.LOGDEBUG )
+        if speeds:
+            lw.log( 'adding the percentages to the end of the speeds', 
xbmc.LOGDEBUG )
             en_speeds = []
-            for i in range(len(speeds)):
+            for i in range( len( speeds ) ):
                 #if there is a matching percentage, add it to the end of the 
speed
                 percent_match = False
                 percent_value = ''
-                for j in range(len(percents)):
+                for j in range( len( percents ) ):
                     if (speeds[i][0][:-1] == percents[j][0]):
-                        lw.log('matched speed ' + speeds[i][0][:-1] + ' with 
percent ' + percents[j][0], xbmc.LOGDEBUG)
+                        lw.log( 'matched speed ' + speeds[i][0][:-1] + ' with 
percent ' + percents[j][0], xbmc.LOGDEBUG )
                         percent_match = True
                         percent_value = percents[j][1]
                 if percent_match:
-                    en_speeds.append((speeds[i][0], speeds [i][1] + ' (' + 
percent_value + ')'))
+                    en_speeds.append( (speeds[i][0], speeds [i][1] + ' (' + 
percent_value + ')') )
                 else:
-                    en_speeds.append((speeds[i][0], speeds [i][1]))
-            self.populateList(__localize__(30101), en_speeds, firstline_shown)
+                    en_speeds.append( (speeds[i][0], speeds [i][1]) )
+            self._populate_list( __language__(30101), en_speeds, 
firstline_shown )
             firstline_shown = True
-        #put in all the voltage information
-        lw.log('put in all the voltage information', xbmc.LOGDEBUG)
-        if(len(voltages) > 0):
-            self.populateList(__localize__(30102), voltages, firstline_shown)
-        #log that we're done and ready to show the page
-        lw.log('completed putting information into lists, displaying window', 
xbmc.LOGDEBUG)
+        lw.log( 'put in all the voltage information', xbmc.LOGDEBUG )
+        if voltages:
+            self._populate_list( __language__(30102), voltages, 
firstline_shown )
+        #add empty line at end in case there's another log file
+        item = xbmcgui.ListItem()
+        self.LISTCONTROL.addItem( item ) #this adds an empty line
+        lw.log( 'completed putting information into lists, displaying window', 
xbmc.LOGDEBUG )
+
             
-    def populateList(self, title, things, titlespace):
+    def _populate_list( self, title, things, titlespace ):
         #this takes an arbitrating list of readings and gets them into the 
ListItems
-        lw.log('running populateList from SpeedFanInfoWindow class', 
xbmc.LOGDEBUG)        
-        #create the list item for the title of the section
-        lw.log('create the list item for the title of the section', 
xbmc.LOGDEBUG)        
-        if(titlespace):
+        lw.log( 'create the list item for the title of the section', 
xbmc.LOGDEBUG )        
+        if titlespace:
             item = xbmcgui.ListItem()
-            self.getControl(120).addItem(item) #this adds an empty line
-        item = xbmcgui.ListItem(label=title)
-        item.setProperty('istitle','true')
-        self.getControl(120).addItem(item)
-        #now add all the data (we want two columns inf full mode and one 
column for compact)
-        if (__addon__.getSetting('show_compact') == "true"):
-            lw.log('add all the data to the one column format', xbmc.LOGDEBUG)
+            self.LISTCONTROL.addItem( item ) #this adds an empty line
+        item = xbmcgui.ListItem( label=title )
+        item.setProperty( 'istitle','true' )
+        self.LISTCONTROL.addItem( item )
+        #now add all the data (we want two columns in full mode and one column 
for compact)
+        if self.SHOWCOMPACT == "true":
+            lw.log( 'add all the data to the one column format', xbmc.LOGDEBUG 
)
             for onething in things:
-                    item = xbmcgui.ListItem(label=onething[0],label2='')
-                    item.setProperty('value',onething[1])
-                    self.getControl(120).addItem(item)
+                    item = xbmcgui.ListItem( label=onething[0],label2='' )
+                    item.setProperty( 'value',onething[1] )
+                    self.LISTCONTROL.addItem( item )
         else:
-            lw.log('add all the data to the two column format', xbmc.LOGDEBUG) 
       
+            lw.log( 'add all the data to the two column format', xbmc.LOGDEBUG 
)        
             nextside = 'left'
             for  onething in things:
                 if(nextside == 'left'):
@@ -132,61 +230,44 @@ class SpeedFanInfoWindow(xbmcgui.WindowXMLDialog):
                     left_value = onething[1]
                     nextside = 'right'
                 else:
-                    item = 
xbmcgui.ListItem(label=left_label,label2=onething[0])
-                    item.setProperty('value',left_value)
-                    item.setProperty('value2',onething[1])
+                    item = xbmcgui.ListItem( 
label=left_label,label2=onething[0] )
+                    item.setProperty( 'value',left_value )
+                    item.setProperty( 'value2',onething[1] )
                     nextside = 'left'
-                    self.getControl(120).addItem(item)
+                    self.LISTCONTROL.addItem( item )
             if(nextside == 'right'):
-                item = xbmcgui.ListItem(label=left_label,label2='')
-                item.setProperty('value',left_value)
-                self.getControl(120).addItem(item)
+                item = xbmcgui.ListItem( label=left_label,label2='' )
+                item.setProperty( 'value',left_value )
+                self.LISTCONTROL.addItem( item )
 
-class LogParser():
-    def __init__(self):
-        lw.log('running __init__ from LogParser class', xbmc.LOGDEBUG)        
-        # and define it as self
 
-    def readLogFile(self):
+    def _read_log_file( self ):
         #try and open the log file
-        lw.log('running readLogFile from LogParser class', xbmc.LOGDEBUG)      
  
-        #SpeedFan rolls the log every day, so we have to look for the log file 
based on the date
-        #SpeedFan also does numerics if it has to roll the log during the day
-        #but in my testing it only uses the numeric log for a couple of 
minutes and then goes
-        #back to the main dated log, so I only read the main log file for a 
given date
-        log_file_date = 
datetime.date(2011,1,29).today().isoformat().replace('-','')
-        log_file_raw = __addon__.getSetting('log_location') + 'SFLog' + 
log_file_date
-        log_file = log_file_raw + '.csv'
-        lw.log('trying to open logfile ' + log_file, xbmc.LOGDEBUG)
+        lw.log( 'trying to open logfile ' + self.LOGFILE, xbmc.LOGDEBUG )
         try:
-            f = open(log_file, 'rb')
-        except IOError:
-            lw.log('no log file found', xbmc.LOGERROR)
-            if(__addon__.getSetting('log_location') == ''):
-                xbmc.executebuiltin('XBMC.Notification("Log File Error", "No 
log file location defined.", 6000, '+ __addonicon__ +')')
-            else:
-                xbmc.executebuiltin('XBMC.Notification("Log File Error", "No 
log file in defined location.", 6000, ' + __addonicon__ + ')')            
-            return
-        lw.log('opened logfile ' + log_file, xbmc.LOGDEBUG)
+            f = open(self.LOGFILE, 'rb')
+        except e:
+            lw.log( 'unexpected error when reading log file', xbmc.LOGERROR )
+            lw.log( e, xbmc.LOGERROR )
+            return ('', '')
+        lw.log( 'opened logfile ' + self.LOGFILE, xbmc.LOGDEBUG )
         #get the first and last line of the log file
         #the first line has the header information, and the last line has the 
last log entry
-        #Speedfan updates the log every three seconds, so I didn't want to 
read the whole log
-        #file in just to get the last line
-        first = next(f).decode()
+        first = next( f ).decode()
         read_size = 1024
         offset = read_size
-        f.seek(0, 2)
+        f.seek( 0, 2 )
         file_size = f.tell()
         while 1:
             if file_size < offset:
                 offset = file_size
-            f.seek(-1*offset, 2)
-            read_str = f.read(offset)
+            f.seek( -1*offset, 2 )
+            read_str = f.read( offset )
             # Remove newline at the end
             if read_str[offset - 1] == '\n':
                 read_str = read_str[0:-1]
             lines = read_str.split('\n')
-            if len(lines) > 1:  # Got a line
+            if len( lines ) > 1:  # Got a line
                 last = lines[len(lines) - 1]
                 break
             if offset == file_size:   # Reached the beginning
@@ -194,113 +275,35 @@ class LogParser():
                 break
             offset += read_size
         f.close()
-        #some additional information for advanced logging
         lw.log('first line: ' + first, xbmc.LOGDEBUG)
         lw.log('last line: ' + last, xbmc.LOGDEBUG)
         return first, last
 
-    def parseLog(self):
-        #parse the log for information, see readme for how to setup SpeedFan 
output so that the script
-        lw.log('running parseLog from LogParser class', xbmc.LOGDEBUG)        
-        #can parse out the useful information
-        lw.log('started parsing log',xbmc.LOGDEBUG);
-        if(__addon__.getSetting('temp_scale') == 'Celcius'):
-            temp_scale = 'C'
-        else:
-            temp_scale = 'F'
-        #read the log file
-        lw.log('read the log file',xbmc.LOGDEBUG);
-        first, last = self.readLogFile()
-        #pair up the heading with the value
-        lw.log('pair up the heading with the value',xbmc.LOGDEBUG);
-        temps = []
-        speeds = []
-        voltages = []
-        percents = []
-        for s_item, s_value in map(None, first.split('\t'), last.split('\t')):
-            item_type = s_item.split('.')[-1].rstrip().lower()
-            item_text = os.path.splitext(s_item)[0].rstrip()
-            #round the number, drop the decimal and then covert to a string
-            #skip the rounding for the voltage reading
-            if(item_type == 'voltage'):
-                s_value = s_value.rstrip()
-            else:
-                try:
-                    s_value = str(int(round(float(s_value.rstrip()))))
-                except ValueError:
-                    s_value = 
str(int(round(float(s_value.rstrip().replace(',', '.')))))
-            if(item_type == "temp"):
-                #put this info in the temperature array
-                lw.log('put the information in the temperature 
array',xbmc.LOGDEBUG);
-                temps.append([item_text + ':', s_value + temp_scale])
-            elif(item_type == "speed"):
-                #put this info in the speed array
-                lw.log('put the information in the speed array',xbmc.LOGDEBUG);
-                speeds.append([item_text + ':', s_value + 'rpm'])
-            elif(item_type == "voltage"):
-                #put this info in the voltage array
-                lw.log('put the information in the voltage 
array',xbmc.LOGDEBUG);
-                voltages.append([item_text + ':', s_value + 'v'])
-            elif(item_type == "percent"):
-                #put this info to the percent array
-                lw.log('put the information in the percent 
array',xbmc.LOGDEBUG);
-                percents.append([item_text, s_value + '%'])
-        #log some additional data if advanced logging is one
-        lw.log(temps, speeds, voltages, percents, xbmc.LOGDEBUG)
-        #log that we're done parsing the file
-        lw.log('ended parsing log, displaying results', xbmc.LOGDEBUG)
-        return temps, speeds, voltages, percents
-                
-def updateWindow(name, w):
-    #this is the worker thread that updates the window information every w 
seconds
-    #this strange looping exists because I didn't want to sleep the thread for 
very long
-    #as time.sleep() keeps user input from being acted upon
-    lw.log('running the worker thread from inside the def',xbmc.LOGDEBUG);
-    while __windowopen__ and (not xbmc.abortRequested):
-        #start counting up to the delay set in the preference and sleep for 
one second
-        lw.log('start counting the delay set in the preference',xbmc.LOGDEBUG);
-        for i in range(int(__addon__.getSetting('update_delay'))):
-            #as long as the window is open, keep sleeping
-            if __windowopen__:
-                lw.log('window is still open, sleep 1 second',xbmc.LOGDEBUG);
-                time.sleep(1)
-            #otherwise drop out of the loop so we can exit the thread
-            else:
-               break
-        #as long as the window is open grab new data and refresh the window
-        if __windowopen__:
-            lw.log('window is still open, updating the window with new 
data',xbmc.LOGDEBUG);
-            w.populateFromLog()
 
 #run the script
-if ( xbmcgui.Window(10000).getProperty("speedfan.running") == "true" ):
-    lw.log('script already running, aborting subsequent run attempts', 
xbmc.LOGNOTICE)
-else:
-    xbmcgui.Window(10000).setProperty( "speedfan.running",  "true" )
-    lw.log('starting script', xbmc.LOGNOTICE)
-    lw.log('attempting to create main script object', xbmc.LOGDEBUG)
-    if (__addon__.getSetting('show_compact') == "true"):
-        transparency_image = "speedfan-panel-compact-" + 
str(int(round(float(__addon__.getSetting('transparency'))))) + ".png"
-        xbmcgui.Window(10000).setProperty("speedfan.panel.compact",  
transparency_image)
-        #create a new object to get all the work done
-        w = SpeedFanInfoWindow("speedfaninfo-compact.xml", __addonpath__, 
"Default")
+if ( __name__ == "__main__" ):
+    lw.log('script version %s started' % __addonversion__)
+    xbmcgui.Window( 10000 ).setProperty( "speedfan.running",  "false" )
+    if xbmcgui.Window( 10000).getProperty( "speedfan.running" ) == "true":
+        lw.log( 'script already running, aborting subsequent run attempts', 
xbmc.LOGDEBUG )
     else:
-        #create a new object to get all the work done
-        w = SpeedFanInfoWindow("speedfaninfo-main.xml", __addonpath__, 
"Default")
-    lw.log('main script object created', 'attempting to create worker thread', 
xbmc.LOGDEBUG)
-    #create and start a separate thread for the looping process that updates 
the window
-    t1 = Thread(target=updateWindow,args=("thread 1",w))
-    t1.setDaemon(True)
-    lw.log('worker thread created', 'attempting to start worker thread', 
xbmc.LOGDEBUG)
-    t1.start()
-    lw.log('worker thread started', 'request window open via doModal', 
xbmc.LOGDEBUG)
-    #create and open the window
-    w.doModal()
-    #just some cleanup
-    lw.log('attempting to delete main object', 'attempting to delete worker 
thread', xbmc.LOGDEBUG)
-    del t1
-    del w
-    lw.log('main object deleted', 'worker thread deleted', xbmc.LOGDEBUG)
-    lw.log('exiting script', xbmc.LOGNOTICE)
-    del lw
-    xbmcgui.Window(10000).setProperty( "speedfan.running",  "false" )
\ No newline at end of file
+        xbmcgui.Window( 10000 ).setProperty( "speedfan.running",  "true" )
+        if (__addon__.getSetting('show_compact') == "true"):
+            transparency_image = "speedfan-panel-compact-" + 
str(int(round(float(__addon__.getSetting('transparency'))))) + ".png"
+            xbmcgui.Window( 10000 ).setProperty( "speedfan.panel.compact",  
transparency_image )
+            #create a new object to get all the work done
+            w = Main( "speedfaninfo-compact.xml", __addonpath__ )
+        else:
+            #create a new object to get all the work done
+            w = Main( "speedfaninfo-main.xml", __addonpath__ )
+        #create and start a separate thread for the looping process that 
updates the window
+        t1 = Thread( target=updateWindow,args=("thread 1", w) )
+        t1.setDaemon( True )
+        t1.start()
+        #create and open the window
+        w.doModal()
+        #just some cleanup
+        del t1
+        del w
+        xbmcgui.Window(10000).setProperty( "speedfan.running",  "false" )
+lw.log('script stopped')
diff --git a/script.speedfaninfo/resources/language/English/strings.po 
b/script.speedfaninfo/resources/language/English/strings.po
index de56560..25fe374 100644
--- a/script.speedfaninfo/resources/language/English/strings.po
+++ b/script.speedfaninfo/resources/language/English/strings.po
@@ -17,7 +17,7 @@ msgstr ""
 "Plural-Forms: nplurals=2; plural=(n != 1);\n"
 
 msgctxt "#30000"
-msgid "SpeedFan Log Folder"
+msgid "General"
 msgstr ""
 
 msgctxt "#30001"
@@ -40,6 +40,34 @@ msgctxt "#30005"
 msgid "    Background Transparency"
 msgstr ""
 
+msgctxt "#30006"
+msgid "Log File Location"
+msgstr ""
+
+msgctxt "#30010"
+msgid " Additional Logs"
+msgstr ""
+
+msgctxt "#30011"
+msgid "Primary Log File Title"
+msgstr ""
+
+msgctxt "#30012"
+msgid "Use Log File 2"
+msgstr ""
+
+msgctxt "#30013"
+msgid "Use Log File 3"
+msgstr ""
+
+msgctxt "#30020"
+msgid "    Log File Title"
+msgstr ""
+
+msgctxt "#30021"
+msgid "    Log File Location"
+msgstr ""
+
 #empty strings from id 30006 to 30099
 
 msgctxt "#30100"
@@ -53,3 +81,11 @@ msgstr ""
 msgctxt "#30102"
 msgid "Voltage Information"
 msgstr ""
+
+msgctxt "#30103"
+msgid "Log File Error"
+msgstr ""
+
+msgctxt "#30104"
+msgid "No log file found."
+msgstr ""
diff --git a/script.speedfaninfo/resources/settings.xml 
b/script.speedfaninfo/resources/settings.xml
index 565da60..d83db84 100644
--- a/script.speedfaninfo/resources/settings.xml
+++ b/script.speedfaninfo/resources/settings.xml
@@ -1,8 +1,19 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <settings>
-    <setting id="show_compact" type="bool" label="30004" default="false" />
-    <setting id="transparency" type="slider" label="30005" default="70" 
range="10,10,100" visible="eq(-1,true)" enable="eq(-1,true)" option="int" />
-    <setting id="log_location" type="folder" label="30000" default="" />
-    <setting id="temp_scale" type="labelenum" label="30002" 
values="Celcius|Farenheit" default="0" />
-    <setting id="update_delay" type ="labelenum" label="30003" 
values="10|20|30|40|50|60|90|120|180|240" default="30" />
+    <category label="30000">
+        <setting id="log_location" type="folder" label="30006" default="" />
+        <setting id="show_compact" type="bool" label="30004" default="false" />
+        <setting id="transparency" type="slider" label="30005" default="70" 
range="10,10,100" visible="eq(-1,true)" enable="eq(-1,true)" option="int" />
+        <setting id="temp_scale" type="labelenum" label="30002" 
values="Celcius|Farenheit" default="0" />
+        <setting id="update_delay" type ="labelenum" label="30003" 
values="10|20|30|40|50|60|90|120|180|240" default="30" />
+    </category>
+    <category label=30010>
+        <setting id="log_title" type="text" label="30011" default="" />
+        <setting id="use_log2" type="bool" label="30012" default="false" />
+        <setting id="log_title2" type="text" label="30020" 
enable="eq(-1,true)" default="" />
+        <setting id="log_location2" type="folder" enable="eq(-2,true)" 
label="30021" default="" />
+        <setting id="use_log3" type="bool" label="30013" default="false" />
+        <setting id="log_title3" type="text" enable="eq(-1,true)" 
label="30020" default="" />
+        <setting id="log_location3" type="folder" enable="eq(-2,true)" 
label="30021" default="" />
+    </category>
 </settings>

-----------------------------------------------------------------------

Summary of changes:
 script.speedfaninfo/CHANGELOG.txt                  |    9 +-
 script.speedfaninfo/README.txt                     |   43 +--
 script.speedfaninfo/addon.xml                      |    8 +-
 script.speedfaninfo/default.py                     |  443 ++++++++++----------
 .../resources/__init__.py                          |    0
 .../resources/common}/__init__.py                  |    0
 script.speedfaninfo/resources/common/fileops.py    |   81 ++++
 .../resources/common}/fix_utf8.py                  |    2 +
 .../resources/common/ordereddict.py                |    5 +-
 script.speedfaninfo/resources/common/transforms.py |   18 +
 .../{ => resources/common}/xlogger.py              |   33 +--
 .../resources/language/Danish/strings.po           |   53 ---
 .../resources/language/English/strings.po          |   38 ++-
 .../resources/language/Galician/strings.po         |   53 ---
 .../resources/language/German/strings.po           |   53 ---
 .../resources/language/Greek/strings.po            |   53 ---
 .../resources/language/Hungarian/strings.po        |   53 ---
 .../resources/language/Italian/strings.po          |   53 ---
 .../resources/language/Polish/strings.po           |   53 ---
 .../language/Portuguese (Brazil)/strings.po        |   53 ---
 .../resources/language/Portuguese/strings.po       |   53 ---
 .../resources/language/Slovak/strings.po           |   53 ---
 .../resources/language/Spanish/strings.po          |   53 ---
 .../resources/language/Swedish/strings.po          |   53 ---
 script.speedfaninfo/resources/settings.xml         |   21 +-
 25 files changed, 402 insertions(+), 935 deletions(-)
 copy {script.ace.extrapack => script.speedfaninfo}/resources/__init__.py (100%)
 copy {script.ace.extrapack/resources => 
script.speedfaninfo/resources/common}/__init__.py (100%)
 create mode 100644 script.speedfaninfo/resources/common/fileops.py
 copy {script.artistslideshow/resources/fix_utf8 => 
script.speedfaninfo/resources/common}/fix_utf8.py (97%)
 copy script.keymap/collections_backport.py => 
script.speedfaninfo/resources/common/ordereddict.py (97%)
 create mode 100644 script.speedfaninfo/resources/common/transforms.py
 rename script.speedfaninfo/{ => resources/common}/xlogger.py (58%)
 delete mode 100644 script.speedfaninfo/resources/language/Danish/strings.po
 delete mode 100644 script.speedfaninfo/resources/language/Galician/strings.po
 delete mode 100644 script.speedfaninfo/resources/language/German/strings.po
 delete mode 100644 script.speedfaninfo/resources/language/Greek/strings.po
 delete mode 100644 script.speedfaninfo/resources/language/Hungarian/strings.po
 delete mode 100644 script.speedfaninfo/resources/language/Italian/strings.po
 delete mode 100644 script.speedfaninfo/resources/language/Polish/strings.po
 delete mode 100644 script.speedfaninfo/resources/language/Portuguese 
(Brazil)/strings.po
 delete mode 100644 script.speedfaninfo/resources/language/Portuguese/strings.po
 delete mode 100644 script.speedfaninfo/resources/language/Slovak/strings.po
 delete mode 100644 script.speedfaninfo/resources/language/Spanish/strings.po
 delete mode 100644 script.speedfaninfo/resources/language/Swedish/strings.po


hooks/post-receive
-- 
Scripts

------------------------------------------------------------------------------
CenturyLink Cloud: The Leader in Enterprise Cloud Services.
Learn Why More Businesses Are Choosing CenturyLink Cloud For
Critical Workloads, Development Environments & Everything In Between.
Get a Quote or Start a Free Trial Today. 
http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk
_______________________________________________
Xbmc-addons mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xbmc-addons

Reply via email to