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():
    """
    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()
Exemplo n.º 4
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()
Exemplo n.º 5
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()