Exemple #1
0
 def list_servers(self):
     """
     Displays every storage server declared
     """
     print '[+] Registered servers:'
     i = 0
     for server in self._db.enum():
         print ' + %s (%s)' % (server, convert_bytes(server.capacity))
         i += 1
     print '[i] %d registered server(s)' % i
Exemple #2
0
 def list_servers(self):
     """
     Displays every storage server declared
     """
     print '[+] Registered servers:'
     i = 0
     for server in self._db.enum():
         print ' + %s (%s)' % (server,convert_bytes(server.capacity))
         i += 1
     print '[i] %d registered server(s)' % i
Exemple #3
0
 def add_server(self, server):
     """
     Add a server to the servers database
     """
     _server = Server(server)
     try:
         _version = _server.get_version()
         print '[i] Remote server version is %s' % _version
         _capacity = _server.get_capacity()
         print '[i] Remote server shares %s' % convert_bytes(_server.capacity)
         if _server.check():
             _server.set_version(_version)
             _server.set_active(True)
             self._db.add(_server)
             return True
         else:
             return False
     except ServerIOError:
         return False
Exemple #4
0
 def add_server(self, server):
     """
     Add a server to the servers database
     """
     _server = Server(server)
     try:
         _version = _server.get_version()
         print '[i] Remote server version is %s' % _version
         _capacity = _server.get_capacity()
         print '[i] Remote server shares %s' % convert_bytes(
             _server.capacity)
         if _server.check():
             _server.set_version(_version)
             _server.set_active(True)
             self._db.add(_server)
             return True
         else:
             return False
     except ServerIOError:
         return False
Exemple #5
0
                print '[i] Servers list:'
                a.list_servers()
            elif args[0] == 'announce':
                print '[i] Announcing server ...'
                a.publish_server(args[1])
        else:
            if args[0] == 'update':
                #print '[i] Updating servers ...'
                a.update_servers()
            elif args[0] == 'list':
                a.list_servers()
            elif args[0] == 'size':
                quota, used, chunks = a.get_global_capacity()
                print ''
                print 'Statistics:'
                print ''
                print '- Global storage space   : %s' % convert_bytes(quota)
                print '- Used storage space     : %s' % convert_bytes(used)
                print '- # of chunks            : %d' % chunks
            elif a.is_vds_url(args[0]):
                manager = CmdLineManager()
                manager.download(args[0], options.dest_dir)
            else:
                if os.path.exists(args[0]):
                    manager = CmdLineManager()
                    manager.upload(args[0])
                else:
                    Options().print_help()
    else:
        Options().print_help()
Exemple #6
0
                print '[i] Servers list:'
                a.list_servers()
            elif args[0] == 'announce':
                print '[i] Announcing server ...'
                a.publish_server(args[1])
        else:
            if args[0] == 'update':
                #print '[i] Updating servers ...'
                a.update_servers()
            elif args[0] == 'list':
                a.list_servers()
            elif args[0] == 'size':
                quota, used, chunks = a.get_global_capacity()
                print ''
                print 'Statistics:'
                print ''
                print '- Global storage space   : %s' % convert_bytes(quota)
                print '- Used storage space     : %s' % convert_bytes(used)
                print '- # of chunks            : %d' % chunks
            elif a.is_vds_url(args[0]):
                manager = CmdLineManager()
                manager.download(args[0], options.dest_dir)
            else:
                if os.path.exists(args[0]):
                    manager = CmdLineManager()
                    manager.upload(args[0])
                else:
                    Options().print_help()
    else:
        Options().print_help()