~ubuntu-branches/ubuntu/trusty/click/trusty

« back to all changes in this revision

Viewing changes to lib/click/database.vala

  • Committer: Package Import Robot
  • Author(s): Ubuntu daily release, Colin Watson
  • Date: 2014-04-08 09:41:55 UTC
  • Revision ID: package-import@ubuntu.com-20140408094155-4dm3211n5afrdorr
Tags: 0.4.21.1
[ Colin Watson ]
* When a hook command fails, include the command in the error message.
* Don't allow failure of a single hook to prevent other hooks being run.
* Log hook failures to stderr and exit non-zero, rather than propagating
  an exception which is then logged as a click crash.

Show diffs side-by-side

added added

removed removed

Lines of Context:
107
107
         *
108
108
         * Returns: True if this version of this package is unpacked in this
109
109
         * database, otherwise false.
 
110
         *
 
111
         * Since: 0.4.18
110
112
         */
111
113
        public bool
112
114
        has_package_version (string package, string version)
177
179
         * of this package.  The manifest may include additional dynamic
178
180
         * keys (starting with an underscore) corresponding to dynamic
179
181
         * properties of installed packages.
 
182
         *
 
183
         * Since: 0.4.18
180
184
         */
181
185
        public Json.Object
182
186
        get_manifest (string package, string version) throws DatabaseError
213
217
                return manifest;
214
218
        }
215
219
 
 
220
        /**
 
221
         * get_manifest_as_string:
 
222
         * @package: A package name.
 
223
         * @version: A version string.
 
224
         *
 
225
         * Returns: A JSON string containing the serialised manifest of this
 
226
         * version of this package.  The manifest may include additional
 
227
         * dynamic keys (starting with an underscore) corresponding to
 
228
         * dynamic properties of installed packages.
 
229
         * This interface may be useful for clients with their own JSON
 
230
         * parsing tools that produce representations more convenient for
 
231
         * them.
 
232
         *
 
233
         * Since: 0.4.21
 
234
         */
 
235
        public string
 
236
        get_manifest_as_string (string package, string version)
 
237
        throws DatabaseError
 
238
        {
 
239
                var manifest = get_manifest (package, version);
 
240
                var node = new Json.Node (Json.NodeType.OBJECT);
 
241
                node.set_object (manifest);
 
242
                var generator = new Json.Generator ();
 
243
                generator.set_root (node);
 
244
                return generator.to_data (null);
 
245
        }
 
246
 
216
247
        /*
217
248
         * app_running:
218
249
         * @package: A package name.
673
704
         *
674
705
         * Returns: A #Json.Object containing the manifest of this version
675
706
         * of this package.
 
707
         *
 
708
         * Since: 0.4.18
676
709
         */
677
710
        public Json.Object
678
711
        get_manifest (string package, string version) throws DatabaseError
692
725
        }
693
726
 
694
727
        /**
 
728
         * get_manifest_as_string:
 
729
         * @package: A package name.
 
730
         * @version: A version string.
 
731
         *
 
732
         * Returns: A JSON string containing the serialised manifest of this
 
733
         * version of this package.
 
734
         * This interface may be useful for clients with their own JSON
 
735
         * parsing tools that produce representations more convenient for
 
736
         * them.
 
737
         *
 
738
         * Since: 0.4.21
 
739
         */
 
740
        public string
 
741
        get_manifest_as_string (string package, string version)
 
742
        throws DatabaseError
 
743
        {
 
744
                var manifest = get_manifest (package, version);
 
745
                var node = new Json.Node (Json.NodeType.OBJECT);
 
746
                node.set_object (manifest);
 
747
                var generator = new Json.Generator ();
 
748
                generator.set_root (node);
 
749
                return generator.to_data (null);
 
750
        }
 
751
 
 
752
        /**
695
753
         * get_manifests:
696
754
         * @all_versions: If true, return manifests for all versions, not
697
755
         * just current ones.
700
758
         * this database.  The manifest may include additional dynamic keys
701
759
         * (starting with an underscore) corresponding to dynamic properties
702
760
         * of installed packages.
 
761
         *
 
762
         * Since: 0.4.18
703
763
         */
704
764
        public Json.Array
705
765
        get_manifests (bool all_versions = false) throws Error
706
766
        {
707
767
                var ret = new Json.Array ();
708
768
                foreach (var inst in get_packages (all_versions)) {
709
 
                        var obj = get_manifest (inst.package, inst.version);
 
769
                        Json.Object obj;
 
770
                        try {
 
771
                                obj = get_manifest
 
772
                                        (inst.package, inst.version);
 
773
                        } catch (DatabaseError e) {
 
774
                                warning ("%s", e.message);
 
775
                                continue;
 
776
                        }
710
777
                        /* This should really be a boolean, but it was
711
778
                         * mistakenly made an int when the "_removable" key
712
779
                         * was first created.  We may change this in future.
718
785
                return ret;
719
786
        }
720
787
 
 
788
        /**
 
789
         * get_manifests_as_string:
 
790
         * @all_versions: If true, return manifests for all versions, not
 
791
         * just current ones.
 
792
         *
 
793
         * Returns: A JSON string containing a serialised array of manifests
 
794
         * of all packages in this database.  The manifest may include
 
795
         * additional dynamic keys (starting with an underscore)
 
796
         * corresponding to dynamic properties of installed packages.
 
797
         * This interface may be useful for clients with their own JSON
 
798
         * parsing tools that produce representations more convenient for
 
799
         * them.
 
800
         *
 
801
         * Since: 0.4.21
 
802
         */
 
803
        public string
 
804
        get_manifests_as_string (bool all_versions = false) throws Error
 
805
        {
 
806
                var manifests = get_manifests (all_versions);
 
807
                var node = new Json.Node (Json.NodeType.ARRAY);
 
808
                node.set_array (manifests);
 
809
                var generator = new Json.Generator ();
 
810
                generator.set_root (node);
 
811
                return generator.to_data (null);
 
812
        }
 
813
 
721
814
        public void
722
815
        maybe_remove (string package, string version) throws Error
723
816
        {