package main
import (
"bytes"
"io/ioutil"
"log"
"net"
"os"
"strings"
"time"
"github.com/getwtxt/registry"
"github.com/syndtr/goleveldb/leveldb"
)
// Checks whether it's time to refresh
// the cache.
func checkCacheTime() bool {
return time.Since(confObj.LastCache) > confObj.CacheInterval
}
// Checks whether it's time to push
// the cache to the database
func checkDBtime() bool {
return time.Since(confObj.LastPush) > confObj.DBInterval
}
// Launched by init as a goroutine to constantly watch
// for the update interval to pass.
func cacheAndPush() {
for {
if checkCacheTime() {
refreshCache()
}
if checkDBtime() {
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Python: module ranger.commands</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head><body bgcolor="#f0f0f8">
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="#7799ee">
<td valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="ranger.html"><font color="#ffffff">ranger</font></a>.commands</strong></big></big></font></td
><td align=right valign=bottom
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/hut/work/ranger/ranger/commands.py">/home/hut/work/ranger/ranger/commands.py</a></font></td></tr></table>
<p></p>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#aa55cc">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
<tr><td bgcolor="#aa55cc"><tt> </tt></td><td> </td>
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="os.html">os</a><br>
</td><td width="25%" valign=top></td><td width="25%" valign=top></td><td width="25%" valign=top></td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ee77aa">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
<tr><td bgcolor="#ee77aa"><tt> </tt></td><td> </td>
<td width="100%"><dl>
<dt><font face="helvetica, arial"><a href="builtins.html#object">builtins.object</a>
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="ranger.commands.html#parse">parse</a>
</font></dt></dl>
</dd>
<dt><font face="helvetica, arial"><a href="ranger.shared.html#FileManagerAware">ranger.shared.FileManagerAware</a>(<a href="ranger.shared.html#Awareness">ranger.shared.Awareness</a>)
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="ranger.commands.html#Command">Command</a>
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="ranger.commands.html#cd">cd</a>
</font></dt><dt><font face="helvetica, arial"><a href="ranger.commands.html#delete">delete</a>
</font></dt><dt><font face="helvetica, arial"><a href="ranger.commands.html#delete">delete</a>
</font></dt><dt><font face="helvetica, arial"><a href="ranger.commands.html#find">find</a>
</font></dt><dt><font face="helvetica, arial"><a href="ranger.commands.html#mkdir">mkdir</a>
</font></dt><dt><font face="helvetica, arial"><a href="ranger.commands.html#quit">quit</a>
</font></dt></dl>
</dd>
</dl>
</dd>
</dl>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="Command">class <strong>Command</strong></a>(<a href="ranger.shared.html#FileManagerAware">ranger.shared.FileManagerAware</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt>Abstract command class<br> </tt></td></tr>
<tr><td> </td>
<td width="100%"><dl><dt>Method resolution order:</dt>
<dd><a href="ranger.commands.html#Command">Command</a></dd>
<dd><a href="ranger.shared.html#FileManagerAware">ranger.shared.FileManagerAware</a></dd>
<dd><a href="ranger.shared.html#Awareness">ranger.shared.Awareness</a></dd>
<dd><a href="builtins.html#object">builtins.object</a></dd>
</dl>
<hr>
Methods defined here:<br>
<dl><dt><a name="Command-__init__"><strong>__init__</strong></a>(self, line, mode)</dt></dl>
<dl><dt><a name="Command-execute"><strong>execute</strong></a>(self)</dt></dl>
<dl><dt><a name="Command-quick_open"><strong>quick_open</strong></a>(self)</dt></dl>
<dl><dt><a name="Command-tab"><strong>tab</strong></a>(self)</dt></dl>
<hr>
Data and other attributes defined here:<br>
<dl><dt><strong>line</strong> = ''</dl>
<dl><dt><strong>mode</strong> = ':'</dl>
<dl><dt><strong>name</strong> = None</dl>
<hr>
Data and other attributes inherited from <a href="ranger.shared.html#FileManagerAware">ranger.shared.FileManagerAware</a>:<br>
<dl><dt><strong>fm</strong> = None</dl>
<hr>
Data descriptors inherited from <a href="ranger.shared.html#Awareness">ranger.shared.Awareness</a>:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list of weak references to the object (if defined)</tt></dd>
</dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="cd">class <strong>cd</strong></a>(<a href="ranger.commands.html#Command">Command</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt>The <a href="#cd">cd</a> command changes the directory. The command '<a href="#cd">cd</a> -' is<br>
equivalent to typing ``. In the quick console, the directory<br>
will be entered without the need to press enter, as soon as there<br>
is one unambiguous match.<br> </tt></td></tr>
<tr><td> </td>
<td width="100%"><dl><dt>Method resolution order:</dt>
<dd><a href="ranger.commands.html#cd">cd</a></dd>
<dd><a href="ranger.commands.html#Command">Command</a></dd>
<dd><a href="ranger.shared.html#FileManagerAware">ranger.shared.FileManagerAware</a></dd>
<dd><a href="ranger.shared.html#Awareness">ranger.shared.Awareness</a></dd>
<dd><a href="builtins.html#object">builtins.object</a></dd>
</dl>
<hr>
Methods defined here:<br>
<dl><dt><a name="cd-execute"><strong>execute</strong></a>(self)</dt></dl>
<dl><dt><a name="cd-quick_open"><strong>quick_open</strong></a>(self)</dt></dl>
<dl><dt><a name="cd-tab"><strong>tab</strong></a>(self)</dt></dl>
<hr>
Methods inherited from <a href="ranger.commands.html#Command">Command</a>:<br>
<dl><dt><a name="cd-__init__"><strong>__init__</strong></a>(self, line, mode)</dt></dl>
<hr>
Data and other attributes inherited from <a href="ranger.commands.html#Command">Command</a>:<br>
<dl><dt><strong>line</strong> = ''</dl>
<dl><dt><strong>mode</strong> = ':'</dl>
<dl><dt><strong>name</strong> = None</dl>
<hr>
Data and other attributes inherited from <a href="ranger.shared.html#FileManagerAware">ranger.shared.FileManagerAware</a>:<br>
<dl><dt><strong>fm</strong> = None</dl>
<hr>
Data descriptors inherited from <a href="ranger.shared.html#Awareness">ranger.shared.Awareness</a>:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list of weak references to the object (if defined)</tt></dd>
</dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="delete">class <strong>delete</strong></a>(<a href="ranger.commands.html#Command">Command</a>)</font></td></tr>
<tr><td bgcolor="#ffc8d8"><tt> </tt></td><td> </td>
<td width="100%"><dl><dt>Method resolution order:</dt>
<dd><a href="ranger.commands.html#delete">delete</a></dd>
<dd><a href="ranger.commands.html#Command">Command</a></dd>
<dd><a href="ranger.shared.html#FileManagerAware">ranger.shared.FileManagerAware</a></dd>
<dd><a href="ranger.shared.html#Awareness">ranger.shared.Awareness</a></dd>
<dd><a href="builtins.html#object">builtins.object</a></dd>
</dl>
<hr>
Methods defined here:<br>
<dl><dt><a name="delete-execute"><strong>execute</strong></a>(self)</dt></dl>
<hr>
Methods inherited from <a href="ranger.commands.html#Command">Command</a>:<br>
<dl><dt><a name="delete-__init__"><strong>__init__</strong></a>(self, line, mode)</dt></dl>
<dl><dt><a name="delete-quick_open"><strong>quick_open</strong></a>(self)</dt></dl>
<dl><dt><a name="delete-tab"><strong>tab</strong></a>(self)</dt></dl>
<hr>
Data and other attributes inherited from <a href="ranger.commands.html#Command">Command</a>:<br>
<dl><dt><strong>line</strong> = ''</dl>
<dl><dt><strong>mode</strong> = ':'</dl>
<dl><dt><strong>name</strong> = None</dl>
<hr>
Data and other attributes inherited from <a href="ranger.shared.html#FileManagerAware">ranger.shared.FileManagerAware</a>:<br>
<dl><dt><strong>fm</strong> = None</dl>
<hr>
Data descriptors inherited from <a href="ranger.shared.html#Awareness">ranger.shared.Awareness</a>:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list of weak references to the object (if defined)</tt></dd>
</dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="find">class <strong>find</strong></a>(<a href="ranger.commands.html#Command">Command</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt>The <a href="#find">find</a> command will attempt to <a href="#find">find</a> a partial, case insensitive<br>
match in the filenames of the current directory. In the quick command<br>
console, once there is one unambiguous match, the file will be run<br>
automatically.<br> </tt></td></tr>
<tr><td> </td>
<td width="100%"><dl><dt>Method resolution order:</dt>
<dd><a href="ranger.commands.html#find">find</a></dd>
<dd><a href="ranger.commands.html#Command">Command</a></dd>
<dd><a href="ranger.shared.html#FileManagerAware">ranger.shared.FileManagerAware</a></dd>
<dd><a href="ranger.shared.html#Awareness">ranger.shared.Awareness</a></dd>
<dd><a href="builtins.html#object">builtins.object</a></dd>
</dl>
<hr>
Methods defined here:<br>
<dl><dt><a name="find-execute"><strong>execute</strong></a>(self)</dt></dl>
<dl><dt><a name="find-quick_open"><strong>quick_open</strong></a>(self)</dt></dl>
<hr>
Data and other attributes defined here:<br>
<dl><dt><strong>count</strong> = 0</dl>
<hr>
Methods inherited from <a href="ranger.commands.html#Command">Command</a>:<br>
<dl><dt><a name="find-__init__"><strong>__init__</strong></a>(self, line, mode)</dt></dl>
<dl><dt><a name="find-tab"><strong>tab</strong></a>(self)</dt></dl>
<hr>
Data and other attributes inherited from <a href="ranger.commands.html#Command">Command</a>:<br>
<dl><dt><strong>line</strong> = ''</dl>
<dl><dt><strong>mode</strong> = ':'</dl>
<dl><dt><strong>name</strong> = None</dl>
<hr>
Data and other attributes inherited from <a href="ranger.shared.html#FileManagerAware">ranger.shared.FileManagerAware</a>:<br>
<dl><dt><strong>fm</strong> = None</dl>
<hr>
Data descriptors inherited from <a href="ranger.shared.html#Awareness">ranger.shared.Awareness</a>:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list of weak references to the object (if defined)</tt></dd>
</dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="mkdir">class <strong>mkdir</strong></a>(<a href="ranger.commands.html#Command">Command</a>)</font></td></tr>
<tr><td bgcolor="#ffc8d8"><tt> </tt></td><td> </td>
<td width="100%"><dl><dt>Method resolution order:</dt>
<dd><a href="ranger.commands.html#mkdir">mkdir</a></dd>
<dd><a href="ranger.commands.html#Command">Command</a></dd>
<dd><a href="ranger.shared.html#FileManagerAware">ranger.shared.FileManagerAware</a></dd>
<dd><a href="ranger.shared.html#Awareness">ranger.shared.Awareness</a></dd>
<dd><a href="builtins.html#object">builtins.object</a></dd>
</dl>
<hr>
Methods defined here:<br>
<dl><dt><a name="mkdir-execute"><strong>execute</strong></a>(self)</dt></dl>
<hr>
Methods inherited from <a href="ranger.commands.html#Command">Command</a>:<br>
<dl><dt><a name="mkdir-__init__"><strong>__init__</strong></a>(self, line, mode)</dt></dl>
<dl><dt><a name="mkdir-quick_open"><strong>quick_open</strong></a>(self)</dt></dl>
<dl><dt><a name="mkdir-tab"><strong>tab</strong></a>(self)</dt></dl>
<hr>
Data and other attributes inherited from <a href="ranger.commands.html#Command">Command</a>:<br>
<dl><dt><strong>line</strong> = ''</dl>
<dl><dt><strong>mode</strong> = ':'</dl>
<dl><dt><strong>name</strong> = None</dl>
<hr>
Data and other attributes inherited from <a href="ranger.shared.html#FileManagerAware">ranger.shared.FileManagerAware</a>:<br>
<dl><dt><strong>fm</strong> = None</dl>
<hr>
Data descriptors inherited from <a href="ranger.shared.html#Awareness">ranger.shared.Awareness</a>:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list of weak references to the object (if defined)</tt></dd>
</dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="parse">class <strong>parse</strong></a>(<a href="builtins.html#object">builtins.object</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt>Parse commands and extract information<br> </tt></td></tr>
<tr><td> </td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="parse-__add__"><strong>__add__</strong></a>(self, newpart)</dt></dl>
<dl><dt><a name="parse-__init__"><strong>__init__</strong></a>(self, line)</dt></dl>
<dl><dt><a name="parse-chunk"><strong>chunk</strong></a>(self, n, otherwise<font color="#909090">=''</font>)</dt></dl>
<hr>
Data descriptors defined here:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list of weak references to the object (if defined)</tt></dd>
</dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="quit">class <strong>quit</strong></a>(<a href="ranger.commands.html#Command">Command</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt>Quits the program.<br> </tt></td></tr>
<tr><td> </td>
<td width="100%"><dl><dt>Method resolution order:</dt>
<dd><a href="ranger.commands.html#quit">quit</a></dd>
<dd><a href="ranger.commands.html#Command">Command</a></dd>
<dd><a href="ranger.shared.html#FileManagerAware">ranger.shared.FileManagerAware</a></dd>
<dd><a href="ranger.shared.html#Awareness">ranger.shared.Awareness</a></dd>
<dd><a href="builtins.html#object">builtins.object</a></dd>
</dl>
<hr>
Methods defined here:<br>
<dl><dt><a name="quit-execute"><strong>execute</strong></a>(self)</dt></dl>
<hr>
Methods inherited from <a href="ranger.commands.html#Command">Command</a>:<br>
<dl><dt><a name="quit-__init__"><strong>__init__</strong></a>(self, line, mode)</dt></dl>
<dl><dt><a name="quit-quick_open"><strong>quick_open</strong></a>(self)</dt></dl>
<dl><dt><a name="quit-tab"><strong>tab</strong></a>(self)</dt></dl>
<hr>
Data and other attributes inherited from <a href="ranger.commands.html#Command">Command</a>:<br>
<dl><dt><strong>line</strong> = ''</dl>
<dl><dt><strong>mode</strong> = ':'</dl>
<dl><dt><strong>name</strong> = None</dl>
<hr>
Data and other attributes inherited from <a href="ranger.shared.html#FileManagerAware">ranger.shared.FileManagerAware</a>:<br>
<dl><dt><strong>fm</strong> = None</dl>
<hr>
Data descriptors inherited from <a href="ranger.shared.html#Awareness">ranger.shared.Awareness</a>:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list of weak references to the object (if defined)</tt></dd>
</dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><strong>var</strong> = <a name="var">class delete</a>(<a href="ranger.commands.html#Command">Command</a>)</font></td></tr>
<tr><td bgcolor="#ffc8d8"><tt> </tt></td><td> </td>
<td width="100%"><dl><dt>Method resolution order:</dt>
<dd><a href="ranger.commands.html#delete">delete</a></dd>
<dd><a href="ranger.commands.html#Command">Command</a></dd>
<dd><a href="ranger.shared.html#FileManagerAware">ranger.shared.FileManagerAware</a></dd>
<dd><a href="ranger.shared.html#Awareness">ranger.shared.Awareness</a></dd>
<dd><a href="builtins.html#object">builtins.object</a></dd>
</dl>
<hr>
Methods defined here:<br>
<dl><dt><a name="delete-execute"><strong>execute</strong></a>(self)</dt></dl>
<hr>
Methods inherited from <a href="ranger.commands.html#Command">Command</a>:<br>
<dl><dt><a name="delete-__init__"><strong>__init__</strong></a>(self, line, mode)</dt></dl>
<dl><dt><a name="delete-quick_open"><strong>quick_open</strong></a>(self)</dt></dl>
<dl><dt><a name="delete-tab"><strong>tab</strong></a>(self)</dt></dl>
<hr>
Data and other attributes inherited from <a href="ranger.commands.html#Command">Command</a>:<br>
<dl><dt><strong>line</strong> = ''</dl>
<dl><dt><strong>mode</strong> = ':'</dl>
<dl><dt><strong>name</strong> = None</dl>
<hr>
Data and other attributes inherited from <a href="ranger.shared.html#FileManagerAware">ranger.shared.FileManagerAware</a>:<br>
<dl><dt><strong>fm</strong> = None</dl>
<hr>
Data descriptors inherited from <a href="ranger.shared.html#Awareness">ranger.shared.Awareness</a>:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list of weak references to the object (if defined)</tt></dd>
</dl>
</td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#eeaa77">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
<tr><td bgcolor="#eeaa77"><tt> </tt></td><td> </td>
<td width="100%"><dl><dt><a name="-alias"><strong>alias</strong></a>(**kw)</dt></dl>
</td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#55aa55">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
<tr><td bgcolor="#55aa55"><tt> </tt></td><td> </td>
<td width="100%"><strong>by_name</strong> = {'cd': <class 'ranger.commands.cd'>, 'delete': <class 'ranger.commands.delete'>, 'find': <class 'ranger.commands.find'>, 'mkdir': <class 'ranger.commands.mkdir'>, 'q': <class 'ranger.commands.quit'>, 'quit': <class 'ranger.commands.quit'>}<br>
<strong>varname</strong> = 'delete'</td></tr></table>
</body></html>