コード例 #1
0
ファイル: db.py プロジェクト: cold12/Scrobbee
 def action(self, query, args=None):
     with db_lock:
         if query == None:
             return
 
         sqlResult = None
         attempt = 0
 
         while attempt < 5:
             try:
                 if args == None:
                     logger.debug("Executing: " + query, 'Database ' + self.filename)
                     sqlResult = self.connection.execute(query)
                 else:
                     logger.debug("Executing: " + query+" with args " + str(args), 'Database' + self.filename)
                     sqlResult = self.connection.execute(query, args)
                 self.connection.commit()
                 # get out of the connection attempt loop since we were successful
                 break
             except sqlite3.OperationalError, e:
                 if "unable to open database file" in e.message or "database is locked" in e.message:
                     logger.warning("Database error: " + e.message, 'Database' + self.filename)
                     attempt += 1
                     time.sleep(1)
                 else:
                     logger.error("DataBase error: " + e.message, 'Database' + self.filename)
                     raise
             except sqlite3.DatabaseError, e:
                 logger.error("Fatal error executing query: " + e.message, 'Database' + self.filename)
                 raise
コード例 #2
0
ファイル: Scrobbee.py プロジェクト: cold12/Scrobbee
    # Initialize Scrobbee
    scrobbee.initialize()
    
    # Daemonize if necessary
    if scrobbee.DAEMON:
        daemonize()
    
    # While loop with actual functionality
    
    if not scrobbee.QUIET:
        print "Starting Scrobbee"
    
    scrobbee.start()
    
    # Start web browser
    if not scrobbee.NOLAUNCH:
        browserURL = "http://localhost:8080/"
        try:
            webbrowser.open(browserURL, 2, 1)
        except:
            try:
                webbrowser.open(browserURL, 1, 1)
            except:
                logger.error(u"Unable to launch a browser", 'Launch')
    
    while (True):
        time.sleep(1)

  
if __name__ == "__main__":
    main()