rem
stringlengths
1
322k
add
stringlengths
0
2.05M
context
stringlengths
4
228k
meta
stringlengths
156
215
return addinfo(fp, headers)
return addinfourl(fp, headers, self.openedurl)
def open_http(self, url): import httplib if type(url) is type(""): host, selector = splithost(url) user_passwd, host = splituser(host) else: host, selector = url urltype, rest = splittype(selector) if string.lower(urltype) == 'http': realhost, rest = splithost(rest) user_passwd, realhost = splituser(realhost) if user_passwd: selector = "%s://%s%s" % (urltype, realhost, rest) print "proxy via http:", host, selector if not host: raise IOError, ('http error', 'no host given') if user_passwd: import base64 auth = string.strip(base64.encodestring(user_passwd)) else: auth = None h = httplib.HTTP(host) h.putrequest('GET', selector) if auth: h.putheader('Authorization: Basic %s' % auth) for args in self.addheaders: apply(h.putheader, args) h.endheaders() errcode, errmsg, headers = h.getreply() fp = h.getfile() if errcode == 200: return addinfo(fp, headers) else: return self.http_error(url, fp, errcode, errmsg, headers)
e6ad8913e20766e3769b346450dc952f0140462c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e6ad8913e20766e3769b346450dc952f0140462c/urllib.py
return addinfo(fp, noheaders())
return addinfourl(fp, noheaders(), self.openedurl)
def open_gopher(self, url): import gopherlib host, selector = splithost(url) if not host: raise IOError, ('gopher error', 'no host given') type, selector = splitgophertype(selector) selector, query = splitquery(selector) selector = unquote(selector) if query: query = unquote(query) fp = gopherlib.send_query(selector, query, host) else: fp = gopherlib.send_selector(selector, host) return addinfo(fp, noheaders())
e6ad8913e20766e3769b346450dc952f0140462c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e6ad8913e20766e3769b346450dc952f0140462c/urllib.py
if not host: return addinfo(open(url2pathname(file), 'r'), noheaders())
if not host: return addinfourl(open(url2pathname(file), 'r'), noheaders(), self.openedurl)
def open_local_file(self, url): host, file = splithost(url) if not host: return addinfo(open(url2pathname(file), 'r'), noheaders()) host, port = splitport(host) if not port and socket.gethostbyname(host) in ( localhost(), thishost()): file = unquote(file) return addinfo(open(url2pathname(file), 'r'), noheaders()) raise IOError, ('local file error', 'not on local host')
e6ad8913e20766e3769b346450dc952f0140462c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e6ad8913e20766e3769b346450dc952f0140462c/urllib.py
return addinfo(open(url2pathname(file), 'r'), noheaders())
return addinfourl(open(url2pathname(file), 'r'), noheaders(), self.openedurl)
def open_local_file(self, url): host, file = splithost(url) if not host: return addinfo(open(url2pathname(file), 'r'), noheaders()) host, port = splitport(host) if not port and socket.gethostbyname(host) in ( localhost(), thishost()): file = unquote(file) return addinfo(open(url2pathname(file), 'r'), noheaders()) raise IOError, ('local file error', 'not on local host')
e6ad8913e20766e3769b346450dc952f0140462c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e6ad8913e20766e3769b346450dc952f0140462c/urllib.py
return addinfo(self.ftpcache[key].retrfile(file, type), noheaders())
return addinfourl(self.ftpcache[key].retrfile(file, type), noheaders(), self.openedurl)
def open_ftp(self, url): host, path = splithost(url) if not host: raise IOError, ('ftp error', 'no host given') host, port = splitport(host) user, host = splituser(host) if user: user, passwd = splitpasswd(user) else: passwd = None host = socket.gethostbyname(host) if not port: import ftplib port = ftplib.FTP_PORT path, attrs = splitattr(path) dirs = string.splitfields(path, '/') dirs, file = dirs[:-1], dirs[-1] if dirs and not dirs[0]: dirs = dirs[1:] key = (user, host, port, string.joinfields(dirs, '/')) try: if not self.ftpcache.has_key(key): self.ftpcache[key] = \ ftpwrapper(user, passwd, host, port, dirs) if not file: type = 'D' else: type = 'I' for attr in attrs: attr, value = splitvalue(attr) if string.lower(attr) == 'type' and \ value in ('a', 'A', 'i', 'I', 'd', 'D'): type = string.upper(value) return addinfo(self.ftpcache[key].retrfile(file, type), noheaders()) except ftperrors(), msg: raise IOError, ('ftp error', msg)
e6ad8913e20766e3769b346450dc952f0140462c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e6ad8913e20766e3769b346450dc952f0140462c/urllib.py
return addinfo(fp, headers)
return addinfourl(fp, headers, self.openedurl)
def http_error_default(self, url, fp, errcode, errmsg, headers): return addinfo(fp, headers)
e6ad8913e20766e3769b346450dc952f0140462c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e6ad8913e20766e3769b346450dc952f0140462c/urllib.py
import sys
def whichmodule(cls, clsname): """Figure out the module in which a class occurs. Search sys.modules for the module. Cache in classmap. Return a module name. If the class cannot be found, return __main__. """ if classmap.has_key(cls): return classmap[cls] import sys for name, module in sys.modules.items(): if name != '__main__' and \ hasattr(module, clsname) and \ getattr(module, clsname) is cls: break else: name = '__main__' classmap[cls] = name return name
743d17e3aa77b84a57531cd74e1daba87132f807 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/743d17e3aa77b84a57531cd74e1daba87132f807/pickle.py
value = apply(klass, args)
try: value = apply(klass, args) except TypeError, err: raise TypeError, "in constructor for %s: %s" % ( klass.__name__, str(err)), sys.exc_info()[2]
def load_inst(self): k = self.marker() args = tuple(self.stack[k+1:]) del self.stack[k:] module = self.readline()[:-1] name = self.readline()[:-1] klass = self.find_class(module, name) instantiated = 0 if (not args and type(klass) is ClassType and not hasattr(klass, "__getinitargs__")): try: value = _EmptyClass() value.__class__ = klass instantiated = 1 except RuntimeError: # In restricted execution, assignment to inst.__class__ is # prohibited pass if not instantiated: value = apply(klass, args) self.append(value)
743d17e3aa77b84a57531cd74e1daba87132f807 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/743d17e3aa77b84a57531cd74e1daba87132f807/pickle.py
try: path = win32api.GetFullPathName(path) except win32api.error: pass
if path: try: path = win32api.GetFullPathName(path) except win32api.error: pass else: path = os.getcwd()
def _abspath(path): if not isabs(path): path = join(os.getcwd(), path) return normpath(path)
647d2fe1451b1e7cd558771fcbae3fbdce1ffcf7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/647d2fe1451b1e7cd558771fcbae3fbdce1ffcf7/ntpath.py
sf = StringIO('Content-Length: %d\n' % retrlen) headers = mimetools.Message(sf) else: headers = noheaders()
headers += "Content-Length: %d\n" % retrlen sf = StringIO(headers) headers = mimetools.Message(sf)
def ftp_open(self, req): host = req.get_host() if not host: raise IOError, ('ftp error', 'no host given') # XXX handle custom username & password try: host = socket.gethostbyname(host) except socket.error, msg: raise URLError(msg) host, port = splitport(host) if port is None: port = ftplib.FTP_PORT path, attrs = splitattr(req.get_selector()) path = unquote(path) dirs = path.split('/') dirs, file = dirs[:-1], dirs[-1] if dirs and not dirs[0]: dirs = dirs[1:] user = passwd = '' # XXX try: fw = self.connect_ftp(user, passwd, host, port, dirs) type = file and 'I' or 'D' for attr in attrs: attr, value = splitattr(attr) if attr.lower() == 'type' and \ value in ('a', 'A', 'i', 'I', 'd', 'D'): type = value.upper() fp, retrlen = fw.retrfile(file, type) if retrlen is not None and retrlen >= 0: sf = StringIO('Content-Length: %d\n' % retrlen) headers = mimetools.Message(sf) else: headers = noheaders() return addinfourl(fp, headers, req.get_full_url()) except ftplib.all_errors, msg: raise IOError, ('ftp error', msg), sys.exc_info()[2]
833a8d86417f4832f5e3ad742f21fe10378388bb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/833a8d86417f4832f5e3ad742f21fe10378388bb/urllib2.py
ci.append(-2.5, -3.7, 1.0) ci.append(-1.5, -3.7, 3.0) ci.append(1.5, -3.7, -2.5) ci.append(2.5, -3.7, -0.75)
ci.append((-2.5, -3.7, 1.0)) ci.append((-1.5, -3.7, 3.0)) ci.append((1.5, -3.7, -2.5)) ci.append((2.5, -3.7, -0.75))
def make_ctlpoints(): c = [] # ci = [] ci.append(-2.5, -3.7, 1.0) ci.append(-1.5, -3.7, 3.0) ci.append(1.5, -3.7, -2.5) ci.append(2.5, -3.7, -0.75) c.append(ci) # ci = [] ci.append(-2.5, -2.0, 3.0) ci.append(-1.5, -2.0, 4.0) ci.append(1.5, -2.0, -3.0) ci.append(2.5, -2.0, 0.0) c.append(ci) # ci = [] ci.append(-2.5, 2.0, 1.0) ci.append(-1.5, 2.0, 0.0) ci.append(1.5, 2.0, -1.0) ci.append(2.5, 2.0, 2.0) c.append(ci) # ci = [] ci.append(-2.5, 2.7, 1.25) ci.append(-1.5, 2.7, 0.1) ci.append(1.5, 2.7, -0.6) ci.append(2.5, 2.7, 0.2) c.append(ci) # return c
b4624b94a86cf792dec99a05b13ebe7d774ee032 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b4624b94a86cf792dec99a05b13ebe7d774ee032/nurbs.py
ci.append(-2.5, -2.0, 3.0) ci.append(-1.5, -2.0, 4.0) ci.append(1.5, -2.0, -3.0) ci.append(2.5, -2.0, 0.0)
ci.append((-2.5, -2.0, 3.0)) ci.append((-1.5, -2.0, 4.0)) ci.append((1.5, -2.0, -3.0)) ci.append((2.5, -2.0, 0.0))
def make_ctlpoints(): c = [] # ci = [] ci.append(-2.5, -3.7, 1.0) ci.append(-1.5, -3.7, 3.0) ci.append(1.5, -3.7, -2.5) ci.append(2.5, -3.7, -0.75) c.append(ci) # ci = [] ci.append(-2.5, -2.0, 3.0) ci.append(-1.5, -2.0, 4.0) ci.append(1.5, -2.0, -3.0) ci.append(2.5, -2.0, 0.0) c.append(ci) # ci = [] ci.append(-2.5, 2.0, 1.0) ci.append(-1.5, 2.0, 0.0) ci.append(1.5, 2.0, -1.0) ci.append(2.5, 2.0, 2.0) c.append(ci) # ci = [] ci.append(-2.5, 2.7, 1.25) ci.append(-1.5, 2.7, 0.1) ci.append(1.5, 2.7, -0.6) ci.append(2.5, 2.7, 0.2) c.append(ci) # return c
b4624b94a86cf792dec99a05b13ebe7d774ee032 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b4624b94a86cf792dec99a05b13ebe7d774ee032/nurbs.py
ci.append(-2.5, 2.0, 1.0) ci.append(-1.5, 2.0, 0.0) ci.append(1.5, 2.0, -1.0) ci.append(2.5, 2.0, 2.0)
ci.append((-2.5, 2.0, 1.0)) ci.append((-1.5, 2.0, 0.0)) ci.append((1.5, 2.0, -1.0)) ci.append((2.5, 2.0, 2.0))
def make_ctlpoints(): c = [] # ci = [] ci.append(-2.5, -3.7, 1.0) ci.append(-1.5, -3.7, 3.0) ci.append(1.5, -3.7, -2.5) ci.append(2.5, -3.7, -0.75) c.append(ci) # ci = [] ci.append(-2.5, -2.0, 3.0) ci.append(-1.5, -2.0, 4.0) ci.append(1.5, -2.0, -3.0) ci.append(2.5, -2.0, 0.0) c.append(ci) # ci = [] ci.append(-2.5, 2.0, 1.0) ci.append(-1.5, 2.0, 0.0) ci.append(1.5, 2.0, -1.0) ci.append(2.5, 2.0, 2.0) c.append(ci) # ci = [] ci.append(-2.5, 2.7, 1.25) ci.append(-1.5, 2.7, 0.1) ci.append(1.5, 2.7, -0.6) ci.append(2.5, 2.7, 0.2) c.append(ci) # return c
b4624b94a86cf792dec99a05b13ebe7d774ee032 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b4624b94a86cf792dec99a05b13ebe7d774ee032/nurbs.py
ci.append(-2.5, 2.7, 1.25) ci.append(-1.5, 2.7, 0.1) ci.append(1.5, 2.7, -0.6) ci.append(2.5, 2.7, 0.2)
ci.append((-2.5, 2.7, 1.25)) ci.append((-1.5, 2.7, 0.1)) ci.append((1.5, 2.7, -0.6)) ci.append((2.5, 2.7, 0.2))
def make_ctlpoints(): c = [] # ci = [] ci.append(-2.5, -3.7, 1.0) ci.append(-1.5, -3.7, 3.0) ci.append(1.5, -3.7, -2.5) ci.append(2.5, -3.7, -0.75) c.append(ci) # ci = [] ci.append(-2.5, -2.0, 3.0) ci.append(-1.5, -2.0, 4.0) ci.append(1.5, -2.0, -3.0) ci.append(2.5, -2.0, 0.0) c.append(ci) # ci = [] ci.append(-2.5, 2.0, 1.0) ci.append(-1.5, 2.0, 0.0) ci.append(1.5, 2.0, -1.0) ci.append(2.5, 2.0, 2.0) c.append(ci) # ci = [] ci.append(-2.5, 2.7, 1.25) ci.append(-1.5, 2.7, 0.1) ci.append(1.5, 2.7, -0.6) ci.append(2.5, 2.7, 0.2) c.append(ci) # return c
b4624b94a86cf792dec99a05b13ebe7d774ee032 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b4624b94a86cf792dec99a05b13ebe7d774ee032/nurbs.py
c.append(1.0, 0.0, 1.0) c.append(1.0, 1.0, 1.0) c.append(0.0, 2.0, 2.0) c.append(-1.0, 1.0, 1.0) c.append(-1.0, 0.0, 1.0) c.append(-1.0, -1.0, 1.0) c.append(0.0, -2.0, 2.0) c.append(1.0, -1.0, 1.0) c.append(1.0, 0.0, 1.0)
c.append((1.0, 0.0, 1.0)) c.append((1.0, 1.0, 1.0)) c.append((0.0, 2.0, 2.0)) c.append((-1.0, 1.0, 1.0)) c.append((-1.0, 0.0, 1.0)) c.append((-1.0, -1.0, 1.0)) c.append((0.0, -2.0, 2.0)) c.append((1.0, -1.0, 1.0) ) c.append((1.0, 0.0, 1.0))
def make_trimpoints(): c = [] c.append(1.0, 0.0, 1.0) c.append(1.0, 1.0, 1.0) c.append(0.0, 2.0, 2.0) c.append(-1.0, 1.0, 1.0) c.append(-1.0, 0.0, 1.0) c.append(-1.0, -1.0, 1.0) c.append(0.0, -2.0, 2.0) c.append(1.0, -1.0, 1.0) c.append(1.0, 0.0, 1.0) return c
b4624b94a86cf792dec99a05b13ebe7d774ee032 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b4624b94a86cf792dec99a05b13ebe7d774ee032/nurbs.py
self.show(name, headers['title'], text, 1)
self.show(name, headers['title'], text)
def do_show(self):
ed531fd9df252b93d75593e5977cfd49eb36ae24 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ed531fd9df252b93d75593e5977cfd49eb36ae24/faqmain.py
self.show(name, title, text, 1)
self.show(name, title, text)
def do_all(self):
ed531fd9df252b93d75593e5977cfd49eb36ae24 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ed531fd9df252b93d75593e5977cfd49eb36ae24/faqmain.py
self.show(name, headers['title'], text, 1) print '<P><A HREF="faq.py?req=roulette">Show another one</A>'
self.show(name, headers['title'], text) print "<P>Use `Reload' to show another one."
def do_roulette(self):
ed531fd9df252b93d75593e5977cfd49eb36ae24 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ed531fd9df252b93d75593e5977cfd49eb36ae24/faqmain.py
self.show(name, headers['title'], text, 1)
self.show(name, headers['title'], text)
def do_recent(self):
ed531fd9df252b93d75593e5977cfd49eb36ae24 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ed531fd9df252b93d75593e5977cfd49eb36ae24/faqmain.py
self.show(name, title, text, 1)
self.show(name, title, text)
def do_query(self):
ed531fd9df252b93d75593e5977cfd49eb36ae24 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ed531fd9df252b93d75593e5977cfd49eb36ae24/faqmain.py
self.show(name, title, text)
self.show(name, title, text, edit=0)
def do_edit(self):
ed531fd9df252b93d75593e5977cfd49eb36ae24 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ed531fd9df252b93d75593e5977cfd49eb36ae24/faqmain.py
self.show(name, title, text)
self.show(name, title, text, edit=0)
def do_review(self):
ed531fd9df252b93d75593e5977cfd49eb36ae24 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ed531fd9df252b93d75593e5977cfd49eb36ae24/faqmain.py
self.show(name, title, text, 1)
self.show(name, title, text)
def checkin(self):
ed531fd9df252b93d75593e5977cfd49eb36ae24 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ed531fd9df252b93d75593e5977cfd49eb36ae24/faqmain.py
Title: <INPUT TYPE=text SIZE=70 NAME=title VALUE="%s"<BR>
Title: <INPUT TYPE=text SIZE=70 NAME=title VALUE="%s"><BR>
def showedit(self, name, title, text):
ed531fd9df252b93d75593e5977cfd49eb36ae24 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ed531fd9df252b93d75593e5977cfd49eb36ae24/faqmain.py
<CODE>Name : </CODE><INPUT TYPE=text SIZE=70 NAME=author VALUE="%s"<BR> <CODE>Email: </CODE><INPUT TYPE=text SIZE=70 NAME=email VALUE="%s"<BR>
<CODE>Name : </CODE><INPUT TYPE=text SIZE=40 NAME=author VALUE="%s"> <BR> <CODE>Email: </CODE><INPUT TYPE=text SIZE=40 NAME=email VALUE="%s"> <BR>
def showedit(self, name, title, text):
ed531fd9df252b93d75593e5977cfd49eb36ae24 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ed531fd9df252b93d75593e5977cfd49eb36ae24/faqmain.py
return headers, text f = open(name) headers = rfc822.Message(f) text = f.read() f.close()
else: f = open(name) headers = rfc822.Message(f) text = f.read() f.close() self.headers = headers
def read(self, name):
ed531fd9df252b93d75593e5977cfd49eb36ae24 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ed531fd9df252b93d75593e5977cfd49eb36ae24/faqmain.py
def show(self, name, title, text, edit=0):
def show(self, name, title, text, edit=1):
def show(self, name, title, text, edit=0):
ed531fd9df252b93d75593e5977cfd49eb36ae24 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ed531fd9df252b93d75593e5977cfd49eb36ae24/faqmain.py
def redirect_request(self, req, fp, code, msg, headers): """Return a Request or None in response to a redirect.
828023b6b5d4d84a3fc01e9907142662a33d45a6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/828023b6b5d4d84a3fc01e9907142662a33d45a6/urllib2.py
if (code in (301, 302, 303, 307) and req.method() in ("GET", "HEAD") or code in (302, 303) and req.method() == "POST"):
if "location" in headers: newurl = headers["location"] elif "uri" in headers: newurl = headers["uri"] else: return newurl = urlparse.urljoin(req.get_full_url(), newurl) m = req.get_method() if (code in (301, 302, 303, 307) and m in ("GET", "HEAD") or code in (302, 303) and m == "POST"):
def redirect_request(self, req, fp, code, msg, headers): """Return a Request or None in response to a redirect.
828023b6b5d4d84a3fc01e9907142662a33d45a6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/828023b6b5d4d84a3fc01e9907142662a33d45a6/urllib2.py
try: h = http_class(host) if req.has_data(): data = req.get_data() h.putrequest('POST', req.get_selector()) if not 'Content-type' in req.headers: h.putheader('Content-type', 'application/x-www-form-urlencoded') if not 'Content-length' in req.headers: h.putheader('Content-length', '%d' % len(data)) else: h.putrequest('GET', req.get_selector()) except socket.error, err: raise URLError(err)
h = http_class(host) if req.has_data(): data = req.get_data() h.putrequest('POST', req.get_selector()) if not 'Content-type' in req.headers: h.putheader('Content-type', 'application/x-www-form-urlencoded') if not 'Content-length' in req.headers: h.putheader('Content-length', '%d' % len(data)) else: h.putrequest('GET', req.get_selector())
def do_open(self, http_class, req): host = req.get_host() if not host: raise URLError('no host given')
828023b6b5d4d84a3fc01e9907142662a33d45a6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/828023b6b5d4d84a3fc01e9907142662a33d45a6/urllib2.py
h.endheaders()
try: h.endheaders() except socket.error, err: raise URLError(err)
def do_open(self, http_class, req): host = req.get_host() if not host: raise URLError('no host given')
828023b6b5d4d84a3fc01e9907142662a33d45a6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/828023b6b5d4d84a3fc01e9907142662a33d45a6/urllib2.py
def writeln(self, *args): if args: self.write(*args)
def writeln(self, arg=None): if arg: self.write(arg)
def writeln(self, *args): if args: self.write(*args) self.write('\n') # text-mode streams translate to \r\n if needed
91dd19db6fe426c52a30843ab2b5bc8776c8c414 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/91dd19db6fe426c52a30843ab2b5bc8776c8c414/unittest.py
def IN_CLASSA(a): return ((((in_addr_t)(a)) & 0x80000000) == 0) IN_CLASSA_NET = 0xff000000
def IN_CLASSA(a): return ((((in_addr_t)(a)) & (-2147483648)) == 0) IN_CLASSA_NET = (-16777216)
def IN_CLASSA(a): return ((((in_addr_t)(a)) & 0x80000000) == 0)
529ec6a1ee36e3af820fdac9b19228c315206093 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/529ec6a1ee36e3af820fdac9b19228c315206093/IN.py
IN_CLASSA_HOST = (0xffffffff & ~IN_CLASSA_NET)
IN_CLASSA_HOST = ((-1) & ~IN_CLASSA_NET)
def IN_CLASSA(a): return ((((in_addr_t)(a)) & 0x80000000) == 0)
529ec6a1ee36e3af820fdac9b19228c315206093 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/529ec6a1ee36e3af820fdac9b19228c315206093/IN.py
def IN_CLASSB(a): return ((((in_addr_t)(a)) & 0xc0000000) == 0x80000000) IN_CLASSB_NET = 0xffff0000
def IN_CLASSB(a): return ((((in_addr_t)(a)) & (-1073741824)) == (-2147483648)) IN_CLASSB_NET = (-65536)
def IN_CLASSB(a): return ((((in_addr_t)(a)) & 0xc0000000) == 0x80000000)
529ec6a1ee36e3af820fdac9b19228c315206093 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/529ec6a1ee36e3af820fdac9b19228c315206093/IN.py
IN_CLASSB_HOST = (0xffffffff & ~IN_CLASSB_NET)
IN_CLASSB_HOST = ((-1) & ~IN_CLASSB_NET)
def IN_CLASSB(a): return ((((in_addr_t)(a)) & 0xc0000000) == 0x80000000)
529ec6a1ee36e3af820fdac9b19228c315206093 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/529ec6a1ee36e3af820fdac9b19228c315206093/IN.py
def IN_CLASSC(a): return ((((in_addr_t)(a)) & 0xe0000000) == 0xc0000000) IN_CLASSC_NET = 0xffffff00
def IN_CLASSC(a): return ((((in_addr_t)(a)) & (-536870912)) == (-1073741824)) IN_CLASSC_NET = (-256)
def IN_CLASSC(a): return ((((in_addr_t)(a)) & 0xe0000000) == 0xc0000000)
529ec6a1ee36e3af820fdac9b19228c315206093 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/529ec6a1ee36e3af820fdac9b19228c315206093/IN.py
IN_CLASSC_HOST = (0xffffffff & ~IN_CLASSC_NET) def IN_CLASSD(a): return ((((in_addr_t)(a)) & 0xf0000000) == 0xe0000000)
IN_CLASSC_HOST = ((-1) & ~IN_CLASSC_NET) def IN_CLASSD(a): return ((((in_addr_t)(a)) & (-268435456)) == (-536870912))
def IN_CLASSC(a): return ((((in_addr_t)(a)) & 0xe0000000) == 0xc0000000)
529ec6a1ee36e3af820fdac9b19228c315206093 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/529ec6a1ee36e3af820fdac9b19228c315206093/IN.py
def IN_EXPERIMENTAL(a): return ((((in_addr_t)(a)) & 0xe0000000) == 0xe0000000) def IN_BADCLASS(a): return ((((in_addr_t)(a)) & 0xf0000000) == 0xf0000000)
def IN_EXPERIMENTAL(a): return ((((in_addr_t)(a)) & (-536870912)) == (-536870912)) def IN_BADCLASS(a): return ((((in_addr_t)(a)) & (-268435456)) == (-268435456))
def IN_EXPERIMENTAL(a): return ((((in_addr_t)(a)) & 0xe0000000) == 0xe0000000)
529ec6a1ee36e3af820fdac9b19228c315206093 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/529ec6a1ee36e3af820fdac9b19228c315206093/IN.py
PATH_MAX = 4095
PATH_MAX = 4096
def IN_BADCLASS(a): return ((((in_addr_t)(a)) & 0xf0000000) == 0xf0000000)
529ec6a1ee36e3af820fdac9b19228c315206093 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/529ec6a1ee36e3af820fdac9b19228c315206093/IN.py
SSIZE_MAX = INT_MAX
SSIZE_MAX = LONG_MAX
def IN_BADCLASS(a): return ((((in_addr_t)(a)) & 0xf0000000) == 0xf0000000)
529ec6a1ee36e3af820fdac9b19228c315206093 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/529ec6a1ee36e3af820fdac9b19228c315206093/IN.py
FILENAME_MAX = 4095
FILENAME_MAX = 4096
def IN_BADCLASS(a): return ((((in_addr_t)(a)) & 0xf0000000) == 0xf0000000)
529ec6a1ee36e3af820fdac9b19228c315206093 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/529ec6a1ee36e3af820fdac9b19228c315206093/IN.py
self.sock.connect((host, port))
try: self.sock.connect((host, port)) except socket.error: self.close() raise
def connect(self, host='localhost', port = 0): """Connect to a host on a given port.
17bfef5860493a0195c999ab44d4c849660cac30 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/17bfef5860493a0195c999ab44d4c849660cac30/smtplib.py
self._ent_handler.resolveEntity(publicId, systemId)
return self._ent_handler.resolveEntity(publicId, systemId)
def resolveEntity(self, publicId, systemId): self._ent_handler.resolveEntity(publicId, systemId)
e4772f3ada185a40232c2e2c9a74694e815c9574 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e4772f3ada185a40232c2e2c9a74694e815c9574/saxutils.py
def test(): root = Tk() def doit(root=root): d = SimpleDialog(root,
if __name__ == '__main__': def test(): root = Tk() def doit(root=root): d = SimpleDialog(root,
def test(): root = Tk() def doit(root=root): d = SimpleDialog(root, text="This is a test dialog. " "Would this have been an actual dialog, " "the buttons below would have been glowing " "in soft pink light.\n" "Do you believe this?", buttons=["Yes", "No", "Cancel"], default=0, cancel=2, title="Test Dialog") print d.go() t = Button(root, text='Test', command=doit) t.pack() q = Button(root, text='Quit', command=t.quit) q.pack() t.mainloop()
a3837a0d6394f9299e9cf5b4c67fcc705ec548ed /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a3837a0d6394f9299e9cf5b4c67fcc705ec548ed/SimpleDialog.py
print d.go() t = Button(root, text='Test', command=doit) t.pack() q = Button(root, text='Quit', command=t.quit) q.pack() t.mainloop()
print d.go() t = Button(root, text='Test', command=doit) t.pack() q = Button(root, text='Quit', command=t.quit) q.pack() t.mainloop()
def doit(root=root): d = SimpleDialog(root, text="This is a test dialog. " "Would this have been an actual dialog, " "the buttons below would have been glowing " "in soft pink light.\n" "Do you believe this?", buttons=["Yes", "No", "Cancel"], default=0, cancel=2, title="Test Dialog") print d.go()
a3837a0d6394f9299e9cf5b4c67fcc705ec548ed /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a3837a0d6394f9299e9cf5b4c67fcc705ec548ed/SimpleDialog.py
if __name__ == '__main__':
def doit(root=root): d = SimpleDialog(root, text="This is a test dialog. " "Would this have been an actual dialog, " "the buttons below would have been glowing " "in soft pink light.\n" "Do you believe this?", buttons=["Yes", "No", "Cancel"], default=0, cancel=2, title="Test Dialog") print d.go()
a3837a0d6394f9299e9cf5b4c67fcc705ec548ed /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a3837a0d6394f9299e9cf5b4c67fcc705ec548ed/SimpleDialog.py
if islink(component): resolved = os.readlink(component) (dir, file) = split(component) resolved = normpath(join(dir, resolved)) newpath = join(*([resolved] + bits[i:])) return realpath(newpath)
if islink(component): resolved = _resolve_link(component) if resolved is None: return join(*([component] + bits[i:])) else: newpath = join(*([resolved] + bits[i:])) return realpath(newpath)
def realpath(filename): """Return the canonical path of the specified filename, eliminating any
f50299c3787757bfe5d637f5de6d4b995d6beeb0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f50299c3787757bfe5d637f5de6d4b995d6beeb0/posixpath.py
if type(url) in types.StringTypes:
if type(url) is types.StringType:
def open_https(self, url, data=None): """Use HTTPS protocol.""" import httplib user_passwd = None if type(url) in types.StringTypes: host, selector = splithost(url) if host: user_passwd, host = splituser(host) host = unquote(host) realhost = host else: host, selector = url urltype, rest = splittype(selector) url = rest user_passwd = None if urltype.lower() != 'https': realhost = None else: realhost, rest = splithost(rest) if realhost: user_passwd, realhost = splituser(realhost) if user_passwd: selector = "%s://%s%s" % (urltype, realhost, rest) #print "proxy via https:", host, selector if not host: raise IOError, ('https error', 'no host given') if user_passwd: import base64 auth = base64.encodestring(user_passwd).strip() else: auth = None h = httplib.HTTPS(host, 0, key_file=self.key_file, cert_file=self.cert_file) if data is not None: h.putrequest('POST', selector) h.putheader('Content-type', 'application/x-www-form-urlencoded') h.putheader('Content-length', '%d' % len(data)) else: h.putrequest('GET', selector) if auth: h.putheader('Authorization: Basic %s' % auth) if realhost: h.putheader('Host', realhost) for args in self.addheaders: apply(h.putheader, args) h.endheaders() if data is not None: h.send(data + '\r\n') errcode, errmsg, headers = h.getreply() fp = h.getfile() if errcode == 200: return addinfourl(fp, headers, url) else: if data is None: return self.http_error(url, fp, errcode, errmsg, headers) else: return self.http_error(url, fp, errcode, errmsg, headers, data)
b2a0a838e08b6d4e1d4ceffb7df90e121a70972d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b2a0a838e08b6d4e1d4ceffb7df90e121a70972d/urllib.py
return self.dict.len()
return len(self.dict)
def __len__(self): return self.dict.len()
5f8ea10bc24be5a02f62d7d8563078f8e4e3e793 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5f8ea10bc24be5a02f62d7d8563078f8e4e3e793/shelve.py
def capwords(str, pat):
def capwords(str, pat='[^a-zA-Z0-9_]+'):
def capwords(str, pat): import string words = split(str, pat, 1) for i in range(0, len(words), 2): words[i] = string.capitalize(words[i]) return string.joinfields(words, "")
7a7d5d8fcf5ac8f9eaf8016da04984687e43dae3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7a7d5d8fcf5ac8f9eaf8016da04984687e43dae3/regsub.py
words = split(str, pat, 1)
words = splitx(str, pat)
def capwords(str, pat): import string words = split(str, pat, 1) for i in range(0, len(words), 2): words[i] = string.capitalize(words[i]) return string.joinfields(words, "")
7a7d5d8fcf5ac8f9eaf8016da04984687e43dae3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7a7d5d8fcf5ac8f9eaf8016da04984687e43dae3/regsub.py
mode = ((os.stat(file)[ST_MODE]) | 0111) & 07777
mode = ((os.stat(file)[ST_MODE]) | 0555) & 07777
def run (self): if not self.skip_build: self.run_command('build_scripts') self.outfiles = self.copy_tree(self.build_dir, self.install_dir) if os.name == 'posix': # Set the executable bits (owner, group, and world) on # all the scripts we just installed. for file in self.get_outputs(): if self.dry_run: log.info("changing mode of %s", file) else: mode = ((os.stat(file)[ST_MODE]) | 0111) & 07777 log.info("changing mode of %s to %o", file, mode) os.chmod(file, mode)
8e30bcdaaf1961e1c75d755b916b64fd577474bb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/8e30bcdaaf1961e1c75d755b916b64fd577474bb/install_scripts.py
if verbose: print 'Connecting to %s...' % host
if verbose: print 'Connecting to %s...' % `host`
def main(): global verbose, interactive, mac, rmok, nologin try: opts, args = getopt.getopt(sys.argv[1:], 'a:bil:mnp:qrs:v') except getopt.error, msg: usage(msg) login = '' passwd = '' account = '' for o, a in opts: if o == '-l': login = a if o == '-p': passwd = a if o == '-a': account = a if o == '-v': verbose = verbose + 1 if o == '-q': verbose = 0 if o == '-i': interactive = 1 if o == '-m': mac = 1; nologin = 1; skippats.append('*.o') if o == '-n': nologin = 1 if o == '-r': rmok = 1 if o == '-s': skippats.append(a) if not args: usage('hostname missing') host = args[0] remotedir = '' localdir = '' if args[1:]: remotedir = args[1] if args[2:]: localdir = args[2] if args[3:]: usage('too many arguments') # f = ftplib.FTP() if verbose: print 'Connecting to %s...' % host f.connect(host) if not nologin: if verbose: print 'Logging in as %s...' % (login or 'anonymous') f.login(login, passwd, account) if verbose: print 'OK.' pwd = f.pwd() if verbose > 1: print 'PWD =', `pwd` if remotedir: if verbose > 1: print 'cwd(%s)' % `remotedir` f.cwd(remotedir) if verbose > 1: print 'OK.' pwd = f.pwd() if verbose > 1: print 'PWD =', `pwd` # mirrorsubdir(f, localdir)
a25969620ad128c95dde9cf500b28fa3e57611c9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a25969620ad128c95dde9cf500b28fa3e57611c9/ftpmirror.py
print 'Logging in as %s...' % (login or 'anonymous')
print 'Logging in as %s...' % `login or 'anonymous'`
def main(): global verbose, interactive, mac, rmok, nologin try: opts, args = getopt.getopt(sys.argv[1:], 'a:bil:mnp:qrs:v') except getopt.error, msg: usage(msg) login = '' passwd = '' account = '' for o, a in opts: if o == '-l': login = a if o == '-p': passwd = a if o == '-a': account = a if o == '-v': verbose = verbose + 1 if o == '-q': verbose = 0 if o == '-i': interactive = 1 if o == '-m': mac = 1; nologin = 1; skippats.append('*.o') if o == '-n': nologin = 1 if o == '-r': rmok = 1 if o == '-s': skippats.append(a) if not args: usage('hostname missing') host = args[0] remotedir = '' localdir = '' if args[1:]: remotedir = args[1] if args[2:]: localdir = args[2] if args[3:]: usage('too many arguments') # f = ftplib.FTP() if verbose: print 'Connecting to %s...' % host f.connect(host) if not nologin: if verbose: print 'Logging in as %s...' % (login or 'anonymous') f.login(login, passwd, account) if verbose: print 'OK.' pwd = f.pwd() if verbose > 1: print 'PWD =', `pwd` if remotedir: if verbose > 1: print 'cwd(%s)' % `remotedir` f.cwd(remotedir) if verbose > 1: print 'OK.' pwd = f.pwd() if verbose > 1: print 'PWD =', `pwd` # mirrorsubdir(f, localdir)
a25969620ad128c95dde9cf500b28fa3e57611c9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a25969620ad128c95dde9cf500b28fa3e57611c9/ftpmirror.py
if verbose: print 'Creating local directory', localdir
if verbose: print 'Creating local directory', `localdir`
def mirrorsubdir(f, localdir): pwd = f.pwd() if localdir and not os.path.isdir(localdir): if verbose: print 'Creating local directory', localdir try: makedir(localdir) except os.error, msg: print "Failed to establish local directory", localdir return infofilename = os.path.join(localdir, '.mirrorinfo') try: text = open(infofilename, 'r').read() except IOError, msg: text = '{}' try: info = eval(text) except (SyntaxError, NameError): print 'Bad mirror info in %s' % infofilename info = {} subdirs = [] listing = [] if verbose: print 'Listing remote directory %s...' % pwd f.retrlines('LIST', listing.append) filesfound = [] for line in listing: if verbose > 1: print '-->', `line` if mac: # Mac listing has just filenames; # trailing / means subdirectory filename = string.strip(line) mode = '-' if filename[-1:] == '/': filename = filename[:-1] mode = 'd' infostuff = '' else: # Parse, assuming a UNIX listing words = string.split(line, None, 8) if len(words) < 6: if verbose > 1: print 'Skipping short line' continue filename = words[-1] if string.find(filename, " -> ") >= 0: if verbose > 1: print 'Skipping symbolic link %s' % \ filename continue infostuff = words[-5:-1] mode = words[0] skip = 0 for pat in skippats: if fnmatch(filename, pat): if verbose > 1: print 'Skip pattern', pat, print 'matches', filename skip = 1 break if skip: continue if mode[0] == 'd': if verbose > 1: print 'Remembering subdirectory', filename subdirs.append(filename) continue filesfound.append(filename) if info.has_key(filename) and info[filename] == infostuff: if verbose > 1: print 'Already have this version of', filename continue fullname = os.path.join(localdir, filename) tempname = os.path.join(localdir, '@'+filename) if interactive: doit = askabout('file', filename, pwd) if not doit: if not info.has_key(filename): info[filename] = 'Not retrieved' continue try: os.unlink(tempname) except os.error: pass try: fp = open(tempname, 'wb') except IOError, msg: print "Can't create %s: %s" % (tempname, str(msg)) continue if verbose: print 'Retrieving %s from %s as %s...' % \ (filename, pwd, fullname) if verbose: fp1 = LoggingFile(fp, 1024, sys.stdout) else: fp1 = fp t0 = time.time() try: f.retrbinary('RETR ' + filename, fp1.write, 8*1024) except ftplib.error_perm, msg: print msg t1 = time.time() bytes = fp.tell() fp.close() if fp1 != fp: fp1.close() try: os.unlink(fullname) except os.error: pass # Ignore the error try: os.rename(tempname, fullname) except os.error, msg: print "Can't rename %s to %s: %s" % (tempname, fullname, str(msg)) continue info[filename] = infostuff writedict(info, infofilename) if verbose: dt = t1 - t0 kbytes = bytes / 1024.0 print int(round(kbytes)), print 'Kbytes in', print int(round(dt)), print 'seconds', if t1 > t0: print '(~%d Kbytes/sec)' % \ int(round(kbytes/dt),) print # # Remove files from info that are no longer remote deletions = 0 for filename in info.keys(): if filename not in filesfound: if verbose: print "Removing obsolete info entry for", print filename, "in", localdir or "." del info[filename] deletions = deletions + 1 if deletions: writedict(info, infofilename) # # Remove local files that are no longer in the remote directory try: if not localdir: names = os.listdir(os.curdir) else: names = os.listdir(localdir) except os.error: names = [] for name in names: if name[0] == '.' or info.has_key(name) or name in subdirs: continue skip = 0 for pat in skippats: if fnmatch(name, pat): if verbose > 1: print 'Skip pattern', pat, print 'matches', name skip = 1 break if skip: continue fullname = os.path.join(localdir, name) if not rmok: if verbose: print 'Local file', fullname, print 'is no longer pertinent' continue if verbose: print 'Removing local file/dir', fullname remove(fullname) # # Recursively mirror subdirectories for subdir in subdirs: if interactive: doit = askabout('subdirectory', subdir, pwd) if not doit: continue if verbose: print 'Processing subdirectory', subdir localsubdir = os.path.join(localdir, subdir) pwd = f.pwd() if verbose > 1: print 'Remote directory now:', pwd print 'Remote cwd', subdir try: f.cwd(subdir) except ftplib.error_perm, msg: print "Can't chdir to", subdir, ":", msg else: if verbose: print 'Mirroring as', localsubdir mirrorsubdir(f, localsubdir) if verbose > 1: print 'Remote cwd ..' f.cwd('..') newpwd = f.pwd() if newpwd != pwd: print 'Ended up in wrong directory after cd + cd ..' print 'Giving up now.' break else: if verbose > 1: print 'OK.'
a25969620ad128c95dde9cf500b28fa3e57611c9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a25969620ad128c95dde9cf500b28fa3e57611c9/ftpmirror.py
print "Failed to establish local directory", localdir
print "Failed to establish local directory", `localdir`
def mirrorsubdir(f, localdir): pwd = f.pwd() if localdir and not os.path.isdir(localdir): if verbose: print 'Creating local directory', localdir try: makedir(localdir) except os.error, msg: print "Failed to establish local directory", localdir return infofilename = os.path.join(localdir, '.mirrorinfo') try: text = open(infofilename, 'r').read() except IOError, msg: text = '{}' try: info = eval(text) except (SyntaxError, NameError): print 'Bad mirror info in %s' % infofilename info = {} subdirs = [] listing = [] if verbose: print 'Listing remote directory %s...' % pwd f.retrlines('LIST', listing.append) filesfound = [] for line in listing: if verbose > 1: print '-->', `line` if mac: # Mac listing has just filenames; # trailing / means subdirectory filename = string.strip(line) mode = '-' if filename[-1:] == '/': filename = filename[:-1] mode = 'd' infostuff = '' else: # Parse, assuming a UNIX listing words = string.split(line, None, 8) if len(words) < 6: if verbose > 1: print 'Skipping short line' continue filename = words[-1] if string.find(filename, " -> ") >= 0: if verbose > 1: print 'Skipping symbolic link %s' % \ filename continue infostuff = words[-5:-1] mode = words[0] skip = 0 for pat in skippats: if fnmatch(filename, pat): if verbose > 1: print 'Skip pattern', pat, print 'matches', filename skip = 1 break if skip: continue if mode[0] == 'd': if verbose > 1: print 'Remembering subdirectory', filename subdirs.append(filename) continue filesfound.append(filename) if info.has_key(filename) and info[filename] == infostuff: if verbose > 1: print 'Already have this version of', filename continue fullname = os.path.join(localdir, filename) tempname = os.path.join(localdir, '@'+filename) if interactive: doit = askabout('file', filename, pwd) if not doit: if not info.has_key(filename): info[filename] = 'Not retrieved' continue try: os.unlink(tempname) except os.error: pass try: fp = open(tempname, 'wb') except IOError, msg: print "Can't create %s: %s" % (tempname, str(msg)) continue if verbose: print 'Retrieving %s from %s as %s...' % \ (filename, pwd, fullname) if verbose: fp1 = LoggingFile(fp, 1024, sys.stdout) else: fp1 = fp t0 = time.time() try: f.retrbinary('RETR ' + filename, fp1.write, 8*1024) except ftplib.error_perm, msg: print msg t1 = time.time() bytes = fp.tell() fp.close() if fp1 != fp: fp1.close() try: os.unlink(fullname) except os.error: pass # Ignore the error try: os.rename(tempname, fullname) except os.error, msg: print "Can't rename %s to %s: %s" % (tempname, fullname, str(msg)) continue info[filename] = infostuff writedict(info, infofilename) if verbose: dt = t1 - t0 kbytes = bytes / 1024.0 print int(round(kbytes)), print 'Kbytes in', print int(round(dt)), print 'seconds', if t1 > t0: print '(~%d Kbytes/sec)' % \ int(round(kbytes/dt),) print # # Remove files from info that are no longer remote deletions = 0 for filename in info.keys(): if filename not in filesfound: if verbose: print "Removing obsolete info entry for", print filename, "in", localdir or "." del info[filename] deletions = deletions + 1 if deletions: writedict(info, infofilename) # # Remove local files that are no longer in the remote directory try: if not localdir: names = os.listdir(os.curdir) else: names = os.listdir(localdir) except os.error: names = [] for name in names: if name[0] == '.' or info.has_key(name) or name in subdirs: continue skip = 0 for pat in skippats: if fnmatch(name, pat): if verbose > 1: print 'Skip pattern', pat, print 'matches', name skip = 1 break if skip: continue fullname = os.path.join(localdir, name) if not rmok: if verbose: print 'Local file', fullname, print 'is no longer pertinent' continue if verbose: print 'Removing local file/dir', fullname remove(fullname) # # Recursively mirror subdirectories for subdir in subdirs: if interactive: doit = askabout('subdirectory', subdir, pwd) if not doit: continue if verbose: print 'Processing subdirectory', subdir localsubdir = os.path.join(localdir, subdir) pwd = f.pwd() if verbose > 1: print 'Remote directory now:', pwd print 'Remote cwd', subdir try: f.cwd(subdir) except ftplib.error_perm, msg: print "Can't chdir to", subdir, ":", msg else: if verbose: print 'Mirroring as', localsubdir mirrorsubdir(f, localsubdir) if verbose > 1: print 'Remote cwd ..' f.cwd('..') newpwd = f.pwd() if newpwd != pwd: print 'Ended up in wrong directory after cd + cd ..' print 'Giving up now.' break else: if verbose > 1: print 'OK.'
a25969620ad128c95dde9cf500b28fa3e57611c9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a25969620ad128c95dde9cf500b28fa3e57611c9/ftpmirror.py
print 'Bad mirror info in %s' % infofilename
print 'Bad mirror info in %s' % `infofilename`
def mirrorsubdir(f, localdir): pwd = f.pwd() if localdir and not os.path.isdir(localdir): if verbose: print 'Creating local directory', localdir try: makedir(localdir) except os.error, msg: print "Failed to establish local directory", localdir return infofilename = os.path.join(localdir, '.mirrorinfo') try: text = open(infofilename, 'r').read() except IOError, msg: text = '{}' try: info = eval(text) except (SyntaxError, NameError): print 'Bad mirror info in %s' % infofilename info = {} subdirs = [] listing = [] if verbose: print 'Listing remote directory %s...' % pwd f.retrlines('LIST', listing.append) filesfound = [] for line in listing: if verbose > 1: print '-->', `line` if mac: # Mac listing has just filenames; # trailing / means subdirectory filename = string.strip(line) mode = '-' if filename[-1:] == '/': filename = filename[:-1] mode = 'd' infostuff = '' else: # Parse, assuming a UNIX listing words = string.split(line, None, 8) if len(words) < 6: if verbose > 1: print 'Skipping short line' continue filename = words[-1] if string.find(filename, " -> ") >= 0: if verbose > 1: print 'Skipping symbolic link %s' % \ filename continue infostuff = words[-5:-1] mode = words[0] skip = 0 for pat in skippats: if fnmatch(filename, pat): if verbose > 1: print 'Skip pattern', pat, print 'matches', filename skip = 1 break if skip: continue if mode[0] == 'd': if verbose > 1: print 'Remembering subdirectory', filename subdirs.append(filename) continue filesfound.append(filename) if info.has_key(filename) and info[filename] == infostuff: if verbose > 1: print 'Already have this version of', filename continue fullname = os.path.join(localdir, filename) tempname = os.path.join(localdir, '@'+filename) if interactive: doit = askabout('file', filename, pwd) if not doit: if not info.has_key(filename): info[filename] = 'Not retrieved' continue try: os.unlink(tempname) except os.error: pass try: fp = open(tempname, 'wb') except IOError, msg: print "Can't create %s: %s" % (tempname, str(msg)) continue if verbose: print 'Retrieving %s from %s as %s...' % \ (filename, pwd, fullname) if verbose: fp1 = LoggingFile(fp, 1024, sys.stdout) else: fp1 = fp t0 = time.time() try: f.retrbinary('RETR ' + filename, fp1.write, 8*1024) except ftplib.error_perm, msg: print msg t1 = time.time() bytes = fp.tell() fp.close() if fp1 != fp: fp1.close() try: os.unlink(fullname) except os.error: pass # Ignore the error try: os.rename(tempname, fullname) except os.error, msg: print "Can't rename %s to %s: %s" % (tempname, fullname, str(msg)) continue info[filename] = infostuff writedict(info, infofilename) if verbose: dt = t1 - t0 kbytes = bytes / 1024.0 print int(round(kbytes)), print 'Kbytes in', print int(round(dt)), print 'seconds', if t1 > t0: print '(~%d Kbytes/sec)' % \ int(round(kbytes/dt),) print # # Remove files from info that are no longer remote deletions = 0 for filename in info.keys(): if filename not in filesfound: if verbose: print "Removing obsolete info entry for", print filename, "in", localdir or "." del info[filename] deletions = deletions + 1 if deletions: writedict(info, infofilename) # # Remove local files that are no longer in the remote directory try: if not localdir: names = os.listdir(os.curdir) else: names = os.listdir(localdir) except os.error: names = [] for name in names: if name[0] == '.' or info.has_key(name) or name in subdirs: continue skip = 0 for pat in skippats: if fnmatch(name, pat): if verbose > 1: print 'Skip pattern', pat, print 'matches', name skip = 1 break if skip: continue fullname = os.path.join(localdir, name) if not rmok: if verbose: print 'Local file', fullname, print 'is no longer pertinent' continue if verbose: print 'Removing local file/dir', fullname remove(fullname) # # Recursively mirror subdirectories for subdir in subdirs: if interactive: doit = askabout('subdirectory', subdir, pwd) if not doit: continue if verbose: print 'Processing subdirectory', subdir localsubdir = os.path.join(localdir, subdir) pwd = f.pwd() if verbose > 1: print 'Remote directory now:', pwd print 'Remote cwd', subdir try: f.cwd(subdir) except ftplib.error_perm, msg: print "Can't chdir to", subdir, ":", msg else: if verbose: print 'Mirroring as', localsubdir mirrorsubdir(f, localsubdir) if verbose > 1: print 'Remote cwd ..' f.cwd('..') newpwd = f.pwd() if newpwd != pwd: print 'Ended up in wrong directory after cd + cd ..' print 'Giving up now.' break else: if verbose > 1: print 'OK.'
a25969620ad128c95dde9cf500b28fa3e57611c9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a25969620ad128c95dde9cf500b28fa3e57611c9/ftpmirror.py
if verbose: print 'Listing remote directory %s...' % pwd
if verbose: print 'Listing remote directory %s...' % `pwd`
def mirrorsubdir(f, localdir): pwd = f.pwd() if localdir and not os.path.isdir(localdir): if verbose: print 'Creating local directory', localdir try: makedir(localdir) except os.error, msg: print "Failed to establish local directory", localdir return infofilename = os.path.join(localdir, '.mirrorinfo') try: text = open(infofilename, 'r').read() except IOError, msg: text = '{}' try: info = eval(text) except (SyntaxError, NameError): print 'Bad mirror info in %s' % infofilename info = {} subdirs = [] listing = [] if verbose: print 'Listing remote directory %s...' % pwd f.retrlines('LIST', listing.append) filesfound = [] for line in listing: if verbose > 1: print '-->', `line` if mac: # Mac listing has just filenames; # trailing / means subdirectory filename = string.strip(line) mode = '-' if filename[-1:] == '/': filename = filename[:-1] mode = 'd' infostuff = '' else: # Parse, assuming a UNIX listing words = string.split(line, None, 8) if len(words) < 6: if verbose > 1: print 'Skipping short line' continue filename = words[-1] if string.find(filename, " -> ") >= 0: if verbose > 1: print 'Skipping symbolic link %s' % \ filename continue infostuff = words[-5:-1] mode = words[0] skip = 0 for pat in skippats: if fnmatch(filename, pat): if verbose > 1: print 'Skip pattern', pat, print 'matches', filename skip = 1 break if skip: continue if mode[0] == 'd': if verbose > 1: print 'Remembering subdirectory', filename subdirs.append(filename) continue filesfound.append(filename) if info.has_key(filename) and info[filename] == infostuff: if verbose > 1: print 'Already have this version of', filename continue fullname = os.path.join(localdir, filename) tempname = os.path.join(localdir, '@'+filename) if interactive: doit = askabout('file', filename, pwd) if not doit: if not info.has_key(filename): info[filename] = 'Not retrieved' continue try: os.unlink(tempname) except os.error: pass try: fp = open(tempname, 'wb') except IOError, msg: print "Can't create %s: %s" % (tempname, str(msg)) continue if verbose: print 'Retrieving %s from %s as %s...' % \ (filename, pwd, fullname) if verbose: fp1 = LoggingFile(fp, 1024, sys.stdout) else: fp1 = fp t0 = time.time() try: f.retrbinary('RETR ' + filename, fp1.write, 8*1024) except ftplib.error_perm, msg: print msg t1 = time.time() bytes = fp.tell() fp.close() if fp1 != fp: fp1.close() try: os.unlink(fullname) except os.error: pass # Ignore the error try: os.rename(tempname, fullname) except os.error, msg: print "Can't rename %s to %s: %s" % (tempname, fullname, str(msg)) continue info[filename] = infostuff writedict(info, infofilename) if verbose: dt = t1 - t0 kbytes = bytes / 1024.0 print int(round(kbytes)), print 'Kbytes in', print int(round(dt)), print 'seconds', if t1 > t0: print '(~%d Kbytes/sec)' % \ int(round(kbytes/dt),) print # # Remove files from info that are no longer remote deletions = 0 for filename in info.keys(): if filename not in filesfound: if verbose: print "Removing obsolete info entry for", print filename, "in", localdir or "." del info[filename] deletions = deletions + 1 if deletions: writedict(info, infofilename) # # Remove local files that are no longer in the remote directory try: if not localdir: names = os.listdir(os.curdir) else: names = os.listdir(localdir) except os.error: names = [] for name in names: if name[0] == '.' or info.has_key(name) or name in subdirs: continue skip = 0 for pat in skippats: if fnmatch(name, pat): if verbose > 1: print 'Skip pattern', pat, print 'matches', name skip = 1 break if skip: continue fullname = os.path.join(localdir, name) if not rmok: if verbose: print 'Local file', fullname, print 'is no longer pertinent' continue if verbose: print 'Removing local file/dir', fullname remove(fullname) # # Recursively mirror subdirectories for subdir in subdirs: if interactive: doit = askabout('subdirectory', subdir, pwd) if not doit: continue if verbose: print 'Processing subdirectory', subdir localsubdir = os.path.join(localdir, subdir) pwd = f.pwd() if verbose > 1: print 'Remote directory now:', pwd print 'Remote cwd', subdir try: f.cwd(subdir) except ftplib.error_perm, msg: print "Can't chdir to", subdir, ":", msg else: if verbose: print 'Mirroring as', localsubdir mirrorsubdir(f, localsubdir) if verbose > 1: print 'Remote cwd ..' f.cwd('..') newpwd = f.pwd() if newpwd != pwd: print 'Ended up in wrong directory after cd + cd ..' print 'Giving up now.' break else: if verbose > 1: print 'OK.'
a25969620ad128c95dde9cf500b28fa3e57611c9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a25969620ad128c95dde9cf500b28fa3e57611c9/ftpmirror.py
filename = words[-1] if string.find(filename, " -> ") >= 0:
filename = string.lstrip(words[-1]) i = string.find(filename, " -> ") if i >= 0:
def mirrorsubdir(f, localdir): pwd = f.pwd() if localdir and not os.path.isdir(localdir): if verbose: print 'Creating local directory', localdir try: makedir(localdir) except os.error, msg: print "Failed to establish local directory", localdir return infofilename = os.path.join(localdir, '.mirrorinfo') try: text = open(infofilename, 'r').read() except IOError, msg: text = '{}' try: info = eval(text) except (SyntaxError, NameError): print 'Bad mirror info in %s' % infofilename info = {} subdirs = [] listing = [] if verbose: print 'Listing remote directory %s...' % pwd f.retrlines('LIST', listing.append) filesfound = [] for line in listing: if verbose > 1: print '-->', `line` if mac: # Mac listing has just filenames; # trailing / means subdirectory filename = string.strip(line) mode = '-' if filename[-1:] == '/': filename = filename[:-1] mode = 'd' infostuff = '' else: # Parse, assuming a UNIX listing words = string.split(line, None, 8) if len(words) < 6: if verbose > 1: print 'Skipping short line' continue filename = words[-1] if string.find(filename, " -> ") >= 0: if verbose > 1: print 'Skipping symbolic link %s' % \ filename continue infostuff = words[-5:-1] mode = words[0] skip = 0 for pat in skippats: if fnmatch(filename, pat): if verbose > 1: print 'Skip pattern', pat, print 'matches', filename skip = 1 break if skip: continue if mode[0] == 'd': if verbose > 1: print 'Remembering subdirectory', filename subdirs.append(filename) continue filesfound.append(filename) if info.has_key(filename) and info[filename] == infostuff: if verbose > 1: print 'Already have this version of', filename continue fullname = os.path.join(localdir, filename) tempname = os.path.join(localdir, '@'+filename) if interactive: doit = askabout('file', filename, pwd) if not doit: if not info.has_key(filename): info[filename] = 'Not retrieved' continue try: os.unlink(tempname) except os.error: pass try: fp = open(tempname, 'wb') except IOError, msg: print "Can't create %s: %s" % (tempname, str(msg)) continue if verbose: print 'Retrieving %s from %s as %s...' % \ (filename, pwd, fullname) if verbose: fp1 = LoggingFile(fp, 1024, sys.stdout) else: fp1 = fp t0 = time.time() try: f.retrbinary('RETR ' + filename, fp1.write, 8*1024) except ftplib.error_perm, msg: print msg t1 = time.time() bytes = fp.tell() fp.close() if fp1 != fp: fp1.close() try: os.unlink(fullname) except os.error: pass # Ignore the error try: os.rename(tempname, fullname) except os.error, msg: print "Can't rename %s to %s: %s" % (tempname, fullname, str(msg)) continue info[filename] = infostuff writedict(info, infofilename) if verbose: dt = t1 - t0 kbytes = bytes / 1024.0 print int(round(kbytes)), print 'Kbytes in', print int(round(dt)), print 'seconds', if t1 > t0: print '(~%d Kbytes/sec)' % \ int(round(kbytes/dt),) print # # Remove files from info that are no longer remote deletions = 0 for filename in info.keys(): if filename not in filesfound: if verbose: print "Removing obsolete info entry for", print filename, "in", localdir or "." del info[filename] deletions = deletions + 1 if deletions: writedict(info, infofilename) # # Remove local files that are no longer in the remote directory try: if not localdir: names = os.listdir(os.curdir) else: names = os.listdir(localdir) except os.error: names = [] for name in names: if name[0] == '.' or info.has_key(name) or name in subdirs: continue skip = 0 for pat in skippats: if fnmatch(name, pat): if verbose > 1: print 'Skip pattern', pat, print 'matches', name skip = 1 break if skip: continue fullname = os.path.join(localdir, name) if not rmok: if verbose: print 'Local file', fullname, print 'is no longer pertinent' continue if verbose: print 'Removing local file/dir', fullname remove(fullname) # # Recursively mirror subdirectories for subdir in subdirs: if interactive: doit = askabout('subdirectory', subdir, pwd) if not doit: continue if verbose: print 'Processing subdirectory', subdir localsubdir = os.path.join(localdir, subdir) pwd = f.pwd() if verbose > 1: print 'Remote directory now:', pwd print 'Remote cwd', subdir try: f.cwd(subdir) except ftplib.error_perm, msg: print "Can't chdir to", subdir, ":", msg else: if verbose: print 'Mirroring as', localsubdir mirrorsubdir(f, localsubdir) if verbose > 1: print 'Remote cwd ..' f.cwd('..') newpwd = f.pwd() if newpwd != pwd: print 'Ended up in wrong directory after cd + cd ..' print 'Giving up now.' break else: if verbose > 1: print 'OK.'
a25969620ad128c95dde9cf500b28fa3e57611c9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a25969620ad128c95dde9cf500b28fa3e57611c9/ftpmirror.py
print 'Skipping symbolic link %s' % \ filename continue
print 'Found symbolic link %s' % `filename` linkto = filename[i+4:] filename = filename[:i]
def mirrorsubdir(f, localdir): pwd = f.pwd() if localdir and not os.path.isdir(localdir): if verbose: print 'Creating local directory', localdir try: makedir(localdir) except os.error, msg: print "Failed to establish local directory", localdir return infofilename = os.path.join(localdir, '.mirrorinfo') try: text = open(infofilename, 'r').read() except IOError, msg: text = '{}' try: info = eval(text) except (SyntaxError, NameError): print 'Bad mirror info in %s' % infofilename info = {} subdirs = [] listing = [] if verbose: print 'Listing remote directory %s...' % pwd f.retrlines('LIST', listing.append) filesfound = [] for line in listing: if verbose > 1: print '-->', `line` if mac: # Mac listing has just filenames; # trailing / means subdirectory filename = string.strip(line) mode = '-' if filename[-1:] == '/': filename = filename[:-1] mode = 'd' infostuff = '' else: # Parse, assuming a UNIX listing words = string.split(line, None, 8) if len(words) < 6: if verbose > 1: print 'Skipping short line' continue filename = words[-1] if string.find(filename, " -> ") >= 0: if verbose > 1: print 'Skipping symbolic link %s' % \ filename continue infostuff = words[-5:-1] mode = words[0] skip = 0 for pat in skippats: if fnmatch(filename, pat): if verbose > 1: print 'Skip pattern', pat, print 'matches', filename skip = 1 break if skip: continue if mode[0] == 'd': if verbose > 1: print 'Remembering subdirectory', filename subdirs.append(filename) continue filesfound.append(filename) if info.has_key(filename) and info[filename] == infostuff: if verbose > 1: print 'Already have this version of', filename continue fullname = os.path.join(localdir, filename) tempname = os.path.join(localdir, '@'+filename) if interactive: doit = askabout('file', filename, pwd) if not doit: if not info.has_key(filename): info[filename] = 'Not retrieved' continue try: os.unlink(tempname) except os.error: pass try: fp = open(tempname, 'wb') except IOError, msg: print "Can't create %s: %s" % (tempname, str(msg)) continue if verbose: print 'Retrieving %s from %s as %s...' % \ (filename, pwd, fullname) if verbose: fp1 = LoggingFile(fp, 1024, sys.stdout) else: fp1 = fp t0 = time.time() try: f.retrbinary('RETR ' + filename, fp1.write, 8*1024) except ftplib.error_perm, msg: print msg t1 = time.time() bytes = fp.tell() fp.close() if fp1 != fp: fp1.close() try: os.unlink(fullname) except os.error: pass # Ignore the error try: os.rename(tempname, fullname) except os.error, msg: print "Can't rename %s to %s: %s" % (tempname, fullname, str(msg)) continue info[filename] = infostuff writedict(info, infofilename) if verbose: dt = t1 - t0 kbytes = bytes / 1024.0 print int(round(kbytes)), print 'Kbytes in', print int(round(dt)), print 'seconds', if t1 > t0: print '(~%d Kbytes/sec)' % \ int(round(kbytes/dt),) print # # Remove files from info that are no longer remote deletions = 0 for filename in info.keys(): if filename not in filesfound: if verbose: print "Removing obsolete info entry for", print filename, "in", localdir or "." del info[filename] deletions = deletions + 1 if deletions: writedict(info, infofilename) # # Remove local files that are no longer in the remote directory try: if not localdir: names = os.listdir(os.curdir) else: names = os.listdir(localdir) except os.error: names = [] for name in names: if name[0] == '.' or info.has_key(name) or name in subdirs: continue skip = 0 for pat in skippats: if fnmatch(name, pat): if verbose > 1: print 'Skip pattern', pat, print 'matches', name skip = 1 break if skip: continue fullname = os.path.join(localdir, name) if not rmok: if verbose: print 'Local file', fullname, print 'is no longer pertinent' continue if verbose: print 'Removing local file/dir', fullname remove(fullname) # # Recursively mirror subdirectories for subdir in subdirs: if interactive: doit = askabout('subdirectory', subdir, pwd) if not doit: continue if verbose: print 'Processing subdirectory', subdir localsubdir = os.path.join(localdir, subdir) pwd = f.pwd() if verbose > 1: print 'Remote directory now:', pwd print 'Remote cwd', subdir try: f.cwd(subdir) except ftplib.error_perm, msg: print "Can't chdir to", subdir, ":", msg else: if verbose: print 'Mirroring as', localsubdir mirrorsubdir(f, localsubdir) if verbose > 1: print 'Remote cwd ..' f.cwd('..') newpwd = f.pwd() if newpwd != pwd: print 'Ended up in wrong directory after cd + cd ..' print 'Giving up now.' break else: if verbose > 1: print 'OK.'
a25969620ad128c95dde9cf500b28fa3e57611c9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a25969620ad128c95dde9cf500b28fa3e57611c9/ftpmirror.py
print 'Skip pattern', pat, print 'matches', filename
print 'Skip pattern', `pat`, print 'matches', `filename`
def mirrorsubdir(f, localdir): pwd = f.pwd() if localdir and not os.path.isdir(localdir): if verbose: print 'Creating local directory', localdir try: makedir(localdir) except os.error, msg: print "Failed to establish local directory", localdir return infofilename = os.path.join(localdir, '.mirrorinfo') try: text = open(infofilename, 'r').read() except IOError, msg: text = '{}' try: info = eval(text) except (SyntaxError, NameError): print 'Bad mirror info in %s' % infofilename info = {} subdirs = [] listing = [] if verbose: print 'Listing remote directory %s...' % pwd f.retrlines('LIST', listing.append) filesfound = [] for line in listing: if verbose > 1: print '-->', `line` if mac: # Mac listing has just filenames; # trailing / means subdirectory filename = string.strip(line) mode = '-' if filename[-1:] == '/': filename = filename[:-1] mode = 'd' infostuff = '' else: # Parse, assuming a UNIX listing words = string.split(line, None, 8) if len(words) < 6: if verbose > 1: print 'Skipping short line' continue filename = words[-1] if string.find(filename, " -> ") >= 0: if verbose > 1: print 'Skipping symbolic link %s' % \ filename continue infostuff = words[-5:-1] mode = words[0] skip = 0 for pat in skippats: if fnmatch(filename, pat): if verbose > 1: print 'Skip pattern', pat, print 'matches', filename skip = 1 break if skip: continue if mode[0] == 'd': if verbose > 1: print 'Remembering subdirectory', filename subdirs.append(filename) continue filesfound.append(filename) if info.has_key(filename) and info[filename] == infostuff: if verbose > 1: print 'Already have this version of', filename continue fullname = os.path.join(localdir, filename) tempname = os.path.join(localdir, '@'+filename) if interactive: doit = askabout('file', filename, pwd) if not doit: if not info.has_key(filename): info[filename] = 'Not retrieved' continue try: os.unlink(tempname) except os.error: pass try: fp = open(tempname, 'wb') except IOError, msg: print "Can't create %s: %s" % (tempname, str(msg)) continue if verbose: print 'Retrieving %s from %s as %s...' % \ (filename, pwd, fullname) if verbose: fp1 = LoggingFile(fp, 1024, sys.stdout) else: fp1 = fp t0 = time.time() try: f.retrbinary('RETR ' + filename, fp1.write, 8*1024) except ftplib.error_perm, msg: print msg t1 = time.time() bytes = fp.tell() fp.close() if fp1 != fp: fp1.close() try: os.unlink(fullname) except os.error: pass # Ignore the error try: os.rename(tempname, fullname) except os.error, msg: print "Can't rename %s to %s: %s" % (tempname, fullname, str(msg)) continue info[filename] = infostuff writedict(info, infofilename) if verbose: dt = t1 - t0 kbytes = bytes / 1024.0 print int(round(kbytes)), print 'Kbytes in', print int(round(dt)), print 'seconds', if t1 > t0: print '(~%d Kbytes/sec)' % \ int(round(kbytes/dt),) print # # Remove files from info that are no longer remote deletions = 0 for filename in info.keys(): if filename not in filesfound: if verbose: print "Removing obsolete info entry for", print filename, "in", localdir or "." del info[filename] deletions = deletions + 1 if deletions: writedict(info, infofilename) # # Remove local files that are no longer in the remote directory try: if not localdir: names = os.listdir(os.curdir) else: names = os.listdir(localdir) except os.error: names = [] for name in names: if name[0] == '.' or info.has_key(name) or name in subdirs: continue skip = 0 for pat in skippats: if fnmatch(name, pat): if verbose > 1: print 'Skip pattern', pat, print 'matches', name skip = 1 break if skip: continue fullname = os.path.join(localdir, name) if not rmok: if verbose: print 'Local file', fullname, print 'is no longer pertinent' continue if verbose: print 'Removing local file/dir', fullname remove(fullname) # # Recursively mirror subdirectories for subdir in subdirs: if interactive: doit = askabout('subdirectory', subdir, pwd) if not doit: continue if verbose: print 'Processing subdirectory', subdir localsubdir = os.path.join(localdir, subdir) pwd = f.pwd() if verbose > 1: print 'Remote directory now:', pwd print 'Remote cwd', subdir try: f.cwd(subdir) except ftplib.error_perm, msg: print "Can't chdir to", subdir, ":", msg else: if verbose: print 'Mirroring as', localsubdir mirrorsubdir(f, localsubdir) if verbose > 1: print 'Remote cwd ..' f.cwd('..') newpwd = f.pwd() if newpwd != pwd: print 'Ended up in wrong directory after cd + cd ..' print 'Giving up now.' break else: if verbose > 1: print 'OK.'
a25969620ad128c95dde9cf500b28fa3e57611c9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a25969620ad128c95dde9cf500b28fa3e57611c9/ftpmirror.py
print 'Remembering subdirectory', filename
print 'Remembering subdirectory', `filename`
def mirrorsubdir(f, localdir): pwd = f.pwd() if localdir and not os.path.isdir(localdir): if verbose: print 'Creating local directory', localdir try: makedir(localdir) except os.error, msg: print "Failed to establish local directory", localdir return infofilename = os.path.join(localdir, '.mirrorinfo') try: text = open(infofilename, 'r').read() except IOError, msg: text = '{}' try: info = eval(text) except (SyntaxError, NameError): print 'Bad mirror info in %s' % infofilename info = {} subdirs = [] listing = [] if verbose: print 'Listing remote directory %s...' % pwd f.retrlines('LIST', listing.append) filesfound = [] for line in listing: if verbose > 1: print '-->', `line` if mac: # Mac listing has just filenames; # trailing / means subdirectory filename = string.strip(line) mode = '-' if filename[-1:] == '/': filename = filename[:-1] mode = 'd' infostuff = '' else: # Parse, assuming a UNIX listing words = string.split(line, None, 8) if len(words) < 6: if verbose > 1: print 'Skipping short line' continue filename = words[-1] if string.find(filename, " -> ") >= 0: if verbose > 1: print 'Skipping symbolic link %s' % \ filename continue infostuff = words[-5:-1] mode = words[0] skip = 0 for pat in skippats: if fnmatch(filename, pat): if verbose > 1: print 'Skip pattern', pat, print 'matches', filename skip = 1 break if skip: continue if mode[0] == 'd': if verbose > 1: print 'Remembering subdirectory', filename subdirs.append(filename) continue filesfound.append(filename) if info.has_key(filename) and info[filename] == infostuff: if verbose > 1: print 'Already have this version of', filename continue fullname = os.path.join(localdir, filename) tempname = os.path.join(localdir, '@'+filename) if interactive: doit = askabout('file', filename, pwd) if not doit: if not info.has_key(filename): info[filename] = 'Not retrieved' continue try: os.unlink(tempname) except os.error: pass try: fp = open(tempname, 'wb') except IOError, msg: print "Can't create %s: %s" % (tempname, str(msg)) continue if verbose: print 'Retrieving %s from %s as %s...' % \ (filename, pwd, fullname) if verbose: fp1 = LoggingFile(fp, 1024, sys.stdout) else: fp1 = fp t0 = time.time() try: f.retrbinary('RETR ' + filename, fp1.write, 8*1024) except ftplib.error_perm, msg: print msg t1 = time.time() bytes = fp.tell() fp.close() if fp1 != fp: fp1.close() try: os.unlink(fullname) except os.error: pass # Ignore the error try: os.rename(tempname, fullname) except os.error, msg: print "Can't rename %s to %s: %s" % (tempname, fullname, str(msg)) continue info[filename] = infostuff writedict(info, infofilename) if verbose: dt = t1 - t0 kbytes = bytes / 1024.0 print int(round(kbytes)), print 'Kbytes in', print int(round(dt)), print 'seconds', if t1 > t0: print '(~%d Kbytes/sec)' % \ int(round(kbytes/dt),) print # # Remove files from info that are no longer remote deletions = 0 for filename in info.keys(): if filename not in filesfound: if verbose: print "Removing obsolete info entry for", print filename, "in", localdir or "." del info[filename] deletions = deletions + 1 if deletions: writedict(info, infofilename) # # Remove local files that are no longer in the remote directory try: if not localdir: names = os.listdir(os.curdir) else: names = os.listdir(localdir) except os.error: names = [] for name in names: if name[0] == '.' or info.has_key(name) or name in subdirs: continue skip = 0 for pat in skippats: if fnmatch(name, pat): if verbose > 1: print 'Skip pattern', pat, print 'matches', name skip = 1 break if skip: continue fullname = os.path.join(localdir, name) if not rmok: if verbose: print 'Local file', fullname, print 'is no longer pertinent' continue if verbose: print 'Removing local file/dir', fullname remove(fullname) # # Recursively mirror subdirectories for subdir in subdirs: if interactive: doit = askabout('subdirectory', subdir, pwd) if not doit: continue if verbose: print 'Processing subdirectory', subdir localsubdir = os.path.join(localdir, subdir) pwd = f.pwd() if verbose > 1: print 'Remote directory now:', pwd print 'Remote cwd', subdir try: f.cwd(subdir) except ftplib.error_perm, msg: print "Can't chdir to", subdir, ":", msg else: if verbose: print 'Mirroring as', localsubdir mirrorsubdir(f, localsubdir) if verbose > 1: print 'Remote cwd ..' f.cwd('..') newpwd = f.pwd() if newpwd != pwd: print 'Ended up in wrong directory after cd + cd ..' print 'Giving up now.' break else: if verbose > 1: print 'OK.'
a25969620ad128c95dde9cf500b28fa3e57611c9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a25969620ad128c95dde9cf500b28fa3e57611c9/ftpmirror.py
print 'Already have this version of', filename
print 'Already have this version of',`filename`
def mirrorsubdir(f, localdir): pwd = f.pwd() if localdir and not os.path.isdir(localdir): if verbose: print 'Creating local directory', localdir try: makedir(localdir) except os.error, msg: print "Failed to establish local directory", localdir return infofilename = os.path.join(localdir, '.mirrorinfo') try: text = open(infofilename, 'r').read() except IOError, msg: text = '{}' try: info = eval(text) except (SyntaxError, NameError): print 'Bad mirror info in %s' % infofilename info = {} subdirs = [] listing = [] if verbose: print 'Listing remote directory %s...' % pwd f.retrlines('LIST', listing.append) filesfound = [] for line in listing: if verbose > 1: print '-->', `line` if mac: # Mac listing has just filenames; # trailing / means subdirectory filename = string.strip(line) mode = '-' if filename[-1:] == '/': filename = filename[:-1] mode = 'd' infostuff = '' else: # Parse, assuming a UNIX listing words = string.split(line, None, 8) if len(words) < 6: if verbose > 1: print 'Skipping short line' continue filename = words[-1] if string.find(filename, " -> ") >= 0: if verbose > 1: print 'Skipping symbolic link %s' % \ filename continue infostuff = words[-5:-1] mode = words[0] skip = 0 for pat in skippats: if fnmatch(filename, pat): if verbose > 1: print 'Skip pattern', pat, print 'matches', filename skip = 1 break if skip: continue if mode[0] == 'd': if verbose > 1: print 'Remembering subdirectory', filename subdirs.append(filename) continue filesfound.append(filename) if info.has_key(filename) and info[filename] == infostuff: if verbose > 1: print 'Already have this version of', filename continue fullname = os.path.join(localdir, filename) tempname = os.path.join(localdir, '@'+filename) if interactive: doit = askabout('file', filename, pwd) if not doit: if not info.has_key(filename): info[filename] = 'Not retrieved' continue try: os.unlink(tempname) except os.error: pass try: fp = open(tempname, 'wb') except IOError, msg: print "Can't create %s: %s" % (tempname, str(msg)) continue if verbose: print 'Retrieving %s from %s as %s...' % \ (filename, pwd, fullname) if verbose: fp1 = LoggingFile(fp, 1024, sys.stdout) else: fp1 = fp t0 = time.time() try: f.retrbinary('RETR ' + filename, fp1.write, 8*1024) except ftplib.error_perm, msg: print msg t1 = time.time() bytes = fp.tell() fp.close() if fp1 != fp: fp1.close() try: os.unlink(fullname) except os.error: pass # Ignore the error try: os.rename(tempname, fullname) except os.error, msg: print "Can't rename %s to %s: %s" % (tempname, fullname, str(msg)) continue info[filename] = infostuff writedict(info, infofilename) if verbose: dt = t1 - t0 kbytes = bytes / 1024.0 print int(round(kbytes)), print 'Kbytes in', print int(round(dt)), print 'seconds', if t1 > t0: print '(~%d Kbytes/sec)' % \ int(round(kbytes/dt),) print # # Remove files from info that are no longer remote deletions = 0 for filename in info.keys(): if filename not in filesfound: if verbose: print "Removing obsolete info entry for", print filename, "in", localdir or "." del info[filename] deletions = deletions + 1 if deletions: writedict(info, infofilename) # # Remove local files that are no longer in the remote directory try: if not localdir: names = os.listdir(os.curdir) else: names = os.listdir(localdir) except os.error: names = [] for name in names: if name[0] == '.' or info.has_key(name) or name in subdirs: continue skip = 0 for pat in skippats: if fnmatch(name, pat): if verbose > 1: print 'Skip pattern', pat, print 'matches', name skip = 1 break if skip: continue fullname = os.path.join(localdir, name) if not rmok: if verbose: print 'Local file', fullname, print 'is no longer pertinent' continue if verbose: print 'Removing local file/dir', fullname remove(fullname) # # Recursively mirror subdirectories for subdir in subdirs: if interactive: doit = askabout('subdirectory', subdir, pwd) if not doit: continue if verbose: print 'Processing subdirectory', subdir localsubdir = os.path.join(localdir, subdir) pwd = f.pwd() if verbose > 1: print 'Remote directory now:', pwd print 'Remote cwd', subdir try: f.cwd(subdir) except ftplib.error_perm, msg: print "Can't chdir to", subdir, ":", msg else: if verbose: print 'Mirroring as', localsubdir mirrorsubdir(f, localsubdir) if verbose > 1: print 'Remote cwd ..' f.cwd('..') newpwd = f.pwd() if newpwd != pwd: print 'Ended up in wrong directory after cd + cd ..' print 'Giving up now.' break else: if verbose > 1: print 'OK.'
a25969620ad128c95dde9cf500b28fa3e57611c9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a25969620ad128c95dde9cf500b28fa3e57611c9/ftpmirror.py
try: fp = open(tempname, 'wb') except IOError, msg: print "Can't create %s: %s" % (tempname, str(msg)) continue if verbose: print 'Retrieving %s from %s as %s...' % \ (filename, pwd, fullname) if verbose: fp1 = LoggingFile(fp, 1024, sys.stdout)
if mode[0] == 'l': if verbose: print "Creating symlink %s -> %s" % ( `filename`, `linkto`) try: os.symlink(linkto, tempname) except IOError, msg: print "Can't create %s: %s" % ( `tempname`, str(msg)) continue
def mirrorsubdir(f, localdir): pwd = f.pwd() if localdir and not os.path.isdir(localdir): if verbose: print 'Creating local directory', localdir try: makedir(localdir) except os.error, msg: print "Failed to establish local directory", localdir return infofilename = os.path.join(localdir, '.mirrorinfo') try: text = open(infofilename, 'r').read() except IOError, msg: text = '{}' try: info = eval(text) except (SyntaxError, NameError): print 'Bad mirror info in %s' % infofilename info = {} subdirs = [] listing = [] if verbose: print 'Listing remote directory %s...' % pwd f.retrlines('LIST', listing.append) filesfound = [] for line in listing: if verbose > 1: print '-->', `line` if mac: # Mac listing has just filenames; # trailing / means subdirectory filename = string.strip(line) mode = '-' if filename[-1:] == '/': filename = filename[:-1] mode = 'd' infostuff = '' else: # Parse, assuming a UNIX listing words = string.split(line, None, 8) if len(words) < 6: if verbose > 1: print 'Skipping short line' continue filename = words[-1] if string.find(filename, " -> ") >= 0: if verbose > 1: print 'Skipping symbolic link %s' % \ filename continue infostuff = words[-5:-1] mode = words[0] skip = 0 for pat in skippats: if fnmatch(filename, pat): if verbose > 1: print 'Skip pattern', pat, print 'matches', filename skip = 1 break if skip: continue if mode[0] == 'd': if verbose > 1: print 'Remembering subdirectory', filename subdirs.append(filename) continue filesfound.append(filename) if info.has_key(filename) and info[filename] == infostuff: if verbose > 1: print 'Already have this version of', filename continue fullname = os.path.join(localdir, filename) tempname = os.path.join(localdir, '@'+filename) if interactive: doit = askabout('file', filename, pwd) if not doit: if not info.has_key(filename): info[filename] = 'Not retrieved' continue try: os.unlink(tempname) except os.error: pass try: fp = open(tempname, 'wb') except IOError, msg: print "Can't create %s: %s" % (tempname, str(msg)) continue if verbose: print 'Retrieving %s from %s as %s...' % \ (filename, pwd, fullname) if verbose: fp1 = LoggingFile(fp, 1024, sys.stdout) else: fp1 = fp t0 = time.time() try: f.retrbinary('RETR ' + filename, fp1.write, 8*1024) except ftplib.error_perm, msg: print msg t1 = time.time() bytes = fp.tell() fp.close() if fp1 != fp: fp1.close() try: os.unlink(fullname) except os.error: pass # Ignore the error try: os.rename(tempname, fullname) except os.error, msg: print "Can't rename %s to %s: %s" % (tempname, fullname, str(msg)) continue info[filename] = infostuff writedict(info, infofilename) if verbose: dt = t1 - t0 kbytes = bytes / 1024.0 print int(round(kbytes)), print 'Kbytes in', print int(round(dt)), print 'seconds', if t1 > t0: print '(~%d Kbytes/sec)' % \ int(round(kbytes/dt),) print # # Remove files from info that are no longer remote deletions = 0 for filename in info.keys(): if filename not in filesfound: if verbose: print "Removing obsolete info entry for", print filename, "in", localdir or "." del info[filename] deletions = deletions + 1 if deletions: writedict(info, infofilename) # # Remove local files that are no longer in the remote directory try: if not localdir: names = os.listdir(os.curdir) else: names = os.listdir(localdir) except os.error: names = [] for name in names: if name[0] == '.' or info.has_key(name) or name in subdirs: continue skip = 0 for pat in skippats: if fnmatch(name, pat): if verbose > 1: print 'Skip pattern', pat, print 'matches', name skip = 1 break if skip: continue fullname = os.path.join(localdir, name) if not rmok: if verbose: print 'Local file', fullname, print 'is no longer pertinent' continue if verbose: print 'Removing local file/dir', fullname remove(fullname) # # Recursively mirror subdirectories for subdir in subdirs: if interactive: doit = askabout('subdirectory', subdir, pwd) if not doit: continue if verbose: print 'Processing subdirectory', subdir localsubdir = os.path.join(localdir, subdir) pwd = f.pwd() if verbose > 1: print 'Remote directory now:', pwd print 'Remote cwd', subdir try: f.cwd(subdir) except ftplib.error_perm, msg: print "Can't chdir to", subdir, ":", msg else: if verbose: print 'Mirroring as', localsubdir mirrorsubdir(f, localsubdir) if verbose > 1: print 'Remote cwd ..' f.cwd('..') newpwd = f.pwd() if newpwd != pwd: print 'Ended up in wrong directory after cd + cd ..' print 'Giving up now.' break else: if verbose > 1: print 'OK.'
a25969620ad128c95dde9cf500b28fa3e57611c9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a25969620ad128c95dde9cf500b28fa3e57611c9/ftpmirror.py
fp1 = fp t0 = time.time() try: f.retrbinary('RETR ' + filename, fp1.write, 8*1024) except ftplib.error_perm, msg: print msg t1 = time.time() bytes = fp.tell() fp.close() if fp1 != fp: fp1.close()
try: fp = open(tempname, 'wb') except IOError, msg: print "Can't create %s: %s" % ( `tempname`, str(msg)) continue if verbose: print 'Retrieving %s from %s as %s...' % \ (`filename`, `pwd`, `fullname`) if verbose: fp1 = LoggingFile(fp, 1024, sys.stdout) else: fp1 = fp t0 = time.time() try: f.retrbinary('RETR ' + filename, fp1.write, 8*1024) except ftplib.error_perm, msg: print msg t1 = time.time() bytes = fp.tell() fp.close() if fp1 != fp: fp1.close()
def mirrorsubdir(f, localdir): pwd = f.pwd() if localdir and not os.path.isdir(localdir): if verbose: print 'Creating local directory', localdir try: makedir(localdir) except os.error, msg: print "Failed to establish local directory", localdir return infofilename = os.path.join(localdir, '.mirrorinfo') try: text = open(infofilename, 'r').read() except IOError, msg: text = '{}' try: info = eval(text) except (SyntaxError, NameError): print 'Bad mirror info in %s' % infofilename info = {} subdirs = [] listing = [] if verbose: print 'Listing remote directory %s...' % pwd f.retrlines('LIST', listing.append) filesfound = [] for line in listing: if verbose > 1: print '-->', `line` if mac: # Mac listing has just filenames; # trailing / means subdirectory filename = string.strip(line) mode = '-' if filename[-1:] == '/': filename = filename[:-1] mode = 'd' infostuff = '' else: # Parse, assuming a UNIX listing words = string.split(line, None, 8) if len(words) < 6: if verbose > 1: print 'Skipping short line' continue filename = words[-1] if string.find(filename, " -> ") >= 0: if verbose > 1: print 'Skipping symbolic link %s' % \ filename continue infostuff = words[-5:-1] mode = words[0] skip = 0 for pat in skippats: if fnmatch(filename, pat): if verbose > 1: print 'Skip pattern', pat, print 'matches', filename skip = 1 break if skip: continue if mode[0] == 'd': if verbose > 1: print 'Remembering subdirectory', filename subdirs.append(filename) continue filesfound.append(filename) if info.has_key(filename) and info[filename] == infostuff: if verbose > 1: print 'Already have this version of', filename continue fullname = os.path.join(localdir, filename) tempname = os.path.join(localdir, '@'+filename) if interactive: doit = askabout('file', filename, pwd) if not doit: if not info.has_key(filename): info[filename] = 'Not retrieved' continue try: os.unlink(tempname) except os.error: pass try: fp = open(tempname, 'wb') except IOError, msg: print "Can't create %s: %s" % (tempname, str(msg)) continue if verbose: print 'Retrieving %s from %s as %s...' % \ (filename, pwd, fullname) if verbose: fp1 = LoggingFile(fp, 1024, sys.stdout) else: fp1 = fp t0 = time.time() try: f.retrbinary('RETR ' + filename, fp1.write, 8*1024) except ftplib.error_perm, msg: print msg t1 = time.time() bytes = fp.tell() fp.close() if fp1 != fp: fp1.close() try: os.unlink(fullname) except os.error: pass # Ignore the error try: os.rename(tempname, fullname) except os.error, msg: print "Can't rename %s to %s: %s" % (tempname, fullname, str(msg)) continue info[filename] = infostuff writedict(info, infofilename) if verbose: dt = t1 - t0 kbytes = bytes / 1024.0 print int(round(kbytes)), print 'Kbytes in', print int(round(dt)), print 'seconds', if t1 > t0: print '(~%d Kbytes/sec)' % \ int(round(kbytes/dt),) print # # Remove files from info that are no longer remote deletions = 0 for filename in info.keys(): if filename not in filesfound: if verbose: print "Removing obsolete info entry for", print filename, "in", localdir or "." del info[filename] deletions = deletions + 1 if deletions: writedict(info, infofilename) # # Remove local files that are no longer in the remote directory try: if not localdir: names = os.listdir(os.curdir) else: names = os.listdir(localdir) except os.error: names = [] for name in names: if name[0] == '.' or info.has_key(name) or name in subdirs: continue skip = 0 for pat in skippats: if fnmatch(name, pat): if verbose > 1: print 'Skip pattern', pat, print 'matches', name skip = 1 break if skip: continue fullname = os.path.join(localdir, name) if not rmok: if verbose: print 'Local file', fullname, print 'is no longer pertinent' continue if verbose: print 'Removing local file/dir', fullname remove(fullname) # # Recursively mirror subdirectories for subdir in subdirs: if interactive: doit = askabout('subdirectory', subdir, pwd) if not doit: continue if verbose: print 'Processing subdirectory', subdir localsubdir = os.path.join(localdir, subdir) pwd = f.pwd() if verbose > 1: print 'Remote directory now:', pwd print 'Remote cwd', subdir try: f.cwd(subdir) except ftplib.error_perm, msg: print "Can't chdir to", subdir, ":", msg else: if verbose: print 'Mirroring as', localsubdir mirrorsubdir(f, localsubdir) if verbose > 1: print 'Remote cwd ..' f.cwd('..') newpwd = f.pwd() if newpwd != pwd: print 'Ended up in wrong directory after cd + cd ..' print 'Giving up now.' break else: if verbose > 1: print 'OK.'
a25969620ad128c95dde9cf500b28fa3e57611c9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a25969620ad128c95dde9cf500b28fa3e57611c9/ftpmirror.py
print "Can't rename %s to %s: %s" % (tempname, fullname,
print "Can't rename %s to %s: %s" % (`tempname`, `fullname`,
def mirrorsubdir(f, localdir): pwd = f.pwd() if localdir and not os.path.isdir(localdir): if verbose: print 'Creating local directory', localdir try: makedir(localdir) except os.error, msg: print "Failed to establish local directory", localdir return infofilename = os.path.join(localdir, '.mirrorinfo') try: text = open(infofilename, 'r').read() except IOError, msg: text = '{}' try: info = eval(text) except (SyntaxError, NameError): print 'Bad mirror info in %s' % infofilename info = {} subdirs = [] listing = [] if verbose: print 'Listing remote directory %s...' % pwd f.retrlines('LIST', listing.append) filesfound = [] for line in listing: if verbose > 1: print '-->', `line` if mac: # Mac listing has just filenames; # trailing / means subdirectory filename = string.strip(line) mode = '-' if filename[-1:] == '/': filename = filename[:-1] mode = 'd' infostuff = '' else: # Parse, assuming a UNIX listing words = string.split(line, None, 8) if len(words) < 6: if verbose > 1: print 'Skipping short line' continue filename = words[-1] if string.find(filename, " -> ") >= 0: if verbose > 1: print 'Skipping symbolic link %s' % \ filename continue infostuff = words[-5:-1] mode = words[0] skip = 0 for pat in skippats: if fnmatch(filename, pat): if verbose > 1: print 'Skip pattern', pat, print 'matches', filename skip = 1 break if skip: continue if mode[0] == 'd': if verbose > 1: print 'Remembering subdirectory', filename subdirs.append(filename) continue filesfound.append(filename) if info.has_key(filename) and info[filename] == infostuff: if verbose > 1: print 'Already have this version of', filename continue fullname = os.path.join(localdir, filename) tempname = os.path.join(localdir, '@'+filename) if interactive: doit = askabout('file', filename, pwd) if not doit: if not info.has_key(filename): info[filename] = 'Not retrieved' continue try: os.unlink(tempname) except os.error: pass try: fp = open(tempname, 'wb') except IOError, msg: print "Can't create %s: %s" % (tempname, str(msg)) continue if verbose: print 'Retrieving %s from %s as %s...' % \ (filename, pwd, fullname) if verbose: fp1 = LoggingFile(fp, 1024, sys.stdout) else: fp1 = fp t0 = time.time() try: f.retrbinary('RETR ' + filename, fp1.write, 8*1024) except ftplib.error_perm, msg: print msg t1 = time.time() bytes = fp.tell() fp.close() if fp1 != fp: fp1.close() try: os.unlink(fullname) except os.error: pass # Ignore the error try: os.rename(tempname, fullname) except os.error, msg: print "Can't rename %s to %s: %s" % (tempname, fullname, str(msg)) continue info[filename] = infostuff writedict(info, infofilename) if verbose: dt = t1 - t0 kbytes = bytes / 1024.0 print int(round(kbytes)), print 'Kbytes in', print int(round(dt)), print 'seconds', if t1 > t0: print '(~%d Kbytes/sec)' % \ int(round(kbytes/dt),) print # # Remove files from info that are no longer remote deletions = 0 for filename in info.keys(): if filename not in filesfound: if verbose: print "Removing obsolete info entry for", print filename, "in", localdir or "." del info[filename] deletions = deletions + 1 if deletions: writedict(info, infofilename) # # Remove local files that are no longer in the remote directory try: if not localdir: names = os.listdir(os.curdir) else: names = os.listdir(localdir) except os.error: names = [] for name in names: if name[0] == '.' or info.has_key(name) or name in subdirs: continue skip = 0 for pat in skippats: if fnmatch(name, pat): if verbose > 1: print 'Skip pattern', pat, print 'matches', name skip = 1 break if skip: continue fullname = os.path.join(localdir, name) if not rmok: if verbose: print 'Local file', fullname, print 'is no longer pertinent' continue if verbose: print 'Removing local file/dir', fullname remove(fullname) # # Recursively mirror subdirectories for subdir in subdirs: if interactive: doit = askabout('subdirectory', subdir, pwd) if not doit: continue if verbose: print 'Processing subdirectory', subdir localsubdir = os.path.join(localdir, subdir) pwd = f.pwd() if verbose > 1: print 'Remote directory now:', pwd print 'Remote cwd', subdir try: f.cwd(subdir) except ftplib.error_perm, msg: print "Can't chdir to", subdir, ":", msg else: if verbose: print 'Mirroring as', localsubdir mirrorsubdir(f, localsubdir) if verbose > 1: print 'Remote cwd ..' f.cwd('..') newpwd = f.pwd() if newpwd != pwd: print 'Ended up in wrong directory after cd + cd ..' print 'Giving up now.' break else: if verbose > 1: print 'OK.'
a25969620ad128c95dde9cf500b28fa3e57611c9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a25969620ad128c95dde9cf500b28fa3e57611c9/ftpmirror.py
if verbose:
if verbose and mode[0] != 'l':
def mirrorsubdir(f, localdir): pwd = f.pwd() if localdir and not os.path.isdir(localdir): if verbose: print 'Creating local directory', localdir try: makedir(localdir) except os.error, msg: print "Failed to establish local directory", localdir return infofilename = os.path.join(localdir, '.mirrorinfo') try: text = open(infofilename, 'r').read() except IOError, msg: text = '{}' try: info = eval(text) except (SyntaxError, NameError): print 'Bad mirror info in %s' % infofilename info = {} subdirs = [] listing = [] if verbose: print 'Listing remote directory %s...' % pwd f.retrlines('LIST', listing.append) filesfound = [] for line in listing: if verbose > 1: print '-->', `line` if mac: # Mac listing has just filenames; # trailing / means subdirectory filename = string.strip(line) mode = '-' if filename[-1:] == '/': filename = filename[:-1] mode = 'd' infostuff = '' else: # Parse, assuming a UNIX listing words = string.split(line, None, 8) if len(words) < 6: if verbose > 1: print 'Skipping short line' continue filename = words[-1] if string.find(filename, " -> ") >= 0: if verbose > 1: print 'Skipping symbolic link %s' % \ filename continue infostuff = words[-5:-1] mode = words[0] skip = 0 for pat in skippats: if fnmatch(filename, pat): if verbose > 1: print 'Skip pattern', pat, print 'matches', filename skip = 1 break if skip: continue if mode[0] == 'd': if verbose > 1: print 'Remembering subdirectory', filename subdirs.append(filename) continue filesfound.append(filename) if info.has_key(filename) and info[filename] == infostuff: if verbose > 1: print 'Already have this version of', filename continue fullname = os.path.join(localdir, filename) tempname = os.path.join(localdir, '@'+filename) if interactive: doit = askabout('file', filename, pwd) if not doit: if not info.has_key(filename): info[filename] = 'Not retrieved' continue try: os.unlink(tempname) except os.error: pass try: fp = open(tempname, 'wb') except IOError, msg: print "Can't create %s: %s" % (tempname, str(msg)) continue if verbose: print 'Retrieving %s from %s as %s...' % \ (filename, pwd, fullname) if verbose: fp1 = LoggingFile(fp, 1024, sys.stdout) else: fp1 = fp t0 = time.time() try: f.retrbinary('RETR ' + filename, fp1.write, 8*1024) except ftplib.error_perm, msg: print msg t1 = time.time() bytes = fp.tell() fp.close() if fp1 != fp: fp1.close() try: os.unlink(fullname) except os.error: pass # Ignore the error try: os.rename(tempname, fullname) except os.error, msg: print "Can't rename %s to %s: %s" % (tempname, fullname, str(msg)) continue info[filename] = infostuff writedict(info, infofilename) if verbose: dt = t1 - t0 kbytes = bytes / 1024.0 print int(round(kbytes)), print 'Kbytes in', print int(round(dt)), print 'seconds', if t1 > t0: print '(~%d Kbytes/sec)' % \ int(round(kbytes/dt),) print # # Remove files from info that are no longer remote deletions = 0 for filename in info.keys(): if filename not in filesfound: if verbose: print "Removing obsolete info entry for", print filename, "in", localdir or "." del info[filename] deletions = deletions + 1 if deletions: writedict(info, infofilename) # # Remove local files that are no longer in the remote directory try: if not localdir: names = os.listdir(os.curdir) else: names = os.listdir(localdir) except os.error: names = [] for name in names: if name[0] == '.' or info.has_key(name) or name in subdirs: continue skip = 0 for pat in skippats: if fnmatch(name, pat): if verbose > 1: print 'Skip pattern', pat, print 'matches', name skip = 1 break if skip: continue fullname = os.path.join(localdir, name) if not rmok: if verbose: print 'Local file', fullname, print 'is no longer pertinent' continue if verbose: print 'Removing local file/dir', fullname remove(fullname) # # Recursively mirror subdirectories for subdir in subdirs: if interactive: doit = askabout('subdirectory', subdir, pwd) if not doit: continue if verbose: print 'Processing subdirectory', subdir localsubdir = os.path.join(localdir, subdir) pwd = f.pwd() if verbose > 1: print 'Remote directory now:', pwd print 'Remote cwd', subdir try: f.cwd(subdir) except ftplib.error_perm, msg: print "Can't chdir to", subdir, ":", msg else: if verbose: print 'Mirroring as', localsubdir mirrorsubdir(f, localsubdir) if verbose > 1: print 'Remote cwd ..' f.cwd('..') newpwd = f.pwd() if newpwd != pwd: print 'Ended up in wrong directory after cd + cd ..' print 'Giving up now.' break else: if verbose > 1: print 'OK.'
a25969620ad128c95dde9cf500b28fa3e57611c9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a25969620ad128c95dde9cf500b28fa3e57611c9/ftpmirror.py
print filename, "in", localdir or "."
print `filename`, "in", `localdir or "."`
def mirrorsubdir(f, localdir): pwd = f.pwd() if localdir and not os.path.isdir(localdir): if verbose: print 'Creating local directory', localdir try: makedir(localdir) except os.error, msg: print "Failed to establish local directory", localdir return infofilename = os.path.join(localdir, '.mirrorinfo') try: text = open(infofilename, 'r').read() except IOError, msg: text = '{}' try: info = eval(text) except (SyntaxError, NameError): print 'Bad mirror info in %s' % infofilename info = {} subdirs = [] listing = [] if verbose: print 'Listing remote directory %s...' % pwd f.retrlines('LIST', listing.append) filesfound = [] for line in listing: if verbose > 1: print '-->', `line` if mac: # Mac listing has just filenames; # trailing / means subdirectory filename = string.strip(line) mode = '-' if filename[-1:] == '/': filename = filename[:-1] mode = 'd' infostuff = '' else: # Parse, assuming a UNIX listing words = string.split(line, None, 8) if len(words) < 6: if verbose > 1: print 'Skipping short line' continue filename = words[-1] if string.find(filename, " -> ") >= 0: if verbose > 1: print 'Skipping symbolic link %s' % \ filename continue infostuff = words[-5:-1] mode = words[0] skip = 0 for pat in skippats: if fnmatch(filename, pat): if verbose > 1: print 'Skip pattern', pat, print 'matches', filename skip = 1 break if skip: continue if mode[0] == 'd': if verbose > 1: print 'Remembering subdirectory', filename subdirs.append(filename) continue filesfound.append(filename) if info.has_key(filename) and info[filename] == infostuff: if verbose > 1: print 'Already have this version of', filename continue fullname = os.path.join(localdir, filename) tempname = os.path.join(localdir, '@'+filename) if interactive: doit = askabout('file', filename, pwd) if not doit: if not info.has_key(filename): info[filename] = 'Not retrieved' continue try: os.unlink(tempname) except os.error: pass try: fp = open(tempname, 'wb') except IOError, msg: print "Can't create %s: %s" % (tempname, str(msg)) continue if verbose: print 'Retrieving %s from %s as %s...' % \ (filename, pwd, fullname) if verbose: fp1 = LoggingFile(fp, 1024, sys.stdout) else: fp1 = fp t0 = time.time() try: f.retrbinary('RETR ' + filename, fp1.write, 8*1024) except ftplib.error_perm, msg: print msg t1 = time.time() bytes = fp.tell() fp.close() if fp1 != fp: fp1.close() try: os.unlink(fullname) except os.error: pass # Ignore the error try: os.rename(tempname, fullname) except os.error, msg: print "Can't rename %s to %s: %s" % (tempname, fullname, str(msg)) continue info[filename] = infostuff writedict(info, infofilename) if verbose: dt = t1 - t0 kbytes = bytes / 1024.0 print int(round(kbytes)), print 'Kbytes in', print int(round(dt)), print 'seconds', if t1 > t0: print '(~%d Kbytes/sec)' % \ int(round(kbytes/dt),) print # # Remove files from info that are no longer remote deletions = 0 for filename in info.keys(): if filename not in filesfound: if verbose: print "Removing obsolete info entry for", print filename, "in", localdir or "." del info[filename] deletions = deletions + 1 if deletions: writedict(info, infofilename) # # Remove local files that are no longer in the remote directory try: if not localdir: names = os.listdir(os.curdir) else: names = os.listdir(localdir) except os.error: names = [] for name in names: if name[0] == '.' or info.has_key(name) or name in subdirs: continue skip = 0 for pat in skippats: if fnmatch(name, pat): if verbose > 1: print 'Skip pattern', pat, print 'matches', name skip = 1 break if skip: continue fullname = os.path.join(localdir, name) if not rmok: if verbose: print 'Local file', fullname, print 'is no longer pertinent' continue if verbose: print 'Removing local file/dir', fullname remove(fullname) # # Recursively mirror subdirectories for subdir in subdirs: if interactive: doit = askabout('subdirectory', subdir, pwd) if not doit: continue if verbose: print 'Processing subdirectory', subdir localsubdir = os.path.join(localdir, subdir) pwd = f.pwd() if verbose > 1: print 'Remote directory now:', pwd print 'Remote cwd', subdir try: f.cwd(subdir) except ftplib.error_perm, msg: print "Can't chdir to", subdir, ":", msg else: if verbose: print 'Mirroring as', localsubdir mirrorsubdir(f, localsubdir) if verbose > 1: print 'Remote cwd ..' f.cwd('..') newpwd = f.pwd() if newpwd != pwd: print 'Ended up in wrong directory after cd + cd ..' print 'Giving up now.' break else: if verbose > 1: print 'OK.'
a25969620ad128c95dde9cf500b28fa3e57611c9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a25969620ad128c95dde9cf500b28fa3e57611c9/ftpmirror.py
print 'Skip pattern', pat, print 'matches', name
print 'Skip pattern', `pat`, print 'matches', `name`
def mirrorsubdir(f, localdir): pwd = f.pwd() if localdir and not os.path.isdir(localdir): if verbose: print 'Creating local directory', localdir try: makedir(localdir) except os.error, msg: print "Failed to establish local directory", localdir return infofilename = os.path.join(localdir, '.mirrorinfo') try: text = open(infofilename, 'r').read() except IOError, msg: text = '{}' try: info = eval(text) except (SyntaxError, NameError): print 'Bad mirror info in %s' % infofilename info = {} subdirs = [] listing = [] if verbose: print 'Listing remote directory %s...' % pwd f.retrlines('LIST', listing.append) filesfound = [] for line in listing: if verbose > 1: print '-->', `line` if mac: # Mac listing has just filenames; # trailing / means subdirectory filename = string.strip(line) mode = '-' if filename[-1:] == '/': filename = filename[:-1] mode = 'd' infostuff = '' else: # Parse, assuming a UNIX listing words = string.split(line, None, 8) if len(words) < 6: if verbose > 1: print 'Skipping short line' continue filename = words[-1] if string.find(filename, " -> ") >= 0: if verbose > 1: print 'Skipping symbolic link %s' % \ filename continue infostuff = words[-5:-1] mode = words[0] skip = 0 for pat in skippats: if fnmatch(filename, pat): if verbose > 1: print 'Skip pattern', pat, print 'matches', filename skip = 1 break if skip: continue if mode[0] == 'd': if verbose > 1: print 'Remembering subdirectory', filename subdirs.append(filename) continue filesfound.append(filename) if info.has_key(filename) and info[filename] == infostuff: if verbose > 1: print 'Already have this version of', filename continue fullname = os.path.join(localdir, filename) tempname = os.path.join(localdir, '@'+filename) if interactive: doit = askabout('file', filename, pwd) if not doit: if not info.has_key(filename): info[filename] = 'Not retrieved' continue try: os.unlink(tempname) except os.error: pass try: fp = open(tempname, 'wb') except IOError, msg: print "Can't create %s: %s" % (tempname, str(msg)) continue if verbose: print 'Retrieving %s from %s as %s...' % \ (filename, pwd, fullname) if verbose: fp1 = LoggingFile(fp, 1024, sys.stdout) else: fp1 = fp t0 = time.time() try: f.retrbinary('RETR ' + filename, fp1.write, 8*1024) except ftplib.error_perm, msg: print msg t1 = time.time() bytes = fp.tell() fp.close() if fp1 != fp: fp1.close() try: os.unlink(fullname) except os.error: pass # Ignore the error try: os.rename(tempname, fullname) except os.error, msg: print "Can't rename %s to %s: %s" % (tempname, fullname, str(msg)) continue info[filename] = infostuff writedict(info, infofilename) if verbose: dt = t1 - t0 kbytes = bytes / 1024.0 print int(round(kbytes)), print 'Kbytes in', print int(round(dt)), print 'seconds', if t1 > t0: print '(~%d Kbytes/sec)' % \ int(round(kbytes/dt),) print # # Remove files from info that are no longer remote deletions = 0 for filename in info.keys(): if filename not in filesfound: if verbose: print "Removing obsolete info entry for", print filename, "in", localdir or "." del info[filename] deletions = deletions + 1 if deletions: writedict(info, infofilename) # # Remove local files that are no longer in the remote directory try: if not localdir: names = os.listdir(os.curdir) else: names = os.listdir(localdir) except os.error: names = [] for name in names: if name[0] == '.' or info.has_key(name) or name in subdirs: continue skip = 0 for pat in skippats: if fnmatch(name, pat): if verbose > 1: print 'Skip pattern', pat, print 'matches', name skip = 1 break if skip: continue fullname = os.path.join(localdir, name) if not rmok: if verbose: print 'Local file', fullname, print 'is no longer pertinent' continue if verbose: print 'Removing local file/dir', fullname remove(fullname) # # Recursively mirror subdirectories for subdir in subdirs: if interactive: doit = askabout('subdirectory', subdir, pwd) if not doit: continue if verbose: print 'Processing subdirectory', subdir localsubdir = os.path.join(localdir, subdir) pwd = f.pwd() if verbose > 1: print 'Remote directory now:', pwd print 'Remote cwd', subdir try: f.cwd(subdir) except ftplib.error_perm, msg: print "Can't chdir to", subdir, ":", msg else: if verbose: print 'Mirroring as', localsubdir mirrorsubdir(f, localsubdir) if verbose > 1: print 'Remote cwd ..' f.cwd('..') newpwd = f.pwd() if newpwd != pwd: print 'Ended up in wrong directory after cd + cd ..' print 'Giving up now.' break else: if verbose > 1: print 'OK.'
a25969620ad128c95dde9cf500b28fa3e57611c9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a25969620ad128c95dde9cf500b28fa3e57611c9/ftpmirror.py
print 'Local file', fullname,
print 'Local file', `fullname`,
def mirrorsubdir(f, localdir): pwd = f.pwd() if localdir and not os.path.isdir(localdir): if verbose: print 'Creating local directory', localdir try: makedir(localdir) except os.error, msg: print "Failed to establish local directory", localdir return infofilename = os.path.join(localdir, '.mirrorinfo') try: text = open(infofilename, 'r').read() except IOError, msg: text = '{}' try: info = eval(text) except (SyntaxError, NameError): print 'Bad mirror info in %s' % infofilename info = {} subdirs = [] listing = [] if verbose: print 'Listing remote directory %s...' % pwd f.retrlines('LIST', listing.append) filesfound = [] for line in listing: if verbose > 1: print '-->', `line` if mac: # Mac listing has just filenames; # trailing / means subdirectory filename = string.strip(line) mode = '-' if filename[-1:] == '/': filename = filename[:-1] mode = 'd' infostuff = '' else: # Parse, assuming a UNIX listing words = string.split(line, None, 8) if len(words) < 6: if verbose > 1: print 'Skipping short line' continue filename = words[-1] if string.find(filename, " -> ") >= 0: if verbose > 1: print 'Skipping symbolic link %s' % \ filename continue infostuff = words[-5:-1] mode = words[0] skip = 0 for pat in skippats: if fnmatch(filename, pat): if verbose > 1: print 'Skip pattern', pat, print 'matches', filename skip = 1 break if skip: continue if mode[0] == 'd': if verbose > 1: print 'Remembering subdirectory', filename subdirs.append(filename) continue filesfound.append(filename) if info.has_key(filename) and info[filename] == infostuff: if verbose > 1: print 'Already have this version of', filename continue fullname = os.path.join(localdir, filename) tempname = os.path.join(localdir, '@'+filename) if interactive: doit = askabout('file', filename, pwd) if not doit: if not info.has_key(filename): info[filename] = 'Not retrieved' continue try: os.unlink(tempname) except os.error: pass try: fp = open(tempname, 'wb') except IOError, msg: print "Can't create %s: %s" % (tempname, str(msg)) continue if verbose: print 'Retrieving %s from %s as %s...' % \ (filename, pwd, fullname) if verbose: fp1 = LoggingFile(fp, 1024, sys.stdout) else: fp1 = fp t0 = time.time() try: f.retrbinary('RETR ' + filename, fp1.write, 8*1024) except ftplib.error_perm, msg: print msg t1 = time.time() bytes = fp.tell() fp.close() if fp1 != fp: fp1.close() try: os.unlink(fullname) except os.error: pass # Ignore the error try: os.rename(tempname, fullname) except os.error, msg: print "Can't rename %s to %s: %s" % (tempname, fullname, str(msg)) continue info[filename] = infostuff writedict(info, infofilename) if verbose: dt = t1 - t0 kbytes = bytes / 1024.0 print int(round(kbytes)), print 'Kbytes in', print int(round(dt)), print 'seconds', if t1 > t0: print '(~%d Kbytes/sec)' % \ int(round(kbytes/dt),) print # # Remove files from info that are no longer remote deletions = 0 for filename in info.keys(): if filename not in filesfound: if verbose: print "Removing obsolete info entry for", print filename, "in", localdir or "." del info[filename] deletions = deletions + 1 if deletions: writedict(info, infofilename) # # Remove local files that are no longer in the remote directory try: if not localdir: names = os.listdir(os.curdir) else: names = os.listdir(localdir) except os.error: names = [] for name in names: if name[0] == '.' or info.has_key(name) or name in subdirs: continue skip = 0 for pat in skippats: if fnmatch(name, pat): if verbose > 1: print 'Skip pattern', pat, print 'matches', name skip = 1 break if skip: continue fullname = os.path.join(localdir, name) if not rmok: if verbose: print 'Local file', fullname, print 'is no longer pertinent' continue if verbose: print 'Removing local file/dir', fullname remove(fullname) # # Recursively mirror subdirectories for subdir in subdirs: if interactive: doit = askabout('subdirectory', subdir, pwd) if not doit: continue if verbose: print 'Processing subdirectory', subdir localsubdir = os.path.join(localdir, subdir) pwd = f.pwd() if verbose > 1: print 'Remote directory now:', pwd print 'Remote cwd', subdir try: f.cwd(subdir) except ftplib.error_perm, msg: print "Can't chdir to", subdir, ":", msg else: if verbose: print 'Mirroring as', localsubdir mirrorsubdir(f, localsubdir) if verbose > 1: print 'Remote cwd ..' f.cwd('..') newpwd = f.pwd() if newpwd != pwd: print 'Ended up in wrong directory after cd + cd ..' print 'Giving up now.' break else: if verbose > 1: print 'OK.'
a25969620ad128c95dde9cf500b28fa3e57611c9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a25969620ad128c95dde9cf500b28fa3e57611c9/ftpmirror.py
if verbose: print 'Removing local file/dir', fullname
if verbose: print 'Removing local file/dir', `fullname`
def mirrorsubdir(f, localdir): pwd = f.pwd() if localdir and not os.path.isdir(localdir): if verbose: print 'Creating local directory', localdir try: makedir(localdir) except os.error, msg: print "Failed to establish local directory", localdir return infofilename = os.path.join(localdir, '.mirrorinfo') try: text = open(infofilename, 'r').read() except IOError, msg: text = '{}' try: info = eval(text) except (SyntaxError, NameError): print 'Bad mirror info in %s' % infofilename info = {} subdirs = [] listing = [] if verbose: print 'Listing remote directory %s...' % pwd f.retrlines('LIST', listing.append) filesfound = [] for line in listing: if verbose > 1: print '-->', `line` if mac: # Mac listing has just filenames; # trailing / means subdirectory filename = string.strip(line) mode = '-' if filename[-1:] == '/': filename = filename[:-1] mode = 'd' infostuff = '' else: # Parse, assuming a UNIX listing words = string.split(line, None, 8) if len(words) < 6: if verbose > 1: print 'Skipping short line' continue filename = words[-1] if string.find(filename, " -> ") >= 0: if verbose > 1: print 'Skipping symbolic link %s' % \ filename continue infostuff = words[-5:-1] mode = words[0] skip = 0 for pat in skippats: if fnmatch(filename, pat): if verbose > 1: print 'Skip pattern', pat, print 'matches', filename skip = 1 break if skip: continue if mode[0] == 'd': if verbose > 1: print 'Remembering subdirectory', filename subdirs.append(filename) continue filesfound.append(filename) if info.has_key(filename) and info[filename] == infostuff: if verbose > 1: print 'Already have this version of', filename continue fullname = os.path.join(localdir, filename) tempname = os.path.join(localdir, '@'+filename) if interactive: doit = askabout('file', filename, pwd) if not doit: if not info.has_key(filename): info[filename] = 'Not retrieved' continue try: os.unlink(tempname) except os.error: pass try: fp = open(tempname, 'wb') except IOError, msg: print "Can't create %s: %s" % (tempname, str(msg)) continue if verbose: print 'Retrieving %s from %s as %s...' % \ (filename, pwd, fullname) if verbose: fp1 = LoggingFile(fp, 1024, sys.stdout) else: fp1 = fp t0 = time.time() try: f.retrbinary('RETR ' + filename, fp1.write, 8*1024) except ftplib.error_perm, msg: print msg t1 = time.time() bytes = fp.tell() fp.close() if fp1 != fp: fp1.close() try: os.unlink(fullname) except os.error: pass # Ignore the error try: os.rename(tempname, fullname) except os.error, msg: print "Can't rename %s to %s: %s" % (tempname, fullname, str(msg)) continue info[filename] = infostuff writedict(info, infofilename) if verbose: dt = t1 - t0 kbytes = bytes / 1024.0 print int(round(kbytes)), print 'Kbytes in', print int(round(dt)), print 'seconds', if t1 > t0: print '(~%d Kbytes/sec)' % \ int(round(kbytes/dt),) print # # Remove files from info that are no longer remote deletions = 0 for filename in info.keys(): if filename not in filesfound: if verbose: print "Removing obsolete info entry for", print filename, "in", localdir or "." del info[filename] deletions = deletions + 1 if deletions: writedict(info, infofilename) # # Remove local files that are no longer in the remote directory try: if not localdir: names = os.listdir(os.curdir) else: names = os.listdir(localdir) except os.error: names = [] for name in names: if name[0] == '.' or info.has_key(name) or name in subdirs: continue skip = 0 for pat in skippats: if fnmatch(name, pat): if verbose > 1: print 'Skip pattern', pat, print 'matches', name skip = 1 break if skip: continue fullname = os.path.join(localdir, name) if not rmok: if verbose: print 'Local file', fullname, print 'is no longer pertinent' continue if verbose: print 'Removing local file/dir', fullname remove(fullname) # # Recursively mirror subdirectories for subdir in subdirs: if interactive: doit = askabout('subdirectory', subdir, pwd) if not doit: continue if verbose: print 'Processing subdirectory', subdir localsubdir = os.path.join(localdir, subdir) pwd = f.pwd() if verbose > 1: print 'Remote directory now:', pwd print 'Remote cwd', subdir try: f.cwd(subdir) except ftplib.error_perm, msg: print "Can't chdir to", subdir, ":", msg else: if verbose: print 'Mirroring as', localsubdir mirrorsubdir(f, localsubdir) if verbose > 1: print 'Remote cwd ..' f.cwd('..') newpwd = f.pwd() if newpwd != pwd: print 'Ended up in wrong directory after cd + cd ..' print 'Giving up now.' break else: if verbose > 1: print 'OK.'
a25969620ad128c95dde9cf500b28fa3e57611c9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a25969620ad128c95dde9cf500b28fa3e57611c9/ftpmirror.py
if verbose: print 'Processing subdirectory', subdir
if verbose: print 'Processing subdirectory', `subdir`
def mirrorsubdir(f, localdir): pwd = f.pwd() if localdir and not os.path.isdir(localdir): if verbose: print 'Creating local directory', localdir try: makedir(localdir) except os.error, msg: print "Failed to establish local directory", localdir return infofilename = os.path.join(localdir, '.mirrorinfo') try: text = open(infofilename, 'r').read() except IOError, msg: text = '{}' try: info = eval(text) except (SyntaxError, NameError): print 'Bad mirror info in %s' % infofilename info = {} subdirs = [] listing = [] if verbose: print 'Listing remote directory %s...' % pwd f.retrlines('LIST', listing.append) filesfound = [] for line in listing: if verbose > 1: print '-->', `line` if mac: # Mac listing has just filenames; # trailing / means subdirectory filename = string.strip(line) mode = '-' if filename[-1:] == '/': filename = filename[:-1] mode = 'd' infostuff = '' else: # Parse, assuming a UNIX listing words = string.split(line, None, 8) if len(words) < 6: if verbose > 1: print 'Skipping short line' continue filename = words[-1] if string.find(filename, " -> ") >= 0: if verbose > 1: print 'Skipping symbolic link %s' % \ filename continue infostuff = words[-5:-1] mode = words[0] skip = 0 for pat in skippats: if fnmatch(filename, pat): if verbose > 1: print 'Skip pattern', pat, print 'matches', filename skip = 1 break if skip: continue if mode[0] == 'd': if verbose > 1: print 'Remembering subdirectory', filename subdirs.append(filename) continue filesfound.append(filename) if info.has_key(filename) and info[filename] == infostuff: if verbose > 1: print 'Already have this version of', filename continue fullname = os.path.join(localdir, filename) tempname = os.path.join(localdir, '@'+filename) if interactive: doit = askabout('file', filename, pwd) if not doit: if not info.has_key(filename): info[filename] = 'Not retrieved' continue try: os.unlink(tempname) except os.error: pass try: fp = open(tempname, 'wb') except IOError, msg: print "Can't create %s: %s" % (tempname, str(msg)) continue if verbose: print 'Retrieving %s from %s as %s...' % \ (filename, pwd, fullname) if verbose: fp1 = LoggingFile(fp, 1024, sys.stdout) else: fp1 = fp t0 = time.time() try: f.retrbinary('RETR ' + filename, fp1.write, 8*1024) except ftplib.error_perm, msg: print msg t1 = time.time() bytes = fp.tell() fp.close() if fp1 != fp: fp1.close() try: os.unlink(fullname) except os.error: pass # Ignore the error try: os.rename(tempname, fullname) except os.error, msg: print "Can't rename %s to %s: %s" % (tempname, fullname, str(msg)) continue info[filename] = infostuff writedict(info, infofilename) if verbose: dt = t1 - t0 kbytes = bytes / 1024.0 print int(round(kbytes)), print 'Kbytes in', print int(round(dt)), print 'seconds', if t1 > t0: print '(~%d Kbytes/sec)' % \ int(round(kbytes/dt),) print # # Remove files from info that are no longer remote deletions = 0 for filename in info.keys(): if filename not in filesfound: if verbose: print "Removing obsolete info entry for", print filename, "in", localdir or "." del info[filename] deletions = deletions + 1 if deletions: writedict(info, infofilename) # # Remove local files that are no longer in the remote directory try: if not localdir: names = os.listdir(os.curdir) else: names = os.listdir(localdir) except os.error: names = [] for name in names: if name[0] == '.' or info.has_key(name) or name in subdirs: continue skip = 0 for pat in skippats: if fnmatch(name, pat): if verbose > 1: print 'Skip pattern', pat, print 'matches', name skip = 1 break if skip: continue fullname = os.path.join(localdir, name) if not rmok: if verbose: print 'Local file', fullname, print 'is no longer pertinent' continue if verbose: print 'Removing local file/dir', fullname remove(fullname) # # Recursively mirror subdirectories for subdir in subdirs: if interactive: doit = askabout('subdirectory', subdir, pwd) if not doit: continue if verbose: print 'Processing subdirectory', subdir localsubdir = os.path.join(localdir, subdir) pwd = f.pwd() if verbose > 1: print 'Remote directory now:', pwd print 'Remote cwd', subdir try: f.cwd(subdir) except ftplib.error_perm, msg: print "Can't chdir to", subdir, ":", msg else: if verbose: print 'Mirroring as', localsubdir mirrorsubdir(f, localsubdir) if verbose > 1: print 'Remote cwd ..' f.cwd('..') newpwd = f.pwd() if newpwd != pwd: print 'Ended up in wrong directory after cd + cd ..' print 'Giving up now.' break else: if verbose > 1: print 'OK.'
a25969620ad128c95dde9cf500b28fa3e57611c9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a25969620ad128c95dde9cf500b28fa3e57611c9/ftpmirror.py
print 'Remote directory now:', pwd print 'Remote cwd', subdir
print 'Remote directory now:', `pwd` print 'Remote cwd', `subdir`
def mirrorsubdir(f, localdir): pwd = f.pwd() if localdir and not os.path.isdir(localdir): if verbose: print 'Creating local directory', localdir try: makedir(localdir) except os.error, msg: print "Failed to establish local directory", localdir return infofilename = os.path.join(localdir, '.mirrorinfo') try: text = open(infofilename, 'r').read() except IOError, msg: text = '{}' try: info = eval(text) except (SyntaxError, NameError): print 'Bad mirror info in %s' % infofilename info = {} subdirs = [] listing = [] if verbose: print 'Listing remote directory %s...' % pwd f.retrlines('LIST', listing.append) filesfound = [] for line in listing: if verbose > 1: print '-->', `line` if mac: # Mac listing has just filenames; # trailing / means subdirectory filename = string.strip(line) mode = '-' if filename[-1:] == '/': filename = filename[:-1] mode = 'd' infostuff = '' else: # Parse, assuming a UNIX listing words = string.split(line, None, 8) if len(words) < 6: if verbose > 1: print 'Skipping short line' continue filename = words[-1] if string.find(filename, " -> ") >= 0: if verbose > 1: print 'Skipping symbolic link %s' % \ filename continue infostuff = words[-5:-1] mode = words[0] skip = 0 for pat in skippats: if fnmatch(filename, pat): if verbose > 1: print 'Skip pattern', pat, print 'matches', filename skip = 1 break if skip: continue if mode[0] == 'd': if verbose > 1: print 'Remembering subdirectory', filename subdirs.append(filename) continue filesfound.append(filename) if info.has_key(filename) and info[filename] == infostuff: if verbose > 1: print 'Already have this version of', filename continue fullname = os.path.join(localdir, filename) tempname = os.path.join(localdir, '@'+filename) if interactive: doit = askabout('file', filename, pwd) if not doit: if not info.has_key(filename): info[filename] = 'Not retrieved' continue try: os.unlink(tempname) except os.error: pass try: fp = open(tempname, 'wb') except IOError, msg: print "Can't create %s: %s" % (tempname, str(msg)) continue if verbose: print 'Retrieving %s from %s as %s...' % \ (filename, pwd, fullname) if verbose: fp1 = LoggingFile(fp, 1024, sys.stdout) else: fp1 = fp t0 = time.time() try: f.retrbinary('RETR ' + filename, fp1.write, 8*1024) except ftplib.error_perm, msg: print msg t1 = time.time() bytes = fp.tell() fp.close() if fp1 != fp: fp1.close() try: os.unlink(fullname) except os.error: pass # Ignore the error try: os.rename(tempname, fullname) except os.error, msg: print "Can't rename %s to %s: %s" % (tempname, fullname, str(msg)) continue info[filename] = infostuff writedict(info, infofilename) if verbose: dt = t1 - t0 kbytes = bytes / 1024.0 print int(round(kbytes)), print 'Kbytes in', print int(round(dt)), print 'seconds', if t1 > t0: print '(~%d Kbytes/sec)' % \ int(round(kbytes/dt),) print # # Remove files from info that are no longer remote deletions = 0 for filename in info.keys(): if filename not in filesfound: if verbose: print "Removing obsolete info entry for", print filename, "in", localdir or "." del info[filename] deletions = deletions + 1 if deletions: writedict(info, infofilename) # # Remove local files that are no longer in the remote directory try: if not localdir: names = os.listdir(os.curdir) else: names = os.listdir(localdir) except os.error: names = [] for name in names: if name[0] == '.' or info.has_key(name) or name in subdirs: continue skip = 0 for pat in skippats: if fnmatch(name, pat): if verbose > 1: print 'Skip pattern', pat, print 'matches', name skip = 1 break if skip: continue fullname = os.path.join(localdir, name) if not rmok: if verbose: print 'Local file', fullname, print 'is no longer pertinent' continue if verbose: print 'Removing local file/dir', fullname remove(fullname) # # Recursively mirror subdirectories for subdir in subdirs: if interactive: doit = askabout('subdirectory', subdir, pwd) if not doit: continue if verbose: print 'Processing subdirectory', subdir localsubdir = os.path.join(localdir, subdir) pwd = f.pwd() if verbose > 1: print 'Remote directory now:', pwd print 'Remote cwd', subdir try: f.cwd(subdir) except ftplib.error_perm, msg: print "Can't chdir to", subdir, ":", msg else: if verbose: print 'Mirroring as', localsubdir mirrorsubdir(f, localsubdir) if verbose > 1: print 'Remote cwd ..' f.cwd('..') newpwd = f.pwd() if newpwd != pwd: print 'Ended up in wrong directory after cd + cd ..' print 'Giving up now.' break else: if verbose > 1: print 'OK.'
a25969620ad128c95dde9cf500b28fa3e57611c9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a25969620ad128c95dde9cf500b28fa3e57611c9/ftpmirror.py
print "Can't chdir to", subdir, ":", msg
print "Can't chdir to", `subdir`, ":", `msg`
def mirrorsubdir(f, localdir): pwd = f.pwd() if localdir and not os.path.isdir(localdir): if verbose: print 'Creating local directory', localdir try: makedir(localdir) except os.error, msg: print "Failed to establish local directory", localdir return infofilename = os.path.join(localdir, '.mirrorinfo') try: text = open(infofilename, 'r').read() except IOError, msg: text = '{}' try: info = eval(text) except (SyntaxError, NameError): print 'Bad mirror info in %s' % infofilename info = {} subdirs = [] listing = [] if verbose: print 'Listing remote directory %s...' % pwd f.retrlines('LIST', listing.append) filesfound = [] for line in listing: if verbose > 1: print '-->', `line` if mac: # Mac listing has just filenames; # trailing / means subdirectory filename = string.strip(line) mode = '-' if filename[-1:] == '/': filename = filename[:-1] mode = 'd' infostuff = '' else: # Parse, assuming a UNIX listing words = string.split(line, None, 8) if len(words) < 6: if verbose > 1: print 'Skipping short line' continue filename = words[-1] if string.find(filename, " -> ") >= 0: if verbose > 1: print 'Skipping symbolic link %s' % \ filename continue infostuff = words[-5:-1] mode = words[0] skip = 0 for pat in skippats: if fnmatch(filename, pat): if verbose > 1: print 'Skip pattern', pat, print 'matches', filename skip = 1 break if skip: continue if mode[0] == 'd': if verbose > 1: print 'Remembering subdirectory', filename subdirs.append(filename) continue filesfound.append(filename) if info.has_key(filename) and info[filename] == infostuff: if verbose > 1: print 'Already have this version of', filename continue fullname = os.path.join(localdir, filename) tempname = os.path.join(localdir, '@'+filename) if interactive: doit = askabout('file', filename, pwd) if not doit: if not info.has_key(filename): info[filename] = 'Not retrieved' continue try: os.unlink(tempname) except os.error: pass try: fp = open(tempname, 'wb') except IOError, msg: print "Can't create %s: %s" % (tempname, str(msg)) continue if verbose: print 'Retrieving %s from %s as %s...' % \ (filename, pwd, fullname) if verbose: fp1 = LoggingFile(fp, 1024, sys.stdout) else: fp1 = fp t0 = time.time() try: f.retrbinary('RETR ' + filename, fp1.write, 8*1024) except ftplib.error_perm, msg: print msg t1 = time.time() bytes = fp.tell() fp.close() if fp1 != fp: fp1.close() try: os.unlink(fullname) except os.error: pass # Ignore the error try: os.rename(tempname, fullname) except os.error, msg: print "Can't rename %s to %s: %s" % (tempname, fullname, str(msg)) continue info[filename] = infostuff writedict(info, infofilename) if verbose: dt = t1 - t0 kbytes = bytes / 1024.0 print int(round(kbytes)), print 'Kbytes in', print int(round(dt)), print 'seconds', if t1 > t0: print '(~%d Kbytes/sec)' % \ int(round(kbytes/dt),) print # # Remove files from info that are no longer remote deletions = 0 for filename in info.keys(): if filename not in filesfound: if verbose: print "Removing obsolete info entry for", print filename, "in", localdir or "." del info[filename] deletions = deletions + 1 if deletions: writedict(info, infofilename) # # Remove local files that are no longer in the remote directory try: if not localdir: names = os.listdir(os.curdir) else: names = os.listdir(localdir) except os.error: names = [] for name in names: if name[0] == '.' or info.has_key(name) or name in subdirs: continue skip = 0 for pat in skippats: if fnmatch(name, pat): if verbose > 1: print 'Skip pattern', pat, print 'matches', name skip = 1 break if skip: continue fullname = os.path.join(localdir, name) if not rmok: if verbose: print 'Local file', fullname, print 'is no longer pertinent' continue if verbose: print 'Removing local file/dir', fullname remove(fullname) # # Recursively mirror subdirectories for subdir in subdirs: if interactive: doit = askabout('subdirectory', subdir, pwd) if not doit: continue if verbose: print 'Processing subdirectory', subdir localsubdir = os.path.join(localdir, subdir) pwd = f.pwd() if verbose > 1: print 'Remote directory now:', pwd print 'Remote cwd', subdir try: f.cwd(subdir) except ftplib.error_perm, msg: print "Can't chdir to", subdir, ":", msg else: if verbose: print 'Mirroring as', localsubdir mirrorsubdir(f, localsubdir) if verbose > 1: print 'Remote cwd ..' f.cwd('..') newpwd = f.pwd() if newpwd != pwd: print 'Ended up in wrong directory after cd + cd ..' print 'Giving up now.' break else: if verbose > 1: print 'OK.'
a25969620ad128c95dde9cf500b28fa3e57611c9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a25969620ad128c95dde9cf500b28fa3e57611c9/ftpmirror.py
if verbose: print 'Mirroring as', localsubdir
if verbose: print 'Mirroring as', `localsubdir`
def mirrorsubdir(f, localdir): pwd = f.pwd() if localdir and not os.path.isdir(localdir): if verbose: print 'Creating local directory', localdir try: makedir(localdir) except os.error, msg: print "Failed to establish local directory", localdir return infofilename = os.path.join(localdir, '.mirrorinfo') try: text = open(infofilename, 'r').read() except IOError, msg: text = '{}' try: info = eval(text) except (SyntaxError, NameError): print 'Bad mirror info in %s' % infofilename info = {} subdirs = [] listing = [] if verbose: print 'Listing remote directory %s...' % pwd f.retrlines('LIST', listing.append) filesfound = [] for line in listing: if verbose > 1: print '-->', `line` if mac: # Mac listing has just filenames; # trailing / means subdirectory filename = string.strip(line) mode = '-' if filename[-1:] == '/': filename = filename[:-1] mode = 'd' infostuff = '' else: # Parse, assuming a UNIX listing words = string.split(line, None, 8) if len(words) < 6: if verbose > 1: print 'Skipping short line' continue filename = words[-1] if string.find(filename, " -> ") >= 0: if verbose > 1: print 'Skipping symbolic link %s' % \ filename continue infostuff = words[-5:-1] mode = words[0] skip = 0 for pat in skippats: if fnmatch(filename, pat): if verbose > 1: print 'Skip pattern', pat, print 'matches', filename skip = 1 break if skip: continue if mode[0] == 'd': if verbose > 1: print 'Remembering subdirectory', filename subdirs.append(filename) continue filesfound.append(filename) if info.has_key(filename) and info[filename] == infostuff: if verbose > 1: print 'Already have this version of', filename continue fullname = os.path.join(localdir, filename) tempname = os.path.join(localdir, '@'+filename) if interactive: doit = askabout('file', filename, pwd) if not doit: if not info.has_key(filename): info[filename] = 'Not retrieved' continue try: os.unlink(tempname) except os.error: pass try: fp = open(tempname, 'wb') except IOError, msg: print "Can't create %s: %s" % (tempname, str(msg)) continue if verbose: print 'Retrieving %s from %s as %s...' % \ (filename, pwd, fullname) if verbose: fp1 = LoggingFile(fp, 1024, sys.stdout) else: fp1 = fp t0 = time.time() try: f.retrbinary('RETR ' + filename, fp1.write, 8*1024) except ftplib.error_perm, msg: print msg t1 = time.time() bytes = fp.tell() fp.close() if fp1 != fp: fp1.close() try: os.unlink(fullname) except os.error: pass # Ignore the error try: os.rename(tempname, fullname) except os.error, msg: print "Can't rename %s to %s: %s" % (tempname, fullname, str(msg)) continue info[filename] = infostuff writedict(info, infofilename) if verbose: dt = t1 - t0 kbytes = bytes / 1024.0 print int(round(kbytes)), print 'Kbytes in', print int(round(dt)), print 'seconds', if t1 > t0: print '(~%d Kbytes/sec)' % \ int(round(kbytes/dt),) print # # Remove files from info that are no longer remote deletions = 0 for filename in info.keys(): if filename not in filesfound: if verbose: print "Removing obsolete info entry for", print filename, "in", localdir or "." del info[filename] deletions = deletions + 1 if deletions: writedict(info, infofilename) # # Remove local files that are no longer in the remote directory try: if not localdir: names = os.listdir(os.curdir) else: names = os.listdir(localdir) except os.error: names = [] for name in names: if name[0] == '.' or info.has_key(name) or name in subdirs: continue skip = 0 for pat in skippats: if fnmatch(name, pat): if verbose > 1: print 'Skip pattern', pat, print 'matches', name skip = 1 break if skip: continue fullname = os.path.join(localdir, name) if not rmok: if verbose: print 'Local file', fullname, print 'is no longer pertinent' continue if verbose: print 'Removing local file/dir', fullname remove(fullname) # # Recursively mirror subdirectories for subdir in subdirs: if interactive: doit = askabout('subdirectory', subdir, pwd) if not doit: continue if verbose: print 'Processing subdirectory', subdir localsubdir = os.path.join(localdir, subdir) pwd = f.pwd() if verbose > 1: print 'Remote directory now:', pwd print 'Remote cwd', subdir try: f.cwd(subdir) except ftplib.error_perm, msg: print "Can't chdir to", subdir, ":", msg else: if verbose: print 'Mirroring as', localsubdir mirrorsubdir(f, localsubdir) if verbose > 1: print 'Remote cwd ..' f.cwd('..') newpwd = f.pwd() if newpwd != pwd: print 'Ended up in wrong directory after cd + cd ..' print 'Giving up now.' break else: if verbose > 1: print 'OK.'
a25969620ad128c95dde9cf500b28fa3e57611c9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a25969620ad128c95dde9cf500b28fa3e57611c9/ftpmirror.py
(fullname, str(msg))
(`fullname`, str(msg))
def remove(fullname): if os.path.isdir(fullname) and not os.path.islink(fullname): try: names = os.listdir(fullname) except os.error: names = [] ok = 1 for name in names: if not remove(os.path.join(fullname, name)): ok = 0 if not ok: return 0 try: os.rmdir(fullname) except os.error, msg: print "Can't remove local directory %s: %s" % \ (fullname, str(msg)) return 0 else: try: os.unlink(fullname) except os.error, msg: print "Can't remove local file %s: %s" % \ (fullname, str(msg)) return 0 return 1
a25969620ad128c95dde9cf500b28fa3e57611c9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a25969620ad128c95dde9cf500b28fa3e57611c9/ftpmirror.py
(fullname, str(msg))
(`fullname`, str(msg))
def remove(fullname): if os.path.isdir(fullname) and not os.path.islink(fullname): try: names = os.listdir(fullname) except os.error: names = [] ok = 1 for name in names: if not remove(os.path.join(fullname, name)): ok = 0 if not ok: return 0 try: os.rmdir(fullname) except os.error, msg: print "Can't remove local directory %s: %s" % \ (fullname, str(msg)) return 0 else: try: os.unlink(fullname) except os.error, msg: print "Can't remove local file %s: %s" % \ (fullname, str(msg)) return 0 return 1
a25969620ad128c95dde9cf500b28fa3e57611c9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a25969620ad128c95dde9cf500b28fa3e57611c9/ftpmirror.py
def item_cget(self, col, opt): return self.tk.call(self._w, 'item', 'cget', col, opt)
def item_cget(self, entry, col, opt): return self.tk.call(self._w, 'item', 'cget', entry, col, opt)
def item_cget(self, col, opt): return self.tk.call(self._w, 'item', 'cget', col, opt)
3e048485f9c56066f347bc0e6a06056870847056 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3e048485f9c56066f347bc0e6a06056870847056/Tix.py
def _interact(): """Make sure the application is in the foreground""" AE.AEInteractWithUser(50000000)
def _initialize(): global _initialized if _initialized: return macresource.need("DLOG", 260, "dialogs.rsrc", __name__)
7451e3b4d5228a9e3efc837f6ecb2c156e07f538 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7451e3b4d5228a9e3efc837f6ecb2c156e07f538/EasyDialogs.py
def loop(timeout=30.0, use_poll=0, map=None):
def loop(timeout=30.0, use_poll=False, map=None):
def loop(timeout=30.0, use_poll=0, map=None): if map is None: map = socket_map if use_poll and hasattr(select, 'poll'): poll_fun = poll2 else: poll_fun = poll while map: poll_fun(timeout, map)
68522b18956b4417f5ab53ad513a6922370c9f2e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/68522b18956b4417f5ab53ad513a6922370c9f2e/asyncore.py
debug = 0 connected = 0 accepting = 0 closing = 0
debug = False connected = False accepting = False closing = False
def loop(timeout=30.0, use_poll=0, map=None): if map is None: map = socket_map if use_poll and hasattr(select, 'poll'): poll_fun = poll2 else: poll_fun = poll while map: poll_fun(timeout, map)
68522b18956b4417f5ab53ad513a6922370c9f2e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/68522b18956b4417f5ab53ad513a6922370c9f2e/asyncore.py
self.connected = 1
self.connected = True
def __init__(self, sock=None, map=None): if map is None: self._map = socket_map else: self._map = map
68522b18956b4417f5ab53ad513a6922370c9f2e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/68522b18956b4417f5ab53ad513a6922370c9f2e/asyncore.py
self.accepting = 1
self.accepting = True
def listen(self, num): self.accepting = 1 if os.name == 'nt' and num > 5: num = 1 return self.socket.listen(num)
68522b18956b4417f5ab53ad513a6922370c9f2e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/68522b18956b4417f5ab53ad513a6922370c9f2e/asyncore.py
self.connected = 0
self.connected = False
def connect(self, address): self.connected = 0 err = self.socket.connect_ex(address) # XXX Should interpret Winsock return values if err in (EINPROGRESS, EALREADY, EWOULDBLOCK): return if err in (0, EISCONN): self.addr = address self.connected = 1 self.handle_connect() else: raise socket.error, err
68522b18956b4417f5ab53ad513a6922370c9f2e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/68522b18956b4417f5ab53ad513a6922370c9f2e/asyncore.py
self.connected = 1
self.connected = True
def connect(self, address): self.connected = 0 err = self.socket.connect_ex(address) # XXX Should interpret Winsock return values if err in (EINPROGRESS, EALREADY, EWOULDBLOCK): return if err in (0, EISCONN): self.addr = address self.connected = 1 self.handle_connect() else: raise socket.error, err
68522b18956b4417f5ab53ad513a6922370c9f2e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/68522b18956b4417f5ab53ad513a6922370c9f2e/asyncore.py
self.connected = 1
self.connected = True
def handle_read_event(self): if self.accepting: # for an accepting socket, getting a read implies # that we are connected if not self.connected: self.connected = 1 self.handle_accept() elif not self.connected: self.handle_connect() self.connected = 1 self.handle_read() else: self.handle_read()
68522b18956b4417f5ab53ad513a6922370c9f2e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/68522b18956b4417f5ab53ad513a6922370c9f2e/asyncore.py
self.connected = 1
self.connected = True
def handle_read_event(self): if self.accepting: # for an accepting socket, getting a read implies # that we are connected if not self.connected: self.connected = 1 self.handle_accept() elif not self.connected: self.handle_connect() self.connected = 1 self.handle_read() else: self.handle_read()
68522b18956b4417f5ab53ad513a6922370c9f2e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/68522b18956b4417f5ab53ad513a6922370c9f2e/asyncore.py
self.connected = 1
self.connected = True
def handle_write_event(self): # getting a write implies that we are connected if not self.connected: self.handle_connect() self.connected = 1 self.handle_write()
68522b18956b4417f5ab53ad513a6922370c9f2e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/68522b18956b4417f5ab53ad513a6922370c9f2e/asyncore.py
self.connected = 1
self.connected = True
def __init__(self, fd): dispatcher.__init__(self) self.connected = 1 # set it to non-blocking mode flags = fcntl.fcntl(fd, fcntl.F_GETFL, 0) flags = flags | os.O_NONBLOCK fcntl.fcntl(fd, fcntl.F_SETFL, flags) self.set_file(fd)
68522b18956b4417f5ab53ad513a6922370c9f2e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/68522b18956b4417f5ab53ad513a6922370c9f2e/asyncore.py
f = open(filename, 'rb')
f = open(filename, 'rT')
def showframe(self, stackindex): (frame, lineno) = self.stack[stackindex] W.SetCursor('watch') filename = frame.f_code.co_filename if filename <> self.file: editor = self.geteditor(filename) if editor: self.w.panes.bottom.src.source.set(editor.get(), filename) else: try: f = open(filename, 'rb') data = f.read() f.close() except IOError: if filename[-3:] == '.py': import imp modname = os.path.basename(filename)[:-3] try: f, filename, (suff, mode, dummy) = imp.find_module(modname) except ImportError: self.w.panes.bottom.src.source.set("can't find file") else: if f: f.close() if f and suff == '.py': f = open(filename, 'rb') data = f.read() f.close() self.w.panes.bottom.src.source.set(data, filename) else: self.w.panes.bottom.src.source.set("can't find file") else: self.w.panes.bottom.src.source.set("can't find file") else: self.w.panes.bottom.src.source.set(data, filename) self.file = filename self.w.panes.bottom.srctitle.set('Source: ' + filename + ((lineno > 0) and (' (line %d)' % lineno) or ' ')) self.goto_line(lineno) self.lineno = lineno self.showvars((frame, lineno))
f6b3fddfc332382935bdd94671c008fe66d306bb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f6b3fddfc332382935bdd94671c008fe66d306bb/PyDebugger.py
f = open(filename, 'rb')
f = open(filename, 'rT')
def showframe(self, stackindex): (frame, lineno) = self.stack[stackindex] W.SetCursor('watch') filename = frame.f_code.co_filename if filename <> self.file: editor = self.geteditor(filename) if editor: self.w.panes.bottom.src.source.set(editor.get(), filename) else: try: f = open(filename, 'rb') data = f.read() f.close() except IOError: if filename[-3:] == '.py': import imp modname = os.path.basename(filename)[:-3] try: f, filename, (suff, mode, dummy) = imp.find_module(modname) except ImportError: self.w.panes.bottom.src.source.set("can't find file") else: if f: f.close() if f and suff == '.py': f = open(filename, 'rb') data = f.read() f.close() self.w.panes.bottom.src.source.set(data, filename) else: self.w.panes.bottom.src.source.set("can't find file") else: self.w.panes.bottom.src.source.set("can't find file") else: self.w.panes.bottom.src.source.set(data, filename) self.file = filename self.w.panes.bottom.srctitle.set('Source: ' + filename + ((lineno > 0) and (' (line %d)' % lineno) or ' ')) self.goto_line(lineno) self.lineno = lineno self.showvars((frame, lineno))
f6b3fddfc332382935bdd94671c008fe66d306bb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f6b3fddfc332382935bdd94671c008fe66d306bb/PyDebugger.py
Ctrl-E Go to right edge (nospaces off) or end of line (nospaces on).
Ctrl-E Go to right edge (stripspaces off) or end of line (stripspaces on).
def rectangle(win, uly, ulx, lry, lrx): "Draw a rectangle." win.vline(uly+1, ulx, curses.ACS_VLINE, lry - uly - 1) win.hline(uly, ulx+1, curses.ACS_HLINE, lrx - ulx - 1) win.hline(lry, ulx+1, curses.ACS_HLINE, lrx - ulx - 1) win.vline(uly+1, lrx, curses.ACS_VLINE, lry - uly - 1) win.addch(uly, ulx, curses.ACS_ULCORNER) win.addch(uly, lrx, curses.ACS_URCORNER) win.addch(lry, lrx, curses.ACS_LRCORNER) win.addch(lry, ulx, curses.ACS_LLCORNER)
5af256ded6190e899530de8df61fa77fe37686fc /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5af256ded6190e899530de8df61fa77fe37686fc/textpad.py
Ctrl-L Refresh screen
Ctrl-L Refresh screen.
def rectangle(win, uly, ulx, lry, lrx): "Draw a rectangle." win.vline(uly+1, ulx, curses.ACS_VLINE, lry - uly - 1) win.hline(uly, ulx+1, curses.ACS_HLINE, lrx - ulx - 1) win.hline(lry, ulx+1, curses.ACS_HLINE, lrx - ulx - 1) win.vline(uly+1, lrx, curses.ACS_VLINE, lry - uly - 1) win.addch(uly, ulx, curses.ACS_ULCORNER) win.addch(uly, lrx, curses.ACS_URCORNER) win.addch(lry, lrx, curses.ACS_LRCORNER) win.addch(lry, ulx, curses.ACS_LLCORNER)
5af256ded6190e899530de8df61fa77fe37686fc /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5af256ded6190e899530de8df61fa77fe37686fc/textpad.py
def firstblank(self, y):
def _end_of_line(self, y):
def firstblank(self, y): "Go to the location of the first blank on the given line." last = self.maxx while 1: if ascii.ascii(self.win.inch(y, last)) != ascii.SP: last = last + 1 break elif last == 0: break last = last - 1 return last
5af256ded6190e899530de8df61fa77fe37686fc /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5af256ded6190e899530de8df61fa77fe37686fc/textpad.py
self.win.move(y-1, self.firstblank(y-1))
self.win.move(y-1, self._end_of_line(y-1))
def do_command(self, ch): "Process a single editing command." (y, x) = self.win.getyx() self.lastcmd = ch if ascii.isprint(ch): if y < self.maxy or x < self.maxx: # The try-catch ignores the error we trigger from some curses # versions by trying to write into the lowest-rightmost spot # in the self.window. try: self.win.addch(ch) except ERR: pass elif ch == ascii.SOH: # ^a self.win.move(y, 0) elif ch in (ascii.STX,curses.KEY_LEFT, ascii.BS,curses.KEY_BACKSPACE): if x > 0: self.win.move(y, x-1) elif y == 0: pass elif self.stripspaces: self.win.move(y-1, self.firstblank(y-1)) else: self.win.move(y-1, self.maxx) if ch in (ascii.BS, curses.KEY_BACKSPACE): self.win.delch() elif ch == ascii.EOT: # ^d self.win.delch() elif ch == ascii.ENQ: # ^e if self.stripspaces: self.win.move(y, self.firstblank(y)) else: self.win.move(y, self.maxx) elif ch in (ascii.ACK, curses.KEY_RIGHT): # ^f if x < self.maxx: self.win.move(y, x+1) elif y == self.maxy: pass else: self.win.move(y+1, 0) elif ch == ascii.BEL: # ^g return 0 elif ch == ascii.NL: # ^j if self.maxy == 0: return 0 elif y < self.maxy: self.win.move(y+1, 0) elif ch == ascii.VT: # ^k if x == 0 and self.firstblank(y) == 0: self.win.deleteln() else: self.win.clrtoeol() elif ch == ascii.FF: # ^l self.win.refresh() elif ch in (ascii.SO, curses.KEY_DOWN): # ^n if y < self.maxy: self.win.move(y+1, x) elif ch == ascii.SI: # ^o self.win.insertln() elif ch in (ascii.DLE, curses.KEY_UP): # ^p if y > 0: self.win.move(y-1, x) return 1
5af256ded6190e899530de8df61fa77fe37686fc /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5af256ded6190e899530de8df61fa77fe37686fc/textpad.py
self.win.move(y, self.firstblank(y))
self.win.move(y, self._end_of_line(y))
def do_command(self, ch): "Process a single editing command." (y, x) = self.win.getyx() self.lastcmd = ch if ascii.isprint(ch): if y < self.maxy or x < self.maxx: # The try-catch ignores the error we trigger from some curses # versions by trying to write into the lowest-rightmost spot # in the self.window. try: self.win.addch(ch) except ERR: pass elif ch == ascii.SOH: # ^a self.win.move(y, 0) elif ch in (ascii.STX,curses.KEY_LEFT, ascii.BS,curses.KEY_BACKSPACE): if x > 0: self.win.move(y, x-1) elif y == 0: pass elif self.stripspaces: self.win.move(y-1, self.firstblank(y-1)) else: self.win.move(y-1, self.maxx) if ch in (ascii.BS, curses.KEY_BACKSPACE): self.win.delch() elif ch == ascii.EOT: # ^d self.win.delch() elif ch == ascii.ENQ: # ^e if self.stripspaces: self.win.move(y, self.firstblank(y)) else: self.win.move(y, self.maxx) elif ch in (ascii.ACK, curses.KEY_RIGHT): # ^f if x < self.maxx: self.win.move(y, x+1) elif y == self.maxy: pass else: self.win.move(y+1, 0) elif ch == ascii.BEL: # ^g return 0 elif ch == ascii.NL: # ^j if self.maxy == 0: return 0 elif y < self.maxy: self.win.move(y+1, 0) elif ch == ascii.VT: # ^k if x == 0 and self.firstblank(y) == 0: self.win.deleteln() else: self.win.clrtoeol() elif ch == ascii.FF: # ^l self.win.refresh() elif ch in (ascii.SO, curses.KEY_DOWN): # ^n if y < self.maxy: self.win.move(y+1, x) elif ch == ascii.SI: # ^o self.win.insertln() elif ch in (ascii.DLE, curses.KEY_UP): # ^p if y > 0: self.win.move(y-1, x) return 1
5af256ded6190e899530de8df61fa77fe37686fc /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5af256ded6190e899530de8df61fa77fe37686fc/textpad.py
if x == 0 and self.firstblank(y) == 0:
if x == 0 and self._end_of_line(y) == 0:
def do_command(self, ch): "Process a single editing command." (y, x) = self.win.getyx() self.lastcmd = ch if ascii.isprint(ch): if y < self.maxy or x < self.maxx: # The try-catch ignores the error we trigger from some curses # versions by trying to write into the lowest-rightmost spot # in the self.window. try: self.win.addch(ch) except ERR: pass elif ch == ascii.SOH: # ^a self.win.move(y, 0) elif ch in (ascii.STX,curses.KEY_LEFT, ascii.BS,curses.KEY_BACKSPACE): if x > 0: self.win.move(y, x-1) elif y == 0: pass elif self.stripspaces: self.win.move(y-1, self.firstblank(y-1)) else: self.win.move(y-1, self.maxx) if ch in (ascii.BS, curses.KEY_BACKSPACE): self.win.delch() elif ch == ascii.EOT: # ^d self.win.delch() elif ch == ascii.ENQ: # ^e if self.stripspaces: self.win.move(y, self.firstblank(y)) else: self.win.move(y, self.maxx) elif ch in (ascii.ACK, curses.KEY_RIGHT): # ^f if x < self.maxx: self.win.move(y, x+1) elif y == self.maxy: pass else: self.win.move(y+1, 0) elif ch == ascii.BEL: # ^g return 0 elif ch == ascii.NL: # ^j if self.maxy == 0: return 0 elif y < self.maxy: self.win.move(y+1, 0) elif ch == ascii.VT: # ^k if x == 0 and self.firstblank(y) == 0: self.win.deleteln() else: self.win.clrtoeol() elif ch == ascii.FF: # ^l self.win.refresh() elif ch in (ascii.SO, curses.KEY_DOWN): # ^n if y < self.maxy: self.win.move(y+1, x) elif ch == ascii.SI: # ^o self.win.insertln() elif ch in (ascii.DLE, curses.KEY_UP): # ^p if y > 0: self.win.move(y-1, x) return 1
5af256ded6190e899530de8df61fa77fe37686fc /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5af256ded6190e899530de8df61fa77fe37686fc/textpad.py
stop = self.firstblank(y)
stop = self._end_of_line(y)
def gather(self): "Collect and return the contents of the window." result = "" for y in range(self.maxy+1): self.win.move(y, 0) stop = self.firstblank(y) #sys.stderr.write("y=%d, firstblank(y)=%d\n" % (y, stop)) if stop == 0 and self.stripspaces: continue for x in range(self.maxx+1): if self.stripspaces and x == stop: break result = result + chr(ascii.ascii(self.win.inch(y, x))) if self.maxy > 0: result = result + "\n" return result
5af256ded6190e899530de8df61fa77fe37686fc /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5af256ded6190e899530de8df61fa77fe37686fc/textpad.py
def testWriteXML(): pass
def testWriteXML(): str = '<a b="c"/>' dom = parseString(str) domstr = dom.toxml() dom.unlink() confirm(str == domstr)
def testWriteXML(): pass
0a84a338f9fb578303eb4341dbf0e8514dafe7e0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/0a84a338f9fb578303eb4341dbf0e8514dafe7e0/test_minidom.py