summary refs log tree commit diff stats
path: root/ranger.py
Commit message (Expand)AuthorAgeFilesLines
* Run python with flag "-O" by defaulthut2010-05-101-1/+1
* Fixed bug #65 by adding flag "--fail-if-run"hut2010-04-261-1/+1
* ranger.py: removed whitespacehut2010-04-121-4/+0
* reverted a part of 45cf5174. Allow "source ranger ranger" againhut2010-04-011-8/+7
* removed the cd-after-exit hackhut2010-03-291-13/+8
* ranger.__init__: don't implicitly import ranger.__main__hut2010-03-261-1/+1
* Changed license to the GNU General Public Licensehut2010-02-281-12/+14
* ranger.py: fixed cd-after-exit with spaces in directoryhut2010-02-241-1/+1
* ranger.py: removed unnecessary codehut2010-02-151-1/+1
* ranger.py: reverted cd-after-exit to the old wayhut2010-02-141-10/+1
* ranger.py: more simple '--debug' flag checkhut2010-02-141-1/+1
* ranger.py: improved handling of bad importhut2010-01-261-1/+2
* ranger.py: more fixeshut2010-01-121-2/+2
* ranger.py: cleanup/fixhut2010-01-111-9/+8
* fixed #31, cd-after-exit works even after pressing ^Chut2010-01-111-1/+12
* added license informationhut2010-01-081-3/+17
* F1 key (inside console) for viewing information about the commandhut2009-12-291-1/+1
* shorten comment in ranger.pyhut2009-12-261-11/+5
* implemented OpenConsolehut2009-12-251-2/+2
* random updateshut2009-12-251-3/+16
* tons of stuffhut2009-12-171-1/+1
* merged main with __init__hut2009-12-121-1/+1
* restructurationshut2009-12-111-2/+4
* changing implementation of optionshut2009-12-061-3/+6
* structural improvementshut2009-12-011-46/+9
* random improvementshut2009-11-291-2/+2) // Functions and types in this file pertain // to periodic, regular actions. // This is a wrapper for a *time.Ticker // that adds another channel. It's used // to signal to the ticker goroutines // that they should stop the tickers // and exit. type tick struct { isDB bool t *time.Ticker exit chan bool } // Creates a new instance of a tick func initTicker(db bool, interval time.Duration) *tick { return &tick{ isDB: db, t: time.NewTicker(interval), exit: make(chan bool, 1), } } // Sends the signal to stop the tickers // and for their respective goroutines // to exit. func killTickers() { ct := <-cTickC dt := <-dbTickC ct.exit <- true dt.exit <- true } // Waits for a signal from the database // *tick. Either stops the ticker and // kills the goroutine or it will // update cache / push the DB to disk func dataTimer(tkr *tick) { for { select { case signal := <-tkr.t.C: if tkr.isDB { errLog("", pushDB()) log.Printf("Database push took: %v\n", time.Since(signal)) continue } cacheUpdate() log.Printf("Cache update took: %v\n", time.Since(signal)) case <-tkr.exit: tkr.t.Stop() return } } } // Called when a change is detected in the // configuration file. Closes log file, // closes database connection, stops all // tickers, then binds new configuration // values, opens new log file, connects to // new database, and starts new cache and // database tickers. func reInit(e fsnotify.Event) { log.Printf("%v. Reloading...\n", e.String()) if !confObj.StdoutLogging { closeLog <- true } killTickers() killDB() bindConfig() initLogging() initDatabase() initPersistence() } // Starts the tickers that periodically: // - pull new user statuses into cache // - push cached data to disk func initPersistence() { confObj.Mu.RLock() cacheTkr := initTicker(false, confObj.CacheInterval) dbTkr := initTicker(true, confObj.DBInterval) confObj.Mu.RUnlock() go dataTimer(cacheTkr) go dataTimer(dbTkr) dbTickC <- dbTkr cTickC <- cacheTkr }