~mvo/aptdaemon/0.3-fix-race-597017

« back to all changes in this revision

Viewing changes to aptdaemon/client.py

  • Committer: sebi at glatzor
  • Date: 2010-09-04 06:57:05 UTC
  • mfrom: (477.1.1 make-trans)
  • Revision ID: sebi@glatzor.de-20100904065705-1s685x94s0hiwed9
Merge with make-trans branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
697
697
 
698
698
    @defer.deferable
699
699
    @convert_dbus_exception
700
 
    def add_repository(self, src_type, uri, dist, comps=[], comment="", 
701
 
                       sourcesfile="", reply_handler=None, error_handler=None):
 
700
    def add_repository(self, src_type, uri, dist, comps=[], comment="",
 
701
                       sourcesfile="", wait=False, reply_handler=None,
 
702
                       error_handler=None):
702
703
        """Add repository to the sources list.
703
704
 
704
705
        Keyword arguments:
708
709
        comps -- a (possible empty) list of components (main, restricted)
709
710
        comment -- an (optional) comment
710
711
        sourcesfile -- an (optinal) filename in sources.list.d 
 
712
        wait - if True run the transaction immediately and return its exit
 
713
            state instead of the transaction itself.
711
714
        reply_handler - callback function. If specified in combination with
712
715
            error_handler the method will be called asynchrounsouly.
713
716
        error_handler - in case of an error the given callback gets the
714
717
            corresponding DBus exception instance
715
718
         """
716
 
        daemon = get_aptdaemon()
717
719
        # dbus can not deal with empty lists and will error
718
720
        if comps == []:
719
721
            comps = [""]
720
 
        return daemon.AddRepository(src_type, uri, dist, comps, comment,
721
 
                                    sourcesfile, reply_handler=reply_handler,
722
 
                                    error_handler=error_handler)
 
722
        return self._run_transaction("AddRepository",
 
723
                                     [src_type, uri, dist, comps, comment,
 
724
                                      sourcesfile],
 
725
                                     wait, reply_handler, error_handler)
723
726
 
724
727
    @defer.deferable
725
728
    @convert_dbus_exception
921
924
 
922
925
    @defer.deferable
923
926
    @convert_dbus_exception
924
 
    def enable_distro_component(self, component, reply_handler=None,
 
927
    def enable_distro_component(self, component, wait=True, reply_handler=None,
925
928
                                error_handler=None):
926
929
        """Add component to the sources list.
927
930
 
931
934
            error_handler the method will be called asynchrounsouly.
932
935
        error_handler - in case of an error the given callback gets the
933
936
            corresponding DBus exception instance
934
 
         """
935
 
        daemon = get_aptdaemon()
936
 
        return daemon.EnableDistroComponent(component,
937
 
                                            reply_handler=reply_handler,
938
 
                                            error_handler=error_handler)
 
937
        """
 
938
        return self._run_transaction("EnableDistroComponent", [component],
 
939
                                     wait, reply_handler, error_handler)
939
940
 
940
941
    def _run_transaction(self, method_name, args, wait, reply_handler,
941
942
                         error_handler):