Logo Search packages:      
Sourcecode: samba-gtk version File versions  Download package

def sambagtk::pygwsvcctl::SvcCtlPipeManager::fetch_services (   self,
  svcctl_window 
)
Feteches a list of services from the server. svcctl_window is used to update the GUI.

Definition at line 52 of file pygwsvcctl.py.

                                           :
        """Feteches a list of services from the server. svcctl_window is used to update the GUI."""
        #note: this function is designed to be called by a secondary thread only. 
        #      If the main thread calls this then THERE WILL BE A DEADLOCK!
        del self.service_list[:]
        
        (buffer, needed, count, resume_handle) = self.pipe.EnumServicesStatusW(self.scm_handle,
            svcctl.SERVICE_TYPE_WIN32_OWN_PROCESS | svcctl.SERVICE_TYPE_WIN32_SHARE_PROCESS,
            svcctl.SERVICE_STATE_ALL, 256 * 1024,
            0)

        runtime_error = None
        current = 0.0
        gtk.gdk.threads_enter()
        svcctl_window.progressbar.show()
        gtk.gdk.threads_leave()
        
        for enum_service_status in SvcCtlPipeManager.enum_service_status_list_from_buffer(buffer, count):
            try:
                gtk.gdk.threads_enter()
                svcctl_window.set_status("Fetching service: %s." % (enum_service_status.service_name))
                svcctl_window.progressbar.set_fraction(current / count)
                gtk.gdk.threads_leave()
                current += 1.0
                service = SvcCtlPipeManager.fetch_service(self, enum_service_status.service_name)
                self.service_list.append(service)
            except RuntimeError as re:
                if re.args[0] == 5: #5 is WERR_ACCESS_DENIED
                    print "Failed to fetch service \'%s\': Access Denied." % (enum_service_status.service_name)
                else:
                    #we do this so we can continue fetching services, even if a few fetches fail.
                    print "Failed to fetch service %s: %s." % (enum_service_status.service_name, re.args[1])
                    traceback.print_exc()

        gtk.gdk.threads_enter()
        svcctl_window.progressbar.hide()
        gtk.gdk.threads_leave()


Generated by  Doxygen 1.6.0   Back to index