Ejemplo n.º 1
0
 def urlretrieval(self, mail):
     url, cs, cwd = self.items[0], [], ''
     if mail:
         cs = [self.mailer]
     elif self.ui.proto == 'ftp' or urlregex.ftpcheck(url):
         if self.ui.ftpdir:
             # otherwise eventual download to cwd
             self.ui.ftpdir = util.savedir(self.ui.ftpdir)
             cwd = os.getcwdu()
             os.chdir(self.ui.ftpdir)
         cs = [self.ui.configitem('net', 'ftpclient', default='ftp')]
         # for ftp programs that have more of a browser interface
         # we assume a file if url has a file extension
         if os.path.splitext(url)[1]:
             exe = os.path.split(cs[0])[-1]
             if exe == 'lftp':
                 # lftp needs an optional command
                 cs += ['-c', 'get']
             elif exe == 'ncftp':
                 # use ncftpget instead
                 cs = ['%sget' % cs[0]]
     if not cs and not self.ui.getdir:
         b = pybrowser.browser(parentui=self.ui, items=self.items)
         b.urlvisit()
     elif self.ui.getdir:
         uget = wget.wget(self.ui)
         uget.download([url])
     else:
         cs += [url]
         util.systemcall(cs)
     if cwd:
         os.chdir(cwd)
Ejemplo n.º 2
0
 def urlretrieval(self, mail):
     url, cs, cwd = self.items[0], [], ''
     if mail:
         cs = [self.mailer]
     elif self.ui.proto == 'ftp' or urlregex.ftpcheck(url):
         if self.ui.ftpdir:
             # otherwise eventual download to cwd
             self.ui.ftpdir = util.savedir(self.ui.ftpdir)
             cwd = os.getcwdu()
             os.chdir(self.ui.ftpdir)
         cs = [self.ui.configitem('net', 'ftpclient', default='ftp')]
         # for ftp programs that have more of a browser interface
         # we assume a file if url has a file extension
         if os.path.splitext(url)[1]:
             exe = os.path.split(cs[0])[-1]
             if exe == 'lftp':
                 # lftp needs an optional command
                 cs += ['-c', 'get']
             elif exe == 'ncftp':
                 # use ncftpget instead
                 cs = ['%sget' % cs[0]]
     if not cs and not self.ui.getdir:
         b = pybrowser.browser(parentui=self.ui, items=self.items)
         b.urlvisit()
     elif self.ui.getdir:
         uget = wget.wget(self.ui)
         uget.download([url])
     else:
         cs += [url]
         util.systemcall(cs)
     if cwd:
         os.chdir(cwd)
Ejemplo n.º 3
0
 def download(self, urls):
     self.ui.getdir = util.savedir(self.ui.getdir)
     for url in map(urlregex.webschemecomplete, urls):
         bn = url.rstrip('/').split('/')[-1]
         path = os.path.join(self.ui.getdir, bn)
         self.ui.note('downloading to %s ...\n' % path)
         s = self.request(url)
         if s:
             try:
                 fp = open(path, 'wb')
                 fp.write(s)
                 fp.close()
             except IOError, inst:
                 raise util.DeadMan(inst)
Ejemplo n.º 4
0
 def download(self, urls):
     self.ui.getdir = util.savedir(self.ui.getdir)
     for url in map(urlregex.webschemecomplete, urls):
         bn = url.rstrip('/').split('/')[-1]
         path = os.path.join(self.ui.getdir, bn)
         self.ui.note('downloading to %s ...\n' % path)
         s = self.request(url)
         if s:
             try:
                 fp = open(path, 'wb')
                 fp.write(s)
                 fp.close()
             except IOError, inst:
                 raise util.DeadMan(inst)