analyser.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:wp-file-analyser 作者: racwn 项目源码 文件源码
def main():

    parser = create_args()
    args = parser.parse_args()

    global verbose
    verbose = args.verbose

    msg("""
                  ___ _ _                            _
                 / __|_) |                          | |
  _ _ _ ____    | |__ _| | ____     ____ ____   ____| |_   _  ___  ____  ____
 | | | |  _ \   |  __) | |/ _  )   / _  |  _ \ / _  | | | | |/___)/ _  )/ ___)
 | | | | | | |  | |  | | ( (/ /   ( ( | | | | ( ( | | | |_| |___ ( (/ /| |
  \____| ||_/   |_|  |_|_|\____)   \_||_|_| |_|\_||_|_|\__  (___/ \____)_|
       |_|                                            (____/
    """)

    msg('Setting up:')

    wpPath, otherWpPath = process_wp_dirs(args)
    if (wpPath is False) or (otherWpPath is False):
        msg('ERROR: could not get WordPress directories for comparison', True)
        sys.exit()

    # Get plugins and themes, but only when a new WordPress directory has 
    # been created.
    if not args.other_wordpress_path:
        msg('Getting plugins:')
        plugins = find_plugins(wpPath)
        for plugin in plugins:
            name = plugin['name']
            version = plugin['version']
            res = get_plugin(name, version, otherWpPath)
            if not res:
                msg("ERROR: Could not download %s %s" % (name, version), True)

        msg('Getting themes:')
        themes = find_themes(wpPath)
        for theme in themes:
            name = theme['name']
            version = theme['version']
            res = get_theme(name, version, otherWpPath)
            if not res:
                msg("ERROR: Could not download %s %s" % (name, version), True)

    msg('Comparing %s with %s' % (wpPath, otherWpPath))

    msg('Starting Analysis:')
    dcres = dircmp(wpPath, otherWpPath)
    diff, extra, missing = analyze(dcres, wpPath)

    uploadsPath = os.path.join(wpPath, 'wp-content', 'uploads')
    phpFiles = search_dir_for_exts(uploadsPath, PHP_FILE_EXTENSIONS)

    print_analysis(diff, extra, missing, phpFiles)

    if args.remove_temporary_files:
        if os.path.exists(TEMP_DIR):
            msg("Removing %s " % TEMP_DIR)
            shutil.rmtree(TEMP_DIR)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号