Exemplo n.º 1
0
 def nsc_findNS(self, ident=None):
    """
    Locating the Name Server by using given nsHost and nsPort
    """
    locator = NameServerLocator(identification=ident)
    try:
       if self.nsHost:
          self._log('connecting to Name Server (%s:%s)' % (self.nsHost,
                                                           self.nsPort))
          self.NS = locator.getNS(self.nsHost, self.nsPort, trace=1, bcaddr=self.bcAddr)
       else:
          self._log('broadcasting to find Name Server')
          self.NS = locator.getNS(None, None, trace = 1, bcaddr=self.bcAddr) 
          self.nsHost = self.NS.URI.address
          self.nsPort = self.NS.URI.port
       self.NS._setIdentification(ident)
       self._log('Name Server found, URI = %s' % self.NS.URI)
       self._setNSData()
    except ConnectionDeniedError, e:
       if str(e).find( Pyro.constants.deniedReasons[Pyro.constants.DENIED_SECURITY] ) != -1:
          msg = 'Authentication required:'
          dlg = wx.TextEntryDialog(self, msg, 'Authentication',
                                  style=wx.OK|wx.CANCEL|wx.TE_PASSWORD)
          dlg.CentreOnParent()
          if dlg.ShowModal() == wx.ID_OK:
             ident = dlg.GetValue()
             self.nsc_findNS(ident)
          else:
             self.NS = None
             self._log('Connection to Name Server denied!','error')
       else:
          self.NS = None
          self._logError('Unable to connect to Name Server')
Exemplo n.º 2
0
 def nsc_findNS(self, ident=None):
    """
    Locating the Name Server by using given nsHost and nsPort
    """
    locator = NameServerLocator(identification=ident)
    try:
       if self.nsHost:
          self._log('connecting to Name Server (%s:%s)' % (self.nsHost,
                                                           self.nsPort))
          self.NS = locator.getNS(self.nsHost, self.nsPort, trace=1, bcaddr=self.bcAddr)
       else:
          self._log('broadcasting to find Name Server')
          self.NS = locator.getNS(None, None, trace = 1, bcaddr=self.bcAddr) 
          self.nsHost = self.NS.URI.address
          self.nsPort = self.NS.URI.port
       self.NS._setIdentification(ident)
       self._log('Name Server found, URI = %s' % self.NS.URI)
       self._setNSData()
    except ConnectionDeniedError, e:
       if str(e).find( Pyro.constants.deniedReasons[Pyro.constants.DENIED_SECURITY] ) != -1:
          msg = 'Authentication required:'
          dlg = wx.TextEntryDialog(self, msg, 'Authentication',
                                  style=wx.OK|wx.CANCEL|wx.TE_PASSWORD)
          dlg.CentreOnParent()
          if dlg.ShowModal() == wx.ID_OK:
             ident = dlg.GetValue()
             self.nsc_findNS(ident)
          else:
             self.NS = None
             self._log('Connection to Name Server denied!','error')
       else:
          self.NS = None
          self._logError('Unable to connect to Name Server')
Exemplo n.º 3
0
Arquivo: nsc.py Projeto: aacevedor/dbs
	def connect(self, sysCmd=None):
		host = self.Args.getOpt('h',None)
		bcaddr = self.Args.getOpt('c',None)
		port = int(self.Args.getOpt('p', 0))
		ident = self.Args.getOpt('i',None)
		if port==0:
			port=None

		locator = NameServerLocator(identification=ident)
		if not sysCmd:
			self.NS = locator.getNS(host,port,1,bcaddr=bcaddr)
			print 'NS is at',self.NS.URI.address,'('+(getHostname(self.NS.URI.address) or '??')+') port',self.NS.URI.port
			self.NS._setIdentification(ident)
		else:
			result = locator.sendSysCommand(sysCmd,host,port,1,bcaddr=bcaddr)
			print 'Result from system command',sysCmd,':',result