def test_desktop_file_path_conversion(self): # test 'normal' case app_install_desktop_path = ("./data/app-install/desktop/" + "deja-dup:deja-dup.desktop") installed_desktop_path = convert_desktop_file_to_installed_location( app_install_desktop_path, "deja-dup") self.assertEqual(installed_desktop_path, "./data/applications/deja-dup.desktop") # test encoded subdirectory case, e.g. e.g. kde4_soundkonverter.desktop app_install_desktop_path = ("./data/app-install/desktop/" + "soundkonverter:" + "kde4__soundkonverter.desktop") installed_desktop_path = convert_desktop_file_to_installed_location( app_install_desktop_path, "soundkonverter") self.assertEqual(installed_desktop_path, "./data/applications/kde4/soundkonverter.desktop") # test the for-purchase case (uses "software-center-agent" as its # appdetails.desktop_file value) # FIXME: this will only work if update-manager is installed app_install_desktop_path = "software-center-agent" installed_desktop_path = convert_desktop_file_to_installed_location( app_install_desktop_path, "update-manager") self.assertEqual(installed_desktop_path, "/usr/share/applications/update-manager.desktop") # test case where we don't have a value for app_install_desktop_path # (e.g. for a local .deb install, see bug LP: #768158) installed_desktop_path = convert_desktop_file_to_installed_location( None, "update-manager") # FIXME: this will only work if update-manager is installed self.assertEqual(installed_desktop_path, "/usr/share/applications/update-manager.desktop")
def test_desktop_file_path_conversion(self): # test 'normal' case app_install_desktop_path = ("./data/app-install/desktop/" + "deja-dup:deja-dup.desktop") installed_desktop_path = convert_desktop_file_to_installed_location( app_install_desktop_path, "deja-dup") self.assertEqual(installed_desktop_path, "./data/applications/deja-dup.desktop") # test encoded subdirectory case, e.g. e.g. kde4_soundkonverter.desktop app_install_desktop_path = ("./data/app-install/desktop/" + "soundkonverter:" + "kde4__soundkonverter.desktop") installed_desktop_path = convert_desktop_file_to_installed_location( app_install_desktop_path, "soundkonverter") self.assertEqual(installed_desktop_path, "./data/applications/kde4/soundkonverter.desktop") # test the for-purchase case (uses "software-center-agent" as its # appdetails.desktop_file value) # FIXME: this will only work if update-manager is installed app_install_desktop_path = "software-center-agent" installed_desktop_path = convert_desktop_file_to_installed_location( app_install_desktop_path, "update-manager") self.assertEqual(installed_desktop_path, "/usr/share/applications/update-manager.desktop") # test case where we don't have a value for app_install_desktop_path # (e.g. for a local .deb install, see bug LP: #768158) installed_desktop_path = convert_desktop_file_to_installed_location( None, "update-manager") # FIXME: this will only work if update-manager is installed self.assertEqual(installed_desktop_path, "/usr/share/applications/update-manager.desktop")
def test_purchase_via_software_center_agent(self): # test the for-purchase case (uses "software-center-agent" as its # appdetails.desktop_file value) # FIXME: this will only work if update-manager is installed app_install_desktop_path = "software-center-agent" installed_desktop_path = convert_desktop_file_to_installed_location(app_install_desktop_path, "update-manager") self.assertEqual(installed_desktop_path, "/usr/share/applications/update-manager.desktop")
def _add_application_to_unity_launcher(self, transaction_details): app = Application(pkgname=transaction_details.pkgname, appname=transaction_details.appname) appdetails = app.get_details(self.db) # convert the app-install desktop file location to the actual installed # desktop file location (or in the case of a purchased item from the # agent, generate the correct installed desktop file location) installed_desktop_file_path = ( convert_desktop_file_to_installed_location(appdetails.desktop_file, app.pkgname)) # we only add items to the launcher that have a desktop file if not installed_desktop_file_path: return # do not add apps that have no Exec entry in their desktop file # (e.g. wine, see LP: #848437 or ubuntu-restricted-extras, # see LP: #913756), also, don't add the item if NoDisplay is # specified (see LP: #1006483) if (os.path.exists(installed_desktop_file_path) and (not get_exec_line_from_desktop(installed_desktop_file_path) or is_no_display_desktop_file(installed_desktop_file_path))): return # now gather up the unity launcher info items and send the app to the # launcher service launcher_info = self._get_unity_launcher_info( app, appdetails, installed_desktop_file_path, transaction_details.trans_id) self.unity_launcher.send_application_to_launcher( transaction_details.pkgname, launcher_info)
def _add_application_to_unity_launcher(self, transaction_details): app = Application(pkgname=transaction_details.pkgname, appname=transaction_details.appname) appdetails = app.get_details(self.db) # convert the app-install desktop file location to the actual installed # desktop file location (or in the case of a purchased item from the # agent, generate the correct installed desktop file location) installed_desktop_file_path = ( convert_desktop_file_to_installed_location(appdetails.desktop_file, app.pkgname)) # we only add items to the launcher that have a desktop file if not installed_desktop_file_path: return # do not add apps that have no Exec entry in their desktop file # (e.g. wine, see LP: #848437 or ubuntu-restricted-extras, # see LP: #913756), also, don't add the item if NoDisplay is # specified (see LP: #1006483) if (os.path.exists(installed_desktop_file_path) and (not get_exec_line_from_desktop(installed_desktop_file_path) or is_no_display_desktop_file(installed_desktop_file_path))): return # now gather up the unity launcher info items and send the app to the # launcher service launcher_info = self._get_unity_launcher_info(app, appdetails, installed_desktop_file_path, transaction_details.trans_id) self.unity_launcher.send_application_to_launcher( transaction_details.pkgname, launcher_info)
def test_no_value(self): # test case where we don't have a value for app_install_desktop_path # (e.g. for a local .deb install, see bug LP: #768158) installed_desktop_path = convert_desktop_file_to_installed_location( None, "update-manager") # FIXME: this will only work if update-manager is installed self.assertEqual(installed_desktop_path, "/usr/share/applications/update-manager.desktop")
def test_no_value(self): # test case where we don't have a value for app_install_desktop_path # (e.g. for a local .deb install, see bug LP: #768158) installed_desktop_path = convert_desktop_file_to_installed_location( None, "update-manager") # FIXME: this will only work if update-manager is installed self.assertEqual(installed_desktop_path, "/usr/share/applications/update-manager.desktop")
def test_normal(self): # test 'normal' case app_install_desktop_path = ("./data/app-install/desktop/" + "deja-dup:deja-dup.desktop") installed_desktop_path = convert_desktop_file_to_installed_location( app_install_desktop_path, "deja-dup") self.assertEqual(installed_desktop_path, "./data/applications/deja-dup.desktop")
def test_normal(self): # test 'normal' case app_install_desktop_path = ("./data/app-install/desktop/" + "deja-dup:deja-dup.desktop") installed_desktop_path = convert_desktop_file_to_installed_location( app_install_desktop_path, "deja-dup") self.assertEqual(installed_desktop_path, "./data/applications/deja-dup.desktop")
def test_purchase_via_software_center_agent(self): # test the for-purchase case (uses "software-center-agent" as its # appdetails.desktop_file value) # FIXME: this will only work if update-manager is installed app_install_desktop_path = "software-center-agent" installed_desktop_path = convert_desktop_file_to_installed_location( app_install_desktop_path, "update-manager") self.assertEqual(installed_desktop_path, "/usr/share/applications/update-manager.desktop")
def test_encoded_subdir(self): # test encoded subdirectory case, e.g. e.g. kde4_soundkonverter.desktop app_install_desktop_path = ("./data/app-install/desktop/" + "soundkonverter:" + "kde4__soundkonverter.desktop") installed_desktop_path = convert_desktop_file_to_installed_location( app_install_desktop_path, "soundkonverter") self.assertEqual(installed_desktop_path, "./data/applications/kde4/soundkonverter.desktop")
def test_encoded_subdir(self): # test encoded subdirectory case, e.g. e.g. kde4_soundkonverter.desktop app_install_desktop_path = os.path.join( DATA_DIR, "app-install", "desktop", "soundkonverter:kde4__soundkonverter.desktop" ) installed_desktop_path = convert_desktop_file_to_installed_location(app_install_desktop_path, "soundkonverter") self.assertEqual( installed_desktop_path, os.path.join(DATA_DIR, "applications", "kde4", "soundkonverter.desktop") )
def test_encoded_subdir(self): # test encoded subdirectory case, e.g. e.g. kde4_soundkonverter.desktop app_install_desktop_path = ("./data/app-install/desktop/" + "soundkonverter:" + "kde4__soundkonverter.desktop") installed_desktop_path = convert_desktop_file_to_installed_location( app_install_desktop_path, "soundkonverter") self.assertEqual(installed_desktop_path, "./data/applications/kde4/soundkonverter.desktop")
def test_normal(self): # test 'normal' case app_install_desktop_path = os.path.join(DATA_DIR, "app-install", "desktop", "deja-dup:deja-dup.desktop") installed_desktop_path = convert_desktop_file_to_installed_location( app_install_desktop_path, "deja-dup") self.assertEqual( installed_desktop_path, os.path.join(DATA_DIR, "applications", "deja-dup.desktop"))
def test_encoded_subdir(self): # test encoded subdirectory case, e.g. e.g. kde4_soundkonverter.desktop app_install_desktop_path = os.path.join( DATA_DIR, "app-install", "desktop", "soundkonverter:kde4__soundkonverter.desktop") installed_desktop_path = convert_desktop_file_to_installed_location( app_install_desktop_path, "soundkonverter") self.assertEqual( installed_desktop_path, os.path.join(DATA_DIR, "applications", "kde4", "soundkonverter.desktop"))
def _check_unity_launcher_transaction_finished(self, result): # add the completed transaction details to the corresponding # launcher_item if result.pkgname in self.unity_launcher_items: launcher_info = self.unity_launcher_items[result.pkgname] launcher_info.icon_file_path = get_file_path_from_iconname( self.icons, launcher_info.icon_name) installed_path = convert_desktop_file_to_installed_location( launcher_info.app_install_desktop_file_path, result.pkgname) launcher_info.installed_desktop_file_path = installed_path # if the request to add to launcher has already been made, do it now if launcher_info.add_to_launcher_requested: if result.success: self._send_dbus_signal_to_unity_launcher(launcher_info) self.unity_launcher_items.pop(result.pkgname) self.action_bar.clear()
def _check_unity_launcher_transaction_finished(self, result): # add the completed transaction details to the corresponding # launcher_item if result.pkgname in self.unity_launcher_items: launcher_info = self.unity_launcher_items[result.pkgname] launcher_info.icon_file_path = get_file_path_from_iconname( self.icons, launcher_info.icon_name) installed_path = convert_desktop_file_to_installed_location( launcher_info.app_install_desktop_file_path, result.pkgname) launcher_info.installed_desktop_file_path = installed_path # if the request to add to launcher has already been made, do it now if launcher_info.add_to_launcher_requested: if result.success: self._send_dbus_signal_to_unity_launcher(launcher_info) self.unity_launcher_items.pop(result.pkgname) self.action_bar.clear()
def guess_final_desktop_file(self): if self.__real_desktop: return self.__real_desktop # convert the app-install desktop file location to the actual installed # desktop file location (or in the case of a purchased item from the # agent, generate the correct installed desktop file location) desktop_file = ( convert_desktop_file_to_installed_location(self.desktop_file, self.app.pkgname)) # we only add items to the launcher that have a desktop file if not desktop_file: return # do not add apps that have no Exec entry in their desktop file # (e.g. wine, see LP: #848437 or ubuntu-restricted-extras, # see LP: #913756), also, don't add the item if NoDisplay is # specified (see LP: #1006483) if (os.path.exists(desktop_file) and (not get_exec_line_from_desktop(desktop_file) or is_no_display_desktop_file(desktop_file))): return self.__real_desktop = desktop_file return self.__real_desktop
def test_normal(self): # test 'normal' case app_install_desktop_path = os.path.join(DATA_DIR, "app-install", "desktop", "deja-dup:deja-dup.desktop") installed_desktop_path = convert_desktop_file_to_installed_location(app_install_desktop_path, "deja-dup") self.assertEqual(installed_desktop_path, os.path.join(DATA_DIR, "applications", "deja-dup.desktop"))