Exemplo n.º 1
0
def sign_binaries(_: Dict[str, str]):
    """Sign binaries with certificate (must be installed on machine)"""
    print("digitally signing binaries...")
    for bin_file in _get_binaries():
        utils.system([
            "signtool",
            "sign",
            "/n",
            "Ehsan Iran Nejad",
            "/t",
            "http://timestamp.digicert.com",
            "/fd",
            "sha256",
            f"{bin_file}",
        ])
Exemplo n.º 2
0
def sign_installers(_: Dict[str, str]):
    """Sign installers with certificate (must be installed on machine)"""
    print("digitally signing installers...")
    build_version = props.get_version()
    for installer_exe_fmt in configs.INSTALLER_EXES:
        installer_exe = installer_exe_fmt.format(version=build_version)
        utils.system([
            "signtool",
            "sign",
            "/n",
            "Ehsan Iran Nejad",
            "/t",
            "http://timestamp.digicert.com",
            "/fd",
            "sha256",
            f"{installer_exe}",
        ])
Exemplo n.º 3
0
def _installer_set_version(version) -> Tuple[str, str]:
    installer = "advancedinstaller.com"
    product_codes = []
    for script in [configs.PYREVIT_AIPFILE, configs.PYREVIT_CLI_AIPFILE]:
        print(f"Updating installer script {script} to {version}")
        utils.system(
            [installer, "/edit",
             op.abspath(script), "/setversion", version])
        product_code_report = utils.system([
            installer,
            "/edit",
            script,
            "/getproperty",
            "ProductCode",
        ])
        # e.g. 1033:{uuid}
        product_codes.append(product_code_report.split(":")[1])
    return (product_codes[0], product_codes[1])
Exemplo n.º 4
0
def start_telem(_: Dict[str, str]):
    """Start a telemetry test server"""
    # make sure db is available
    _ensure_db(_)

    test_bin = _get_test_bin()
    # build a server binary for testing
    build_telem({"<output>": op.basename(test_bin)})

    # listen for CTRL+C
    signal.signal(signal.SIGINT, _handle_break)

    # run it
    utils.system([
        test_bin,
        "mongodb://*****:*****@localhost:27017/pyrevit",
        "--scripts=scripts",
        "--events=events",
        "--port=8090",
    ],
                 dump_stdout=True)
Exemplo n.º 5
0
def build_docs(_: Dict[str, str]):
    """Build the python docs"""
    report = utils.system([
        "pipenv",
        "run",
        "sphinx-build",
        "-b",
        "html",
        configs.DOCS_DIR,
        configs.DOCS_BUILD,
    ],
                          cwd=configs.DOCS_DIR)
    print(report)
Exemplo n.º 6
0
def count_sloc(_: Dict[str, str]):
    """Count SLOC across pyRevit source codes"""
    print("Counting single lines of code...")
    counter_args = [
        "pygount",
        "--format=summary",
        "--suffix=cs,py,go",
        # lets not count the submodules
        "--folders-to-skip",
        "modules",
    ]
    counter_args.extend(configs.SOURCE_DIRS)
    report = utils.system(counter_args)
    print(report)
Exemplo n.º 7
0
def report_clog(args: Dict[str, str]):
    """Report changes from given <tag> to HEAD
    Queries github issue information for better reporting
    """
    tag_hash = utils.system(["git", "rev-parse", f"{args['<tag>']}"])
    gitlog_report = utils.system(
        ["git", "log", "--pretty=format:%h %s%n%b/", f"{tag_hash}..HEAD"]
    )
    changes = find_changes(gitlog_report)

    # groups changes (and purge)
    grouped_changes = defaultdict(list)
    for change in changes:
        # skip unintersting commits
        if any(re.search(x, change.message) for x in SKIP_PATTERNS):
            continue

        if change.groups:
            for group in change.groups:
                grouped_changes[group].append(change)
        else:
            grouped_changes[""].append(change)

    # report changes by groups in order
    for cgroup in CHANGE_GROUPS:
        header(cgroup.header, level=1)
        for change in grouped_changes[cgroup.tag]:
            if change.issue_type == 'issue':
                print(f"- Resolved Issue ({change.ticket}: {change.title})")
            elif change.issue_type == 'pr':
                print(f"- Merged PR ({change.ticket}: {change.title})")
            else:
                print(f"- {change.message}")

            for todo in change.todos:
                print(f'    - [ ] {todo}')
Exemplo n.º 8
0
def _build(name: str, sln: str, config: str):
    utils.ensure_windows()

    # clean
    slnpath = op.abspath(sln)
    logger.debug("building %s solution: %s", name, slnpath)
    # clean, restore, build
    print(f"Building {name}...")
    report = utils.system([
        "msbuild",
        slnpath,
        "-t:Clean;Restore;Build",
        f"-p:Configuration={config}",
    ])
    passed, report = utils.parse_msbuild_output(report)
    if not passed:
        _abort(report)
    else:
        print(f"Building {name} completed successfully")
Exemplo n.º 9
0
def _build(name: str, sln: str, config: str, print_output: Optional[bool] = False):
    utils.ensure_windows()

    # clean
    slnpath = op.abspath(sln)
    logger.debug("building %s solution: %s", name, slnpath)
    # clean, restore, build
    print(f"Building {name}...")
    report = utils.system(
        [
            "dotnet",
            "build",
            slnpath,
            "-c",
            f"{config}",
        ],
        dump_stdout=print_output
    )
    passed, report = utils.parse_dotnet_build_output(report)
    if not passed:
        _abort(report)
    else:
        print(f"Building {name} completed successfully")
Exemplo n.º 10
0
def build_autocmp(_: Dict[str, str]):
    """Build CLI shell autocomplete utility"""
    print("Updating autocomplete utility dependencies...")
    utils.system(["go", "get", "github.com/posener/complete"])
    print("Autocomplete utility dependencies successfully updated")

    # generate go autocomplete source from usage patterns
    go_ast = parse_docopts(configs.USAGEPATTERNS)
    if go_ast:
        go_code = go_ast.write_go()
        with open(configs.AUTOCOMP, "w") as gf:
            gf.write(go_code)

    print("Building autocomplete utility...")
    target = op.abspath(configs.AUTOCOMPBIN)
    utils.system(["go", "fmt", configs.AUTOCOMP])
    utils.system(["go", "build", "-o", target, configs.AUTOCOMP])
    print("Building autocomplete utility succompleted successfully")
    os.remove(configs.AUTOCOMP)
Exemplo n.º 11
0
def _commit_changes(msg):
    utils.system(['git', 'add', '--all'])
    utils.system(['git', 'commit', '-m', msg])
Exemplo n.º 12
0
def _ensure_clean_tree():
    res = utils.system(['git', 'status'])
    if 'nothing to commit' not in res:
        print('You have uncommited changes in working tree. Commit those first')
        sys.exit(1)
Exemplo n.º 13
0
def _tag_changes():
    build_version = props.get_version()
    utils.system(["git", "tag", f"v{build_version}"])
    utils.system(["git", "tag", f"cli-v{build_version}"])
Exemplo n.º 14
0
def _commit_changes(msg):
    for commit_file in configs.COMMIT_FILES:
        utils.system(["git", "add", commit_file])
    utils.system(["git", "commit", "-m", msg])
Exemplo n.º 15
0
def _ensure_clean_tree():
    res = utils.system(["git", "status"])
    if "nothing to commit" not in res:
        print(
            "You have uncommited changes in working tree. Commit those first")
        sys.exit(1)