rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
print "Can not substitute %s with %s" % ('@'+k+'@', env[k]) | pass | def env_subst(target, source, env): ''' subst variables in source by those in env, and output to target source and target are scons File() objects %key% (not key itself) is an indication of substitution ''' assert len(target) == 1 assert len(source) == 1 target_file = file(str(target[0]), "w") source_file = file(str(s... |
if c in printable_chars_in_codepage: | if ord(c)>0: | def quote_char(c): if c in printable_chars_in_codepage: return c elif ' ' <= c <= '~': return c else: return repr(c)[1:-1] |
elif ' ' <= c <= '~': return c else: return repr(c)[1:-1] | class ReadlineError(exceptions.Exception): pass | def quote_char(c): if c in printable_chars_in_codepage: return c elif ' ' <= c <= '~': return c else: return repr(c)[1:-1] |
self.bell_style = 'none' | self.bell_style = 'audible' | def __init__(self): self.startup_hook = None self.pre_input_hook = None self.completer = None self.completer_delims = " \t\n\"\\'`@$><=;|&{(" self.history_length = -1 self.history = [] # strings for previous commands self.history_cursor = 0 self.undo_stack = [] # each entry is a tuple with cursor_position and line_text... |
c.bell() | if event.keyinfo[0]!=True: self.self_insert(event) | def readline(self, prompt=''): '''Try to act like GNU readline.''' |
c.bell() | self._bell() | def _i_search(self, direction, init_event): c = self.console line = self._line_text() query = '' hc_start = self.history_cursor + direction hc = hc_start while 1: x, y = self.prompt_end_pos c.pos(0, y) if direction < 0: prompt = 'reverse-i-search' else: prompt = 'forward-i-search' |
c.bell() | self._bell() | def _non_i_search(self, direction): c = self.console line = self._line_text() query = '' while 1: c.pos(*self.prompt_end_pos) scroll = c.write_scrolling(":%s" % query) self._update_prompt_pos(scroll) self._clear_after() |
c.bell() | self._bell() | def _search(self, direction): c = self.console |
pass | self.line_buffer=self.line_buffer[:0] self.line_cursor=0 | def kill_whole_line(self, e): # () '''Kill all characters on the current line, no matter where point is. By default, this is unbound.''' pass |
print "return none", len(response) | def socks4AParseResponse(response): RESPONSE_LEN = 8 if len(response) < RESPONSE_LEN: print "return none", len(response) return None assert len(response) >= RESPONSE_LEN version,status,port = struct.unpack("!BBH",response[:4]) assert version == 0 assert port == 0 if status == 90: return "%d.%d.%d.%d"%tuple(map(ord, res... | |
reqheader = struct.pack("!BBBB",version, command, rsv, atype) | reqheader = struct.pack("!BBBBB",version, command, rsv, atype, len(hostname)) | def socks5ResolveRequest(hostname): version = 5 command = 0xF0 rsv = 0 port = 0 atype = 0x03 reqheader = struct.pack("!BBBB",version, command, rsv, atype) portstr = struct.pack("!H",port) return "%s%s\0%s"%(reqheader,hostname,port) |
return "%s%s\0%s"%(reqheader,hostname,port) | return "%s%s%s"%(reqheader,hostname,portstr) | def socks5ResolveRequest(hostname): version = 5 command = 0xF0 rsv = 0 port = 0 atype = 0x03 reqheader = struct.pack("!BBBB",version, command, rsv, atype) portstr = struct.pack("!H",port) return "%s%s\0%s"%(reqheader,hostname,port) |
return "ERROR" | return "ERROR",reply | def socks5ParseResponse(r): if len(r)<8: return None version, reply, rsv, atype = struct.unpack("!BBBB",r[:4]) assert version==5 assert rsv==0 if reply != 0x00: return "ERROR" assert atype in (0x01,0x04) expected_len = 4 + ({1:4,4:16}[atype]) + 2 if len(r) < expected_len: return None elif len(r) > expected_len: raise V... |
socksParseHello(s.recv(2)) | socks5ParseHello(s.recv(2)) print len(fmt(hostname)), len(hostname) | def resolve(hostname, sockshost, socksport, socksver=4): assert socksver in (4,5) if socksver == 4: fmt = socks4AResolveRequest parse = socks4AParseResponse else: fmt = socks5ResolveRequest parse = socks5ParseResponse s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((sockshost,socksport)) if socksver == ... |
answer = s.recv(8) | answer = s.recv(6) | def resolve(hostname, sockshost, socksport, socksver=4): assert socksver in (4,5) if socksver == 4: fmt = socks4AResolveRequest parse = socks4AParseResponse else: fmt = socks5ResolveRequest parse = socks5ParseResponse s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((sockshost,socksport)) if socksver == ... |
print "Connection closed; dying." | def resolve(hostname, sockshost, socksport, socksver=4): assert socksver in (4,5) if socksver == 4: fmt = socks4AResolveRequest parse = socks4AParseResponse else: fmt = socks5ResolveRequest parse = socks5ParseResponse s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((sockshost,socksport)) if socksver == ... | |
print "Got extra data too! Ick." | print "Got extra data too: %r"%m | def resolve(hostname, sockshost, socksport, socksver=4): assert socksver in (4,5) if socksver == 4: fmt = socks4AResolveRequest parse = socks4AParseResponse else: fmt = socks5ResolveRequest parse = socks5ParseResponse s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((sockshost,socksport)) if socksver == ... |
resolve(sys.argv[1], sh, sp) | resolve(sys.argv[1], sh, sp, socksver) | def resolve(hostname, sockshost, socksport, socksver=4): assert socksver in (4,5) if socksver == 4: fmt = socks4AResolveRequest parse = socks4AParseResponse else: fmt = socks5ResolveRequest parse = socks5ParseResponse s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((sockshost,socksport)) if socksver == ... |
class _Enum2: def __init__(self, **args): self.__dict__.update(args) | def __init__(self, start, names): self.nameOf = {} idx = start for name in names: setattr(self,name,idx) self.nameOf[idx] = name idx += 1 | |
assert MSG_TYPE.SAVECONF = 0x0008 assert MSG_TYPE.CLOSECIRCUIT = 0x0014 EVENT_TYPE = _ENUM(0x0001, | assert MSG_TYPE.SAVECONF == 0x0008 assert MSG_TYPE.CLOSECIRCUIT == 0x0014 EVENT_TYPE = _Enum(0x0001, | def __init__(self, start, names): self.nameOf = {} idx = start for name in names: setattr(self,name,idx) self.nameOf[idx] = name idx += 1 |
minPackets,minSlop = divmod(realLength+6,65535) minLength = (minPackets*(65535+4))+4+minSlop | minLength = _minLengthToPack(realLength+6) | def unpack_msg(msg): "returns as for _unpack_msg" tp,body,rest = _unpack_msg(msg) if tp != MSG_TYPE.FRAGMENTHEADER: return tp, body, rest if len(body) < 6: raise ProtocolError("FRAGMENTHEADER message too short") realType,realLength = struct.unpack("!HL", body[:6]) # Okay; could the message _possibly_ be here? minPac... |
while rest and lenSoFar < realLength: ln, tp = struct.unpack("!HH" rest[:4]) | while len(rest)>=4 and lenSoFar < realLength: ln, tp = struct.unpack("!HH", rest[:4]) | def unpack_msg(msg): "returns as for _unpack_msg" tp,body,rest = _unpack_msg(msg) if tp != MSG_TYPE.FRAGMENTHEADER: return tp, body, rest if len(body) < 6: raise ProtocolError("FRAGMENTHEADER message too short") realType,realLength = struct.unpack("!HL", body[:6]) # Okay; could the message _possibly_ be here? minPac... |
rest = rest[4+ln:] | if 4+ln > len(rest): rest = "" leftInPacket = 4+ln-len(rest) else: rest = rest[4+ln:] leftInPacket=0 | def unpack_msg(msg): "returns as for _unpack_msg" tp,body,rest = _unpack_msg(msg) if tp != MSG_TYPE.FRAGMENTHEADER: return tp, body, rest if len(body) < 6: raise ProtocolError("FRAGMENTHEADER message too short") realType,realLength = struct.unpack("!HL", body[:6]) # Okay; could the message _possibly_ be here? minPac... |
return None, len(msg)+(realLength-lenSoFar), msg | inOtherPackets = realLength-lenSoFar-leftInPacket minLength = _minLengthToPack(inOtherPackets) return None, len(msg)+leftInPacket+inOtherPackets, msg | def unpack_msg(msg): "returns as for _unpack_msg" tp,body,rest = _unpack_msg(msg) if tp != MSG_TYPE.FRAGMENTHEADER: return tp, body, rest if len(body) < 6: raise ProtocolError("FRAGMENTHEADER message too short") realType,realLength = struct.unpack("!HL", body[:6]) # Okay; could the message _possibly_ be here? minPac... |
return body | if len(body) != 4: raise ProtocolError("Extendcircuit reply too short or long") return struct.unpack("!L",body) def redirect_stream(s, streamid, newtarget): msg = struct.pack("!L",streamid) + newtarget + "\0" tp,body = receive_reply(s,[MSG_TYPE.DONE]) def _unterminate(s): if s[-1] == '\0': return s[:-1] else: return ... | def extend_circuit(s, circid, hops): msg = struct.pack("!L",circid) + ",".join(hops) + "\0" send_message(s,MSG_TYPE.EXTENDCIRCUIT,msg) tp, body = receive_reply(s,[MSG_TYPE.DONE]) return body |
return struct.unpack("!L",body) | return struct.unpack("!L",body)[0] | def extend_circuit(s, circid, hops): msg = struct.pack("!L",circid) + ",".join(hops) + "\0" send_message(s,MSG_TYPE.EXTENDCIRCUIT,msg) tp, body = receive_reply(s,[MSG_TYPE.DONE]) if len(body) != 4: raise ProtocolError("Extendcircuit reply too short or long") return struct.unpack("!L",body) |
evtype = struct.unpack("!H", body[:2]) | evtype, = struct.unpack("!H", body[:2]) | def unpack_event(body): if len(body)<2: raise ProtocolError("EVENT body too short.") evtype = struct.unpack("!H", body[:2]) body = body[2:] if evtype == EVENT_TYPE.CIRCUITSTATUS: if len(body)<5: raise ProtocolError("CIRCUITSTATUS event too short.") status,ident = struct.unpack("!BL", body[:5]) path = _unterminate(body[... |
if evtype == EVENT_TYPE.CIRCUITSTATUS: | if evtype == EVENT_TYPE.CIRCSTATUS: | def unpack_event(body): if len(body)<2: raise ProtocolError("EVENT body too short.") evtype = struct.unpack("!H", body[:2]) body = body[2:] if evtype == EVENT_TYPE.CIRCUITSTATUS: if len(body)<5: raise ProtocolError("CIRCUITSTATUS event too short.") status,ident = struct.unpack("!BL", body[:5]) path = _unterminate(body[... |
print "Syntax: tor-control.py torhost:torport" | print "Syntax: TorControl.py torhost:torport" | def do_main_loop(host,port): print "host is %s:%d"%(host,port) s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((host,port)) authenticate(s) print "nick",`get_option(s,"nickname")` print get_option(s,"DirFetchPeriod\n") print `get_info(s,"version")` #print `get_info(s,"desc/name/moria1")` print `get_info... |
body = s.recv(length) | while length > len(body): body += s.recv(length) | def _receive_msg(s): body = "" header = s.recv(4) length,type = struct.unpack("!HH",header) if length: body = s.recv(length) return length,type,body |
send_signal(s,1) | print '========' print `extend_circuit(s,0,[""])` print '========' | def do_main_loop(host,port): print "host is %s:%d"%(host,port) s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((host,port)) authenticate(s) print "nick",`get_option(s,"nickname")` print get_option(s,"DirFetchPeriod\n") print `get_info(s,"version")` #print `get_info(s,"desc/name/moria1")` print `get_info... |
del circs[circid] | if circs.has_key(circid): del circs[circid] | def handleEvent(s, body, circs, streamsByNonce, streamsByIdent): event, args = TorControl.unpack_event(body) if event == TorControl.EVENT_TYPE.STREAMSTATUS: status, ident, target = args print "Got stream event:",TorControl.STREAM_STATUS.nameOf[status],\ ident,target if status in (TorControl.STREAM_STATUS.NEW_CONNECT, T... |
reqheader = struct.pack("!BBBBB",version, command, rsv, atype, len(hostname)) | reqheader = struct.pack("!BBBB",version, command, rsv, atype) if atype == 0x03: reqheader += struct.pack("!B", len(hostname)) | def socks5ResolveRequest(hostname, atype=0x03, command=0xF0): version = 5 rsv = 0 port = 0 reqheader = struct.pack("!BBBBB",version, command, rsv, atype, len(hostname)) portstr = struct.pack("!H",port) return "%s%s%s"%(reqheader,hostname,portstr) |
nul = r.index('\0',4) return r[4:nul] | hlen, = struct.unpack("!B", r[4]) expected_len = 5 + hlen + 2 if len(r) < expected_len: return None return r[5:-2] | def socks5ParseResponse(r): if len(r)<8: return None version, reply, rsv, atype = struct.unpack("!BBBB",r[:4]) assert version==5 assert rsv==0 if reply != 0x00: return "ERROR",reply assert atype in (0x01,0x03,0x04) if atype != 0x03: expected_len = 4 + ({1:4,4:16}[atype]) + 2 if len(r) < expected_len: return None elif l... |
print len(fmt(hostname)), len(hostname) | def resolve(hostname, sockshost, socksport, socksver=4, reverse=0): assert socksver in (4,5) if socksver == 4: fmt = socks4AResolveRequest parse = socks4AParseResponse elif not reverse: fmt = socks5ResolveRequest parse = socks5ParseResponse else: fmt = socks5ResolvePTRRequest parse = socks5ParseResponse s = socket.soc... | |
while sys.argv[1] == '-': | while sys.argv[1][0] == '-': | def resolve(hostname, sockshost, socksport, socksver=4, reverse=0): assert socksver in (4,5) if socksver == 4: fmt = socks4AResolveRequest parse = socks4AParseResponse elif not reverse: fmt = socks5ResolveRequest parse = socks5ParseResponse else: fmt = socks5ResolvePTRRequest parse = socks5ParseResponse s = socket.soc... |
print "Syntax: resolve.py [-4|-5] hostname [sockshost:socksport]" | print "Syntax: resolve.py [-x] [-4|-5] hostname [sockshost:socksport]" | def resolve(hostname, sockshost, socksport, socksver=4, reverse=0): assert socksver in (4,5) if socksver == 4: fmt = socks4AResolveRequest parse = socks4AParseResponse elif not reverse: fmt = socks5ResolveRequest parse = socks5ParseResponse else: fmt = socks5ResolvePTRRequest parse = socks5ParseResponse s = socket.soc... |
body += s.recv(length) | body += s.recv(length-len(body)) | def _receive_msg(s): body = "" header = s.recv(4) length,type = struct.unpack("!HH",header) if length: while length > len(body): body += s.recv(length) return length,type,body |
portstr = struct.pach("!H",port) | portstr = struct.pack("!H",port) | def socks5ResolveRequest(hostname): version = 5 command = 0xF0 rsv = 0 port = 0 atype = 0x03 reqheader = struct.pack("!BBBB",version, command, rsv, atype) portstr = struct.pach("!H",port) return "%s%s\0%s"%(reqheader,hostname,port) |
body += '''Subject: Meatoo is ready for you.\n\n''' | body += '''Subject: Meatoo Registration Confirmation.\n\n''' | def send_new_passwd(address): """Create new account and email passwd""" if "@" not in address: return "Invalid email address." if address.split("@")[1] != "gentoo.org": return "Only official Gentoo developers may register." username = address.split("@")[0] password = accounts.get_password() if accounts.get_user_passwd... |
if send_email(address, body) == -1: | if send_email(body) == -1: | def send_new_passwd(address): """Create new account and email passwd""" if "@" not in address: return "Invalid email address." if address.split("@")[1] != "gentoo.org": return "Only official Gentoo developers may register." username = address.split("@")[0] password = accounts.get_password() if accounts.get_user_passwd... |
body += '''From: "Meatoo Admin" <gentooexp@gbody.com>\n''' | body += '''From: "Meatoo Admin" <gentooexp@gmail.com>\n''' | def mail_lost_passwd(username): """Email existing password to user""" password = accounts.get_user_passwd(username) body = '''Date: %s\n''' % datetime.datetime.now() body += '''To: <%s>\n''' % "%s@gentoo.org" % username body += '''From: "Meatoo Admin" <gentooexp@gbody.com>\n''' body += '''Subject: Your lost Meatoo pass... |
new_user = Users( user = username, password = passwd) | herdsAuto = " ".join(herds.get_dev_herds(username)) new_user = Users( user = username, password = passwd, herdsAuto = herdsAuto, herdsUser = "") | def add_user(username, passwd): """Add new user to db""" new_user = Users( user = username, password = passwd) |
yield header_top() yield "<table class='admin'><tr><td>" | def mail_passwd(username): yield header_top() yield "<table class='admin'><tr><td>" password = accounts.get_user_passwd(username) mail = '''Date: %s\n''' % datetime.datetime.now() mail += '''To: <%s>\n''' % "%s@gentoo.org" % username mail += '''From: "Meatoo Admin" <gentooexp@gmail.com>\n''' mail += '''Subject: Lost Me... | |
mail += '''Subject: Lost Meatoo password.\n\n''' | mail += '''Subject: Your lost Meatoo password.\n\n''' | def mail_passwd(username): yield header_top() yield "<table class='admin'><tr><td>" password = accounts.get_user_passwd(username) mail = '''Date: %s\n''' % datetime.datetime.now() mail += '''To: <%s>\n''' % "%s@gentoo.org" % username mail += '''From: "Meatoo Admin" <gentooexp@gmail.com>\n''' mail += '''Subject: Lost Me... |
os.system('/usr/bin/nbsmtp < %s' % tfname) yield """Your password has been emailed.""" yield """</td></tr></table>""" | os.system('/usr/bin/nbsmtp -V < %s' % tfname) | def mail_passwd(username): yield header_top() yield "<table class='admin'><tr><td>" password = accounts.get_user_passwd(username) mail = '''Date: %s\n''' % datetime.datetime.now() mail += '''To: <%s>\n''' % "%s@gentoo.org" % username mail += '''From: "Meatoo Admin" <gentooexp@gmail.com>\n''' mail += '''Subject: Lost Me... |
pass yield footer() | print "WARNING - tmpfile not deleted - ", tfname | def mail_passwd(username): yield header_top() yield "<table class='admin'><tr><td>" password = accounts.get_user_passwd(username) mail = '''Date: %s\n''' % datetime.datetime.now() mail += '''To: <%s>\n''' % "%s@gentoo.org" % username mail += '''From: "Meatoo Admin" <gentooexp@gmail.com>\n''' mail += '''Subject: Lost Me... |
herds = Herds.select() | def index(self, verbose = None): """Main index.html page""" #verbose=1 will show you sql id's for debugging #For debugging, seeing cookies etc: print cherrypy.request.headerMap week = utils.get_days() packages = Packages.select(OR(Packages.q.latestReleaseDate == week[0], Packages.q.latestReleaseDate == week[1], Package... | |
self._body_tmpl.herds = herds | def index(self, verbose = None): """Main index.html page""" #verbose=1 will show you sql id's for debugging #For debugging, seeing cookies etc: print cherrypy.request.headerMap week = utils.get_days() packages = Packages.select(OR(Packages.q.latestReleaseDate == week[0], Packages.q.latestReleaseDate == week[1], Package... | |
db = None | def getFile(filename): """Helper function to return a file as a string""" fd = open(filename) s = fd.read() fd.close() return s | |
global DataBase if DataBase == None: DataBase = mysql.MysqlDB(getDBDict()) | def __init__(self, client): """Set up server and define who we are talking to...well at least what we are told we are talking to.""" self.client = client self.hostid = None | |
db = getDBDict() self.db = mysql.MysqlDB(db) self.conn = self.db.getConnection() self.cursor = self.db.getCursor() | self.conn = DataBase.getConnection() self.cursor = DataBase.getCursor() | def __init__(self, client): """Set up server and define who we are talking to...well at least what we are told we are talking to.""" self.client = client self.hostid = None |
copy.newChild(None, "othername", holder) | copy.newChild(None, "othername", holder.encode('utf-8')) | def postProcessXmlTranslation(self, doc, language, translators): """Sets a language and translators in "doc" tree. "translators" is a string consisted of "Name <email>" pairs of each translator, separated by newlines.""" |
(0, 500),)) | (1000, 500),)) | def end(): append("""\ endchar |
r = re.compile('%[^diouxXeEfFgGaAcsPn%]*[diouxXeEfFgGaAcsPn%]') | r = re.compile('%[^diouxXeEfFgGaAcspn%]*[diouxXeEfFgGaAcspn%]') | def compare(base, other, show_missing=False): r = re.compile('%[^diouxXeEfFgGaAcsPn%]*[diouxXeEfFgGaAcsPn%]') missing = [] for key in base: if key not in other: missing.append(key) continue if re.findall(r, base[key]) != re.findall(r, other[key]): print 'Mismatch: ', key print base[key] print other[key] print del other... |
'diff failed', | 'scons and installer installations differ', | def confirm(question): print question if raw_input() != 'y': sys.exit(2) |
if open('diff.log').read() != '': print '*** scons and installer installations differ' exit() | def confirm(question): print question if raw_input() != 'y': sys.exit(2) | |
confirm('did update history.but?' % VERSION) | confirm('did you update history.but?') | def confirm(question): print question if raw_input() != 'y': sys.exit(2) |
'%s commit -m "%s" ..\\Menu\\images\\header.gif' % (CVS, VERSION). | '%s commit -m "%s" ..\\Menu\\images\\header.gif' % (CVS, VERSION), | def confirm(question): print question if raw_input() != 'y': sys.exit(2) |
'..\\nsis-test.exe /S /D=%s\\insttest' % os.getcwd() | '..\\nsis-test.exe /S /D=%s\\insttest' % os.getcwd(), | def confirm(question): print question if raw_input() != 'y': sys.exit(2) |
def check_link_flag(ctx, flag): | def check_link_flag(ctx, flag, run = 0, extension = '.c', code = None): | def check_link_flag(ctx, flag): ctx.Message('Checking for linker flag %s... ' % flag) old_flags = ctx.env['LINKFLAGS'] ctx.env.Append(LINKFLAGS = flag) test = """ int main() { return 0; } """ result = ctx.TryLink(test, '.c') ctx.Result(result) if not result: ctx.env.Replace(LINKFLAGS = old_flags) return result |
test = """ int main() { return 0; } """ | if code: test = code else: test = """ int main() { return 0; } """ | def check_link_flag(ctx, flag): ctx.Message('Checking for linker flag %s... ' % flag) old_flags = ctx.env['LINKFLAGS'] ctx.env.Append(LINKFLAGS = flag) test = """ int main() { return 0; } """ result = ctx.TryLink(test, '.c') ctx.Result(result) if not result: ctx.env.Replace(LINKFLAGS = old_flags) return result |
result = ctx.TryLink(test, '.c') | result = ctx.TryLink(test, extension) if run: result = result and ctx.TryRun(test, extension)[0] | def check_link_flag(ctx, flag): ctx.Message('Checking for linker flag %s... ' % flag) old_flags = ctx.env['LINKFLAGS'] ctx.env.Append(LINKFLAGS = flag) test = """ int main() { return 0; } """ result = ctx.TryLink(test, '.c') ctx.Result(result) if not result: ctx.env.Replace(LINKFLAGS = old_flags) return result |
'..\\nsis-test.exe /S /D=%s\\insttest' % os.getcwd(), | '..\\nsis-test-setup.exe /S /D=%s\\insttest' % os.getcwd(), | def confirm(question): print question if raw_input() != 'y': sys.exit(2) |
upload(ftp, newverdir + '\\nsis-%s.exe' % VERSION) | upload(ftp, newverdir + '\\nsis-%s-setup.exe' % VERSION) | def upload(ftp, file): print ' uploading %s...' % file ftp.storbinary('STOR /incoming/%s' % file.split('\\')[-1], open(file, 'rb')) |
if (self.days_old_max < 1): | if self.days_old_max < 1: | def sanity_check(self): """Complain bitterly about our options now rather than later""" if self.output_dir: if not os.path.isdir(self.output_dir): user_error("output directory does not exist: '%s'" % \ self.output_dir) if not os.access(self.output_dir, os.W_OK): user_error("no write permission on output directory: '%s'... |
if (self.days_old_max >= 10000): | if self.days_old_max >= 10000: | def sanity_check(self): """Complain bitterly about our options now rather than later""" if self.output_dir: if not os.path.isdir(self.output_dir): user_error("output directory does not exist: '%s'" % \ self.output_dir) if not os.access(self.output_dir, os.W_OK): user_error("no write permission on output directory: '%s'... |
retain.finalise(mailbox_name) | retain.finalise() | def _archive_mbox(mailbox_name, final_archive_name): """Archive a 'mbox' style mailbox - used by archive_mailbox() Arguments: mailbox_name -- the filename/dirname of the mailbox to be archived final_archive_name -- the filename of the 'mbox' mailbox to archive old messages to - appending if the archive already exists ... |
opts, args = getopt.getopt(args, '?D:S:Vd:hno:qs:uv', | opts, args = getopt.getopt(args, '?D:S:Vd:hno:P:qs:uv', | def parse_args(self, args, usage): """Set our runtime options from the command-line arguments. |
if mailbox_name[:7].lower() == 'imap://': | imap_scheme = urlparse.urlparse(mailbox_name)[0] if imap_scheme == 'imap' or imap_scheme == 'imaps': | def archive(mailbox_name): """Archives a mailbox. Arguments: mailbox_name -- the filename/dirname of the mailbox to be archived final_archive_name -- the filename of the 'mbox' mailbox to archive old messages to - appending if the archive already exists """ assert(mailbox_name) # strip any trailing slash (we could b... |
elif mailbox_name[:7].lower() == 'imap://': vprint("guessing mailbox is of type: imap") | if imap_scheme == 'imap' or imap_scheme == 'imaps': vprint("guessing mailbox is of type: imap(s)") | def archive(mailbox_name): """Archives a mailbox. Arguments: mailbox_name -- the filename/dirname of the mailbox to be archived final_archive_name -- the filename of the 'mbox' mailbox to archive old messages to - appending if the archive already exists """ assert(mailbox_name) # strip any trailing slash (we could b... |
imap_str = mailbox_name[7:] | imap_str = mailbox_name[mailbox_name.find('://') + 3:] | def _archive_imap(mailbox_name, final_archive_name): """Archive an imap mailbox - used by archive_mailbox()""" assert(mailbox_name) assert(final_archive_name) import imaplib import cStringIO archive = None stats = Stats(mailbox_name, final_archive_name) imap_str = mailbox_name[7:] filter = build_imap_filter() vprint("... |
imap_srv = imaplib.IMAP4(imap_server) | imap_username = getpass.getuser() if options.pwfile: imap_password = open(options.pwfile).read().rstrip() else: imap_password = getpass.getpass() imap_server, imap_folder = imap_str.split('/', 1) if mailbox_name[:5] == 'imaps': vprint("Using SSL") imap_srv = imaplib.IMAP4_SSL(imap_server) else: imap_srv = imaplib.IMAP... | def _archive_imap(mailbox_name, final_archive_name): """Archive an imap mailbox - used by archive_mailbox()""" assert(mailbox_name) assert(final_archive_name) import imaplib import cStringIO archive = None stats = Stats(mailbox_name, final_archive_name) imap_str = mailbox_name[7:] filter = build_imap_filter() vprint("... |
result, response = imap_srv.login(imap_username, imap_password) | cram_md5 = True if cram_md5: result, response = imap_srv.login_cram_md5(imap_username, imap_password) else: result, response = imap_srv.login(imap_username, imap_password) | def _archive_imap(mailbox_name, final_archive_name): """Archive an imap mailbox - used by archive_mailbox()""" assert(mailbox_name) assert(final_archive_name) import imaplib import cStringIO archive = None stats = Stats(mailbox_name, final_archive_name) imap_str = mailbox_name[7:] filter = build_imap_filter() vprint("... |
too_old_error = """This test script requires python version 2.1 or later. This is because it requires the pyUnit 'unittest' module, which only got released in python version 2.1. You should still be able to run archivemail on python versions 2.0 and above, however -- just not test it. Your version of python is: %s""" %... | too_old_error = "This test script requires python version 2.3 or later. " + \ "Your version of python is:\n%s" % sys.version | def check_python_version(): """Abort if we are running on python < v2.1""" too_old_error = """This test script requires python version 2.1 or later. |
if (version[0] < 2) or ((version[0] == 2) and (version[1] < 1)): | if (version[0] < 2) or (version[0] == 2 and version[1] < 3): | def check_python_version(): """Abort if we are running on python < v2.1""" too_old_error = """This test script requires python version 2.1 or later. |
class TestMboxIsEmpty(unittest.TestCase): def setUp(self): | class TestMboxIsEmpty(TestCaseInTempdir): def setUp(self): super(TestMboxIsEmpty, self).setUp() | def check_python_version(): """Abort if we are running on python < v2.1""" too_old_error = """This test script requires python version 2.1 or later. |
def tearDown(self): for name in (self.empty_name, self.not_empty_name): if os.path.exists(name): os.remove(name) class TestMboxLeaveEmpty(unittest.TestCase): def setUp(self): | class TestMboxLeaveEmpty(TestCaseInTempdir): def setUp(self): super(TestMboxLeaveEmpty, self).setUp() | def tearDown(self): for name in (self.empty_name, self.not_empty_name): if os.path.exists(name): os.remove(name) |
def tearDown(self): if os.path.exists(self.mbox_name): os.remove(self.mbox_name) class TestMboxProcmailLock(unittest.TestCase): def setUp(self): | class TestMboxProcmailLock(TestCaseInTempdir): def setUp(self): super(TestMboxProcmailLock, self).setUp() | def tearDown(self): if os.path.exists(self.mbox_name): os.remove(self.mbox_name) |
def tearDown(self): if os.path.exists(self.mbox_name): os.remove(self.mbox_name) class TestMboxRemove(unittest.TestCase): def setUp(self): | class TestMboxRemove(TestCaseInTempdir): def setUp(self): super(TestMboxRemove, self).setUp() | def tearDown(self): if os.path.exists(self.mbox_name): os.remove(self.mbox_name) |
def tearDown(self): if os.path.exists(self.mbox_name): os.remove(self.mbox_name) class TestMboxExclusiveLock(unittest.TestCase): def setUp(self): | class TestMboxExclusiveLock(TestCaseInTempdir): def setUp(self): super(TestMboxExclusiveLock, self).setUp() | def tearDown(self): if os.path.exists(self.mbox_name): os.remove(self.mbox_name) |
def tearDown(self): if os.path.exists(self.mbox_name): os.remove(self.mbox_name) class TestMboxNext(unittest.TestCase): def setUp(self): | class TestMboxNext(TestCaseInTempdir): def setUp(self): super(TestMboxNext, self).setUp() | def tearDown(self): if os.path.exists(self.mbox_name): os.remove(self.mbox_name) |
def tearDown(self): for name in (self.not_empty_name, self.empty_name): if os.path.exists(name): os.remove(name) class TestMboxWrite(unittest.TestCase): def setUp(self): | class TestMboxWrite(TestCaseInTempdir): def setUp(self): super(TestMboxWrite, self).setUp() | def tearDown(self): for name in (self.not_empty_name, self.empty_name): if os.path.exists(name): os.remove(name) |
def tearDown(self): for name in (self.mbox_write, self.mbox_read): if os.path.exists(name): os.remove(name) | def tearDown(self): for name in (self.mbox_write, self.mbox_read): if os.path.exists(name): os.remove(name) | |
class TestArchiveMbox(unittest.TestCase): | class TestArchiveMbox(TestCaseInTempdir): | def testFuture(self): """with max_days=1, should be false for times in the future""" for minutes in range(0, 60): time_msg = time.time() + (minutes * 60) assert(not archivemail.is_older_than_days(time_message=time_msg, max_days=1)) |
archive = self.mbox_name + "_archive" for name in (self.mbox_name, self.old_mbox, self.new_mbox, self.copy_name, archive, archive + ".gz"): if name and os.path.exists(name): os.remove(name) class TestArchiveMboxTimestamp(unittest.TestCase): | super(TestArchiveMbox, self).tearDown() class TestArchiveMboxTimestamp(TestCaseInTempdir): | def tearDown(self): archivemail.options.quiet = 0 archive = self.mbox_name + "_archive" for name in (self.mbox_name, self.old_mbox, self.new_mbox, self.copy_name, archive, archive + ".gz"): if name and os.path.exists(name): os.remove(name) |
for name in (self.mbox_name, self.mbox_name + "_archive.gz"): if os.path.exists(name): os.remove(name) class TestArchiveMboxPreserveStatus(unittest.TestCase): | super(TestArchiveMboxTimestamp, self).tearDown() class TestArchiveMboxPreserveStatus(TestCaseInTempdir): | def tearDown(self): archivemail.options.quiet = 0 for name in (self.mbox_name, self.mbox_name + "_archive.gz"): if os.path.exists(name): os.remove(name) |
archive = self.mbox_name + "_archive" for name in (self.mbox_name, self.copy_name, archive, archive + ".gz"): if os.path.exists(name): os.remove(name) class TestArchiveMboxSuffix(unittest.TestCase): | super(TestArchiveMboxPreserveStatus, self).tearDown() class TestArchiveMboxSuffix(TestCaseInTempdir): | def tearDown(self): archivemail.options.quiet = 0 archivemail.options.preserve_unread = 0 archive = self.mbox_name + "_archive" for name in (self.mbox_name, self.copy_name, archive, archive + ".gz"): if os.path.exists(name): os.remove(name) |
archive = self.mbox_name + "_archive" for name in (self.mbox_name, self.copy_name, archive, archive + ".gz"): if os.path.exists(name): os.remove(name) class TestArchiveDryRun(unittest.TestCase): | super(TestArchiveMboxSuffix, self).tearDown() class TestArchiveDryRun(TestCaseInTempdir): | def tearDown(self): archivemail.options.quiet = 0 archivemail.options.archive_suffix = "_archive" archive = self.mbox_name + "_archive" for name in (self.mbox_name, self.copy_name, archive, archive + ".gz"): if os.path.exists(name): os.remove(name) |
archive = self.mbox_name + "_archive" for name in (self.mbox_name, self.copy_name, archive, archive + ".gz"): if os.path.exists(name): os.remove(name) class TestArchiveDays(unittest.TestCase): | super(TestArchiveDryRun, self).tearDown() class TestArchiveDays(TestCaseInTempdir): | def tearDown(self): archivemail.options.dry_run = 0 archivemail.options.quiet = 0 archive = self.mbox_name + "_archive" for name in (self.mbox_name, self.copy_name, archive, archive + ".gz"): if os.path.exists(name): os.remove(name) |
archive = self.mbox_name + "_archive" for name in (self.mbox_name, self.copy_name, archive, archive + ".gz"): if name and os.path.exists(name): os.remove(name) class TestArchiveDelete(unittest.TestCase): | super(TestArchiveDays, self).tearDown() class TestArchiveDelete(TestCaseInTempdir): | def tearDown(self): archivemail.options.days_old_max = 180 archivemail.options.quiet = 0 archive = self.mbox_name + "_archive" for name in (self.mbox_name, self.copy_name, archive, archive + ".gz"): if name and os.path.exists(name): os.remove(name) |
archive = self.mbox_name + "_archive" for name in (self.mbox_name, self.copy_name, self.new_mbox, self.old_mbox, archive, archive + ".gz"): if name and os.path.exists(name): os.remove(name) class TestArchiveMboxFlagged(unittest.TestCase): | super(TestArchiveDelete, self).tearDown() class TestArchiveMboxFlagged(TestCaseInTempdir): | def tearDown(self): archivemail.options.delete_old_mail = 0 archivemail.options.quiet = 0 archive = self.mbox_name + "_archive" for name in (self.mbox_name, self.copy_name, self.new_mbox, self.old_mbox, archive, archive + ".gz"): if name and os.path.exists(name): os.remove(name) |
archive = self.mbox_name + "_archive" for name in (self.mbox_name, self.copy_name, archive, archive + ".gz"): if os.path.exists(name): os.remove(name) class TestArchiveMboxOutputDir(unittest.TestCase): | super(TestArchiveMboxFlagged, self).tearDown() class TestArchiveMboxOutputDir(TestCaseInTempdir): | def tearDown(self): archivemail.options.include_flagged = 0 archivemail.options.quiet = 0 archive = self.mbox_name + "_archive" for name in (self.mbox_name, self.copy_name, archive, archive + ".gz"): if os.path.exists(name): os.remove(name) |
archive = self.dir_name + "/" + os.path.basename(self.mbox_name) \ + "_archive" for name in (self.mbox_name, self.copy_name, archive, archive + ".gz"): if name and os.path.exists(name): os.remove(name) if self.dir_name and os.path.isdir(self.dir_name): os.rmdir(self.dir_name) class TestArchiveMboxUncompressed(unittes... | super(TestArchiveMboxOutputDir, self).tearDown() class TestArchiveMboxUncompressed(TestCaseInTempdir): | def tearDown(self): archivemail.options.quiet = 0 archivemail.options.output_dir = None archive = self.dir_name + "/" + os.path.basename(self.mbox_name) \ + "_archive" for name in (self.mbox_name, self.copy_name, archive, archive + ".gz"): if name and os.path.exists(name): os.remove(name) if self.dir_name and os.path.i... |
archive = self.mbox_name + "_archive" for name in (self.mbox_name, self.new_mbox, self.old_mbox, self.copy_name, archive, archive + ".gz"): if name and os.path.exists(name): os.remove(name) class TestArchiveSize(unittest.TestCase): | super(TestArchiveMboxUncompressed, self).tearDown() class TestArchiveSize(TestCaseInTempdir): | def tearDown(self): archivemail.options.quiet = 0 archivemail.options.no_compress = 0 archive = self.mbox_name + "_archive" for name in (self.mbox_name, self.new_mbox, self.old_mbox, self.copy_name, archive, archive + ".gz"): if name and os.path.exists(name): os.remove(name) |
archive = self.mbox_name + "_archive" for name in (self.mbox_name, self.copy_name, archive, archive + ".gz"): if name and os.path.exists(name): os.remove(name) class TestArchiveMboxMode(unittest.TestCase): | super(TestArchiveSize, self).tearDown() class TestArchiveMboxMode(TestCaseInTempdir): | def tearDown(self): archivemail.options.quiet = 0 archivemail.options.min_size = None archive = self.mbox_name + "_archive" for name in (self.mbox_name, self.copy_name, archive, archive + ".gz"): if name and os.path.exists(name): os.remove(name) |
archive = self.mbox_name + "_archive" for name in (self.mbox_name, archive, archive + ".gz"): if name and os.path.exists(name): os.remove(name) | super(TestArchiveMboxMode, self).tearDown() | def tearDown(self): archivemail.options.quiet = 0 archive = self.mbox_name + "_archive" for name in (self.mbox_name, archive, archive + ".gz"): if name and os.path.exists(name): os.remove(name) |
name = tempfile.mktemp() file = open(name, "w") | assert(tempfile.tempdir) fd, name = tempfile.mkstemp() file = os.fdopen(fd, "w") | def make_mbox(body=None, headers=None, hours_old=0, messages=1): name = tempfile.mktemp() file = open(name, "w") for count in range(messages): msg = make_message(body=body, default_headers=headers, hours_old=hours_old) file.write(msg) file.close() return name |
if (not archive): | if not archive: | def _archive_dir(mailbox_name, final_archive_name, type): """Archive a 'maildir' or 'MH' style mailbox - used by archive_mailbox()""" assert(mailbox_name) assert(final_archive_name) assert(type) original = None archive = None stats = Stats(mailbox_name, final_archive_name) delete_queue = [] if type == "maildir": origi... |
time.localtime(time.time())) | time.localtime(parsed_suffix_time)) | def archive(mailbox_name): """Archives a mailbox. Arguments: mailbox_name -- the filename/dirname of the mailbox to be archived final_archive_name -- the filename of the 'mbox' mailbox to archive old messages to - appending if the archive already exists """ assert(mailbox_name) # strip any trailing slash (we could b... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.