def download_plugin(plugin, prefix=''): """ Download plugin. This function takes two parameters. The first is the plugin. The plugin must be a dictionary returned by bukget with at least the following fields: versions.download, plugin_name, versions.md5, versions.filename The second parameter is a prefix to print before each output line, typically a counter on which download this it. Example: ( 5/20) """ target_folder = common.find_plugins_folder() + '/' url = plugin['versions'][0]['download'] filename = common.format_name(plugin['plugin_name']) md5 = plugin['versions'][0]['md5'] suffix = plugin['versions'][0]['filename'].split('.')[-1] full_name = target_folder + filename + '.' + suffix common.download(url, destination=full_name, checksum=md5, prefix=prefix, display_name=filename) if suffix == 'zip': print(' ' * len(prefix) + 'Unzipping...', end=' ') unzip_plugin(full_name, target_folder) os.remove(full_name) print('Success')
def download_plugin(plugin, prefix=''): """ Download plugin. This function takes two parameters. The first is the plugin. The plugin must be a dictionary returned by bukget with at least the following fields: versions.download, plugin_name, versions.md5, versions.filename The second parameter is a prefix to print before each output line, typically a counter on which download this it. Example: ( 5/20) """ target_folder = common.find_plugins_folder() + '/' url = plugin['versions'][0]['download'] filename = common.format_name(plugin['plugin_name']) md5 = plugin['versions'][0]['md5'] suffix = plugin['versions'][0]['filename'].split('.')[-1] full_name = target_folder + filename + '.' + suffix common.download(url, destination=full_name, checksum=md5, prefix=prefix, display_name=filename) if suffix == 'zip': print(' '*len(prefix) + 'Unzipping...', end=' ') unzip_plugin(full_name, target_folder) os.remove(full_name) print('Success')
def parse_installed_plugins(workers=4): """ Parse installed plugins for some information. The information is returned in a tuple like this: (jar checksum, main class, plugin name, plugin version, jar path) These tuples are put in a set. """ folder = common.find_plugins_folder() + '/' jars = [ folder + f for f in os.listdir(folder) if os.path.isfile(folder + f) and f.endswith('.jar') ] jar_queue = Queue() for jar in jars: jar_queue.put(jar) result_queue = Queue(len(jars)) threads = list() for _ in range(workers): thread = threading.Thread(target=parse_installed_plugins_worker, args=(jar_queue, result_queue)) thread.daemon = True thread.start() threads.append(thread) # Wait for all jars to be claimed jar_queue.join() # Wait for all threads to finish for thread in threads: thread.join() plugins = set() while not result_queue.empty(): plugins.add(result_queue.get()) return plugins
def parse_installed_plugins(workers=4): """ Parse installed plugins for some information. The information is returned in a tuple like this: (jar checksum, main class, plugin name, plugin version, jar path) These tuples are put in a set. """ folder = common.find_plugins_folder() + '/' jars = [folder + f for f in os.listdir(folder) if os.path.isfile(folder + f) and f.endswith('.jar')] jar_queue = Queue() for jar in jars: jar_queue.put(jar) result_queue = Queue(len(jars)) threads = list() for _ in range(workers): thread = threading.Thread(target=parse_installed_plugins_worker, args=(jar_queue, result_queue)) thread.daemon = True thread.start() threads.append(thread) # Wait for all jars to be claimed jar_queue.join() # Wait for all threads to finish for thread in threads: thread.join() plugins = set() while not result_queue.empty(): plugins.add(result_queue.get()) return plugins