예제 #1
0
    def __init__(self, protocol, host, rootdir='', file_list=None):
        '''

        Initialize the files in list with today as last-modification date.
        Size is also preset to zero, size will be set after download

        :param file_list: list of files to download on server
        :type file_list: list
        '''
        FTPDownload.__init__(self, protocol, host, rootdir)
        if file_list is None:
            file_list = []
        today = datetime.date.today()
        self.files_to_download = []
        self.headers = {}
        for file in file_list:
            rfile = {}
            rfile['root'] = self.rootdir
            rfile['permissions'] = ''
            rfile['group'] = ''
            rfile['user'] = ''
            rfile['size'] = 0
            rfile['month'] = today.month
            rfile['day'] = today.day
            rfile['year'] = today.year
            rfile['name'] = file
            self.files_to_download.append(rfile)
예제 #2
0
    def __init__(self, protocol, host, rootdir='', file_list=None):
        '''

        Initialize the files in list with today as last-modification date.
        Size is also preset to zero, size will be set after download

        :param file_list: list of files to download on server
        :type file_list: list
        '''
        FTPDownload.__init__(self, protocol, host, rootdir)
        if file_list is None:
            file_list = []
        today = datetime.date.today()
        self.files_to_download = []
        self.headers = {}
        for file in file_list:
            rfile = {}
            rfile['root'] = self.rootdir
            rfile['permissions'] = ''
            rfile['group'] = ''
            rfile['user'] = ''
            rfile['size'] = 0
            rfile['month'] = today.month
            rfile['day'] = today.day
            rfile['year'] = today.year
            rfile['name'] = file
            rfile['hash'] = None
            self.files_to_download.append(rfile)
예제 #3
0
 def test_download_in_subdir(self):
     ftpd = FTPDownload('ftp', 'ftp.ncbi.nih.gov', '/blast/')
     (file_list, dir_list) = ftpd.list()
     ftpd.match([r'^db/FASTA/alu.*\.gz$'], file_list, dir_list)
     ftpd.download(self.utils.data_dir)
     ftpd.close()
     self.assertTrue(len(ftpd.files_to_download) == 2)
예제 #4
0
 def test_download_in_subdir(self):
   ftpd = FTPDownload('ftp', 'ftp.ncbi.nih.gov', '/blast/')
   (file_list, dir_list) = ftpd.list()
   ftpd.match([r'^db/FASTA/alu.*\.gz$'], file_list, dir_list)
   ftpd.download(self.utils.data_dir)
   ftpd.close()
   self.assertTrue(len(ftpd.files_to_download) == 2)
예제 #5
0
    def get_handler(self, protocol, server, remote_dir, list_file=None):
        """
        Get a protocol download handler
        """
        if list_file is None:
            list_file = []
        downloader = None
        if protocol == "ftp" or protocol == "sftp":
            downloader = FTPDownload(protocol, server, remote_dir)
        if protocol == "http":
            downloader = HTTPDownload(protocol, server, remote_dir, self.bank.config)
        if protocol == "local":
            downloader = LocalDownload(remote_dir)
        if protocol == "directftp":
            downloader = DirectFTPDownload("ftp", server, remote_dir, list_file)
        if protocol == "directhttp":
            downloader = DirectHttpDownload("http", server, remote_dir, list_file)
        if downloader is not None:
            downloader.bank = self.bank.name

        proxy = self.bank.config.get("proxy")
        proxy_auth = self.bank.config.get("proxy_auth")
        if proxy is not None and proxy:
            downloader.set_proxy(proxy, proxy_auth)
        return downloader
예제 #6
0
    def get_handler(self, protocol, server, remote_dir, list_file=None):
        '''
        Get a protocol download handler
        '''
        if list_file is None:
            list_file = []
        downloader = None
        if protocol == 'ftp' or protocol == 'sftp':
            downloader = FTPDownload(protocol, server, remote_dir)
        if protocol == 'http':
            downloader = HTTPDownload(protocol, server, remote_dir, self.bank.config)
        if protocol == 'local':
            downloader = LocalDownload(remote_dir)
        if protocol == 'directftp':
            downloader = DirectFTPDownload('ftp', server, remote_dir, list_file)
        if protocol == 'directhttp':
            downloader = DirectHttpDownload('http', server, remote_dir, list_file)
        if downloader is not None:
            downloader.bank = self.bank.name

        proxy = self.bank.config.get('proxy')
        proxy_auth = self.bank.config.get('proxy_auth')
        if proxy is not None and proxy:
            downloader.set_proxy(proxy, proxy_auth)
        return downloader
예제 #7
0
 def test_download(self):
     ftpd = FTPDownload("ftp", "ftp.ncbi.nih.gov", "/blast/db/FASTA/")
     (file_list, dir_list) = ftpd.list()
     ftpd.match([r"^alu.*\.gz$"], file_list, dir_list)
     ftpd.download(self.utils.data_dir)
     ftpd.close()
     self.assertTrue(len(ftpd.files_to_download) == 2)
예제 #8
0
 def test_download_or_copy(self):
   ftpd = FTPDownload('ftp', 'ftp.ncbi.nih.gov', '/blast/')
   ftpd.files_to_download = [
         {'name':'/test1', 'year': '2013', 'month': '11', 'day': '10', 'size': 10},
         {'name':'/test2', 'year': '2013', 'month': '11', 'day': '10', 'size': 10},
         {'name':'/test/test1', 'year': '2013', 'month': '11', 'day': '10', 'size': 10},
         {'name':'/test/test11', 'year': '2013', 'month': '11', 'day': '10', 'size': 10}
         ]
   available_files = [
         {'name':'/test1', 'year': '2013', 'month': '11', 'day': '10', 'size': 10},
         {'name':'/test12', 'year': '2013', 'month': '11', 'day': '10', 'size': 10},
         {'name':'/test3', 'year': '2013', 'month': '11', 'day': '10', 'size': 10},
         {'name':'/test/test1', 'year': '2013', 'month': '11', 'day': '10', 'size': 20},
         {'name':'/test/test11', 'year': '2013', 'month': '11', 'day': '10', 'size': 10}
         ]
   ftpd.download_or_copy(available_files, '/biomaj', False)
   ftpd.close()
   self.assertTrue(len(ftpd.files_to_download)==2)
   self.assertTrue(len(ftpd.files_to_copy)==2)
예제 #9
0
 def test_download_or_copy(self):
     ftpd = FTPDownload("ftp", "ftp.ncbi.nih.gov", "/blast/")
     ftpd.files_to_download = [
         {"name": "/test1", "year": "2013", "month": "11", "day": "10", "size": 10},
         {"name": "/test2", "year": "2013", "month": "11", "day": "10", "size": 10},
         {"name": "/test/test1", "year": "2013", "month": "11", "day": "10", "size": 10},
         {"name": "/test/test11", "year": "2013", "month": "11", "day": "10", "size": 10},
     ]
     available_files = [
         {"name": "/test1", "year": "2013", "month": "11", "day": "10", "size": 10},
         {"name": "/test12", "year": "2013", "month": "11", "day": "10", "size": 10},
         {"name": "/test3", "year": "2013", "month": "11", "day": "10", "size": 10},
         {"name": "/test/test1", "year": "2013", "month": "11", "day": "10", "size": 20},
         {"name": "/test/test11", "year": "2013", "month": "11", "day": "10", "size": 10},
     ]
     ftpd.download_or_copy(available_files, "/biomaj", False)
     ftpd.close()
     self.assertTrue(len(ftpd.files_to_download) == 2)
     self.assertTrue(len(ftpd.files_to_copy) == 2)
예제 #10
0
 def __init__(self, protocol, host, rootdir, config):
     FTPDownload.__init__(self, protocol, host, rootdir)
     self.config = config
예제 #11
0
 def test_download_or_copy(self):
     ftpd = FTPDownload('ftp', 'ftp.ncbi.nih.gov', '/blast/')
     ftpd.files_to_download = [{
         'name': '/test1',
         'year': '2013',
         'month': '11',
         'day': '10',
         'size': 10
     }, {
         'name': '/test2',
         'year': '2013',
         'month': '11',
         'day': '10',
         'size': 10
     }, {
         'name': '/test/test1',
         'year': '2013',
         'month': '11',
         'day': '10',
         'size': 10
     }, {
         'name': '/test/test11',
         'year': '2013',
         'month': '11',
         'day': '10',
         'size': 10
     }]
     available_files = [{
         'name': '/test1',
         'year': '2013',
         'month': '11',
         'day': '10',
         'size': 10
     }, {
         'name': '/test12',
         'year': '2013',
         'month': '11',
         'day': '10',
         'size': 10
     }, {
         'name': '/test3',
         'year': '2013',
         'month': '11',
         'day': '10',
         'size': 10
     }, {
         'name': '/test/test1',
         'year': '2013',
         'month': '11',
         'day': '10',
         'size': 20
     }, {
         'name': '/test/test11',
         'year': '2013',
         'month': '11',
         'day': '10',
         'size': 10
     }]
     ftpd.download_or_copy(available_files, '/biomaj', False)
     ftpd.close()
     self.assertTrue(len(ftpd.files_to_download) == 2)
     self.assertTrue(len(ftpd.files_to_copy) == 2)
예제 #12
0
 def test_ftp_list(self):
     ftpd = FTPDownload('ftp', 'ftp.ncbi.nih.gov', '/blast/db/FASTA/')
     (file_list, dir_list) = ftpd.list()
     ftpd.close()
     self.assertTrue(len(file_list) > 1)
예제 #13
0
 def test_ftp_list(self):
   ftpd = FTPDownload('ftp', 'ftp.ncbi.nih.gov', '/blast/db/FASTA/')
   (file_list, dir_list) = ftpd.list()
   ftpd.close()
   self.assertTrue(len(file_list) > 1)
예제 #14
0
파일: http.py 프로젝트: markiskander/biomaj
 def __init__(self, protocol, host, rootdir, config):
     FTPDownload.__init__(self, protocol, host, rootdir)
     self.config = config