Exemplo n.º 1
0
def main():
    args = util.get_commandline_args()
    new_icons = filehandler.find_new_icons(args.devicon_json_path,
                                           args.icomoon_json_path)
    if len(new_icons) == 0:
        print("No files need to be uploaded. Ending script...")
        return

    # 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)
        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:
        print(e)
        print(e.stacktrace)
    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() 
Exemplo n.º 3
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()
Exemplo n.º 4
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()
Exemplo n.º 5
0
def main():
    """
    Check the quality of the svgs.
    If any error is found, set an environmental variable called ERR_MSGS
    that will contains the error messages.
    """
    args = arg_getters.get_check_svgs_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("SVGs being checked:", *new_icons, sep = "\n", end='\n\n')

    time.sleep(1)  # do this so the logs stay clean
    try:
        # check the svgs
        svgs = filehandler.get_svgs_paths(new_icons, args.icons_folder_path, as_str=False)
        check_svgs(svgs)
        print("All SVGs found were good.\nTask completed.")
    except Exception as e:
        github_env.set_env_var("ERR_MSGS", str(e))
        sys.exit(str(e))
Exemplo n.º 6
0
def main():
    parser = ArgumentParser(
        description="Upload svgs to Icomoon to create icon files.")

    parser.add_argument(
        "--headless",
        help="Whether to run the browser in headless/no UI mode",
        action="store_true")

    parser.add_argument("geckodriver_path",
                        help="The path to the firefox executable file",
                        action=PathResolverAction)

    parser.add_argument(
        "icomoon_json_path",
        help=
        "The path to the icomoon.json aka the selection.json created by Icomoon",
        action=PathResolverAction)

    parser.add_argument("devicon_json_path",
                        help="The path to the devicon.json",
                        action=PathResolverAction)

    parser.add_argument("icons_folder_path",
                        help="The path to the icons folder",
                        action=PathResolverAction)

    parser.add_argument(
        "download_path",
        help="The path where you'd like to download the Icomoon files to",
        action=PathResolverAction)

    args = parser.parse_args()

    new_icons = filehandler.find_new_icons(args.devicon_json_path,
                                           args.icomoon_json_path)
    if len(new_icons) == 0:
        print("No files need to be uploaded. Ending script...")
        return

    # print list of new icons, separated by comma
    print("List of new icons:")
    print(*new_icons, sep="\n")
    try:
        runner = SeleniumRunner(args.icomoon_json_path, args.download_path,
                                args.geckodriver_path, args.headless)
        runner.upload_icomoon()
        svgs = filehandler.get_svgs_paths(new_icons, args.icons_folder_path)
        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)
        runner.close()
        print("Task completed.")
    except TimeoutException as e:
        print(e)
        print(e.stacktrace)
        runner.close()