本文整理汇总了Python中sugar3.bundle.activitybundle.ActivityBundle.get_start_uri方法的典型用法代码示例。如果您正苦于以下问题:Python ActivityBundle.get_start_uri方法的具体用法?Python ActivityBundle.get_start_uri怎么用?Python ActivityBundle.get_start_uri使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sugar3.bundle.activitybundle.ActivityBundle
的用法示例。
在下文中一共展示了ActivityBundle.get_start_uri方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: resume
# 需要导入模块: from sugar3.bundle.activitybundle import ActivityBundle [as 别名]
# 或者: from sugar3.bundle.activitybundle.ActivityBundle import get_start_uri [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))
示例2: resume
# 需要导入模块: from sugar3.bundle.activitybundle import ActivityBundle [as 别名]
# 或者: from sugar3.bundle.activitybundle.ActivityBundle import get_start_uri [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))