當前位置: 首頁>>代碼示例>>Python>>正文


Python ActivityBundle.install方法代碼示例

本文整理匯總了Python中sugar3.bundle.activitybundle.ActivityBundle.install方法的典型用法代碼示例。如果您正苦於以下問題:Python ActivityBundle.install方法的具體用法?Python ActivityBundle.install怎麽用?Python ActivityBundle.install使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在sugar3.bundle.activitybundle.ActivityBundle的用法示例。


在下文中一共展示了ActivityBundle.install方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: resume

# 需要導入模塊: from sugar3.bundle.activitybundle import ActivityBundle [as 別名]
# 或者: from sugar3.bundle.activitybundle.ActivityBundle import install [as 別名]
def resume(metadata, bundle_id=None):
    registry = bundleregistry.get_registry()

    if is_activity_bundle(metadata) and bundle_id is None:

        logging.debug("Creating activity bundle")

        file_path = model.get_file(metadata["uid"])
        bundle = ActivityBundle(file_path)
        if not registry.is_installed(bundle):
            logging.debug("Installing activity bundle")
            try:
                registry.install(bundle)
            except AlreadyInstalledException:
                _downgrade_option_alert(bundle)
                return
        else:
            logging.debug("Upgrading activity bundle")
            registry.upgrade(bundle)

        _launch_bundle(bundle)

    elif is_content_bundle(metadata) and bundle_id is None:

        logging.debug("Creating content bundle")

        file_path = model.get_file(metadata["uid"])
        bundle = ContentBundle(file_path)
        if not bundle.is_installed():
            logging.debug("Installing content bundle")
            bundle.install()

        activities = _get_activities_for_mime("text/html")
        if len(activities) == 0:
            logging.warning("No activity can open HTML content bundles")
            return

        uri = bundle.get_start_uri()
        logging.debug("activityfactory.creating with uri %s", uri)

        activity_bundle = registry.get_bundle(activities[0].get_bundle_id())
        launch(activity_bundle, uri=uri)
    else:
        activity_id = metadata.get("activity_id", "")

        if bundle_id is None:
            activities = get_activities(metadata)
            if not activities:
                logging.warning("No activity can open this object, %s.", metadata.get("mime_type", None))
                return
            bundle_id = activities[0].get_bundle_id()

        bundle = registry.get_bundle(bundle_id)

        if metadata.get("mountpoint", "/") == "/":
            object_id = metadata["uid"]
        else:
            object_id = model.copy(metadata, "/")

        launch(bundle, activity_id=activity_id, object_id=object_id, color=get_icon_color(metadata))
開發者ID:erikos,項目名稱:sugar,代碼行數:62,代碼來源:misc.py

示例2: resume

# 需要導入模塊: from sugar3.bundle.activitybundle import ActivityBundle [as 別名]
# 或者: from sugar3.bundle.activitybundle.ActivityBundle import install [as 別名]
def resume(metadata, bundle_id=None):
    registry = bundleregistry.get_registry()

    if is_activity_bundle(metadata) and bundle_id is None:

        logging.debug('Creating activity bundle')

        file_path = model.get_file(metadata['uid'])
        bundle = ActivityBundle(file_path)
        if not registry.is_installed(bundle):
            logging.debug('Installing activity bundle')
            try:
                registry.install(bundle)
            except AlreadyInstalledException:
                _downgrade_option_alert(bundle)
                return
        else:
            logging.debug('Upgrading activity bundle')
            registry.upgrade(bundle)

        _launch_bundle(bundle)

    elif is_content_bundle(metadata) and bundle_id is None:

        logging.debug('Creating content bundle')

        file_path = model.get_file(metadata['uid'])
        bundle = ContentBundle(file_path)
        if not bundle.is_installed():
            logging.debug('Installing content bundle')
            bundle.install()

        activities = _get_activities_for_mime('text/html')
        if len(activities) == 0:
            logging.warning('No activity can open HTML content bundles')
            return

        uri = bundle.get_start_uri()
        logging.debug('activityfactory.creating with uri %s', uri)

        activity_bundle = registry.get_bundle(activities[0].get_bundle_id())
        launch(activity_bundle, uri=uri)
    else:
        activity_id = metadata.get('activity_id', '')

        if bundle_id is None:
            activities = get_activities(metadata)
            if not activities:
                logging.warning('No activity can open this object, %s.',
                                metadata.get('mime_type', None))
                return
            bundle_id = activities[0].get_bundle_id()

        bundle = registry.get_bundle(bundle_id)

        if metadata.get('mountpoint', '/') == '/':
            object_id = metadata['uid']
        else:
            object_id = model.copy(metadata, '/')

        launch(bundle, activity_id=activity_id, object_id=object_id,
               color=get_icon_color(metadata))
開發者ID:axitkhurana,項目名稱:sugar,代碼行數:64,代碼來源:misc.py


注:本文中的sugar3.bundle.activitybundle.ActivityBundle.install方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。