def get_downloader_properties(): downloader_files = current_app.config["DOWNLOADER_FILES"] source_available = os.path.exists(downloader_files["source.zip"]) installer_available = os.path.exists(downloader_files["installer.exe"]) setup_metadata = get_file_metadata(downloader_files["setup.exe"]) update_metadata = get_file_metadata(downloader_files["update.exe"]) properties = { "available": installer_available and setup_metadata, "source_available": source_available, "update_version": update_metadata.get("version", "") } try: if properties["available"]: properties["version_code"] = setup_metadata["version"] properties["length"] = os.path.getsize(downloader_files["installer.exe"]) properties["filename"] = "installer.exe" except KeyError: properties["available"] = False try: if source_available: properties["source_length"] = os.path.getsize(downloader_files["source.zip"]) properties["source_filename"] = "source.zip" except KeyError: properties["source_available"] = False return properties
def index(): downloader_files = current_app.config["DOWNLOADER_FILES"] installer_available = os.path.exists(downloader_files["installer.exe"]) setup_metadata = get_file_metadata(downloader_files["setup.exe"]) source_available = os.path.exists(downloader_files["source.zip"]) properties = { "available": installer_available and setup_metadata, "source_available": source_available } try: if properties["available"]: properties["version_code"] = setup_metadata["version"] properties["length"] = os.path.getsize(downloader_files["installer.exe"]) properties["filename"] = "installer.exe" except KeyError: properties["available"] = False try: if source_available: properties["source_length"] = os.path.getsize(downloader_files["source.zip"]) properties["source_filename"] = "source.zip" except KeyError: properties["source_available"] = False g.title = "Foofind download manager" return render_template( "microsite/foodownloader.html", properties = properties, mode = "download", style_alternative = request.args.get("a", 2, int) )
def update(): ''' JSON SPEC { ?"update": { ?"title": "Update available...", ?"text": "New version...", "files":[ {"url": "http://...", "version": "xyz", "argv": ["/arg1", ... ]}, ... ] }, ?"messages": [{ ?"title": "title", ?"icon": "wxART_INFORMATION" // Icon name to display, defaults to wxART_INFORMATION ?"priority": 0, // Higher priority means first shown on multiple messages, otherwhise alphabetical order by title is used ?"id": "unique_identifier", // For non repeateable messages, if not specified, message will be shown on every session ?"text": "Text...", ?"url": "http://...", ?"size": [-1,-1], // Size for embeded objects like url ?"go_url": "http//:", // Implies Go, Cancel buttons ?"go_text": "" ?"start_url": "http://...", // Implies Download, Cancel buttons ?"start_filename": "...", // Filename wich file should have on disk, if not given, last part of url will be used ?"start_argv": ["/arg1", ...] ?"start_text" ?"start_close": true // True if app needs to be closed when run. Defaults to false, }, ...] } ICONS: wxART_ERROR wxART_FOLDER_OPEN wxART_QUESTION wxART_GO_DIR_UP wxART_WARNING wxART_EXECUTABLE_FILE wxART_INFORMATION wxART_NORMAL_FILE wxART_ADD_BOOKMARK wxART_TICK_MARK wxART_DEL_BOOKMARK wxART_CROSS_MARK wxART_HELP_SIDE_PANEL wxART_MISSING_IMAGE wxART_HELP_SETTINGS wxART_NEW wxART_HELP_BOOK wxART_FILE_OPEN wxART_HELP_FOLDER wxART_FILE_SAVE wxART_HELP_PAGE wxART_FILE_SAVE_AS wxART_GO_BACK wxART_DELETE wxART_GO_FORWARD wxART_COPY wxART_GO_UP wxART_CUT wxART_GO_DOWN wxART_PASTE wxART_GO_TO_PARENT wxART_UNDO wxART_GO_HOME wxART_REDO wxART_PRINT wxART_CLOSE wxART_HELP wxART_QUIT wxART_TIP wxART_FIND wxART_REPORT_VIEW wxART_FIND_AND_REPLACE wxART_LIST_VIEW wxART_HARDDISK wxART_NEW_DIR wxART_FLOPPY wxART_FOLDER wxART_CDROM wxART_REMOVABLE ''' # TODO(felipe): counter version = request.args.get("version", "") lang = request.args.get("lang", "en") platform = request.args.get("platform", None) # Updates update_files = [] downloader_files = current_app.config["DOWNLOADER_FILES"] setup_version = get_file_metadata(downloader_files["update.exe"]).get("version", "") if version < setup_version: update_files.append({ "url": url_for(".download", instfile="update.exe", _external=True, **request.args), "version": setup_version, "argv": ["/SILENT", "/NORESTART", "/RESTARTAPPLICATIONS", "/LAUNCH", "/VERSION=%s" % version], }) response = {} if update_files: # Custom update message message_version = max(i["version"] for i in update_files) response["update"] = { "text": _("downloader_update_message", appname = current_app.config["DOWNLOADER_APPNAME"], version = message_version ), "title": _("Update available"), "files": update_files, } # Messages # TODO(felipe): remove before release response["messages"] = [ #{ #"title": "Test", #"icon": "wxART_WARNING", #"text": "This is a test server message", #"url": "http://foofind.is", #"go_url": "http://foofind.is" #}, #{ #"url": "http://foofind.is", #}, #{ #"title": "Simple message", #"icon": "wxART_FIND", #"text": "Simple text" #}, #{ #"title": "Test", #"text": "This is another server message\nin two lines", #"go_url": "http://foofind.is", #"go_text": "Open URL" #}, #{ #"title": "Download test", #"text": "Download test\n<b>What if we add this before next release?</b>", #"start_url": "http://foofind.is/en/downloader/foofind_download_manager_installer.exe", #"start_text": "Download installer", #"start_close": True, #"id":"test1", #}, ] return jsonify(response)