Exemple #1
0
def zip_one_file(dir, to_pack, zip_name):
    verify_path_exists(dir)
    # for the benefit of pigz, we have to cd to the directory, because
    # we don't control the name of the file inside created zip file - it's
    # the same as path of the file we're compressing
    curr_dir = os.getcwd()
    os.chdir(dir)
    verify_path_exists(to_pack)
    util.delete_file(zip_name)  # ensure destination doesn't exist
    try:
        # -11 for zopfil compression
        # --keep to not delete the source file
        # --zip to create a single-file zip archive
        # we can't control the name of the file pigz will create, so rename
        # to desired name after it's created
        pigz_dst = to_pack + ".zip"
        util.delete_file(pigz_dst)
        run_cmd_throw("pigz", "-11", "--keep", "--zip", to_pack)
        print("Compressed using pigz.exe")
        if pigz_dst != zip_name:
            print("moving %s => %s" % (pigz_dst, zip_name))
            shutil.move(pigz_dst, zip_name)
    except:
        # if pigz.exe is not in path, use regular zip compression
        zip_file(zip_name, to_pack, to_pack, compress=True)
        print("Compressed using regular zip")
    verify_path_exists(zip_name)
    os.chdir(curr_dir)
Exemple #2
0
def zip_one_file(dir, to_pack, zip_name):
    verify_path_exists(dir)
    # for the benefit of pigz, we have to cd to the directory, because
    # we don't control the name of the file inside created zip file - it's
    # the same as path of the file we're compressing
    curr_dir = os.getcwd()
    os.chdir(dir)
    verify_path_exists(to_pack)
    util.delete_file(zip_name)  # ensure destination doesn't exist
    try:
        # -11 for zopfil compression
        # --keep to not delete the source file
        # --zip to create a single-file zip archive
        # we can't control the name of the file pigz will create, so rename
        # to desired name after it's created
        pigz_dst = to_pack + ".zip"
        util.delete_file(pigz_dst)
        run_cmd_throw("pigz", "-11", "--keep", "--zip", to_pack)
        print("Compressed using pigz.exe")
        if pigz_dst != zip_name:
            print("moving %s => %s" % (pigz_dst, zip_name))
            shutil.move(pigz_dst, zip_name)
    except:
        # if pigz.exe is not in path, use regular zip compression
        zip_file(zip_name, to_pack, to_pack, compress=True)
        print("Compressed using regular zip")
    verify_path_exists(zip_name)
    os.chdir(curr_dir)
Exemple #3
0
def create_pdb_zip_archive(dir, archive_name):
    archive_path = os.path.join(dir, archive_name)
    files = ["libmupdf.pdb", "Installer.pdb",
             "SumatraPDF-no-MuPDF.pdb", "SumatraPDF.pdb"]
    for file_name in files:
        file_path = os.path.join(dir, file_name)
        zip_file(archive_path, file_path, file_name, compress=True, append=True)
    print("Created zip archive: %s" % archive_path)
    return archive_path
def create_pdb_zip_archive(dir, archive_name):
    archive_path = os.path.join(dir, archive_name)
    files = ["libmupdf.pdb", "Installer.pdb",
             "SumatraPDF-no-MuPDF.pdb", "SumatraPDF.pdb"]
    for file_name in files:
        file_path = os.path.join(dir, file_name)
        zip_file(archive_path, file_path, file_name, compress=True, append=True)
    print("Created zip archive: %s" % archive_path)
    return archive_path
def download(account_input, password_input, courseList_input):

    account = account_input
    password = password_input
    course = courseList_input

    if not login(account, password):
        print("Login Failed")
        return ""
    else:
        path = os.path.join(data_path, course)
        if os.path.exists(path):
            return path + ".zip"

        dict[course] = {}
        download_lecture_notes(course)
        util.zip_file(data_path, course)
        zip_filename = course + ".zip"
        util.write_dict_to_json(data_path, dict, courseList_input)
        path = os.path.join(data_path, zip_filename)
        return {"link:": path}
Exemple #6
0
def deal_log(log_file):
    # log_file : upload/20180716/SUPPTOOL_LOG_20180507181756897.7z
    log_path = unzip_file(log_file)
    tester = template_tester()
    tester.log2html(log_path)
    tester.test(log_path)
    # report_file : ./report/20180717/SUPPTOOL_LOG_20180509003843892/*  # ./.../* 的格式是为了保证压缩时只压缩文件,不压缩目录
    report_files = './report/' + log_file.split('/')[-2] + '/' + os.path.splitext(os.path.basename(log_file))[0] + '/*'
    # download_file : download/20180717/SUPPTOOL_LOG_20180509003843892.7z
    download_file = zip_file(report_files)
    FileSimpleModel.objects.filter(file_field=log_file).update(report_download=download_file)
    # 清理 upload/MMDD 下的 7z 文件以及解压的目录。MMDD会保留,暂时不管它
    os.remove(log_file)
    shutil.rmtree(log_file.split('.')[0])
Exemple #7
0
def main():
  global upload
  if len(args) != 0:
    usage()
  verify_started_in_right_directory()

  if build_prerelease:
    if svn_revision is None:
      run_cmd_throw("svn", "update")
      (out, err) = run_cmd_throw("svn", "info")
      ver = str(parse_svninfo_out(out))
    else:
      # allow to pass in an SVN revision, in case SVN itself isn't available
      ver = svn_revision
  else:
    ver = extract_sumatra_version(os.path.join("src", "Version.h"))
  log("Version: '%s'" % ver)

  filename_base = "SumatraPDF-%s" % ver
  if build_prerelease:
    filename_base = "SumatraPDF-prerelease-%s" % ver

  s3_dir = "sumatrapdf/rel"
  if build_prerelease:
    s3_dir = "sumatrapdf/prerel"
  if upload_tmp:
    upload = True
    s3_dir += "tmp"

  if upload:
    log("Will upload to s3 at %s" % s3_dir)

  s3_prefix = "%s/%s" % (s3_dir, filename_base)
  s3_exe           = s3_prefix + ".exe"
  s3_installer     = s3_prefix + "-install.exe"
  s3_pdb_zip       = s3_prefix + ".pdb.zip"
  s3_exe_zip       = s3_prefix + ".zip"

  s3_files = [s3_exe, s3_installer, s3_pdb_zip]
  if not build_prerelease:
    s3_files.append(s3_exe_zip)

  cert_pwd = None
  cert_path = os.path.join("scripts", "cert.pfx")
  if upload:
    map(ensure_s3_doesnt_exist, s3_files)
    if not os.path.exists(os.path.join("scripts", "cert.pfx")):
      print("scripts/cert.pfx missing")
      sys.exit(1)
    import awscreds
    cert_pwd = awscreds.certpwd

  obj_dir = "obj-rel"
  if target_platform == "X64":
    obj_dir += "64"

  if not testing and not build_test_installer and not build_rel_installer:
    shutil.rmtree(obj_dir, ignore_errors=True)
    shutil.rmtree(os.path.join("mupdf", "generated"), ignore_errors=True)

  config = "CFG=rel"
  if build_test_installer and not build_prerelease:
    obj_dir = "obj-dbg"
    config = "CFG=dbg"
  extcflags = ""
  if build_prerelease:
    extcflags = "EXTCFLAGS=-DSVN_PRE_RELEASE_VER=%s" % ver
  platform = "PLATFORM=%s" % (target_platform or "X86")

  run_cmd_throw("nmake", "-f", "makefile.msvc", config, extcflags, platform, "all_sumatrapdf")
  exe = os.path.join(obj_dir, "SumatraPDF.exe")
  if upload:
    sign(exe, cert_pwd)
    sign(os.path.join(obj_dir, "uninstall.exe"), cert_pwd)

  build_installer_data(obj_dir)
  run_cmd_throw("nmake", "-f", "makefile.msvc", "Installer", config, platform, extcflags)

  if build_test_installer or build_rel_installer:
    sys.exit(0)

  installer = os.path.join(obj_dir, "Installer.exe")
  if upload:
    sign(installer, cert_pwd)

  pdb_zip = os.path.join(obj_dir, "%s.pdb.zip" % filename_base)

  zip_file(pdb_zip, os.path.join(obj_dir, "libmupdf.pdb"))
  zip_file(pdb_zip, os.path.join(obj_dir, "Installer.pdb"), append=True)
  zip_file(pdb_zip, os.path.join(obj_dir, "SumatraPDF-no-MuPDF.pdb"), append=True)
  zip_file(pdb_zip, os.path.join(obj_dir, "SumatraPDF.pdb"), append=True)

  builds_dir = os.path.join("builds", ver)
  if os.path.exists(builds_dir):
    shutil.rmtree(builds_dir)
  os.makedirs(builds_dir)

  copy_to_dst_dir(exe, builds_dir)
  copy_to_dst_dir(installer, builds_dir)
  copy_to_dst_dir(pdb_zip, builds_dir)

  if not build_prerelease:
    exe_zip = os.path.join(obj_dir, "%s.zip" % filename_base)
    zip_file(exe_zip, exe, "SumatraPDF.exe", compress=True)
    ensure_path_exists(exe_zip)
    copy_to_dst_dir(exe_zip, builds_dir)

  if not upload: return

  if build_prerelease:
    jstxt  = 'var sumLatestVer = %s;\n' % ver
    jstxt += 'var sumBuiltOn = "%s";\n' % time.strftime("%Y-%m-%d")
    jstxt += 'var sumLatestName = "%s";\n' % s3_exe.split("/")[-1]
    jstxt += 'var sumLatestExe = "http://kjkpub.s3.amazonaws.com/%s";\n' % s3_exe
    jstxt += 'var sumLatestPdb = "http://kjkpub.s3.amazonaws.com/%s";\n' % s3_pdb_zip
    jstxt += 'var sumLatestInstaller = "http://kjkpub.s3.amazonaws.com/%s";\n' % s3_installer

  s3UploadFilePublic(installer, s3_installer)
  s3UploadFilePublic(pdb_zip, s3_pdb_zip)
  s3UploadFilePublic(exe, s3_exe)

  if build_prerelease:
    s3UploadDataPublic(jstxt, "sumatrapdf/sumatralatest.js")
    txt = "%s\n" % ver
    s3UploadDataPublic(txt, "sumatrapdf/sumpdf-prerelease-latest.txt")
    deleteOldPreReleaseBuilds()
  else:
    s3UploadFilePublic(exe_zip, s3_exe_zip)
def main():
  global upload
  if len(args) != 0:
    usage()
  verify_started_in_right_directory()

  if build_prerelease:
    if svn_revision is None:
      run_cmd_throw("svn", "update")
      (out, err) = run_cmd_throw("svn", "info")
      ver = str(parse_svninfo_out(out))
    else:
      # allow to pass in an SVN revision, in case SVN itself isn't available
      ver = svn_revision
  else:
    ver = extract_sumatra_version(os.path.join("src", "Version.h"))
  log("Version: '%s'" % ver)

  # don't update translations for release versions to prevent Trunk changes
  # from messing up the compilation of a point release on a branch
  if g_new_translation_system and build_prerelease and not skip_transl_update:
    trans_upload.uploadStringsIfChanged()
    changed = trans_download.downloadAndUpdateTranslationsIfChanged()
    # Note: this is not a perfect check since re-running the script will
    # proceed
    if changed:
      print("\nNew translations have been downloaded from apptranslator.og")
      print("Please verify and checkin src/Translations_txt.cpp and strings/translations.txt")
      sys.exit(1)

  filename_base = "SumatraPDF-%s" % ver
  if build_prerelease:
    filename_base = "SumatraPDF-prerelease-%s" % ver

  s3_dir = "sumatrapdf/rel"
  if build_prerelease:
    s3_dir = "sumatrapdf/prerel"
  if upload_tmp:
    upload = True
    s3_dir += "tmp"

  if upload:
    log("Will upload to s3 at %s" % s3_dir)
    conf = load_config()
    s3.set_secrets(conf.aws_access, conf.aws_secret)
    s3.set_bucket("kjkpub")

  s3_prefix = "%s/%s" % (s3_dir, filename_base)
  s3_exe           = s3_prefix + ".exe"
  s3_installer     = s3_prefix + "-install.exe"
  s3_pdb_zip       = s3_prefix + ".pdb.zip"
  s3_exe_zip       = s3_prefix + ".zip"

  s3_files = [s3_exe, s3_installer, s3_pdb_zip]
  if not build_prerelease:
    s3_files.append(s3_exe_zip)

  cert_pwd = None
  cert_path = os.path.join("scripts", "cert.pfx")
  if upload:
    map(s3.verify_doesnt_exist, s3_files)
    verify_path_exists(cert_path)
    conf = load_config()
    cert_pwd = conf.GetCertPwdMustExist()

  obj_dir = "obj-rel"
  if target_platform == "X64":
    obj_dir += "64"

  if not testing and not build_test_installer and not build_rel_installer:
    shutil.rmtree(obj_dir, ignore_errors=True)
    shutil.rmtree(os.path.join("mupdf", "generated"), ignore_errors=True)

  config = "CFG=rel"
  if build_test_installer and not build_prerelease:
    obj_dir = "obj-dbg"
    config = "CFG=dbg"
  extcflags = ""
  if build_prerelease:
    extcflags = "EXTCFLAGS=-DSVN_PRE_RELEASE_VER=%s" % ver
  platform = "PLATFORM=%s" % (target_platform or "X86")

  run_cmd_throw("nmake", "-f", "makefile.msvc", config, extcflags, platform, "all_sumatrapdf")
  exe = os.path.join(obj_dir, "SumatraPDF.exe")
  if upload:
    sign(exe, cert_pwd)
    sign(os.path.join(obj_dir, "uninstall.exe"), cert_pwd)

  build_installer_data(obj_dir)
  run_cmd_throw("nmake", "-f", "makefile.msvc", "Installer", config, platform, extcflags)

  if build_test_installer or build_rel_installer:
    sys.exit(0)

  installer = os.path.join(obj_dir, "Installer.exe")
  if upload:
    sign(installer, cert_pwd)

  pdb_zip = os.path.join(obj_dir, "%s.pdb.zip" % filename_base)

  zip_file(pdb_zip, os.path.join(obj_dir, "libmupdf.pdb"))
  zip_file(pdb_zip, os.path.join(obj_dir, "Installer.pdb"), append=True)
  zip_file(pdb_zip, os.path.join(obj_dir, "SumatraPDF-no-MuPDF.pdb"), append=True)
  zip_file(pdb_zip, os.path.join(obj_dir, "SumatraPDF.pdb"), append=True)

  builds_dir = os.path.join("builds", ver)
  if os.path.exists(builds_dir):
    shutil.rmtree(builds_dir)
  os.makedirs(builds_dir)

  copy_to_dst_dir(exe, builds_dir)
  copy_to_dst_dir(installer, builds_dir)
  copy_to_dst_dir(pdb_zip, builds_dir)

  if not build_prerelease:
    exe_zip = os.path.join(obj_dir, "%s.zip" % filename_base)
    zip_file(exe_zip, exe, "SumatraPDF.exe", compress=True)
    verify_path_exists(exe_zip)
    copy_to_dst_dir(exe_zip, builds_dir)

  if not upload: return

  if build_prerelease:
    jstxt  = 'var sumLatestVer = %s;\n' % ver
    jstxt += 'var sumBuiltOn = "%s";\n' % time.strftime("%Y-%m-%d")
    jstxt += 'var sumLatestName = "%s";\n' % s3_exe.split("/")[-1]
    jstxt += 'var sumLatestExe = "http://kjkpub.s3.amazonaws.com/%s";\n' % s3_exe
    jstxt += 'var sumLatestPdb = "http://kjkpub.s3.amazonaws.com/%s";\n' % s3_pdb_zip
    jstxt += 'var sumLatestInstaller = "http://kjkpub.s3.amazonaws.com/%s";\n' % s3_installer

  s3.upload_file_public(installer, s3_installer)
  s3.upload_file_public(pdb_zip, s3_pdb_zip)
  s3.upload_file_public(exe, s3_exe)

  if build_prerelease:
    s3.upload_data_public(jstxt, "sumatrapdf/sumatralatest.js")
    txt = "%s\n" % ver
    s3.upload_data_public(txt, "sumatrapdf/sumpdf-prerelease-latest.txt")
    deleteOldPreReleaseBuilds()
  else:
    s3.upload_file_public(exe_zip, s3_exe_zip)
Exemple #9
0
def main():
    global upload
    if len(args) != 0:
        usage()
    verify_started_in_right_directory()

    if build_prerelease:
        if svn_revision is None:
            run_cmd_throw("svn", "update")
            (out, err) = run_cmd_throw("svn", "info")
            ver = str(parse_svninfo_out(out))
        else:
            # allow to pass in an SVN revision, in case SVN itself isn't available
            ver = svn_revision
    else:
        ver = extract_sumatra_version(os.path.join("src", "Version.h"))
    log("Version: '%s'" % ver)

    filename_base = "SumatraPDF-%s" % ver
    if build_prerelease:
        filename_base = "SumatraPDF-prerelease-%s" % ver

    s3_dir = "sumatrapdf/rel"
    if build_prerelease:
        s3_dir = "sumatrapdf/prerel"
    if upload_tmp:
        upload = True
        s3_dir += "tmp"

    if upload:
        log("Will upload to s3 at %s" % s3_dir)

    s3_prefix = "%s/%s" % (s3_dir, filename_base)
    s3_exe = s3_prefix + ".exe"
    s3_installer = s3_prefix + "-install.exe"
    s3_pdb_zip = s3_prefix + ".pdb.zip"
    s3_exe_zip = s3_prefix + ".zip"

    s3_files = [s3_exe, s3_installer, s3_pdb_zip]
    if not build_prerelease:
        s3_files.append(s3_exe_zip)

    cert_pwd = None
    cert_path = os.path.join("scripts", "cert.pfx")
    if upload:
        map(ensure_s3_doesnt_exist, s3_files)
        if not os.path.exists(os.path.join("scripts", "cert.pfx")):
            print("scripts/cert.pfx missing")
            sys.exit(1)
        import awscreds
        cert_pwd = awscreds.certpwd

    obj_dir = "obj-rel"
    if target_platform == "X64":
        obj_dir += "64"

    if not testing and not build_test_installer and not build_rel_installer:
        shutil.rmtree(obj_dir, ignore_errors=True)

    config = "CFG=rel"
    if build_test_installer and not build_prerelease:
        obj_dir = "obj-dbg"
        config = "CFG=dbg"
    extcflags = ""
    if build_prerelease:
        extcflags = "EXTCFLAGS=-DSVN_PRE_RELEASE_VER=%s" % ver
    platform = "PLATFORM=%s" % (target_platform or "X86")

    run_cmd_throw("nmake", "-f", "makefile.msvc", config, extcflags, platform,
                  "all_sumatrapdf")
    exe = os.path.join(obj_dir, "SumatraPDF.exe")
    if upload:
        sign(exe, cert_pwd)
        sign(os.path.join(obj_dir, "uninstall.exe"), cert_pwd)

    build_installer_data(obj_dir)
    run_cmd_throw("nmake", "-f", "makefile.msvc", "Installer", config,
                  platform, extcflags)

    if build_test_installer or build_rel_installer:
        sys.exit(0)

    installer = os.path.join(obj_dir, "Installer.exe")
    if upload:
        sign(installer, cert_pwd)

    pdb_zip = os.path.join(obj_dir, "%s.pdb.zip" % filename_base)

    zip_file(pdb_zip, os.path.join(obj_dir, "libmupdf.pdb"))
    zip_file(pdb_zip, os.path.join(obj_dir, "Installer.pdb"), append=True)
    zip_file(pdb_zip,
             os.path.join(obj_dir, "SumatraPDF-no-MuPDF.pdb"),
             append=True)
    zip_file(pdb_zip, os.path.join(obj_dir, "SumatraPDF.pdb"), append=True)

    builds_dir = os.path.join("builds", ver)
    if os.path.exists(builds_dir):
        shutil.rmtree(builds_dir)
    os.makedirs(builds_dir)

    copy_to_dst_dir(exe, builds_dir)
    copy_to_dst_dir(installer, builds_dir)
    copy_to_dst_dir(pdb_zip, builds_dir)

    if not build_prerelease:
        exe_zip = os.path.join(obj_dir, "%s.zip" % filename_base)
        zip_file(exe_zip, exe, "SumatraPDF.exe", compress=True)
        ensure_path_exists(exe_zip)
        copy_to_dst_dir(exe_zip, builds_dir)

    if not upload: return

    if build_prerelease:
        jstxt = 'var sumLatestVer = %s;\n' % ver
        jstxt += 'var sumBuiltOn = "%s";\n' % time.strftime("%Y-%m-%d")
        jstxt += 'var sumLatestName = "%s";\n' % s3_exe.split("/")[-1]
        jstxt += 'var sumLatestExe = "http://kjkpub.s3.amazonaws.com/%s";\n' % s3_exe
        jstxt += 'var sumLatestPdb = "http://kjkpub.s3.amazonaws.com/%s";\n' % s3_pdb_zip
        jstxt += 'var sumLatestInstaller = "http://kjkpub.s3.amazonaws.com/%s";\n' % s3_installer

    s3UploadFilePublic(installer, s3_installer)
    s3UploadFilePublic(pdb_zip, s3_pdb_zip)
    s3UploadFilePublic(exe, s3_exe)

    if build_prerelease:
        s3UploadDataPublic(jstxt, "sumatrapdf/sumatralatest.js")
        txt = "%s\n" % ver
        s3UploadDataPublic(txt, "sumatrapdf/sumpdf-prerelease-latest.txt")
        deleteOldPreReleaseBuilds()
    else:
        s3UploadFilePublic(exe_zip, s3_exe_zip)