[Dextrose] [olpc-updater PATCH] au#825: Check for a existence for an already existing "library" bundle; else the corresponding "activity" will be continued to be shown as new in "Software-Update".
Rafael Ortiz
rafael at activitycentral.com
Thu Mar 15 11:57:51 EDT 2012
On Thu, Mar 15, 2012 at 4:26 AM, Jerry Vonau <jvonau at shaw.ca> wrote:
> On Thu, 2012-03-15 at 12:07 +0530, Ajay Garg wrote:
> > diff --git a/extensions/cpsection/updater/model.py
> b/extensions/cpsection/updater/model.py
> > index 974c050..60195c7 100755
> > --- a/extensions/cpsection/updater/model.py
> > +++ b/extensions/cpsection/updater/model.py
> > @@ -413,7 +413,11 @@ class UpdateList(gtk.ListStore):
> > zf.getinfo('%s/activity/activity.info' % activity_base)
> > is_activity = True
> > except KeyError:
> > - is_activity = False
> > + try:
> > + zf.getinfo('%s/library/library.info' %
> activity_base)
> > + is_activity = True
> > + except:
> > + is_activity = False
> > if is_activity:
> > cp = actutils.activity_info_from_zipfile(zf)
> > SECTION = 'Activity'
>
> How about this:
> --- src/model.py.orig 2011-05-30 15:16:53.000000000 -0500
> +++ src/model.py 2012-03-15 03:59:53.630674825 -0500
> @@ -411,16 +411,18 @@
> activity_base = actutils.bundle_base_from_zipfile(zf)
> try:
> zf.getinfo('%s/activity/activity.info' % activity_base)
> - is_activity = True
> - except KeyError:
> - is_activity = False
> - if is_activity:
> cp = actutils.activity_info_from_zipfile(zf)
> SECTION = 'Activity'
> - else:
> - cp = actutils.library_info_from_zipfile(zf)
> - SECTION = 'Library'
> - act_id = None
> + except KeyError:
> + try:
> + # grab data from library.info file
> + zf.getinfo('%s/library/library.info' %
> activity_base)
> + act_id = None
> + cp = actutils.library_info_from_zipfile(zf)
> + SECTION = 'Library'
> + execpt:
> + raise RuntimeError("zf not found for %s" %zf)
> +
> for fieldname in ('bundle_id', 'service_name',
> 'global_name'):
> if cp.has_option(SECTION, fieldname):
> act_id = cp.get(SECTION, fieldname)
>
>
>
>
> _______________________________________________
> Dextrose mailing list
> Dextrose at lists.sugarlabs.org
> http://lists.sugarlabs.org/listinfo/dextrose
>
An outsider comment:
Jerry's solution is more informative, although both
(Ajay and Jerry) reach the same ends it's better to have more descriptive
ifs and errors.
Cheers.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sugarlabs.org/archive/dextrose/attachments/20120315/61eddbfd/attachment.html>
More information about the Dextrose
mailing list