Пример #1
0
    def scan(self, gateway="auto", silent=False):
        if gateway == "auto":
            gateway = self.findGatewayConnection()
        if gateway is not None:
            gw = gateway.initConnect()
        else:
            gw = None
        done = asyncio.get_event_loop().run_until_complete(
            self.asyncScan(gw, silent))
        try:
            gw.close()
        except:
            pass

        if gateway is None:
            gwHost = None
        else:
            gwHost = gateway.getEndpoint().getHost()
            if gwHost is None:
                return done
        from baboossh.path import Path
        p = Path(gwHost, self)
        if done:
            p.save()
        else:
            if p.getId() is not None:
                p.delete()
        return done
Пример #2
0
 def delPath(self,src,dst):
     if src.lower() != "local":
         if src not in self.getHostsNames():
             print("Not a known Host name.")
             return False
         
         hosts = Host.findByName(src)
         if len(hosts) > 1:
             print("Several hosts corresponding. Add failed")
             return False
         src = hosts[0]
         if src is None:
             print("The source Host provided doesn't exist in this workspace")
             return False
     else:
         src = None
     try:
         dst = Endpoint.findByIpPort(dst)
     except:
         print("Please specify valid destination endpoint in the IP:PORT form")
     if dst is None:
         print("The destination endpoint provided doesn't exist in this workspace")
         return False
     p = Path(src,dst)
     if p.getId() is None:
         print("The specified Path doesn't exist in this workspace.")
         return False
     return p.delete()