rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
print "This event type", event.eventtype(), "has no suitable event"
Debug("This event type", event.eventtype(), "has no suitable event")
def do_event(self, event): """Does an appropriate action based on event""" if event.eventtype() == "privmsg": for line in string.split(event.arguments()[0], "\n"): # print the output to the STDOUT, with a bit of colour print RED + ">" + \ PURPLE + self.connection.get_nickname() + \ RED + "/" + \ GREEN + event.target() ...
print "Parsed config files:" print config.read(filelist)
Debug("Parsed config files:", config.read(filelist))
def get_configs(self, filelist=[]): """Gets configuration options from a list of files""" from ConfigParser import ConfigParser, NoSectionError, NoOptionError
print "ERROR: Non-numeric port in config files."
Debug("ERROR: Non-numeric port in config files.")
def get_configs(self, filelist=[]): """Gets configuration options from a list of files""" from ConfigParser import ConfigParser, NoSectionError, NoOptionError
print "ERROR: [connection] section missing from config files."
Debug("ERROR: [connection] section missing from config files.")
def get_configs(self, filelist=[]): """Gets configuration options from a list of files""" from ConfigParser import ConfigParser, NoSectionError, NoOptionError
print "ERROR: missing vital option"
Debug("ERROR: missing vital option")
def get_configs(self, filelist=[]): """Gets configuration options from a list of files""" from ConfigParser import ConfigParser, NoSectionError, NoOptionError
'channels': channels, 'module_list': module_list,
'channels': channels, 'module_list': module_list, 'encoding': encoding,
def get_configs(self, filelist=[]): """Gets configuration options from a list of files""" from ConfigParser import ConfigParser, NoSectionError, NoOptionError
print "Module \"%s\" not found " % (newmod)
Debug("Module \"%s\" not found " % (newmod))
def load_module(self, event): """ this loads a module, at run-time. event is an Event whose arguments() attribute contains a list of modules to write (starting with the second element """ import imp for newmod in event.arguments()[1:]: # why this? --djd fp = "" pathname = "" description = ""
print "Added handler: " , handlerName, "for \"" \
Debug("Added handler: " , handlerName, "for \"" \
def load_module(self, event): """ this loads a module, at run-time. event is an Event whose arguments() attribute contains a list of modules to write (starting with the second element """ import imp for newmod in event.arguments()[1:]: # why this? --djd fp = "" pathname = "" description = ""
"priority ", newHandler.instance.priority
"priority ", newHandler.instance.priority)
def load_module(self, event): """ this loads a module, at run-time. event is an Event whose arguments() attribute contains a list of modules to write (starting with the second element """ import imp for newmod in event.arguments()[1:]: # why this? --djd fp = "" pathname = "" description = ""
print "reloading %s from %s" % (self.className, self.module.__name__)
Debug("reloading %s from %s" % (self.className, self.module.__name__))
def reInstantiate(self): from re import compile print "reloading %s from %s" % (self.className, self.module.__name__) reload(self.module) self.instance = getattr(self.module, self.className)() self.regex = compile(self.instance.regex)
self.regex = "^(weather|w)( [^ ]+){0,2}"
self.regex = "^(weather|w)($|( [^ ]+){1,2})"
def __init__(self): self.regex = "^(weather|w)( [^ ]+){0,2}"
n = 400 while len(result_string) > n: result_string = '\n'.join((result_string[:n],result_string[n:])) n += 400
def handler(self, **args): """Parse the received commandline arguments case length of the real arguments: zero, check database to see if the user already have a record. y: use it to get the forcast and setting change tips; n: print help message. 1, get and print the citylist. 2, get the citylist, and then get the for...
i = 1 result = "" for c, u in regionlist: result = "".join((result, "=", str(i),"=>", c)) i += 1 return result
if len(regionlist) == 1: c, u = regionlist[0] return self.getforcast(u) else: i = 1 result = "" for c, u in regionlist: result = "".join((result, "=", str(i),"=>", c)) if i % 10 == 0: result = "".join((result, '\n')) i += 1 return result
def gogetit(self, l): """get the citylist or forecast get the citylist, return it if there is no 3rd arg. check length against the 3rd arg if vailed, get the weather forcast. """ citykeyword = l[1].lower() search_parm = urllib.urlencode({"searchname": citykeyword.encode("gbk")}) print search_parm try: response = urll...
self.rCtoE = re.compile(u"Ӣʵ(.*)", re.M) self.rBlue = re.compile("<font color=blue>", re.I) self.rEtoC = re.compile(u"Ӣʵ</div>(.*?)</div>", re.S)
self.rCtoE = re.compile(u"Ӣʵ") self.rRwWord = re.compile('rwWord\("([^"]+)"\)') self.rEtoC = re.compile(u"Ӣʵ") self.rExplain = re.compile('explain_item">(.*?)</div>', re.S)
def __init__(self): # have problem filtering out `|' character self.regex = "^(dict |~)[^~\+\*/\\<>-]+" self.rStrip = re.compile("(<.*?>)+") self.rWord = re.compile("^<!-- WORD", re.I) self.rGif = re.compile("/gif/([\\w_]+)\\.gif", re.I) self.rBody = re.compile("^<!-- BODY", re.I) self.ymap = {"slash": "/", "quote": "...
self.rExpl = re.compile(u'class="explain_(?:attr|item)">(.*)', re.I)
def __init__(self): # have problem filtering out `|' character self.regex = "^(dict |~)[^~\+\*/\\<>-]+" self.rStrip = re.compile("(<.*?>)+") self.rWord = re.compile("^<!-- WORD", re.I) self.rGif = re.compile("/gif/([\\w_]+)\\.gif", re.I) self.rBody = re.compile("^<!-- BODY", re.I) self.ymap = {"slash": "/", "quote": "...
if self.ciba_failed <= 0: result = self.lookup_ciba(word) if result == "error": self.ciba_failed = 5 result = self.lookup_yahoo(word) else: result = self.lookup_yahoo(word) self.ciba_failed = self.ciba_failed - 1
result = self.lookup_ciba(word)
def handler(self, **args):
connect = httplib.HTTPConnection('cb.kingsoft.com', 80)
connect = httplib.HTTPConnection('www.iciba.com', 80)
def lookup_ciba(self, word): connect = httplib.HTTPConnection('cb.kingsoft.com', 80) connect.request("GET", "/search?s=%s&t=word&lang=utf-8" % (word.encode("UTF-8"), )) response = connect.getresponse() if response.status != 200: msg = "%d:%s" % (response.status, response.reason) loc = response.getheader("location") sel...
self.debug("dict word(%s) err(%s) loc(%s)" % (word, msg, loc))
self.Debug("dict word(%s) err(%s) loc(%s)" % (word, msg, loc))
def lookup_ciba(self, word): connect = httplib.HTTPConnection('cb.kingsoft.com', 80) connect.request("GET", "/search?s=%s&t=word&lang=utf-8" % (word.encode("UTF-8"), )) response = connect.getresponse() if response.status != 200: msg = "%d:%s" % (response.status, response.reason) loc = response.getheader("location") sel...
m = self.rBlue.split(m.group(1))[1:] words = [] for i in m: words.append(i[:i.find("<")]) return word + ": " + ", ".join(words)
m = self.rRwWord.findall(html) if m: result = word + ':' for i in m: result += ' ' + i return result
def lookup_ciba(self, word): connect = httplib.HTTPConnection('cb.kingsoft.com', 80) connect.request("GET", "/search?s=%s&t=word&lang=utf-8" % (word.encode("UTF-8"), )) response = connect.getresponse() if response.status != 200: msg = "%d:%s" % (response.status, response.reason) loc = response.getheader("location") sel...
html = m.group(1)
def lookup_ciba(self, word): connect = httplib.HTTPConnection('cb.kingsoft.com', 80) connect.request("GET", "/search?s=%s&t=word&lang=utf-8" % (word.encode("UTF-8"), )) response = connect.getresponse() if response.status != 200: msg = "%d:%s" % (response.status, response.reason) loc = response.getheader("location") sel...
m = self.rExpl.search(html)
m = self.rExplain.search(html)
def lookup_ciba(self, word): connect = httplib.HTTPConnection('cb.kingsoft.com', 80) connect.request("GET", "/search?s=%s&t=word&lang=utf-8" % (word.encode("UTF-8"), )) response = connect.getresponse() if response.status != 200: msg = "%d:%s" % (response.status, response.reason) loc = response.getheader("location") sel...
html = m.group(1) html = self.rStrip.sub(" ", html) result += " " result += html
result += ' ' + m.group(1).strip()
def lookup_ciba(self, word): connect = httplib.HTTPConnection('cb.kingsoft.com', 80) connect.request("GET", "/search?s=%s&t=word&lang=utf-8" % (word.encode("UTF-8"), )) response = connect.getresponse() if response.status != 200: msg = "%d:%s" % (response.status, response.reason) loc = response.getheader("location") sel...
if re.compile("/error").match(loc):
self.Debug(loc) if loc and re.compile("/error").match(loc):
def lookup_yahoo(self, word): connect = httplib.HTTPConnection('cn.yahoo.com', 80) w = word.encode("GBK") # better than error connect.request("GET", "/dictionary/result/%s/%s.html" % (w[0], w)) response = connect.getresponse() if response.status != 200: msg = "%d:%s" % (response.status, response.reason) loc = response....
Debug(moobot.RED + "There was an error with the database"+\
DebugErr(moobot.RED + "There was an error with the database"+\
def doSQL(SQL): """ executes the sql statement SQL and returns a list of tuples containing the results""" #grab a DB connection to use connection_num = getAConnection() #print moobot.RED + "got connection " + moobot.NORMAL + str(connection_num) results = [] try: cur = botdbs[connection_num].cursor() cur.execute(SQL.enc...
Debug(moobot.RED + "Exception occurred: " + moobot.BLUE + \
DebugErr(moobot.RED + "Exception occurred: " + moobot.BLUE + \
def doSQL(SQL): """ executes the sql statement SQL and returns a list of tuples containing the results""" #grab a DB connection to use connection_num = getAConnection() #print moobot.RED + "got connection " + moobot.NORMAL + str(connection_num) results = [] try: cur = botdbs[connection_num].cursor() cur.execute(SQL.enc...
unicode = dbencoding, unicode_errors = "replace")
use_unicode = True)
def getAConnection(): cnum = -1 # check to see if any existing connections are free. If not, # create a new one. while cnum == -1: for idx in range(len(dblocks)): if not dblocks[idx].locked(): if dblocks[idx].acquire(0): cnum = idx #if checkFreeConnections() != 0: # notify.set() break if cnum == -1: dblocks.append(thr...
search_request = "/ie?hl=zh-CN&oe=GBK&ie=GBK&q="
search_request = "/ie?hl=zh-CN&oe=UTF-8&ie=UTF-8&q="
def handler(self, **args): from irclib import Event, nm_to_n import string self.return_to_sender(args) search_terms = args["text"].split(" ")[3:] search_request = "/ie?hl=zh-CN&oe=GBK&ie=GBK&q=" # the resulting output so much nicer search_request += string.join(search_terms, "+") connect = httplib.HTTPConnection('www....
search_request += string.join(search_terms, "+")
search_request += string.join(search_terms, "+").encode("UTF-8", 'replace')
def handler(self, **args): from irclib import Event, nm_to_n import string self.return_to_sender(args) search_terms = args["text"].split(" ")[3:] search_request = "/ie?hl=zh-CN&oe=GBK&ie=GBK&q=" # the resulting output so much nicer search_request += string.join(search_terms, "+") connect = httplib.HTTPConnection('www....
listing = response.read()
listing = response.read().decode("UTF-8", 'replace')
def handler(self, **args): from irclib import Event, nm_to_n import string self.return_to_sender(args) search_terms = args["text"].split(" ")[3:] search_request = "/ie?hl=zh-CN&oe=GBK&ie=GBK&q=" # the resulting output so much nicer search_request += string.join(search_terms, "+") connect = httplib.HTTPConnection('www....
self.regex = "^dict .+"
self.regex = "^(dict |~)[^~\+\*/\\<>-]+"
def __init__(self): import re self.regex = "^dict .+" self.rStrip = re.compile("(<.*?>)+") self.rWord = re.compile("^<!-- WORD", re.I) self.rGif = re.compile("/gif/([\\w_]+)\\.gif", re.I) self.rBody = re.compile("^<!-- BODY", re.I) self.ymap = {"slash": "/", "quote": "'", "_e_": 2, "_a": "a:", "int": "S"} self.cmap = {...
import string
def handler(self, **args):
word = string.join(args["text"].split()[2:])
if args["text"].split()[1][0][0] == '~': word = "".join(args["text"].split()[1:])[1:] else: word = "".join(args["text"].split()[2:])
def handler(self, **args):
self.regex = "^((babelfish|translate) \w+ to \w+|%s|babelfish$|translate$)" % ("|".join(self.translations))
self.shortcuts = { "ec": "en_zh", "ce": "zh_en" } self.regex = "^((babelfish|translate) \w+ to \w+|(%s)\s+.+|babelfish$|translate$)" % ("|".join(self.translations + self.shortcuts.keys()))
def __init__(self): # the languages babelfish can do
+ "\r\nOr: {LN_LN} TEXT\r\nWhere LNs are \"%s\"" % (trans)
+ "\r\nSynonyms: {LN_LN} TEXT\r\nWhere LNs are \"%s\"" % (trans)
def help(self, args): from irclib import Event langs = " ".join(self.languages.keys()) trans = " ".join(self.languages.values()) return Event("privmsg", "", self.return_to_sender(args), [ "Usage: translate <FROM_LANGUAGE> to <TO_LANGUAGE> TEXT\r\nAvailable LANGUAGES are \"%s\"" % (langs) + "\r\nOr: {LN_LN} TEXT\r\nWher...
translation_key = args["text"].split(" ", 2)[1].lower()
def handler(self, **args): from irclib import Event import string, re, urllib translation_key = args["text"].split(" ", 2)[1].lower() tmp = args["text"].split(" ", 2) if len(tmp) != 3: return self.help(args) request = tmp[2] # chop off the "moobot: babelfish" if translation_key in self.translations: translation_text =...
if translation_key in self.translations:
if self.shortcuts.has_key(translation_key): translation_key = self.shortcuts[translation_key] translation_text = request elif translation_key in self.translations:
def handler(self, **args): from irclib import Event import string, re, urllib translation_key = args["text"].split(" ", 2)[1].lower() tmp = args["text"].split(" ", 2) if len(tmp) != 3: return self.help(args) request = tmp[2] # chop off the "moobot: babelfish" if translation_key in self.translations: translation_text =...
translation_text = " ".join(request.split()[3:]) if len(translation_text) == 0:
translation_text = " ".join(request.split()[3:]) if re.compile("^\s*$").match(translation_text):
def handler(self, **args): from irclib import Event import string, re, urllib translation_key = args["text"].split(" ", 2)[1].lower() tmp = args["text"].split(" ", 2) if len(tmp) != 3: return self.help(args) request = tmp[2] # chop off the "moobot: babelfish" if translation_key in self.translations: translation_text =...
searchRegex2 = re.compile("<td bgcolor=white class=s><div style=padding:10px;>(.+?)</div></td>")
searchRegex2 = re.compile("<td bgcolor=white class=s><div style=padding:10px;>(.*?)</div></td>")
def handler(self, **args): from irclib import Event import string, re, urllib translation_key = args["text"].split(" ", 2)[1].lower() tmp = args["text"].split(" ", 2) if len(tmp) != 3: return self.help(args) request = tmp[2] # chop off the "moobot: babelfish" if translation_key in self.translations: translation_text =...
if type(channels) == types.StringType:
if type(channels) == types.StringType or type(channels) == types.UnicodeType:
def part(self, channels): """Send a PART command.""" if type(channels) == types.StringType: self.send_raw("PART " + channels) else: self.send_raw("PART " + string.join(channels, ","))
print text.encode("gbk", "ignore"),
print text.encode("gbk", "ignore"), ' ',
def Debug(*args): for text in args: t = type(text) if t is unicode: print text.encode("gbk", "ignore"), elif t is str: print text, else: print str(text), print
print text,
print text, ' ',
def Debug(*args): for text in args: t = type(text) if t is unicode: print text.encode("gbk", "ignore"), elif t is str: print text, else: print str(text), print
print str(text),
print str(text), ' ',
def Debug(*args): for text in args: t = type(text) if t is unicode: print text.encode("gbk", "ignore"), elif t is str: print text, else: print str(text), print
self.regex = '^(?:(?:whois|whios\s+.+|%s)$' % (ipv4part)
self.regex = '^(?:(?:whois|whios)\s+.+|%s)$' % (ipv4part)
def __init__(self): # init regex import re
search_request = "/ie?ie=gbk&q="
search_request = "/ie?hl=zh-CN&oe=GBK&ie=GBK&q="
def handler(self, **args): from irclib import Event, nm_to_n import string self.return_to_sender(args) search_terms = args["text"].split(" ")[3:]
self.debug(string.split(args["text"], " ", 3)[3])
self.Debug(string.split(args["text"], " ", 3)[3])
def handler(self, **args): import priv, string from irclib import Event if (priv.checkPriv(args["source"], "all_priv") == 0): return Event("privmsg", "", self.return_to_sender(args), ["You can't do that!"])
elif tmplist[1].isalpha() and len1 >= 4:
elif tmplist[1].isalpha() and len1 > 4:
def handler(self, **args): """Parse the received commandline arguments case length of the real arguments: zero, check database to see if the user already have a record. y: use it to get the forcast and setting change tips; n: print help message. 1, get and print the citylist. 2, get the citylist, and then get the for...
search_parm = urllib.urlencode({"searchname": citykeyword})
search_parm = urllib.urlencode({"searchname": citykeyword.encode("gbk")})
def gogetit(self, l): """get the citylist or forecast get the citylist, return it if there is no 3rd arg. check length against the 3rd arg if vailed, get the weather forcast. """ citykeyword = l[1].lower() search_parm = urllib.urlencode({"searchname": citykeyword}) print search_parm try: response = urllib.urlopen("ht...
self.regex = "(^karma( .+$)?$|^\w+(\+\+|\-\-)$)"
self.regex = "(^karma( .+$)?$|^[^ ]+(\+\+|\-\-)$)"
def __init__(self): self.regex = "(^karma( .+$)?$|^\w+(\+\+|\-\-)$)"
from irclib import Event, nm_to_n
from irclib import Event
def handler(self, **args): import database from irclib import Event, nm_to_n # Set the target as either the person or the channel target = self.return_to_sender(args) orig_msg = args["text"] # Strip bot name orig_msg = orig_msg.split()[1:] # Now determine if we need to list karma or increment/decrement it, # which w...
+ str(record[i][0]) + ";"
+ self.str(record[i][0]) + ";"
def handler(self, **args): import database from irclib import Event, nm_to_n # Set the target as either the person or the channel target = self.return_to_sender(args) orig_msg = args["text"] # Strip bot name orig_msg = orig_msg.split()[1:] # Now determine if we need to list karma or increment/decrement it, # which w...
print name
self.debug(name)
def handler(self, **args): import database from irclib import Event, nm_to_n # Set the target as either the person or the channel target = self.return_to_sender(args) orig_msg = args["text"] # Strip bot name orig_msg = orig_msg.split()[1:] # Now determine if we need to list karma or increment/decrement it, # which w...
req = name + ": " + str(record[0][0])
req = name + ": " + self.str(record[0][0])
def handler(self, **args): import database from irclib import Event, nm_to_n # Set the target as either the person or the channel target = self.return_to_sender(args) orig_msg = args["text"] # Strip bot name orig_msg = orig_msg.split()[1:] # Now determine if we need to list karma or increment/decrement it, # which w...
msg += name + ": " + str(record[0][0]) + " ;; "
msg += name + ": " + self.str(record[0][0]) + " ;; "
def handler(self, **args): import database from irclib import Event, nm_to_n # Set the target as either the person or the channel target = self.return_to_sender(args) orig_msg = args["text"] # Strip bot name orig_msg = orig_msg.split()[1:] # Now determine if we need to list karma or increment/decrement it, # which w...
query = "update stats set counter="+ str(record[0][0]) +"+1 where nick='" + name + "' and type='karma'"
query = "update stats set counter="+ self.str(record[0][0]) +"+1 where nick='" + name + "' and type='karma'"
def handler(self, **args): import database from irclib import Event, nm_to_n # Set the target as either the person or the channel target = self.return_to_sender(args) orig_msg = args["text"] # Strip bot name orig_msg = orig_msg.split()[1:] # Now determine if we need to list karma or increment/decrement it, # which w...
query = "update stats set counter="+ str(record[0][0]) +"-1 where nick='" + name + "' and type='karma'"
query = "update stats set counter="+ self.str(record[0][0]) +"-1 where nick='" + name + "' and type='karma'"
def handler(self, **args): import database from irclib import Event, nm_to_n # Set the target as either the person or the channel target = self.return_to_sender(args) orig_msg = args["text"] # Strip bot name orig_msg = orig_msg.split()[1:] # Now determine if we need to list karma or increment/decrement it, # which w...
print "Shouldn't be here! -", args["text"]
self.debug("Shouldn't be here! -", args["text"])
def handler(self, **args): import database from irclib import Event, nm_to_n # Set the target as either the person or the channel target = self.return_to_sender(args) orig_msg = args["text"] # Strip bot name orig_msg = orig_msg.split()[1:] # Now determine if we need to list karma or increment/decrement it, # which w...
regex = re.compile(re.escape(pmask).replace("\\%", ".*"))
regex = re.compile(re.escape(pmask).replace("\\%", ".*"), re.I)
def checkPriv(hostmask, privilege): """checks if the user identified by hostmask has privilege privilege returns 0 if the nick/hostmask doesn't have that privilege returns 1 if they do""" global privCache if not privCache: privCache = {} import database, re privs = database.doSQL("SELECT priv_type,hostmask FROM grants...
else:
elif not data == "":
def handle_data(self, data): if not self.over: if self.is_result_table: if '\n' in data: data = data.strip() if len(self.list)+len(data) >= self.block: self.list += "\n%s(%s): " % (self.file, self.version) self.block += self.block_size self.hit += 1 if self.hit == self.__max_hit: self.over = True else: self.list += "=%...
try: dbconn = dbConPool.get() cur = dbconn.cursor() cur.execute(SQL) except Exception, message: DebugErr(moobot.RED + "Exception occurred: " + moobot.BLUE + \ str(message) + moobot.NORMAL + ", retrying ...") dbconn = dbConPool.get() cur = dbconn.cursor() cur.execute(SQL)
dbconn = dbConPool.get() dbconn.ping() cur = dbconn.cursor() cur.execute(SQL)
def doSQL(SQL): """ executes the sql statement SQL and returns a list of tuples containing the results""" results = [] SQL = SQL.encode(dbencoding, "backslashreplace")
import string, database, time
import string, time
def handler(self, **args): """ gets the factoid_value field from the database """ import string, database, time from irclib import Event, nm_to_n
ref = args["ref"]()
def handler(self, **args): """ gets the factoid_value field from the database """ import string, database, time from irclib import Event, nm_to_n
self.debug("%s!%s@%s" % (ref.connection.ircname, ref.connection.username, ref.connection.localhost))
def handler(self, **args): """ gets the factoid_value field from the database """ import string, database, time from irclib import Event, nm_to_n
import database, string
import string
def handler(self, **args): """ gets a random factoid from the database""" from irclib import nm_to_n, Event import database, string
import database, priv
import priv
def handler(self, **args): "Remove a factoid from the database" import database, priv from irclib import Event
import database
def __init__(self): self.priority = 20 self.regex = ".+ (is|are|_is_|_are_) .+" # --- Get the max factoid key length --- # I insert a 255-char long string of a's with "factoid-length-check" as # the created_by field. Since this created_by isn't a valid nickmask # on IRC, it can't be duplicated by anyone. However, if ...
import database, time
import time
def handler(self, **args): """adds a factoid""" import database, time from irclib import Event
import database
def handler(self, **args): """searches factoid keys""" import database from irclib import Event
import database, priv
import priv
def handler(self, **args): """ replaces an existing factoid (no factoid is text> """ import database, priv from irclib import Event from time import time
import database, priv, time
import priv, time
def handler(self, **args): """ lock and unlock factoids """ import database, priv, time from irclib import Event, nm_to_n
import database, time
import time
def handler(self, **args): """Return information about a factoid to the person requesting it""" import database, time from irclib import Event
import priv, database
import priv
def handler(self, **args): """Allows someone to add material onto a factoid (that isn't locked) by saying "foo is also bar", for example""" import priv, database from irclib import Event from time import time target = self.return_to_sender(args) # args["text"] should look something like: # "moobot: foo is also bar bl...
import priv, database, re, string, time
import priv, re, string, time
def handler(self, **args): """Allows someone to alter material in a factoid by using a regular expression. Invoked like: "moobot: foo =~ s/moo/bar/".""" import priv, database, re, string, time from irclib import Event target = self.return_to_sender(args) # Grab the factoid to change: # first, drop the bot name factoi...
self.regex="^d?whois .+"
self.regex="^(whois\s+.+|\d{1,3}(\.\d{1,3}){1,3})$" self.priority = 4
def __init__(self): self.regex="^d?whois .+"
myquery = myquery[2]
if myquery[1] == "whois": myquery = myquery[2] else: myquery = myquery[1]
def handler(self, **args): """TODO. only query from Asia Pacific Network Infomation Center, need fix""" import socket, string, re
if re.compile('\d{1,3}(\.\d{1,3}){0,3}').match(myquery):
if re.compile('\d{1,3}(\.\d{1,3}){1,3}').match(myquery):
def handler(self, **args): """TODO. only query from Asia Pacific Network Infomation Center, need fix""" import socket, string, re
while True:
old = None while old != data: old = data
def handler(self, **args): """TODO. only query from Asia Pacific Network Infomation Center, need fix""" import socket, string, re
os.system("gnome-terminal -x sudo ./serpint gpiotoserial ttyS44 1234")
os.system("gnome-terminal -x sudo ./serpint gpiotoserial ttyS44 1234 &")
def throw_error(errorno, debug, die=1): #report errors, errorno is the error of the list of errors to display in the report errors=["ERROR0_MODULE_NOT_GPIOFORMAT", "ERROR1_MODULE_NOT_FOUND", "ERROR2_NETWORK_RELAY_THREAD_B"\ , "ERROR3_NETWORK_RELAY_THREAD_A", "ERROR4_GPIO_ERROR", "ERROR5_CREATE_VSI", "ERROR6_CREATE_VSI_...
os.system("gnome-terminal -x sudo ./serpint serialtosock ttyS44 1235")
os.system("gnome-terminal -x sudo ./serpint serialtosock ttyS44 1235 &")
def throw_error(errorno, debug, die=1): #report errors, errorno is the error of the list of errors to display in the report errors=["ERROR0_MODULE_NOT_GPIOFORMAT", "ERROR1_MODULE_NOT_FOUND", "ERROR2_NETWORK_RELAY_THREAD_B"\ , "ERROR3_NETWORK_RELAY_THREAD_A", "ERROR4_GPIO_ERROR", "ERROR5_CREATE_VSI", "ERROR6_CREATE_VSI_...
throw_error(11, 'No arguments specified; Use "serpint.py help" for information', 0)
throw_error(11, "No arguments specified; Use 'serpint.py help' for information", 0)
def throw_error(errorno, debug, die=1): #report errors, errorno is the error of the list of errors to display in the report errors=["ERROR0_MODULE_NOT_GPIOFORMAT", "ERROR1_MODULE_NOT_FOUND", "ERROR2_NETWORK_RELAY_THREAD_B"\ , "ERROR3_NETWORK_RELAY_THREAD_A", "ERROR4_GPIO_ERROR", "ERROR5_CREATE_VSI", "ERROR6_CREATE_VSI_...
os.system("sudo rm -f /dev/"+ser_addr)
os.system("sleep 3 && sudo rm -f /dev/"+ser_addr+" &")
def remove_vsi(ser_addr, conn): #close a VSI try: print "Closing Socket..." conn.close() #close the socket connection print "Removing System Virtual Socket..." os.system("sudo rm -f /dev/"+ser_addr) #remove the virtual socket print "VSI Removed... Please Note That That Your System May Still Have Traces Of VSI Usage Unt...
def new_Playlist(self,**kwargs): return Playlist(self, **kwargs)
def new_Playlist(self,*args,**kwargs): return Playlist(self, *args,**kwargs)
def new_Playlist(self,**kwargs): return Playlist(self, **kwargs)
return gpod.sw_get_list_len(gpod.sw_get_playlists(self._itdb))
return gpod.sw_get_list_len(self._db._itdb.playlists)
def __len__(self): return gpod.sw_get_list_len(gpod.sw_get_playlists(self._itdb))
def __init__(self, parent_db, proxied_playlist=None, title="New Playlist", smart=False, pos=-1):
def __init__(self, parent_db, title="New Playlist", smart=False, pos=-1, proxied_playlist=None):
def __init__(self, parent_db, proxied_playlist=None, title="New Playlist", smart=False, pos=-1): self._db = parent_db if proxied_playlist: self._pl = proxied_playlist else: if smart: smart = 1 else: smart = 0 self._pl = gpod.itdb_playlist_new(title, smart) gpod.itdb_playlist_add(self._db._itdb, self._pl, pos)
rows = self.execute("SELECT proname, oid FROM pg_proc WHERE proname like 'lo%'")[0]['rows'] for r in rows: oid = int(r[1]) self.__lo_funcs[r[0]] = oid self.__lo_funcnames[oid] = r[0]
descr, rows, msgs = self._execute("SELECT proname, oid FROM pg_proc WHERE proname like 'lo%'") for proname, oid in rows: self.__lo_funcs[proname] = oid self.__lo_funcnames[oid] = proname
def __lo_init(self): # # Make up a dictionary mapping function names beginning with "lo" to function oids # (there may be some non-lobject functions in there, but that should be harmless) # rows = self.execute("SELECT proname, oid FROM pg_proc WHERE proname like 'lo%'")[0]['rows'] for r in rows: oid = int(r[1]) self.__...
self.__lo_funcnames = {}
def __init__(self): self.__backend_pid = None self.__backend_key = None self.__socket = None self.__input_buffer = '' self.__authenticated = 0 self.__ready = 0 self.__result = None self.__notify_queue = [] self.__func_result = None self.__lo_funcs = {}
self.__lo_funcs[r[0]] = int(r[1])
oid = int(r[1]) self.__lo_funcs[r[0]] = oid self.__lo_funcnames[oid] = r[0]
def __lo_init(self): # # Make up a dictionary mapping function names beginning with "lo" to function oids # (there may be some non-lobject functions in there, but that should be harmless) # rows = self.execute("SELECT proname, oid FROM pg_proc WHERE proname like 'lo%'")[0]['rows'] for r in rows: self.__lo_funcs[r[0]] =...
if DEBUG: print '>[%s]' % self.__input_buffer
def __read_response(self): # # Read a single response from the backend # Looks at the next byte, and calls a more specific # method the handle the rest of the response # # PostgreSQL responses begin with a single character <c>, this # method looks up a method named _pkt_<c> and calls that # to handle the response ...
field_bits = ord(self.__read_bytes(1)) extra_bytes = self.__field_count >> 3 field_mask = 128
null_bytes = (self.__field_count + 7) >> 3
def __read_row(self, ascii=1): # # Read an ASCII or Binary Row # result = [] field_bits = ord(self.__read_bytes(1)) # start off with one byte's worth of field bits extra_bytes = self.__field_count >> 3 # how many more we'll be getting field_mask = 128
if extra_bytes > 3: field_bits = long(field_bits)
if null_bytes > 4: field_bits = 0L
def __read_row(self, ascii=1): # # Read an ASCII or Binary Row # result = [] field_bits = ord(self.__read_bytes(1)) # start off with one byte's worth of field bits extra_bytes = self.__field_count >> 3 # how many more we'll be getting field_mask = 128
if extra_bytes: for ch in self.__read_bytes(extra_bytes):
else: field_bits = 0 field_mask = 128 if null_bytes: for ch in self.__read_bytes(null_bytes):
def __read_row(self, ascii=1): # # Read an ASCII or Binary Row # result = [] field_bits = ord(self.__read_bytes(1)) # start off with one byte's worth of field bits extra_bytes = self.__field_count >> 3 # how many more we'll be getting field_mask = 128
field_mask <<= 8
field_mask <<= (null_bytes - 1) * 8
def __read_row(self, ascii=1): # # Read an ASCII or Binary Row # result = [] field_bits = ord(self.__read_bytes(1)) # start off with one byte's worth of field bits extra_bytes = self.__field_count >> 3 # how many more we'll be getting field_mask = 128
if DEBUG: print 'Send [%s]' % data
def __send(self, data): # # Send data to the backend, make sure it's all sent # #print 'Send [%s]' % data while data: nSent = self.__socket.send(data) data = data[nSent:]
elif code == 5: import md5 m = md5.new(self.__passwd + self.__userid).hexdigest() m = md5.new(m + self.__read_bytes(4)).hexdigest() m = 'md5' + m + '\0' self.__send(pack('!i', len(m)+4) + m) else: raise PostgreSQL_Error('Unknown startup response code: R%d (unknown password encryption?)' % code)
def _pkt_R(self): # # Startup Response # code = unpack('!i', self.__read_bytes(4))[0] if code == 0: self.__authenticated = 1 #print 'Authenticated!' elif code == 1: raise PostgreSQL_Error('Kerberos V4 authentication is required') elif code == 2: raise PostgreSQL_Error('Kerberos V5 authentication is required') elif code...
self.__passwd = password self.__userid = user
self.__passwd = args['password'] self.__userid = args['user']
def connect(self, dsn=None, user='', password='', host=None, database='', port=5432, opt=''): """ Connect to a PostgreSQL server over TCP/IP
def execute(self, str, args=None, debug=0):
def execute(self, str, args=None, debug=DEBUG):
def execute(self, str, args=None, debug=0): if args != None: na = [] for a in args: if a == None: a = 'NULL' elif type(a) == types.StringType: a = "'" + a.replace('\\', '\\\\').replace("'", "\\'") + "'" na.append(a) str = str % tuple(na) if debug: print '>>', str self.__ready = 0 self.__result = [{}] self.__send('Q'+...
print '>>', str
print 'execute', str
def execute(self, str, args=None, debug=0): if args != None: na = [] for a in args: if a == None: a = 'NULL' elif type(a) == types.StringType: a = "'" + a.replace('\\', '\\\\').replace("'", "\\'") + "'" na.append(a) str = str % tuple(na) if debug: print '>>', str self.__ready = 0 self.__result = [{}] self.__send('Q'+...
return unpack('!i', r)[0]
return _unpack('!i', r)[0]
def tell(self): r = self.__client._lo_funcall('lo_tell', self.__fd) return unpack('!i', r)[0]
return unpack('!i', r)[0]
return _unpack('!i', r)[0]
def write(self, data): """ Write data to lobj, return number of bytes written """ r = self.__client._lo_funcall('lowrite', self.__fd, data) return unpack('!i', r)[0]
field_size = unpack('!i', self.__read_bytes(4))[0]
field_size = _unpack('!i', self.__read_bytes(4))[0]
def __read_row(self, ascii=1): # # Read an ASCII or Binary Row # result = self.__current_result
pid = unpack('!i', self.__read_bytes(4))[0]
pid = _unpack('!i', self.__read_bytes(4))[0]
def _pkt_A(self): # # Notification Response # pid = unpack('!i', self.__read_bytes(4))[0] self.__notify_queue.append((self.__read_string(), pid))