Package gozerbot :: Module generic
[hide private]
[frames] | no frames]

Module generic

source code

generic functions


Copyright: this file is in the public domain

Classes [hide private]
  istr
adjustable string object
  PopenWhitelistError
exception to be raised if popen arguments contain options
  PopenListError
exception to tbe raised if popen argument is not a list
  GozerStringIO
  Gozerpopen4
class providing a close method to subprocess
  CBURLopener
our URLOpener
  Stripper
html stripper
Functions [hide private]
 
cleanpyc() source code
 
getversion() source code
 
gethgrev()
get mercurial revision
source code
 
getsvnrev()
get subversion revision
source code
 
makeoptions(ievent, options={}) source code
 
makeargrest(ievent)
create ievent.args and ievent.rest ..
source code
 
enable_logging()
enable logging
source code
 
openlogfile(fname, mode="a+")
open log file
source code
 
setdefenc(encoding) source code
 
plugfile() source code
 
cchar(bot, ievent)
return control char of bot/ievent's channel
source code
 
splittxt(what, l=375)
split text into <l> char portions
source code
 
lockdec(lock)
return locking descriptor locking on the provided lock
source code
 
popenlocked(func)
lock function func
source code
 
gozerpopen(args, userargs=[])
function to use to run a subprocess ..
source code
 
die()
stop the bot
source code
 
reboot()
reboot the bot
source code
 
reboot_stateful(bot, ievent, fleet, partyline)
reboot the bot, but keep the connections
source code
 
calledfrom(frame)
return plugin from which function is called
source code
 
callstack(frame)
return plugin from which function is called
source code
 
whichmodule()
return plugin from which function is called
source code
 
stripident(userhost)
strip ident char from userhost
source code
 
stripidents(ulist)
strip ident char from list of userhosts
source code
 
rlogfile(level, descr, txt)
log to file
source code
 
rlog(level, descr, txt, nofile=False)
log text if level >= loglevel
source code
 
log(level, txt, nofile=False)
log text if level >= loglevel
source code
 
exceptionmsg() source code
 
handle_exception(ievent=None, log=True, short=False, txt='')
print exception trace to sys.stderr
source code
 
getlistensocket(listenip)
scan for a free socket on listenip
source code
 
elapsedstring(nsec, ywd=None)
return string of elapsed time
source code
 
hourmin(ttime)
extract hour:minutes from time
source code
 
striptime(what)
strip time indicators from string
source code
 
now() source code
 
today()
get time for today 00:00
source code
 
strtotime(what)
convert string to time
source code
 
uurminsec(ttime)
return hours:minutes:seconds string
source code
 
getdaymonth(ttime)
return day-month tuple
source code
 
getdaymonthyear(ttime)
return day-month-year tuple
source code
 
dmy(ttime)
return day-month-year string
source code
 
checkchan(bot, item)
check if chan <channel> is in string
source code
 
getwho(bot, who)
get userhost from bots userhost cache
source code
 
waitforuser(bot, userhost, timeout=15)
wait for user response
source code
 
useragent()
provide useragent string
source code
 
geturl(url, version=None)
fetch an url
source code
 
geturl2(url, decode=False)
use urllib2 to fetch an url
source code
 
geturl3(url, myheaders={}, postdata={}, keyfile='', certfile='', port=80) source code
 
geturl4(url, myheaders={}, postdata={}, keyfile='', certfile='', port=80) source code
 
posturl(url, myheaders, postdata, keyfile=None, certfile='', port=80)
very basic HTTP POST url retriever
source code
 
deleteurl(url, myheaders={}, postdata={}, keyfile='', certfile='', port=80)
very basic HTTP POST url retriever
source code
 
puturl(url, myheaders={}, postdata={}, keyfile='', certfile='', port=80)
very basic HTTP POST url retriever
source code
 
getpostdata(event) source code
 
decode_html_entities(s)
smart decoding of html entities to utf-8
source code
 
get_encoding(data)
get encoding from web data
source code
 
getrandomnick()
generate random nick
source code
 
striphtml(txt)
strip html from txt
source code
 
waitforqueue(queue, timeout=10, maxitems=None)
wait for queue output
source code
 
decodeperchar(txt, encoding='utf-8', what='') source code
 
toenc(what, encoding='utf-8') source code
 
fromenc(txt, encoding='utf-8', what='') source code
 
toascii(what)
convert to ascii
source code
 
tolatin1(what)
convert to latin-1
source code
 
strippedtxt(what)
strip txt to barebones
source code
 
uniqlist(l)
return unique values of list
source code
 
fix_format(s)
make sure bold txt is completed
source code
 
stripbold(s)
remove bold from string
source code
 
jabberstrip(what)
strip jabber txt to barebones
source code
 
plugnames(dirname)
get all plugnames in dir
source code
 
filesize(path)
function to determine file size
source code
 
touch(fname)
touch filename
source code
 
stringinlist(s, l)
check if string is substring of the lists elements
source code
 
stripped(userhost)
strip resource from userhost
source code
 
checkpermissions(ddir, umode)
set permissions of dir to umode
source code
Variables [hide private]
  debuglog = False
  chardet = None
  exceptionlist = []
  hostnamere = re.compile(r'^[\w\.]+$')
  logging_enabled = False
  fname = os.path.join(datadir, config ['logfile'])
  logfile = None
  popenlock = thread.allocate_lock()
  logcallbacks = []
  directlist = ['urlopen error timed out', '[Errno socket error]...
  leapfactor = 0.000684931506849
  timere = re.compile(r'(\S+)\s+(\S+)\s+(\d+)\s+(\d+):(\d+):(\d+...
  bdmonths = ['Bo', 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'J...
Function Details [hide private]

makeargrest(ievent)

source code 

create ievent.args and ievent.rest .. this is needed because ircevents might be created outside the parse() function

gozerpopen(args, userargs=[])

source code 

function to use to run a subprocess .. enforces list argument and checks for options passed


Variables Details [hide private]

directlist

Value:
['urlopen error timed out',
 '[Errno socket error] timed out',
 'Name or service not known',
 'No route to host',
 'Non-recoverable failure in name resolution']

timere

Value:
re.compile(r'(\S+)\s+(\S+)\s+(\d+)\s+(\d+):(\d+):(\d+)\s+(\d+)')

bdmonths

Value:
['Bo',
 'Jan',
 'Feb',
 'Mar',
 'Apr',
 'May',
 'Jun',
 'Jul',
...