rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
s = L2ListenSocket(type=ETH_P_ALL, *arg, **karg) | s = conf.L2listen(type=ETH_P_ALL, *arg, **karg) | def sniff(count=0, prn = None, *arg, **karg): """Sniff packets |
timeout=5, filter="(icmp and icmp[0]=11) or (tcp and (tcp[13] & 0x16 > 0x10))") | timeout=2, filter="(icmp and icmp[0]=11) or (tcp and (tcp[13] & 0x16 > 0x10))") | def traceroute(target, maxttl=30, dport=80, sport=RandShort()): """Instant TCP traceroute |
def arping(net): global last ans, unans, x = sndrcv(PacketRawSocket(iface=iface), Ether(dst="ff:ff:ff:ff:ff:ff")/ARP(pdst=net)) | def arping(net, iface=None): ans, unans, x = sndrcv(conf.L2socket(iface=iface), Ether(dst="ff:ff:ff:ff:ff:ff")/ARP(pdst=net)) | def arping(net): global last ans, unans, x = sndrcv(PacketRawSocket(iface=iface), Ether(dst="ff:ff:ff:ff:ff:ff")/ARP(pdst=net)) for s,r in ans: print r.payload.psrc last = ans,unans,x |
ans, unans, x = sndrcv(InetPacketSocket(),IP(dst=net)/ICMP()) | ans, unans, x = sndrcv(conf.L3socket(),IP(dst=net)/ICMP()) | def icmping(net): global last ans, unans, x = sndrcv(InetPacketSocket(),IP(dst=net)/ICMP()) for s,r in ans: print r.src last = ans,unans,x |
ans, unans, x = sndrcv(InetPacketSocket(),IP(dst=net)/TCP(dport=port, flags=2)) | ans, unans, x = sndrcv(conf.L3socket(),IP(dst=net)/TCP(dport=port, flags=2)) | def tcping(net, port): global last ans, unans, x = sndrcv(InetPacketSocket(),IP(dst=net)/TCP(dport=port, flags=2)) for s,r in ans: if isinstance(r.payload,TCP): print r.src,r.payload.sport, r.payload.flags else: print r.src,"icmp",r.payload.type last = ans, unans, x |
ans, unans, x = sndrcv(InetPacketSocket(), | ans, unans, x = sndrcv(conf.L3socket(), | def tcptraceroute(net, port=80): global last ans, unans, x = sndrcv(InetPacketSocket(), IP(dst=net, id=RandShort(), ttl=(1,25))/TCP(seq=RandInt(), dport=port, flags=2)) ans.sort(lambda (s1,r1),(s2,r2): cmp(s1.ttl,s2.ttl)) for s,r in ans: if isinstance(r.payload, ICMP): print "%2i: %s" % (s.ttl,r.src) else: print "%2i: ... |
s=L3PacketSocket() | s=conf.L3socket() | def fragleak(target): load = "XXXXYYYYYYYYYY" |
if not internal and self.haslayer(Padding): p += self.getlayer(Padding).load | if not internal: pkt = self while pkt.haslayer(Padding): pkt = pkt.getlayer(Padding) p += pkt.load pkt = pkt.payload | def build(self,internal=0): p = self.post_build(self.do_build()) if not internal and self.haslayer(Padding): p += self.getlayer(Padding).load return p |
b &= (1L << (nb_bytes*8-bn+1)) - 1 | b &= (1L << (nb_bytes*8-bn)) - 1 | def getfield(self, pkt, s): if type(s) is tuple: s,bn = s else: bn = 0 # we don't want to process all the string nb_bytes = (self.size+bn-1)/8 + 1 w = s[:nb_bytes] |
log_loading.info("did not find gnuplot lib. Won't be able to plot") | log_loading.info("did not find python gnuplot wrapper . Won't be able to plot") | def filter(self, record): wt = conf.warning_threshold if wt > 0: stk = traceback.extract_stack(limit=1) caller = stk[0][1] tm,nb = self.warning_table.get(caller, (0,0)) ltm = time.time() if ltm-tm > wt: tm = ltm nb = 0 else: if nb < 2: nb += 1 if nb == 2: record.msg = "more "+record.msg else: return 0 self.warning_tabl... |
if conf.debug_dissector and isinstance(cls,Packet): | if conf.debug_dissector and issubclass(cls,Packet): | def do_dissect_payload(self, s): if s: cls = self.guess_payload_class(s) try: p = cls(s, _internal=1) except: if conf.debug_dissector and isinstance(cls,Packet): log_runtime.error("%s dissector failed" % cls.name) raise else: if conf.debug_dissector: log_runtime.warning("%s.guess_payload_class() returned [%s]" % (self.... |
return self.sprintf("SSID=%s"%self.info),[Dot11] | return "SSID=%s"%repr(self.info),[Dot11] | def mysummary(self): if self.ID == 0: return self.sprintf("SSID=%s"%self.info),[Dot11] else: return "" |
print "%s\nSent %i packets, received %i packets. %3.1f%% hits." % (Color.normal,n,r,100.0*r/n) | if n>0: print "%s\nSent %i packets, received %i packets. %3.1f%% hits." % (Color.normal,n,r,100.0*r/n) | def __sr_loop(srfunc, pkts, prn=lambda x:x[1].summary(), prnfail=lambda x:x.summary(), inter=1, timeout=0, count=None, verbose=0, *args, **kargs): n = 0 r = 0 parity = 0 if timeout == 0: timeout = min(2*inter, 5) try: while 1: parity ^= 1 col = [conf.color_theme.even,conf.color_theme.odd][parity] if count is not None:... |
if session.has_key("__builtins__"): del(session["__builtins__"]) for k in session.keys(): if type(session[k]) in [types.ClassType, types.ModuleType]: print "[%s] (%s) can't be saved. Deleted." % (k, type(session[k])) del(session[k]) | def usage(): print "Usage: scapy.py [-s sessionfile]" sys.exit(0) | |
elif self.payload != NoPayload(): | elif not isinstance(self.payload, NoPayload): | def add_payload(self, payload): if payload is None: return elif self.payload != NoPayload(): self.payload.add_payload(payload) else: if isinstance(payload, Packet): self.__dict__["payload"] = payload payload.add_underlayer(self) for t in self.aliastypes: if payload.overload_fields.has_key(t): self.overloaded_fields = p... |
if self.payload == NoPayload(): | if isinstance(self.payload,NoPayload): | def loop(todo, done, self=self): if todo: eltname = todo.pop() elt = self.__getattr__(eltname) if not isinstance(elt, Gen): elt = SetGen(elt) for e in elt: done[eltname]=e for x in loop(todo[:], done): yield x else: if self.payload == NoPayload(): payloads = [None] else: payloads = self.payload for payl in payloads: do... |
pass | name = "Padding" | def answers(self, other): s = str(other) t = self.load l = min(len(s), len(t)) return s[:l] == t[:l] |
if pkt == NoPayload(): | if isinstance(pkt,NoPayload): | def pkt2uptime(pkt, HZ=100): """Calculate the date the machine which emitted the packet booted using TCP timestamp |
for l in cmds.splitlines(): sys.stderr.write(str(sys.__dict__.get("ps1",ColorPrompt()))) | cmds = cmds.splitlines() cmds.append("") cmds.reverse() while 1: if cmd: sys.stderr.write(sys.__dict__.get("ps2","... ")) else: sys.stderr.write(str(sys.__dict__.get("ps1",ColorPrompt()))) l = cmds.pop() | def autorun_commands(cmds,verb=0): sv = conf.verb try: conf.verb = verb interp = ScapyAutorunInterpreter(globals()) cmd = "" for l in cmds.splitlines(): sys.stderr.write(str(sys.__dict__.get("ps1",ColorPrompt()))) print l cmd += "\n"+l if interp.runsource(cmd): sys.stderr.write(sys.__dict__.get("ps2","... ")) continue ... |
sys.stderr.write(sys.__dict__.get("ps2","... ")) | def autorun_commands(cmds,verb=0): sv = conf.verb try: conf.verb = verb interp = ScapyAutorunInterpreter(globals()) cmd = "" for l in cmds.splitlines(): sys.stderr.write(str(sys.__dict__.get("ps1",ColorPrompt()))) print l cmd += "\n"+l if interp.runsource(cmd): sys.stderr.write(sys.__dict__.get("ps2","... ")) continue ... | |
Field.__init__(self, name, default, "@H") | Field.__init__(self, name, default, "<H") | def __init__(self, name, default): Field.__init__(self, name, default, "@H") |
Field.__init__(self, name, default, "@I") | Field.__init__(self, name, default, "<I") | def __init__(self, name, default): Field.__init__(self, name, default, "@I") |
Field.__init__(self, name, default, "@i") | Field.__init__(self, name, default, "<i") | def __init__(self, name, default): Field.__init__(self, name, default, "@i") |
EnumField.__init__(self, name, default, enum, "@H") | EnumField.__init__(self, name, default, enum, "<H") | def __init__(self, name, default, enum): EnumField.__init__(self, name, default, enum, "@H") |
EnumField.__init__(self, name, default, enum, "@I") | EnumField.__init__(self, name, default, enum, "<I") | def __init__(self, name, default, enum): EnumField.__init__(self, name, default, enum, "@I") |
Field.__init__(self, name, default, "@Q") | Field.__init__(self, name, default, "<Q") | def __init__(self, name, default): Field.__init__(self, name, default, "@Q") |
def __init__(self, name, default, fld, fmt = "@H"): | def __init__(self, name, default, fld, fmt = "<H"): | def __init__(self, name, default, fld, fmt = "@H"): FieldLenField.__init__(self, name, default, fld=fld, fmt=fmt) |
5 : ("SAck","!II"), | 5 : ("SAck","!"), | def randval(self): return RandBin(RandNum(0,39)) |
if ofmt: | if onum == 5: ofmt += "%iI" % (len(oval)/4) if ofmt and struct.calcsize(ofmt) == len(oval): | def m2i(self, pkt, x): opt = [] while x: onum = ord(x[0]) if onum == 0: opt.append(("EOL",None)) x=x[1:] break if onum == 1: opt.append(("NOP",None)) x=x[1:] continue olen = ord(x[1]) if olen < 2: warning("Malformed TCP option (announced length is %i)" % olen) olen = 2 oval = x[2:olen] if TCPOptions[0].has_key(onum): o... |
self.fmt = "!"+fmt | if fmt[0] in "@=<>!": self.fmt = fmt else: self.fmt = "!"+fmt | def __init__(self, name, default, fmt="H"): self.name = name self.fmt = "!"+fmt self.default = self.any2i(None,default) self.sz = struct.calcsize(self.fmt) |
r = range(self.units - o.units, 0, -1) | r = range(self.units - o.units, -1, -1) | def __iadd__(self, o): if self.affinity == "bottom": r = range(0, self.units - o.units + 1) else: r = range(self.units - o.units, 0, -1) |
measure.setAttribute("style", "stroke: | measure.setAttribute("style", "fill:none;stroke:black;") | def visitRackElement(self, element, pos): """ @param element the element to render @param pos position in the rack of this element """ # e is our rack element e = self._image.createElement("g") title = self._image.createElement("title") title.appendChild(self._image.createTextNode("rack element")) e.appendChild(title) |
p1.setAttribute("d", "M -50 0 -30 0") | p1.setAttribute("d", "M -50 0 L -30 0") | def visitRackElement(self, element, pos): """ @param element the element to render @param pos position in the rack of this element """ # e is our rack element e = self._image.createElement("g") title = self._image.createElement("title") title.appendChild(self._image.createTextNode("rack element")) e.appendChild(title) |
p2.setAttribute("d", "M -50 %s -30 %s" % (self._unitsize * element._units, self._unitsize * element._units)) | p2.setAttribute("d", "M -50 %s L -30 %s" % (self._unitsize * element._units, self._unitsize * element._units)) | def visitRackElement(self, element, pos): """ @param element the element to render @param pos position in the rack of this element """ # e is our rack element e = self._image.createElement("g") title = self._image.createElement("title") title.appendChild(self._image.createTextNode("rack element")) e.appendChild(title) |
p3.setAttribute("d", "M -40 0 -40 %s" % (self._unitsize * element._units,)) | p3.setAttribute("d", "M -40 0 L -40 %s" % (self._unitsize * element._units,)) | def visitRackElement(self, element, pos): """ @param element the element to render @param pos position in the rack of this element """ # e is our rack element e = self._image.createElement("g") title = self._image.createElement("title") title.appendChild(self._image.createTextNode("rack element")) e.appendChild(title) |
label.setAttribute("x", "-45") | label.setAttribute("x", "-%s" % (44 + len("%s" % (element._units,)) * 23,)) | def visitRackElement(self, element, pos): """ @param element the element to render @param pos position in the rack of this element """ # e is our rack element e = self._image.createElement("g") title = self._image.createElement("title") title.appendChild(self._image.createTextNode("rack element")) e.appendChild(title) |
label.setAttribute("style", "fill:black;stroke:none;text-anchor:right;font-size:36pt;") | label.setAttribute("style", "fill:black;stroke:none;text-anchor:right;font-size:28pt;") | def visitRackElement(self, element, pos): """ @param element the element to render @param pos position in the rack of this element """ # e is our rack element e = self._image.createElement("g") title = self._image.createElement("title") title.appendChild(self._image.createTextNode("rack element")) e.appendChild(title) |
label.setAttribute("x", "%s" % (self._rackwidth + 35,)) | label.setAttribute("x", "%s" % (self._rackwidth + 25,)) | def visitRackElement(self, element, pos): """ @param element the element to render @param pos position in the rack of this element """ # e is our rack element e = self._image.createElement("g") title = self._image.createElement("title") title.appendChild(self._image.createTextNode("rack element")) e.appendChild(title) |
label.setAttribute("x", "%s" % (self._rackwidth + 35,)) | label.setAttribute("x", "%s" % (self._rackwidth + 25,)) | def visitEmptyRackElement(self, pos): |
label.setAttribute("style", "text-anchor:left;font-size:30pt;") | label.setAttribute("style", "text-anchor:left;font-size:26pt;") | def visitRackmount(self, element): """ @param element the rackmount element """ |
label.setAttribute("style", "text-anchor:left;font-size:30pt;") | label.setAttribute("style", "text-anchor:left;font-size:26pt;") | def visitPatchPanel(self, panel): """ @param panel the patchpanel element """ |
d = "M %s %s %s %s %s %s A %s %s %s %s %s %s %s L %s %s A %s %s %s %s %s %s %s L %s %s %s %s %s %s %s %s %s %s A %s %s %s %s %s %s %s L %s %s A %s %s %s %s %s %s %s L %s %s %s %s %s %s" % ( | d = "M %s %s L %s %s %s %s A %s %s %s %s %s %s %s L %s %s A %s %s %s %s %s %s %s L %s %s %s %s %s %s %s %s %s %s A %s %s %s %s %s %s %s L %s %s A %s %s %s %s %s %s %s L %s %s %s %s %s %s" % ( | def visitShelf(self, shelf): # e is our shelf e = self._image.createElement("g") title = self._image.createElement("title") title.appendChild(self._image.createTextNode("Shelf 1U")) e.appendChild(title) |
- bw + 5, self._unitsize - bh, | - bw + rad, self._unitsize - bh, | def visitShelf(self, shelf): # e is our shelf e = self._image.createElement("g") title = self._image.createElement("title") title.appendChild(self._image.createTextNode("Shelf 1U")) e.appendChild(title) |
5, 5, | rad, rad, | def visitShelf(self, shelf): # e is our shelf e = self._image.createElement("g") title = self._image.createElement("title") title.appendChild(self._image.createTextNode("Shelf 1U")) e.appendChild(title) |
- bw, self._unitsize - bh + 5, | - bw, self._unitsize - bh + rad, | def visitShelf(self, shelf): # e is our shelf e = self._image.createElement("g") title = self._image.createElement("title") title.appendChild(self._image.createTextNode("Shelf 1U")) e.appendChild(title) |
- bw, self._unitsize - 5, | - bw, self._unitsize - rad, | def visitShelf(self, shelf): # e is our shelf e = self._image.createElement("g") title = self._image.createElement("title") title.appendChild(self._image.createTextNode("Shelf 1U")) e.appendChild(title) |
- bw + 5, self._unitsize, | - bw + rad, self._unitsize, | def visitShelf(self, shelf): # e is our shelf e = self._image.createElement("g") title = self._image.createElement("title") title.appendChild(self._image.createTextNode("Shelf 1U")) e.appendChild(title) |
self._rackwidth + bw - 5, self._unitsize, | self._rackwidth + bw - rad, self._unitsize, | def visitShelf(self, shelf): # e is our shelf e = self._image.createElement("g") title = self._image.createElement("title") title.appendChild(self._image.createTextNode("Shelf 1U")) e.appendChild(title) |
self._rackwidth + bw, self._unitsize - 5, | self._rackwidth + bw, self._unitsize - rad, | def visitShelf(self, shelf): # e is our shelf e = self._image.createElement("g") title = self._image.createElement("title") title.appendChild(self._image.createTextNode("Shelf 1U")) e.appendChild(title) |
self._rackwidth + bw, self._unitsize - bh + 5, | self._rackwidth + bw, self._unitsize - bh + rad, | def visitShelf(self, shelf): # e is our shelf e = self._image.createElement("g") title = self._image.createElement("title") title.appendChild(self._image.createTextNode("Shelf 1U")) e.appendChild(title) |
self._rackwidth + bw - 5, self._unitsize - bh, | self._rackwidth + bw - rad, self._unitsize - bh, | def visitShelf(self, shelf): # e is our shelf e = self._image.createElement("g") title = self._image.createElement("title") title.appendChild(self._image.createTextNode("Shelf 1U")) e.appendChild(title) |
label.setAttribute("style", "fill:black;stroke:none;text-anchor:left;font-size:30pt;") | label.setAttribute("style", "fill:black;stroke:none;text-anchor:left;font-size:26pt;") | def visitShelfElement(self, element): """ @param element the element to render """ # e is our shelf element e = self._image.createElement("g") title = self._image.createElement("title") title.appendChild(self._image.createTextNode("shelf element")) e.appendChild(title) |
label = "%s (%s)" % (element.name, element.label) | label = element.label | def visitRackmount(self, element): """ @param element the rackmount element """ |
pass | self.visitRackmount(panel) | def visitPatchPanel(self, panel): """ @param panel the patchpanel element """ pass |
win32gui.MessageBox(self.hwnd, 'Unable to cerate freshclam configuration file. Please check there is enough space on the disk', 'Error', win32con.MB_OK | win32con.MB_ICONSTOP) | win32gui.MessageBox(self.hwnd, 'Unable to create freshclam configuration file. Please check there is enough space on the disk', 'Error', win32con.MB_OK | win32con.MB_ICONSTOP) | def _UpdateDB(self, hide): if not hide: try: params = (' --mode=update', ' --config_file="%s"' % self._config.GetFilename()) Utils.SpawnPyOrExe(os.path.join(Utils.GetCurrentDir(True), 'ClamWin'), *params) except Exception, e: win32gui.MessageBox(self.hwnd, 'An error occured while starting ClamWin Update.\n' + str(e), '... |
self.textCtrlAdditionalParams.SetToolTipString('Specify any additional paramters for clamscan.exe') | self.textCtrlAdditionalParams.SetToolTipString('Specify any additional parameters for clamscan.exe') | def _init_ctrls(self, prnt): # generated method, don't edit wxDialog.__init__(self, id=wxID_WXPREFERENCESDLG, name='', parent=prnt, pos=wxPoint(1011, 469), size=wxSize(419, 351), style=wxDEFAULT_DIALOG_STYLE, title='ClamWin Preferences') self._init_utils() self.SetClientSize(wxSize(411, 324)) self.SetAutoLayout(False) ... |
MsgBox.ErrorBox(parent, 'Unable to cerate freshclam configutration file. Please check there is enough space on the disk') | MsgBox.ErrorBox(parent, 'Unable to create freshclam configutration file. Please check there is enough space on the disk') | def wxUpdateVirDB(parent, config, autoClose = False): exit_code = -1 freshclam_conf = Utils.SaveFreshClamConf(config) if not len(freshclam_conf): MsgBox.ErrorBox(parent, 'Unable to cerate freshclam configutration file. Please check there is enough space on the disk') return updatelog = tempfile.mktemp() dbdir = config.... |
self.checkBoxUpdateLogon.SetToolTipString('Select if you wish to update the virus databses just after you logged on') | self.checkBoxUpdateLogon.SetToolTipString('Select if you wish to update the virus databases just after you logged on') | def _init_ctrls(self, prnt): # generated method, don't edit wxDialog.__init__(self, id=wxID_WXPREFERENCESDLG, name='', parent=prnt, pos=wxPoint(523, 290), size=wxSize(419, 351), style=wxDEFAULT_DIALOG_STYLE, title='ClamWin Preferences') self._init_utils() self.SetClientSize(wxSize(411, 324)) self.SetAutoLayout(False) s... |
parent.Append(helpString='Checks for the Latest Vesrion', | parent.Append(helpString='Checks for the Latest Version', | def _init_coll_Help_Items(self, parent): # generated method, don't edit |
self.assertTrue(filePath, children[0].get_path() or filePath == children[1].get_path()) self.assertEquals(folderPath, children[0].get_path() or folderPath == children[1].get_path()) | self.assertTrue(filePath == children[0].get_path() or filePath == children[1].get_path()) self.assertTrue(folderPath == children[0].get_path() or folderPath == children[1].get_path()) | def test_nonempty_get_children2(self): file_name = 'nestedfile.txt' folder_name = 'nestedfolder.txt' filePath = self.projectMaker.get_sample_folder_name() + '/' + file_name folderPath = self.projectMaker.get_sample_folder_name() + '/' + folder_name parent = self.project.get_resource(self.projectMaker.get_sample_folder_... |
function_object = _AttributeListFinder.\ | function_pyname = _AttributeListFinder.\ | def visitAssign(self, node): type_ = None if isinstance(node.expr, compiler.ast.CallFunc): function_name = _AttributeListFinder.get_attribute_list(node.expr.node) function_object = self._search_in_dictionary_for_attribute_list(self.scope_visitor.names, function_name) if function_object is None and self.scope_visitor.ow... |
parent.get_scope()).get_object() | parent.get_scope()) if function_pyname is not None: function_object = function_pyname.get_object() | def visitAssign(self, node): type_ = None if isinstance(node.expr, compiler.ast.CallFunc): function_name = _AttributeListFinder.get_attribute_list(node.expr.node) function_object = self._search_in_dictionary_for_attribute_list(self.scope_visitor.names, function_name) if function_object is None and self.scope_visitor.ow... |
actions.append(SimpleAction('Find File', find_file, 'C-x C-p', | actions.append(SimpleAction('Find File', find_file, 'C-x C-f', | def exit_rope(context): context.get_core()._close_project_and_exit() |
context.get_core().save_adtive_editor() | context.get_core().save_active_editor() | def save_editor(context): context.get_core().save_adtive_editor() |
if friend != None: | if friend != None and group != None: | def __process_add(self, command): list_ = command.args[0] ver = int(command.args[1]) passport_id = command.args[2] display_name = url_codec.decode(command.args[3]) group = None if list_ == Lists.FORWARD: group = self.friend_list.groups[int(command.args[4])] |
sys.stderr.write("JABBER: Couldn't connect to %s: %s\n" % (server,e)) | sys.stderr.write("JABBER: Couldn't connect to %s: network error\n" % server) | def __init__(self): # Read username, password, server, resource and nickname from # config file. If they're not found, prompt the user for # them. config = howie.configFile.get() try: username = config['jabber.username'] if username == "": raise KeyError except KeyError: username = raw_input("Jabber Username: ") try: ... |
if issubclass(eval("frontends.%s.%s" % (fe, cls)), frontend.IFrontEnd): | if issubclass(eval("frontends.%s.%s" % (fe, cls)), frontends.frontend.IFrontEnd): | def init(): "Initialize the front-ends and back-ends." # Fetch the configuration info config = configFile.get() # Initialize the backends jalice.bootstrap() # Handle local mode: only start the tty frontend if config['cla.localMode'] == "yes": __addFrontEnd("tty", "FrontEndTTY") else: # Initialize the front-ends. Pyt... |
if res.status != 200: | if res.status / 100 == 3: dalogin[0] = res.getheader('Location').split('/', 3)[2] elif res.status != 200: | def __get_twn_ticket(self, twn_string, username, password): from net import HTTPSConnection from urllib import urlencode debuglevel = 0 |
return "%s %s %s" % (result.group('query'), result.group('verb'), | return "%s %s %s" % (result.group('query'), string.lower(result.group('verb')), | def respondTo(self, input): """ If input matches the form of a legal Googlism query (e.g. "Who is X?"), returns a random answer from the Googlism server. None is returned if an error occurs. """ |
return None | return "I don't know %s you're talking about." % string.lower(result.group('qtype')) | def respondTo(self, input): """ If input matches the form of a legal Googlism query (e.g. "Who is X?"), returns a random answer from the Googlism server. None is returned if an error occurs. """ |
def __WriteINI(file, config=configDefaults): """ Writes the config dictionary to a .INI file. """ if len(config) == 0: return iniFile = open(file, "w") currentSection = "" keys = config.keys() keys.sort() for key in keys: value = config[key] if value == "": continue | def _WriteINI(file, config=configDefaults): """ Writes the config dictionary to a .INI file. """ if len(config) == 0: return iniFile = open(file, "w") currentSection = "" keys = config.keys() keys.sort() for key in keys: value = config[key] if value == "": continue | def __WriteINI(file, config=configDefaults): """ Writes the config dictionary to a .INI file. """ if len(config) == 0: return iniFile = open(file, "w") currentSection = "" keys = config.keys() keys.sort() for key in keys: # Don't write entries with no value value = config[key] if value == "": continue # Split the key ... |
def __ReadINI(file, config={}): """ Returns a dictionary with keys of the form <section>.<option> and the corresponding values. """ config = config.copy() cp = ConfigParser.ConfigParser() cp.read(file) for sec in cp.sections(): name = string.lower(sec) for opt in cp.options(sec): config[name + "." + string.lower(opt)] ... | def _ReadINI(file, config={}): """ Returns a dictionary with keys of the form <section>.<option> and the corresponding values. """ config = config.copy() cp = ConfigParser.ConfigParser() cp.read(file) for sec in cp.sections(): name = sec.lower() for opt in cp.options(sec): config[name + "." + opt.lower()] = string.stri... | def __ReadINI(file, config={}): """ Returns a dictionary with keys of the form <section>.<option> and the corresponding values. """ config = config.copy() cp = ConfigParser.ConfigParser() cp.read(file) for sec in cp.sections(): name = string.lower(sec) for opt in cp.options(sec): config[name + "." + string.lower(opt)] ... |
__config = {} | _config = None | def __ReadINI(file, config={}): """ Returns a dictionary with keys of the form <section>.<option> and the corresponding values. """ config = config.copy() cp = ConfigParser.ConfigParser() cp.read(file) for sec in cp.sections(): name = string.lower(sec) for opt in cp.options(sec): config[name + "." + string.lower(opt)] ... |
global __config, configDefaults | global _config, configDefaults | def load(file): """ Returns a dictionary containing the current configuration information, read from the specified .INI file. """ global __config, configDefaults try: if not os.path.exists(file): __WriteINI(file) __config = __ReadINI(file, configDefaults) except: print "ERROR: could not load config file %s" % file sys.... |
__WriteINI(file) __config = __ReadINI(file, configDefaults) | _WriteINI(file) _config = _ReadINI(file, configDefaults) | def load(file): """ Returns a dictionary containing the current configuration information, read from the specified .INI file. """ global __config, configDefaults try: if not os.path.exists(file): __WriteINI(file) __config = __ReadINI(file, configDefaults) except: print "ERROR: could not load config file %s" % file sys.... |
return __config | return _config | def load(file): """ Returns a dictionary containing the current configuration information, read from the specified .INI file. """ global __config, configDefaults try: if not os.path.exists(file): __WriteINI(file) __config = __ReadINI(file, configDefaults) except: print "ERROR: could not load config file %s" % file sys.... |
self._session.add_friend(msnp.Lists.ALLOW, passport_id, display_name) | self._session.add_friend(msnp.Lists.ALLOW, passport_id) self._session.add_friend(msnp.Lists.FORWARD, passport_id) print "%s is now our friend!" % passport_id | def friend_added(self, list_, passport_id, display_name, group_id = -1): if list_ == msnp.Lists.REVERSE: # somebody's made us a friend. Add them to our list as well. print "%s (%s) wants us to be his friend!" % (passport_id, display_name) self._session.add_friend(msnp.Lists.ALLOW, passport_id, display_name) |
friends.extend(self._session.friend_list.get_friends(msnp.Lists.ALLOW)) | def friend_list_updated(self, friend_list): friends = [] #friends.extend(self._session.friend_list.get_friends(msnp.Lists.ALLOW)) #friends.extend(self._session.friend_list.get_friends(msnp.Lists.BLOCK)) friends.extend(self._session.friend_list.get_friends(msnp.Lists.FORWARD)) #friends.extend(self._session.friend_list.g... | |
self.__inst = inst self.__thread = thread | self._inst = inst self._thread = thread | def __init__(self, inst, thread): self.__inst = inst self.__thread = thread |
__frontends = {} __kernel = None def __addFrontEnd(name, cls): global __frontends | _frontends = {} _kernel = None def _addFrontEnd(name, cls): global _frontends | def __init__(self, inst, thread): self.__inst = inst self.__thread = thread |
__frontends[name] = ActiveFrontEnd(feInst, feThread) | _frontends[name] = ActiveFrontEnd(feInst, feThread) | def __addFrontEnd(name, cls): global __frontends # verbose output config = configFile.get() if config['cla.verboseMode'] == "yes": print "Creating %s front-end using class %s" % (name, cls) # Instantiate the frontend object feInst = eval("%s.%s()" % (name, cls)) # Create a thread to run this frontend feThread = thre... |
global __kernel | global _kernel | def init(): global __kernel "Initialize the front-ends and back-ends." # Fetch the configuration info config = configFile.get() # Initialize the AIML interpreter __kernel = aiml.Kernel() __kernel.bootstrap(learnFiles="std-startup.xml", commands="bootstrap") # Handle local mode: only start the tty frontend if config['... |
__kernel = aiml.Kernel() __kernel.bootstrap(learnFiles="std-startup.xml", commands="bootstrap") | _kernel = aiml.Kernel() _kernel.verbose(config["general.verbose"] == "yes") _kernel.bootstrap(learnFiles="std-startup.xml", commands="bootstrap") _kernel.setBotName(config["general.botname"]) | def init(): global __kernel "Initialize the front-ends and back-ends." # Fetch the configuration info config = configFile.get() # Initialize the AIML interpreter __kernel = aiml.Kernel() __kernel.bootstrap(learnFiles="std-startup.xml", commands="bootstrap") # Handle local mode: only start the tty frontend if config['... |
__addFrontEnd("tty", "FrontEndTTY") | _addFrontEnd("tty", "FrontEndTTY") | def init(): global __kernel "Initialize the front-ends and back-ends." # Fetch the configuration info config = configFile.get() # Initialize the AIML interpreter __kernel = aiml.Kernel() __kernel.bootstrap(learnFiles="std-startup.xml", commands="bootstrap") # Handle local mode: only start the tty frontend if config['... |
__addFrontEnd(fe, cls) | _addFrontEnd(fe, cls) | def init(): global __kernel "Initialize the front-ends and back-ends." # Fetch the configuration info config = configFile.get() # Initialize the AIML interpreter __kernel = aiml.Kernel() __kernel.bootstrap(learnFiles="std-startup.xml", commands="bootstrap") # Handle local mode: only start the tty frontend if config['... |
def __updateConfig(self): | def _updateConfig(self): | def __updateConfig(self): "Saves our current configuration (buddy list, etc.) back to the server." # Create a TOC-style CONFIG string newConfig = "m 1\ng Buddies\n" for buddy in self._buddyList: newConfig += "b " + buddy + "\n" self.do_SET_CONFIG(newConfig) |
def __addBuddy(self, newBuddy): | def _addBuddy(self, newBuddy): | def __addBuddy(self, newBuddy): "Add a new buddy, both locally and remotely." if self._buddyList.count(newBuddy) > 0: # Buddy already in list. return self.do_ADD_BUDDY(list(newBuddy)) self.__buddyList.append(newBuddy) self.__updateConfig() |
self.__buddyList.append(newBuddy) self.__updateConfig() | self._buddyList.append(newBuddy) self._updateConfig() | def __addBuddy(self, newBuddy): "Add a new buddy, both locally and remotely." if self._buddyList.count(newBuddy) > 0: # Buddy already in list. return self.do_ADD_BUDDY(list(newBuddy)) self.__buddyList.append(newBuddy) self.__updateConfig() |
def __removeBuddy(self, oldBuddy): | def _removeBuddy(self, oldBuddy): | def __removeBuddy(self, oldBuddy): "Remove an existing buddy from the buddy list." if self._buddyList.count(oldBuddy) == 0: # No such buddy. return self.do_REMOVE_BUDDY(list(oldBuddy)) self.__buddyList.remove(oldBuddy) self.__updateConfig() |
self.__buddyList.remove(oldBuddy) self.__updateConfig() | self._buddyList.remove(oldBuddy) self._updateConfig() | def __removeBuddy(self, oldBuddy): "Remove an existing buddy from the buddy list." if self._buddyList.count(oldBuddy) == 0: # No such buddy. return self.do_REMOVE_BUDDY(list(oldBuddy)) self.__buddyList.remove(oldBuddy) self.__updateConfig() |
time.sleep( random.random() * 4 ) self.display(self.submit(message, screenname), screenname) | time.sleep( random.random() * self._maxdelay ) response = self.submit(message, screenname+"@AIM") self.display(response, screenname) | def on_IM_IN(self, data): # we must use the optional maxsplit argument of 2 in case the # message contains a colon! data_components = data.split(":",2) |
self.__buddyList = [] | self._buddyList = [] | def on_CONFIG(self, data): # first time logging in--add buddies from config... self.__buddyList = [] budsToAdd = [] # remember the format of config data here: # "m 1\ng Buddies\nb bouncebot\nb perlaim\n" for item in data.split("\n"): if item == '': continue if item[0] == "b": budsToAdd.append(item[1:].strip()) #add ... |
self.__buddyList.extend(budsToAdd) | self._buddyList.extend(budsToAdd) | def on_CONFIG(self, data): # first time logging in--add buddies from config... self.__buddyList = [] budsToAdd = [] # remember the format of config data here: # "m 1\ng Buddies\nb bouncebot\nb perlaim\n" for item in data.split("\n"): if item == '': continue if item[0] == "b": budsToAdd.append(item[1:].strip()) #add ... |
def debug(msg): pass def compare(i1, i2): comp = Comparison() | DEBUG = 0 class Unspec: pass def compare(i1, i2, debug=Unspec): if debug is Unspec: debug = DEBUG if debug: comp = DebugComparison() else: comp = Comparison() | def debug(msg): pass |
debug("descend(%s, %s)" % (i1, i2)) | def descend(self, i1, i2): debug("descend(%s, %s)" % (i1, i2)) | |
self.debug("descend(%s, %s)" % (i1, i2)) | i2_str = str(i2) if isinstance(i2, Comparator): i2_str = i2.render_debug() self.debug("descend(%s, %s)" % (i1, i2_str)) | def descend(self, i1, i2): self.debug("descend(%s, %s)" % (i1, i2)) self.depth += 1 res = super(DebugComparison, self).descend(i1, i2) self.depth -= 1 self.debug(res) return res |
def render_debug(self): return str(self) | def render_debug(self): return str(self) | |
i2_str = str(i2) if isinstance(i2, Comparator): i2_str = i2.render_debug() self.debug("descend(%s, %s)" % (i1, i2_str)) | self.debug("descend(%s, %s)" % (i1, i2)) | def descend(self, i1, i2): i2_str = str(i2) if isinstance(i2, Comparator): i2_str = i2.render_debug() self.debug("descend(%s, %s)" % (i1, i2_str)) self.depth += 1 res = super(DebugComparison, self).descend(i1, i2) self.depth -= 1 self.debug(res) return res |
def render_debug(self): | def __repr__(self): | def render_debug(self): return "%s(%s)" % (self.__class__.__name__, self.value) |
def render_debug(self): | def __repr__(self): | def render_debug(self): return "%s([%s] == %s)" % (self.__class__.__name__, self.index, self.value) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.