Пример #1
0
    def _download_one(self, course_info, source_info):
        '''
        给定一门课,下载该门课指定一个资源
        :return:
        '''
        # 按季度划分课程
        if "秋季" in course_info['name']:
            base_dir = self._source_dir + '/秋季/'
        elif "春季" in course_info['name']:
            base_dir = self._source_dir + '/春季/'
        else:
            base_dir = self._source_dir+ '/夏季/'
        if not os.path.exists(base_dir):
            os.mkdir(base_dir)

        course_dir = base_dir + course_info['name']  # 课程目录
        if not os.path.exists(course_dir):
            os.mkdir(course_dir)

        dirs = source_info['name'].split('/')[0:-1]  # 只取目录部分
        if dirs:
            # 存在文件夹,递归检测文件夹
            self.__recur_mkdir(course_dir,dirs)

        file_path = base_dir + course_info["name"] + '/' + source_info['name']  # 文件存储路径
        if not os.path.isfile(file_path):
            # 只下载没有的文件,若存在不下载,节省流量
            self._logger.info("正在下载:{}".format(source_info['name']))
            # content = self._S.get(source_info['url']).content
            # with open(file_path, 'wb') as f:
            #     f.write(content)
            download_file(url=source_info['url'], session=self._S, file_path=file_path)
            self._update_sources.append("[{}:{}]".format(course_info["name"], source_info['name']))  # 记录更新的课程数据
Пример #2
0
    def _build_openssl(self, file_name):
        cc.n('prepare OpenSSL pre-built package ... ', end='')
        if os.path.exists(self.OPENSSL_PATH_SRC):
            cc.w('already exists, skip.')
            return
        cc.v('')

        _alt_ver = '_'.join(env.ver_ossl.split('.'))

        file_name = 'Win32OpenSSL-{}.msi'.format(_alt_ver)
        installer = os.path.join(PATH_DOWNLOAD, file_name)

        if not os.path.exists(installer):
            if not utils.download_file(
                    'openssl installer',
                    'http://slproweb.com/download/{}'.format(filename),
                    PATH_DOWNLOAD, file_name):
                cc.e('can not download pre-built installer of OpenSSL.')
                return

        utils.ensure_file_exists(installer)

        cc.w('On Windows, we use pre-built package of OpenSSL.')
        cc.w('The installer have been downloaded at "{}".'.format(installer))
        cc.w('please install OpenSSL into "{}".'.format(self.OPENSSL_PATH_SRC))
        cc.w(
            '\nOnce the OpenSSL installed, press Enter to continue or Q to quit...',
            end='')
        try:
            x = env.input()
        except EOFError:
            x = 'q'
        if x == 'q':
            return
Пример #3
0
 def _build_openssl(self, file_name):
     _alt_ver = '_'.join(env.ver_ossl.split('.'))
     if not utils.download_file('openssl source tarball', 'https://github.com/openssl/openssl/archive/OpenSSL_{}.zip'.format(_alt_ver), PATH_DOWNLOAD, file_name):
         cc.e("can not download openssl source tarball.")
         return False
     else:
         return True
Пример #4
0
 def build_sqlite(self):
     file_name = 'sqlite-autoconf-{}.tar.gz'.format(env.ver_sqlite)
     if not utils.download_file(
             'sqlite source tarball',
             'http://sqlite.org/2017/{}'.format(file_name), PATH_DOWNLOAD,
             file_name):
         return
     self._build_sqlite(file_name)
Пример #5
0
 def build_jsoncpp(self):
     file_name = 'jsoncpp-{}.zip'.format(env.ver_jsoncpp)
     if not utils.download_file(
             'jsoncpp source tarball',
             'https://github.com/open-source-parsers/jsoncpp/archive/{}.zip'
             .format(env.ver_jsoncpp), PATH_DOWNLOAD, file_name):
         return
     self._build_jsoncpp(file_name)
Пример #6
0
 def build_mongoose(self):
     file_name = 'mongoose-{}.zip'.format(env.ver_mongoose)
     if not utils.download_file(
             'mongoose source tarball',
             'https://github.com/cesanta/mongoose/archive/{}.zip'.format(
                 env.ver_mongoose), PATH_DOWNLOAD, file_name):
         return
     self._build_mongoose(file_name)
Пример #7
0
 def build_libssh(self):
     file_name = 'libssh-{}.zip'.format(env.ver_libssh)
     if not utils.download_file(
             'libssh source tarball',
             'https://git.libssh.org/projects/libssh.git/snapshot/libssh-{}.zip'
             .format(env.ver_libssh), PATH_DOWNLOAD, file_name):
         return
     self._build_libssh(file_name)
Пример #8
0
 def build_libuv(self):
     file_name = 'libuv-{}.zip'.format(env.ver_libuv)
     if not utils.download_file(
             'libuv source tarball',
             'https://github.com/libuv/libuv/archive/v{}.zip'.format(
                 env.ver_libuv), PATH_DOWNLOAD, file_name):
         return
     self._build_libuv(file_name)
Пример #9
0
 def build_mbedtls(self):
     file_name = 'mbedtls-mbedtls-{}.zip'.format(env.ver_mbedtls)
     if not utils.download_file(
             'mbedtls source tarball',
             'https://github.com/ARMmbed/mbedtls/archive/mbedtls-{}.zip'.
             format(env.ver_mbedtls), PATH_DOWNLOAD, file_name):
         return
     self._build_mbedtls(file_name)
Пример #10
0
 def build_openssl(self):
     file_name = 'openssl-{}.zip'.format(env.ver_openssl)
     _alt_ver = '_'.join(env.ver_openssl.split('.'))
     if not utils.download_file(
             'openssl source tarball',
             'https://github.com/openssl/openssl/archive/OpenSSL_{}.zip'.
             format(_alt_ver), PATH_DOWNLOAD, file_name):
         return
     self._build_openssl(file_name)
Пример #11
0
 def _build_openssl(self, file_name):
     _alt_ver = '_'.join(env.ver_ossl.split('.'))
     if not utils.download_file(
             'openssl source tarball',
             'https://github.com/openssl/openssl/archive/OpenSSL_{}.zip'.
             format(_alt_ver), PATH_DOWNLOAD, file_name):
         cc.e("can not download openssl source tarball.")
         return False
     else:
         return True
Пример #12
0
    def _build_openssl(self, file_name):
        cc.n('prepare OpenSSL pre-built package ... ', end='')
        if os.path.exists(self.OPENSSL_PATH_SRC):
            cc.w('already exists, skip.')
            return
        cc.v('')

        _alt_ver = '_'.join(env.ver_ossl.split('.'))

        file_name = 'Win32OpenSSL-{}.msi'.format(_alt_ver)
        installer = os.path.join(PATH_DOWNLOAD, file_name)

        if not os.path.exists(installer):
            if not utils.download_file(
                    'openssl installer',
                    'http://slproweb.com/download/{}'.format(filename),
                    PATH_DOWNLOAD, file_name):
                cc.e('can not download pre-built installer of OpenSSL.')
                return

        utils.ensure_file_exists(installer)

        cc.w('On Windows, we use pre-built package of OpenSSL.')
        cc.w('The installer have been downloaded at "{}".'.format(installer))
        cc.w('please install OpenSSL into "{}".'.format(self.OPENSSL_PATH_SRC))
        cc.w(
            '\nOnce the OpenSSL installed, press Enter to continue or Q to quit...',
            end='')
        try:
            x = input()
        except EOFError:
            x = 'q'
        if x == 'q':
            return

        _chk_output = [
            os.path.join(self.OPENSSL_PATH_SRC, 'include', 'openssl', 'aes.h'),
            os.path.join(self.OPENSSL_PATH_SRC, 'include', 'openssl',
                         'opensslv.h'),
            os.path.join(self.OPENSSL_PATH_SRC, 'lib', 'VC',
                         'libcrypto32MT.lib'),
            os.path.join(self.OPENSSL_PATH_SRC, 'lib', 'VC', 'libeay32MT.lib'),
            os.path.join(self.OPENSSL_PATH_SRC, 'lib', 'VC', 'ssleay32MT.lib'),
            os.path.join(self.OPENSSL_PATH_SRC, 'lib', 'VC', 'static',
                         'libcrypto32MT.lib'),
            os.path.join(self.OPENSSL_PATH_SRC, 'lib', 'VC', 'static',
                         'libeay32MT.lib'),
            os.path.join(self.OPENSSL_PATH_SRC, 'lib', 'VC', 'static',
                         'ssleay32MT.lib'),
        ]

        for f in _chk_output:
            if not os.path.exists(f):
                raise RuntimeError(
                    'build openssl static library from source code failed.')
Пример #13
0
    def _build_openssl(self, file_name):
        cc.n('build openssl static library from source code... ')

        _alt_ver = '_'.join(env.ver_ossl.split('.'))
        if not utils.download_file(
                'openssl source tarball',
                'https://github.com/openssl/openssl/archive/OpenSSL_{}.zip'.
                format(_alt_ver), PATH_DOWNLOAD, file_name):
            return

        _chk_output = [
            os.path.join(self.OPENSSL_PATH_SRC, 'out32', 'libeay32.lib'),
            os.path.join(self.OPENSSL_PATH_SRC, 'out32', 'ssleay32.lib'),
            os.path.join(self.OPENSSL_PATH_SRC, 'inc32', 'openssl',
                         'opensslconf.h'),
        ]

        need_build = False
        for f in _chk_output:
            if not os.path.exists(f):
                need_build = True
                break

        if not need_build:
            cc.n('build openssl static library from source code... ', end='')
            cc.w('already exists, skip.')
            return
        cc.v('')

        cc.n('prepare openssl source code...')
        _alt_ver = '_'.join(env.ver_ossl.split('.'))
        if not os.path.exists(self.OPENSSL_PATH_SRC):
            utils.unzip(os.path.join(PATH_DOWNLOAD, file_name), PATH_EXTERNAL)
            os.rename(
                os.path.join(PATH_EXTERNAL,
                             'openssl-OpenSSL_{}'.format(_alt_ver)),
                self.OPENSSL_PATH_SRC)
            if not os.path.exists(self.OPENSSL_PATH_SRC):
                raise RuntimeError('can not prepare openssl source code.')
        else:
            cc.w('already exists, skip.')

        os.chdir(self.OPENSSL_PATH_SRC)
        os.system('""{}" Configure VC-WIN32"'.format(env.perl))
        os.system(r'ms\do_nasm')
        os.system(r'"{}\VC\bin\vcvars32.bat" && nmake -f ms\nt.mak'.format(
            env.visual_studio_path))

        for f in _chk_output:
            if not os.path.exists(f):
                raise RuntimeError(
                    'build openssl static library from source code failed.')
Пример #14
0
 def _download_mbedtls(self, file_name):
     return utils.download_file(
         'mbedtls source tarball',
         'https://github.com/ARMmbed/mbedtls/archive/mbedtls-{}.zip'.format(
             env.ver_mbedtls), PATH_DOWNLOAD, file_name)
Пример #15
0
 def _download_libuv(self, file_name):
     return utils.download_file(
         'libuv source tarball',
         'https://github.com/libuv/libuv/archive/v{}.zip'.format(
             env.ver_libuv), PATH_DOWNLOAD, file_name)
Пример #16
0
 def build_mongoose(self):
     file_name = 'mongoose-{}.zip'.format(env.ver_mongoose)
     if not utils.download_file('mongoose source tarball', 'https://github.com/cesanta/mongoose/archive/{}.zip'.format(env.ver_mongoose), PATH_DOWNLOAD, file_name):
         return
     self._build_mongoose(file_name)
Пример #17
0
 def _download_zlib(self, file_name):
     return utils.download_file(
         'mbedtls source tarball',
         'https://www.zlib.net/zlib{}.zip'.format(env.ver_zlib_number),
         PATH_DOWNLOAD, file_name)
Пример #18
0
 def build_libssh(self):
     file_name = 'libssh-{}.zip'.format(env.ver_libssh)
     if not utils.download_file('libssh source tarball', 'https://git.libssh.org/projects/libssh.git/snapshot/libssh-{}.zip'.format(env.ver_libssh), PATH_DOWNLOAD, file_name):
         return
     self._build_libssh(file_name)
Пример #19
0
 def build_mbedtls(self):
     file_name = 'mbedtls-mbedtls-{}.zip'.format(env.ver_mbedtls)
     if not utils.download_file('mbedtls source tarball', 'https://github.com/ARMmbed/mbedtls/archive/mbedtls-{}.zip'.format(env.ver_mbedtls), PATH_DOWNLOAD, file_name):
         return
     self._build_mbedtls(file_name)
Пример #20
0
 def build_libuv(self):
     file_name = 'libuv-{}.zip'.format(env.ver_libuv)
     if not utils.download_file('libuv source tarball', 'https://github.com/libuv/libuv/archive/v{}.zip'.format(env.ver_libuv), PATH_DOWNLOAD, file_name):
         return
     self._build_libuv(file_name)
Пример #21
0
 def _download_mongoose(self, file_name):
     return utils.download_file(
         'mongoose source tarball',
         'https://github.com/cesanta/mongoose/archive/{}.zip'.format(
             env.ver_mongoose), PATH_DOWNLOAD, file_name)
Пример #22
0
 def _download_openssl(self, file_name):
     _alt_ver = '_'.join(env.ver_ossl.split('.'))
     return utils.download_file(
         'openssl source tarball',
         'https://github.com/openssl/openssl/archive/OpenSSL_{}.zip'.format(
             _alt_ver), PATH_DOWNLOAD, file_name)
Пример #23
0
 def _download_jsoncpp(self, file_name):
     return utils.download_file(
         'jsoncpp source tarball',
         'https://github.com/open-source-parsers/jsoncpp/archive/{}.zip'.
         format(env.ver_jsoncpp), PATH_DOWNLOAD, file_name)
Пример #24
0
 def build_jsoncpp(self):
     file_name = 'jsoncpp-{}.zip'.format(env.ver_jsoncpp)
     if not utils.download_file('jsoncpp source tarball', 'https://github.com/open-source-parsers/jsoncpp/archive/{}.zip'.format(env.ver_jsoncpp), PATH_DOWNLOAD, file_name):
         return
     self._build_jsoncpp(file_name)