Beispiel #1
0
def main():
    runner = None
    try:
        args = arg_getters.get_selenium_runner_args(peek_mode=True)
        all_icons = filehandler.get_json_file_content(args.devicon_json_path)

        # get only the icon object that has the name matching the pr title
        filtered_icon = util.find_object_added_in_pr(all_icons, args.pr_title)
        check_devicon_object(filtered_icon)
        print("Icon being checked:", filtered_icon, sep="\n", end='\n\n')

        runner = PeekSeleniumRunner(args.download_path, args.geckodriver_path,
                                    args.headless)
        svgs = filehandler.get_svgs_paths([filtered_icon],
                                          args.icons_folder_path, True)
        screenshot_folder = filehandler.create_screenshot_folder("./")
        svgs_with_strokes = runner.peek(svgs, screenshot_folder, filtered_icon)
        print("Task completed.")

        message = ""
        if svgs_with_strokes != []:
            svgs_str = "\n\n".join(svgs_with_strokes)
            message = "\n### WARNING -- Strokes detected in the following SVGs:\n" + svgs_str + "\n"
        filehandler.write_to_file("./err_messages.txt", message)
    except Exception as e:
        filehandler.write_to_file("./err_messages.txt", str(e))
        util.exit_with_err(e)
    finally:
        if runner is not None:
            runner.close()
Beispiel #2
0
def main():
    runner = None
    try:
        args = arg_getters.get_selenium_runner_args(True)
        new_icons = filehandler.find_new_icons(args.devicon_json_path,
                                               args.icomoon_json_path)

        if len(new_icons) == 0:
            raise Exception("No files need to be uploaded. Ending script...")

        # get only the icon object that has the name matching the pr title
        filtered_icon = find_object_added_in_this_pr(new_icons, args.pr_title)
        print("Icon being checked:", filtered_icon, sep="\n", end='\n\n')

        runner = SeleniumRunner(args.download_path, args.geckodriver_path,
                                args.headless)
        svgs = filehandler.get_svgs_paths([filtered_icon],
                                          args.icons_folder_path, True)
        screenshot_folder = filehandler.create_screenshot_folder("./")
        runner.upload_svgs(svgs, screenshot_folder)
        print("Task completed.")

        # no errors, do this so upload-artifact won't fail
        filehandler.write_to_file("./err_messages.txt", "0")
    except Exception as e:
        filehandler.write_to_file("./err_messages.txt", str(e))
        util.exit_with_err(e)
    finally:
        runner.close()
def main():
    args = arg_getters.get_selenium_runner_args()
    new_icons = filehandler.find_new_icons(args.devicon_json_path, args.icomoon_json_path)
    if len(new_icons) == 0:
        sys.exit("No files need to be uploaded. Ending script...")

    # print list of new icons
    print("List of new icons:", *new_icons, sep = "\n")
    
    runner = None
    try:
        runner = SeleniumRunner(args.download_path,
                                args.geckodriver_path, args.headless)
        runner.upload_icomoon(args.icomoon_json_path)
        svgs = filehandler.get_svgs_paths(new_icons, args.icons_folder_path, True)
        runner.upload_svgs(svgs)

        zip_name = "devicon-v1.0.zip"
        zip_path = Path(args.download_path, zip_name)
        runner.download_icomoon_fonts(zip_path)
        filehandler.extract_files(str(zip_path), args.download_path)
        filehandler.rename_extracted_files(args.download_path)
        print("Task completed.")
    except TimeoutException as e:
        util.exit_with_err("Selenium Time Out Error: \n" + str(e))
    except Exception as e:
        util.exit_with_err(e)
    finally:
        runner.close() 
def main():
    try:
        print("Please wait a few seconds...")
        args = arg_getters.get_release_message_args()

        # fetch first page by default
        data = api_handler.get_merged_pull_reqs_since_last_release(args.token)
        newIcons = []
        features = []

        print("Parsing through the pull requests")
        for pullData in data:
            authors = api_handler.find_all_authors(pullData, args.token)
            markdown = f"- [{pullData['title']}]({pullData['html_url']}) by {authors}."

            if api_handler.is_feature_icon(pullData):
                newIcons.append(markdown)
            else:
                features.append(markdown)

        print("Constructing message")
        thankYou = "A huge thanks to all our maintainers and contributors for making this release possible!"
        iconTitle = f"**{len(newIcons)} New Icons**"
        featureTitle = f"**{len(features)} New Features**"
        finalString = "{0}\n\n {1}\n{2}\n\n {3}\n{4}".format(
            thankYou, iconTitle, "\n".join(newIcons), featureTitle,
            "\n".join(features))

        print("--------------Here is the build message--------------\n",
              finalString)
        print("Script finished")
    except Exception as e:
        util.exit_with_err(e)
Beispiel #5
0
def main():
    """
    Build the icons using Icomoon. Also optimize the svgs.
    """
    runner = None
    logfile = open("log.txt", "w")
    try:
        args = arg_getters.get_selenium_runner_args()
        new_icons = get_icons_for_building(args.icomoon_json_path, args.devicon_json_path, args.token, logfile)
        if len(new_icons) == 0:
            sys.exit("No files need to be uploaded. Ending script...")

        print(f"There are {len(new_icons)} icons to be build. Here are they:", *new_icons, sep = "\n", file=logfile)

        print("Begin optimizing files...", file=logfile)
        optimize_svgs(new_icons, args.icons_folder_path, logfile=logfile)

        print("Updating the icomoon json...", file=logfile)
        update_icomoon_json(new_icons, args.icomoon_json_path, logfile)

        print("Start the building icons process...", file=logfile)
        icon_svgs = filehandler.get_svgs_paths(
            new_icons, args.icons_folder_path, icon_versions_only=True)
        zip_name = "devicon-v1.0.zip"
        zip_path = Path(args.download_path, zip_name)
        screenshot_folder = filehandler.create_screenshot_folder("./") 

        runner = BuildSeleniumRunner(args.download_path,
            args.geckodriver_path, args.headless, log_output=logfile)
        runner.build_icons(args.icomoon_json_path, zip_path,
            icon_svgs, screenshot_folder)

        filehandler.extract_files(str(zip_path), args.download_path, logfile)
        filehandler.rename_extracted_files(args.download_path, logfile)

        print("Creating the release message by querying the GitHub API...", file=logfile)
        get_release_message(args.token, logfile)

        print("Closing issues with the `in-develop` label.", file=logfile)
        issues = api_handler.get_issues_by_labels(args.token, ["in-develop"])
        issue_nums = [issue_num["number"] for issue_num in issues]
        api_handler.close_issues(args.token, issue_nums)

        print("Task completed.", file=logfile)
    except TimeoutException as e:
        util.exit_with_err(Exception("Selenium Time Out Error: \n" + str(e)), logfile)
    except Exception as e:
        util.exit_with_err(e, logfile)
    finally:
        print("Exiting", file=logfile)
        if runner is not None:
            runner.close() 
        logfile.close()
def main():
    """
    Check the quality of the svgs of the whole icons folder.
    """
    args = arg_getters.get_check_svgs_monthly_args()

    try:
        devicon_json = filehandler.get_json_file_content(
            args.devicon_json_path)
        svgs = filehandler.get_svgs_paths(devicon_json, args.icons_folder_path)
        util.check_svgs(svgs)
        print("All SVGs found were good. Task completed.")
    except Exception as e:
        util.exit_with_err(e)
Beispiel #7
0
def main():
    """
    Check the quality of the svgs IF this is an icon PR. Else, does nothing.
    If any svg error is found, create a json file called 'svg_err_messages.json'
    in the root folder that will contains the error messages.
    """
    args = arg_getters.get_check_icon_pr_args()
    try:
        all_icons = filehandler.get_json_file_content(args.devicon_json_path)

        # get only the icon object that has the name matching the pr title
        filtered_icon = util.find_object_added_in_pr(all_icons, args.pr_title)
        print("Checking devicon.json object: " + str(filtered_icon))
        devicon_err_msg = check_devicon_object(filtered_icon)

        # check the file names
        filename_err_msg = ""
        svgs = None
        try:
            svgs = filehandler.get_svgs_paths([filtered_icon],
                                              args.icons_folder_path,
                                              as_str=False)
            print("SVGs to check: ", *svgs, sep='\n')
        except ValueError as e:
            filename_err_msg = "Error found regarding filenames:\n- " + e.args[
                0]

        # check the svgs
        if svgs is None or len(svgs) == 0:
            print("No SVGs to check, ending script.")
            svg_err_msg = "Error checking SVGs: no SVGs to check. Might be caused by above issues."
        else:
            svg_err_msg = check_svgs(svgs)

        err_msg = []
        if devicon_err_msg != "":
            err_msg.append(devicon_err_msg)

        if filename_err_msg != "":
            err_msg.append(filename_err_msg)

        if svg_err_msg != "":
            err_msg.append(svg_err_msg)

        filehandler.write_to_file("./err_messages.txt", "\n\n".join(err_msg))
        print("Task completed.")
    except Exception as e:
        filehandler.write_to_file("./err_messages.txt", str(e))
        util.exit_with_err(e)
Beispiel #8
0
def main():
    """
    Build the icons using Icomoon. Also optimize the svgs.
    """
    runner = None
    try:
        args = arg_getters.get_selenium_runner_args()
        new_icons = get_icons_for_building(args.icomoon_json_path,
                                           args.devicon_json_path, args.token)
        if len(new_icons) == 0:
            sys.exit("No files need to be uploaded. Ending script...")

        print(f"There are {len(new_icons)} icons to be build. Here are they:",
              *new_icons,
              sep="\n")

        print("Begin optimizing files...")
        optimize_svgs(new_icons, args.icons_folder_path)

        print("Updating the icomoon json...")
        update_icomoon_json(new_icons, args.icomoon_json_path)

        print("Start the building icons process...")
        icon_svgs = filehandler.get_svgs_paths(new_icons,
                                               args.icons_folder_path,
                                               icon_versions_only=True)
        zip_name = "devicon-v1.0.zip"
        zip_path = Path(args.download_path, zip_name)
        screenshot_folder = filehandler.create_screenshot_folder("./")
        runner = BuildSeleniumRunner(args.download_path, args.geckodriver_path,
                                     args.headless)
        runner.build_icons(args.icomoon_json_path, zip_path, icon_svgs,
                           screenshot_folder)

        filehandler.extract_files(str(zip_path), args.download_path)
        filehandler.rename_extracted_files(args.download_path)

        print("Creating the release message by querying the GitHub API...")
        get_release_message(args.token)

        print("Task completed.")
    except TimeoutException as e:
        util.exit_with_err("Selenium Time Out Error: \n" + str(e))
    except Exception as e:
        util.exit_with_err(e)
    finally:
        if runner is not None:
            runner.close()
Beispiel #9
0
def main():
    """
    Check the quality of the svgs.
    If any svg error is found, create a json file called 'svg_err_messages.json'
    in the root folder that will contains the error messages.
    """
    args = arg_getters.get_check_svgs_on_pr_args()
    try:
        # check the svgs
        svgs = filehandler.get_added_modified_svgs(
            args.files_added_json_path, args.files_modified_json_path)
        print("SVGs to check: ", *svgs, sep='\n')

        if len(svgs) == 0:
            print("No SVGs to check, ending script.")
            return

        err_messages = util.check_svgs(svgs)
        filehandler.write_to_file("./svg_err_messages.txt", err_messages)
        print("Task completed.")
    except Exception as e:
        util.exit_with_err(e)
Beispiel #10
0
def main():
    args = arg_getters.get_selenium_runner_args(True)
    new_icons = filehandler.find_new_icons(args.devicon_json_path,
                                           args.icomoon_json_path)

    # get only the icon object that has the name matching the pr title
    filtered_icons = find_object_added_in_this_pr(new_icons, args.pr_title)

    if len(new_icons) == 0:
        sys.exit("No files need to be uploaded. Ending script...")

    if len(filtered_icons) == 0:
        message = "No icons found matching the icon name in the PR's title.\n" \
        "Ensure that a new icon entry is added in the devicon.json and the PR title matches the convention here: \n" \
        "https://github.com/devicons/devicon/blob/master/CONTRIBUTING.md#overview\n" \
        "Ending script...\n"
        sys.exit(message)

    # print list of new icons
    print("List of new icons:", *new_icons, sep="\n")
    print("Icons being uploaded:", *filtered_icons, sep="\n", end='\n\n')

    runner = None
    try:
        runner = SeleniumRunner(args.download_path, args.geckodriver_path,
                                args.headless)
        svgs = filehandler.get_svgs_paths(filtered_icons,
                                          args.icons_folder_path, True)
        screenshot_folder = filehandler.create_screenshot_folder("./")
        runner.upload_svgs(svgs, screenshot_folder)
        print("Task completed.")
    except TimeoutException as e:
        util.exit_with_err("Selenium Time Out Error: \n" + str(e))
    except Exception as e:
        util.exit_with_err(e)
    finally:
        runner.close()