Example #1
0
from resources.common.fileops import readFile, writeFile, deleteFile, renameFile, checkPath
from resources.common.transforms import replaceWords
if sys.version_info >= (2, 7):
    import json as _json
else:
    import simplejson as _json

p_folderpath, p_filename = os.path.split( os.path.realpath(__file__) )
lw = Logger( logfile = os.path.join( p_folderpath, 'data', 'logfile.log' ) )
JSONURL = URL( 'json', headers={'content-type':'application/json'} )

try:
    import data.settings as settings
except ImportError:
    err_str = 'no settings file found at %s' % os.path.join ( p_folderpath, 'data', 'settings.py' )
    lw.log( [err_str, 'script stopped'] )
    sys.exit( err_str )
try:
    settings.xbmcuser
    settings.xbmcpass
    settings.xbmcuri
    settings.xbmcport
    settings.video_exts
    settings.thumb_exts
    settings.thumb_end
    settings.rename_ends
    settings.protected_files
    settings.db_loc
    settings.nas_mount
    settings.smb_name
    settings.movie_dir
Example #2
0
        self.DATAROOT = os.path.join(p_folderpath, 'data')
        self.MAPPINGS = config.Get('mappings')
        lw.log([self.MAPPINGS])
        self.STRIPTEXT = config.Get('striptext')
        self.MINLINES = config.Get('minlines')

    def _create_speedfan_log(self):
        log_name = os.path.join(
            self.DATAROOT,
            'SFLog%s.csv' % datetime.datetime.now().strftime("%Y%m%d"))
        header = 'Seconds'
        data_row = '12345'
        for mapping in self.MAPPINGS:
            lw.log(['trying vcgencmd ' + mapping[1]])
            output = os.popen("/opt/vc/bin/vcgencmd %s" %
                              mapping[1]).readline().strip()
            lw.log(['got %s from vcgencmd' % output])
            num_output = replaceWords(output, self.STRIPTEXT)
            header = header + '\t' + mapping[0]
            data_row = data_row + '\t' + num_output
        file_text = header
        for x in range(0, self.MINLINES):
            file_text = file_text + '\n' + data_row
        success, loglines = writeFile(file_text, log_name, wtype='w')
        lw.log(loglines)


if (__name__ == "__main__"):
    lw.log(['script started'], 'info')
    Main()
lw.log(['script finished'], 'info')
Example #3
0
if sys.version_info < (3, 0):
    from ConfigParser import *
else:
    from configparser import *

p_folderpath, p_filename = os.path.split( os.path.realpath(__file__) )
checkPath( os.path.join( p_folderpath, 'data', 'logs', '' ) )
lw = Logger( logfile=os.path.join( p_folderpath, 'data', 'logs', 'logfile.log' ),
             logconfig='timed', numbackups=config.Get( 'logbackups' ), logdebug=str( config.Get( 'debug' ) ) )

connection_modules = {}
for module in resources.connections.__all__:
    full_plugin = 'resources.connections.' + module
    __import__( full_plugin )
    imp_plugin = sys.modules[ full_plugin ]
    lw.log( ['loaded plugin ' + module] )
    connection_modules[module] = imp_plugin
transform_modules = {}
for module in resources.transforms.__all__:
    full_plugin = 'resources.transforms.' + module
    __import__( full_plugin )
    imp_plugin = sys.modules[ full_plugin ]
    lw.log( ['loaded plugin ' + module] )
    transform_modules[module] = imp_plugin


def _deletePID():
    success, loglines = deleteFile( pidfile )
    lw.log (loglines )

pid = str(os.getpid())
Example #4
0
        except Exception, e:
            lw.log( ['unexpected error when reading log file', e], xbmc.LOGERROR )
            return ('', '')
        lw.log( ['opened logfile ' + self.LOGFILE] )
        #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
        first = self._parse_line( f, 0 )
        last = self._parse_line( f, 2 )
        f.close()
        lw.log( ['first line: ' + first, 'last line: ' + last] )
        return first, last


#run the script
if ( __name__ == "__main__" ):
    lw.log( ['script version %s started' % addonversion], xbmc.LOGNOTICE )
    lw.log( ['debug logging set to %s' % logdebug], xbmc.LOGNOTICE )
    if xbmcgui.Window( 10000 ).getProperty( "speedfan.running" ) == "true":
        lw.log( ['script already running, aborting subsequent run attempts'] )
    else:
        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) )
        token = _oauth.Token(self.OAUTHTOKEN, self.OAUTHSECRET)
        url = "https://mail.google.com/mail/b/%s/smtp/" % self.GMAILACCOUNT
        conn = _smtp.SMTP('smtp.googlemail.com', 587)
        conn.set_debuglevel(True)
        conn.ehlo('test')
        conn.starttls()
        conn.ehlo()
        conn.authenticate(url, consumer, token)
        subject = "Test of Cablebox Failed"
        header = 'To:%s\nFrom: %s\nSubject:%s\n' % (self.TOEMAIL, self.GMAILACCOUNT, subject)
        msg = 'The test recording was not found.  The servo has been actived.'
        if extrainfo:
            msg = msg + '\n\n---extra information follows---\n'
            for line in extrainfo:
                msg = msg + line.__str__() + '\n'
        conn.sendmail(self.GMAILACCOUNT, self.TOEMAIL, header + msg + '\n\n')


    def _trigger_servo( self ):
        servo_prog = os.path.join( self.DATAROOT, 'servo.vbs' )
        if xbmcvfs.exists( servo_prog ):
            subprocess.call( servo_prog, shell=True )



if ( __name__ == "__main__" ):
    lw.log( ['script version %s started' % __addonversion__], xbmc.LOGNOTICE )
    lw.log( ['debug logging set to %s' % __logdebug__], xbmc.LOGNOTICE )
    Main()
lw.log( ['script stopped'], xbmc.LOGNOTICE )
            lw.log(['unexpected error when reading log file', e],
                   xbmc.LOGERROR)
            return ('', '')
        lw.log(['opened logfile ' + self.LOGFILE])
        #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
        first = self._parse_line(f, 0)
        last = self._parse_line(f, 2)
        f.close()
        lw.log(['first line: ' + first, 'last line: ' + last])
        return first, last


#run the script
if (__name__ == "__main__"):
    lw.log(['script version %s started' % addonversion], xbmc.LOGNOTICE)
    lw.log(['debug logging set to %s' % logdebug], xbmc.LOGNOTICE)
    if xbmcgui.Window(10000).getProperty("speedfan.running") == "true":
        lw.log(['script already running, aborting subsequent run attempts'])
    else:
        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)
Example #7
0

    def _send_email( self, loglines ):
        consumer = _oauth.Consumer('anonymous', 'anonymous')
        token = _oauth.Token(self.OAUTHTOKEN, self.OAUTHSECRET)
        url = "https://mail.google.com/mail/b/%s/smtp/" % self.GMAILACCOUNT
        conn = _smtp.SMTP('smtp.googlemail.com', 587)
        conn.set_debuglevel(True)
        conn.ehlo('test')
        conn.starttls()
        conn.ehlo()
        conn.authenticate(url, consumer, token)
        subject = "Test of Cablebox Failed"
        header = 'To:%s\nFrom: %s\nSubject:%s\n' % (self.TOEMAIL, self.GMAILACCOUNT, subject)
        msg = 'The test recording was not found.  The servo has been actived.\n\n---Log follows---\n'
        for line in loglines:
            msg = msg + line.__str__() + '\n'
        conn.sendmail(self.GMAILACCOUNT, self.TOEMAIL, header + msg + '\n\n')


    def _trigger_servo( self ):
        servo_prog = os.path.join( self.DATAROOT, 'servo.vbs' )
        if xbmcvfs.exists( servo_prog ):
            subprocess.call( servo_prog, shell=True )



if ( __name__ == "__main__" ):
    lw.log( ['script version %s started' % __addonversion__], xbmc.LOGNOTICE )
    Main()
lw.log( ['script stopped'], xbmc.LOGNOTICE )
Example #8
0
     folders, throwaway = xbmcvfs.listdir( self.ASCACHEFOLDER )
 except OSError:
     lw.log( ['no directory found: ' + self.ASCACHEFOLDER] )
     return
 except Exception, e:
     lw.log( ['unexpected error while getting directory list', e] )
     return
 pDialog = DialogProgressBG()
 pDialog.create( smartUTF8(language(32003)), smartUTF8(language(30301)) )
 total = len( folders )
 count = 1
 for folder in folders:
     try:
         artist_start = hashmap[folder]
     except KeyError:
         lw.log( ['no matching artist folder for: ' + folder] )
         artist_start = ''
     except Exception, e:
         lw.log( ['unexpected error while finding matching artist for ' + folder, e] )
         artist_start = ''
     if artist_start:
         pDialog.update(int(100*(count/total)), smartUTF8( language(32003) ), smartUTF8( artist_start ) )
         if self.ENABLEFUZZYSEARCH == 'true':
             artist_name = ''
             lw.log( ['the illegal characters are ', self.ILLEGALCHARS, 'the replacement is ' + self.ILLEGALREPLACE] )
             for c in list( self._remove_trailing_dot( artist_start ) ):
                 if c in self.ILLEGALCHARS:
                     artist_name = artist_name + self.ILLEGALREPLACE
                 else:
                     artist_name = artist_name + c  
         else:
    if module == 'local':
        return 'true', 0
    try:
        active = addon.getSetting( preamble + module )
    except ValueError:
        active = 'false'
    except Exception, e:
        lw.log( ['unexpected error while parsing %s setting for %s' % (description, module), e] )
        active = 'false'        
    if active == 'true':
        try:
            priority = int( addon.getSetting( preamble + "priority_" + module ) )
        except ValueError:
            priority = 10
        except Exception, e:
            lw.log( ['unexpected error while parsing %s priority for %s' % (description, module), e] )
            priority = 10
    else:
        priority = 10
    return active, priority

bio_plugins = {'names':[], 'objs':{}}
image_plugins = {'names':[], 'objs':{}}
album_plugins = {'names':[], 'objs':{}}
similar_plugins = {'names':[], 'objs':{}}
for module in resources.plugins.__all__:
    full_plugin = 'resources.plugins.' + module
    __import__( full_plugin )
    imp_plugin = sys.modules[ full_plugin ]
    lw.log( ['loaded plugin ' + module] )
    plugin = imp_plugin.objectConfig()